source: trunk/src/gui/widgets/qtoolbararealayout_p.h@ 500

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

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

File size: 6.0 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 QTOOLBARAREALAYOUT_P_H
43#define QTOOLBARAREALAYOUT_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 <QList>
57#include <QSize>
58#include <QRect>
59
60QT_BEGIN_NAMESPACE
61
62#ifndef QT_NO_TOOLBAR
63
64class QToolBar;
65class QLayoutItem;
66class QMainWindow;
67class QStyleOptionToolBar;
68
69class QToolBarAreaLayoutItem
70{
71public:
72 QToolBarAreaLayoutItem(QLayoutItem *item = 0)
73 : widgetItem(item), pos(0), size(-1), extraSpace(0), gap(false) {}
74
75 bool skip() const;
76 QSize minimumSize() const;
77 QSize sizeHint() const;
78 QSize realSizeHint() const;
79
80 QLayoutItem *widgetItem;
81 int pos;
82 int size;
83 int extraSpace;
84 bool gap;
85};
86
87class QToolBarAreaLayoutLine
88{
89public:
90 QToolBarAreaLayoutLine(Qt::Orientation orientation);
91
92 QSize sizeHint() const;
93 QSize minimumSize() const;
94
95 void fitLayout();
96 bool skip() const;
97
98 QRect rect;
99 Qt::Orientation o;
100
101 QList<QToolBarAreaLayoutItem> toolBarItems;
102};
103
104class QToolBarAreaLayoutInfo
105{
106public:
107 enum { EmptyDockAreaSize = 80 }; // when a dock area is empty, how "wide" is it?
108
109 QToolBarAreaLayoutInfo(QInternal::DockPosition pos = QInternal::TopDock);
110
111 QList<QToolBarAreaLayoutLine> lines;
112
113 QSize sizeHint() const;
114 QSize minimumSize() const;
115
116 void fitLayout();
117
118 QLayoutItem *insertToolBar(QToolBar *before, QToolBar *toolBar);
119 void insertItem(QToolBar *before, QLayoutItem *item);
120 void removeToolBar(QToolBar *toolBar);
121 void insertToolBarBreak(QToolBar *before);
122 void removeToolBarBreak(QToolBar *before);
123 void moveToolBar(QToolBar *toolbar, int pos);
124
125 QList<int> gapIndex(const QPoint &pos) const;
126 bool insertGap(QList<int> path, QLayoutItem *item);
127 void clear();
128 QRect itemRect(QList<int> path) const;
129 QRect appendLineDropRect() const;
130
131 QRect rect;
132 Qt::Orientation o;
133 QInternal::DockPosition dockPos;
134 bool dirty;
135};
136
137class QToolBarAreaLayout
138{
139public:
140 enum { // sentinel values used to validate state data
141 ToolBarStateMarker = 0xfe,
142 ToolBarStateMarkerEx = 0xfc
143 };
144
145 QRect rect;
146 QMainWindow *mainWindow;
147 QToolBarAreaLayoutInfo docks[4];
148 bool visible;
149
150 QToolBarAreaLayout(QMainWindow *win);
151
152 QRect fitLayout();
153
154 QSize minimumSize(const QSize &centerMin) const;
155 QRect rectHint(const QRect &r) const;
156 QSize sizeHint(const QSize &center) const;
157 void apply(bool animate);
158
159 QLayoutItem *itemAt(int *x, int index) const;
160 QLayoutItem *takeAt(int *x, int index);
161 void deleteAllLayoutItems();
162
163 QLayoutItem *insertToolBar(QToolBar *before, QToolBar *toolBar);
164 void removeToolBar(QToolBar *toolBar);
165 QLayoutItem *addToolBar(QInternal::DockPosition pos, QToolBar *toolBar);
166 void insertToolBarBreak(QToolBar *before);
167 void removeToolBarBreak(QToolBar *before);
168 void addToolBarBreak(QInternal::DockPosition pos);
169 void moveToolBar(QToolBar *toolbar, int pos);
170
171 void insertItem(QInternal::DockPosition pos, QLayoutItem *item);
172 void insertItem(QToolBar *before, QLayoutItem *item);
173
174 QInternal::DockPosition findToolBar(QToolBar *toolBar) const;
175 bool toolBarBreak(QToolBar *toolBar) const;
176
177 void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
178
179 QList<int> indexOf(QWidget *toolBar) const;
180 QList<int> gapIndex(const QPoint &pos) const;
181 QList<int> currentGapIndex() const;
182 bool insertGap(QList<int> path, QLayoutItem *item);
183 void remove(QList<int> path);
184 void remove(QLayoutItem *item);
185 void clear();
186 QToolBarAreaLayoutItem &item(QList<int> path);
187 QRect itemRect(QList<int> path) const;
188 QLayoutItem *plug(QList<int> path);
189 QLayoutItem *unplug(QList<int> path, QToolBarAreaLayout *other);
190
191 void saveState(QDataStream &stream) const;
192 bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false);
193 bool isEmpty() const;
194};
195
196
197QT_END_NAMESPACE
198#endif // QT_NO_TOOLBAR
199#endif // QTOOLBARAREALAYOUT_P_H
Note: See TracBrowser for help on using the repository browser.