]> Shamusworld >> Repos - architektonas/blob - src/mainapp/applicationwindow.h
In the middle of chasing down MDI not activating bug, renaming of Graphic to
[architektonas] / src / mainapp / applicationwindow.h
1 #ifndef __APPLICATIONWINDOW_H__
2 #define __APPLICATIONWINDOW_H__
3
4 #include <QtGui>
5
6 #include "document.h"
7 #include "qc_dialogfactory.h"
8 #include "mdiwindow.h"
9 #include "actionhandler.h"
10 #include "blockwidget.h"
11 #include "layerwidget.h"
12 #include "qg_mainwindowinterface.h"
13 #include "pentoolbar.h"
14 #include "cadtoolbar.h"
15 #include "commandwidget.h"
16 #include "librarywidget.h"
17
18 #ifdef SCRIPTING
19 #include "qs_scripter.h"
20 #include <qsproject.h>
21 #endif
22
23 #ifdef RS_CAM
24 #include "simulationcontrols.h"
25 #endif
26
27 class RecentFiles;
28
29 /**
30  * Main application window. Hold together document, view and controls.
31  *
32  * @author James Hammons
33  * @author Andrew Mustun
34  */
35 class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface
36 {
37         Q_OBJECT
38
39         public:
40                 ApplicationWindow();
41                 ~ApplicationWindow();
42
43                 void initActions();
44                 void initMenuBar();
45                 void initToolBar();
46                 void initStatusBar();
47                 void initSettings();
48                 void storeSettings();
49                 void initMDI();
50                 void initView();
51                 bool QueryExit(void);
52
53                 /** Catch hotkey for giving focus to command line. */
54                 virtual void keyPressEvent(QKeyEvent * e);
55                 virtual void keyReleaseEvent(QKeyEvent * e);
56
57         public slots:
58                 virtual void show();
59                 void finishSplashScreen();
60                 void slotFocus();
61                 void slotBack();
62                 void slotEnter();
63                 void slotFocusCommandLine();
64                 void slotError(const QString & msg);
65
66                 void slotWindowActivated(QMdiSubWindow * w);
67                 void slotWindowsMenuAboutToShow();
68                 void slotWindowsMenuActivated(QAction *);
69                 void slotTileHorizontal();
70                 void slotTileVertical();
71
72                 void slotPenChanged(Pen p);
73
74                 /** generates a new document for a graphic. */
75                 MDIWindow * slotFileNew(Document * doc = NULL);
76                 /** opens a document */
77                 void slotFileOpen();
78                 /** opens a recent file document */
79                 void slotFileOpenRecent(void);
80                 /** opens the given file. */
81                 void slotFileOpen(const QString & fileName, RS2::FormatType type);
82                 /** saves a document */
83                 void slotFileSave();
84                 /** saves a document under a different filename*/
85                 void slotFileSaveAs();
86                 /** exports the document as bitmap */
87                 void slotFileExport();
88                 bool slotFileExport(const QString & name, const QString & format,
89                         QSize size, bool black, bool bw = false);
90                 /** closes the current file */
91                 void slotFileClose();
92                 /** closing the current file */
93                 void slotFileClosing();
94                 /** prints the current file */
95                 void slotFilePrint();
96                 /** shows print preview of the current file */
97                 void slotFilePrintPreview(bool on);
98                 /** exits the application */
99                 void slotFileQuit();
100
101                 /** toggle the grid */
102                 void slotViewGrid(bool toggle);
103                 /** toggle the draft mode */
104                 void slotViewDraft(bool toggle);
105                 /** toggle the statusbar */
106                 void slotViewStatusBar(bool toggle);
107
108                 void slotOptionsGeneral();
109
110                 void slotScriptOpenIDE();
111                 void slotScriptRun();
112
113                 void slotRunStartScript();
114                 void slotRunScript();
115                 void slotRunScript(const QString & name);
116
117                 void slotInsertBlock();
118                 void slotInsertBlock(const QString & name);
119
120                 /** shows an about dlg */
121                 void slotHelpAbout();
122                 void slotHelpManual();
123
124                 /** dumps entities to file */
125                 void slotTestDumpEntities(EntityContainer * d = NULL);
126                 /** dumps undo info to stdout */
127                 void slotTestDumpUndo();
128                 /** updates all inserts */
129                 void slotTestUpdateInserts();
130                 /** draws some random lines */
131                 void slotTestDrawFreehand();
132                 /** inserts a test block */
133                 void slotTestInsertBlock();
134                 /** inserts a test ellipse */
135                 void slotTestInsertEllipse();
136                 /** inserts a test text */
137                 void slotTestInsertText();
138                 /** inserts a test image */
139                 void slotTestInsertImage();
140                 /** unicode table */
141                 void slotTestUnicode();
142                 /** math experimental */
143                 void slotTestMath01();
144                 /** resizes window to 640x480 for screen shots */
145                 void slotTestResize640();
146                 /** resizes window to 640x480 for screen shots */
147                 void slotTestResize800();
148                 /** resizes window to 640x480 for screen shots */
149                 void slotTestResize1024();
150
151         signals:
152 //              void gridChanged(bool on);
153 //              void draftChanged(bool on);
154 //              void printPreviewChanged(bool on);
155                 void windowsChanged(bool);
156
157         public:
158                 static ApplicationWindow * getAppWindow();
159                 QMdiArea * getWorkspace();
160                 MDIWindow * getMDIWindow();
161
162 #ifdef SCRIPTING
163                 /**
164                  * @return Pointer to the qsa object.
165                  */
166                 QSProject * getQSAProject();
167 #endif
168
169                 void redrawAll();
170                 void updateGrids();
171
172                 /** Implementation from QG_MainWindowInterface. */
173                 virtual void setFocus2();
174                 virtual GraphicView * getGraphicView();
175                 virtual Document * getDocument();
176                 virtual void createNewDocument(const QString & fileName = QString::null, Document * doc = NULL);
177                 virtual void showSimulationControls();
178
179         protected:
180                 void closeEvent(QCloseEvent *);
181                 virtual void mouseReleaseEvent(QMouseEvent * e);
182
183         private:
184                 /** Pointer to the application window (this). */
185                 static ApplicationWindow * appWindow;
186
187                 /** Workspace for MDI */
188                 QMdiArea * workspace;
189
190                 /** Dialog factory */
191                 QC_DialogFactory * dialogFactory;
192
193                 /** Layer list widget */
194                 LayerWidget * layerWidget;
195                 /** Block list widget */
196                 BlockWidget * blockWidget;
197                 /** Library browser widget */
198                 LibraryWidget * libraryWidget;
199 #ifdef RS_CAM
200                 /** CAM Simulation panel */
201                 RS_SimulationControls * simulationControls;
202 #endif
203
204                 /** Layer list dock widget */
205                 QDockWidget * layerDockWindow;
206                 /** Block list dock widget */
207                 QDockWidget * blockDockWindow;
208                 /** Library list dock widget */
209                 QDockWidget * libraryDockWindow;
210 #ifdef RS_CAM
211                 /** Simulation controls dock widget */
212                 QDockWidget * simulationDockWindow;
213 #endif
214
215                 /** Command line */
216                 CommandWidget * commandWidget;
217                 QDockWidget * commandDockWindow;
218
219                 /** Coordinate widget */
220                 CoordinateWidget * coordinateWidget;
221                 /** Mouse widget */
222                 MouseWidget * mouseWidget;
223                 /** Selection Status */
224                 SelectionWidget * selectionWidget;
225
226                 /** Option widget for individual tool options */
227                 QToolBar * optionWidget;
228
229                 /** Recent files list */
230                 RecentFiles * recentFiles;
231
232                 /** Action handler. */
233                 ActionHandler * actionHandler;
234
235 #ifdef SCRIPTING
236                 /** Scripting interface. */
237                 QS_Scripter * scripter;
238 #endif
239
240                 QMenu * fileMenu;
241                 QMenu * windowsMenu;
242                 QMenu * scriptMenu;
243                 QMenu * helpMenu;
244                 QMenu * testMenu;
245
246                 /** the main toolbars */
247                 QToolBar * fileToolBar;
248                 QToolBar * editToolBar;
249                 QToolBar * zoomToolBar;
250
251                 // Toolbar for selecting the current pen
252                 PenToolBar * penToolBar;
253                 // Toolbar for CAD tools
254                 CadToolBar * cadToolBar;
255
256                 QAction * scriptOpenIDE;
257                 QAction * scriptRun;
258
259                 QAction * helpAboutApp;
260                 QAction * helpManual;
261
262                 QAction * testDumpEntities;
263                 QAction * testDumpUndo;
264                 QAction * testUpdateInserts;
265                 QAction * testDrawFreehand;
266                 QAction * testInsertBlock;
267                 QAction * testInsertText;
268                 QAction * testInsertImage;
269                 QAction * testUnicode;
270                 QAction * testInsertEllipse;
271
272                 QAction * testMath01;
273
274                 QAction * testResize640;
275                 QAction * testResize800;
276                 QAction * testResize1024;
277 };
278
279 #endif  // __APPLICATIONWINDOW_H__