Qt 4.8
qsplitter_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 QSPLITTER_P_H
43 #define QSPLITTER_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 "private/qframe_p.h"
57 #include "qrubberband.h"
58 
60 
61 static const uint Default = 2;
62 
64 {
65 public:
67  int sizer;
72 
73  QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(0), handle(0) {}
75  int getWidgetSize(Qt::Orientation orient);
76  int getHandleSize(Qt::Orientation orient);
77  int pick(const QSize &size, Qt::Orientation orient)
78  { return (orient == Qt::Horizontal) ? size.width() : size.height(); }
79 };
80 
82 {
84 public:
85  QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
86  childrenCollapsible(true), compatMode(false), handleWidth(0), blockChildAdd(false) {}
87 
91  bool opaque : 8;
92  bool firstShow : 8;
94  bool compatMode : 8;
97 
98  inline int pick(const QPoint &pos) const
99  { return orient == Qt::Horizontal ? pos.x() : pos.y(); }
100  inline int pick(const QSize &s) const
101  { return orient == Qt::Horizontal ? s.width() : s.height(); }
102 
103  inline int trans(const QPoint &pos) const
104  { return orient == Qt::Vertical ? pos.x() : pos.y(); }
105  inline int trans(const QSize &s) const
106  { return orient == Qt::Vertical ? s.width() : s.height(); }
107 
108  void init();
109  void recalc(bool update = false);
110  void doResize();
111  void storeSizes();
112  void getRange(int index, int *, int *, int *, int *) const;
113  void addContribution(int, int *, int *, bool) const;
114  int adjustPos(int, int, int *, int *, int *, int *) const;
115  bool collapsible(QSplitterLayoutStruct *) const;
116  bool collapsible(int index) const
117  { return (index < 0 || index >= list.size()) ? true : collapsible(list.at(index)); }
118  QSplitterLayoutStruct *findWidget(QWidget *) const;
119  void insertWidget_helper(int index, QWidget *widget, bool show);
120  QSplitterLayoutStruct *insertWidget(int index, QWidget *);
121  void doMove(bool backwards, int pos, int index, int delta,
122  bool mayCollapse, int *positions, int *widths);
123  void setGeo(QSplitterLayoutStruct *s, int pos, int size, bool allowCollapse);
124  int findWidgetJustBeforeOrJustAfter(int index, int delta, int &collapsibleSize) const;
125  void updateHandles();
126  void setSizes_helper(const QList<int> &sizes, bool clampNegativeSize = false);
127 
128 };
129 
131 {
133 public:
134  QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {}
135 
136  inline int pick(const QPoint &pos) const
137  { return orient == Qt::Horizontal ? pos.x() : pos.y(); }
138 
142  bool opaq : 1;
143  bool hover : 1;
144  bool pressed : 1;
145 };
146 
148 
149 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int pick(const QPoint &pos) const
Definition: qsplitter_p.h:136
int getWidgetSize(Qt::Orientation orient)
Definition: qsplitter.cpp:350
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int pick(const QSize &size, Qt::Orientation orient)
Definition: qsplitter_p.h:77
int pick(const QSize &s) const
Definition: qsplitter_p.h:100
int trans(const QSize &s) const
Definition: qsplitter_p.h:105
int getHandleSize(Qt::Orientation orient)
Definition: qsplitter.cpp:369
The QSplitterHandle class provides handle functionality of the splitter.
Definition: qsplitter.h:158
bool childrenCollapsible
Definition: qsplitter_p.h:93
static const uint Default
Definition: qsplitter_p.h:61
int width() const
Returns the width.
Definition: qsize.h:126
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool collapsible(int index) const
Definition: qsplitter_p.h:116
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
static bool init
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
unsigned int uint
Definition: qglobal.h:996
QList< QSplitterLayoutStruct * > list
Definition: qsplitter_p.h:89
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
Qt::Orientation orient
Definition: qsplitter_p.h:90
QSplitterHandle * handle
Definition: qsplitter_p.h:71
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
QPointer< QRubberBand > rubberBand
Definition: qsplitter_p.h:88
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::Orientation orient
Definition: qsplitter_p.h:140
Orientation
Definition: qnamespace.h:174
The QSplitter class implements a splitter widget.
Definition: qsplitter.h:62
int trans(const QPoint &pos) const
Definition: qsplitter_p.h:103
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
int pick(const QPoint &pos) const
Definition: qsplitter_p.h:98