source: trunk/examples/chart/chartform.h@ 165

Last change on this file since 165 was 160, checked in by dmik, 19 years ago

Imported table and iconview modules and a bunch of dependent examples from the official release 3.3.1 from Trolltech.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#ifndef CHARTFORM_H
2#define CHARTFORM_H
3
4#include "element.h"
5
6#include <qmainwindow.h>
7#include <qstringlist.h>
8
9
10class CanvasView;
11
12class QAction;
13class QCanvas;
14class QFont;
15class QPrinter;
16class QString;
17
18
19class ChartForm: public QMainWindow
20{
21 Q_OBJECT
22public:
23 enum { MAX_ELEMENTS = 100 };
24 enum { MAX_RECENTFILES = 9 }; // Must not exceed 9
25 enum ChartType { PIE, VERTICAL_BAR, HORIZONTAL_BAR };
26 enum AddValuesType { NO, YES, AS_PERCENTAGE };
27
28 ChartForm( const QString& filename );
29 ~ChartForm();
30
31 int chartType() { return m_chartType; }
32 void setChanged( bool changed = TRUE ) { m_changed = changed; }
33 void drawElements();
34
35 QPopupMenu *optionsMenu; // Why public? See canvasview.cpp
36
37protected:
38 virtual void closeEvent( QCloseEvent * );
39
40private slots:
41 void fileNew();
42 void fileOpen();
43 void fileOpenRecent( int index );
44 void fileSave();
45 void fileSaveAs();
46 void fileSaveAsPixmap();
47 void filePrint();
48 void fileQuit();
49 void optionsSetData();
50 void updateChartType( QAction *action );
51 void optionsSetFont();
52 void optionsSetOptions();
53 void helpHelp();
54 void helpAbout();
55 void helpAboutQt();
56 void saveOptions();
57
58private:
59 void init();
60 void load( const QString& filename );
61 bool okToClear();
62 void drawPieChart( const double scales[], double total, int count );
63 void drawVerticalBarChart( const double scales[], double total, int count );
64 void drawHorizontalBarChart( const double scales[], double total, int count );
65
66 QString valueLabel( const QString& label, double value, double total );
67 void updateRecentFiles( const QString& filename );
68 void updateRecentFilesMenu();
69 void setChartType( ChartType chartType );
70
71 QPopupMenu *fileMenu;
72 QAction *optionsPieChartAction;
73 QAction *optionsHorizontalBarChartAction;
74 QAction *optionsVerticalBarChartAction;
75
76
77 QString m_filename;
78 QStringList m_recentFiles;
79 QCanvas *m_canvas;
80 CanvasView *m_canvasView;
81 bool m_changed;
82 ElementVector m_elements;
83 QPrinter *m_printer;
84 ChartType m_chartType;
85 AddValuesType m_addValues;
86 int m_decimalPlaces;
87 QFont m_font;
88};
89
90#endif
Note: See TracBrowser for help on using the repository browser.