1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
45 #include <QtWidgets/qmenu.h>
47 #include "QtWidgets/qmacdefines_mac.h"
59 class QMenuBarPrivate;
60 class QStyleOptionMenuItem;
63 class Q_WIDGETS_EXPORT QMenuBar : public QWidget
67 Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
68 Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
71 explicit QMenuBar(QWidget *parent = 0);
74 #ifdef Q_NO_USING_KEYWORD
75 void addAction(QAction *action) { QWidget::addAction(action); }
77 using QWidget::addAction;
79 QAction *addAction(const QString &text);
80 QAction *addAction(const QString &text, const QObject *receiver, const char* member);
82 QAction *addMenu(QMenu *menu);
83 QMenu *addMenu(const QString &title);
84 QMenu *addMenu(const QIcon &icon, const QString &title);
87 QAction *addSeparator();
88 QAction *insertSeparator(QAction *before);
90 QAction *insertMenu(QAction *before, QMenu *menu);
94 QAction *activeAction() const;
95 void setActiveAction(QAction *action);
97 void setDefaultUp(bool);
98 bool isDefaultUp() const;
100 QSize sizeHint() const;
101 QSize minimumSizeHint() const;
102 int heightForWidth(int) const;
104 QRect actionGeometry(QAction *) const;
105 QAction *actionAt(const QPoint &) const;
107 void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
108 QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
111 void setDefaultAction(QAction *);
112 QAction *defaultAction() const;
114 static void wceCommands(uint command);
115 static void wceRefresh();
118 bool isNativeMenuBar() const;
119 void setNativeMenuBar(bool nativeMenuBar);
120 QPlatformMenuBar *platformMenuBar();
122 virtual void setVisible(bool visible);
125 void triggered(QAction *action);
126 void hovered(QAction *action);
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;
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())
154 Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
158 friend class QMenuPrivate;
159 friend class QWindowsStyle;
162 friend class QApplicationPrivate;
163 friend class QWidgetPrivate;
164 friend bool qt_mac_activate_action(MenuRef, uint, QAction::ActionEvent, bool);
168 #endif // QT_NO_MENUBAR