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

Last change on this file since 694 was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 8.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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 [email protected].
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 bool macWidgetHasNativeMenubar(QWidget *widget);
200 void macCreateMenuBar(QWidget *);
201 void macDestroyMenuBar();
202 OSMenuRef macMenu();
203#endif
204#ifdef Q_WS_WINCE
205 void wceCreateMenuBar(QWidget *);
206 void wceDestroyMenuBar();
207 struct QWceMenuBarPrivate {
208 QList<QWceMenuAction*> actionItems;
209 QList<QWceMenuAction*> actionItemsLeftButton;
210 QList<QList<QWceMenuAction*>> actionItemsClassic;
211 HMENU menuHandle;
212 HMENU leftButtonMenuHandle;
213 HWND menubarHandle;
214 HWND parentWindowHandle;
215 bool leftButtonIsMenu;
216 QPointer<QAction> leftButtonAction;
217 QMenuBarPrivate *d;
218 int leftButtonCommand;
219
220 QWceMenuBarPrivate(QMenuBarPrivate *menubar);
221 ~QWceMenuBarPrivate();
222 void addAction(QAction *, QWceMenuAction* =0);
223 void addAction(QWceMenuAction *, QWceMenuAction* =0);
224 void syncAction(QWceMenuAction *);
225 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
226 void removeAction(QWceMenuAction *);
227 void rebuild();
228 inline void removeAction(QAction *a) { removeAction(findAction(a)); }
229 inline QWceMenuAction *findAction(QAction *a) {
230 for(int i = 0; i < actionItems.size(); i++) {
231 QWceMenuAction *act = actionItems[i];
232 if(a == act->action)
233 return act;
234 }
235 return 0;
236 }
237 } *wce_menubar;
238 bool wceClassicMenu;
239 void wceCommands(uint command);
240 void wceRefresh();
241 bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command);
242#endif
243#ifdef Q_WS_S60
244 void symbianCreateMenuBar(QWidget *);
245 void symbianDestroyMenuBar();
246 struct QSymbianMenuBarPrivate {
247 QList<QSymbianMenuAction*> actionItems;
248 QMenuBarPrivate *d;
249 QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
250 ~QSymbianMenuBarPrivate();
251 void addAction(QAction *, QSymbianMenuAction* =0);
252 void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
253 void syncAction(QSymbianMenuAction *);
254 inline void syncAction(QAction *a) { syncAction(findAction(a)); }
255 void removeAction(QSymbianMenuAction *);
256 void rebuild();
257 inline void removeAction(QAction *a) { removeAction(findAction(a)); }
258 inline QSymbianMenuAction *findAction(QAction *a) {
259 for(int i = 0; i < actionItems.size(); i++) {
260 QSymbianMenuAction *act = actionItems[i];
261 if(a == act->action)
262 return act;
263 }
264 return 0;
265 }
266 void insertNativeMenuItems(const QList<QAction*> &actions);
267
268 } *symbian_menubar;
269 static int symbianCommands(int command);
270
271#endif
272};
273#endif
274
275#endif // QT_NO_MENUBAR
276
277QT_END_NAMESPACE
278
279#endif // QMENUBAR_P_H
Note: See TracBrowser for help on using the repository browser.