~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/widgets/qsplitter.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the widgets module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QSPLITTER_H
 
30
#define QSPLITTER_H
 
31
 
 
32
#include "QtGui/qframe.h"
 
33
#include "QtGui/qsizepolicy.h"
 
34
 
 
35
#ifndef QT_NO_SPLITTER
 
36
 
 
37
class QSplitterPrivate;
 
38
class QTextStream;
 
39
template <typename T> class QList;
 
40
 
 
41
class QSplitterHandle;
 
42
 
 
43
class Q_GUI_EXPORT QSplitter : public QFrame
 
44
{
 
45
    Q_OBJECT
 
46
 
 
47
    Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
 
48
    Q_PROPERTY(bool opaqueResize READ opaqueResize WRITE setOpaqueResize)
 
49
    Q_PROPERTY(int handleWidth READ handleWidth WRITE setHandleWidth)
 
50
    Q_PROPERTY(bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible)
 
51
 
 
52
public:
 
53
    explicit QSplitter(QWidget* parent = 0);
 
54
    explicit QSplitter(Qt::Orientation, QWidget* parent = 0);
 
55
    ~QSplitter();
 
56
 
 
57
    void addWidget(QWidget *widget);
 
58
    void insertWidget(int index, QWidget *widget);
 
59
 
 
60
    void setOrientation(Qt::Orientation);
 
61
    Qt::Orientation orientation() const;
 
62
 
 
63
    void setChildrenCollapsible(bool);
 
64
    bool childrenCollapsible() const;
 
65
 
 
66
    void setCollapsible(int index, bool);
 
67
    bool isCollapsible(int index) const;
 
68
    void setOpaqueResize(bool opaque = true);
 
69
    bool opaqueResize() const;
 
70
    void refresh();
 
71
 
 
72
    QSize sizeHint() const;
 
73
    QSize minimumSizeHint() const;
 
74
 
 
75
    QList<int> sizes() const;
 
76
    void setSizes(const QList<int> &list);
 
77
 
 
78
    QByteArray saveState() const;
 
79
    bool restoreState(const QByteArray &state);
 
80
 
 
81
    int handleWidth() const;
 
82
    void setHandleWidth(int);
 
83
 
 
84
    int indexOf(QWidget *w) const;
 
85
    QWidget *widget(int index) const;
 
86
    int count() const;
 
87
 
 
88
    void getRange(int index, int *, int *) const;
 
89
    QSplitterHandle *handle(int index) const;
 
90
 
 
91
    void setStretchFactor(int index, int stretch);
 
92
 
 
93
signals:
 
94
    void splitterMoved(int pos, int index);
 
95
 
 
96
protected:
 
97
    virtual QSplitterHandle *createHandle();
 
98
 
 
99
    void childEvent(QChildEvent *);
 
100
 
 
101
    bool event(QEvent *);
 
102
    void resizeEvent(QResizeEvent *);
 
103
 
 
104
    void changeEvent(QEvent *);
 
105
    void moveSplitter(int pos, int index);
 
106
    void setRubberBand(int position);
 
107
    int closestLegalPosition(int, int);
 
108
 
 
109
#ifdef QT3_SUPPORT
 
110
public:
 
111
    QT3_SUPPORT_CONSTRUCTOR QSplitter(QWidget* parent, const char* name);
 
112
    QT3_SUPPORT_CONSTRUCTOR QSplitter(Qt::Orientation, QWidget* parent, const char* name);
 
113
    enum ResizeMode { Stretch, KeepSize, FollowSizeHint, Auto };
 
114
    QT3_SUPPORT void setResizeMode(QWidget *w, ResizeMode mode);
 
115
    inline QT3_SUPPORT void moveToFirst(QWidget *w) { insertWidget(0,w); }
 
116
    inline QT3_SUPPORT void moveToLast(QWidget *w) { addWidget(w); }
 
117
    inline QT3_SUPPORT void setCollapsible(QWidget *w, bool collapse)
 
118
    { setCollapsible(indexOf(w), collapse); }
 
119
#endif
 
120
 
 
121
private:
 
122
    Q_DISABLE_COPY(QSplitter)
 
123
    Q_DECLARE_PRIVATE(QSplitter)
 
124
private:
 
125
    friend class QSplitterHandle;
 
126
};
 
127
 
 
128
//#ifdef QT3_SUPPORT
 
129
#ifndef QT_NO_TEXTSTREAM
 
130
Q_GUI_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
 
131
Q_GUI_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
 
132
#endif
 
133
//#endif
 
134
 
 
135
class QSplitterHandlePrivate;
 
136
class Q_GUI_EXPORT QSplitterHandle : public QWidget
 
137
{
 
138
    Q_OBJECT
 
139
public:
 
140
    QSplitterHandle(Qt::Orientation o, QSplitter *parent);
 
141
    void setOrientation(Qt::Orientation o);
 
142
    Qt::Orientation orientation() const;
 
143
    bool opaqueResize() const;
 
144
    QSplitter *splitter() const;
 
145
 
 
146
    QSize sizeHint() const;
 
147
 
 
148
protected:
 
149
    void paintEvent(QPaintEvent *);
 
150
    void mouseMoveEvent(QMouseEvent *);
 
151
    void mousePressEvent(QMouseEvent *);
 
152
    void mouseReleaseEvent(QMouseEvent *);
 
153
    bool event(QEvent *);
 
154
 
 
155
    void moveSplitter(int p);
 
156
    int closestLegalPosition(int p);
 
157
 
 
158
private:
 
159
    Q_DISABLE_COPY(QSplitterHandle)
 
160
    Q_DECLARE_PRIVATE(QSplitterHandle)
 
161
};
 
162
 
 
163
#endif // QT_NO_SPLITTER
 
164
 
 
165
#endif // QSPLITTER_H