source: trunk/src/gui/widgets/qmenubar_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 8.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QMENUBAR_P_H
43#define QMENUBAR_P_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists purely as an
50// implementation detail. This header file may change from version to
51// version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#ifndef QMAC_Q3MENUBAR_CPP_FILE
57#include "QtGui/qstyleoption.h"
58#include <private/qmenu_p.h> // Mac needs what in this file!
59
60#ifdef Q_WS_WINCE
61#include "qguifunctions_wince.h"
62#endif
63
64#ifndef QT_NO_MENUBAR
65#ifdef Q_WS_S60
66class CCoeControl;
67class CEikMenuBar;
68#endif
69#endif
70
71QT_BEGIN_NAMESPACE
72
73#ifndef QT_NO_MENUBAR
74class QMenuBarExtension;
75class QMenuBarPrivate : public QWidgetPrivate
76{
77 Q_DECLARE_PUBLIC(QMenuBar)
78public:
79 QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0),
80 closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
81 nativeMenuBar(-1), doChildEffects(false)
82#ifdef QT3_SUPPORT
83 , doAutoResize(false)
84#endif
85#ifdef Q_WS_MAC
86 , mac_menubar(0)
87#endif
88
89#ifdef Q_WS_WINCE
90 , wce_menubar(0), wceClassicMenu(false)
91#endif
92#ifdef Q_WS_S60
93 , symbian_menubar(0)
94#endif
95
96 { }
97 ~QMenuBarPrivate()
98 {
99#ifdef Q_WS_MAC
100 delete mac_menubar;
101#endif
102#ifdef Q_WS_WINCE
103 delete wce_menubar;
104#endif
105#ifdef Q_WS_S60
106 delete symbian_menubar;
107#endif
108 }
109
110 void init();
111 QAction *getNextAction(const int start, const int increment) const;
112
113 //item calculations
114 uint itemsDirty : 1;
115
116 QVector<int> shortcutIndexMap;
117 mutable QVector<QRect> actionRects;
118 void calcActionRects(int max_width, int start) const;
119 QRect actionRect(QAction *) const;
120 void updateGeometries();
121
122 //selection
123 QPointer<QAction>currentAction;
124 uint mouseDown : 1, closePopupMode : 1, defaultPopDown;
125 QAction *actionAt(QPoint p) const;
126 void setCurrentAction(QAction *, bool =false, bool =false);
127 void popupAction(QAction *, bool);
128
129 //active popup state
130 uint popupState : 1;
131 QPointer<QMenu> activeMenu;
132
133 //keyboard mode for keyboard navigation
134 void focusFirstAction();
135 void setKeyboardMode(bool);
136 uint keyboardState : 1, altPressed : 1;
137 QPointer<QWidget> keyboardFocusWidget;
138
139
140 int nativeMenuBar : 3; // Only has values -1, 0, and 1
141 //firing of events
142 void activateAction(QAction *, QAction::ActionEvent);
143
144 void _q_actionTriggered();
145 void _q_actionHovered();
146 void _q_internalShortcutActivated(int);
147 void _q_updateLayout();
148
149#ifdef Q_WS_WINCE
150 void _q_updateDefaultAction();
151#endif
152
153 //extra widgets in the menubar
154 QPointer<QWidget> leftWidget, rightWidget;
155 QMenuBarExtension *extension;
156 bool isVisible(QAction *action);
157
158 //menu fading/scrolling effects
159 bool doChildEffects;
160
161 QRect menuRect(bool) const;
162
163 // reparenting
164 void handleReparent();
165 QWidget *oldParent;
166 QWidget *oldWindow;
167
168 QList<QAction*> hiddenActions;
169 //default action
170 QPointer<QAction> defaultAction;
171
172 QBasicTimer autoReleaseTimer;
173#ifdef QT3_SUPPORT
174 bool doAutoResize;
175#endif
176#ifdef Q_WS_MAC
177 //mac menubar binding
178 struct QMacMenuBarPrivate {
179 QList<QMacMenuAction*> actionItems;
180 OSMenuRef menu, apple_menu;
181 QMacMenuBarPrivate();
182 ~QMacMenuBarPrivate();
183
184 void addAction(QAction *, QMacMenuAction* =0);
185 void addAction(QMacMenuAction *, QMacMenuAction* =0);
186 void syncAction(QMacMenuAction *);
187 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
188 void removeAction(QMacMenuAction *);
189 inline void removeAction(QAction *a) { removeAction(findAction(a)); }
190 inline QMacMenuAction *findAction(QAction *a) {
191 for(int i = 0; i < actionItems.size(); i++) {
192 QMacMenuAction *act = actionItems[i];
193 if(a == act->action)
194 return act;
195 }
196 return 0;
197 }
198 } *mac_menubar;
199 static bool macUpdateMenuBarImmediatly();
200 bool macWidgetHasNativeMenubar(QWidget *widget);
201 void macCreateMenuBar(QWidget *);
202 void macDestroyMenuBar();
203 OSMenuRef macMenu();
204#endif
205#ifdef Q_WS_WINCE
206 void wceCreateMenuBar(QWidget *);
207 void wceDestroyMenuBar();
208 struct QWceMenuBarPrivate {
209 QList<QWceMenuAction*> actionItems;
210 QList<QWceMenuAction*> actionItemsLeftButton;
211 QList<QList<QWceMenuAction*>> actionItemsClassic;
212 HMENU menuHandle;
213 HMENU leftButtonMenuHandle;
214 HWND menubarHandle;
215 HWND parentWindowHandle;
216 bool leftButtonIsMenu;
217 QPointer<QAction> leftButtonAction;
218 QMenuBarPrivate *d;
219 int leftButtonCommand;
220
221 QWceMenuBarPrivate(QMenuBarPrivate *menubar);
222 ~QWceMenuBarPrivate();
223 void addAction(QAction *, QWceMenuAction* =0);
224 void addAction(QWceMenuAction *, QWceMenuAction* =0);
225 void syncAction(QWceMenuAction *);
226 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
227 void removeAction(QWceMenuAction *);
228 void rebuild();
229 inline void removeAction(QAction *a) { removeAction(findAction(a)); }
230 inline QWceMenuAction *findAction(QAction *a) {
231 for(int i = 0; i < actionItems.size(); i++) {
232 QWceMenuAction *act = actionItems[i];
233 if(a == act->action)
234 return act;
235 }
236 return 0;
237 }
238 } *wce_menubar;
239 bool wceClassicMenu;
240 void wceCommands(uint command);
241 void wceRefresh();
242 bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command);
243#endif
244#ifdef Q_WS_S60
245 void symbianCreateMenuBar(QWidget *);
246 void symbianDestroyMenuBar();
247 void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
248 struct QSymbianMenuBarPrivate {
249 QList<QSymbianMenuAction*> actionItems;
250 QMenuBarPrivate *d;
251 QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
252 ~QSymbianMenuBarPrivate();
253 void addAction(QAction *, QSymbianMenuAction* =0);
254 void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
255 void syncAction(QSymbianMenuAction *);
256 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
257 void removeAction(QSymbianMenuAction *);
258 void rebuild();
259 inline void removeAction(QAction *a) { removeAction(findAction(a)); }
260 inline QSymbianMenuAction *findAction(QAction *a) {
261 for(int i = 0; i < actionItems.size(); i++) {
262 QSymbianMenuAction *act = actionItems[i];
263 if(a == act->action)
264 return act;
265 }
266 return 0;
267 }
268 void insertNativeMenuItems(const QList<QAction*> &actions);
269
270 } *symbian_menubar;
271 static int symbianCommands(int command);
272#endif
273#ifdef QT_SOFTKEYS_ENABLED
274 QAction *menuBarAction;
275#endif
276};
277#endif
278
279#endif // QT_NO_MENUBAR
280
281QT_END_NAMESPACE
282
283#endif // QMENUBAR_P_H
Note: See TracBrowser for help on using the repository browser.