Salome HOME
Merge branch 'V7_dev'
[modules/gui.git] / src / LightApp / LightApp_ModuleAction.h
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : LightApp_ModuleAction.h
21 // Author : Sergey TELKOV, Vadim SANDLER
22 //
23 #ifndef LIGHTAPP_MODULEACTION_H
24 #define LIGHTAPP_MODULEACTION_H
25
26 #include "LightApp.h"
27
28 #include <QtxAction.h>
29
30 #ifdef WIN32
31 #pragma warning ( disable:4251 )
32 #endif
33
34 class QtxComboBox;
35
36 class LIGHTAPP_EXPORT LightApp_ModuleAction : public QtxAction
37 {
38   Q_OBJECT
39
40 private:
41   class ActionSet;
42   class ComboAction;
43   class ActivateEvent;
44
45 public:
46   enum { None = 0x00, Buttons = 0x01, ComboItem = 0x02, All = Buttons | ComboItem };
47
48 public:
49   LightApp_ModuleAction( const QString&, QObject* = 0 );
50   LightApp_ModuleAction( const QString&, const QIcon&, QObject* = 0 );
51   virtual ~LightApp_ModuleAction();
52
53   QStringList      modules() const;
54
55   QIcon            moduleIcon( const QString& ) const;
56   void             setModuleIcon( const QString&, const QIcon& );
57
58   void             insertModule( const QString&, const QIcon&, const int = -1 );
59   void             removeModule( const QString& );
60
61   QString          activeModule() const;
62   void             setActiveModule( const QString& );
63
64   void             setMode( const int );
65   int              mode() const;
66
67 protected:
68   virtual void     addedTo( QWidget* );
69   virtual void     removedFrom( QWidget* );
70
71   virtual bool     event( QEvent* );
72
73 signals:
74   void             moduleActivated( const QString& );
75
76 private:
77   void             init();
78
79   void             update();
80   void             update( QtxComboBox* );
81
82   QAction*         active() const;
83   void             activate( int, bool = true );
84
85 private slots:
86   void             onChanged();
87   void             onTriggered( int );
88   void             onComboActivated( int );
89
90 private:
91   ComboAction*     myCombo;
92   ActionSet*       mySet;
93   int              myMode;
94 };
95
96 class LightApp_ModuleAction::ComboAction : public QtxAction
97 {
98   Q_OBJECT
99
100 public:
101   ComboAction( QObject* parent );
102
103   QList<QtxComboBox*> widgets() const;
104
105 signals:
106   void                activatedId( int );
107
108 protected:
109   virtual QWidget*    createWidget( QWidget* );
110 };
111
112 #endif // LIGHTAPP_MODULEACTION_H