40 #ifndef _uigridcontainer_cpp
41 #define _uigridcontainer_cpp
43 #include "UI/gridcontainer.h"
44 #include "UI/pageprovider.h"
71 {
return ( this->
X == Other.
X && this->Y == Other.
Y ); }
74 {
return ( this->
X != Other.
X || this->Y != Other.
Y ); }
136 if( !CurrAttrib.
Empty() )
140 if( !CurrAttrib.
Empty() )
144 if( !CurrAttrib.
Empty() )
148 if( !CurrAttrib.
Empty() )
159 {
return "GridRect"; }
242 if( XCellsPerPage >= 1 && YCellsPerPage >= 1 ) {
250 ViewRect.
Position.
X =
static_cast<Whole>( ( CurrXPage - 1 ) * XCellsPerPage );
251 ViewRect.
Position.
Y =
static_cast<Whole>( ( CurrYPage - 1 ) * YCellsPerPage );
252 ViewRect.
Size.
X =
static_cast<Whole>( XCellsPerPage );
253 ViewRect.
Size.
Y =
static_cast<Whole>( YCellsPerPage );
260 GridRect ChildGridRect = (*RectIt).second;
261 if( ViewRect.
Envelopes( ChildGridRect ) ) {
263 const Rect OldChildRect = (*RectIt).first->GetRect();
267 NewChildRect.
Size.
X = ( ActCellSize.
X *
static_cast<Real>( ChildGridRect.
Size.
X ) ) - ActCellPadding.
X;
268 NewChildRect.
Size.
Y = ( ActCellSize.
Y *
static_cast<Real>( ChildGridRect.
Size.
Y ) ) - ActCellPadding.
Y;
277 NewChildRect.
Position.
X = NewSelfRect.
Position.
X + ( ( ActCellSize.
X *
static_cast<Real>( ChildColumn ) ) + ( ActCellPadding.
X * 0.5 ) );
278 NewChildRect.
Position.
Y = NewSelfRect.
Position.
Y + ( ( ActCellSize.
Y *
static_cast<Real>( ChildRow ) ) + ( ActCellPadding.
Y * 0.5 ) );
280 (*RectIt).first->UpdateDimensions(OldChildRect,NewChildRect);
283 (*RectIt).first->SetVisible( this->
GetVisible() );
286 const Rect OldChildRect = (*RectIt).first->GetRect();
288 NewChildRect.
Size = OldChildRect.
Size;
290 (*RectIt).first->UpdateDimensions(OldChildRect,NewChildRect);
291 (*RectIt).first->Hide();
322 if( XProv != YProv ) {
336 if( XProv != NULL ) {
384 Real XRel = 1.0 /
static_cast<Real>(X);
385 Real YRel = 1.0 /
static_cast<Real>(Y);
409 if( Ret.
X < (*RectIt).second.GetRightCell() ) {
410 Ret.
X = (*RectIt).second.GetRightCell();
412 if( Ret.
Y < (*RectIt).second.GetBottomCell() ) {
413 Ret.
Y = (*RectIt).second.GetBottomCell();
426 if( (*RectIt).first == Child ) {
427 (*RectIt).second = ChildTrans;
429 }
else if( (*RectIt).first->GetZOrder() > Zorder && InsIt != RectEnd ) {
434 return ( InsIt != RectEnd );
441 if( (*RectIt).first == Child ) {
442 return (*RectIt).second;
452 if( (*RectIt).first == Child ) {
515 (*ChildRectIt).second.ProtoSerialize(CellRectNode);
554 if( !ChildRectsNode.
Empty() ) {
557 for(
XML::NodeIterator ChildRectNodeIt = ChildRectsNode.
begin() ; ChildRectNodeIt != ChildRectsNode.
end() ; ++ChildRectNodeIt )
559 if( (*ChildRectNodeIt).GetAttribute(
"Version").AsInt() == 1 ) {
563 CurrAttrib = (*ChildRectNodeIt).GetAttribute(
"ChildName");
564 if( !CurrAttrib.
Empty() )
568 if( !CellRectNode.
Empty() )
571 if( !ChildName.empty() && CellRect != EmptyRect ) {
573 if( GridChild != NULL ) {
594 if( !PropertiesNode.
Empty() ) {
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
This is the base class for containers that have a render area and work area of different sizes...
GridRect()
Blank constructor.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
A light-weight handle for manipulating attributes in DOM tree.
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
GridVector2 Size
The Cell size of this rect.
Boole operator==(const GridRect &Other)
Equality comparison operator.
static const String TypeName
String containing the type name for this class: "GricContainer".
virtual void ProtoSerializeGridRects(XML::Node &SelfRoot) const
Convert the GridRects data of this class to an XML::Node ready for serialization. ...
bool Boole
Generally acts a single bit, true or false.
virtual GridVector2 GetGridSize() const
Gets the total used size of the Grid based on the current children.
virtual GridRect GetChildGridRect(Widget *Child) const
Gets the grid transform of a child in this container.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
This is a container class for placing child objects on a 2 dimensional grid.
ChildRectContainer::iterator ChildRectIterator
Iterator type for GridRects in relation to the children they apply to.
Vector2 Size
Vector2 representing the width and height of the rect.
virtual void ProtoDeSerializeGridRects(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the GridRects data of this object with it...
virtual Boole SetChildGridRect(Widget *Child, const GridRect &ChildTrans)
Sets the grid transform of a child in this container.
GridVector2 Position
The Cell position of this rect.
virtual const UnifiedVec2 & GetCellSize() const
Gets the Unified size of a single cell in this container.
Thrown when the requested identity could not be found.
virtual void DestroyChild(Widget *ToBeDestroyed)
Destroys a child Widget currently inside this QuadRenderable.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
virtual void RemoveAllChildren()
Removes all child Widgets from this QuadRenderable.
Simple rect used to represent a complete transform on a grid.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
virtual void UpdateWorkAreaSize()
Checks the size of every child in this container and updates the work area to match the size needed...
virtual void ProtoDeSerializeImpl(const XML::Node &SelfRoot)
Implementation method for deseriailizing additional sets of data.
ChildRectContainer ChildRects
Container storing pairs of Grid rects and the children they apply to.
Whole GetRightCell() const
Gets the Right cell of this Rect.
This class represents a box shaped area on the screen.
virtual void _SetContainer(PagedContainer *ToUpdate)
Sets the container that is using this provider to update which renderables are visible.
Whole Y
The Cell(s) on the Y axis.
Whole GetBottomCell() const
Gets the Bottom cell of this Rect.
virtual void AddChild(Widget *Child, const GridRect &GridTransform)
Adds a Widget to this as a child of this quad.
virtual void SetYProvider(PageProvider *YProv)
Sets the PageProvider for the Y axis.
bool Empty() const
Is this storing anything at all?
virtual ~GridContainer()
Class destructor.
This implements the exception hiearchy for Mezzanine.
PageProvider * XProvider
A pointer to the X axis provider.
Vector2 CalculateActualDimensions(const Vector2 &Actual) const
Calculates the actual values when a Vector2 with actual dimensions has this unified vector2 applied t...
virtual void DestroyAllChildren()
Destroys all child Widgets currently inside this QuadRenderable.
virtual Widget * GetChild(const UInt16 Zorder) const
Gets a child by it's ZOrder.
virtual void ProtoDeSerializeImpl(const XML::Node &SelfRoot)
Implementation method for deseriailizing additional sets of data.
virtual Boole RemoveChildGridRect(Widget *Child)
Removes the grid transform of a child from this container.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
Boole operator==(const GridVector2 &Other)
Equality comparison operator.
Rect ActDims
The actual (pixel) position and size of this Quad on the screen it belongs to.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
virtual const UInt16 & GetZOrder() const
Gets the currently set ZOrder of this QuadRenderable with it's parent.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual void DestroyAllChildren()
Destroys all child Widgets currently inside this QuadRenderable.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual Real GetCurrentYPage() const =0
Gets the current page position on the Y axis.
virtual GridContainer * CreateGridContainer(const String &RendName, Screen *Parent)
Creates a new GridContainer.
Whole GetLeftCell() const
Gets the Left cell of this Rect.
This class represents a 2D rect which can express the size and position of a renderable on screen...
uint16_t UInt16
An 16-bit unsigned integer.
ChildRectContainer::const_iterator ConstChildRectIterator
Const Iterator type for GridRects in relation to the children they apply to.
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
virtual void ProtoSerializeImpl(XML::Node &SelfRoot) const
Implementation method for serializing additional sets of data.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Real Y
Coordinate on the Y vector.
Child node iterator (a bidirectional iterator over a collection of Node)
GridContainer(Screen *Parent)
Blank constructor.
A light-weight handle for manipulating nodes in DOM tree.
iterator begin() const
Get a Child node iterator that references the first child Node.
Whole GetTopCell() const
Gets the Top cell of this Rect.
Real X
Coordinate on the X vector.
Boole operator!=(const GridVector2 &Other)
Inequality comparison operator.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
This is used to represent a point on a 2 dimentional area, such as a screen.
iterator end() const
Get a Child node iterator that references one past the last child Node.
bool Empty() const
Is this storing anything at all?
virtual void UnbindProvider(PageProvider *Prov)
Unbinds a provider being used by this container.
void SetIdentity()
Sets the values of this vector2 to identity values(0,0).
UnifiedVec2 CellSize
The size of each cell in this grid.
virtual void SetCellPadding(const UnifiedVec2 &Padding)
Sets the Unified padding to be applied on each axis to each cell in this grid.
Simple class used to represent positions or sizes on a grid.
virtual void RemoveChild(Widget *ToBeRemoved)
Removes a child Widget from this quadrenderable.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
virtual Boole GetVisible() const
Gets the visibility setting of this renderable.
UnifiedVec2 CellPadding
The amount of space on each side of each dimension of a given cell which will be considered unusable ...
virtual void QuickUpdateWorkAreaSize(const UnifiedVec2 &ChildSize, Boole Adding)
Quickly updates the work area size based on a single childs' dimensions.
Boole Envelopes(const GridRect &Other)
Gets whether or not this GridRect completely envelopes another GridRect.
virtual void SetXProvider(PageProvider *XProv)
Sets the PageProvider for the X axis.
virtual void SetProviders(PageProvider *XProv, PageProvider *YProv)
Sets the page providers for both axes.
Boole operator!=(const GridRect &Other)
Inequality comparison operator.
std::pair< Widget *, GridRect > ChildRectPair
Convenience typedef for a child of this container and it's grid rect.
PageProvider * YProvider
A pointer to the Y axis provider.
This is the base class for interpretting widget values to page positions.
virtual void SetCellSize(const Whole X, const Whole Y)
Convenience method that will set the cell size of this grid via the desired number of cells within th...
Vector2 WorkAreaSize
Vector2 storing the size for all pages of this container.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
GridVector2()
Blank constructor.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
virtual void RemoveAllChildren()
Removes all child Widgets from this QuadRenderable.
virtual Real GetCurrentXPage() const =0
Gets the current page position on the X axis.
virtual void UpdateContainerDimensionsImpl(const Rect &OldSelfRect, const Rect &NewSelfRect)
The container specific logic for updating it's dimensions.
This class represents a point in 2D space using UnifiedDim's.
virtual void _NotifyContainerUpdated()=0
Notifies this provider that the container it is providing page data to has been updated.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
VisibleChildContainer VisibleChildren
A container of children that meet the criteria for rendering in this container.
Vector2 Position
Vector2 representing the top-left position of the rect.
Whole X
The Cell(s) on the X axis.
virtual const UnifiedVec2 & GetCellPadding() const
Gets the Unified padding to be applied on each axis to each cell in this grid.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
virtual void DestroyChild(Widget *ToBeDestroyed)
Destroys a child Widget currently inside this QuadRenderable.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
virtual void RemoveChild(Widget *ToBeRemoved)
Removes a child Widget from this quadrenderable.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
std::string String
A datatype used to a series of characters.
virtual UnifiedVec2 GetCellClientArea() const
Gets the area available to a child widget when it's placed in a single cell.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual const String & GetTypeName() const
Gets the type of widget this is.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual void ProtoSerializeImpl(XML::Node &SelfRoot) const
Implementation method for serializing additional sets of data.