Updated Russian translation
[lxde/liblxqt.git] / lxqtgridlayout.h
1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
4 * LXQt - a lightweight, Qt based, desktop toolset
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
29 #ifndef LXQTGRIDLAYOUT_H
30 #define LXQTGRIDLAYOUT_H
31
32 #include <QList>
33 #include "lxqtglobals.h"
34 #include <QLayout>
35
36
37 namespace LXQt
38 {
39
40 class GridLayoutPrivate;
41
42 /**
43 The GridLayout class lays out widgets in a grid.
44 **/
45 class LXQT_API GridLayout: public QLayout
46 {
47 Q_OBJECT
48 public:
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 {
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
67 };
68 Q_DECLARE_FLAGS(Stretch, StretchFlag)
69
70
71
72 /**
73 Constructs a new GridLayout with parent widget, parent.
74 The layout has one row and zero column initially, and will
75 expand to left when new items are inserted.
76 **/
77 explicit GridLayout(QWidget *parent = 0);
78
79 /**
80 Destroys the grid layout. The layout's widgets aren't destroyed.
81 **/
82 ~GridLayout();
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);
92 QRect occupiedGeometry() const;
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
107 \sa GridLayout::setColumnCount
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
124 \sa GridLayout::setRowCount
125 **/
126 void setColumnCount(int value);
127
128
129 /**
130 Returns the alignment of this grid.
131
132 \sa GridLayout::Direction
133 **/
134 Direction direction() const;
135
136 /**
137 Sets the direction for this grid.
138
139 \sa GridLayout::Direction
140 **/
141 void setDirection(Direction value);
142
143 /**
144 Returns the stretch flags of this grid.
145
146 \sa GridLayout::StretchFlag
147 **/
148 Stretch stretch() const;
149
150 /**
151 Sets the stretch flags for this grid.
152
153 \sa GridLayout::StretchFlag
154 **/
155 void setStretch(Stretch value);
156
157 /**
158 Moves the item at index position \param from to index position \param to.
159 If \param withAnimation set the reordering will be animated
160 **/
161 void moveItem(int from, int to, bool withAnimation = false);
162
163 /**
164 Returns the cells' minimum size.
165 By default, this property contains a size with zero width and height.
166 **/
167 QSize cellMinimumSize() const;
168
169 /**
170 Sets the minimum size of all cells to minSize pixels.
171 **/
172 void setCellMinimumSize(QSize minSize);
173
174 /**
175 Sets the minimum height of the cells to value without
176 changing the width. Provided for convenience.
177 **/
178 void setCellMinimumHeight(int value);
179
180 /**
181 Sets the minimum width of the cells to value without
182 changing the heights. Provided for convenience.
183 **/
184 void setCellMinimumWidth(int value);
185
186
187
188 /**
189 Returns the cells' maximum size.
190 By default, this property contains a size with zero width and height.
191 **/
192 QSize cellMaximumSize() const;
193
194 /**
195 Sets the maximum size of all cells to maxSize pixels.
196 **/
197 void setCellMaximumSize(QSize maxSize);
198
199 /**
200 Sets the maximum height of the cells to value without
201 changing the width. Provided for convenience.
202 **/
203 void setCellMaximumHeight(int value);
204
205 /**
206 Sets the maximum width of the cells to value without
207 changing the heights. Provided for convenience.
208 **/
209 void setCellMaximumWidth(int value);
210
211
212
213 /**
214 Sets both the minimum and maximum sizes of the cells to size,
215 thereby preventing it from ever growing or shrinking.
216 **/
217 void setCellFixedSize(QSize size);
218
219 /**
220 Sets both the minimum and maximum height of the cells to value without
221 changing the width. Provided for convenience.
222 **/
223 void setCellFixedHeight(int value);
224
225 /**
226 Sets both the minimum and maximum width of the cells to value without
227 changing the heights. Provided for convenience.
228 **/
229 void setCellFixedWidth(int value);
230
231 private:
232 GridLayoutPrivate* const d_ptr;
233 Q_DECLARE_PRIVATE(GridLayout)
234 };
235
236 Q_DECLARE_OPERATORS_FOR_FLAGS(GridLayout::Stretch)
237
238 } // namespace LXQt
239 #endif // LXQTGRIDLAYOUT_H