Qt 4.8
qdockwidget_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDYNAMICDOCKWIDGET_P_H
43 #define QDYNAMICDOCKWIDGET_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "QtGui/qstyleoption.h"
57 #include "private/qwidget_p.h"
58 #include "QtGui/qboxlayout.h"
59 #include "QtGui/qdockwidget.h"
60 
61 #ifndef QT_NO_DOCKWIDGET
62 
64 
65 class QGridLayout;
67 class QRubberBand;
69 class QSpacerItem;
70 class QDockWidgetItem;
71 
73 {
75 
76  struct DragState {
78  bool dragging;
81  bool nca;
82  bool ctrlDrag;
83  };
84 
85 public:
87  : QWidgetPrivate(), state(0),
88  features(QDockWidget::DockWidgetClosable
89  | QDockWidget::DockWidgetMovable
90  | QDockWidget::DockWidgetFloatable),
92  { }
93 
94  void init();
95  void _q_toggleView(bool); // private slot
96  void _q_toggleTopLevel(); // private slot
97 
98  void updateButtons();
100 
101  QDockWidget::DockWidgetFeatures features;
102  Qt::DockWidgetAreas allowedAreas;
103 
105 
106 #ifndef QT_NO_ACTION
108 #endif
109 
110 // QMainWindow *findMainWindow(QWidget *widget) const;
113 
118  void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
120  void initDrag(const QPoint &pos, bool nca);
121  void startDrag();
122  void endDrag(bool abort = false);
123  void moveEvent(QMoveEvent *event);
124 
125  void unplug(const QRect &rect);
126  void plug(const QRect &rect);
127 
128  bool isAnimating() const;
129 };
130 
132 {
133  Q_OBJECT
134 public:
137  void addItem(QLayoutItem *item);
138  QLayoutItem *itemAt(int index) const;
139  QLayoutItem *takeAt(int index);
140  int count() const;
141 
142  QSize maximumSize() const;
143  QSize minimumSize() const;
144  QSize sizeHint() const;
145 
146  QSize sizeFromContent(const QSize &content, bool floating) const;
147 
148  void setGeometry(const QRect &r);
149 
150  enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount };
151  QWidget *widgetForRole(Role r) const;
152  void setWidgetForRole(Role r, QWidget *w);
153  QLayoutItem *itemForRole(Role r) const;
154 
155  QRect titleArea() const { return _titleArea; }
156 
157  int minimumTitleWidth() const;
158  int titleHeight() const;
159  void updateMaxSize();
160  bool nativeWindowDeco() const;
161  bool nativeWindowDeco(bool floating) const;
162 
163  void setVerticalTitleBar(bool b);
164 
166 
167 private:
170 };
171 
172 /* The size hints of a QDockWidget will depend on whether it is docked or not.
173  This layout item always returns the size hints as if the dock widget was docked. */
174 
176 {
177 public:
178  QDockWidgetItem(QDockWidget *dockWidget);
179  QSize minimumSize() const;
180  QSize maximumSize() const;
181  QSize sizeHint() const;
182 
183 private:
184  inline QLayoutItem *dockWidgetChildItem() const;
185  inline QDockWidgetLayout *dockWidgetLayout() const;
186 };
187 
189 {
190  if (QDockWidgetLayout *layout = dockWidgetLayout())
191  return layout->itemForRole(QDockWidgetLayout::Content);
192  return 0;
193 }
194 
196 {
197  QWidget *w = const_cast<QDockWidgetItem*>(this)->widget();
198  if (w != 0)
199  return qobject_cast<QDockWidgetLayout*>(w->layout());
200  return 0;
201 }
202 
204 
205 #endif // QT_NO_DOCKWIDGET
206 
207 #endif // QDYNAMICDOCKWIDGET_P_H
T qobject_cast(QObject *object)
Definition: qobject.h:375
void initDrag(const QPoint &pos, bool nca)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
QPointer< QWidget > widget
void unplug(const QRect &rect)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLayoutItem * dockWidgetChildItem() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
QDockWidgetLayout * dockWidgetLayout() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
Qt::DockWidgetAreas allowedAreas
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QAction * toggleViewAction
The QSpacerItem class provides blank space in a layout.
Definition: qlayoutitem.h:96
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
QVector< QLayoutItem * > item_list
bool mouseMoveEvent(QMouseEvent *event)
bool mouseReleaseEvent(QMouseEvent *event)
QDockWidget::DockWidgetFeatures features
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
void moveEvent(QMoveEvent *event)
bool isAnimating() const
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QRect titleArea() const
void plug(const QRect &rect)
void _q_toggleView(bool)
bool mouseDoubleClickEvent(QMouseEvent *event)
bool mousePressEvent(QMouseEvent *event)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
void endDrag(bool abort=false)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
quint16 index
QObject * parent
Definition: qobject.h:92
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QWidgetResizeHandler * resizer
void nonClientAreaMouseEvent(QMouseEvent *event)
DragState * state
Definition: qdockwidget_p.h:99
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary...
Definition: qrubberband.h:58
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64