1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File: QtxActionToolMgr.h
20 // Author: Alexander SOLOVYEV, Sergey TELKOV
22 #ifndef QTXACTIONTOOLMGR_H
23 #define QTXACTIONTOOLMGR_H
29 #include "QtxActionMgr.h"
35 #pragma warning( disable:4251 )
39 \class QtxActionToolMgr
40 Allows to use set of action to automatically build set of toolbars.
41 With help of methods insert/append/remove it is possible to
42 describe toolbars and its internal structure.
43 This manager is able to attune toolbar by removing excess separators
45 class QTX_EXPORT QtxActionToolMgr : public QtxActionMgr
51 Represents a toolbutton inside toolbar
52 For internal purposes only
57 ToolNode() : id( -1 ), visible( true ) {};
63 typedef QValueList<ToolNode> NodeList;
69 QtxActionToolMgr( QMainWindow* );
70 virtual ~QtxActionToolMgr();
72 QMainWindow* mainWindow() const;
74 int createToolBar( const QString&, int = -1 );
75 void removeToolBar( const QString& );
76 void removeToolBar( const int );
78 int insert( const int, const int, const int = -1 );
79 int insert( QAction*, const int, const int = -1 );
80 int insert( const int, const QString&, const int = -1 );
81 int insert( QAction*, const QString&, const int = -1 );
83 int append( const int, const int );
84 int append( QAction*, const int );
85 int append( const int, const QString& );
86 int append( QAction*, const QString& );
88 int prepend( const int, const int );
89 int prepend( QAction*, const int );
90 int prepend( const int, const QString& );
91 int prepend( QAction*, const QString& );
93 virtual bool isVisible( const int, const int ) const;
94 virtual void setVisible( const int, const int, const bool );
96 void show( const int );
97 void hide( const int );
98 bool isShown( const int ) const;
99 void setShown( const int, const bool );
101 void remove( const int, const int );
102 void remove( const int, const QString& );
104 QToolBar* toolBar( const int ) const;
105 QToolBar* toolBar( const QString& ) const;
107 bool hasToolBar( const int ) const;
108 bool hasToolBar( const QString& ) const;
110 bool containsAction( const int, const int = -1 ) const;
112 virtual bool load( const QString&, QtxActionMgr::Reader& );
115 void onToolBarDestroyed();
118 int find( QToolBar* ) const;
119 int find( const QString& ) const;
120 QToolBar* find( const QString&, QMainWindow* ) const;
122 virtual void internalUpdate();
123 void updateToolBar( const int );
126 void simplifySeparators( QToolBar* );
129 typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
130 typedef QMap<int, ToolBarInfo> ToolBarMap;
133 ToolBarMap myToolBars;
134 QMainWindow* myMainWindow;
138 \class QtxActionToolMgr::ToolCreator
139 Allows to create automatically toolbar by data read from file
141 class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
144 ToolCreator( QtxActionMgr::Reader*, QtxActionToolMgr* );
145 virtual ~ToolCreator();
147 virtual int append( const QString&, const bool,
148 const ItemAttributes&, const int );
151 QtxActionToolMgr* myMgr;