Make lxqt globals a public header
[lxde/liblxqt.git] / lxqtgridlayout.h
CommitLineData
ca1b12f4
AS
1/* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
b9223fe7 4 * LXQt - a lightweight, Qt based, desktop toolset
ca1b12f4
AS
5 * http://razor-qt.org
6 *
7 * Copyright: 2012 Razor team
8 * Authors:
9 * Alexander Sokoloff <sokoloff.a@gmail.com>
10 *
11 * This program or library is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20
21 * You should have received a copy of the GNU Lesser General
22 * Public License along with this library; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
25 *
26 * END_COMMON_COPYRIGHT_HEADER */
27
28
f9de00b4
AS
29#ifndef LXQTGRIDLAYOUT_H
30#define LXQTGRIDLAYOUT_H
ca1b12f4 31
e6389bfc 32#include <QList>
f9cba1ba 33#include "lxqtglobals.h"
afd3b116 34#include <QLayout>
afd3b116
JL
35
36
f05ba5af 37namespace LXQt
f9de00b4
AS
38{
39
40class GridLayoutPrivate;
ca1b12f4
AS
41
42/**
f9de00b4 43 The GridLayout class lays out widgets in a grid.
ca1b12f4 44 **/
f9cba1ba 45class LXQT_API GridLayout: public QLayout
ca1b12f4
AS
46{
47 Q_OBJECT
48public:
49 /**
50 This enum type is used to describe direction for this grid.
51 **/
52 enum Direction
53 {
54 LeftToRight, ///< The items are first laid out horizontally and then vertically.
55 TopToBottom ///< The items are first laid out vertically and then horizontally.
56 };
57
58 /**
59 This enum type is used to describe stretch. It contains one horizontal
60 and one vertical flags that can be combined to produce the required effect.
61 */
62 enum StretchFlag
63 {
39b2c497
KS
64 NoStretch = 0, ///< No justifies items
65 StretchHorizontal = 1, ///< Justifies items in the available horizontal space
66 StretchVertical = 2 ///< Justifies items in the available vertical space
ca1b12f4
AS
67 };
68 Q_DECLARE_FLAGS(Stretch, StretchFlag)
69
70
71
72 /**
f9de00b4 73 Constructs a new GridLayout with parent widget, parent.
ca1b12f4
AS
74 The layout has one row and zero column initially, and will
75 expand to left when new items are inserted.
76 **/
f9de00b4 77 explicit GridLayout(QWidget *parent = 0);
ca1b12f4
AS
78
79 /**
80 Destroys the grid layout. The layout's widgets aren't destroyed.
81 **/
f9de00b4 82 ~GridLayout();
ca1b12f4
AS
83
84 void addItem(QLayoutItem *item);
85 QLayoutItem *itemAt(int index) const;
86 QLayoutItem *takeAt(int index);
87 int count() const;
88 void invalidate();
89
90 QSize sizeHint() const;
91 void setGeometry(const QRect &geometry);
57f016d9 92 QRect occupiedGeometry() const;
ca1b12f4
AS
93
94
95 /**
96 Returns the number of rows in this grid.
97 **/
98 int rowCount() const;
99
100 /**
101 Sets the number of rows in this grid. If value is 0, then rows
102 count will calculated automatically when new items are inserted.
103
104 In the most cases you should to set fixed number for one thing,
105 or for rows, or for columns.
106
f9de00b4 107 \sa GridLayout::setColumnCount
ca1b12f4
AS
108 **/
109 void setRowCount(int value);
110
111
112 /**
113 Returns the number of columns in this grid.
114 **/
115 int columnCount() const;
116
117 /**
118 Sets the number of columns in this grid. If value is 0, then columns
119 count will calculated automatically when new items are inserted.
120
121 In the most cases you should to set fixed number for one thing,
122 or for rows, or for columns.
123
f9de00b4 124 \sa GridLayout::setRowCount
ca1b12f4
AS
125 **/
126 void setColumnCount(int value);
127
128
129 /**
130 Returns the alignment of this grid.
131
f9de00b4 132 \sa GridLayout::Direction
ca1b12f4
AS
133 **/
134 Direction direction() const;
135
136 /**
137 Sets the direction for this grid.
138
f9de00b4 139 \sa GridLayout::Direction
ca1b12f4
AS
140 **/
141 void setDirection(Direction value);
142
143 /**
144 Returns the stretch flags of this grid.
145
f9de00b4 146 \sa GridLayout::StretchFlag
ca1b12f4
AS
147 **/
148 Stretch stretch() const;
149
150 /**
151 Sets the stretch flags for this grid.
152
f9de00b4 153 \sa GridLayout::StretchFlag
ca1b12f4
AS
154 **/
155 void setStretch(Stretch value);
156
5a1ce682 157 /**
c6a4f226
PK
158 Moves the item at index position \param from to index position \param to.
159 If \param withAnimation set the reordering will be animated
5a1ce682 160 **/
c6a4f226 161 void moveItem(int from, int to, bool withAnimation = false);
5a1ce682 162
a654e583 163 /**
303190cf
PK
164 Checks if layout is currently animated after the \sa moveItem()
165 invocation.
166 **/
167 bool animatedMoveInProgress() const;
168
169 /**
a654e583
AS
170 Returns the cells' minimum size.
171 By default, this property contains a size with zero width and height.
172 **/
173 QSize cellMinimumSize() const;
174
175 /**
176 Sets the minimum size of all cells to minSize pixels.
177 **/
178 void setCellMinimumSize(QSize minSize);
179
180 /**
05a1e105
AS
181 Sets the minimum height of the cells to value without
182 changing the width. Provided for convenience.
183 **/
184 void setCellMinimumHeight(int value);
185
186 /**
187 Sets the minimum width of the cells to value without
188 changing the heights. Provided for convenience.
189 **/
190 void setCellMinimumWidth(int value);
191
192
193
194 /**
a654e583
AS
195 Returns the cells' maximum size.
196 By default, this property contains a size with zero width and height.
197 **/
198 QSize cellMaximumSize() const;
199
200 /**
05a1e105 201 Sets the maximum size of all cells to maxSize pixels.
a654e583
AS
202 **/
203 void setCellMaximumSize(QSize maxSize);
204
05a1e105
AS
205 /**
206 Sets the maximum height of the cells to value without
207 changing the width. Provided for convenience.
208 **/
209 void setCellMaximumHeight(int value);
210
211 /**
212 Sets the maximum width of the cells to value without
213 changing the heights. Provided for convenience.
214 **/
215 void setCellMaximumWidth(int value);
216
217
218
219 /**
220 Sets both the minimum and maximum sizes of the cells to size,
221 thereby preventing it from ever growing or shrinking.
222 **/
223 void setCellFixedSize(QSize size);
224
225 /**
226 Sets both the minimum and maximum height of the cells to value without
227 changing the width. Provided for convenience.
228 **/
229 void setCellFixedHeight(int value);
230
231 /**
232 Sets both the minimum and maximum width of the cells to value without
233 changing the heights. Provided for convenience.
234 **/
235 void setCellFixedWidth(int value);
a654e583 236
ca1b12f4 237private:
f9de00b4
AS
238 GridLayoutPrivate* const d_ptr;
239 Q_DECLARE_PRIVATE(GridLayout)
ca1b12f4
AS
240};
241
f9de00b4 242Q_DECLARE_OPERATORS_FOR_FLAGS(GridLayout::Stretch)
ca1b12f4 243
f05ba5af 244} // namespace LXQt
f9de00b4 245#endif // LXQTGRIDLAYOUT_H