RazorAutostartEntry => LxQt::AutostartEntry
[lxde/liblxqt.git] / razorgridlayout.h
1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
4 * Razor - 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 RAZORGRIDLAYOUT_H
30 #define RAZORGRIDLAYOUT_H
31
32 #include <QtGui/QLayout>
33 #include <QtCore/QList>
34
35 class RazorGridLayoutPrivate;
36
37 /**
38 The RazorGridLayout class lays out widgets in a grid.
39 **/
40 class RazorGridLayout: public QLayout
41 {
42 Q_OBJECT
43 public:
44 /**
45 This enum type is used to describe direction for this grid.
46 **/
47 enum Direction
48 {
49 LeftToRight, ///< The items are first laid out horizontally and then vertically.
50 TopToBottom ///< The items are first laid out vertically and then horizontally.
51 };
52
53 /**
54 This enum type is used to describe stretch. It contains one horizontal
55 and one vertical flags that can be combined to produce the required effect.
56 */
57 enum StretchFlag
58 {
59 NoStretch = 0, ///< No justifies items
60 StretchHorizontal = 1, ///< Justifies items in the available horizontal space
61 StretchVertical = 2 ///< Justifies items in the available vertical space
62 };
63 Q_DECLARE_FLAGS(Stretch, StretchFlag)
64
65
66
67 /**
68 Constructs a new RazorGridLayout with parent widget, parent.
69 The layout has one row and zero column initially, and will
70 expand to left when new items are inserted.
71 **/
72 explicit RazorGridLayout(QWidget *parent = 0);
73
74 /**
75 Destroys the grid layout. The layout's widgets aren't destroyed.
76 **/
77 ~RazorGridLayout();
78
79 void addItem(QLayoutItem *item);
80 QLayoutItem *itemAt(int index) const;
81 QLayoutItem *takeAt(int index);
82 int count() const;
83 void invalidate();
84
85 QSize sizeHint() const;
86 void setGeometry(const QRect &geometry);
87
88
89 /**
90 Returns the number of rows in this grid.
91 **/
92 int rowCount() const;
93
94 /**
95 Sets the number of rows in this grid. If value is 0, then rows
96 count will calculated automatically when new items are inserted.
97
98 In the most cases you should to set fixed number for one thing,
99 or for rows, or for columns.
100
101 \sa RazorGridLayout::setColumnCount
102 **/
103 void setRowCount(int value);
104
105
106 /**
107 Returns the number of columns in this grid.
108 **/
109 int columnCount() const;
110
111 /**
112 Sets the number of columns in this grid. If value is 0, then columns
113 count will calculated automatically when new items are inserted.
114
115 In the most cases you should to set fixed number for one thing,
116 or for rows, or for columns.
117
118 \sa RazorGridLayout::setRowCount
119 **/
120 void setColumnCount(int value);
121
122
123 /**
124 Returns the alignment of this grid.
125
126 \sa RazorGridLayout::Direction
127 **/
128 Direction direction() const;
129
130 /**
131 Sets the direction for this grid.
132
133 \sa RazorGridLayout::Direction
134 **/
135 void setDirection(Direction value);
136
137 /**
138 Returns the stretch flags of this grid.
139
140 \sa RazorGridLayout::StretchFlag
141 **/
142 Stretch stretch() const;
143
144 /**
145 Sets the stretch flags for this grid.
146
147 \sa RazorGridLayout::StretchFlag
148 **/
149 void setStretch(Stretch value);
150
151 /**
152 Moves the item at index position from to index position to.
153 **/
154 void moveItem(int from, int to);
155
156 /**
157 Returns the cells' minimum size.
158 By default, this property contains a size with zero width and height.
159 **/
160 QSize cellMinimumSize() const;
161
162 /**
163 Sets the minimum size of all cells to minSize pixels.
164 **/
165 void setCellMinimumSize(QSize minSize);
166
167 /**
168 Sets the minimum height of the cells to value without
169 changing the width. Provided for convenience.
170 **/
171 void setCellMinimumHeight(int value);
172
173 /**
174 Sets the minimum width of the cells to value without
175 changing the heights. Provided for convenience.
176 **/
177 void setCellMinimumWidth(int value);
178
179
180
181 /**
182 Returns the cells' maximum size.
183 By default, this property contains a size with zero width and height.
184 **/
185 QSize cellMaximumSize() const;
186
187 /**
188 Sets the maximum size of all cells to maxSize pixels.
189 **/
190 void setCellMaximumSize(QSize maxSize);
191
192 /**
193 Sets the maximum height of the cells to value without
194 changing the width. Provided for convenience.
195 **/
196 void setCellMaximumHeight(int value);
197
198 /**
199 Sets the maximum width of the cells to value without
200 changing the heights. Provided for convenience.
201 **/
202 void setCellMaximumWidth(int value);
203
204
205
206 /**
207 Sets both the minimum and maximum sizes of the cells to size,
208 thereby preventing it from ever growing or shrinking.
209 **/
210 void setCellFixedSize(QSize size);
211
212 /**
213 Sets both the minimum and maximum height of the cells to value without
214 changing the width. Provided for convenience.
215 **/
216 void setCellFixedHeight(int value);
217
218 /**
219 Sets both the minimum and maximum width of the cells to value without
220 changing the heights. Provided for convenience.
221 **/
222 void setCellFixedWidth(int value);
223
224 private:
225 RazorGridLayoutPrivate* const d_ptr;
226 Q_DECLARE_PRIVATE(RazorGridLayout)
227 };
228
229 Q_DECLARE_OPERATORS_FOR_FLAGS(RazorGridLayout::Stretch)
230
231
232 #endif // RAZORGRIDLAYOUT_H