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