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 ); };
67 QtxActionMenuMgr( QMainWindow* );
68 QtxActionMenuMgr( QWidget*, QObject* );
69 virtual ~QtxActionMenuMgr();
71 virtual bool isVisible( const int, const int ) const;
72 virtual void setVisible( const int, const int, const bool );
74 int insert( const int, const QString&, const int, const int = -1 );
75 int insert( QAction*, const QString&, const int, const int = -1 );
77 int insert( const int, const QStringList&, const int, const int = -1 );
78 int insert( QAction*, const QStringList&, const int, const int = -1 );
80 virtual int insert( const int, const int, const int, const int = -1 );
81 int insert( QAction*, const int, const int, const int = -1 );
83 int insert( const QString&, const QString&, const int, const int = -1, const int = -1, const bool = false );
84 int insert( const QString&, const QStringList&, const int, const int = -1, const int = -1, const bool = false );
85 virtual int insert( const QString&, const int, const int, const int = -1, const int = -1, const bool = false );
87 int append( const int, const int, const int );
88 int append( QAction*, const int, const int );
89 int append( const QString&, const int, const int, const int = -1, const bool = false );
91 int prepend( const int, const int, const int );
92 int prepend( QAction*, const int, const int );
93 int prepend( const QString&, const int, const int, const int = -1, const bool = false );
95 void remove( const int );
96 void remove( const int, const int, const int = -1 );
98 void show( const int );
99 void hide( const int );
101 bool isShown( const int ) const;
102 void setShown( const int, const bool );
104 virtual bool load( const QString&, QtxActionMgr::Reader& );
106 bool containsMenu( const QString&, const int ) const;
107 bool containsMenu( const int, const int ) const;
111 void onDestroyed( QObject* );
112 void onHighlighted( int );
115 void menuHighlighted( int, int );
118 void setWidget( QWidget* );
119 MenuNode* find( const int, const int, const bool = true ) const;
120 MenuNode* find( const int, MenuNode* = 0, const bool = true ) const;
121 bool find( const int, NodeList&, MenuNode* = 0 ) const;
122 MenuNode* find( const QString&, const int, const bool = true ) const;
123 MenuNode* find( const QString&, MenuNode* = 0, const bool = true ) const;
124 bool find( const QString&, NodeList&, MenuNode* = 0 ) const;
125 int findId( const int, const int = -1 ) const;
127 void removeMenu( const int, MenuNode* );
129 QAction* itemAction( const int ) const;
130 MenuAction* menuAction( const int ) const;
132 void updateMenu( MenuNode* = 0, const bool = true, const bool = true );
133 virtual void internalUpdate();
136 bool checkWidget( QWidget* ) const;
137 QWidget* menuWidget( MenuNode* ) const;
138 void simplifySeparators( QWidget* );
139 QString clearTitle( const QString& ) const;
140 int createMenu( const QStringList&, const int );
143 typedef QMap<int, MenuAction*> MenuMap;
151 class QtxActionMenuMgr::MenuCreator : public QtxActionMgr::Creator
154 MenuCreator( QtxActionMgr::Reader*, QtxActionMenuMgr* );
155 virtual ~MenuCreator();
157 virtual int append( const QString&, const bool,
158 const ItemAttributes&, const int );
161 QtxActionMenuMgr* myMgr;