40 #ifndef _uispinner_cpp
41 #define _uispinner_cpp
43 #include "UI/spinner.h"
44 #include "UI/button.h"
45 #include "UI/editbox.h"
46 #include "UI/pagedcontainer.h"
47 #include "UI/screen.h"
49 #include "UI/horizontallayoutstrategy.h"
50 #include "UI/verticallayoutstrategy.h"
51 #include "UI/uimanager.h"
53 #include "stringtool.h"
54 #include "MathTools/mathtools.h"
90 OrderPriority(UI::OP_Horizontal_Vertical)
102 OrderPriority(UI::OP_Horizontal_Vertical)
114 OrderPriority(UI::OP_Horizontal_Vertical)
126 OrderPriority(UI::OP_Horizontal_Vertical)
138 OrderPriority(UI::OP_Horizontal_Vertical)
150 OrderPriority(UI::OP_Horizontal_Vertical)
169 this->
AddEvent(Spinner::EventSpinValueChanged);
189 Value = std::max(Value,this->
MinValue);
190 Value = std::min(Value,this->
MaxValue);
252 if( Style == UI::Spn_Separate_Horizontal || Style == Spn_Separate_Vertical ) {
257 if( Style == UI::Spn_Separate_Horizontal ) {
278 }
else if( Style == Spn_Separate_Vertical ) {
299 }
else if( Style == Spn_Together_Left || Style == Spn_Together_Right ) {
309 if( Style == Spn_Together_Left ) {
328 }
else if( Style == Spn_Together_Right ) {
369 if( ContainerXSize > 0 ) {
371 return ( Ret > 1 ? Ret : 1 );
381 if( ContainerYSize > 0 ) {
383 return ( Ret > 1 ? Ret : 1 );
437 if( !PropertiesNode.
Empty() ) {
440 if( !CurrAttrib.
Empty() )
443 CurrAttrib = PropertiesNode.
GetAttribute(
"IncrementValue");
444 if( !CurrAttrib.
Empty() )
448 if( !CurrAttrib.
Empty() )
452 if( !CurrAttrib.
Empty() )
485 if( EventWidget == NULL )
514 if( View.
X > 0 && View.
Y > 0 ) {
517 Real MaxPages = MathTools::Ceil( Work.
X / View.
X );
520 Real MaxPages = MathTools::Ceil( Work.
Y / View.
Y );
523 Real MaxXPages = MathTools::Ceil( Work.
X / View.
X );
524 Real MaxYPages = MathTools::Ceil( Work.
Y / View.
Y );
540 {
return new Spinner(RendName,SpinStyle,EditFont,Parent); }
543 {
return new Spinner(RendName,SpinStyle,EditFontName,Parent); }
546 {
return new Spinner(RendName,RendRect,SpinStyle,EditFont,Parent); }
549 {
return new Spinner(RendName,RendRect,SpinStyle,EditFontName,Parent); }
552 {
return new Spinner(XMLNode,Parent); }
555 {
return new Spinner(Parent); }
562 NameValuePairMap::const_iterator ParamIt;
563 ParamIt = Params.find(
"EditFontName");
564 if( ParamIt != Params.end() )
565 EditFontName = (*ParamIt).second;
567 ParamIt = Params.find(
"SpinStyle");
568 if( ParamIt != Params.end() )
571 return this->
CreateSpinner(RendName,SpinStyle,EditFontName,Parent);
579 NameValuePairMap::const_iterator ParamIt;
580 ParamIt = Params.find(
"EditFontName");
581 if( ParamIt != Params.end() )
582 EditFontName = (*ParamIt).second;
584 ParamIt = Params.find(
"SpinStyle");
585 if( ParamIt != Params.end() )
588 return this->
CreateSpinner(RendName,RendRect,SpinStyle,EditFontName,Parent);
595 {
delete static_cast<Spinner*
>( ToBeDestroyed ); }
int32_t Int32
An 32-bit integer.
Button * DecrementSpin
A pointer to the button that will decrement the spin value.
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
This class represents a collection of Glyphs in a common visual style.
virtual void SetSpinValueLimits(const Real Min, const Real Max)
Sets the minimum and maximum limits for the value this Spinner can have.
A light-weight handle for manipulating attributes in DOM tree.
Spinner(Screen *Parent)
Blank constructor.
bool Boole
Generally acts a single bit, true or false.
There is only one PageProvider providing pages for both the X and Y axes of this container, or the queried provider is being used for both the X and Y axes be the container.
static const String EventSpinValueChanged
Event name for when the value in this Spinner is updated.
UI::OrderingPriority OrderPriority
Which axis is primary when determining the current X or Y page.
SpinnerStyle
Used by the spinner class to determine what styling should be used for the spinner.
Anchors to the bottom side of the quad.
virtual Real GetMinSpinValue() const
Gets the minimum limit for the value this Spinner can have.
This is a specialization of a layout strategy where a group of quads are sized and placed in a linear...
Unified dimensions are ignored and will instead us all available space.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
Thrown when the requested identity could not be found.
virtual EditBox * CreateEditBox(const String &RendName, const RenderLayerType EditLayerType, FontData *EditFont)
Creates a EditBox.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
virtual void SetHorizontalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the X axis...
virtual void SetButtonLayout(const SpinnerStyle Style)
Sets the sizing and positioning policies of the children in this spinner to match the provided layout...
A simple reference counting pointer.
EventSubscriberSlot * Subscribe(const String &EventName, EventSubscriber *Sub)
Adds a subscriber to this event.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Value representing a SingleLineTextLayer.
virtual Real GetCurrentYPage() const
Gets the current page position on the Y axis.
virtual const String & GetTypeName() const
Gets the type of widget this is.
virtual void SetUnifiedSize(const UnifiedVec2 &Size)
Sets the size this QuadRenderable will have within it's parent.
virtual void SetText(const String &Text)
Sets the text in the edit layer of this EditBox.
OrderingPriority
Used by container widgets to determine which axis is considered primary for children/pages.
FontData * GetFont(const String &FontName, const String &Atlas) const
Gets the specified FontData from an Atlas.
virtual String GetText() const
Gets the text in the edit layer of this EditBox.
virtual void SetInputFilter(FilterCallback *Callback)
Sets the filter that will be used by this EditBox to determine if an input will be consumed...
bool Empty() const
Is this storing anything at all?
virtual Spinner * CreateSpinner(const String &RendName, const SpinnerStyle SpinStyle, FontData *EditFont, Screen *Parent)
Creates a new Spinner.
This is a simple widget for a numeric variable in a box.
PagedContainer * Container
A pointer to the PagedContainer this scrollbar is providing page data for.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
float Real
A Datatype used to represent a real floating point number.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual void ConstructSpinner(const SpinnerStyle SpinStyle, FontData *EditFont)
Contains all the common necessary startup initializations for this class.
EditBox * ValueDisplay
A pointer to the EditBox that will display the spin value.
This class represents a 2D rect which can express the size and position of a renderable on screen...
void SetMuteEvents(const Boole Mute)
Sets whether or not event firings by this publisher will be suppressed.
Resizing will use the provided unified dimensions with no further alterations. This is the default fo...
virtual void RemoveChild(Widget *ToBeRemoved)
Removes a child Widget from this quadrenderable.
The calculated value for the perpendicular axis will be used as the final value for this axis...
Real Y
Coordinate on the Y vector.
virtual Button * GetDecrement() const
Gets the decrement Button of this Spinner.
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a widget.
virtual Real GetMaxYPages() const
Gets the maximum number of pages supported on the Y axis.
A light-weight handle for manipulating nodes in DOM tree.
Real X
Coordinate on the X vector.
virtual void SetMaxSpinValue(const Real Value)
Sets the maximum limit for the value this spinner can have.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
virtual const Vector2 & GetWorkAreaSize() const
Gets the size of this containers work area.
This is used to represent a point on a 2 dimentional area, such as a screen.
bool Empty() const
Is this storing anything at all?
virtual void SetHorizontalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the X axis when it is resized.
virtual void UnbindProvider(PageProvider *Prov)
Unbinds a provider being used by this container.
virtual Vector2 GetActualSize() const
Gets the pixel size of this widget.
virtual Real GetMaxXPages() const
Gets the maximum number of pages supported on the X axis.
Real MinValue
The minimum value allowed to be expressed by this Spinner.
Anchors to the left side of the quad.
Button * IncrementSpin
A pointer to the button that will increment the spin value.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
virtual void SetMinSpinValue(const Real Value)
Sets the minimum limit for the value this Spinner can have.
virtual void _OnSpinValueChanged(const Real OldValue, const Real NewValue)
Self logic to be executed when this Spinner has it's spin value updated.
This is the EventArguments class for when the spinvalue of a Spinner is updated.
virtual void SetSpinValue(Real Value)
Sets the value of this Spinner.
virtual void ClampToLimits(Real &Value)
Ensures the provided value is within the configured limits.
Event * AddEvent(const String &EventName)
Creates a new event this Publisher can fire.
virtual EditBox * GetValueDisplay() const
Gets the EditBox displaying the value of this Spinner.
virtual ~Spinner()
Class destructor.
String Name
The unique name of this Renderable.
virtual void _NotifyContainerUpdated()
Notifies this provider that the container it is providing page data to has been updated.
void FireEvent(EventArgumentsPtr Args)
Fires an event.
virtual ProviderMode GetProviderConfig() const
Gets the current provider configuration of this container.
There is only one PageProvider providing pages for the Y axis of this container, or the queried provi...
virtual void AddChild(Widget *Child)
Adds a Widget to this as a child of this quad.
virtual void _SetLayoutStrat(LayoutStrategy *ToSet)
Sets a new LayoutStrategy for this quad to use.
virtual void SetIncrementValue(const Real Value)
Sets the amount to increase or decrease by when the spinner value is altered by child buttons...
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
This is the base class for interpretting widget values to page positions.
virtual Widget * GetWidget(const String &Name)
Gets a widget in this screen by name.
virtual Button * CreateButton(const String &RendName)
Creates a Button.
virtual Real GetSpinValue() const
Gets the value of this Spinner.
static const String EventTextUpdated
Event name for when the text in this widget has been updated.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
The bulk of the engine components go in this namspace.
virtual Real GetCurrentXPage() const
Gets the current page position on the X axis.
Real SpinValue
The current spin value of this Spinner.
virtual void SetVerticalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the Y axis when it is resized.
Boole GetMuteEvents() const
Gets whether or not event firings by this publisher will be suppressed.
Anchors to the right side of the quad.
This class represents a point in 2D space using UnifiedDim's.
ProviderMode
An enum describing how the providers for this container are configured and being used.
virtual Button * GetIncrement() const
Gets the increment Button of this Spinner.
virtual UI::OrderingPriority GetOrderingPriority() const
Gets which axis will be considered first when converting the current value to an X or Y page...
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Real MaxValue
The maximum value allowed to be expressed by this Spinner.
virtual Real GetMaxSpinValue() const
Gets the maximum limit for the value this spinner can have.
virtual void SetOrderingPriority(const UI::OrderingPriority Order)
Sets which axis will be considered first when converting the current value to an X or Y page...
virtual void SetUnifiedPosition(const UnifiedVec2 &Position)
Sets the position this QuadRenderable will have within it's parent.
Real IncrementValue
The amount to increase or decrease by when the spin value is altered via buttons. ...
virtual void SetVerticalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the Y axis...
static const String TypeName
String containing the type name for this class: "Spinner".
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
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...
Anchors to the top side of the quad.
std::string String
A datatype used to a series of characters.
This is a specialization of a layout strategy where a group of quads are sized and placed in a linear...
virtual Real GetIncrementValue() const
Gets the amount to increase or decrease by when the spinner value is altered by child buttons...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual void UpdateVisibleChildren()
Forces an update of the visible children in this container.
There is only one PageProvider providing pages for the X axis of this container, or the queried provi...
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Widget for handling the input and manipulation of text.