1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:8 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>chart/chartform.h Example File</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <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.h Example File</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 | <pre>#ifndef CHARTFORM_H
|
---|
36 | #define CHARTFORM_H
|
---|
37 |
|
---|
38 | #include "element.h"
|
---|
39 |
|
---|
40 | #include <<a href="qmainwindow-h.html">qmainwindow.h</a>>
|
---|
41 | #include <<a href="qstringlist-h.html">qstringlist.h</a>>
|
---|
42 |
|
---|
43 |
|
---|
44 | class CanvasView;
|
---|
45 |
|
---|
46 | class QAction;
|
---|
47 | class QCanvas;
|
---|
48 | class QFont;
|
---|
49 | class QPrinter;
|
---|
50 | class QString;
|
---|
51 |
|
---|
52 |
|
---|
53 | class ChartForm: public <a href="qmainwindow.html">QMainWindow</a>
|
---|
54 | {
|
---|
55 | Q_OBJECT
|
---|
56 | public:
|
---|
57 | enum { MAX_ELEMENTS = 100 };
|
---|
58 | enum { MAX_RECENTFILES = 9 }; // Must not exceed 9
|
---|
59 | enum ChartType { PIE, VERTICAL_BAR, HORIZONTAL_BAR };
|
---|
60 | enum AddValuesType { NO, YES, AS_PERCENTAGE };
|
---|
61 |
|
---|
62 | ChartForm( const <a href="qstring.html">QString</a>& filename );
|
---|
63 | ~ChartForm();
|
---|
64 |
|
---|
65 | int chartType() { return m_chartType; }
|
---|
66 | void setChanged( bool changed = TRUE ) { m_changed = changed; }
|
---|
67 | void drawElements();
|
---|
68 |
|
---|
69 | <a href="qpopupmenu.html">QPopupMenu</a> *optionsMenu; // Why public? See canvasview.cpp
|
---|
70 |
|
---|
71 | protected:
|
---|
72 | virtual void closeEvent( <a href="qcloseevent.html">QCloseEvent</a> * );
|
---|
73 |
|
---|
74 | private slots:
|
---|
75 | void fileNew();
|
---|
76 | void fileOpen();
|
---|
77 | void fileOpenRecent( int index );
|
---|
78 | void fileSave();
|
---|
79 | void fileSaveAs();
|
---|
80 | void fileSaveAsPixmap();
|
---|
81 | void filePrint();
|
---|
82 | void fileQuit();
|
---|
83 | void optionsSetData();
|
---|
84 | void updateChartType( <a href="qaction.html">QAction</a> *action );
|
---|
85 | void optionsSetFont();
|
---|
86 | void optionsSetOptions();
|
---|
87 | void helpHelp();
|
---|
88 | void helpAbout();
|
---|
89 | void helpAboutQt();
|
---|
90 | void saveOptions();
|
---|
91 |
|
---|
92 | private:
|
---|
93 | void init();
|
---|
94 | void load( const <a href="qstring.html">QString</a>& filename );
|
---|
95 | bool okToClear();
|
---|
96 | void drawPieChart( const double scales[], double total, int count );
|
---|
97 | void drawVerticalBarChart( const double scales[], double total, int count );
|
---|
98 | void drawHorizontalBarChart( const double scales[], double total, int count );
|
---|
99 |
|
---|
100 | <a href="qstring.html">QString</a> valueLabel( const <a href="qstring.html">QString</a>& label, double value, double total );
|
---|
101 | void updateRecentFiles( const <a href="qstring.html">QString</a>& filename );
|
---|
102 | void updateRecentFilesMenu();
|
---|
103 | void setChartType( ChartType chartType );
|
---|
104 |
|
---|
105 | <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu;
|
---|
106 | <a href="qaction.html">QAction</a> *optionsPieChartAction;
|
---|
107 | <a href="qaction.html">QAction</a> *optionsHorizontalBarChartAction;
|
---|
108 | <a href="qaction.html">QAction</a> *optionsVerticalBarChartAction;
|
---|
109 |
|
---|
110 |
|
---|
111 | <a href="qstring.html">QString</a> m_filename;
|
---|
112 | <a href="qstringlist.html">QStringList</a> m_recentFiles;
|
---|
113 | <a href="qcanvas.html">QCanvas</a> *m_canvas;
|
---|
114 | CanvasView *m_canvasView;
|
---|
115 | bool m_changed;
|
---|
116 | ElementVector m_elements;
|
---|
117 | <a href="qprinter.html">QPrinter</a> *m_printer;
|
---|
118 | ChartType m_chartType;
|
---|
119 | AddValuesType m_addValues;
|
---|
120 | int m_decimalPlaces;
|
---|
121 | <a href="qfont.html">QFont</a> m_font;
|
---|
122 | };
|
---|
123 |
|
---|
124 | #endif
|
---|
125 | </pre><!-- eof -->
|
---|
126 | <p><address><hr><div align=center>
|
---|
127 | <table width=100% cellspacing=0 border=0><tr>
|
---|
128 | <td>Copyright © 2007
|
---|
129 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
130 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
131 | </table></div></address></body>
|
---|
132 | </html>
|
---|