Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / PatchQt / qactionP.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Module      : PatchQt
3 // File        : qactionP.h
4 // Description : the patch for Qt's QAction class (qaction.h)
5 /////////////////////////////////////////////////////////////////////////////
6
7 /****************************************************************************
8 ** $Id$
9 **
10 ** Definition of QAction class
11 **
12 ** Created : 000000
13 **
14 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
15 **
16 ** This file is part of the widgets module of the Qt GUI Toolkit.
17 **
18 ** This file may be distributed under the terms of the Q Public License
19 ** as defined by Trolltech AS of Norway and appearing in the file
20 ** LICENSE.QPL included in the packaging of this file.
21 **
22 ** This file may be distributed and/or modified under the terms of the
23 ** GNU General Public License version 2 as published by the Free Software
24 ** Foundation and appearing in the file LICENSE.GPL included in the
25 ** packaging of this file.
26 **
27 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
28 ** licenses may use this file in accordance with the Qt Commercial License
29 ** Agreement provided with the Software.
30 **
31 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33 **
34 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
35 **   information about Qt Commercial License Agreements.
36 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
37 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
38 **
39 ** Contact info@trolltech.com if any conditions of this licensing are
40 ** not clear to you.
41 **
42 **********************************************************************/
43
44 #ifndef QACTIONP_H
45 #define QACTIONP_H
46
47 #ifndef QT_H
48 #include <qobject.h>
49 #include <qiconset.h>
50 #include <qstring.h>
51 #include <qkeysequence.h>
52 #endif // QT_H
53
54 #ifndef QT_NO_ACTION
55
56 class QActionPPrivate;
57 class QActionPGroupPrivate;
58 class QStatusBar;
59 class QPopupMenu;
60
61 class Q_EXPORT QActionP : public QObject
62 {
63     Q_OBJECT
64     Q_PROPERTY( bool toggleAction READ isToggleAction WRITE setToggleAction)
65     Q_PROPERTY( bool on READ isOn WRITE setOn )
66     Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
67     Q_PROPERTY( QIconSet iconSet READ iconSet WRITE setIconSet )
68     Q_PROPERTY( QString text READ text WRITE setText )
69     Q_PROPERTY( QString menuText READ menuText WRITE setMenuText )
70     Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
71     Q_PROPERTY( QString statusTip READ statusTip WRITE setStatusTip )
72     Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
73     Q_PROPERTY( QKeySequence accel READ accel WRITE setAccel )
74
75 public:
76     QActionP( QObject* parent, const char* name = 0, bool toggle = FALSE  );
77     QActionP( const QString& text, const QIconSet& icon, const QString& menuText, QKeySequence accel,
78              QObject* parent, const char* name = 0, bool toggle = FALSE );
79     QActionP( const QString& text, const QString& menuText, QKeySequence accel, QObject* parent,
80              const char* name = 0, bool toggle = FALSE );
81     ~QActionP();
82
83     virtual void setIconSet( const QIconSet& );
84     QIconSet iconSet() const;
85     virtual void setText( const QString& );
86     QString text() const;
87     virtual void setMenuText( const QString& );
88     QString menuText() const;
89     virtual void setToolTip( const QString& );
90     QString toolTip() const;
91     virtual void setStatusTip( const QString& );
92     QString statusTip() const;
93     virtual void setWhatsThis( const QString& );
94     QString whatsThis() const;
95     virtual void setAccel( const QKeySequence& key );
96     QKeySequence accel() const;
97     virtual void setToggleAction( bool );
98     bool isToggleAction() const;
99     bool isOn() const;
100     bool isEnabled() const;
101     virtual bool addTo( QWidget* );
102     virtual bool removeFrom( QWidget* );
103
104 protected:
105     virtual void addedTo( QWidget *actionWidget, QWidget *container );
106     virtual void addedTo( int index, QPopupMenu *menu );
107
108 public slots:
109     void toggle();
110     virtual void setOn( bool );
111     virtual void setEnabled( bool );
112
113 signals:
114     void activated();
115     void toggled( bool );
116
117 private slots:
118     void internalActivation();
119     void toolButtonToggled( bool );
120     void objectDestroyed();
121     void menuStatusText( int id );
122     void showStatusText( const QString& );
123     void clearStatusText();
124
125 private:
126     void init();
127
128     QActionPPrivate* d;
129
130 };
131
132 class Q_EXPORT QActionPGroup : public QActionP
133 {
134     Q_OBJECT
135     Q_PROPERTY( bool exclusive READ isExclusive WRITE setExclusive )
136     Q_PROPERTY( bool usesDropDown READ usesDropDown WRITE setUsesDropDown )
137
138 public:
139     QActionPGroup( QObject* parent, const char* name = 0, bool exclusive = TRUE );
140     ~QActionPGroup();
141     void setExclusive( bool );
142     bool isExclusive() const;
143     void add( QActionP* a);
144     void addSeparator();
145     bool addTo( QWidget* );
146     bool removeFrom( QWidget* );
147     void setEnabled( bool );
148
149     void setUsesDropDown( bool enable );
150     bool usesDropDown() const;
151
152     void setIconSet( const QIconSet& );
153     void setText( const QString& );
154     void setMenuText( const QString& );
155     void setToolTip( const QString& );
156     void setWhatsThis( const QString& );
157
158 protected:
159     void childEvent( QChildEvent* );
160     virtual void addedTo( QWidget *actionWidget, QWidget *container, QActionP *a );
161     virtual void addedTo( int index, QPopupMenu *menu, QActionP *a );
162     virtual void addedTo( QWidget *actionWidget, QWidget *container );
163     virtual void addedTo( int index, QPopupMenu *menu );
164
165 signals:
166     void selected( QActionP* );
167
168 private slots:
169     void childToggled( bool );
170     void childDestroyed();
171     void internalComboBoxActivated( int );
172     void internalToggle( QActionP* );
173     void objectDestroyed();
174
175 private:
176     QActionPGroupPrivate* d;
177
178 #ifndef QT_NO_COMPAT
179 public:
180     void insert( QActionP* a ) { add( a ); }
181 #endif
182
183 };
184
185 #endif
186
187 #endif