43 #include "UI/widget.h"
44 #include "UI/screen.h"
45 #include "UI/renderlayergroup.h"
46 #include "UI/layoutstrategy.h"
72 HoveredSubWidget(NULL),
78 HoveredSubWidget(NULL),
84 HoveredSubWidget(NULL),
90 HoveredSubWidget(NULL),
125 this->
AddEvent(Widget::EventMouseEnter);
126 this->
AddEvent(Widget::EventMouseExit);
127 this->
AddEvent(Widget::EventMouseDragStart);
128 this->
AddEvent(Widget::EventMouseDragEnd);
129 this->
AddEvent(Widget::EventFocusGained);
130 this->
AddEvent(Widget::EventFocusLost);
131 this->
AddEvent(Widget::EventFocusLocked);
132 this->
AddEvent(Widget::EventFocusUnlocked);
133 this->
AddEvent(Widget::EventVisibilityShown);
134 this->
AddEvent(Widget::EventVisibilityHidden);
147 this->
BindGroupToState( WS_Hovered | WS_Focused | WS_Dragged, HoveredGroup);
154 {
return Renderable::RT_Widget; }
160 {
return (this->
State & WS_Hovered); }
163 {
return (this->
State & WS_Focused); }
166 {
return (this->
State & WS_Dragged); }
170 if( this->
State != NewState ) {
172 this->
State = NewState;
231 if( this->
Visible != CanSee ) {
239 { (*It)->SetVisible(CanSee); }
307 SerializeError(
"Create XML Version Attribute",
"StateGroupBinding",
true);
311 SerializeError(
"Create XML Version Attribute",
"StateGroupBindings",
true);
344 if( !PropertiesNode.
Empty() ) {
347 if( !CurrAttrib.
Empty() )
364 if( !BindingsNode.
Empty() ) {
368 if( (*BindingNodeIt).GetAttribute(
"Version").AsInt() == 1 ) {
371 CurrAttrib = (*BindingNodeIt).GetAttribute(
"StateID");
372 if( !CurrAttrib.
Empty() )
373 StateID = CurrAttrib.
AsUint();
375 CurrAttrib = (*BindingNodeIt).GetAttribute(
"LayerGroupID");
376 if( !CurrAttrib.
Empty() ) {
379 if( NamedGroup != NULL ) {
380 this->
StateGroupBindings.insert( std::pair<UInt32,RenderLayerGroup*>(StateID,NamedGroup) );
383 ExceptionStream <<
"Named RenderLayerGroup \"" << LayerGroupID <<
"\" not found when deserializing Widget named \"" << this->
GetName() <<
"\".";
404 if( !EventsNode.
Empty() ) {
408 if( (*EvNodeIt).GetAttribute(
"Version").AsInt() == 1 ) {
411 CurrAttrib = (*EvNodeIt).GetAttribute(
"Name");
412 if( !CurrAttrib.
Empty() )
415 if( !EvName.empty() ) {
546 return static_cast<Widget*>(this->
ParentQuad)->_HandleInput(Code);
555 static_cast<Widget*>(this->
ParentQuad)->_NotifyChildStateChange(Child,OldState,NewState);
594 {
return this->
CreateWidget(RendName,RendRect,Parent); }
604 {
delete ToBeDestroyed; }
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
const String & GetName() const
Gets the name of this renderable.
A light-weight handle for manipulating attributes in DOM tree.
This is a base class for the algorithms used by QuadRenderables to determine how they should update t...
bool Boole
Generally acts a single bit, true or false.
EventContainer Events
A container storing all the Events published by this class by name.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Thrown when the requested identity could not be found.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
A simple reference counting pointer.
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 ProtoDeSerializeImpl(const XML::Node &SelfRoot)
Implementation method for deseriailizing additional sets of data.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Boole Visible
Stores whether this Renderable is to be rendered (also dependent on parent visibility).
EventContainer::const_iterator ConstEventIterator
Const Iterator type for Event instances stored by this class.
RenderLayerGroup * CreateRenderLayerGroup(const UInt16 GroupID)
Creates a new RenderLayerGroup that can have. function will throw an exception if a group already exi...
virtual void ProtoSerializeImpl(XML::Node &SelfRoot) const
Implementation method for serializing additional sets of data.
bool Empty() const
Is this storing anything at all?
std::stringstream StringStream
A Datatype used for streaming operations with strings.
ChildContainer ChildWidgets
This is a container storing all the children that belong to this Quad.
bool SetValue(const Char8 *rhs)
Set the value of this.
void RemoveAllEvents()
Removes all events in this Publisher.
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.
Child node iterator (a bidirectional iterator over a collection of Node)
A light-weight handle for manipulating nodes in DOM tree.
iterator begin() const
Get a Child node iterator that references the first child Node.
unsigned int AsUint(unsigned int def=0) const
Attempts to convert the value of the attribute to an unsigned int and returns the results...
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
uint32_t UInt32
An 32-bit unsigned integer.
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?
Event * AddEvent(const String &EventName)
Creates a new event this Publisher can fire.
String Name
The unique name of this Renderable.
void FireEvent(EventArgumentsPtr Args)
Fires an event.
Thrown when parameters are checked at runtime and found invalid.
virtual void _SetLayoutStrat(LayoutStrategy *ToSet)
Sets a new LayoutStrategy for this quad to use.
This class stores a group of render layers that can be set to be rendered.
The bulk of the engine components go in this namspace.
ChildContainer::iterator ChildIterator
Iterator type for Widget instances stored by this class.
Boole IsWidget() const
Gets whether or not this renderable is a Widget.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
This represents a nestable quad for an object in a GUI layout.
virtual void _MarkDirty()
Marks this renderable as dirty, and informs other renderables if needed.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
RenderLayerGroup * GetRenderLayerGroup(const UInt16 GroupID) const
Gets a RenderLayerGroup by ID.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
virtual Boole IsVisible() const =0
Gets whether or not this renderable is being drawn.
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...
std::string String
A datatype used to a series of characters.
RenderableType
A small enum to describe the type of renderable this is.
QuadRenderable * ParentQuad
This is a pointer to the Quad that owns this Quad and is responsible for transform updates applied to...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
void SetActiveGroup(const UInt16 GroupID)
Sets the RenderLayerGroup that will be used to render this renderable.