44 #ifndef QT_NO_DOCKWIDGET 57 #include <private/qwidgetresizehandler_p.h> 62 #include <private/qapplication_p.h> 63 #include <private/qt_mac_p.h> 75 {
return (priv->
features & feature) == feature; }
78 {
return (dockwidget->
features() & feature) == feature; }
145 return QSize(size, size);
194 :
QLayout(parent), verticalTitleBar(false), item_list(RoleCount, 0)
210 #if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_WINCE) 221 qWarning() <<
"QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()";
267 QSize result = content;
280 int fw = floating && !nativeDeco
287 result +=
QSize(th + 2*fw, 2*fw);
289 result +=
QSize(2*fw, th + 2*fw);
295 if (content.
width() < 0)
312 uint explicitMin = 0;
313 uint explicitMax = 0;
314 if (w->d_func()->extra != 0) {
315 explicitMin = w->d_func()->extra->explicitMinSize;
316 explicitMax = w->d_func()->extra->explicitMaxSize;
324 if (!(explicitMax & Qt::Horizontal))
326 if (!(explicitMax & Qt::Vertical))
336 QSize content(-1, -1);
368 return item == 0 ? 0 : item->
widget();
395 static inline int pick(
bool vertical,
const QSize &size)
400 static inline int perp(
bool vertical,
const QSize &size)
412 QSize closeSize(0, 0);
413 QSize floatSize(0, 0);
416 closeSize = item->widget()->sizeHint();
420 floatSize = item->widget()->sizeHint();
430 + titleHeight + 2*fw + 3*mw;
440 QSize closeSize(0, 0);
441 QSize floatSize(0, 0);
443 closeSize = item->widget()->sizeHint();
445 floatSize = item->widget()->sizeHint();
452 if (qobject_cast<QMacStyle *>(q->
style())) {
461 return qMax(buttonHeight + 2, titleFontMetrics.
height() + 2*mw);
476 item->setGeometry(geometry);
485 QSize(geometry.
width() - (fw * 2), titleHeight));
495 if (!item->isEmpty()) {
500 item->setGeometry(r);
505 if (!item->isEmpty()) {
510 item->setGeometry(r);
519 r.
adjust(0, fw, -fw, -fw);
522 r.
adjust(fw, 0, -fw, -fw);
524 item->setGeometry(r);
549 QSize widgetMin(0, 0);
551 widgetMin = item->minimumSize();
596 resizer->setMovingEnabled(
false);
597 resizer->setActive(
false);
600 toggleViewAction =
new QAction(q);
601 toggleViewAction->setCheckable(
true);
603 toggleViewAction->setText(fixedWindowTitle);
605 q,
SLOT(_q_toggleView(
bool)));
628 option->
title =
d->fixedWindowTitle;
643 if (b == q->isHidden()) {
657 q->initStyleOption(&opt);
661 bool hideButtons = nativeDeco || customTitleBar;
677 (canFloat || canClose) && !hideButtons);
685 q->setFloating(!q->isFloating());
703 state->widgetItem = 0;
704 state->ownWidgetItem =
false;
706 state->ctrlDrag =
false;
708 if (!q->isFloating()) {
713 int width = undockedGeometry.isNull() ? q->width() : undockedGeometry.width();
715 state->pressPos.setX(width / 2);
717 state->pressPos = pos;
725 if (state == 0 || state->dragging)
731 state->widgetItem = layout->
unplug(q);
732 if (state->widgetItem == 0) {
738 state->ownWidgetItem =
true;
744 state->dragging =
true;
754 if (state->dragging) {
758 if (abort || !mwLayout->
plug(state->widgetItem)) {
760 if (state->ownWidgetItem)
761 delete state->widgetItem;
765 Qt::WindowFlags flags = q->windowFlags();
767 q->setWindowFlags(flags);
779 mwLayout->
revert(state->widgetItem);
796 if (mainWinLayout == 0)
804 #if !defined(QT_NO_MAINWINDOW) 818 qobject_cast<QMainWindow*>(parent) == 0 ||
819 isAnimating() || state != 0) {
823 initDrag(event->
pos(),
false);
831 #endif // !defined(QT_NO_MAINWINDOW) 854 #if !defined(QT_NO_MAINWINDOW) 865 && mwlayout->pluggingWidget == 0
866 && (event->
pos() - state->pressPos).manhattanLength()
870 grabMouseWhileInWindow();
878 if (state->dragging && !state->nca) {
879 QPoint pos =
event->globalPos() - state->pressPos;
882 if (!state->ctrlDrag)
883 mwlayout->hover(state->widgetItem, event->
globalPos());
888 #endif // !defined(QT_NO_MAINWINDOW) 894 #if !defined(QT_NO_MAINWINDOW) 901 #endif // !defined(QT_NO_MAINWINDOW) 911 QRect geo = q->geometry();
912 QRect titleRect = q->frameGeometry();
924 titleRect.
adjust(0, fw, 0, 0);
927 switch (event->
type()) {
933 if (qobject_cast<QMainWindow*>(parent) == 0)
937 initDrag(event->
pos(),
true);
942 state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
949 if (state == 0 || !state->dragging)
959 q->move(event->
globalPos() - state->pressPos);
960 if (!state->ctrlDrag)
983 if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
995 QPoint globalMousePos =
event->pos() + state->pressPos;
996 layout->
hover(state->widgetItem, globalMousePos);
1003 if (!undockedGeometry.isNull()) {
1004 r = undockedGeometry;
1013 setWindowState(
true,
true, r);
1018 setWindowState(
false,
false, rect);
1025 if (!floating && parent) {
1031 bool wasFloating = q->isFloating();
1032 bool hidden = q->isHidden();
1053 q->setWindowFlags(flags);
1055 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) 1057 ChangeWindowAttributes(HIViewGetWindow(
HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
1062 q->setGeometry(rect);
1069 if (floating != wasFloating) {
1070 emit q->topLevelChanged(floating);
1071 if (!floating && parent) {
1249 if (
d->features == features)
1262 d->setWindowState(
true ,
true );
1295 QRect r =
d->undockedGeometry;
1300 d->setWindowState(floating,
false, floating ? r :
QRect());
1302 if (floating && r.
isNull()) {
1303 if (
x() < 0 ||
y() < 0)
1325 if (areas ==
d->allowedAreas)
1327 d->allowedAreas = areas;
1334 return d->allowedAreas;
1353 switch (event->
type()) {
1357 #ifndef QT_NO_ACTION 1359 d->toggleViewAction->setText(
d->fixedWindowTitle);
1361 #ifndef QT_NO_TABBAR 1366 info->updateTabBar();
1369 #endif // QT_NO_TABBAR 1396 if (!nativeDeco && !customTitleBar) {
1422 switch (event->
type()) {
1423 #ifndef QT_NO_ACTION 1426 layout->keepSize(
this);
1427 d->toggleViewAction->setChecked(
false);
1431 d->toggleViewAction->setChecked(
true);
1451 layout->raise(
this);
1456 update(qobject_cast<QDockWidgetLayout *>(this->
layout())->titleArea());
1467 if (
d->mousePressEvent(static_cast<QMouseEvent *>(event)))
1471 if (
d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
1475 if (
d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
1480 if (
d->state != 0 &&
d->state->dragging && !
d->state->nca) {
1485 d->mouseMoveEvent(&fake);
1490 if (
d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
1497 d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
1500 d->moveEvent(static_cast<QMoveEvent*>(event));
1504 if (
isFloating() && layout != 0 && layout->pluggingWidget !=
this)
1513 #ifndef QT_NO_ACTION 1525 return d->toggleViewAction;
1527 #endif // QT_NO_ACTION 1641 d->setWindowState(
true ,
true );
1665 #include "qdockwidget.moc" 1666 #include "moc_qdockwidget.cpp" 1668 #endif // QT_NO_DOCKWIDGET
T qobject_cast(QObject *object)
The QPainter class performs low-level painting on widgets and other paint devices.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
void drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
Use the widget's style to draw a control element ce specified by QStyleOption option.
void revert(QLayoutItem *widgetItem)
QStyle::State state
the style flags that are used when drawing the control
int count(const T &t) const
Returns the number of occurrences of value in the vector.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
void init(const QWidget *w)
Use initFrom(widget) instead.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
QList< int > hover(QLayoutItem *widgetItem, const QPoint &mousePos)
void invalidate()
Reimplemented Function
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
void setHeight(int h)
Sets the height to the given height.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const T value(const Key &key) const
Returns the value associated with the key.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
void setObjectName(const QString &name)
void setWidth(int w)
Sets the width to the given width.
QWidget * parentWidget() const
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget...
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QMoveEvent class contains event parameters for move events.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
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 initFrom(const QWidget *w)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
The QLayout class is the base class of geometry managers.
struct OpaqueControlRef * HIViewRef
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
const char * styleHint(const QFontDef &request)
Q_CORE_EXPORT void qWarning(const char *,...)
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
FontHash * qt_app_fonts_hash()
void restore(bool keepSavedState=false)
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
static int startDragDistance()
Qt::MouseButton button() const
Returns the button that caused the event.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
const T & at(int i) const
Returns the item at index position i in the vector.
The QMouseEvent class contains parameters that describe a mouse event.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int top() const
Returns the y-coordinate of the rectangle's top edge.
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=0) const =0
Returns the sub-area for the given element as described in the provided style option.
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
int right() const
Returns the x-coordinate of the rectangle's right edge.
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
The QFont class specifies a font used for drawing text.
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
bool plug(QLayoutItem *widgetItem)
T qstyleoption_cast(const QStyleOption *opt)
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
T & last()
Returns a reference to the last item in the list.
The QMainWindow class provides a main application window.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
const QObjectList & children() const
Returns a list of child objects.
int y() const
Returns the y coordinate of this point.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
void setSizeConstraint(SizeConstraint)
The QSize class defines the size of a two-dimensional object using integer point precision.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
int x() const
Returns the x coordinate of this point.
QRect geometry() const
Reimplemented Function
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
int height() const
Returns the height of the font.
The QPaintEvent class contains event parameters for paint events.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QRect rect
the area that should be used for various calculations and painting
The QCloseEvent class contains parameters that describe a close event.
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
The QAction class provides an abstract user interface action that can be inserted into widgets...
static bool isNull(const QVariant::Private *d)
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
QLayoutItem * unplug(QWidget *widget)