1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_Application.h
25 // Author : Nicolas REJNERI
29 #ifndef QAD_Application_H
30 #define QAD_Application_H
33 #include "QAD_Popup.h"
34 #include "QAD_Study.h"
35 #include "QAD_Action.h"
37 #include "SALOME_NamingService.hxx"
42 #include <qstringlist.h>
43 #include <qtranslator.h>
49 class QAD_EXPORT QAD_Application : public QObject, public QAD_PopupServer
52 enum { EditUndoId, EditRedoId, EditCopyId, EditPasteId };
54 friend class QAD_Desktop;
57 QAD_Application ( const QString& format, const QString& description,
58 const QString& filter);
63 static bool addToDesktop( QAD_Application* app, SALOME_NamingService* name_service );
64 static QAD_Desktop* getDesktop();
66 static QPalette getPalette(bool alternative = false);
68 const QString& getApplicationName() const;
69 const QPixmap& getApplicationIcon() const;
71 /* studies management */
72 const QString& getStudyFormat() const;
73 const QString& getStudyExtension() const;
74 const QString& getStudyDescription() const;
77 bool isStudyOpened( const QString& studyname );
78 QAD_Study* getStudyByName( const QString& studyname );
79 QAD_Study* getActiveStudy() const;
80 QList<QAD_Study>& getStudies();
82 QAD_Study* newStudy();
83 QAD_Study* loadStudy( const QString& fileName);
84 QAD_Study* openStudy( const QString& fileName);
85 bool saveStudy( QAD_Study* study );
86 bool saveAsStudy( QAD_Study* study, const QString& fileName );
87 bool closeStudy( QAD_Study* study, bool permanently = false );
90 void updateFilePopup( QPopupMenu* menu, bool add, int index = -1 );
91 void updateEditPopup( QPopupMenu* menu, bool add, int index = -1 );
92 void updateViewPopup( QPopupMenu* menu, bool add, int index = -1 );
93 void updateHelpPopup( QPopupMenu* menu, bool add, int index = -1 );
94 void updateMainMenu( QMenuBar* menu, bool add, int index = -1 );
95 void updateStatusBar( QStatusBar*, bool add );
96 void updateToolBars( bool add );
99 QToolBar* createToolBar( int id,
100 const QString& label, Dock dock = DockTop,
101 bool dockTop = true, bool dockBottom = true,
102 bool dockLeft = true, bool dockRight = true,
103 bool dockMinimized = true, bool dockTornOff = true );
104 void removeToolBar( int id );
105 QToolBar* getToolBar( int id );
106 QList<QToolBar> getToolBars();
108 virtual void onStudyActivated( QAD_Study* );
109 virtual void onStudyDeactivated( QAD_Study* );
110 virtual void startOperation( QAD_Operation* op );
112 virtual void helpAbout();
113 virtual void helpSearch();
114 virtual void helpContents();
117 void updateActions();
120 void appActivated ( QAD_Application* );
121 void appDeactivated ( QAD_Application* );
122 void desktopCreated();
125 virtual bool onUndo();
126 virtual bool onRedo();
127 virtual bool onCopy();
128 virtual bool onPaste();
129 virtual void onOperationTerminated( bool );
132 void onDesktopCreated();
136 virtual int onUpdateMainMenuItems ( QMenuBar*, bool add, int index );
137 virtual int onUpdateFileActions ( QPopupMenu*, bool add, int index );
138 virtual int onUpdateEditActions ( QPopupMenu*, bool add, int index );
139 virtual int onUpdateViewActions ( QPopupMenu*, bool add, int index );
140 virtual int onUpdateHelpActions ( QPopupMenu*, bool add, int index );
141 virtual void onUpdateStatusBar( QStatusBar*, bool activate );
142 virtual void onUpdateToolBars( bool activate );
145 virtual void onStudyCreated( QAD_Study* );
146 virtual void onStudyOpened( QAD_Study* );
147 virtual void onStudyClosed( QAD_Study* );
148 virtual void onStudyShown( QAD_Study* );
149 virtual void onActiveStudyChanged( QAD_Study* oldActiveStudy,
150 QAD_Study* newActiveStudy );
151 /* specific initialization ( CAF etc. ) */
152 virtual bool initApp(SALOME_NamingService* name_service) = 0;
153 virtual bool createDesktop(SALOME_NamingService* name_service);
156 virtual bool undo( QAD_Study* study );
157 virtual bool redo( QAD_Study* study );
163 void onCreatePopup();
167 SALOMEDS::StudyManager_var myStudyMgr;
169 QAD_Study* myActiveStudy;
170 QList<QAD_Study> myStudies;
174 QString myStudyFormat;
175 QString myStudyExtension;
176 QString myStudyDescription;
179 /* SUN C++ v4.1 compiler BUG ?
180 Error when using protected 'desktop' in subclasses.
184 static QAD_Desktop* desktop; /* the only QAD desktop */
187 void createActions();
189 void addStudy( QAD_Study* study );
190 void removeStudy( QAD_Study* study );
193 ActionMap myEditActions;
194 ActionMap myViewActions;
195 ActionMap myHelpActions;
196 QMap<int, QToolBar*> myToolBars;