CS::SubRectangles Class Reference
A class managing allocations of sub-rectangles. More...
#include <csgeom/subrec.h>

Classes | |
class | SubRect |
Sub-rectangle. More... | |
Public Member Functions | |
virtual SubRect * | Alloc (int w, int h, csRect &rect) |
Allocate a new rectangle. | |
virtual void | Clear () |
Free all rectangles in this region. | |
void | Dump (const char *tag=0) |
For debugging: dump all free rectangles. | |
void | Dump (iObjectRegistry *object_reg, const char *tag=0) |
For debugging: dump all free rectangles. | |
csRect | GetMinimumRectangle () const |
Return the rectangle to which the allocator can be shrunk to at most. | |
const csRect & | GetRectangle () const |
Get the rectangle for this region. | |
virtual bool | Grow (int newWidth, int newHeight) |
Increase the size of the region. | |
bool | IsEmpty () const |
Returns whether the allocator is empty (ie no rectangles have been allocated at all or all allocated rectangles have been reclaimed). | |
virtual bool | PlaceInto (const SubRectangles *rectangles, SubRect *subRect, csHash< SubRect *, csConstPtrKey< SubRect > > *newRectangles=0) |
Place the subrectangles of another allocator into a rectangle allocated from this allocator. | |
void | Reclaim (SubRect *subrect) |
Reclaim a subrectangle, meaning, the space occupied by the subrect can be reused by subsequent Alloc() calls. | |
virtual bool | Shrink (int newWidth, int newHeight) |
Decrease the size of the region. | |
SubRectangles (const csRect ®ion) | |
Allocate a new empty region with the given size. | |
virtual | ~SubRectangles () |
Remove this region and sub-regions. | |
Protected Member Functions | |
void | Split (SubRect *subRect, SubRect::SplitType split, int splitPos) |
Helper function to split a node. | |
Protected Attributes | |
csArray< SubRect * > | leaves |
Leaves of the region tree. | |
csRect | region |
Dimensions of this region. | |
SubRect * | root |
Root of the region tree. |
Detailed Description
A class managing allocations of sub-rectangles.i.e. this class represents a rectangular region from which a client can allocate smaller rectangles until the region is full.
- Remarks:
- works best if bigger rectangles are inserted first.
Definition at line 48 of file subrec.h.
Constructor & Destructor Documentation
CS::SubRectangles::SubRectangles | ( | const csRect & | region | ) |
Allocate a new empty region with the given size.
virtual CS::SubRectangles::~SubRectangles | ( | ) | [virtual] |
Remove this region and sub-regions.
Member Function Documentation
virtual void CS::SubRectangles::Clear | ( | ) | [virtual] |
void CS::SubRectangles::Dump | ( | const char * | tag = 0 |
) |
For debugging: dump all free rectangles.
Works the same as Dump(iObjectRegistry*, const char*), although has no effect Crystal Space was not compiled in debug mode.
void CS::SubRectangles::Dump | ( | iObjectRegistry * | object_reg, | |
const char * | tag = 0 | |||
) |
For debugging: dump all free rectangles.
- Parameters:
-
object_reg Object registry. Used to obtain some required plugins. tag String appended to the filename dumped to.
csRect CS::SubRectangles::GetMinimumRectangle | ( | ) | const [inline] |
const csRect& CS::SubRectangles::GetRectangle | ( | ) | const [inline] |
virtual bool CS::SubRectangles::Grow | ( | int | newWidth, | |
int | newHeight | |||
) | [virtual] |
Increase the size of the region.
You can only grow upwards.
bool CS::SubRectangles::IsEmpty | ( | ) | const [inline] |
virtual bool CS::SubRectangles::PlaceInto | ( | const SubRectangles * | rectangles, | |
SubRect * | subRect, | |||
csHash< SubRect *, csConstPtrKey< SubRect > > * | newRectangles = 0 | |||
) | [virtual] |
Place the subrectangles of another allocator into a rectangle allocated from this allocator.
void CS::SubRectangles::Reclaim | ( | SubRect * | subrect | ) |
Reclaim a subrectangle, meaning, the space occupied by the subrect can be reused by subsequent Alloc() calls.
virtual bool CS::SubRectangles::Shrink | ( | int | newWidth, | |
int | newHeight | |||
) | [virtual] |
Decrease the size of the region.
If the region can't be shrunk to the desired size because some already allocated subrectangles would be cut off false
is returned. You can check if shrinking to a size is possible by comparing the result of GetMinimumRectangle() with the desired size.
void CS::SubRectangles::Split | ( | SubRect * | subRect, | |
SubRect::SplitType | split, | |||
int | splitPos | |||
) | [protected] |
Helper function to split a node.
Member Data Documentation
csArray<SubRect*> CS::SubRectangles::leaves [protected] |
csRect CS::SubRectangles::region [protected] |
SubRect* CS::SubRectangles::root [protected] |
The documentation for this class was generated from the following file:
- csgeom/subrec.h
Generated for Crystal Space 1.4.0 by doxygen 1.5.8