47 #ifndef QT_NO_MAINWINDOW 60 #include <private/qwidget_p.h> 64 #include <private/qt_mac_p.h> 65 #include <private/qt_cocoa_helpers_mac_p.h> 97 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) 116 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 143 Q_ASSERT_X(
false,
"qt_setMainWindowTitleWidget",
"Unknown area");
148 delete oldItem->widget();
149 topLayout->
addWidget(widget, row, column);
157 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 463 d->layout->setDockOptions(opt);
469 return d->layout->dockOptions;
473 {
return d_func()->iconSize; }
481 sz =
QSize(metric, metric);
483 if (
d->iconSize != sz) {
487 d->explicitIconSize = iconSize.
isValid();
500 {
return d_func()->toolButtonStyle; }
505 if (
d->toolButtonStyle == toolButtonStyle)
511 #ifndef QT_NO_MENUBAR 533 self->setMenuBar(menuBar);
598 if (
d->layout->menuBar() &&
d->layout->menuBar() !=
menuBar) {
599 d->layout->menuBar()->hide();
600 d->layout->menuBar()->deleteLater();
602 d->layout->setMenuBar(menuBar);
604 #endif // QT_NO_MENUBAR 606 #ifndef QT_NO_STATUSBAR 620 self->setStatusBar(statusbar);
637 if (
d->layout->statusBar() &&
d->layout->statusBar() != statusbar) {
638 d->layout->statusBar()->hide();
639 d->layout->statusBar()->deleteLater();
641 d->layout->setStatusBar(statusbar);
643 #endif // QT_NO_STATUSBAR 652 {
return d_func()->
layout->centralWidget(); }
665 if (
d->layout->centralWidget() &&
d->layout->centralWidget() !=
widget) {
666 d->layout->centralWidget()->hide();
667 d->layout->centralWidget()->deleteLater();
669 d->layout->setCentralWidget(widget);
672 #ifndef QT_NO_DOCKWIDGET 697 qWarning(
"QMainWindow::setCorner(): 'area' is not valid for 'corner'");
699 d_func()->layout->setCorner(corner, area);
709 {
return d_func()->layout->corner(corner); }
712 #ifndef QT_NO_TOOLBAR 725 qWarning(
"%s: invalid 'area' argument", where);
737 d_func()->layout->addToolBarBreak(area);
744 { d_func()->layout->insertToolBarBreak(before); }
753 d->layout->removeToolBarBreak(before);
772 toolbar,
SLOT(_q_updateIconSize(
QSize)));
776 if(toolbar->d_func()->state && toolbar->d_func()->state->dragging) {
778 #ifndef QT_NO_DOCKWIDGET 782 toolbar->d_func()->endDrag();
783 #ifndef QT_NO_DOCKWIDGET 788 if (!
d->layout->usesHIToolBar(toolbar)) {
789 d->layout->removeWidget(toolbar);
791 d->layout->removeToolBar(toolbar);
794 toolbar->d_func()->_q_updateIconSize(
d->iconSize);
795 toolbar->d_func()->_q_updateToolButtonStyle(
d->toolButtonStyle);
797 toolbar,
SLOT(_q_updateIconSize(
QSize)));
801 d->layout->addToolBar(area, toolbar);
841 d->layout->removeToolBar(toolbar);
843 toolbar->d_func()->_q_updateIconSize(
d->iconSize);
844 toolbar->d_func()->_q_updateToolButtonStyle(
d->toolButtonStyle);
846 toolbar,
SLOT(_q_updateIconSize(
QSize)));
850 d->layout->insertToolBar(before, toolbar);
860 d_func()->layout->removeToolBar(toolbar);
873 {
return d_func()->layout->toolBarArea(toolbar); }
884 return d_func()->layout->toolBarBreak(toolbar);
887 #endif // QT_NO_TOOLBAR 889 #ifndef QT_NO_DOCKWIDGET 924 DockOptions opts =
d->layout->dockOptions;
930 d->layout->setDockOptions(opts);
966 DockOptions opts =
d->layout->dockOptions;
972 d->layout->setDockOptions(opts);
992 bool QMainWindow::verticalTabsEnabled()
const 994 return d_func()->layout->verticalTabsEnabled();
997 void QMainWindow::setVerticalTabsEnabled(
bool enabled)
999 d_func()->layout->setVerticalTabsEnabled(enabled);
1014 qWarning(
"%s: invalid 'area' argument", where);
1018 #ifndef QT_NO_TABBAR 1033 return d_func()->layout->documentMode();
1038 d_func()->layout->setDocumentMode(enabled);
1040 #endif // QT_NO_TABBAR 1042 #ifndef QT_NO_TABWIDGET 1057 return d_func()->layout->tabShape();
1062 d_func()->layout->setTabShape(tabShape);
1082 return d_func()->layout->tabPosition(area);
1101 d_func()->layout->setTabPosition(areas, tabPosition);
1103 #endif // QT_NO_TABWIDGET 1122 d_func()->layout->removeWidget(dockwidget);
1125 #ifdef Q_WS_MAC //drawer support 1151 return d_func()->layout->restoreDockWidget(dockwidget);
1165 d_func()->layout->addDockWidget(area, dockwidget, orientation);
1192 d_func()->layout->splitDockWidget(after, dockwidget, orientation);
1205 d_func()->layout->tabifyDockWidget(first, second);
1221 #if defined(QT_NO_TABBAR) 1230 if (dock != dockwidget) {
1249 d_func()->layout->removeWidget(dockwidget);
1262 {
return d_func()->layout->dockWidgetArea(dockwidget); }
1264 #endif // QT_NO_DOCKWIDGET 1291 d_func()->layout->saveState(stream);
1321 bool restored = d_func()->layout->restoreState(stream);
1325 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) 1330 if (path.
size() == 1) {
1332 switch (path.
first()) {
1356 if (pos ==
QPoint(0, 0)) {
1357 if (!hoverSeparator.isEmpty())
1358 q->update(
layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
1359 hoverSeparator.clear();
1361 if (cursorAdjusted) {
1362 cursorAdjusted =
false;
1364 q->setCursor(oldCursor);
1370 =
layout->layoutState.dockAreaLayout.findSeparator(pos);
1372 if (pathToSeparator != hoverSeparator) {
1373 if (!hoverSeparator.isEmpty())
1374 q->
update(
layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
1376 hoverSeparator = pathToSeparator;
1378 if (hoverSeparator.isEmpty()) {
1379 if (cursorAdjusted) {
1380 cursorAdjusted =
false;
1382 q->setCursor(oldCursor);
1387 q->update(
layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
1388 if (!cursorAdjusted) {
1389 oldCursor = q->cursor();
1393 cursorAdjusted =
false;
1394 q->setCursor(cursor);
1395 cursorAdjusted =
true;
1406 switch (event->
type()) {
1408 #ifndef QT_NO_DOCKWIDGET 1412 d->layout->layoutState.dockAreaLayout.paintSeparators(&p,
this, r,
d->hoverPos);
1416 #ifndef QT_NO_CURSOR 1418 d->adjustCursor(static_cast<QHoverEvent*>(event)->
pos());
1427 d->adjustCursor(
QPoint(0, 0));
1430 d->adjustCursor(
QPoint(0, 0));
1432 #endif // QT_NO_CURSOR 1447 #ifndef QT_NO_CURSOR 1448 d->adjustCursor(e->
pos());
1451 if (
d->layout->separatorMove(e->
pos())) {
1463 if (
d->layout->endSeparatorMove(e->
pos())) {
1473 #ifndef QT_NO_TOOLBAR 1475 d->layout->toggleToolBarsVisible();
1480 #ifndef QT_NO_STATUSTIP 1482 #ifndef QT_NO_STATUSBAR 1484 sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip());
1489 #endif // QT_NO_STATUSTIP 1492 #ifndef QT_NO_DOCKWIDGET 1493 d->layout->layoutState.dockAreaLayout.styleChangedEvent();
1495 if (!
d->explicitIconSize)
1500 d->layout->blockVisiblityCheck =
false;
1502 d->layout->syncUnifiedToolbarVisibility();
1508 d->layout->blockVisiblityCheck =
true;
1510 # ifdef QT_MAC_USE_COCOA 1514 d->layout->updateHIToolBarStatus();
1520 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) 1522 if (
d->cursorAdjusted) {
1535 #ifndef QT_NO_TOOLBAR 1574 d->useHIToolBar =
set;
1577 #ifdef QT_MAC_USE_COCOA 1582 #endif // QT_MAC_USE_COCOA 1584 d->layout->updateHIToolBarStatus();
1586 #ifdef QT_MAC_USE_COCOA 1589 if (
d->layout->unifiedSurface) {
1590 delete d->layout->unifiedSurface;
1591 d->layout->unifiedSurface = 0;
1594 #endif // QT_MAC_USE_COCOA 1597 d->macUpdateOpaqueSizeGrip();
1611 #endif // QT_NO_TOOLBAR 1618 #ifndef QT_NO_DOCKWIDGET 1620 return !
d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty();
1627 #ifndef QT_NO_CONTEXTMENU 1637 while (child && child !=
this) {
1638 #ifndef QT_NO_MENUBAR 1639 if (
QMenuBar *mb = qobject_cast<QMenuBar *>(child)) {
1640 if (mb->parentWidget() !=
this)
1645 #ifndef QT_NO_DOCKWIDGET 1646 if (
QDockWidget *dw = qobject_cast<QDockWidget *>(child)) {
1647 if (dw->parentWidget() !=
this)
1650 && dw->widget()->geometry().contains(child->
mapFrom(
this, event->
pos()))) {
1656 #endif // QT_NO_DOCKWIDGET 1657 #ifndef QT_NO_TOOLBAR 1658 if (
QToolBar *tb = qobject_cast<QToolBar *>(child)) {
1659 if (tb->parentWidget() !=
this)
1682 #endif // QT_NO_CONTEXTMENU 1704 #ifndef QT_NO_DOCKWIDGET 1706 if (dockwidgets.
size()) {
1707 menu =
new QMenu(
this);
1708 for (
int i = 0; i < dockwidgets.
size(); ++i) {
1711 && !
d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) {
1717 #endif // QT_NO_DOCKWIDGET 1718 #ifndef QT_NO_TOOLBAR 1720 if (toolbars.
size()) {
1722 menu =
new QMenu(
this);
1723 for (
int i = 0; i < toolbars.
size(); ++i) {
1726 && (!
d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty()
1737 #endif // QT_NO_MENU 1741 #endif // QT_NO_MAINWINDOW
T qobject_cast(QObject *object)
The QPainter class performs low-level painting on widgets and other paint devices.
Status status() const
Returns the status of the data stream.
Qt::WindowStates oldState() const
Returns the state of the window before the change.
virtual QMenu * createPopupMenu()
Returns a popup menu containing checkable entries for the toolbars and dock widgets present in the ma...
QList< QDockAreaLayoutItem > item_list
QLayoutItem * itemAtPosition(int row, int column) const
Returns the layout item that occupies cell (row, column), or 0 if the cell is empty.
void setDockNestingEnabled(bool enabled)
The QCursor class provides a mouse cursor with an arbitrary shape.
static mach_timebase_info_data_t info
void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition)
Sets the tab position for the given dock widget areas to the specified tabPosition.
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
bool unifiedTitleAndToolBarOnMac() const
QMainWindow(QWidget *parent=0, Qt::WindowFlags flags=0)
Constructs a QMainWindow with the given parent and the specified widget flags.
void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, Qt::Orientation orientation)
Splits the space covered by the first dock widget into two parts, moves the first dock widget into th...
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
void adjustCursor(const QPoint &pos)
DockOptions dockOptions() const
The QByteArray class provides an array of bytes.
Qt::DockWidgetArea corner(Qt::Corner corner) const
Returns the dock widget area that occupies the specified corner.
Qt::ToolButtonStyle toolButtonStyle() const
static bool ignore(const char *test, const char *const *table)
void insertToolBarBreak(QToolBar *before)
Inserts a toolbar break before the toolbar specified by before.
Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const
Returns the Qt::DockWidgetArea for dockwidget.
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
QList< QDockWidget * > tabifiedDockWidgets(QDockWidget *dockwidget) const
Returns the dock widgets that are tabified together with dockwidget.
void setAnimated(bool enabled)
void setIconSize(const QSize &iconSize)
QWidget * menuBar() const
Returns the menu bar set for this layout, or 0 if no menu bar is set.
QWidget * centralWidget() const
Returns the central widget for the main window.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
void setStatusBar(QStatusBar *statusbar)
Sets the status bar for the main window to statusbar.
void setObjectName(const QString &name)
The QStatusBar class provides a horizontal bar suitable for presenting status information.
void contextMenuEvent(QContextMenuEvent *event)
Reimplemented Function
static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where)
void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)
This signal is emitted when the style used for tool buttons in the window is changed.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const
Returns the tab position for area.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
bool restoreState(const QByteArray &state, int version=0)
Restores the state of this mainwindow's toolbars and dockwidgets.
Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const
Returns the Qt::ToolBarArea for toolbar.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void update()
Updates the layout for parentWidget().
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *mainWindow)
The QLayout class is the base class of geometry managers.
const T & at(int i) const
Returns the item at index position i in the list.
void tabifyDockWidget(QDockWidget *first, QDockWidget *second)
Moves second dock widget on top of first dock widget, creating a tabbed docked area in the main windo...
static bool checkToolBarArea(Qt::ToolBarArea area, const char *where)
Q_CORE_EXPORT void qWarning(const char *,...)
QCursor separatorCursor(const QList< int > &path) const
OSWindowRef qt_mac_window_for(const QWidget *)
QWidget * menuWidget() const
Returns the menu bar for the main window.
The QRegion class specifies a clip region for a painter.
void setMenuBar(QWidget *w)
Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins().
bool toolBarBreak(QToolBar *toolbar) const
Returns whether there is a toolbar break before the toolbar.
Qt::MouseButton button() const
Returns the button that caused the event.
bool event(QEvent *event)
Reimplemented Function
void setTabShape(QTabWidget::TabShape tabShape)
void removeDockWidget(QDockWidget *dockwidget)
Removes the dockwidget from the main window layout and hides it.
QMenuBar * menuBar() const
Returns the menu bar for the main window.
void setCorner(Qt::Corner corner, Qt::DockWidgetArea area)
Sets the given dock widget area to occupy the specified corner.
The QMouseEvent class contains parameters that describe a mouse event.
T & first()
Returns a reference to the first item in the list.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
#define Q_ASSERT_X(cond, where, what)
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)
Adds the given dockwidget to the specified area.
#define Q_DECLARE_PUBLIC(Class)
~QMainWindow()
Destroys the main window.
bool isDockNestingEnabled() const
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
The QWindowStateChangeEvent class provides the window state before a window state change...
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
Adds the toolbar into the specified area in this main window.
void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
QTabWidget::TabShape tabShape() const
void insertToolBar(QToolBar *before, QToolBar *toolbar)
Inserts the toolbar into the area occupied by the before toolbar so that it appears before it...
The QStatusTipEvent class provides an event that is used to show messages in a status bar...
void setDockOptions(DockOptions options)
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
The QGridLayout class lays out widgets in a grid.
The QMainWindow class provides a main application window.
int size() const
Returns the number of items in the list.
void setDocumentMode(bool enabled)
bool documentMode() const
if(void) toggleToolbarShown
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
bool isSeparator(const QPoint &pos) const
void addToolBarBreak(Qt::ToolBarArea area=Qt::TopToolBarArea)
Adds a toolbar break to the given area after all the other objects that are present.
void setContentsMargins(int left, int top, int right, int bottom)
Sets the left, top, right, and bottom margins to use around the layout.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
static QMainWindowLayout * mainWindowLayout(const QMainWindow *mainWindow)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
QByteArray saveState(int version=0) const
Saves the current state of this mainwindow's toolbars and dockwidgets.
void removeToolBarBreak(QToolBar *before)
Removes a toolbar break previously inserted before the toolbar specified by before.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QDataStream class provides serialization of binary data to a QIODevice.
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QStatusBar * statusBar() const
Returns the status bar for the main window.
void setUnifiedTitleAndToolBarOnMac(bool set)
The QPaintEvent class contains event parameters for paint events.
QMainWindowLayout * layout
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
bool qt_mac_is_macdrawer(const QWidget *w)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool animated
whether manipulating dock widgets and tool bars is animated
void deleteLater()
Schedules this object for deletion.
bool restoreDockWidget(QDockWidget *dockwidget)
Restores the state of dockwidget if it is created after the call to restoreState().
void setMenuWidget(QWidget *menubar)
Sets the menu bar for the main window to menuBar.
void addItem(QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=0)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it accord...
void removeToolBar(QToolBar *toolbar)
Removes the toolbar from the main window layout and hides it.
void iconSizeChanged(const QSize &iconSize)
This signal is emitted when the size of the icons used in the window is changed.
void setMenuBar(QMenuBar *menubar)
Sets the menu bar for the main window to menuBar.
Qt::ToolButtonStyle toolButtonStyle
static int area(const QSize &s)
QList< int > hoverSeparator