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