Animation of precision_vs_zoom
[ipdf/code.git] / src / controlpanel.h
1 /**
2  * Declarations for Qt4 based control panel
3  */
4 #ifndef _CONTROLPANEL_H
5 #define _CONTROLPANEL_H
6
7 //#define CONTROLPANEL_DISABLED // To turn off the control panel
8
9 #ifndef CONTROLPANEL_DISABLED
10
11
12 #include <QPushButton>
13 #include <QMainWindow>
14 #include <QWidget>
15 #include <QAction>
16 #include <QMenu>
17 #include <QMenuBar>
18 #include <QApplication>
19 #include <QTextEdit>
20 #include <QInputDialog>
21 #include <QFileDialog>
22
23
24 namespace IPDF
25 {
26         class View;
27         class Document;
28         class Screen;
29
30         /**
31          * Class to manage Qt control panel
32          * Should be a singleton from the point of view of View, Document, Screen
33          *  - Just call "Update"
34          */
35         class ControlPanel : public QMainWindow
36         {       
37                 Q_OBJECT // Having this causes shit about undefined vtables
38                                 // Not having it means things break
39                                 // Apparently you need "qmake" to build qt applications
40                                 // Or some bullshit -_-
41                 public:
42                         struct RunArgs
43                         {
44                                 int argc;
45                                 char ** argv;
46                                 View & view;
47                                 Document & doc;
48                                 Screen & screen;
49                         };
50                         
51                         static int Run(void * args);
52                         static void Update() {if (g_panel != NULL) g_panel->UpdateAll();}                       
53         
54                 private:
55                         typedef enum {
56                                 ABOUT,
57                                 INSERT_TEXT,
58                                 PARSE_SVG
59                         } State;
60                         
61                 private slots:
62                         void SetGPURendering();
63                         void SetCPURendering();
64                         void ToggleLazyRendering();
65                         void ToggleShowBezierBounds();
66                         void ToggleShowBezierType();
67                         void ToggleShowFillBounds();
68                         void ToggleShowFillPoints();
69                         void ToggleScreenDebugFont();
70                         void ToggleEnableShading();
71                         void SetViewBounds();
72                         void LoadSVGIntoDocument();
73                         void SetDocumentFont();
74                         void StateInsertText() {ChangeState(INSERT_TEXT);}
75                         void StateAbout() {ChangeState(ABOUT);}
76                         void StateParseSVG() {ChangeState(PARSE_SVG);}
77                         void PressOK() {if (m_on_ok != NULL) (this->*m_on_ok)();}
78
79                 private:
80                         static ControlPanel * g_panel;
81                         void paintEvent(QPaintEvent * e);
82                         ControlPanel(RunArgs & a, QWidget * p = NULL);
83                         virtual ~ControlPanel() {}
84                         void UpdateAll();
85                         void ChangeState(State next_state);
86                         View & m_view;
87                         Document & m_doc;
88                         Screen & m_screen;
89                         
90                         int m_width;
91                         int m_height;
92                         
93                         
94                         State m_state;
95                         
96                         QMenu * CreateMainMenu();
97                         QMenu * CreateViewMenu();
98                         QMenu * CreateDocumentMenu();
99                         QMenu * CreateScreenMenu();
100                         void CreateLayout();
101                         
102                         void InsertTextIntoDocument();
103                         void InsertSVGIntoDocument();
104                         
105                         QAction * m_screen_gpu_rendering;
106                         QAction * m_screen_cpu_rendering;
107                         QAction * m_screen_show_debug;
108                         QAction * m_screen_lazy_rendering;
109                         
110                         QAction * m_document_set_font;
111                         QAction * m_document_insert_text;
112                         QAction * m_document_parse_svg;
113                         QAction * m_document_load_svg;
114                         QAction * m_view_set_bounds;
115                         QAction * m_view_show_bezier_bounds;
116                         QAction * m_view_show_bezier_type;
117                         QAction * m_view_show_fill_bounds;
118                         QAction * m_view_show_fill_points;
119                         QAction * m_view_enable_shading;
120                         
121                 
122                         QTextEdit * m_text_edit;
123                         QPushButton * m_ok_button;
124                         
125                         void (ControlPanel::* m_on_ok)();
126
127
128         };
129
130 }
131
132 #endif //CONTROLPANEL_DISABLED
133
134 #endif //_CONTROLPANEL_H

UCC git Repository :: git.ucc.asn.au