]> Shamusworld >> Repos - architektonas/blob - src/mainapp/applicationwindow.h
In the middle of major refactoring...
[architektonas] / src / mainapp / applicationwindow.h
1 #ifndef __APPLICATIONWINDOW_H__
2 #define __APPLICATIONWINDOW_H__
3
4 #include <QtGui>
5
6 #include "rs_document.h"
7 #include "qc_dialogfactory.h"
8 #include "mdiwindow.h"
9 #include "qg_actionhandler.h"
10 #include "qg_blockwidget.h"
11 #include "qg_layerwidget.h"
12 #include "qg_mainwindowinterface.h"
13 #include "qg_pentoolbar.h"
14 #include "cadtoolbar.h"
15 #include "commandwidget.h"
16 #include "librarywidget.h"
17
18 #ifdef RS_SCRIPTING
19 #include "qs_scripter.h"
20 #include <qsproject.h>
21 #endif
22
23 #ifdef RS_CAM
24 #include "rs_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(bool force);
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 slotNext();
63                 void slotEnter();
64                 void slotFocusCommandLine();
65                 void slotError(const QString & msg);
66
67                 void slotWindowActivated(QMdiSubWindow * w);
68                 void slotWindowsMenuAboutToShow();
69                 void slotWindowsMenuActivated(QAction *);
70                 void slotTileHorizontal();
71                 void slotTileVertical();
72
73                 void slotPenChanged(RS_Pen p);
74
75                 /** generates a new document for a graphic. */
76                 MDIWindow * slotFileNew(RS_Document * doc = NULL);
77                 /** opens a document */
78                 void slotFileOpen();
79                 /**
80                 * opens a recent file document
81                 * @param id File Menu id of the file
82                 */
83                 void slotFileOpenRecent(void);
84                 /**
85                 * opens the given file.
86                 */
87                 void slotFileOpen(const QString & fileName, RS2::FormatType type);
88                 /** saves a document */
89                 void slotFileSave();
90                 /** saves a document under a different filename*/
91                 void slotFileSaveAs();
92                 /** exports the document as bitmap */
93                 void slotFileExport();
94                 bool slotFileExport(const QString & name, const QString & format,
95                         QSize size, bool black, bool bw = false);
96                 /** closes the current file */
97                 void slotFileClose();
98                 /** closing the current file */
99                 void slotFileClosing();
100                 /** prints the current file */
101                 void slotFilePrint();
102                 /** shows print preview of the current file */
103                 void slotFilePrintPreview(bool on);
104                 /** exits the application */
105                 void slotFileQuit();
106
107                 /** forces to quit QCad (demo) */
108                 void slotFileDemoQuit();
109
110                 /** toggle the grid */
111                 void slotViewGrid(bool toggle);
112                 /** toggle the draft mode */
113                 void slotViewDraft(bool toggle);
114                 /** toggle the statusbar */
115                 void slotViewStatusBar(bool toggle);
116                 /** toggle the layerlist */
117                 //void slotViewLayerList(bool toggle);
118                 /** toggle the blocklist */
119                 //void slotViewBlockList(bool toggle);
120                 /** toggle the command line */
121                 //void slotViewCommandLine(bool toggle);
122                 /** toggle the option toolbar */
123                 //void slotViewOptionToolbar(bool toggle);
124
125                 //void slotBlocksEdit();
126                 void slotOptionsGeneral();
127
128                 void slotScriptOpenIDE();
129                 void slotScriptRun();
130
131                 void slotRunStartScript();
132                 void slotRunScript();
133                 void slotRunScript(const QString & name);
134
135                 void slotInsertBlock();
136                 void slotInsertBlock(const QString & name);
137
138                 /** shows an about dlg*/
139                 void slotHelpAbout();
140                 void slotHelpManual();
141
142                 /** dumps entities to file */
143                 void slotTestDumpEntities(RS_EntityContainer * d = NULL);
144                 /** dumps undo info to stdout */
145                 void slotTestDumpUndo();
146                 /** updates all inserts */
147                 void slotTestUpdateInserts();
148                 /** draws some random lines */
149                 void slotTestDrawFreehand();
150                 /** inserts a test block */
151                 void slotTestInsertBlock();
152                 /** inserts a test ellipse */
153                 void slotTestInsertEllipse();
154                 /** inserts a test text */
155                 void slotTestInsertText();
156                 /** inserts a test image */
157                 void slotTestInsertImage();
158                 /** unicode table */
159                 void slotTestUnicode();
160                 /** math experimental */
161                 void slotTestMath01();
162                 /** resizes window to 640x480 for screen shots */
163                 void slotTestResize640();
164                 /** resizes window to 640x480 for screen shots */
165                 void slotTestResize800();
166                 /** resizes window to 640x480 for screen shots */
167                 void slotTestResize1024();
168
169         signals:
170                 void gridChanged(bool on);
171                 void draftChanged(bool on);
172                 void printPreviewChanged(bool on);
173                 void windowsChanged(bool windowsLeft);
174
175         public:
176                 static ApplicationWindow * getAppWindow();
177                 QMdiArea * getWorkspace();
178                 MDIWindow * getMDIWindow();
179                 virtual GraphicView * getGraphicView();
180                 virtual RS_Document * getDocument();
181                 virtual void createNewDocument(const QString & fileName = QString::null, RS_Document * doc = NULL);
182                 virtual QMainWindow * GetMainWindow();
183                 virtual QG_ActionHandler * getActionHandler();
184                 virtual void showSimulationControls();
185
186                 //virtual QToolBar* createToolBar(const QString& name);
187                 //virtual void addToolBarButton(QToolBar* tb);
188
189                 /**
190                 * @return Pointer to the qsa object.
191                 */
192 #ifdef RS_SCRIPTING
193                 QSProject * getQSAProject();
194 #endif
195
196                 void redrawAll();
197                 void updateGrids();
198
199                 /**
200                 * Implementation from QG_MainWindowInterface.
201                 */
202                 virtual void setFocus2();
203
204         protected:
205                 void closeEvent(QCloseEvent *);
206                 virtual void mouseReleaseEvent(QMouseEvent * e);
207
208         private:
209                 /** Pointer to the application window (this). */
210                 static ApplicationWindow * appWindow;
211
212                 /** Workspace for MDI */
213                 QMdiArea * workspace;
214
215                 /** Dialog factory */
216                 QC_DialogFactory * dialogFactory;
217
218                 /** Layer list widget */
219                 QG_LayerWidget * layerWidget;
220                 /** Block list widget */
221                 QG_BlockWidget * blockWidget;
222                 /** Library browser widget */
223                 LibraryWidget * libraryWidget;
224 #ifdef RS_CAM
225                 /** CAM Simulation panel */
226                 RS_SimulationControls * simulationControls;
227 #endif
228
229                 /** Layer list dock widget */
230                 QDockWidget * layerDockWindow;
231                 /** Block list dock widget */
232                 QDockWidget * blockDockWindow;
233                 /** Library list dock widget */
234                 QDockWidget * libraryDockWindow;
235 #ifdef RS_CAM
236                 /** Simulation controls dock widget */
237                 QDockWidget * simulationDockWindow;
238 #endif
239
240                 /** Command line */
241                 CommandWidget * commandWidget;
242                 QDockWidget * commandDockWindow;
243
244                 /** Coordinate widget */
245                 CoordinateWidget * coordinateWidget;
246                 /** Mouse widget */
247                 MouseWidget * mouseWidget;
248                 /** Selection Status */
249                 SelectionWidget * selectionWidget;
250
251                 /** Option widget for individual tool options */
252                 QToolBar * optionWidget;
253
254                 /** Recent files list */
255                 RecentFiles * recentFiles;
256
257                 /** Action handler. */
258                 QG_ActionHandler * actionHandler;
259
260 #ifdef RS_SCRIPTING
261                 /** Scripting interface. */
262                 QS_Scripter * scripter;
263 #endif
264
265                 QMenu * fileMenu;
266                 QMenu * windowsMenu;
267                 QMenu * scriptMenu;
268                 QMenu * helpMenu;
269                 QMenu * testMenu;
270
271                 /** the main toolbars */
272                 QToolBar * fileToolBar;
273                 QToolBar * editToolBar;
274                 QToolBar * zoomToolBar;
275
276                 // Toolbar for selecting the current pen
277                 QG_PenToolBar * penToolBar;
278                 // Toolbar for CAD tools
279                 CadToolBar * cadToolBar;
280
281 //No.   QAssistantClient * assistant;
282
283                 QAction * scriptOpenIDE;
284                 QAction * scriptRun;
285
286                 QAction * helpAboutApp;
287                 QAction * helpManual;
288
289                 QAction * testDumpEntities;
290                 QAction * testDumpUndo;
291                 QAction * testUpdateInserts;
292                 QAction * testDrawFreehand;
293                 QAction * testInsertBlock;
294                 QAction * testInsertText;
295                 QAction * testInsertImage;
296                 QAction * testUnicode;
297                 QAction * testInsertEllipse;
298
299                 QAction * testMath01;
300
301                 QAction * testResize640;
302                 QAction * testResize800;
303                 QAction * testResize1024;
304 };
305
306 #endif  // __APPLICATIONWINDOW_H__