wxShapeFramework  1.13.0 beta
wxSFGridShape Class Reference

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>

Inheritance diagram for wxSFGridShape:
Collaboration diagram for wxSFGridShape:

List of all members.

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).
wxSFShapeBaseGetManagedShape (size_t index)
 Get managed shape specified by lexicographic cell index.
wxSFShapeBaseGetManagedShape (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

Detailed Description

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.


Constructor & Destructor Documentation

Default constructor.

wxSFGridShape::wxSFGridShape ( const wxRealPoint &  pos,
const wxRealPoint &  size,
int  rows,
int  cols,
int  cellspace,
wxSFDiagramManager manager 
)

User constructor.

Parameters:
posInitial position
sizeInitial size
rowsNumber of grid rows
colsNumber of grid columns
cellspaceAdditional space between managed shapes
managerPointer to parent diagram manager

Copy constructor.

Parameters:
objReference to the source object
virtual wxSFGridShape::~wxSFGridShape ( ) [virtual]

Destructor.


Member Function Documentation

Append given shape to the grid at the last managed position.

Parameters:
shapePointer to appended shape

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.

Parameters:
shapePointer to modified shape
rctBounding rectangle
See also:
wxSFShapeBase::SetVAlign, wxSFShapeBase::SetHAlign
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).

Returns:
Cellspace size
void wxSFGridShape::GetDimensions ( int *  rows,
int *  cols 
)

Get grid dimensions.

Parameters:
rowsPointer to variable where number of rows will be stored
colsPointer to variable where number of columns will be stored

Get managed shape specified by lexicographic cell index.

Parameters:
indexLexicographic index of requested shape
Returns:
Pointer to shape object of given cell index if exists, otherwise NULL
wxSFShapeBase* wxSFGridShape::GetManagedShape ( int  row,
int  col 
)

Get managed shape specified by row and column indexes.

Parameters:
rowZero-base row index
colZero-based column index
Returns:
Pointer to shape object stored in specified grid cell if exists, otherwise NULL
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.

Parameters:
rowVertical position
colHorizontal position
shapePointer to inserted shape
Returns:
True on success, otherwise False
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.

Parameters:
indexLexicographic position of inserted shape
shapePointer to inserted shape
Returns:
True on successe, otherwise False

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).

Parameters:
posRelative position of dropped shape
childPointer to dropped shape

Reimplemented from wxSFShapeBase.

void wxSFGridShape::RemoveFromGrid ( long  id)

Remove shape with given ID from the grid.

Parameters:
idID of shape which should be removed
void wxSFGridShape::SetCellSpace ( int  cellspace) [inline]

Set space between grid cells (managed shapes).

Parameters:
cellspaceCellspace size
void wxSFGridShape::SetDimensions ( int  rows,
int  cols 
)

Set grid dimensions.

Parameters:
rowsNumber of rows
colsNumber of columns
virtual void wxSFGridShape::Update ( ) [virtual]

Upate shape (align all child shapes an resize it to fit them)

Reimplemented from wxSFShapeBase.


Friends And Related Function Documentation

friend class wxSFDiagramManager [friend]

Reimplemented from wxSFShapeBase.


Member Data Documentation

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines