]> git.saurik.com Git - wxWidgets.git/blob - interface/gbsizer.h
store selected indices as unsigned int, not size_t, in wxSelectionStore, we don't...
[wxWidgets.git] / interface / gbsizer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gbsizer.h
3 // Purpose: interface of wxGBPosition
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxGBPosition
11 @wxheader{gbsizer.h}
12
13 This class represents the position of an item in a virtual grid of
14 rows and columns managed by a wxGridBagSizer.
15
16 @library{wxcore}
17 @category{FIXME}
18 */
19 class wxGBPosition
20 {
21 public:
22 //@{
23 /**
24 Construct a new wxGBPosition, optionally setting the row and column.
25 The default is (0,0).
26 */
27 wxGBPosition();
28 wxGBPosition(int row, int col);
29 //@}
30
31 /**
32 Get the current column value.
33 */
34 int GetCol() const;
35
36 /**
37 Get the current row value.
38 */
39 int GetRow() const;
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 */
54 bool operator!(const wxGBPosition& p) const;
55
56 /**
57 Compare equality of two wxGBPositions.
58 */
59 bool operator operator==(const wxGBPosition& p) const;
60 };
61
62
63
64 /**
65 @class wxGridBagSizer
66 @wxheader{gbsizer.h}
67
68 A wxSizer that can lay out items in a virtual grid
69 like a wxFlexGridSizer but in this case
70 explicit positioning of the items is allowed using
71 wxGBPosition, and items can optionally span
72 more than one row and/or column using wxGBSpan.
73
74 @library{wxcore}
75 @category{winlayout}
76 */
77 class wxGridBagSizer : public wxFlexGridSizer
78 {
79 public:
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,
96 wxObject* userData = NULL);
97 wxSizerItem* Add(wxSizer* sizer, const wxGBPosition& pos,
98 const wxGBSpan& span = wxDefaultSpan,
99 int flag = 0,
100 int border = 0,
101 wxObject* userData = NULL);
102 wxSizerItem* Add(int width, int height,
103 const wxGBPosition& pos,
104 const wxGBSpan& span = wxDefaultSpan,
105 int flag = 0,
106 int border = 0,
107 wxObject* userData = NULL);
108 wxSizerItem* Add(wxGBSizerItem* item);
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,
125 wxGBSizerItem* excludeItem = NULL);
126 bool CheckForIntersection(const wxGBPosition& pos,
127 const wxGBSpan& span,
128 wxGBSizerItem* excludeItem = NULL);
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);
137 wxGBSizerItem* FindItem(wxSizer* sizer);
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 */
164 wxSize GetCellSize(int row, int col) const;
165
166 /**
167 Get the size used for cells in the grid with no item.
168 */
169 wxSize GetEmptyCellSize() const;
170
171 //@{
172 /**
173 Get the grid position of the specified item.
174 */
175 wxGBPosition GetItemPosition(wxWindow* window);
176 wxGBPosition GetItemPosition(wxSizer* sizer);
177 wxGBPosition GetItemPosition(size_t index);
178 //@}
179
180 //@{
181 /**
182 Get the row/col spanning of the specified item
183 */
184 wxGBSpan GetItemSpan(wxWindow* window);
185 wxGBSpan GetItemSpan(wxSizer* sizer);
186 wxGBSpan GetItemSpan(size_t index);
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);
207 bool SetItemPosition(wxSizer* sizer, const wxGBPosition& pos);
208 bool SetItemPosition(size_t index, const wxGBPosition& pos);
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);
218 bool SetItemSpan(wxSizer* sizer, const wxGBSpan& span);
219 bool SetItemSpan(size_t index, const wxGBSpan& span);
220 //@}
221 };
222
223
224
225 /**
226 @class wxGBSizerItem
227 @wxheader{gbsizer.h}
228
229 The wxGBSizerItem class is used by the
230 wxGridBagSizer for tracking the items in the
231 sizer. It adds grid position and spanning information to the normal
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.
237
238 @library{wxcore}
239 @category{FIXME}
240 */
241 class wxGBSizerItem : public wxSizerItem
242 {
243 public:
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);
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);
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 */
270 wxGBPosition GetPos() const;
271 const void GetPos(int& row, int& col) const;
272 //@}
273
274 //@{
275 /**
276 Get the row and column spanning of the item.
277 */
278 wxGBSpan GetSpan() const;
279 const void GetSpan(int& rowspan, int& colspan) const;
280 //@}
281
282 //@{
283 /**
284 Returns @true if the given pos/span would intersect with this item.
285 */
286 bool Intersects(const wxGBSizerItem& other);
287 bool Intersects(const wxGBPosition& pos,
288 const wxGBSpan& span);
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
309
310 /**
311 @class wxGBSpan
312 @wxheader{gbsizer.h}
313
314 This class is used to hold the row and column spanning attributes of
315 items in a wxGridBagSizer.
316
317 @library{wxcore}
318 @category{FIXME}
319 */
320 class wxGBSpan
321 {
322 public:
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();
330 wxGBSpan(int rowspan, int colspan);
331 //@}
332
333 /**
334 Get the current colspan value.
335 */
336 int GetColspan() const;
337
338 /**
339 Get the current rowspan value.
340 */
341 int GetRowspan() const;
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 */
356 bool operator!(const wxGBSpan& o) const;
357
358 /**
359 Compare equality of two wxGBSpans.
360 */
361 bool operator operator==(const wxGBSpan& o) const;
362 };
363