2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: gbsizer.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxGBPosition
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxGBPosition
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-05-02 04:12:39 +00:00
|
|
|
This class represents the position of an item in a virtual grid of rows and
|
|
|
|
columns managed by a wxGridBagSizer.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-05-02 04:12:39 +00:00
|
|
|
@category{winlayout}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxGBPosition
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Default constructor, setting the row and column to (0,0).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxGBPosition();
|
2008-05-02 04:12:39 +00:00
|
|
|
/**
|
|
|
|
Construct a new wxGBPosition, setting the row and column.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBPosition(int row, int col);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current column value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetCol() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current row value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetRow() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set a new column value.
|
|
|
|
*/
|
|
|
|
void SetCol(int col);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set a new row value.
|
|
|
|
*/
|
|
|
|
void SetRow(int row);
|
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Checks if the position is valid. An invalid position is (-1,-1).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool operator!(const wxGBPosition& p) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Compare equality of two wxGBPositions.
|
|
|
|
*/
|
2008-05-02 04:12:39 +00:00
|
|
|
bool operator==(const wxGBPosition& p) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxGridBagSizer
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-05-02 04:12:39 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@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);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Adds the given item to the given position.
|
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return A valid pointer if the item was successfully placed at the
|
2008-05-02 04:12:39 +00:00
|
|
|
given position, or @NULL if something was already there.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxSizerItem* Add(wxWindow* window, const wxGBPosition& pos,
|
|
|
|
const wxGBSpan& span = wxDefaultSpan,
|
2008-05-02 04:12:39 +00:00
|
|
|
int flag = 0, int border = 0, wxObject* userData = NULL);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxSizerItem* Add(wxSizer* sizer, const wxGBPosition& pos,
|
|
|
|
const wxGBSpan& span = wxDefaultSpan,
|
2008-05-02 04:12:39 +00:00
|
|
|
int flag = 0, int border = 0, wxObject* userData = NULL);
|
|
|
|
wxSizerItem* Add(int width, int height, const wxGBPosition& pos,
|
2008-03-08 14:43:31 +00:00
|
|
|
const wxGBSpan& span = wxDefaultSpan,
|
2008-05-02 04:12:39 +00:00
|
|
|
int flag = 0, int border = 0, wxObject* userData = NULL);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxSizerItem* Add(wxGBSizerItem* item);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
2008-05-02 04:12:39 +00:00
|
|
|
@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.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool CheckForIntersection(wxGBSizerItem* item,
|
2008-03-09 12:33:59 +00:00
|
|
|
wxGBSizerItem* excludeItem = NULL);
|
2008-05-02 04:12:39 +00:00
|
|
|
bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span,
|
2008-03-09 12:33:59 +00:00
|
|
|
wxGBSizerItem* excludeItem = NULL);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Find the sizer item for the given window or subsizer, returns @NULL if
|
|
|
|
not found. (non-recursive)
|
|
|
|
*/
|
|
|
|
wxGBSizerItem* FindItem(wxWindow* window);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBSizerItem* FindItem(wxSizer* sizer);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return the sizer item located at the point given in pt, or @NULL if
|
2008-05-02 04:12:39 +00:00
|
|
|
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
|
2008-03-08 13:52:38 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Get the size of the specified cell, including hgap and vgap. Only valid
|
|
|
|
after window layout has been performed.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxSize GetCellSize(int row, int col) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the size used for cells in the grid with no item.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxSize GetEmptyCellSize() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Get the grid position of the specified item.
|
|
|
|
*/
|
|
|
|
wxGBPosition GetItemPosition(wxWindow* window);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBPosition GetItemPosition(wxSizer* sizer);
|
|
|
|
wxGBPosition GetItemPosition(size_t index);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Get the row/col spanning of the specified item.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxGBSpan GetItemSpan(wxWindow* window);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBSpan GetItemSpan(wxSizer* sizer);
|
|
|
|
wxGBSpan GetItemSpan(size_t index);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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);
|
2008-03-08 14:43:31 +00:00
|
|
|
bool SetItemPosition(wxSizer* sizer, const wxGBPosition& pos);
|
|
|
|
bool SetItemPosition(size_t index, const wxGBPosition& pos);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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);
|
2008-03-08 14:43:31 +00:00
|
|
|
bool SetItemSpan(wxSizer* sizer, const wxGBSpan& span);
|
|
|
|
bool SetItemSpan(size_t index, const wxGBSpan& span);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxGBSizerItem
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-05-02 04:12:39 +00:00
|
|
|
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 attrbibutes. 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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-05-02 04:12:39 +00:00
|
|
|
@category{winlayout}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxGBSizerItem : public wxSizerItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Construct a sizer item for tracking a spacer.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxGBSizerItem(int width, int height, const wxGBPosition& pos,
|
2008-05-02 04:12:39 +00:00
|
|
|
const wxGBSpan& span, int flag, int border,
|
|
|
|
wxObject* userData);
|
|
|
|
/**
|
|
|
|
Construct a sizer item for tracking a window.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBSizerItem(wxWindow* window, const wxGBPosition& pos,
|
2008-05-02 04:12:39 +00:00
|
|
|
const wxGBSpan& span, int flag, int border,
|
2008-03-08 14:43:31 +00:00
|
|
|
wxObject* userData);
|
2008-05-02 04:12:39 +00:00
|
|
|
/**
|
|
|
|
Construct a sizer item for tracking a subsizer.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBSizerItem(wxSizer* sizer, const wxGBPosition& pos,
|
2008-05-02 04:12:39 +00:00
|
|
|
const wxGBSpan& span, int flag, int border,
|
2008-03-08 14:43:31 +00:00
|
|
|
wxObject* userData);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Get the row and column of the endpoint of this item.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void GetEndPos(int& row, int& col);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Get the grid position of the item.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxGBPosition GetPos() const;
|
2008-05-02 04:12:39 +00:00
|
|
|
void GetPos(int& row, int& col) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Get the row and column spanning of the item.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxGBSpan GetSpan() const;
|
2008-05-02 04:12:39 +00:00
|
|
|
void GetSpan(int& rowspan, int& colspan) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Returns @true if this item and the @a other item instersect.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool Intersects(const wxGBSizerItem& other);
|
2008-05-02 04:12:39 +00:00
|
|
|
/**
|
|
|
|
Returns @true if the given pos/span would intersect with this item.
|
|
|
|
*/
|
|
|
|
bool Intersects(const wxGBPosition& pos, const wxGBSpan& span);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
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
|
2008-03-08 13:52:38 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
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
|
2008-03-08 13:52:38 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxGBSpan
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-05-02 04:12:39 +00:00
|
|
|
This class is used to hold the row and column spanning attributes of items
|
|
|
|
in a wxGridBagSizer.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-05-02 04:12:39 +00:00
|
|
|
@category{winlayout}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxGBSpan
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Default constructor, setting the rowspan and colspan to (1,1) meaning
|
|
|
|
that the item occupies one cell in each direction.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxGBSpan();
|
2008-05-02 04:12:39 +00:00
|
|
|
/**
|
|
|
|
Construct a new wxGBSpan, setting the @a rowspan and @a colspan.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxGBSpan(int rowspan, int colspan);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current colspan value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetColspan() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current rowspan value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetRowspan() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set a new colspan value.
|
|
|
|
*/
|
|
|
|
void SetColspan(int colspan);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set a new rowspan value.
|
|
|
|
*/
|
|
|
|
void SetRowspan(int rowspan);
|
|
|
|
|
|
|
|
/**
|
2008-05-02 04:12:39 +00:00
|
|
|
Checks if the span is valid. An invalid span is (-1,-1).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool operator!(const wxGBSpan& o) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Compare equality of two wxGBSpans.
|
|
|
|
*/
|
2008-05-02 04:12:39 +00:00
|
|
|
bool operator==(const wxGBSpan& o) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|