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.mainwindow;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.bytearray;
19 import qt.core.coreevent;
20 import qt.core.flags;
21 import qt.core.list;
22 import qt.core.namespace;
23 import qt.core.point;
24 import qt.core.size;
25 import qt.core.string;
26 import qt.helpers;
27 import qt.widgets.dockwidget;
28 import qt.widgets.menu;
29 import qt.widgets.menubar;
30 import qt.widgets.statusbar;
31 import qt.widgets.tabwidget;
32 import qt.widgets.toolbar;
33 import qt.widgets.widget;
34 version(QT_NO_CONTEXTMENU){}else
35     import qt.gui.event;
36 
37 /+ #if QT_CONFIG(tabwidget)
38 #endif
39 
40 QT_REQUIRE_CONFIG(mainwindow);
41 
42 
43 class QDockWidget; +/
44 extern(C++, class) struct QMainWindowPrivate;
45 /+ class QMenuBar;
46 class QStatusBar;
47 class QToolBar;
48 class QMenu; +/
49 
50 class /+ Q_WIDGETS_EXPORT +/ QMainWindow : QWidget
51 {
52     mixin(Q_OBJECT);
53 
54     /+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
55     Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
56 #if QT_CONFIG(dockwidget)
57     Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
58 #if QT_CONFIG(tabbar)
59     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
60 #endif // QT_CONFIG(tabbar)
61 #if QT_CONFIG(tabwidget)
62     Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
63 #endif // QT_CONFIG(tabwidget)
64     Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
65 #endif // QT_CONFIG(dockwidget)
66     Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
67 #if QT_CONFIG(toolbar)
68     Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
69 #endif +/
70 
71 public:
72     enum DockOption {
73         AnimatedDocks = 0x01,
74         AllowNestedDocks = 0x02,
75         AllowTabbedDocks = 0x04,
76         ForceTabbedDocks = 0x08,  // implies AllowTabbedDocks, !AllowNestedDocks
77         VerticalTabs = 0x10,      // implies AllowTabbedDocks
78         GroupedDragging = 0x20    // implies AllowTabbedDocks
79     }
80     /+ Q_ENUM(DockOption) +/
81     /+ Q_DECLARE_FLAGS(DockOptions, DockOption) +/
82 alias DockOptions = QFlags!(DockOption);    /+ Q_FLAG(DockOptions) +/
83 
84     /+ explicit +/this(QWidget parent = null, /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags());
85     ~this();
86 
87     final QSize iconSize() const;
88     final void setIconSize(ref const(QSize) iconSize);
89 
90     final /+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle() const;
91     final void setToolButtonStyle(/+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle);
92 
93 /+ #if QT_CONFIG(dockwidget) +/
94     final bool isAnimated() const;
95     final bool isDockNestingEnabled() const;
96 /+ #endif
97 
98 #if QT_CONFIG(tabbar) +/
99     final bool documentMode() const;
100     final void setDocumentMode(bool enabled);
101 /+ #endif
102 
103 #if QT_CONFIG(tabwidget) +/
104     final QTabWidget.TabShape tabShape() const;
105     final void setTabShape(QTabWidget.TabShape tabShape);
106     final QTabWidget.TabPosition tabPosition(/+ Qt:: +/qt.core.namespace.DockWidgetArea area) const;
107     final void setTabPosition(/+ Qt:: +/qt.core.namespace.DockWidgetAreas areas, QTabWidget.TabPosition tabPosition);
108 /+ #endif +/ // QT_CONFIG(tabwidget)
109 
110     final void setDockOptions(DockOptions options);
111     final DockOptions dockOptions() const;
112 
113     final bool isSeparator(ref const(QPoint) pos) const;
114 
115 /+ #if QT_CONFIG(menubar) +/
116     final QMenuBar menuBar() const;
117     final void setMenuBar(QMenuBar menubar);
118 
119     final QWidget  menuWidget() const;
120     final void setMenuWidget(QWidget menubar);
121 /+ #endif
122 
123 #if QT_CONFIG(statusbar) +/
124     final QStatusBar statusBar() const;
125     final void setStatusBar(QStatusBar statusbar);
126 /+ #endif +/
127 
128     final QWidget centralWidget() const;
129     final void setCentralWidget(QWidget widget);
130 
131     final QWidget takeCentralWidget();
132 
133 /+ #if QT_CONFIG(dockwidget) +/
134     final void setCorner(/+ Qt:: +/qt.core.namespace.Corner corner, /+ Qt:: +/qt.core.namespace.DockWidgetArea area);
135     final /+ Qt:: +/qt.core.namespace.DockWidgetArea corner(/+ Qt:: +/qt.core.namespace.Corner corner) const;
136 /+ #endif
137 
138 #if QT_CONFIG(toolbar) +/
139     final void addToolBarBreak(/+ Qt:: +/qt.core.namespace.ToolBarArea area = /+ Qt:: +/qt.core.namespace.ToolBarArea.TopToolBarArea);
140     final void insertToolBarBreak(QToolBar before);
141 
142     final void addToolBar(/+ Qt:: +/qt.core.namespace.ToolBarArea area, QToolBar toolbar);
143     final void addToolBar(QToolBar toolbar);
144     final QToolBar addToolBar(ref const(QString) title);
145     final void insertToolBar(QToolBar before, QToolBar toolbar);
146     final void removeToolBar(QToolBar toolbar);
147     final void removeToolBarBreak(QToolBar before);
148 
149     final bool unifiedTitleAndToolBarOnMac() const;
150 
151     final /+ Qt:: +/qt.core.namespace.ToolBarArea toolBarArea(
152     /+ #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
153             const
154     #endif +/
155             QToolBar toolbar) const;
156     final bool toolBarBreak(QToolBar toolbar) const;
157 /+ #endif
158 #if QT_CONFIG(dockwidget) +/
159     final void addDockWidget(/+ Qt:: +/qt.core.namespace.DockWidgetArea area, QDockWidget dockwidget);
160     final void addDockWidget(/+ Qt:: +/qt.core.namespace.DockWidgetArea area, QDockWidget dockwidget,
161                            /+ Qt:: +/qt.core.namespace.Orientation orientation);
162     final void splitDockWidget(QDockWidget after, QDockWidget dockwidget,
163                              /+ Qt:: +/qt.core.namespace.Orientation orientation);
164 /+ #if QT_CONFIG(tabbar) +/
165     final void tabifyDockWidget(QDockWidget first, QDockWidget second);
166     final QList!(QDockWidget) tabifiedDockWidgets(QDockWidget dockwidget) const;
167 /+ #endif +/
168     final void removeDockWidget(QDockWidget dockwidget);
169     final bool restoreDockWidget(QDockWidget dockwidget);
170 
171     final /+ Qt:: +/qt.core.namespace.DockWidgetArea dockWidgetArea(QDockWidget dockwidget) const;
172 
173     final void resizeDocks(ref const(QList!(QDockWidget)) docks,
174                          ref const(QList!(int)) sizes, /+ Qt:: +/qt.core.namespace.Orientation orientation);
175 /+ #endif +/ // QT_CONFIG(dockwidget)
176 
177     final QByteArray saveState(int version_ = 0) const;
178     final bool restoreState(ref const(QByteArray) state, int version_ = 0);
179 
180 /+ #if QT_CONFIG(menu) +/
181     /+ virtual +/ QMenu createPopupMenu();
182 /+ #endif +/
183 
184 public /+ Q_SLOTS +/:
185 /+ #if QT_CONFIG(dockwidget) +/
186     @QSlot final void setAnimated(bool enabled);
187     @QSlot final void setDockNestingEnabled(bool enabled);
188 /+ #endif
189 #if QT_CONFIG(toolbar) +/
190     @QSlot final void setUnifiedTitleAndToolBarOnMac(bool set);
191 /+ #endif +/
192 
193 /+ Q_SIGNALS +/public:
194     @QSignal final void iconSizeChanged(ref const(QSize) iconSize);
195     @QSignal final void toolButtonStyleChanged(/+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle);
196 /+ #if QT_CONFIG(dockwidget) +/
197     @QSignal final void tabifiedDockWidgetActivated(QDockWidget dockWidget);
198 /+ #endif +/
199 
200 protected:
201     version(QT_NO_CONTEXTMENU){}else
202     {
203         override void contextMenuEvent(QContextMenuEvent event);
204     }
205     override bool event(QEvent event);
206 
207 private:
208     /+ Q_DECLARE_PRIVATE(QMainWindow) +/
209     /+ Q_DISABLE_COPY(QMainWindow) +/
210 }
211 /+pragma(inline, true) QFlags!(QMainWindow.DockOptions.enum_type) operator |(QMainWindow.DockOptions.enum_type f1, QMainWindow.DockOptions.enum_type f2)/+noexcept+/{return QFlags!(QMainWindow.DockOptions.enum_type)(f1)|f2;}+/
212 /+pragma(inline, true) QFlags!(QMainWindow.DockOptions.enum_type) operator |(QMainWindow.DockOptions.enum_type f1, QFlags!(QMainWindow.DockOptions.enum_type) f2)/+noexcept+/{return f2|f1;}+/
213 /+pragma(inline, true) QIncompatibleFlag operator |(QMainWindow.DockOptions.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/
214 
215 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions) +/