~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to kdevdesigner/designer/layout.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
** Copyright (C) 2000 Trolltech AS.  All rights reserved.
 
3
**
 
4
** This file is part of Qt Designer.
 
5
**
 
6
** This file may be distributed and/or modified under the terms of the
 
7
** GNU General Public License version 2 as published by the Free Software
 
8
** Foundation and appearing in the file LICENSE.GPL included in the
 
9
** packaging of this file.
 
10
**
 
11
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
 
12
** licenses may use this file in accordance with the Qt Commercial License
 
13
** Agreement provided with the Software.
 
14
**
 
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
17
**
 
18
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
19
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
20
**   information about Qt Commercial License Agreements.
 
21
**
 
22
** Contact info@trolltech.com if any conditions of this licensing are
 
23
** not clear to you.
 
24
**
 
25
**********************************************************************/
 
26
 
 
27
#ifndef LAYOUT_H
 
28
#define LAYOUT_H
 
29
 
 
30
#include <qwidget.h>
 
31
#include <qmap.h>
 
32
#include <qguardedptr.h>
 
33
#include <qobject.h>
 
34
#include <qlayout.h>
 
35
#include <qmap.h>
 
36
#include <qwidgetlist.h>
 
37
 
 
38
class FormWindow;
 
39
class QPaintEvent;
 
40
 
 
41
class Layout : public QObject
 
42
{
 
43
    Q_OBJECT
 
44
 
 
45
public:
 
46
    Layout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
 
47
    virtual ~Layout() {}
 
48
 
 
49
    virtual void doLayout() = 0;
 
50
    virtual void undoLayout();
 
51
    virtual void breakLayout();
 
52
    virtual bool prepareLayout( bool &needMove, bool &needReparent );
 
53
    virtual void finishLayout( bool needMove, QLayout *layout );
 
54
 
 
55
protected:
 
56
    QWidgetList widgets;
 
57
    QWidget *parent;
 
58
    QPoint startPoint;
 
59
    QMap<QGuardedPtr<QWidget>, QRect> geometries;
 
60
    QWidget *layoutBase;
 
61
    FormWindow *formWindow;
 
62
    QRect oldGeometry;
 
63
    bool isBreak;
 
64
    bool useSplitter;
 
65
 
 
66
protected:
 
67
    virtual void setup();
 
68
 
 
69
protected slots:
 
70
    void widgetDestroyed();
 
71
 
 
72
};
 
73
 
 
74
class HorizontalLayout : public Layout
 
75
{
 
76
public:
 
77
    HorizontalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
 
78
 
 
79
    void doLayout();
 
80
 
 
81
protected:
 
82
    void setup();
 
83
 
 
84
};
 
85
 
 
86
class VerticalLayout : public Layout
 
87
{
 
88
public:
 
89
    VerticalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
 
90
 
 
91
    void doLayout();
 
92
 
 
93
protected:
 
94
    void setup();
 
95
 
 
96
};
 
97
 
 
98
class Grid;
 
99
 
 
100
class GridLayout : public Layout
 
101
{
 
102
public:
 
103
    GridLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, const QSize &res, bool doSetup = TRUE );
 
104
    ~GridLayout();
 
105
 
 
106
    void doLayout();
 
107
 
 
108
protected:
 
109
    void setup();
 
110
 
 
111
protected:
 
112
    void buildGrid();
 
113
    QSize resolution;
 
114
    Grid* grid;
 
115
 
 
116
};
 
117
 
 
118
class Spacer : public QWidget
 
119
{
 
120
    Q_OBJECT
 
121
 
 
122
    Q_OVERRIDE( QCString name )
 
123
    Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
 
124
    Q_ENUMS( SizeType )
 
125
    Q_PROPERTY( SizeType sizeType READ sizeType WRITE setSizeType )
 
126
    Q_PROPERTY( QSize sizeHint READ sizeHint WRITE setSizeHint DESIGNABLE true STORED true )
 
127
    Q_OVERRIDE( QRect geometry DESIGNABLE false )
 
128
 
 
129
private:
 
130
    enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize,
 
131
           MayGrow = 1, ExpMask = 2, MayShrink = 4 };
 
132
 
 
133
public:
 
134
    enum SizeType { Fixed = 0,
 
135
                    Minimum = MayGrow,
 
136
                    Maximum = MayShrink,
 
137
                    Preferred = MayGrow|MayShrink ,
 
138
                    MinimumExpanding = Minimum|ExpMask,
 
139
                    Expanding = MinimumExpanding|MayShrink };
 
140
 
 
141
    Spacer( QWidget *parent, const char *name );
 
142
 
 
143
    QSize minimumSize() const;
 
144
    QSize sizeHint() const;
 
145
    void setSizeType( SizeType t );
 
146
    SizeType sizeType() const;
 
147
    int alignment() const;
 
148
    Orientation orientation() const;
 
149
    void setOrientation( Orientation o );
 
150
    void setInteraciveMode( bool b ) { interactive = b; };
 
151
    void setSizeHint( const QSize &s );
 
152
 
 
153
protected:
 
154
    void paintEvent( QPaintEvent *e );
 
155
    void resizeEvent( QResizeEvent* e );
 
156
    void updateMask();
 
157
    Qt::Orientation orient;
 
158
    bool interactive;
 
159
    QSize sh;
 
160
};
 
161
 
 
162
class QDesignerGridLayout : public QGridLayout
 
163
{
 
164
   Q_OBJECT
 
165
public:
 
166
    QDesignerGridLayout( QWidget *parent ) : QGridLayout( parent ){};
 
167
    QDesignerGridLayout( QLayout *parentLayout ) : QGridLayout( parentLayout ){};
 
168
 
 
169
    void addWidget( QWidget *, int row, int col, int align = 0 );
 
170
    void addMultiCellWidget( QWidget *, int fromRow, int toRow,
 
171
                               int fromCol, int toCol, int align = 0 );
 
172
 
 
173
    struct Item
 
174
    {
 
175
        Item(): row(0), column(0),rowspan(1),colspan(1){}
 
176
        Item( int r, int c, int rs, int cs): row(r), column(c), rowspan(rs), colspan(cs){}
 
177
        int row;
 
178
        int column;
 
179
        int rowspan;
 
180
        int colspan;
 
181
        Q_DUMMY_COMPARISON_OPERATOR( Item )
 
182
    };
 
183
 
 
184
    QMap<QWidget*, Item> items;
 
185
};
 
186
 
 
187
 
 
188
#endif