00001
00016 #ifndef __EDITWINDOW_H_INCLUDED__
00017 #define __EDITWINDOW_H_INCLUDED__
00018
00019 #include <QtCore/QSignalMapper>
00020 #include <QtGui/QMainWindow>
00021 #include <QtGui/QTextEdit>
00022 #include <QtGui/QAction>
00023 #include <QtGui/QMenu>
00024 #include <QtGui/QTabWidget>
00025 #include <QtGui/QSyntaxHighlighter>
00026 #include <QtGui/QPushButton>
00027 #include <QtGui/QCheckBox>
00028 #include <QtGui/QDialog>
00029
00030
00031
00032 class IShader;
00033 class CSourceEdit;
00034
00035
00036
00037
00038
00039
00045 class CBaseEditWindow : public QMainWindow
00046 {
00047 Q_OBJECT
00048 public:
00054 CBaseEditWindow( void );
00055 virtual ~CBaseEditWindow( void );
00056
00061 virtual bool maybeSave( void ) = 0;
00062
00065 virtual void loadInitialShaderSource( void ) = 0;
00066
00070 virtual void uploadShaderSource( IShader* shader ) = 0;
00071
00072 signals:;
00075 void linkProgram( void );
00076
00080 void deactivateProgram( void );
00081
00086 void aboutToQuit( void );
00087
00090 void requestSdiMode( void );
00091
00094 void requestMdiMode( void );
00095
00096 private slots:;
00097
00098
00099 void link( void );
00100 void shaderFileChanged( void );
00101 void contentsChanged( void );
00102
00103
00104 void newFile( void );
00105 void open( void );
00106 bool save( void );
00107 bool saveAs( void );
00108
00109
00110 void undo ( void );
00111 void redo ( void );
00112 void copy ( void );
00113 void cut ( void );
00114 void paste( void );
00115
00116
00117 void about( void );
00118 void aboutQt( void );
00119
00120 protected:
00121
00126 virtual CSourceEdit* activeDocument( void ) = 0;
00127
00132 virtual void createActions( IShader* shader );
00133
00139 virtual void createMenus( IShader* shader );
00140
00144 void updateWindowTitle( void );
00145
00146
00147 QPushButton* m_btnLink;
00148
00149
00150 QCheckBox* m_chkAttach;
00151
00152
00153 QMenu* m_menuFile;
00154 QMenu* m_menuEdit;
00155 QMenu* m_menuShader;
00156 QMenu* m_menuView;
00157 QMenu* m_menuHelp;
00158
00159 private:
00160
00161 void closeEvent( QCloseEvent* event );
00162
00163
00164 QAction* m_actQuit;
00165 QAction* m_actNew;
00166 QAction* m_actOpen;
00167 QAction* m_actSave;
00168 QAction* m_actSaveAs;
00169 QAction* m_actUndo;
00170 QAction* m_actRedo;
00171 QAction* m_actCopy;
00172 QAction* m_actCut;
00173 QAction* m_actPaste;
00174 QAction* m_actLink;
00175 QAction* m_actAbout;
00176 QAction* m_actAboutQt;
00177 };
00178
00179
00180
00181
00182
00183
00188 class CSdiEditWindow : public CBaseEditWindow
00189 {
00190 Q_OBJECT
00191 public:
00197 CSdiEditWindow( IShader* shader, int shaderType );
00198
00199
00200 bool maybeSave( void );
00201 void loadInitialShaderSource( void );
00202 void uploadShaderSource( IShader* shader );
00203
00208 void loadSourceFile( const QString & fileName );
00209
00214 QString fileName( void ) const;
00215
00216 private slots:;
00217
00218 void requestMdiModeSlot( void );
00219
00220 void checkAttachToShader( int checkState );
00221
00222 private:
00223
00224
00225 void createActions( IShader* shader );
00226 void createMenus ( IShader* shader );
00227
00228 CSourceEdit* activeDocument( void ) { return m_document; }
00229
00230
00231 CSourceEdit* m_document;
00232 bool m_attachToShader;
00233
00234 QAction* m_actToMDI;
00235 };
00236
00237
00238
00239
00240
00241
00246 class CMdiEditWindow : public CBaseEditWindow
00247 {
00248 Q_OBJECT
00249 public:
00254 CMdiEditWindow( IShader* shader );
00255 virtual ~CMdiEditWindow( void );
00256
00257
00258 bool maybeSave( void );
00259 void loadInitialShaderSource( void );
00260 void uploadShaderSource( IShader* shader );
00261
00267 void loadSourceFile( int shaderType, const QString & fileName );
00268
00274 QString fileName( int shaderType );
00275
00276 private slots:;
00277 void activeEditorChanged( int tabIndex );
00278 void nextShaderTab( void );
00279 void prevShaderTab( void );
00280 void requestSdiModeSlot( void );
00281 void checkAttachToShader( int checkState );
00282
00283 private:
00284
00285
00286 virtual CSourceEdit* activeDocument( void );
00287
00288
00289 void createActions( IShader* shader );
00290 void createMenus( IShader* shader );
00291 void createTabs( IShader* shader );
00292
00293
00294
00295 int tabToShader( int tabIndex );
00296
00297 QTabWidget* m_tabs;
00298 QSignalMapper* m_signalMapper;
00299
00300
00301 CSourceEdit** m_editors;
00302 bool* m_attachToShader;
00303
00304
00305 QAction* m_actNextShader;
00306 QAction* m_actPrevShader;
00307 QAction* m_actToSDI;
00308 QAction** m_actFocusEditor;
00309 };
00310
00311
00312
00313 #endif // __EDITWINDOW_H_INCLUDED__