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