1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.menubar;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.coreevent;
19 import qt.core.namespace;
20 import qt.core.object;
21 import qt.core.point;
22 import qt.core.rect;
23 import qt.core.size;
24 import qt.core.string;
25 import qt.gui.event;
26 import qt.gui.icon;
27 import qt.helpers;
28 import qt.widgets.action;
29 import qt.widgets.menu;
30 import qt.widgets.styleoption;
31 import qt.widgets.widget;
32 version(QT_NO_ACTION){}else
33     import qt.widgets.event;
34 
35 /+ QT_REQUIRE_CONFIG(menubar); +/
36 
37 
38 extern(C++, class) struct QMenuBarPrivate;
39 /+ class QStyleOptionMenuItem; +/
40 extern(C++, class) struct QWindowsStyle;
41 extern(C++, class) struct QPlatformMenuBar;
42 
43 class /+ Q_WIDGETS_EXPORT +/ QMenuBar : QWidget
44 {
45     mixin(Q_OBJECT);
46 
47     /+ Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
48     Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar) +/
49 
50 public:
51     /+ explicit +/this(QWidget parent = null);
52     ~this();
53 
54     /+ using QWidget::addAction; +/
55     alias addAction = QWidget.addAction;
56     final QAction addAction(ref const(QString) text);
57     final QAction addAction(ref const(QString) text, const(QObject) receiver, const(char)* member);
58 
59 /+ #ifdef Q_CLANG_QDOC
60     template<typename Obj, typename PointerToMemberFunctionOrFunctor>
61     QAction *addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method);
62     template<typename Functor>
63     QAction *addAction(const QString &text, Functor functor);
64 #else +/
65     // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
66     /+ template<typename Obj, typename Func1> +/
67     /+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
68         && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
69         addAction(const QString &text, const Obj *object, Func1 slot)
70     {
71         QAction *result = addAction(text);
72         connect(result, &QAction::triggered, object, std::move(slot));
73         return result;
74     } +/
75     // addAction(QString): Connect to a functor or function pointer (without context)
76     /+ template <typename Func1> +/
77     /+ inline QAction *addAction(const QString &text, Func1 slot)
78     {
79         QAction *result = addAction(text);
80         connect(result, &QAction::triggered, std::move(slot));
81         return result;
82     } +/
83 /+ #endif +/ // !Q_CLANG_QDOC
84 
85     final QAction addMenu(QMenu menu);
86     final QMenu addMenu(ref const(QString) title);
87     final QMenu addMenu(ref const(QIcon) icon, ref const(QString) title);
88 
89 
90     final QAction addSeparator();
91     final QAction insertSeparator(QAction before);
92 
93     final QAction insertMenu(QAction before, QMenu menu);
94 
95     final void clear();
96 
97     final QAction activeAction() const;
98     final void setActiveAction(QAction action);
99 
100     final void setDefaultUp(bool);
101     final bool isDefaultUp() const;
102 
103     override QSize sizeHint() const;
104     override QSize minimumSizeHint() const;
105     override int heightForWidth(int) const;
106 
107     final QRect actionGeometry(QAction ) const;
108     final QAction actionAt(ref const(QPoint) ) const;
109 
110     final void setCornerWidget(QWidget w, /+ Qt:: +/qt.core.namespace.Corner corner = /+ Qt:: +/qt.core.namespace.Corner.TopRightCorner);
111     final QWidget cornerWidget(/+ Qt:: +/qt.core.namespace.Corner corner = /+ Qt:: +/qt.core.namespace.Corner.TopRightCorner) const;
112 
113     version(OSX)
114     {
115         /+ NSMenu* toNSMenu(); +/
116     }
117 
118     final bool isNativeMenuBar() const;
119     final void setNativeMenuBar(bool nativeMenuBar);
120     final QPlatformMenuBar* platformMenuBar();
121 public /+ Q_SLOTS +/:
122     @QSlot override void setVisible(bool visible);
123 
124 /+ Q_SIGNALS +/public:
125     @QSignal final void triggered(QAction action);
126     @QSignal final void hovered(QAction action);
127 
128 protected:
129     override void changeEvent(QEvent );
130     override void keyPressEvent(QKeyEvent );
131     override void mouseReleaseEvent(QMouseEvent );
132     override void mousePressEvent(QMouseEvent );
133     override void mouseMoveEvent(QMouseEvent );
134     override void leaveEvent(QEvent );
135     override void paintEvent(QPaintEvent );
136     override void resizeEvent(QResizeEvent );
137     override void actionEvent(QActionEvent );
138     override void focusOutEvent(QFocusEvent );
139     override void focusInEvent(QFocusEvent );
140     override void timerEvent(QTimerEvent );
141     override bool eventFilter(QObject , QEvent );
142     override bool event(QEvent );
143     final 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     /+ friend class QMenu; +/
154     /+ friend class QMenuPrivate; +/
155     /+ friend class QWindowsStyle; +/
156 }
157