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

« back to all changes in this revision

Viewing changes to src/gui/kernel/qlayout.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 gui 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 QLAYOUT_H
 
30
#define QLAYOUT_H
 
31
 
 
32
#include "QtCore/qobject.h"
 
33
#include "QtGui/qlayoutitem.h"
 
34
#include "QtGui/qsizepolicy.h"
 
35
#include "QtCore/qrect.h"
 
36
 
 
37
#include "limits.h"
 
38
 
 
39
class QLayout;
 
40
class QSize;
 
41
 
 
42
#ifdef QT3_SUPPORT
 
43
class Q_GUI_EXPORT QLayoutIterator
 
44
{
 
45
public:
 
46
    inline QT3_SUPPORT_CONSTRUCTOR QLayoutIterator(QLayout *i) : layout(i), index(0) {}
 
47
    inline QLayoutIterator(const QLayoutIterator &i)
 
48
        : layout(i.layout), index(i.index) {}
 
49
    inline QLayoutIterator &operator=(const QLayoutIterator &i) {
 
50
        layout = i.layout;
 
51
        index = i.index;
 
52
        return *this;
 
53
    }
 
54
    inline QT3_SUPPORT QLayoutItem *operator++();
 
55
    inline QT3_SUPPORT QLayoutItem *current();
 
56
    inline QT3_SUPPORT QLayoutItem *takeCurrent();
 
57
    inline QT3_SUPPORT void deleteCurrent();
 
58
 
 
59
private:
 
60
    // hack to avoid deprecated warning
 
61
    friend class QLayout;
 
62
    inline QLayoutIterator(QLayout *i, bool) : layout(i), index(0) {}
 
63
    QLayout *layout;
 
64
    int index;
 
65
};
 
66
#endif
 
67
 
 
68
class QLayoutPrivate;
 
69
 
 
70
class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem
 
71
{
 
72
    Q_OBJECT
 
73
    Q_DECLARE_PRIVATE(QLayout)
 
74
 
 
75
    Q_ENUMS(SizeConstraint)
 
76
    Q_PROPERTY(int margin READ margin WRITE setMargin)
 
77
    Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
 
78
    Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint)
 
79
 
 
80
public:
 
81
    enum SizeConstraint {
 
82
        SetDefaultConstraint,
 
83
        SetNoConstraint,
 
84
        SetMinimumSize,
 
85
        SetFixedSize,
 
86
        SetMaximumSize,
 
87
        SetMinAndMaxSize
 
88
#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
 
89
        , Auto = SetDefaultConstraint,
 
90
        FreeResize = SetNoConstraint,
 
91
        Minimum = SetMinimumSize,
 
92
        Fixed = SetFixedSize
 
93
#endif
 
94
    };
 
95
 
 
96
    QLayout(QWidget *parent);
 
97
    QLayout();
 
98
    ~QLayout();
 
99
 
 
100
    int margin() const;
 
101
    int spacing() const;
 
102
 
 
103
    void setMargin(int);
 
104
    void setSpacing(int);
 
105
 
 
106
    bool setAlignment(QWidget *w, Qt::Alignment alignment);
 
107
    bool setAlignment(QLayout *l, Qt::Alignment alignment);
 
108
#ifdef Q_NO_USING_KEYWORD
 
109
    inline void setAlignment(Qt::Alignment alignment) { QLayoutItem::setAlignment(alignment); }
 
110
#else
 
111
    using QLayoutItem::setAlignment;
 
112
#endif
 
113
 
 
114
    void setSizeConstraint(SizeConstraint);
 
115
    SizeConstraint sizeConstraint() const;
 
116
#ifdef QT3_SUPPORT
 
117
    inline QT3_SUPPORT void setResizeMode(SizeConstraint s) {setSizeConstraint(s);}
 
118
    inline QT3_SUPPORT SizeConstraint resizeMode() const {return sizeConstraint();}
 
119
#endif
 
120
    void setMenuBar(QWidget *w);
 
121
    QWidget *menuBar() const;
 
122
 
 
123
    QWidget *parentWidget() const;
 
124
 
 
125
    void invalidate();
 
126
    QRect geometry() const;
 
127
    bool activate();
 
128
    void update();
 
129
 
 
130
    void addWidget(QWidget *w);
 
131
    virtual void addItem(QLayoutItem *) = 0;
 
132
 
 
133
    void removeWidget(QWidget *w);
 
134
    void removeItem(QLayoutItem *);
 
135
 
 
136
    Qt::Orientations expandingDirections() const;
 
137
    QSize minimumSize() const;
 
138
    QSize maximumSize() const;
 
139
    void setGeometry(const QRect&) = 0;
 
140
    virtual QLayoutItem *itemAt(int index) const = 0;
 
141
    virtual QLayoutItem *takeAt(int index) = 0;
 
142
    virtual int indexOf(QWidget *) const;
 
143
    virtual int count() const = 0;
 
144
    bool isEmpty() const;
 
145
 
 
146
    int totalHeightForWidth(int w) const;
 
147
    QSize totalMinimumSize() const;
 
148
    QSize totalMaximumSize() const;
 
149
    QSize totalSizeHint() const;
 
150
    QLayout *layout();
 
151
 
 
152
    void setEnabled(bool);
 
153
    bool isEnabled() const;
 
154
 
 
155
#ifdef QT3_SUPPORT
 
156
    QT3_SUPPORT void freeze(int w=0, int h=0);
 
157
    QT3_SUPPORT bool isTopLevel() const;
 
158
#endif
 
159
 
 
160
    static QSize closestAcceptableSize(const QWidget *w, const QSize &s);
 
161
 
 
162
protected:
 
163
    void widgetEvent(QEvent *);
 
164
    void childEvent(QChildEvent *e);
 
165
    void addChildLayout(QLayout *l);
 
166
    void addChildWidget(QWidget *w);
 
167
#ifdef QT3_SUPPORT
 
168
    QT3_SUPPORT void deleteAllItems();
 
169
#endif
 
170
 
 
171
    QRect alignmentRect(const QRect&) const;
 
172
protected:
 
173
    QLayout(QLayoutPrivate &d, QLayout*, QWidget*);
 
174
 
 
175
private:
 
176
    Q_DISABLE_COPY(QLayout)
 
177
 
 
178
    static void activateRecursiveHelper(QLayoutItem *item);
 
179
 
 
180
    friend class QApplicationPrivate;
 
181
    friend class QWidget;
 
182
 
 
183
#ifdef QT3_SUPPORT
 
184
public:
 
185
    QT3_SUPPORT_CONSTRUCTOR QLayout(QWidget *parent, int margin, int spacing = -1,
 
186
                             const char *name = 0);
 
187
    QT3_SUPPORT_CONSTRUCTOR QLayout(QLayout *parentLayout, int spacing = -1, const char *name = 0);
 
188
    QT3_SUPPORT_CONSTRUCTOR QLayout(int spacing, const char *name = 0);
 
189
    inline QT3_SUPPORT QWidget *mainWidget() const { return parentWidget(); }
 
190
    inline QT3_SUPPORT void remove(QWidget *w) { removeWidget(w); }
 
191
    inline QT3_SUPPORT void add(QWidget *w) { addWidget(w); }
 
192
 
 
193
    QT3_SUPPORT void setAutoAdd(bool a);
 
194
    QT3_SUPPORT bool autoAdd() const;
 
195
    inline QT3_SUPPORT QLayoutIterator iterator() { return QLayoutIterator(this,true); }
 
196
 
 
197
    inline QT3_SUPPORT int defaultBorder() const { return spacing(); }
 
198
#endif
 
199
};
 
200
 
 
201
#ifdef QT3_SUPPORT
 
202
inline QLayoutItem *QLayoutIterator::operator++() { return layout->itemAt(++index); }
 
203
inline QLayoutItem *QLayoutIterator::current() { return layout->itemAt(index); }
 
204
inline QLayoutItem *QLayoutIterator::takeCurrent() { return layout->takeAt(index); }
 
205
inline void QLayoutIterator::deleteCurrent() { delete  layout->takeAt(index); }
 
206
#endif
 
207
 
 
208
 
 
209
#endif
 
210
 
 
211
//### support old includes
 
212
#if 1 //def QT3_SUPPORT
 
213
#include "QtGui/qboxlayout.h"
 
214
#include "QtGui/qgridlayout.h"
 
215
#endif