source: trunk/src/gui/widgets/qsplitter_p.h@ 332

Last change on this file since 332 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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
59QT_BEGIN_NAMESPACE
60
61static const uint Default = 2;
62
63class QSplitterLayoutStruct
64{
65public:
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
81class QSplitterPrivate : public QFramePrivate
82{
83 Q_DECLARE_PUBLIC(QSplitter)
84public:
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
130class QSplitterHandlePrivate : public QWidgetPrivate
131{
132 Q_DECLARE_PUBLIC(QSplitterHandle)
133public:
134 QSplitterHandlePrivate() : orient(Qt::Horizontal), opaq(false), s(0), mouseOffset(0) {}
135
136 inline int pick(const QPoint &pos) const
137 { return orient == Qt::Horizontal ? pos.x() : pos.y(); }
138
139 Qt::Orientation orient;
140 bool opaq;
141 QSplitter *s;
142 bool hover;
143 int mouseOffset;
144};
145
146QT_END_NAMESPACE
147
148#endif
Note: See TracBrowser for help on using the repository browser.