Qt 4.8
qmenubar_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 // platformMenuBarementation 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 #ifdef Q_WS_X11
66 #endif
67 
68 #ifndef QT_NO_MENUBAR
69 #ifdef Q_WS_S60
70 class CCoeControl;
71 class CEikMenuBar;
72 #endif
73 #endif
74 
76 
77 #ifndef QT_NO_MENUBAR
78 class QToolBar;
79 class QMenuBarExtension;
81 {
83 public:
86 #ifndef Q_WS_X11
87  , nativeMenuBar(-1)
88 #endif
89  , doChildEffects(false)
90 #ifdef QT3_SUPPORT
91  , doAutoResize(false)
92 #endif
93 #ifdef Q_WS_MAC
94  , mac_menubar(0)
95 #endif
96 #ifdef Q_WS_X11
97  , platformMenuBar(0)
98 #endif
99 #ifdef Q_WS_WINCE
100  , wce_menubar(0), wceClassicMenu(false)
101 #endif
102 #ifdef Q_WS_S60
103  , symbian_menubar(0)
104 #endif
105 
106  { }
108  {
109 #ifdef Q_WS_X11
110  delete platformMenuBar;
111 #endif
112 #ifdef Q_WS_MAC
113  delete mac_menubar;
114 #endif
115 #ifdef Q_WS_WINCE
116  delete wce_menubar;
117 #endif
118 #ifdef Q_WS_S60
119  delete symbian_menubar;
120 #endif
121  }
122 
123  void init();
124  QAction *getNextAction(const int start, const int increment) const;
125 
126  //item calculations
128 
131  void calcActionRects(int max_width, int start) const;
132  QRect actionRect(QAction *) const;
133  void updateGeometries();
134 
135  //selection
138  QAction *actionAt(QPoint p) const;
139  void setCurrentAction(QAction *, bool =false, bool =false);
140  void popupAction(QAction *, bool);
141 
142  //active popup state
145 
146  //keyboard mode for keyboard navigation
147  void focusFirstAction();
148  void setKeyboardMode(bool);
151 
152 #ifndef Q_WS_X11
153  int nativeMenuBar : 3; // Only has values -1, 0, and 1
154 #endif
155  //firing of events
157 
158  void _q_actionTriggered();
159  void _q_actionHovered();
161  void _q_updateLayout();
162 
163 #ifdef Q_WS_WINCE
164  void _q_updateDefaultAction();
165 #endif
166 
167  //extra widgets in the menubar
170  bool isVisible(QAction *action);
171 
172  //menu fading/scrolling effects
174 
175  QRect menuRect(bool) const;
176 
177  // reparenting
178  void handleReparent();
181 
183  //default action
185 
187 #ifdef QT3_SUPPORT
188  bool doAutoResize;
189 #endif
190 #ifdef Q_WS_X11
192 #endif
193 #ifdef Q_WS_MAC
194  //mac menubar binding
200 
201  void addAction(QAction *, QAction* =0);
203  void syncAction(QMacMenuAction *);
204  inline void syncAction(QAction *a) { syncAction(findAction(a)); }
208  for(int i = 0; i < actionItems.size(); i++) {
209  QMacMenuAction *act = actionItems[i];
210  if(a == act->action)
211  return act;
212  }
213  return 0;
214  }
215  } *mac_menubar;
216  static bool macUpdateMenuBarImmediatly();
218  void macCreateMenuBar(QWidget *);
219  void macDestroyMenuBar();
220  OSMenuRef macMenu();
221 #endif
222 #ifdef Q_WS_WINCE
223  void wceCreateMenuBar(QWidget *);
224  void wceDestroyMenuBar();
229  HMENU menuHandle;
237 
240  void addAction(QAction *, QAction* =0);
242  void syncAction(QWceMenuAction *);
243  inline void syncAction(QAction *a) { syncAction(findAction(a)); }
245  void rebuild();
248  for(int i = 0; i < actionItems.size(); i++) {
249  QWceMenuAction *act = actionItems[i];
250  if(a == act->action)
251  return act;
252  }
253  return 0;
254  }
255  } *wce_menubar;
257  void wceCommands(uint command);
258  void wceRefresh();
260 #endif
261 #ifdef Q_WS_S60
262  void symbianCreateMenuBar(QWidget *);
263  void symbianDestroyMenuBar();
264  void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
265  struct QSymbianMenuBarPrivate {
268  QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
269  ~QSymbianMenuBarPrivate();
270  void addAction(QAction *, QAction* =0);
271  void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
272  void syncAction(QSymbianMenuAction *);
273  inline void syncAction(QAction *a) { syncAction(findAction(a)); }
274  void removeAction(QSymbianMenuAction *);
275  void rebuild();
276  inline void removeAction(QAction *a) { removeAction(findAction(a)); }
277  inline QSymbianMenuAction *findAction(QAction *a) {
278  for(int i = 0; i < actionItems.size(); i++) {
279  QSymbianMenuAction *act = actionItems[i];
280  if(a == act->action)
281  return act;
282  }
283  return 0;
284  }
285  void insertNativeMenuItems(const QList<QAction*> &actions);
286 
287  } *symbian_menubar;
288  static int symbianCommands(int command);
289 #endif
290 #ifdef QT_SOFTKEYS_ENABLED
291  QAction *menuBarAction;
292 #endif
293 
294 #ifdef Q_WS_X11
298 #endif
299 };
300 #endif
301 
302 #endif // QT_NO_MENUBAR
303 
305 
306 #endif // QMENUBAR_P_H
QBasicTimer autoReleaseTimer
Definition: qmenubar_p.h:186
void setKeyboardMode(bool)
Definition: qmenubar.cpp:313
double d
Definition: qnumeric_p.h:62
void removeAction(QMacMenuAction *)
Definition: qmenu_mac.mm:1766
QList< QList< QWceMenuAction * > > actionItemsClassic
Definition: qmenubar_p.h:228
void wceCommands(uint command)
struct QMenuBarPrivate::QWceMenuBarPrivate * wce_menubar
QList< QWceMenuAction * > actionItems
Definition: qmenubar_p.h:226
QWidget * cornerWidgetContainer
Definition: qmenubar_p.h:297
QRect actionRect(QAction *) const
Definition: qmenubar.cpp:289
QPointer< QWidget > keyboardFocusWidget
Definition: qmenubar_p.h:150
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
QPointer< QAction > currentAction
Definition: qmenubar_p.h:136
bool isVisible(QAction *action)
Definition: qmenubar.cpp:170
void focusFirstAction()
Definition: qmenubar.cpp:302
ActionEvent
This enum type is used when calling QAction::activate()
Definition: qaction.h:176
QToolBar * cornerWidgetToolBar
Definition: qmenubar_p.h:296
QMenuBarExtension * extension
Definition: qmenubar_p.h:169
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QList< QWceMenuAction * > actionItemsLeftButton
Definition: qmenubar_p.h:227
long ASN1_INTEGER_get ASN1_INTEGER * a
void addAction(QAction *, QAction *=0)
Definition: qmenu_mac.mm:1646
QAction * getNextAction(const int start, const int increment) const
Definition: qmenubar.cpp:795
void macCreateMenuBar(QWidget *)
Definition: qmenu_mac.mm:1790
bool wceEmitSignals(QList< QWceMenuAction *> actions, uint command)
QPointer< QWidget > leftWidget
Definition: qmenubar_p.h:168
QVector< QRect > actionRects
Definition: qmenubar_p.h:130
void wceCreateMenuBar(QWidget *)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QWidget * oldWindow
Definition: qmenubar_p.h:180
QList< QMacMenuAction * > actionItems
Definition: qmenubar_p.h:196
void _q_internalShortcutActivated(int)
Definition: qmenubar.cpp:1901
void calcActionRects(int max_width, int start) const
Definition: qmenubar.cpp:434
void popupAction(QAction *, bool)
Definition: qmenubar.cpp:339
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
unsigned int uint
Definition: qglobal.h:996
void handleReparent()
Definition: qmenubar.cpp:1404
QList< QAction * > hiddenActions
Definition: qmenubar_p.h:182
The platform-specific implementation of a menubar.
void macDestroyMenuBar()
Definition: qmenu_mac.mm:1824
MenuRef OSMenuRef
QPointer< QMenu > activeMenu
Definition: qmenubar_p.h:144
static bool macUpdateMenuBarImmediatly()
Definition: qmenu_mac.mm:2066
void setCurrentAction(QAction *, bool=false, bool=false)
Definition: qmenubar.cpp:391
QPointer< QAction > defaultAction
Definition: qmenubar_p.h:184
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
QPointer< QAction > action
Definition: qmenu_p.h:129
struct QMenuBarPrivate::QMacMenuBarPrivate * mac_menubar
QAbstractPlatformMenuBar * platformMenuBar
Definition: qmenubar_p.h:191
QWidget * oldParent
Definition: qmenubar_p.h:179
QRect menuRect(bool) const
Definition: qmenubar.cpp:136
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void _q_actionTriggered()
Definition: qmenubar.cpp:546
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< QAction * > actions
Definition: qwidget_p.h:760
void updateGeometries()
Definition: qmenubar.cpp:175
void _q_updateLayout()
Definition: qmenubar.cpp:1924
bool macWidgetHasNativeMenubar(QWidget *widget)
Definition: qmenu_mac.mm:1779
QVector< int > shortcutIndexMap
Definition: qmenubar_p.h:129
void syncAction(QMacMenuAction *)
Definition: qmenu_mac.mm:1705
The QBasicTimer class provides timer events for objects.
Definition: qbasictimer.h:55
void wceDestroyMenuBar()
#define Q_WS_WINCE
Definition: qglobal.h:895
QPointer< QAction > action
Definition: qmenu_p.h:108
QPointer< QAction > leftButtonAction
Definition: qmenubar_p.h:234
QWceMenuAction * findAction(QAction *a)
Definition: qmenubar_p.h:247
void updateCornerWidgetToolBar()
Definition: qmenubar.cpp:1935
void _q_updateDefaultAction()
OSMenuRef macMenu()
Definition: qmenu_mac.mm:1847
void activateAction(QAction *, QAction::ActionEvent)
Definition: qmenubar.cpp:530
QMacMenuAction * findAction(QAction *a)
Definition: qmenubar_p.h:207
void _q_actionHovered()
Definition: qmenubar.cpp:557
QPointer< QWidget > rightWidget
Definition: qmenubar_p.h:168
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
QAction * actionAt(QPoint p) const
Definition: qmenubar.cpp:127
The QList class is a template class that provides lists.
Definition: qdatastream.h:62