Back to index

salome-gui  6.5.0
STD_Application.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef STD_APPLICATION_H
00024 #define STD_APPLICATION_H
00025 
00026 #include "STD.h"
00027 
00028 #include <SUIT_Application.h>
00029 
00030 #include <QList>
00031 
00032 class QMenu;
00033 class QCloseEvent;
00034 class QContextMenuEvent;
00035 
00036 class QToolBar;
00037 class QtxAction;
00038 class SUIT_Operation;
00039 class SUIT_ViewWindow;
00040 class SUIT_ToolWindow;
00041 class SUIT_Desktop;
00042 class SUIT_ViewManager;
00043 class SUIT_PopupClient;
00044 
00045 typedef QList<SUIT_ViewManager*> ViewManagerList;
00046 
00047 #if defined WIN32
00048 #pragma warning( disable: 4251 )
00049 #endif
00050 
00051 class STD_EXPORT STD_Application : public SUIT_Application
00052 {
00053   Q_OBJECT
00054 
00055 public:
00056   enum { MenuFileId, FileNewId, FileOpenId, FileReopenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
00057          MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
00058          MenuEditId, EditCutId, EditCopyId, EditPasteId,
00059          MenuHelpId, HelpAboutId,
00060          UserID
00061   };
00062 
00063  public:
00064   STD_Application();
00065   virtual ~STD_Application();
00066 
00067   virtual QString       applicationName() const;
00068 
00069   virtual bool          isPossibleToClose( bool& );
00070   virtual bool          useFile( const QString& );
00071 
00072   virtual void          createEmptyStudy();
00073 
00074   void                  setEditEnabled( const bool );
00075   bool                  isEditEnabled() const { return myEditEnabled; }
00076 
00077   void                  clearViewManagers();
00078   virtual void          addViewManager( SUIT_ViewManager* );
00079   virtual void          removeViewManager( SUIT_ViewManager* );
00080 
00081   SUIT_ViewManager*     activeViewManager() const;
00082   SUIT_ViewManager*     viewManager( const QString& ) const;
00083 
00084   bool                  containsViewManager( SUIT_ViewManager* ) const;
00085 
00086   ViewManagerList       viewManagers() const;
00087   void                  viewManagers( ViewManagerList& ) const;
00088   void                  viewManagers( const QString&, ViewManagerList& ) const;
00089   virtual int           viewManagerId (const SUIT_ViewManager* ) const;
00090 
00091   virtual QString       getFileFilter() const { return QString(); }
00092   virtual QString       getFileName( bool open, const QString& initial, const QString& filters,
00093                                                              const QString& caption, QWidget* parent );
00094   QString               getDirectory( const QString& initial, const QString& caption, QWidget* parent );
00095 
00096   virtual void          start();
00097 
00098   virtual void          closeApplication();
00099 
00100   virtual void          contextMenuPopup( const QString&, QMenu*, QString& ) {}
00101 
00102   bool                  exitConfirmation() const;
00103   void                  setExitConfirmation( const bool );
00104 
00105   virtual void          updateDesktopTitle();
00106 
00107 signals:
00109   void                  viewManagerAdded( SUIT_ViewManager* );
00111   void                  viewManagerRemoved( SUIT_ViewManager* );
00113   void                  viewManagerActivated( SUIT_ViewManager* );
00114 
00115 public slots:
00116   virtual void          onNewDoc();
00117   virtual bool          onNewDoc( const QString& );
00118 
00119   virtual void          onCloseDoc( bool ask = true );
00120   virtual void          onSaveDoc();
00121   virtual bool          onSaveAsDoc();
00122 
00123   virtual void          onOpenDoc();
00124   virtual bool          onOpenDoc( const QString& );
00125 
00126   virtual bool          onReopenDoc();
00127 
00128   virtual void          onExit();
00129 
00130   virtual void          onCopy();
00131   virtual void          onPaste();
00132 
00133   virtual void          onViewStatusBar( bool );
00134 
00135   virtual void          onHelpAbout();
00136 
00137   virtual void          onDesktopClosing( SUIT_Desktop*, QCloseEvent* );
00138   virtual void          onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* );
00139 
00140 private slots:
00141   virtual void          onViewManagerActivated( SUIT_ViewManager* );
00142 
00143 protected:
00144   enum { OpenCancel, OpenNew, OpenExist };
00145   enum { CloseCancel, CloseSave, CloseDiscard };
00146 
00147 protected:
00148   virtual void          createActions();
00149   virtual void          updateCommandsStatus();
00150 
00151   virtual void          setDesktop( SUIT_Desktop* );
00152 
00153   virtual void          loadPreferences();
00154   virtual void          savePreferences();
00155 
00156   virtual void          studySaved( SUIT_Study* );
00157   virtual void          studyOpened( SUIT_Study* );
00158   virtual void          studyCreated( SUIT_Study* );
00159 
00160   virtual void          beforeCloseDoc( SUIT_Study* theDoc );
00161   virtual void          afterCloseDoc();
00162 
00163   virtual void          setActiveViewManager( SUIT_ViewManager* );
00164 
00165   virtual int           openChoice( const QString& );
00166   virtual bool          openAction( const int, const QString& );
00167 
00168   virtual int           closeChoice( const QString& );
00169   virtual bool          closeAction( const int, bool& );
00170 
00171 private:
00172   ViewManagerList       myViewMgrs;
00173   SUIT_ViewManager*     myActiveViewMgr;
00174 
00175 private:
00176   bool                  myExitConfirm;
00177   bool                  myEditEnabled;
00178 };
00179 
00180 #if defined WIN32
00181 #pragma warning( default: 4251 )
00182 #endif
00183 
00184 #endif