1 | /****************************************************************************
|
---|
2 | ** $Id: qmenubar.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QMenuBar class
|
---|
5 | **
|
---|
6 | ** Created : 941209
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QMENUBAR_H
|
---|
39 | #define QMENUBAR_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qpopupmenu.h" // ### remove or keep for users' convenience?
|
---|
43 | #include "qframe.h"
|
---|
44 | #include "qmenudata.h"
|
---|
45 | #endif // QT_H
|
---|
46 |
|
---|
47 | #ifndef QT_NO_MENUBAR
|
---|
48 |
|
---|
49 | class QPopupMenu;
|
---|
50 |
|
---|
51 | class Q_EXPORT QMenuBar : public QFrame, public QMenuData
|
---|
52 | {
|
---|
53 | Q_OBJECT
|
---|
54 | Q_ENUMS( Separator )
|
---|
55 | Q_PROPERTY( Separator separator READ separator WRITE setSeparator DESIGNABLE false )
|
---|
56 | Q_PROPERTY( bool defaultUp READ isDefaultUp WRITE setDefaultUp )
|
---|
57 |
|
---|
58 | public:
|
---|
59 | QMenuBar( QWidget* parent=0, const char* name=0 );
|
---|
60 | ~QMenuBar();
|
---|
61 |
|
---|
62 | void updateItem( int id );
|
---|
63 |
|
---|
64 | void show(); // reimplemented show
|
---|
65 | void hide(); // reimplemented hide
|
---|
66 |
|
---|
67 | bool eventFilter( QObject *, QEvent * );
|
---|
68 |
|
---|
69 | int heightForWidth(int) const;
|
---|
70 |
|
---|
71 | enum Separator { Never=0, InWindowsStyle=1 };
|
---|
72 | Separator separator() const;
|
---|
73 | virtual void setSeparator( Separator when );
|
---|
74 |
|
---|
75 | void setDefaultUp( bool );
|
---|
76 | bool isDefaultUp() const;
|
---|
77 |
|
---|
78 | bool customWhatsThis() const;
|
---|
79 |
|
---|
80 | QSize sizeHint() const;
|
---|
81 | QSize minimumSize() const;
|
---|
82 | QSize minimumSizeHint() const;
|
---|
83 |
|
---|
84 | void activateItemAt( int index );
|
---|
85 |
|
---|
86 | #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
|
---|
87 | static void initialize();
|
---|
88 | static void cleanup();
|
---|
89 | #endif
|
---|
90 |
|
---|
91 | signals:
|
---|
92 | void activated( int itemId );
|
---|
93 | void highlighted( int itemId );
|
---|
94 |
|
---|
95 | protected:
|
---|
96 | void drawContents( QPainter * );
|
---|
97 | void fontChange( const QFont & );
|
---|
98 | void mousePressEvent( QMouseEvent * );
|
---|
99 | void mouseReleaseEvent( QMouseEvent * );
|
---|
100 | void mouseMoveEvent( QMouseEvent * );
|
---|
101 | void keyPressEvent( QKeyEvent * );
|
---|
102 | void focusInEvent( QFocusEvent * );
|
---|
103 | void focusOutEvent( QFocusEvent * );
|
---|
104 | void resizeEvent( QResizeEvent * );
|
---|
105 | void leaveEvent( QEvent * );
|
---|
106 | void menuContentsChanged();
|
---|
107 | void menuStateChanged();
|
---|
108 | void styleChange( QStyle& );
|
---|
109 | int itemAtPos( const QPoint & );
|
---|
110 | void hidePopups();
|
---|
111 | QRect itemRect( int item );
|
---|
112 |
|
---|
113 | private slots:
|
---|
114 | void subActivated( int itemId );
|
---|
115 | void subHighlighted( int itemId );
|
---|
116 | #ifndef QT_NO_ACCEL
|
---|
117 | void accelActivated( int itemId );
|
---|
118 | void accelDestroyed();
|
---|
119 | #endif
|
---|
120 | void popupDestroyed( QObject* );
|
---|
121 | void performDelayedChanges();
|
---|
122 |
|
---|
123 | void languageChange();
|
---|
124 |
|
---|
125 | private:
|
---|
126 | void performDelayedContentsChanged();
|
---|
127 | void performDelayedStateChanged();
|
---|
128 | void menuInsPopup( QPopupMenu * );
|
---|
129 | void menuDelPopup( QPopupMenu * );
|
---|
130 | void frameChanged();
|
---|
131 |
|
---|
132 | bool tryMouseEvent( QPopupMenu *, QMouseEvent * );
|
---|
133 | void tryKeyEvent( QPopupMenu *, QKeyEvent * );
|
---|
134 | void goodbye( bool cancelled = FALSE );
|
---|
135 | void openActPopup();
|
---|
136 |
|
---|
137 | void setActiveItem( int index, bool show = TRUE, bool activate_first_item = TRUE );
|
---|
138 | void setAltMode( bool );
|
---|
139 |
|
---|
140 | int calculateRects( int max_width = -1 );
|
---|
141 |
|
---|
142 | #ifndef QT_NO_ACCEL
|
---|
143 | void setupAccelerators();
|
---|
144 | QAccel *autoaccel;
|
---|
145 | #endif
|
---|
146 | QRect *irects;
|
---|
147 | int rightSide;
|
---|
148 |
|
---|
149 | uint mseparator : 1;
|
---|
150 | uint waitforalt : 1;
|
---|
151 | uint popupvisible : 1;
|
---|
152 | uint hasmouse : 1;
|
---|
153 | uint defaultup : 1;
|
---|
154 | uint toggleclose : 1;
|
---|
155 | uint pendingDelayedContentsChanges : 1;
|
---|
156 | uint pendingDelayedStateChanges : 1;
|
---|
157 |
|
---|
158 | friend class QPopupMenu;
|
---|
159 |
|
---|
160 | #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
|
---|
161 | friend class QWidget;
|
---|
162 | friend class QApplication;
|
---|
163 | friend void qt_mac_set_modal_state(bool, QMenuBar *);
|
---|
164 |
|
---|
165 | void macCreateNativeMenubar();
|
---|
166 | void macRemoveNativeMenubar();
|
---|
167 | void macDirtyNativeMenubar();
|
---|
168 |
|
---|
169 | #if !defined(QMAC_QMENUBAR_NO_EVENT)
|
---|
170 | static void qt_mac_install_menubar_event(MenuRef);
|
---|
171 | static OSStatus qt_mac_menubar_event(EventHandlerCallRef, EventRef, void *);
|
---|
172 | #endif
|
---|
173 | virtual void macWidgetChangedWindow();
|
---|
174 | bool syncPopups(MenuRef ret, QPopupMenu *d);
|
---|
175 | MenuRef createMacPopup(QPopupMenu *d, int id, bool =FALSE);
|
---|
176 | bool updateMenuBar();
|
---|
177 | #if !defined(QMAC_QMENUBAR_NO_MERGE)
|
---|
178 | uint isCommand(QMenuItem *, bool just_check=FALSE);
|
---|
179 | #endif
|
---|
180 |
|
---|
181 | uint mac_eaten_menubar : 1;
|
---|
182 | class MacPrivate;
|
---|
183 | MacPrivate *mac_d;
|
---|
184 | static bool activate(MenuRef, short, bool highlight=FALSE, bool by_accel=FALSE);
|
---|
185 | static bool activateCommand(uint cmd);
|
---|
186 | static bool macUpdateMenuBar();
|
---|
187 | static bool macUpdatePopupVisible(MenuRef, bool);
|
---|
188 | static bool macUpdatePopup(MenuRef);
|
---|
189 | #endif
|
---|
190 |
|
---|
191 | private: // Disabled copy constructor and operator=
|
---|
192 |
|
---|
193 | #if defined(Q_DISABLE_COPY)
|
---|
194 | QMenuBar( const QMenuBar & );
|
---|
195 | QMenuBar &operator=( const QMenuBar & );
|
---|
196 | #endif
|
---|
197 | };
|
---|
198 |
|
---|
199 |
|
---|
200 | #endif // QT_NO_MENUBAR
|
---|
201 |
|
---|
202 | #endif // QMENUBAR_H
|
---|