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