Fixed crash in GL 2 paint engine on Intel Atom.
[profile/ivi/qtbase.git] / src / widgets / widgets / qmenubar.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 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 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QMENUBAR_H
43 #define QMENUBAR_H
44
45 #include <QtWidgets/qmenu.h>
46 #ifdef Q_OS_MAC
47 #include "QtWidgets/qmacdefines_mac.h"
48 #endif
49
50
51 QT_BEGIN_HEADER
52
53 QT_BEGIN_NAMESPACE
54
55 QT_MODULE(Gui)
56
57 #ifndef QT_NO_MENUBAR
58
59 class QMenuBarPrivate;
60 class QStyleOptionMenuItem;
61 class QWindowsStyle;
62
63 class Q_WIDGETS_EXPORT QMenuBar : public QWidget
64 {
65     Q_OBJECT
66
67     Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
68     Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
69
70 public:
71     explicit QMenuBar(QWidget *parent = 0);
72     ~QMenuBar();
73
74 #ifdef Q_NO_USING_KEYWORD
75     void addAction(QAction *action) { QWidget::addAction(action); }
76 #else
77     using QWidget::addAction;
78 #endif
79     QAction *addAction(const QString &text);
80     QAction *addAction(const QString &text, const QObject *receiver, const char* member);
81
82     QAction *addMenu(QMenu *menu);
83     QMenu *addMenu(const QString &title);
84     QMenu *addMenu(const QIcon &icon, const QString &title);
85
86
87     QAction *addSeparator();
88     QAction *insertSeparator(QAction *before);
89
90     QAction *insertMenu(QAction *before, QMenu *menu);
91
92     void clear();
93
94     QAction *activeAction() const;
95     void setActiveAction(QAction *action);
96
97     void setDefaultUp(bool);
98     bool isDefaultUp() const;
99
100     QSize sizeHint() const;
101     QSize minimumSizeHint() const;
102     int heightForWidth(int) const;
103
104     QRect actionGeometry(QAction *) const;
105     QAction *actionAt(const QPoint &) const;
106
107     void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
108     QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
109
110 #ifdef Q_WS_WINCE
111     void setDefaultAction(QAction *);
112     QAction *defaultAction() const;
113
114     static void wceCommands(uint command);
115     static void wceRefresh();
116 #endif
117
118     bool isNativeMenuBar() const;
119     void setNativeMenuBar(bool nativeMenuBar);
120     QPlatformMenuBar *platformMenuBar();
121 public Q_SLOTS:
122     virtual void setVisible(bool visible);
123
124 Q_SIGNALS:
125     void triggered(QAction *action);
126     void hovered(QAction *action);
127
128 protected:
129     void changeEvent(QEvent *);
130     void keyPressEvent(QKeyEvent *);
131     void mouseReleaseEvent(QMouseEvent *);
132     void mousePressEvent(QMouseEvent *);
133     void mouseMoveEvent(QMouseEvent *);
134     void leaveEvent(QEvent *);
135     void paintEvent(QPaintEvent *);
136     void resizeEvent(QResizeEvent *);
137     void actionEvent(QActionEvent *);
138     void focusOutEvent(QFocusEvent *);
139     void focusInEvent(QFocusEvent *);
140     void timerEvent(QTimerEvent *);
141     bool eventFilter(QObject *, QEvent *);
142     bool event(QEvent *);
143     void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
144
145 private:
146     Q_DECLARE_PRIVATE(QMenuBar)
147     Q_DISABLE_COPY(QMenuBar)
148     Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
149     Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
150     Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
151     Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
152
153 #ifdef Q_WS_WINCE
154     Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
155 #endif
156
157     friend class QMenu;
158     friend class QMenuPrivate;
159     friend class QWindowsStyle;
160
161 #ifdef Q_OS_MAC
162     friend class QApplicationPrivate;
163     friend class QWidgetPrivate;
164     friend bool qt_mac_activate_action(MenuRef, uint, QAction::ActionEvent, bool);
165 #endif
166 };
167
168 #endif // QT_NO_MENUBAR
169
170 QT_END_NAMESPACE
171
172 QT_END_HEADER
173
174 #endif // QMENUBAR_H