Salome HOME
Add methods to create menu and toolbar actions to be accessed from Python.
[modules/gui.git] / src / SALOME_PYQT / SALOME_PYQT_GUI / SALOME_PYQT_Module.h
index d0f402c5fa568f129e4cd075af88eb3d8f38735f..9474fb0acadf6bceca0651dde151ff1685cdf9a8 100644 (file)
@@ -20,6 +20,9 @@
 #include <qstringlist.h>
 #include <qmap.h>
 
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+
 class SALOME_PYQT_XmlHandler;
 
 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
@@ -39,6 +42,8 @@ private:
   SALOME_PYQT_PyInterp*            myInterp;
   /* Python GUI module loaded */
   PyObjWrapper                     myModule;
+  /* Pytho GUI being initialized (not zero only during the initialization)*/
+  static SALOME_PYQT_Module* myInitModule;
 
   typedef QPtrList<QAction> ActionList;
   
@@ -68,31 +73,65 @@ public:
   /* destructor */
   ~SALOME_PYQT_Module();
 
+  /* get module engine */
+  Engines::Component_var getEngine() const;
+
   /******************************
-   * Inherited from CAM_Module 
+   * Inherited from SalomeApp_Module 
    ******************************/
 
 public:
+  /* little trick : provide an access to being activated Python module from outside;
+     needed by the SalomePyQt library :(
+  */
+  static SALOME_PYQT_Module* getInitModule();
+
   /* initialization */
-  void           initialize  ( CAM_Application* );
+  void            initialize  ( CAM_Application* );
 
   /* getting windows list */
-  void           windows     ( QMap<int, int>& ) const;
+  void            windows     ( QMap<int, int>& ) const;
   /* getting compatible viewer managers list */
-  void           viewManagers( QStringList& ) const;
+  void            viewManagers( QStringList& ) const;
 
   /* context popup menu request */
-  void           contextMenuPopup( const QString&, QPopupMenu* );
-  
-protected:
-  /* data model creation */
-  CAM_DataModel* createDataModel();
+  void            contextMenuPopup( const QString&, QPopupMenu*, QString& );
+
+  /* get module engine IOR */
+  virtual QString engineIOR() const;
+
+  /* called when study desktop is activated */
+  virtual void    studyActivated();
+
+  /* working with toolbars : open protected methods */
+  int                    createTool( const QString& );
+  int                    createTool( const int, const int, const int = -1 );
+  int                    createTool( const int, const QString&, const int = -1 );
+  int                    createTool( QAction*, const int, const int = -1, const int = -1 );
+  int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
+
+  /* working with menus : open protected methods */
+  int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
+  int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
+  int                    createMenu( const int, const int, const int = -1, const int = -1 );
+  int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
+  int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
+  int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
+
+  /* create separator : open protected method */
+  QAction*               createSeparator();
+
+  /* working with actions : open protected methods */
+  QAction*               action( const int ) const;
+  int                    actionId( const QAction* ) const;
+  QAction*               createAction( const int, const QString&, const QString&, const QString&,
+                                       const QString&, const int, const bool = false );
 
 public slots:
   /* activation */
-  void           activateModule  ( SUIT_Study* );
+  virtual bool    activateModule( SUIT_Study* );
   /* deactivation */
-  void           deactivateModule( SUIT_Study* );
+  virtual bool    deactivateModule( SUIT_Study* );
 
   /******************************
    * Internal methods
@@ -100,35 +139,35 @@ public slots:
 
 public slots:
   /* GUI action processing slot */
-  void           onGUIEvent();
+  void            onGUIEvent();
   /* desktop activation slot */ 
-  void           onDesktopActivated();
+  void            onDesktopActivated();
+
 private:
   /* internal initizalition */ 
-  void           init        ( CAM_Application* );
+  void            init        ( CAM_Application* );
   /* internal activation */ 
-  void           activate    ( SUIT_Study* );
+  void            activate    ( SUIT_Study* );
   /* internal deactivation */ 
-  void           deactivate  ( SUIT_Study* );
+  void            deactivate  ( SUIT_Study* );
   /* study activation */ 
-  void           studyChanged( SUIT_Study* );
+  void            studyChanged( SUIT_Study* );
   /* context popup menu processing */
-  void           contextMenu( const QString&, QPopupMenu* );
+  void            contextMenu( const QString&, QPopupMenu* );
   /* GUI event processing */
-  void           guiEvent( const int );
+  void            guiEvent( const int );
 
   /* add action to the private action map */ 
-  void           addAction   ( const PyQtGUIAction, QAction* );
+  void            addAction   ( const PyQtGUIAction, QAction* );
 
   /* initialize a Python subinterpreter */
-  void           initInterp  ( int );
+  void            initInterp  ( int );
   /* import a Python GUI module */
-  void           importModule();
+  void            importModule();
   /* set workspace to Python GUI module */
-  void           setWorkSpace();
+  void            setWorkSpace();
 
-friend class SALOME_PYQT_XmlHandler;
+  friend class SALOME_PYQT_XmlHandler;
 };
 
 #endif // SALOME_PYQT_MODULE_H