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/
19 // File: QtxActionMenuMgr.h
20 // Author: Alexander SOLOVYEV, Sergey TELKOV
22 #ifndef QTXACTIONMENUMGR_H
23 #define QTXACTIONMENUMGR_H
26 #include "QtxActionMgr.h"
29 #include <qstringlist.h>
35 #pragma warning( disable:4251 )
38 class QTX_EXPORT QtxActionMenuMgr : public QtxActionMgr
44 typedef QPtrList<MenuNode> NodeList;
45 typedef QPtrListIterator<MenuNode> NodeListIterator;
50 MenuNode() : parent( 0 ), visible( true ) { children.setAutoDelete( true ); };
51 MenuNode( MenuNode* p ) : parent( p ), visible( true ) { children.setAutoDelete( true ); };
66 QtxActionMenuMgr( QMainWindow* );
67 QtxActionMenuMgr( QWidget*, QObject* );
68 virtual ~QtxActionMenuMgr();
70 virtual bool isVisible( const int, const int ) const;
71 virtual void setVisible( const int, const int, const bool );
73 int insert( const int, const QString&, const int, const int = -1 );
74 int insert( QAction*, const QString&, const int, const int = -1 );
76 int insert( const int, const QStringList&, const int, const int = -1 );
77 int insert( QAction*, const QStringList&, const int, const int = -1 );
79 virtual int insert( const int, const int, const int, const int = -1 );
80 int insert( QAction*, const int, const int, const int = -1 );
82 int insert( const QString&, const QString&, const int, const int = -1 );
83 int insert( const QString&, const QStringList&, const int, const int = -1 );
84 virtual int insert( const QString&, const int, const int, const int = -1 );
86 int append( const int, const int, const int );
87 int append( QAction*, const int, const int );
88 int append( const QString&, const int, const int );
90 int prepend( const int, const int, const int );
91 int prepend( QAction*, const int, const int );
92 int prepend( const QString&, const int, const int );
94 void remove( const int );
95 void remove( const int, const int, const int = -1 );
97 void show( const int );
98 void hide( const int );
100 bool isShown( const int ) const;
101 void setShown( const int, const bool );
103 virtual bool load( const QString&, QtxActionMgr::Reader& );
106 void onDestroyed( QObject* );
109 void setWidget( QWidget* );
110 MenuNode* find( const int, const int ) const;
111 MenuNode* find( const int, MenuNode* = 0 ) const;
112 bool find( const int, NodeList&, MenuNode* = 0 ) const;
114 void removeMenu( const int, MenuNode* );
116 QAction* itemAction( const int ) const;
117 MenuAction* menuAction( const int ) const;
119 void updateMenu( MenuNode* = 0, const bool = true, const bool = true );
120 virtual void internalUpdate();
123 bool checkWidget( QWidget* ) const;
124 QWidget* menuWidget( MenuNode* ) const;
125 void simplifySeparators( QWidget* );
126 QString clearTitle( const QString& ) const;
127 int createMenu( const QStringList&, const int );
130 typedef QMap<int, MenuAction*> MenuMap;
138 class QtxActionMenuMgr::MenuCreator : public QtxActionMgr::Creator
141 MenuCreator( QtxActionMgr::Reader*, QtxActionMenuMgr* );
142 virtual ~MenuCreator();
144 virtual int append( const QString&, const bool,
145 const ItemAttributes&, const int );
148 QtxActionMenuMgr* myMgr;