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