]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/gbsizer.h
Add wxFileName::SetPermissions().
[wxWidgets.git] / interface / wx / gbsizer.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: gbsizer.h
e54c96f1 3// Purpose: interface of wxGBPosition
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxGBPosition
7c913512 10
3d2cf884
BP
11 This class represents the position of an item in a virtual grid of rows and
12 columns managed by a wxGridBagSizer.
7c913512 13
23324ae1 14 @library{wxcore}
3d2cf884 15 @category{winlayout}
23324ae1 16*/
7c913512 17class wxGBPosition
23324ae1
FM
18{
19public:
23324ae1 20 /**
3d2cf884 21 Default constructor, setting the row and column to (0,0).
23324ae1
FM
22 */
23 wxGBPosition();
3d2cf884
BP
24 /**
25 Construct a new wxGBPosition, setting the row and column.
26 */
7c913512 27 wxGBPosition(int row, int col);
23324ae1
FM
28
29 /**
30 Get the current column value.
31 */
328f5751 32 int GetCol() const;
23324ae1
FM
33
34 /**
35 Get the current row value.
36 */
328f5751 37 int GetRow() const;
23324ae1
FM
38
39 /**
40 Set a new column value.
41 */
42 void SetCol(int col);
43
44 /**
45 Set a new row value.
46 */
47 void SetRow(int row);
48
49 /**
fc910c50 50 Compare inequality of two wxGBPositions.
23324ae1 51 */
fc910c50 52 bool operator!=(const wxGBPosition& p) const;
23324ae1
FM
53
54 /**
55 Compare equality of two wxGBPositions.
56 */
3d2cf884 57 bool operator==(const wxGBPosition& p) const;
23324ae1
FM
58};
59
60
e54c96f1 61
23324ae1
FM
62/**
63 @class wxGridBagSizer
7c913512 64
3d2cf884
BP
65 A wxSizer that can lay out items in a virtual grid like a wxFlexGridSizer
66 but in this case explicit positioning of the items is allowed using
67 wxGBPosition, and items can optionally span more than one row and/or column
68 using wxGBSpan.
7c913512 69
23324ae1
FM
70 @library{wxcore}
71 @category{winlayout}
72*/
73class wxGridBagSizer : public wxFlexGridSizer
74{
75public:
76 /**
77 Constructor, with optional parameters to specify the gap between the
78 rows and columns.
79 */
80 wxGridBagSizer(int vgap = 0, int hgap = 0);
81
82 //@{
83 /**
3d2cf884
BP
84 Adds the given item to the given position.
85
d29a9a8a 86 @return A valid pointer if the item was successfully placed at the
3d2cf884 87 given position, or @NULL if something was already there.
23324ae1
FM
88 */
89 wxSizerItem* Add(wxWindow* window, const wxGBPosition& pos,
90 const wxGBSpan& span = wxDefaultSpan,
3d2cf884 91 int flag = 0, int border = 0, wxObject* userData = NULL);
7c913512
FM
92 wxSizerItem* Add(wxSizer* sizer, const wxGBPosition& pos,
93 const wxGBSpan& span = wxDefaultSpan,
3d2cf884 94 int flag = 0, int border = 0, wxObject* userData = NULL);
faadbe6f
VZ
95 wxSizerItem* Add(wxGBSizerItem* item);
96
97 /**
98 Adds a spacer to the given position.
99 @a width and @a height specify the dimension of the spacer to be added.
100
101 @return A valid pointer if the spacer was successfully placed at the
102 given position, or @NULL if something was already there.
103 */
3d2cf884 104 wxSizerItem* Add(int width, int height, const wxGBPosition& pos,
7c913512 105 const wxGBSpan& span = wxDefaultSpan,
3d2cf884 106 int flag = 0, int border = 0, wxObject* userData = NULL);
23324ae1 107
faadbe6f 108 //@}
23324ae1
FM
109 /**
110 Called when the managed size of the sizer is needed or when layout
111 needs done.
112 */
113 wxSize CalcMin();
114
115 //@{
116 /**
117 Look at all items and see if any intersect (or would overlap) the given
118 item. Returns @true if so, @false if there would be no overlap. If an
3d2cf884
BP
119 @a excludeItem is given then it will not be checked for intersection,
120 for example it may be the item we are checking the position of.
23324ae1
FM
121 */
122 bool CheckForIntersection(wxGBSizerItem* item,
4cc4bfaf 123 wxGBSizerItem* excludeItem = NULL);
3d2cf884 124 bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span,
4cc4bfaf 125 wxGBSizerItem* excludeItem = NULL);
23324ae1
FM
126 //@}
127
128 //@{
129 /**
130 Find the sizer item for the given window or subsizer, returns @NULL if
131 not found. (non-recursive)
132 */
133 wxGBSizerItem* FindItem(wxWindow* window);
7c913512 134 wxGBSizerItem* FindItem(wxSizer* sizer);
23324ae1
FM
135 //@}
136
137 /**
138 Return the sizer item located at the point given in pt, or @NULL if
3d2cf884
BP
139 there is no item at that point. The (x,y) coordinates in @a pt
140 correspond to the client coordinates of the window using the sizer for
23324ae1
FM
141 layout. (non-recursive)
142 */
143 wxGBSizerItem* FindItemAtPoint(const wxPoint& pt);
144
145 /**
146 Return the sizer item for the given grid cell, or @NULL if there is no
147 item at that position. (non-recursive)
148 */
149 wxGBSizerItem* FindItemAtPosition(const wxGBPosition& pos);
150
151 /**
152 Return the sizer item that has a matching user data (it only compares
153 pointer values) or @NULL if not found. (non-recursive)
154 */
155 wxGBSizerItem* FindItemWithData(const wxObject* userData);
156
157 /**
3d2cf884
BP
158 Get the size of the specified cell, including hgap and vgap. Only valid
159 after window layout has been performed.
23324ae1 160 */
328f5751 161 wxSize GetCellSize(int row, int col) const;
23324ae1
FM
162
163 /**
164 Get the size used for cells in the grid with no item.
165 */
328f5751 166 wxSize GetEmptyCellSize() const;
23324ae1
FM
167
168 //@{
169 /**
170 Get the grid position of the specified item.
171 */
172 wxGBPosition GetItemPosition(wxWindow* window);
7c913512
FM
173 wxGBPosition GetItemPosition(wxSizer* sizer);
174 wxGBPosition GetItemPosition(size_t index);
23324ae1
FM
175 //@}
176
177 //@{
178 /**
3d2cf884 179 Get the row/col spanning of the specified item.
23324ae1
FM
180 */
181 wxGBSpan GetItemSpan(wxWindow* window);
7c913512
FM
182 wxGBSpan GetItemSpan(wxSizer* sizer);
183 wxGBSpan GetItemSpan(size_t index);
23324ae1
FM
184 //@}
185
186 /**
187 Called when the managed size of the sizer is needed or when layout
188 needs done.
189 */
190 void RecalcSizes();
191
192 /**
193 Set the size used for cells in the grid with no item.
194 */
195 void SetEmptyCellSize(const wxSize& sz);
196
197 //@{
198 /**
199 Set the grid position of the specified item. Returns @true on success.
200 If the move is not allowed (because an item is already there) then
201 @false is returned.
202 */
203 bool SetItemPosition(wxWindow* window, const wxGBPosition& pos);
7c913512
FM
204 bool SetItemPosition(wxSizer* sizer, const wxGBPosition& pos);
205 bool SetItemPosition(size_t index, const wxGBPosition& pos);
23324ae1
FM
206 //@}
207
208 //@{
209 /**
210 Set the row/col spanning of the specified item. Returns @true on
211 success. If the move is not allowed (because an item is already there)
212 then @false is returned.
213 */
214 bool SetItemSpan(wxWindow* window, const wxGBSpan& span);
7c913512
FM
215 bool SetItemSpan(wxSizer* sizer, const wxGBSpan& span);
216 bool SetItemSpan(size_t index, const wxGBSpan& span);
23324ae1
FM
217 //@}
218};
219
220
e54c96f1 221
23324ae1
FM
222/**
223 @class wxGBSizerItem
7c913512 224
3d2cf884
BP
225 The wxGBSizerItem class is used by the wxGridBagSizer for tracking the
226 items in the sizer. It adds grid position and spanning information to the
d13b34d3 227 normal wxSizerItem by adding wxGBPosition and wxGBSpan attributes. Most of
3d2cf884
BP
228 the time you will not need to use a wxGBSizerItem directly in your code,
229 but there are a couple of cases where it is handy.
7c913512 230
23324ae1 231 @library{wxcore}
3d2cf884 232 @category{winlayout}
23324ae1
FM
233*/
234class wxGBSizerItem : public wxSizerItem
235{
236public:
23324ae1 237 /**
3d2cf884 238 Construct a sizer item for tracking a spacer.
23324ae1
FM
239 */
240 wxGBSizerItem(int width, int height, const wxGBPosition& pos,
5eb16fe2
RD
241 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
242 wxObject* userData=NULL);
3d2cf884
BP
243 /**
244 Construct a sizer item for tracking a window.
245 */
7c913512 246 wxGBSizerItem(wxWindow* window, const wxGBPosition& pos,
5eb16fe2
RD
247 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
248 wxObject* userData=NULL);
3d2cf884
BP
249 /**
250 Construct a sizer item for tracking a subsizer.
251 */
7c913512 252 wxGBSizerItem(wxSizer* sizer, const wxGBPosition& pos,
5eb16fe2
RD
253 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
254 wxObject* userData=NULL);
23324ae1
FM
255
256 /**
3d2cf884 257 Get the row and column of the endpoint of this item.
23324ae1
FM
258 */
259 void GetEndPos(int& row, int& col);
260
261 //@{
262 /**
263 Get the grid position of the item.
264 */
328f5751 265 wxGBPosition GetPos() const;
3d2cf884 266 void GetPos(int& row, int& col) const;
23324ae1
FM
267 //@}
268
269 //@{
270 /**
271 Get the row and column spanning of the item.
272 */
328f5751 273 wxGBSpan GetSpan() const;
3d2cf884 274 void GetSpan(int& rowspan, int& colspan) const;
23324ae1
FM
275 //@}
276
23324ae1 277 /**
d13b34d3 278 Returns @true if this item and the @a other item intersect.
23324ae1
FM
279 */
280 bool Intersects(const wxGBSizerItem& other);
3d2cf884
BP
281 /**
282 Returns @true if the given pos/span would intersect with this item.
283 */
284 bool Intersects(const wxGBPosition& pos, const wxGBSpan& span);
23324ae1
FM
285
286 /**
3d2cf884
BP
287 If the item is already a member of a sizer then first ensure that there
288 is no other item that would intersect with this one at the new
23324ae1
FM
289 position, then set the new position. Returns @true if the change is
290 successful and after the next Layout the item will be moved.
291 */
292 bool SetPos(const wxGBPosition& pos);
293
294 /**
3d2cf884
BP
295 If the item is already a member of a sizer then first ensure that there
296 is no other item that would intersect with this one with its new
23324ae1
FM
297 spanning size, then set the new spanning. Returns @true if the change
298 is successful and after the next Layout the item will be resized.
299 */
300 bool SetSpan(const wxGBSpan& span);
5eb16fe2
RD
301
302
303 wxGridBagSizer* GetGBSizer() const;
304 void SetGBSizer(wxGridBagSizer* sizer);
23324ae1
FM
305};
306
307
e54c96f1 308
23324ae1
FM
309/**
310 @class wxGBSpan
7c913512 311
3d2cf884
BP
312 This class is used to hold the row and column spanning attributes of items
313 in a wxGridBagSizer.
7c913512 314
23324ae1 315 @library{wxcore}
3d2cf884 316 @category{winlayout}
23324ae1 317*/
7c913512 318class wxGBSpan
23324ae1
FM
319{
320public:
23324ae1 321 /**
3d2cf884
BP
322 Default constructor, setting the rowspan and colspan to (1,1) meaning
323 that the item occupies one cell in each direction.
23324ae1
FM
324 */
325 wxGBSpan();
3d2cf884
BP
326 /**
327 Construct a new wxGBSpan, setting the @a rowspan and @a colspan.
328 */
7c913512 329 wxGBSpan(int rowspan, int colspan);
23324ae1
FM
330
331 /**
332 Get the current colspan value.
333 */
328f5751 334 int GetColspan() const;
23324ae1
FM
335
336 /**
337 Get the current rowspan value.
338 */
328f5751 339 int GetRowspan() const;
23324ae1
FM
340
341 /**
342 Set a new colspan value.
343 */
344 void SetColspan(int colspan);
345
346 /**
347 Set a new rowspan value.
348 */
349 void SetRowspan(int rowspan);
350
351 /**
fc910c50 352 Compare inequality of two wxGBSpans.
23324ae1 353 */
fc910c50 354 bool operator!=(const wxGBSpan& o) const;
23324ae1
FM
355
356 /**
357 Compare equality of two wxGBSpans.
358 */
3d2cf884 359 bool operator==(const wxGBSpan& o) const;
23324ae1 360};
e54c96f1 361
5eb16fe2
RD
362
363const wxGBSpan wxDefaultSpan;