0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
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 |
|
|
59 |
QT_BEGIN_NAMESPACE
|
|
60 |
|
|
61 |
static const uint Default = 2;
|
|
62 |
|
|
63 |
class QSplitterLayoutStruct
|
|
64 |
{
|
|
65 |
public:
|
|
66 |
QRect rect;
|
|
67 |
int sizer;
|
|
68 |
uint collapsed : 1;
|
|
69 |
uint collapsible : 2;
|
|
70 |
QWidget *widget;
|
|
71 |
QSplitterHandle *handle;
|
|
72 |
|
|
73 |
QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(0), handle(0) {}
|
|
74 |
~QSplitterLayoutStruct() { delete handle; }
|
|
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 |
|
|
81 |
class QSplitterPrivate : public QFramePrivate
|
|
82 |
{
|
|
83 |
Q_DECLARE_PUBLIC(QSplitter)
|
|
84 |
public:
|
|
85 |
QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
|
|
86 |
childrenCollapsible(true), compatMode(false), handleWidth(0), blockChildAdd(false) {}
|
|
87 |
|
|
88 |
QPointer<QRubberBand> rubberBand;
|
|
89 |
mutable QList<QSplitterLayoutStruct *> list;
|
|
90 |
Qt::Orientation orient;
|
|
91 |
bool opaque : 8;
|
|
92 |
bool firstShow : 8;
|
|
93 |
bool childrenCollapsible : 8;
|
|
94 |
bool compatMode : 8;
|
|
95 |
int handleWidth;
|
|
96 |
bool blockChildAdd;
|
|
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 |
|
|
130 |
class QSplitterHandlePrivate : public QWidgetPrivate
|
|
131 |
{
|
|
132 |
Q_DECLARE_PUBLIC(QSplitterHandle)
|
|
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 |
|
|
139 |
QSplitter *s;
|
|
140 |
Qt::Orientation orient;
|
|
141 |
int mouseOffset;
|
|
142 |
bool opaq : 1;
|
|
143 |
bool hover : 1;
|
|
144 |
bool pressed : 1;
|
|
145 |
};
|
|
146 |
|
|
147 |
QT_END_NAMESPACE
|
|
148 |
|
|
149 |
#endif
|