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: QtxDockAction.h
20 // Author: Sergey TELKOV
22 #ifndef QTX_DOCKACTION_H
23 #define QTX_DOCKACTION_H
25 #include "QtxAction.h"
29 #include <qpopupmenu.h>
38 #pragma warning( disable:4251 )
41 class QTX_EXPORT QtxDockAction : public QtxAction
45 Q_PROPERTY( bool autoAdd READ isAutoAdd WRITE setAutoAdd )
46 Q_PROPERTY( bool autoPlace READ isAutoPlace WRITE setAutoPlace )
47 Q_PROPERTY( bool separate READ isSeparate WRITE setSeparate )
50 QtxDockAction( QMainWindow*, const char* = 0 );
51 QtxDockAction( const QString&, const QString&, QMainWindow*, const char* = 0 );
52 QtxDockAction( const QString&, const QIconSet&, const QString&, QMainWindow*, const char* = 0 );
53 virtual ~QtxDockAction();
55 QMainWindow* mainWindow() const;
57 bool isAutoAdd() const;
58 void setAutoAdd( const bool );
60 bool isAutoPlace() const;
61 void setAutoPlace( const bool );
63 bool isSeparate() const;
64 void setSeparate( const bool );
66 virtual bool addTo( QWidget* );
67 virtual bool addTo( QWidget*, const int );
68 virtual bool removeFrom( QWidget* );
69 virtual void setMenuText( const QString& );
71 bool addDockWindow( QDockWindow* );
72 bool removeDockWindow( QDockWindow* );
74 virtual bool eventFilter( QObject*, QEvent* );
76 virtual void storeGeometry( QDockWindow* = 0 );
77 virtual void restoreGeometry( QDockWindow* = 0 ) const;
79 virtual void loadGeometry( QtxResourceMgr*, const QString&, const bool = true );
80 virtual void saveGeometry( QtxResourceMgr*, const QString&, const bool = true ) const;
84 void onToggled( bool );
85 void onVisibilityChanged( bool );
86 void onPopupDestroyed( QObject* );
87 void onWindowDestroyed( QObject* );
88 void onDockWindowPositionChanged( QDockWindow* );
91 virtual bool event( QEvent* );
94 QAction* action( QDockWindow* ) const;
95 QDockWindow* dockWindow( const QAction* ) const;
97 void checkPopup( QPopupMenu* );
98 void fillPopup( QPopupMenu* ) const;
99 int findId( QPopupMenu*, QPopupMenu* ) const;
101 void initialize( QMainWindow* );
102 void updateInfo( QDockWindow* );
103 bool isToolBar( QDockWindow* ) const;
104 void dockWindows( QPtrList<QDockWindow>&, QMainWindow* = 0 ) const;
106 QString windowName( QDockWindow* ) const;
107 void savePlaceInfo( QDockWindow* );
108 void loadPlaceInfo( QDockWindow* ) const;
109 void loadPlaceInfo() const;
111 bool autoAddDockWindow( QDockWindow* );
112 void autoLoadPlaceInfo( QDockWindow* );
114 void splitMenuText( QString&, QString& ) const;
115 QStringList splitText( const QString&, const QString& ) const;
117 QDockArea* dockArea( const int ) const;
118 int dockPlace( const QString& ) const;
120 void collectNames( const int, QStringList& ) const;
125 enum { AutoAdd = QEvent::User, LoadArea };
127 typedef struct { bool vis, newLine;
128 int place, index, offset;
129 int x, y, w, h, fixW, fixH; } GeomInfo;
130 typedef struct { QString name; QAction* a; } DockInfo;
131 typedef struct { QPopupMenu *dock, *tool; } MenuInfo;
133 typedef QMap<QDockWindow*, DockInfo> InfoMap;
134 typedef QMap<QString, GeomInfo> GeomMap;
135 typedef QMap<QPopupMenu*, MenuInfo> MenuMap;
138 bool loadGeometry( QtxResourceMgr*, const QString&,
139 const QString&, GeomInfo& ) const;
140 bool saveGeometry( QtxResourceMgr*, const QString&,
141 const QString&, const GeomInfo& ) const;
142 void loadPlaceArea( const int, QMainWindow*, QDockArea*,
143 const QPtrList<QDockWindow>&,
144 const QMap<QDockWindow*, GeomInfo*>& ) const;
159 #pragma warning( default:4251 )