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

« back to all changes in this revision

Viewing changes to src/qt3support/widgets/q3dockarea.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 Qt 3 compatibility classes 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 Q3DOCKAREA_H
 
30
#define Q3DOCKAREA_H
 
31
 
 
32
#include "QtGui/qwidget.h"
 
33
#include "QtCore/qlist.h"
 
34
#include "Qt3Support/q3dockwindow.h"
 
35
#include "QtGui/qlayout.h"
 
36
#include "QtCore/qpointer.h"
 
37
 
 
38
#ifndef QT_NO_MAINWINDOW
 
39
 
 
40
class QSplitter;
 
41
class QBoxLayout;
 
42
class Q3DockAreaLayout;
 
43
class QMouseEvent;
 
44
class Q3DockWindowResizeHandle;
 
45
class Q3DockAreaPrivate;
 
46
class QTextStream;
 
47
 
 
48
class Q_COMPAT_EXPORT Q3DockAreaLayout : public QLayout
 
49
{
 
50
    Q_OBJECT
 
51
    friend class Q3DockArea;
 
52
 
 
53
public:
 
54
    Q3DockAreaLayout(QWidget* parent, Qt::Orientation o, QList<Q3DockWindow *> *wl, int space = -1, int margin = -1, const char *name = 0)
 
55
        : QLayout(parent), orient(o), dockWindows(wl), parentWidget(parent)
 
56
    {
 
57
        if (space != -1)
 
58
            setSpacing(space);
 
59
        if (margin != -1)
 
60
            setMargin(margin);
 
61
        setObjectName(name);
 
62
        init();
 
63
    }
 
64
    ~Q3DockAreaLayout() {}
 
65
 
 
66
    void addItem(QLayoutItem *) {}
 
67
    bool hasHeightForWidth() const;
 
68
    int heightForWidth(int) const;
 
69
    int widthForHeight(int) const;
 
70
    QSize sizeHint() const;
 
71
    QSize minimumSize() const;
 
72
    QLayoutItem *itemAt(int) const;
 
73
    QLayoutItem *takeAt(int);
 
74
    int count() const;
 
75
    Qt::Orientations expandingDirections() const { return Qt::Orientations(0); }
 
76
    void invalidate();
 
77
    Qt::Orientation orientation() const { return orient; }
 
78
    QList<QRect> lineList() const { return lines; }
 
79
    QList<Q3DockWindow *> lineStarts() const { return ls; }
 
80
 
 
81
protected:
 
82
    void setGeometry(const QRect&);
 
83
 
 
84
private:
 
85
    Q_DISABLE_COPY(Q3DockAreaLayout)
 
86
 
 
87
    void init();
 
88
    int layoutItems(const QRect&, bool testonly = false);
 
89
    Qt::Orientation orient;
 
90
    bool dirty;
 
91
    int cached_width, cached_height;
 
92
    int cached_hfw, cached_wfh;
 
93
    QList<Q3DockWindow *> *dockWindows;
 
94
    QWidget *parentWidget;
 
95
    QList<QRect> lines;
 
96
    QList<Q3DockWindow *> ls;
 
97
};
 
98
 
 
99
class Q_COMPAT_EXPORT Q3DockArea : public QWidget
 
100
{
 
101
    Q_OBJECT
 
102
    Q_ENUMS(HandlePosition)
 
103
    Q_PROPERTY(Qt::Orientation orientation READ orientation)
 
104
    Q_PROPERTY(int count READ count)
 
105
    Q_PROPERTY(bool empty READ isEmpty)
 
106
    Q_PROPERTY(HandlePosition handlePosition READ handlePosition)
 
107
 
 
108
    friend class Q3DockWindow;
 
109
    friend class Q3DockWindowResizeHandle;
 
110
    friend class Q3DockAreaLayout;
 
111
 
 
112
public:
 
113
    enum HandlePosition { Normal, Reverse };
 
114
 
 
115
    Q3DockArea(Qt::Orientation o, HandlePosition h = Normal, QWidget* parent=0, const char* name=0);
 
116
    ~Q3DockArea();
 
117
 
 
118
    void moveDockWindow(Q3DockWindow *w, const QPoint &globalPos, const QRect &rect, bool swap);
 
119
    void removeDockWindow(Q3DockWindow *w, bool makeFloating, bool swap, bool fixNewLines = true);
 
120
    void moveDockWindow(Q3DockWindow *w, int index = -1);
 
121
    bool hasDockWindow(Q3DockWindow *w, int *index = 0);
 
122
 
 
123
    void invalidNextOffset(Q3DockWindow *dw);
 
124
 
 
125
    Qt::Orientation orientation() const { return orient; }
 
126
    HandlePosition handlePosition() const { return hPos; }
 
127
 
 
128
    bool eventFilter(QObject *, QEvent *);
 
129
    bool isEmpty() const;
 
130
    int count() const;
 
131
    QList<Q3DockWindow *> dockWindowList() const;
 
132
 
 
133
    bool isDockWindowAccepted(Q3DockWindow *dw);
 
134
    void setAcceptDockWindow(Q3DockWindow *dw, bool accept);
 
135
 
 
136
public slots:
 
137
    void lineUp(bool keepNewLines);
 
138
 
 
139
private:
 
140
    struct DockWindowData
 
141
    {
 
142
        int index;
 
143
        int offset;
 
144
        int line;
 
145
        QSize fixedExtent;
 
146
        QPointer<Q3DockArea> area;
 
147
    };
 
148
 
 
149
    int findDockWindow(Q3DockWindow *w);
 
150
    int lineOf(int index);
 
151
    DockWindowData *dockWindowData(Q3DockWindow *w);
 
152
    void dockWindow(Q3DockWindow *dockWindow, DockWindowData *data);
 
153
    void updateLayout();
 
154
    void invalidateFixedSizes();
 
155
    int maxSpace(int hint, Q3DockWindow *dw);
 
156
    void setFixedExtent(int d, Q3DockWindow *dw);
 
157
    bool isLastDockWindow(Q3DockWindow *dw);
 
158
 
 
159
private:
 
160
    Q_DISABLE_COPY(Q3DockArea)
 
161
 
 
162
    Qt::Orientation orient;
 
163
    QList<Q3DockWindow *> dockWindows;
 
164
    Q3DockAreaLayout *layout;
 
165
    HandlePosition hPos;
 
166
    QList<Q3DockWindow *> forbiddenWidgets;
 
167
    Q3DockAreaPrivate *d;
 
168
};
 
169
 
 
170
#ifndef QT_NO_TEXTSTREAM
 
171
Q_COMPAT_EXPORT QTextStream &operator<<(QTextStream &, const Q3DockArea &);
 
172
Q_COMPAT_EXPORT QTextStream &operator>>(QTextStream &, Q3DockArea &);
 
173
#endif
 
174
 
 
175
#endif //QT_NO_MAINWINDOW
 
176
 
 
177
#endif //Q3DOCKAREA_H