<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/doc/tutorial2.doc:9 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > chart/chartform.cpp Example File< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > chart/chartform.cpp Example File< / h1 >
< pre > #include "canvasview.h"
#include "chartform.h"
#include "optionsform.h"
#include "setdataform.h"
#include < < a href = "tqaction-h.html" > tqaction.h< / a > >
#include < < a href = "qapplication-h.html" > ntqapplication.h< / a > >
#include < < a href = "qcombobox-h.html" > ntqcombobox.h< / a > >
#include < < a href = "qfile-h.html" > ntqfile.h< / a > >
#include < < a href = "qfiledialog-h.html" > ntqfiledialog.h< / a > >
#include < < a href = "qfont-h.html" > ntqfont.h< / a > >
#include < < a href = "qfontdialog-h.html" > ntqfontdialog.h< / a > >
#include < < a href = "tqmenubar-h.html" > tqmenubar.h< / a > >
#include < < a href = "qmessagebox-h.html" > ntqmessagebox.h< / a > >
#include < < a href = "qpixmap-h.html" > ntqpixmap.h< / a > >
#include < < a href = "tqpopupmenu-h.html" > tqpopupmenu.h< / a > >
#include < < a href = "qprinter-h.html" > ntqprinter.h< / a > >
#include < < a href = "qradiobutton-h.html" > ntqradiobutton.h< / a > >
#include < < a href = "qsettings-h.html" > ntqsettings.h< / a > >
#include < < a href = "qspinbox-h.html" > ntqspinbox.h< / a > >
#include < < a href = "tqstatusbar-h.html" > tqstatusbar.h< / a > >
#include < < a href = "tqtoolbar-h.html" > tqtoolbar.h< / a > >
#include < < a href = "tqtoolbutton-h.html" > tqtoolbutton.h< / a > >
#include "images/file_new.xpm"
#include "images/file_open.xpm"
#include "images/file_save.xpm"
#include "images/file_print.xpm"
#include "images/options_setdata.xpm"
#include "images/options_setfont.xpm"
#include "images/options_setoptions.xpm"
#include "images/options_horizontalbarchart.xpm"
#include "images/options_piechart.xpm"
#include "images/options_verticalbarchart.xpm"
const < a href = "tqstring.html" > TQString< / a > WINDOWS_REGISTRY = "/Trolltech/TQtExamples";
const < a href = "tqstring.html" > TQString< / a > APP_KEY = "/Chart/";
< a name = "f148" > < / a > ChartForm::ChartForm( const < a href = "tqstring.html" > TQString< / a > & filename )
: < a href = "tqmainwindow.html" > TQMainWindow< / a > ( 0, 0, WDestructiveClose )
{
< a href = "tqwidget.html#setIcon" > setIcon< / a > ( TQPixmap( options_piechart ) );
< a href = "tqaction.html" > TQAction< / a > *fileNewAction;
< a href = "tqaction.html" > TQAction< / a > *fileOpenAction;
< a href = "tqaction.html" > TQAction< / a > *fileSaveAction;
< a href = "tqaction.html" > TQAction< / a > *fileSaveAsAction;
< a href = "tqaction.html" > TQAction< / a > *fileSaveAsPixmapAction;
< a href = "tqaction.html" > TQAction< / a > *filePrintAction;
< a href = "tqaction.html" > TQAction< / a > *fileQuitAction;
< a href = "tqaction.html" > TQAction< / a > *optionsSetDataAction;
< a href = "tqaction.html" > TQAction< / a > *optionsSetFontAction;
< a href = "tqaction.html" > TQAction< / a > *optionsSetOptionsAction;
fileNewAction = new < a href = "tqaction.html" > TQAction< / a > (
"New Chart", TQPixmap( file_new ),
"& New", CTRL+Key_N, this, "new" );
< a name = "x2869" > < / a > < a href = "tqobject.html#connect" > connect< / a > ( fileNewAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ), this, TQ_SLOT( fileNew() ) );
fileOpenAction = new < a href = "tqaction.html" > TQAction< / a > (
"Open Chart", TQPixmap( file_open ),
"& Open...", CTRL+Key_O, this, "open" );
< a href = "tqobject.html#connect" > connect< / a > ( fileOpenAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ), this, TQ_SLOT( fileOpen() ) );
fileSaveAction = new < a href = "tqaction.html" > TQAction< / a > (
"Save Chart", TQPixmap( file_save ),
"& Save", CTRL+Key_S, this, "save" );
< a href = "tqobject.html#connect" > connect< / a > ( fileSaveAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ), this, TQ_SLOT( fileSave() ) );
fileSaveAsAction = new < a href = "tqaction.html" > TQAction< / a > (
"Save Chart As", TQPixmap( file_save ),
"Save & As...", 0, this, "save as" );
< a href = "tqobject.html#connect" > connect< / a > ( fileSaveAsAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( fileSaveAs() ) );
fileSaveAsPixmapAction = new < a href = "tqaction.html" > TQAction< / a > (
"Save Chart As Bitmap", TQPixmap( file_save ),
"Save As & Bitmap...", CTRL+Key_B, this, "save as bitmap" );
< a href = "tqobject.html#connect" > connect< / a > ( fileSaveAsPixmapAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( fileSaveAsPixmap() ) );
filePrintAction = new < a href = "tqaction.html" > TQAction< / a > (
"Print Chart", TQPixmap( file_print ),
"& Print Chart...", CTRL+Key_P, this, "print chart" );
< a href = "tqobject.html#connect" > connect< / a > ( filePrintAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( filePrint() ) );
optionsSetDataAction = new < a href = "tqaction.html" > TQAction< / a > (
"Set Data", TQPixmap( options_setdata ),
"Set & Data...", CTRL+Key_D, this, "set data" );
< a href = "tqobject.html#connect" > connect< / a > ( optionsSetDataAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( optionsSetData() ) );
< a href = "tqactiongroup.html" > TQActionGroup< / a > *chartGroup = new < a href = "tqactiongroup.html" > TQActionGroup< / a > ( this ); // Connected later
< a name = "x2874" > < / a > chartGroup-> < a href = "tqactiongroup.html#setExclusive" > setExclusive< / a > ( TRUE );
optionsPieChartAction = new < a href = "tqaction.html" > TQAction< / a > (
"Pie Chart", TQPixmap( options_piechart ),
"& Pie Chart", CTRL+Key_I, chartGroup, "pie chart" );
< a name = "x2872" > < / a > optionsPieChartAction-> < a href = "tqaction.html#setToggleAction" > setToggleAction< / a > ( TRUE );
optionsHorizontalBarChartAction = new < a href = "tqaction.html" > TQAction< / a > (
"Horizontal Bar Chart", TQPixmap( options_horizontalbarchart ),
"& Horizontal Bar Chart", CTRL+Key_H, chartGroup,
"horizontal bar chart" );
optionsHorizontalBarChartAction-> < a href = "tqaction.html#setToggleAction" > setToggleAction< / a > ( TRUE );
optionsVerticalBarChartAction = new < a href = "tqaction.html" > TQAction< / a > (
"Vertical Bar Chart", TQPixmap( options_verticalbarchart ),
"& Vertical Bar Chart", CTRL+Key_V, chartGroup, "Vertical bar chart" );
optionsVerticalBarChartAction-> < a href = "tqaction.html#setToggleAction" > setToggleAction< / a > ( TRUE );
optionsSetFontAction = new < a href = "tqaction.html" > TQAction< / a > (
"Set Font", TQPixmap( options_setfont ),
"Set & Font...", CTRL+Key_F, this, "set font" );
< a href = "tqobject.html#connect" > connect< / a > ( optionsSetFontAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( optionsSetFont() ) );
optionsSetOptionsAction = new < a href = "tqaction.html" > TQAction< / a > (
"Set Options", TQPixmap( options_setoptions ),
"Set & Options...", 0, this, "set options" );
< a href = "tqobject.html#connect" > connect< / a > ( optionsSetOptionsAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ),
this, TQ_SLOT( optionsSetOptions() ) );
fileQuitAction = new < a href = "tqaction.html" > TQAction< / a > ( "Quit", "& Quit", CTRL+Key_Q, this, "quit" );
< a href = "tqobject.html#connect" > connect< / a > ( fileQuitAction, TQ_SIGNAL( < a href = "tqaction.html#activated" > activated< / a > () ), this, TQ_SLOT( fileQuit() ) );
< a href = "tqtoolbar.html" > TQToolBar< / a > * fileTools = new < a href = "tqtoolbar.html" > TQToolBar< / a > ( this, "file operations" );
< a name = "x2895" > < / a > fileTools-> < a href = "tqtoolbar.html#setLabel" > setLabel< / a > ( "File Operations" );
< a name = "x2870" > < / a > fileNewAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileTools );
fileOpenAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileTools );
fileSaveAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileTools );
< a name = "x2894" > < / a > fileTools-> < a href = "tqtoolbar.html#addSeparator" > addSeparator< / a > ();
filePrintAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileTools );
< a href = "tqtoolbar.html" > TQToolBar< / a > *optionsTools = new < a href = "tqtoolbar.html" > TQToolBar< / a > ( this, "options operations" );
optionsTools-> < a href = "tqtoolbar.html#setLabel" > setLabel< / a > ( "Options Operations" );
optionsSetDataAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
optionsTools-> < a href = "tqtoolbar.html#addSeparator" > addSeparator< / a > ();
optionsPieChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
optionsHorizontalBarChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
optionsVerticalBarChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
optionsTools-> < a href = "tqtoolbar.html#addSeparator" > addSeparator< / a > ();
optionsSetFontAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
optionsTools-> < a href = "tqtoolbar.html#addSeparator" > addSeparator< / a > ();
optionsSetOptionsAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsTools );
fileMenu = new < a href = "tqpopupmenu.html" > TQPopupMenu< / a > ( this );
< a href = "tqmainwindow.html#menuBar" > menuBar< / a > ()-> insertItem( "& File", fileMenu );
fileNewAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileOpenAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileSaveAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileSaveAsAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
fileSaveAsPixmapAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
filePrintAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
fileMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
fileQuitAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( fileMenu );
optionsMenu = new < a href = "tqpopupmenu.html" > TQPopupMenu< / a > ( this );
< a href = "tqmainwindow.html#menuBar" > menuBar< / a > ()-> insertItem( "& Options", optionsMenu );
optionsSetDataAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
optionsMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
optionsPieChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
optionsHorizontalBarChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
optionsVerticalBarChartAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
optionsMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
optionsSetFontAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
optionsMenu-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
optionsSetOptionsAction-> < a href = "tqaction.html#addTo" > addTo< / a > ( optionsMenu );
< a href = "tqmainwindow.html#menuBar" > menuBar< / a > ()-> insertSeparator();
< a href = "tqpopupmenu.html" > TQPopupMenu< / a > *helpMenu = new < a href = "tqpopupmenu.html" > TQPopupMenu< / a > ( this );
< a href = "tqmainwindow.html#menuBar" > menuBar< / a > ()-> insertItem( "& Help", helpMenu );
helpMenu-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "& Help", this, TQ_SLOT(helpHelp()), Key_F1 );
helpMenu-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "& About", this, TQ_SLOT(helpAbout()) );
helpMenu-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "About & TQt", this, TQ_SLOT(helpAboutTQt()) );
m_printer = 0;
m_elements.resize( MAX_ELEMENTS );
< a href = "ntqsettings.html" > TQSettings< / a > settings;
< a name = "x2890" > < / a > settings.< a href = "ntqsettings.html#insertSearchPath" > insertSearchPath< / a > ( TQSettings::Windows, WINDOWS_REGISTRY );
int windowWidth = settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "WindowWidth", 460 );
int windowHeight = settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "WindowHeight", 530 );
int windowX = settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "WindowX", -1 );
int windowY = settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "WindowY", -1 );
setChartType( ChartType(
settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "ChartType", int(PIE) ) ) );
m_addValues = AddValuesType(
settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "AddValues", int(NO) ));
m_decimalPlaces = settings.< a href = "ntqsettings.html#readNumEntry" > readNumEntry< / a > ( APP_KEY + "Decimals", 2 );
m_font = TQFont( "Helvetica", 18, TQFont::Bold );
m_font.fromString(
settings.< a href = "ntqsettings.html#readEntry" > readEntry< / a > ( APP_KEY + "Font", m_font.toString() ) );
for ( int i = 0; i < MAX_RECENTFILES; ++i ) {
< a href = "tqstring.html" > TQString< / a > filename = settings.< a href = "ntqsettings.html#readEntry" > readEntry< / a > ( APP_KEY + "File" +
< a name = "x2893" > < / a > TQString::< a href = "tqstring.html#number" > number< / a > ( i + 1 ) );
< a name = "x2892" > < / a > if ( !filename.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () )
m_recentFiles.push_back( filename );
}
if ( m_recentFiles.count() )
updateRecentFilesMenu();
// Connect *after* we've set the chart type on so we don't call
// drawElements() prematurely.
< a name = "x2873" > < / a > < a href = "tqobject.html#connect" > connect< / a > ( chartGroup, TQ_SIGNAL( < a href = "tqactiongroup.html#selected" > selected< / a > (TQAction*) ),
this, TQ_SLOT( updateChartType(TQAction*) ) );
< a href = "tqwidget.html#resize" > resize< / a > ( windowWidth, windowHeight );
if ( windowX != -1 || windowY != -1 )
< a href = "tqwidget.html#move" > move< / a > ( windowX, windowY );
m_canvas = new < a href = "tqcanvas.html" > TQCanvas< / a > ( this );
< a name = "x2876" > < / a > m_canvas-> < a href = "tqcanvas.html#resize" > resize< / a > ( < a href = "tqwidget.html#width" > width< / a > (), height() );
m_canvasView = new CanvasView( m_canvas, & m_elements, this );
< a href = "tqmainwindow.html#setCentralWidget" > setCentralWidget< / a > ( m_canvasView );
m_canvasView-> < a href = "tqwidget.html#show" > show< / a > ();
if ( !filename.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () )
load( filename );
else {
init();
m_elements[0].set( 20, red, 14, "Red" );
m_elements[1].set( 70, cyan, 2, "Cyan", darkGreen );
m_elements[2].set( 35, blue, 11, "Blue" );
m_elements[3].set( 55, yellow, 1, "Yellow", darkBlue );
m_elements[4].set( 80, magenta, 1, "Magenta" );
drawElements();
}
< a href = "tqmainwindow.html#statusBar" > statusBar< / a > ()-> message( "Ready", 2000 );
}
ChartForm::~ChartForm()
{
delete m_printer;
}
void < a name = "f149" > < / a > ChartForm::init()
{
< a href = "tqwidget.html#setCaption" > setCaption< / a > ( "Chart" );
m_filename = TQString::null;
m_changed = FALSE;
m_elements[0] = Element( Element::INVALID, red );
m_elements[1] = Element( Element::INVALID, cyan );
m_elements[2] = Element( Element::INVALID, blue );
m_elements[3] = Element( Element::INVALID, yellow );
m_elements[4] = Element( Element::INVALID, green );
m_elements[5] = Element( Element::INVALID, magenta );
m_elements[6] = Element( Element::INVALID, darkYellow );
m_elements[7] = Element( Element::INVALID, darkRed );
m_elements[8] = Element( Element::INVALID, darkCyan );
m_elements[9] = Element( Element::INVALID, darkGreen );
m_elements[10] = Element( Element::INVALID, darkMagenta );
m_elements[11] = Element( Element::INVALID, darkBlue );
for ( int i = 12; i < MAX_ELEMENTS; ++i ) {
double x = (double(i) / MAX_ELEMENTS) * 360;
int y = (int(x * 256) % 105) + 151;
int z = ((i * 17) % 105) + 151;
m_elements[i] = Element( Element::INVALID, TQColor( int(x), y, z, TQColor::Hsv ) );
}
}
< a name = "x2896" > < / a > void ChartForm::< a href = "tqwidget.html#closeEvent" > closeEvent< / a > ( < a href = "qcloseevent.html" > TQCloseEvent< / a > * )
{
fileQuit();
}
void < a name = "f150" > < / a > ChartForm::fileNew()
{
if ( okToClear() ) {
init();
drawElements();
}
}
void < a name = "f151" > < / a > ChartForm::fileOpen()
{
if ( !okToClear() )
return;
< a href = "tqstring.html" > TQString< / a > filename = TQFileDialog::< a href = "ntqfiledialog.html#getOpenFileName" > getOpenFileName< / a > (
TQString::null, "Charts (*.cht)", this,
"file open", "Chart -- File Open" );
if ( !filename.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () )
load( filename );
else
< a href = "tqmainwindow.html#statusBar" > statusBar< / a > ()-> message( "File Open abandoned", 2000 );
}
void < a name = "f152" > < / a > ChartForm::fileSaveAs()
{
< a href = "tqstring.html" > TQString< / a > filename = TQFileDialog::< a href = "ntqfiledialog.html#getSaveFileName" > getSaveFileName< / a > (
TQString::null, "Charts (*.cht)", this,
"file save as", "Chart -- File Save As" );
if ( !filename.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () ) {
int answer = 0;
< a name = "x2878" > < / a > if ( TQFile::< a href = "ntqfile.html#exists" > exists< / a > ( filename ) )
< a name = "x2889" > < / a > answer = TQMessageBox::< a href = "ntqmessagebox.html#warning" > warning< / a > (
this, "Chart -- Overwrite File",
TQString( "Overwrite\n\'%1\'?" ).
arg( filename ),
"& Yes", "& No", TQString::null, 1, 1 );
if ( answer == 0 ) {
m_filename = filename;
updateRecentFiles( filename );
fileSave();
return;
}
}
< a href = "tqmainwindow.html#statusBar" > statusBar< / a > ()-> message( "Saving abandoned", 2000 );
}
void < a name = "f153" > < / a > ChartForm::fileOpenRecent( int index )
{
if ( !okToClear() )
return;
load( m_recentFiles[index] );
}
void < a name = "f154" > < / a > ChartForm::updateRecentFiles( const < a href = "tqstring.html" > TQString< / a > & filename )
{
if ( m_recentFiles.find( filename ) != m_recentFiles.end() )
return;
m_recentFiles.push_back( filename );
if ( m_recentFiles.count() > MAX_RECENTFILES )
m_recentFiles.pop_front();
updateRecentFilesMenu();
}
void < a name = "f155" > < / a > ChartForm::updateRecentFilesMenu()
{
for ( int i = 0; i < MAX_RECENTFILES; ++i ) {
< a name = "x2882" > < / a > if ( fileMenu-> < a href = "tqmenudata.html#findItem" > findItem< / a > ( i ) )
< a name = "x2885" > < / a > fileMenu-> < a href = "tqmenudata.html#removeItem" > removeItem< / a > ( i );
if ( i < int(m_recentFiles.count()) )
fileMenu-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( TQString( "& %1 %2" ).
arg( i + 1 ).arg( m_recentFiles[i] ),
this, TQ_SLOT( fileOpenRecent(int) ),
0, i );
}
}
void < a name = "f156" > < / a > ChartForm::fileQuit()
{
if ( okToClear() ) {
saveOptions();
< a name = "x2875" > < / a > tqApp-> < a href = "ntqapplication.html#exit" > exit< / a > ( 0 );
}
}
bool < a name = "f157" > < / a > ChartForm::okToClear()
{
if ( m_changed ) {
< a href = "tqstring.html" > TQString< / a > msg;
if ( m_filename.isEmpty() )
msg = "Unnamed chart ";
else
msg = TQString( "Chart '%1'\n" ).arg( m_filename );
msg += "has been changed.";
int x = TQMessageBox::< a href = "ntqmessagebox.html#information" > information< / a > ( this, "Chart -- Unsaved Changes",
msg, "& Save", "Cancel", "& Abandon",
0, 1 );
switch( x ) {
case 0: // Save
fileSave();
break;
case 1: // Cancel
default:
return FALSE;
case 2: // Abandon
break;
}
}
return TRUE;
}
void < a name = "f158" > < / a > ChartForm::saveOptions()
{
< a href = "ntqsettings.html" > TQSettings< / a > settings;
settings.< a href = "ntqsettings.html#insertSearchPath" > insertSearchPath< / a > ( TQSettings::Windows, WINDOWS_REGISTRY );
< a name = "x2891" > < / a > settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "WindowWidth", width() );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "WindowHeight", height() );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "WindowX", x() );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "WindowY", y() );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "ChartType", int(m_chartType) );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "AddValues", int(m_addValues) );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "Decimals", m_decimalPlaces );
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "Font", m_font.toString() );
for ( int i = 0; i < int(m_recentFiles.count()); ++i )
settings.< a href = "ntqsettings.html#writeEntry" > writeEntry< / a > ( APP_KEY + "File" + TQString::number( i + 1 ),
m_recentFiles[i] );
}
void < a name = "f159" > < / a > ChartForm::optionsSetData()
{
SetDataForm *setDataForm = new SetDataForm( & m_elements, m_decimalPlaces, this );
< a name = "x2877" > < / a > if ( setDataForm-> < a href = "ntqdialog.html#exec" > exec< / a > () ) {
m_changed = TRUE;
drawElements();
}
delete setDataForm;
}
void < a name = "f160" > < / a > ChartForm::setChartType( ChartType chartType )
{
m_chartType = chartType;
switch ( m_chartType ) {
case PIE:
< a name = "x2871" > < / a > optionsPieChartAction-> < a href = "tqaction.html#setOn" > setOn< / a > ( TRUE );
break;
case VERTICAL_BAR:
optionsVerticalBarChartAction-> < a href = "tqaction.html#setOn" > setOn< / a > ( TRUE );
break;
case HORIZONTAL_BAR:
optionsHorizontalBarChartAction-> < a href = "tqaction.html#setOn" > setOn< / a > ( TRUE );
break;
}
}
void < a name = "f161" > < / a > ChartForm::updateChartType( < a href = "tqaction.html" > TQAction< / a > *action )
{
if ( action == optionsPieChartAction ) {
m_chartType = PIE;
}
else if ( action == optionsHorizontalBarChartAction ) {
m_chartType = HORIZONTAL_BAR;
}
else if ( action == optionsVerticalBarChartAction ) {
m_chartType = VERTICAL_BAR;
}
drawElements();
}
void < a name = "f162" > < / a > ChartForm::optionsSetFont()
{
bool ok;
< a name = "x2881" > < / a > < a href = "ntqfont.html" > TQFont< / a > font = TQFontDialog::< a href = "ntqfontdialog.html#getFont" > getFont< / a > ( & ok, m_font, this );
if ( ok ) {
m_font = font;
drawElements();
}
}
void < a name = "f163" > < / a > ChartForm::optionsSetOptions()
{
OptionsForm *optionsForm = new OptionsForm( this );
optionsForm-> chartTypeComboBox-> setCurrentItem( m_chartType );
optionsForm-> < a href = "tqwidget.html#setFont" > setFont< / a > ( m_font );
switch ( m_addValues ) {
case NO:
optionsForm-> noRadioButton-> setChecked( TRUE );
break;
case YES:
optionsForm-> yesRadioButton-> setChecked( TRUE );
break;
case AS_PERCENTAGE:
optionsForm-> asPercentageRadioButton-> setChecked( TRUE );
break;
}
optionsForm-> decimalPlacesSpinBox-> setValue( m_decimalPlaces );
if ( optionsForm-> < a href = "ntqdialog.html#exec" > exec< / a > () ) {
setChartType( ChartType(
optionsForm-> chartTypeComboBox-> currentItem()) );
< a name = "x2897" > < / a > m_font = optionsForm-> < a href = "tqwidget.html#font" > font< / a > ();
if ( optionsForm-> noRadioButton-> isChecked() )
m_addValues = NO;
else if ( optionsForm-> yesRadioButton-> isChecked() )
m_addValues = YES;
else if ( optionsForm-> asPercentageRadioButton-> isChecked() )
m_addValues = AS_PERCENTAGE;
m_decimalPlaces = optionsForm-> decimalPlacesSpinBox-> value();
drawElements();
}
delete optionsForm;
}
void < a name = "f164" > < / a > ChartForm::helpHelp()
{
< a href = "tqmainwindow.html#statusBar" > statusBar< / a > ()-> message( "Help is not implemented yet", 2000 );
}
void < a name = "f165" > < / a > ChartForm::helpAbout()
{
< a name = "x2886" > < / a > TQMessageBox::< a href = "ntqmessagebox.html#about" > about< / a > ( this, "Chart -- About",
"< center> < h1> < font color=blue> Chart< font> < /h1> < /center> "
"< p> Chart your data with < i> chart< /i> .< /p> "
);
}
void < a name = "f166" > < / a > ChartForm::helpAboutTQt()
{
< a name = "x2887" > < / a > TQMessageBox::< a href = "ntqmessagebox.html#aboutTQt" > aboutTQt< / a > ( this, "Chart -- About TQt" );
}
< / pre > <!-- eof -->
< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >