wxShapeFramework
1.13.0 beta
|
Class encapsulates a rectangular shape derived from wxSFRectShape class which acts as a grid-based container able to manage other assigned child shapes (it can control their position). The managed shapes are aligned into defined grid with a behaviour similar to classic wxWidget's wxGridSizer class. More...
#include <GridShape.h>
Public Member Functions | |
XS_DECLARE_CLONABLE_CLASS (wxSFGridShape) | |
wxSFGridShape () | |
Default constructor. | |
wxSFGridShape (const wxRealPoint &pos, const wxRealPoint &size, int rows, int cols, int cellspace, wxSFDiagramManager *manager) | |
User constructor. | |
wxSFGridShape (const wxSFGridShape &obj) | |
Copy constructor. | |
virtual | ~wxSFGridShape () |
Destructor. | |
void | SetDimensions (int rows, int cols) |
Set grid dimensions. | |
void | SetCellSpace (int cellspace) |
Set space between grid cells (managed shapes). | |
void | GetDimensions (int *rows, int *cols) |
Get grid dimensions. | |
int | GetCellSpace () |
Get space between grid cells (managed shapes). | |
wxSFShapeBase * | GetManagedShape (size_t index) |
Get managed shape specified by lexicographic cell index. | |
wxSFShapeBase * | GetManagedShape (int row, int col) |
Get managed shape specified by row and column indexes. | |
void | ClearGrid () |
Clear information about managed shapes and set number of rows and columns to zero. | |
bool | AppendToGrid (wxSFShapeBase *shape) |
Append given shape to the grid at the last managed position. | |
bool | InsertToGrid (int row, int col, wxSFShapeBase *shape) |
Insert given shape to the grid at the given position. | |
bool | InsertToGrid (int index, wxSFShapeBase *shape) |
Insert given shape to the grid at the given position. | |
void | RemoveFromGrid (long id) |
Remove shape with given ID from the grid. | |
virtual void | Update () |
Upate shape (align all child shapes an resize it to fit them) | |
virtual void | FitToChildren () |
Resize the shape to bound all child shapes. The function can be overrided if neccessary. | |
virtual void | DoChildrenLayout () |
Do layout of assigned child shapes. | |
virtual void | OnChildDropped (const wxRealPoint &pos, wxSFShapeBase *child) |
Event handler called when any shape is dropped above this shape (and the dropped shape is accepted as a child of this shape). The function can be overrided if necessary. | |
Protected Member Functions | |
void | FitShapeToRect (wxSFShapeBase *shape, const wxRect &rct) |
Move and resize given shape so it will fit the given bounding rectangle. | |
Protected Attributes | |
int | m_nRows |
Number of grid rows. | |
int | m_nCols |
Number of grid columns. | |
int | m_nCellSpace |
Space additional space between managed shapes. | |
wxXS::IntArray | m_arrCells |
Array containing the IDs of managed shapes. | |
Private Member Functions | |
void | MarkSerializableDataMembers () |
Initialize serializable properties. | |
Friends | |
class | wxSFDiagramManager |
Class encapsulates a rectangular shape derived from wxSFRectShape class which acts as a grid-based container able to manage other assigned child shapes (it can control their position). The managed shapes are aligned into defined grid with a behaviour similar to classic wxWidget's wxGridSizer class.
Default constructor.
wxSFGridShape::wxSFGridShape | ( | const wxRealPoint & | pos, |
const wxRealPoint & | size, | ||
int | rows, | ||
int | cols, | ||
int | cellspace, | ||
wxSFDiagramManager * | manager | ||
) |
User constructor.
pos | Initial position |
size | Initial size |
rows | Number of grid rows |
cols | Number of grid columns |
cellspace | Additional space between managed shapes |
manager | Pointer to parent diagram manager |
wxSFGridShape::wxSFGridShape | ( | const wxSFGridShape & | obj | ) |
Copy constructor.
obj | Reference to the source object |
virtual wxSFGridShape::~wxSFGridShape | ( | ) | [virtual] |
Destructor.
bool wxSFGridShape::AppendToGrid | ( | wxSFShapeBase * | shape | ) |
Append given shape to the grid at the last managed position.
shape | Pointer to appended shape |
void wxSFGridShape::ClearGrid | ( | ) |
Clear information about managed shapes and set number of rows and columns to zero.
Note that this function doesn't remove managed (child) shapes from the parent grid shape (they are still its child shapes but aren't managed anymore).
virtual void wxSFGridShape::DoChildrenLayout | ( | ) | [virtual] |
Do layout of assigned child shapes.
Reimplemented in wxSFFlexGridShape.
void wxSFGridShape::FitShapeToRect | ( | wxSFShapeBase * | shape, |
const wxRect & | rct | ||
) | [protected] |
Move and resize given shape so it will fit the given bounding rectangle.
The shape is aligned inside the given bounding rectangle in accordance to the shape's valign and halign flags.
shape | Pointer to modified shape |
rct | Bounding rectangle |
virtual void wxSFGridShape::FitToChildren | ( | ) | [virtual] |
Resize the shape to bound all child shapes. The function can be overrided if neccessary.
Reimplemented from wxSFRectShape.
int wxSFGridShape::GetCellSpace | ( | ) | [inline] |
Get space between grid cells (managed shapes).
void wxSFGridShape::GetDimensions | ( | int * | rows, |
int * | cols | ||
) |
Get grid dimensions.
rows | Pointer to variable where number of rows will be stored |
cols | Pointer to variable where number of columns will be stored |
wxSFShapeBase* wxSFGridShape::GetManagedShape | ( | size_t | index | ) |
Get managed shape specified by lexicographic cell index.
index | Lexicographic index of requested shape |
wxSFShapeBase* wxSFGridShape::GetManagedShape | ( | int | row, |
int | col | ||
) |
Get managed shape specified by row and column indexes.
row | Zero-base row index |
col | Zero-based column index |
bool wxSFGridShape::InsertToGrid | ( | int | row, |
int | col, | ||
wxSFShapeBase * | shape | ||
) |
Insert given shape to the grid at the given position.
Note that the grid can grow in a vertical direction only, so if the user specify desired horizontal position bigger than the current number of columns is then this function exits with an error (false) return value. If specified vertical position exceeds the number or grid rows than the grid is resized. If the given position (grid cell) is already occupied by some shape then the previous one will be moved to the grid's last lexicographic position.
row | Vertical position |
col | Horizontal position |
shape | Pointer to inserted shape |
bool wxSFGridShape::InsertToGrid | ( | int | index, |
wxSFShapeBase * | shape | ||
) |
Insert given shape to the grid at the given position.
Note that the given index is a lexicographic position of inserted shape. The given shape is inserted before the existing item 'index', thus InsertToGrid(0, something) will insert an item in such way that it will become the first grid element.
index | Lexicographic position of inserted shape |
shape | Pointer to inserted shape |
void wxSFGridShape::MarkSerializableDataMembers | ( | ) | [private] |
Initialize serializable properties.
Reimplemented from wxSFRectShape.
virtual void wxSFGridShape::OnChildDropped | ( | const wxRealPoint & | pos, |
wxSFShapeBase * | child | ||
) | [virtual] |
Event handler called when any shape is dropped above this shape (and the dropped shape is accepted as a child of this shape). The function can be overrided if necessary.
The function is called by the framework (by the shape canvas).
pos | Relative position of dropped shape |
child | Pointer to dropped shape |
Reimplemented from wxSFShapeBase.
void wxSFGridShape::RemoveFromGrid | ( | long | id | ) |
Remove shape with given ID from the grid.
id | ID of shape which should be removed |
void wxSFGridShape::SetCellSpace | ( | int | cellspace | ) | [inline] |
Set space between grid cells (managed shapes).
cellspace | Cellspace size |
void wxSFGridShape::SetDimensions | ( | int | rows, |
int | cols | ||
) |
Set grid dimensions.
rows | Number of rows |
cols | Number of columns |
virtual void wxSFGridShape::Update | ( | ) | [virtual] |
Upate shape (align all child shapes an resize it to fit them)
Reimplemented from wxSFShapeBase.
friend class wxSFDiagramManager [friend] |
Reimplemented from wxSFShapeBase.
wxXS::IntArray wxSFGridShape::m_arrCells [protected] |
Array containing the IDs of managed shapes.
int wxSFGridShape::m_nCellSpace [protected] |
Space additional space between managed shapes.
int wxSFGridShape::m_nCols [protected] |
Number of grid columns.
int wxSFGridShape::m_nRows [protected] |
Number of grid rows.