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