]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/gbsizer.h
Try loading even English translations if provided.
[wxWidgets.git] / interface / wx / gbsizer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gbsizer.h
3 // Purpose: interface of wxGBPosition
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
7
8 /**
9 @class wxGBPosition
10
11 This class represents the position of an item in a virtual grid of rows and
12 columns managed by a wxGridBagSizer.
13
14 @library{wxcore}
15 @category{winlayout}
16 */
17 class wxGBPosition
18 {
19 public:
20 /**
21 Default constructor, setting the row and column to (0,0).
22 */
23 wxGBPosition();
24 /**
25 Construct a new wxGBPosition, setting the row and column.
26 */
27 wxGBPosition(int row, int col);
28
29 /**
30 Get the current column value.
31 */
32 int GetCol() const;
33
34 /**
35 Get the current row value.
36 */
37 int GetRow() const;
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 /**
50 Compare inequality of two wxGBPositions.
51 */
52 bool operator!=(const wxGBPosition& p) const;
53
54 /**
55 Compare equality of two wxGBPositions.
56 */
57 bool operator==(const wxGBPosition& p) const;
58 };
59
60
61
62 /**
63 @class wxGridBagSizer
64
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.
69
70 @library{wxcore}
71 @category{winlayout}
72 */
73 class wxGridBagSizer : public wxFlexGridSizer
74 {
75 public:
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 /**
84 Adds the given item to the given position.
85
86 @return A valid pointer if the item was successfully placed at the
87 given position, or @NULL if something was already there.
88 */
89 wxSizerItem* Add(wxWindow* window, const wxGBPosition& pos,
90 const wxGBSpan& span = wxDefaultSpan,
91 int flag = 0, int border = 0, wxObject* userData = NULL);
92 wxSizerItem* Add(wxSizer* sizer, const wxGBPosition& pos,
93 const wxGBSpan& span = wxDefaultSpan,
94 int flag = 0, int border = 0, wxObject* userData = NULL);
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 */
104 wxSizerItem* Add(int width, int height, const wxGBPosition& pos,
105 const wxGBSpan& span = wxDefaultSpan,
106 int flag = 0, int border = 0, wxObject* userData = NULL);
107
108 //@}
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
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.
121 */
122 bool CheckForIntersection(wxGBSizerItem* item,
123 wxGBSizerItem* excludeItem = NULL);
124 bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span,
125 wxGBSizerItem* excludeItem = NULL);
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);
134 wxGBSizerItem* FindItem(wxSizer* sizer);
135 //@}
136
137 /**
138 Return the sizer item located at the point given in pt, or @NULL if
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
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 /**
158 Get the size of the specified cell, including hgap and vgap. Only valid
159 after window layout has been performed.
160 */
161 wxSize GetCellSize(int row, int col) const;
162
163 /**
164 Get the size used for cells in the grid with no item.
165 */
166 wxSize GetEmptyCellSize() const;
167
168 //@{
169 /**
170 Get the grid position of the specified item.
171 */
172 wxGBPosition GetItemPosition(wxWindow* window);
173 wxGBPosition GetItemPosition(wxSizer* sizer);
174 wxGBPosition GetItemPosition(size_t index);
175 //@}
176
177 //@{
178 /**
179 Get the row/col spanning of the specified item.
180 */
181 wxGBSpan GetItemSpan(wxWindow* window);
182 wxGBSpan GetItemSpan(wxSizer* sizer);
183 wxGBSpan GetItemSpan(size_t index);
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);
204 bool SetItemPosition(wxSizer* sizer, const wxGBPosition& pos);
205 bool SetItemPosition(size_t index, const wxGBPosition& pos);
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);
215 bool SetItemSpan(wxSizer* sizer, const wxGBSpan& span);
216 bool SetItemSpan(size_t index, const wxGBSpan& span);
217 //@}
218 };
219
220
221
222 /**
223 @class wxGBSizerItem
224
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
227 normal wxSizerItem by adding wxGBPosition and wxGBSpan attributes. Most of
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.
230
231 @library{wxcore}
232 @category{winlayout}
233 */
234 class wxGBSizerItem : public wxSizerItem
235 {
236 public:
237 /**
238 Construct a sizer item for tracking a spacer.
239 */
240 wxGBSizerItem(int width, int height, const wxGBPosition& pos,
241 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
242 wxObject* userData=NULL);
243 /**
244 Construct a sizer item for tracking a window.
245 */
246 wxGBSizerItem(wxWindow* window, const wxGBPosition& pos,
247 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
248 wxObject* userData=NULL);
249 /**
250 Construct a sizer item for tracking a subsizer.
251 */
252 wxGBSizerItem(wxSizer* sizer, const wxGBPosition& pos,
253 const wxGBSpan& span=wxDefaultSpan, int flag=0, int border=0,
254 wxObject* userData=NULL);
255
256 /**
257 Get the row and column of the endpoint of this item.
258 */
259 void GetEndPos(int& row, int& col);
260
261 //@{
262 /**
263 Get the grid position of the item.
264 */
265 wxGBPosition GetPos() const;
266 void GetPos(int& row, int& col) const;
267 //@}
268
269 //@{
270 /**
271 Get the row and column spanning of the item.
272 */
273 wxGBSpan GetSpan() const;
274 void GetSpan(int& rowspan, int& colspan) const;
275 //@}
276
277 /**
278 Returns @true if this item and the @a other item intersect.
279 */
280 bool Intersects(const wxGBSizerItem& other);
281 /**
282 Returns @true if the given pos/span would intersect with this item.
283 */
284 bool Intersects(const wxGBPosition& pos, const wxGBSpan& span);
285
286 /**
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
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 /**
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
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);
301
302
303 wxGridBagSizer* GetGBSizer() const;
304 void SetGBSizer(wxGridBagSizer* sizer);
305 };
306
307
308
309 /**
310 @class wxGBSpan
311
312 This class is used to hold the row and column spanning attributes of items
313 in a wxGridBagSizer.
314
315 @library{wxcore}
316 @category{winlayout}
317 */
318 class wxGBSpan
319 {
320 public:
321 /**
322 Default constructor, setting the rowspan and colspan to (1,1) meaning
323 that the item occupies one cell in each direction.
324 */
325 wxGBSpan();
326 /**
327 Construct a new wxGBSpan, setting the @a rowspan and @a colspan.
328 */
329 wxGBSpan(int rowspan, int colspan);
330
331 /**
332 Get the current colspan value.
333 */
334 int GetColspan() const;
335
336 /**
337 Get the current rowspan value.
338 */
339 int GetRowspan() const;
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 /**
352 Compare inequality of two wxGBSpans.
353 */
354 bool operator!=(const wxGBSpan& o) const;
355
356 /**
357 Compare equality of two wxGBSpans.
358 */
359 bool operator==(const wxGBSpan& o) const;
360 };
361
362
363 const wxGBSpan wxDefaultSpan;