Qt 4.8
qmdiarea_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 QMDIAREA_P_H
43 #define QMDIAREA_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 "qmdiarea.h"
57 #include "qmdisubwindow.h"
58 
59 #ifndef QT_NO_MDIAREA
60 
61 #include <QList>
62 #include <QRect>
63 #include <QPoint>
64 #include <QtGui/qapplication.h>
65 #include <private/qmdisubwindow_p.h>
66 #include <private/qabstractscrollarea_p.h>
67 
69 
70 namespace QMdi {
72 {
73 public:
74  enum Type {
78  };
79 
80  // Rearranges widgets relative to domain.
81  virtual void rearrange(QList<QWidget *> &widgets, const QRect &domain) const = 0;
82  virtual Type type() const = 0;
83  virtual ~Rearranger() {}
84 };
85 
86 class RegularTiler : public Rearranger
87 {
88  // Rearranges widgets according to a regular tiling pattern
89  // covering the entire domain.
90  // Both positions and sizes may change.
91  void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
92  inline Type type() const { return Rearranger::RegularTiler; }
93 };
94 
95 class SimpleCascader : public Rearranger
96 {
97  // Rearranges widgets according to a simple, regular cascading pattern.
98  // Widgets are resized to minimumSize.
99  // Both positions and sizes may change.
100  void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
101  inline Type type() const { return Rearranger::SimpleCascader; }
102 };
103 
104 class IconTiler : public Rearranger
105 {
106  // Rearranges icons (assumed to be the same size) according to a regular
107  // tiling pattern filling up the domain from the bottom.
108  // Only positions may change.
109  void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
110  inline Type type() const { return Rearranger::IconTiler; }
111 };
112 
113 class Placer
114 {
115 public:
116  // Places the rectangle defined by 'size' relative to 'rects' and 'domain'.
117  // Returns the position of the resulting rectangle.
118  virtual QPoint place(
119  const QSize &size, const QList<QRect> &rects, const QRect &domain) const = 0;
120  virtual ~Placer() {}
121 };
122 
123 class MinOverlapPlacer : public Placer
124 {
125  QPoint place(const QSize &size, const QList<QRect> &rects, const QRect &domain) const;
126  static int accumulatedOverlap(const QRect &source, const QList<QRect> &rects);
127  static QRect findMinOverlapRect(const QList<QRect> &source, const QList<QRect> &rects);
128  static void getCandidatePlacements(
129  const QSize &size, const QList<QRect> &rects, const QRect &domain,
130  QList<QRect> &candidates);
131  static QPoint findBestPlacement(
132  const QRect &domain, const QList<QRect> &rects, QList<QRect> &source);
133  static void findNonInsiders(
134  const QRect &domain, QList<QRect> &source, QList<QRect> &result);
135  static void findMaxOverlappers(
136  const QRect &domain, const QList<QRect> &source, QList<QRect> &result);
137 };
138 } // namespace QMdi
139 
140 class QMdiAreaTabBar;
142 {
144 public:
145  QMdiAreaPrivate();
146 
147  // Variables.
152 #ifndef QT_NO_RUBBERBAND
154 #endif
164  QMdiArea::AreaOptions options;
166 #ifndef QT_NO_TABBAR
170 #endif
171 #ifndef QT_NO_TABWIDGET
174 #endif
189 
190  // Slots.
191  void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
192  void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
193  void _q_currentTabChanged(int index);
194  void _q_closeTab(int index);
195  void _q_moveTab(int from, int to);
196 
197  // Functions.
198  void appendChild(QMdiSubWindow *child);
199  void place(QMdi::Placer *placer, QMdiSubWindow *child);
200  void rearrange(QMdi::Rearranger *rearranger);
201  void arrangeMinimizedSubWindows();
202  void activateWindow(QMdiSubWindow *child);
203  void activateCurrentWindow();
204  void activateHighlightedWindow();
205  void emitWindowActivated(QMdiSubWindow *child);
206  void resetActiveWindow(QMdiSubWindow *child = 0);
207  void updateActiveWindow(int removedIndex, bool activeRemoved);
208  void updateScrollBars();
209  void internalRaise(QMdiSubWindow *child) const;
210  bool scrollBarsEnabled() const;
211  bool lastWindowAboutToBeDestroyed() const;
212  void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
213  QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
214  void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp
215  QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
216  int removed = -1, int fromIndex = -1) const;
217  void highlightNextSubWindow(int increaseFactor);
218  QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const;
219  void disconnectSubWindow(QObject *subWindow);
220  void setViewMode(QMdiArea::ViewMode mode);
221 #ifndef QT_NO_TABBAR
222  void updateTabBarGeometry();
223  void refreshTabBar();
224 #endif
225 
226  inline void startResizeTimer()
227  {
228  Q_Q(QMdiArea);
229  if (resizeTimerId > 0)
230  q->killTimer(resizeTimerId);
231  resizeTimerId = q->startTimer(200);
232  }
233 
235  {
236  Q_Q(QMdiArea);
237  if (tabToPreviousTimerId > 0)
238  q->killTimer(tabToPreviousTimerId);
239  tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval());
240  }
241 
242  inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const
243  {
244  if (!subWindow)
245  return false;
246  return subWindow->windowFlags() & Qt::WindowStaysOnTopHint;
247  }
248 
249  inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
250  {
251  if (!subWindow)
252  return true;
253  return subWindow->d_func()->isExplicitlyDeactivated;
254  }
255 
256  inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const
257  {
258  if (subWindow)
259  subWindow->d_func()->setActive(active, changeFocus);
260  }
261 
262 #ifndef QT_NO_RUBBERBAND
263  inline void showRubberBandFor(QMdiSubWindow *subWindow)
264  {
265  if (!subWindow || !rubberBand)
266  return;
267  rubberBand->setGeometry(subWindow->geometry());
268  rubberBand->raise();
269  rubberBand->show();
270  }
271 
272  inline void hideRubberBand()
273  {
274  if (rubberBand && rubberBand->isVisible())
275  rubberBand->hide();
276  indexToHighlighted = -1;
277  }
278 #endif // QT_NO_RUBBERBAND
279 };
280 
281 #endif // QT_NO_MDIAREA
282 
284 
285 #endif // QMDIAREA_P_H
static int keyboardInputInterval()
bool updatesDisabledByUs
Definition: qmdiarea_p.h:181
QList< QMdi::Rearranger * > pendingRearrangements
Definition: qmdiarea_p.h:156
QMdi::Rearranger * regularTiler
Definition: qmdiarea_p.h:149
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QMdiSubWindow > aboutToBecomeActive
Definition: qmdiarea_p.h:161
bool showActiveWindowMaximized
Definition: qmdiarea_p.h:179
Type type() const
Definition: qmdiarea_p.h:110
int indexToHighlighted
Definition: qmdiarea_p.h:185
QMdiArea::AreaOptions options
Definition: qmdiarea_p.h:164
bool isVisible() const
Definition: qwidget.h:1005
TabPosition
This enum type defines where QTabWidget draws the tab row:
Definition: qtabwidget.h:112
QMdiAreaTabBar * tabBar
Definition: qmdiarea_p.h:155
bool ignoreWindowStateChange
Definition: qmdiarea_p.h:176
virtual void rearrange(QList< QWidget *> &widgets, const QRect &domain) const =0
Type type() const
Definition: qmdiarea_p.h:92
void showRubberBandFor(QMdiSubWindow *subWindow)
Definition: qmdiarea_p.h:263
ViewMode
This enum describes the view mode of the area; i.
Definition: qmdiarea.h:88
QList< QPointer< QMdiSubWindow > > pendingPlacements
Definition: qmdiarea_p.h:157
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QMdiArea::ViewMode viewMode
Definition: qmdiarea_p.h:165
#define Q_Q(Class)
Definition: qglobal.h:2483
QBrush background
Definition: qmdiarea_p.h:162
QList< QPointer< QMdiSubWindow > > childWindows
Definition: qmdiarea_p.h:158
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setGeometry(const QRect &r)
Sets the geometry of the rubber band to rect, specified in the coordinate system of its parent widget...
int indexToPreviousWindow
Definition: qmdiarea_p.h:184
bool tileCalledFromResizeEvent
Definition: qmdiarea_p.h:180
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
QMdi::Rearranger * cascader
Definition: qmdiarea_p.h:148
QPointer< QMdiSubWindow > active
Definition: qmdiarea_p.h:160
virtual Type type() const =0
bool windowStaysOnTop(QMdiSubWindow *subWindow) const
Definition: qmdiarea_p.h:242
bool ignoreGeometryChange
Definition: qmdiarea_p.h:175
void show()
Shows the widget and its child widgets.
QTabWidget::TabShape tabShape
Definition: qmdiarea_p.h:172
void hide()
Hides the widget.
Definition: qwidget.h:501
QRubberBand * rubberBand
Definition: qmdiarea_p.h:153
virtual ~Rearranger()
Definition: qmdiarea_p.h:83
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
void startTabToPreviousTimer()
Definition: qmdiarea_p.h:234
void setActive(QMdiSubWindow *subWindow, bool active=true, bool changeFocus=true) const
Definition: qmdiarea_p.h:256
QList< int > indicesToActivatedChildren
Definition: qmdiarea_p.h:159
ScrollBarPolicy
Definition: qnamespace.h:1420
void startResizeTimer()
Definition: qmdiarea_p.h:226
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
WindowOrder
Specifies the criteria to use for ordering the list of child windows returned by subWindowList().
Definition: qmdiarea.h:82
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
Definition: qmdiarea_p.h:249
quint16 index
void hideRubberBand()
Definition: qmdiarea_p.h:272
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Type type() const
Definition: qmdiarea_p.h:101
QMdi::Rearranger * iconTiler
Definition: qmdiarea_p.h:150
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
bool isSubWindowsTiled
Definition: qmdiarea_p.h:178
bool inViewModeChange
Definition: qmdiarea_p.h:182
const QRect & geometry() const
Orientation
Definition: qnamespace.h:174
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary...
Definition: qrubberband.h:58
QTabWidget::TabPosition tabPosition
Definition: qmdiarea_p.h:173
QMdi::Placer * placer
Definition: qmdiarea_p.h:151
virtual ~Placer()
Definition: qmdiarea_p.h:120
QMdiArea::WindowOrder activationOrder
Definition: qmdiarea_p.h:163
int indexToLastActiveTab
Definition: qmdiarea_p.h:186
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
TabShape
This enum type defines the shape of the tabs:
Definition: qtabwidget.h:126
int tabToPreviousTimerId
Definition: qmdiarea_p.h:188