]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxActionToolMgr.h
Salome HOME
48a7227859a079109d8c7c8fac0d484fd19843c7
[modules/gui.git] / src / Qtx / QtxActionToolMgr.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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/
18 //
19 // File:      QtxActionToolMgr.h
20 // Author:    Alexander SOLOVYEV, Sergey TELKOV
21
22 #ifndef QTXACTIONTOOLMGR_H
23 #define QTXACTIONTOOLMGR_H
24
25 #include "Qtx.h"
26
27 #include <qaction.h>
28
29 #include "QtxActionMgr.h"
30
31 class QToolBar;
32 class QMainWindow;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 class QTX_EXPORT QtxActionToolMgr : public QtxActionMgr
39 {
40   Q_OBJECT
41
42   class ToolNode
43   {
44   public:
45     ToolNode() : id( -1 ), visible( true ) {};
46
47     int       id;
48     bool      visible;
49   };
50
51   typedef QValueList<ToolNode> NodeList;
52
53 protected:
54   class ToolCreator;
55
56 public:
57   QtxActionToolMgr( QMainWindow* );
58   virtual ~QtxActionToolMgr();
59
60   QMainWindow*    mainWindow() const;
61
62   int             createToolBar( const QString&, int = -1 );
63   void            removeToolBar( const QString& );
64   void            removeToolBar( const int );
65
66   int             insert( const int, const int, const int = -1 );
67   int             insert( QAction*, const int, const int = -1 );
68   int             insert( const int, const QString&, const int = -1 );
69   int             insert( QAction*, const QString&, const int = -1 );
70
71   int             append( const int, const int );
72   int             append( QAction*, const int );
73   int             append( const int, const QString& );
74   int             append( QAction*, const QString& );
75
76   int             prepend( const int, const int );
77   int             prepend( QAction*, const int );
78   int             prepend( const int, const QString& );
79   int             prepend( QAction*, const QString& );
80
81   virtual bool    isVisible( const int, const int ) const;
82   virtual void    setVisible( const int, const int, const bool );
83
84   void            show( const int );
85   void            hide( const int );
86   bool            isShown( const int ) const;
87   void            setShown( const int, const bool );
88
89   void            remove( const int, const int );
90   void            remove( const int, const QString& );
91
92   QToolBar*       toolBar( const int ) const;
93   QToolBar*       toolBar( const QString& ) const;
94   
95   bool            hasToolBar( const int ) const;
96   bool            hasToolBar( const QString& ) const;
97
98   bool            containsAction( const int, const int = -1 ) const;
99
100   virtual bool    load( const QString&, QtxActionMgr::Reader& );
101
102 protected slots:
103   void            onToolBarDestroyed();
104
105 protected:
106   int             find( QToolBar* ) const;  
107   int             find( const QString& ) const;
108   QToolBar*       find( const QString&, QMainWindow* ) const;
109
110   virtual void    internalUpdate();
111   void            updateToolBar( const int );
112
113 private:
114   void            simplifySeparators( QToolBar* );
115
116 private:
117   typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
118   typedef QMap<int, ToolBarInfo>                        ToolBarMap;
119
120 private:
121   ToolBarMap      myToolBars;
122   QMainWindow*    myMainWindow;
123 };
124
125 class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
126 {
127 public:
128   ToolCreator( QtxActionMgr::Reader*, QtxActionToolMgr* );
129   virtual ~ToolCreator();
130
131   virtual int append( const QString&, const bool,
132                       const ItemAttributes&, const int );
133
134 private:
135   QtxActionToolMgr* myMgr;
136 };
137
138 #endif