]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/gbsizer.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGBPosition
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 This class represents the position of an item in a virtual grid of rows and
12 columns managed by a wxGridBagSizer.
21 Default constructor, setting the row and column to (0,0).
25 Construct a new wxGBPosition, setting the row and column.
27 wxGBPosition(int row
, int col
);
30 Get the current column value.
35 Get the current row value.
40 Set a new column value.
50 Compare inequality of two wxGBPositions.
52 bool operator!=(const wxGBPosition
& p
) const;
55 Compare equality of two wxGBPositions.
57 bool operator==(const wxGBPosition
& p
) const;
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
73 class wxGridBagSizer
: public wxFlexGridSizer
77 Constructor, with optional parameters to specify the gap between the
80 wxGridBagSizer(int vgap
= 0, int hgap
= 0);
84 Adds the given item to the given position.
86 @return A valid pointer if the item was successfully placed at the
87 given position, or @NULL if something was already there.
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
);
98 Adds a spacer to the given position.
99 @a width and @a height specify the dimension of the spacer to be added.
101 @return A valid pointer if the spacer was successfully placed at the
102 given position, or @NULL if something was already there.
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
);
110 Called when the managed size of the sizer is needed or when layout
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.
122 bool CheckForIntersection(wxGBSizerItem
* item
,
123 wxGBSizerItem
* excludeItem
= NULL
);
124 bool CheckForIntersection(const wxGBPosition
& pos
, const wxGBSpan
& span
,
125 wxGBSizerItem
* excludeItem
= NULL
);
130 Find the sizer item for the given window or subsizer, returns @NULL if
131 not found. (non-recursive)
133 wxGBSizerItem
* FindItem(wxWindow
* window
);
134 wxGBSizerItem
* FindItem(wxSizer
* sizer
);
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)
143 wxGBSizerItem
* FindItemAtPoint(const wxPoint
& pt
);
146 Return the sizer item for the given grid cell, or @NULL if there is no
147 item at that position. (non-recursive)
149 wxGBSizerItem
* FindItemAtPosition(const wxGBPosition
& pos
);
152 Return the sizer item that has a matching user data (it only compares
153 pointer values) or @NULL if not found. (non-recursive)
155 wxGBSizerItem
* FindItemWithData(const wxObject
* userData
);
158 Get the size of the specified cell, including hgap and vgap. Only valid
159 after window layout has been performed.
161 wxSize
GetCellSize(int row
, int col
) const;
164 Get the size used for cells in the grid with no item.
166 wxSize
GetEmptyCellSize() const;
170 Get the grid position of the specified item.
172 wxGBPosition
GetItemPosition(wxWindow
* window
);
173 wxGBPosition
GetItemPosition(wxSizer
* sizer
);
174 wxGBPosition
GetItemPosition(size_t index
);
179 Get the row/col spanning of the specified item.
181 wxGBSpan
GetItemSpan(wxWindow
* window
);
182 wxGBSpan
GetItemSpan(wxSizer
* sizer
);
183 wxGBSpan
GetItemSpan(size_t index
);
187 Called when the managed size of the sizer is needed or when layout
193 Set the size used for cells in the grid with no item.
195 void SetEmptyCellSize(const wxSize
& sz
);
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
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
);
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.
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
);
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.
234 class wxGBSizerItem
: public wxSizerItem
238 Construct a sizer item for tracking a spacer.
240 wxGBSizerItem(int width
, int height
, const wxGBPosition
& pos
,
241 const wxGBSpan
& span
=wxDefaultSpan
, int flag
=0, int border
=0,
242 wxObject
* userData
=NULL
);
244 Construct a sizer item for tracking a window.
246 wxGBSizerItem(wxWindow
* window
, const wxGBPosition
& pos
,
247 const wxGBSpan
& span
=wxDefaultSpan
, int flag
=0, int border
=0,
248 wxObject
* userData
=NULL
);
250 Construct a sizer item for tracking a subsizer.
252 wxGBSizerItem(wxSizer
* sizer
, const wxGBPosition
& pos
,
253 const wxGBSpan
& span
=wxDefaultSpan
, int flag
=0, int border
=0,
254 wxObject
* userData
=NULL
);
257 Get the row and column of the endpoint of this item.
259 void GetEndPos(int& row
, int& col
);
263 Get the grid position of the item.
265 wxGBPosition
GetPos() const;
266 void GetPos(int& row
, int& col
) const;
271 Get the row and column spanning of the item.
273 wxGBSpan
GetSpan() const;
274 void GetSpan(int& rowspan
, int& colspan
) const;
278 Returns @true if this item and the @a other item intersect.
280 bool Intersects(const wxGBSizerItem
& other
);
282 Returns @true if the given pos/span would intersect with this item.
284 bool Intersects(const wxGBPosition
& pos
, const wxGBSpan
& span
);
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.
292 bool SetPos(const wxGBPosition
& pos
);
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.
300 bool SetSpan(const wxGBSpan
& span
);
303 wxGridBagSizer
* GetGBSizer() const;
304 void SetGBSizer(wxGridBagSizer
* sizer
);
312 This class is used to hold the row and column spanning attributes of items
322 Default constructor, setting the rowspan and colspan to (1,1) meaning
323 that the item occupies one cell in each direction.
327 Construct a new wxGBSpan, setting the @a rowspan and @a colspan.
329 wxGBSpan(int rowspan
, int colspan
);
332 Get the current colspan value.
334 int GetColspan() const;
337 Get the current rowspan value.
339 int GetRowspan() const;
342 Set a new colspan value.
344 void SetColspan(int colspan
);
347 Set a new rowspan value.
349 void SetRowspan(int rowspan
);
352 Compare inequality of two wxGBSpans.
354 bool operator!=(const wxGBSpan
& o
) const;
357 Compare equality of two wxGBSpans.
359 bool operator==(const wxGBSpan
& o
) const;
363 const wxGBSpan wxDefaultSpan
;