]> Shamusworld >> Repos - architektonas/blob - src/mainapp/applicationwindow.h
3e2a1347203c37929c42ef0cc9e269177a2093f9
[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 "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 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 #if 0
108                 /** forces to quit QCad (demo) */
109                 void slotFileDemoQuit();
110 #endif
111
112                 /** toggle the grid */
113                 void slotViewGrid(bool toggle);
114                 /** toggle the draft mode */
115                 void slotViewDraft(bool toggle);
116                 /** toggle the statusbar */
117                 void slotViewStatusBar(bool toggle);
118                 /** toggle the layerlist */
119                 //void slotViewLayerList(bool toggle);
120                 /** toggle the blocklist */
121                 //void slotViewBlockList(bool toggle);
122                 /** toggle the command line */
123                 //void slotViewCommandLine(bool toggle);
124                 /** toggle the option toolbar */
125                 //void slotViewOptionToolbar(bool toggle);
126
127                 //void slotBlocksEdit();
128                 void slotOptionsGeneral();
129
130                 void slotScriptOpenIDE();
131                 void slotScriptRun();
132
133                 void slotRunStartScript();
134                 void slotRunScript();
135                 void slotRunScript(const QString & name);
136
137                 void slotInsertBlock();
138                 void slotInsertBlock(const QString & name);
139
140                 /** shows an about dlg*/
141                 void slotHelpAbout();
142                 void slotHelpManual();
143
144                 /** dumps entities to file */
145                 void slotTestDumpEntities(RS_EntityContainer * d = NULL);
146                 /** dumps undo info to stdout */
147                 void slotTestDumpUndo();
148                 /** updates all inserts */
149                 void slotTestUpdateInserts();
150                 /** draws some random lines */
151                 void slotTestDrawFreehand();
152                 /** inserts a test block */
153                 void slotTestInsertBlock();
154                 /** inserts a test ellipse */
155                 void slotTestInsertEllipse();
156                 /** inserts a test text */
157                 void slotTestInsertText();
158                 /** inserts a test image */
159                 void slotTestInsertImage();
160                 /** unicode table */
161                 void slotTestUnicode();
162                 /** math experimental */
163                 void slotTestMath01();
164                 /** resizes window to 640x480 for screen shots */
165                 void slotTestResize640();
166                 /** resizes window to 640x480 for screen shots */
167                 void slotTestResize800();
168                 /** resizes window to 640x480 for screen shots */
169                 void slotTestResize1024();
170
171         signals:
172                 void gridChanged(bool on);
173                 void draftChanged(bool on);
174                 void printPreviewChanged(bool on);
175                 void windowsChanged(bool windowsLeft);
176
177         public:
178                 static ApplicationWindow * getAppWindow();
179                 QMdiArea * getWorkspace();
180                 MDIWindow * getMDIWindow();
181                 virtual GraphicView * getGraphicView();
182                 virtual RS_Document * getDocument();
183                 virtual void createNewDocument(const QString & fileName = QString::null, RS_Document * doc = NULL);
184                 virtual QMainWindow * GetMainWindow();
185                 virtual ActionHandler * getActionHandler();
186                 virtual void showSimulationControls();
187
188                 /**
189                 * @return Pointer to the qsa object.
190                 */
191 #ifdef RS_SCRIPTING
192                 QSProject * getQSAProject();
193 #endif
194
195                 void redrawAll();
196                 void updateGrids();
197
198                 /**
199                 * Implementation from QG_MainWindowInterface.
200                 */
201                 virtual void setFocus2();
202
203         protected:
204                 void closeEvent(QCloseEvent *);
205                 virtual void mouseReleaseEvent(QMouseEvent * e);
206
207         private:
208                 /** Pointer to the application window (this). */
209                 static ApplicationWindow * appWindow;
210
211                 /** Workspace for MDI */
212                 QMdiArea * workspace;
213
214                 /** Dialog factory */
215                 QC_DialogFactory * dialogFactory;
216
217                 /** Layer list widget */
218                 LayerWidget * layerWidget;
219                 /** Block list widget */
220                 BlockWidget * blockWidget;
221                 /** Library browser widget */
222                 LibraryWidget * libraryWidget;
223 #ifdef RS_CAM
224                 /** CAM Simulation panel */
225                 RS_SimulationControls * simulationControls;
226 #endif
227
228                 /** Layer list dock widget */
229                 QDockWidget * layerDockWindow;
230                 /** Block list dock widget */
231                 QDockWidget * blockDockWindow;
232                 /** Library list dock widget */
233                 QDockWidget * libraryDockWindow;
234 #ifdef RS_CAM
235                 /** Simulation controls dock widget */
236                 QDockWidget * simulationDockWindow;
237 #endif
238
239                 /** Command line */
240                 CommandWidget * commandWidget;
241                 QDockWidget * commandDockWindow;
242
243                 /** Coordinate widget */
244                 CoordinateWidget * coordinateWidget;
245                 /** Mouse widget */
246                 MouseWidget * mouseWidget;
247                 /** Selection Status */
248                 SelectionWidget * selectionWidget;
249
250                 /** Option widget for individual tool options */
251                 QToolBar * optionWidget;
252
253                 /** Recent files list */
254                 RecentFiles * recentFiles;
255
256                 /** Action handler. */
257                 ActionHandler * actionHandler;
258
259 #ifdef RS_SCRIPTING
260                 /** Scripting interface. */
261                 QS_Scripter * scripter;
262 #endif
263
264                 QMenu * fileMenu;
265                 QMenu * windowsMenu;
266                 QMenu * scriptMenu;
267                 QMenu * helpMenu;
268                 QMenu * testMenu;
269
270                 /** the main toolbars */
271                 QToolBar * fileToolBar;
272                 QToolBar * editToolBar;
273                 QToolBar * zoomToolBar;
274
275                 // Toolbar for selecting the current pen
276                 PenToolBar * penToolBar;
277                 // Toolbar for CAD tools
278                 CadToolBar * cadToolBar;
279
280 //No.   QAssistantClient * assistant;
281
282                 QAction * scriptOpenIDE;
283                 QAction * scriptRun;
284
285                 QAction * helpAboutApp;
286                 QAction * helpManual;
287
288                 QAction * testDumpEntities;
289                 QAction * testDumpUndo;
290                 QAction * testUpdateInserts;
291                 QAction * testDrawFreehand;
292                 QAction * testInsertBlock;
293                 QAction * testInsertText;
294                 QAction * testInsertImage;
295                 QAction * testUnicode;
296                 QAction * testInsertEllipse;
297
298                 QAction * testMath01;
299
300                 QAction * testResize640;
301                 QAction * testResize800;
302                 QAction * testResize1024;
303 };
304
305 #endif  // __APPLICATIONWINDOW_H__