Spinning Topp Logo BlackTopp Studios
inc
spinner.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uispinner_cpp
41 #define _uispinner_cpp
42 
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"
48 #include "UI/font.h"
49 #include "UI/horizontallayoutstrategy.h"
50 #include "UI/verticallayoutstrategy.h"
51 #include "UI/uimanager.h"
52 
53 #include "stringtool.h"
54 #include "MathTools/mathtools.h"
55 
56 #include <algorithm>
57 #include <sstream>
58 
59 namespace
60 {
61  Mezzanine::Boole SpinnerFilter(const Mezzanine::Int32 Glyph)
62  {
63  // If the glyph is a period, a number, or a backspace then it gets through.
64  return ( Glyph == Mezzanine::Int32(46) || ( Glyph >= Mezzanine::Int32(48) && Glyph <= Mezzanine::Int32(57) ) );
65  }
66 }
67 
68 namespace Mezzanine
69 {
70  namespace UI
71  {
72  ///////////////////////////////////////////////////////////////////////////////
73  // Spinner Static Members
74 
75  const String Spinner::TypeName = "Spinner";
76  const String Spinner::EventSpinValueChanged = "SpinValueChanged";
77 
78  ///////////////////////////////////////////////////////////////////////////////
79  // Spinner Methods
80 
82  PageProvider(Parent),
83  IncrementSpin(NULL),
84  DecrementSpin(NULL),
85  ValueDisplay(NULL),
86  SpinValue(0.0),
87  IncrementValue(1.0),
88  MinValue(-1),
89  MaxValue(-1),
90  OrderPriority(UI::OP_Horizontal_Vertical)
91  { }
92 
93  Spinner::Spinner(const String& RendName, const SpinnerStyle SpinStyle, FontData* EditFont, Screen* Parent) :
94  PageProvider(RendName,Parent),
95  IncrementSpin(NULL),
96  DecrementSpin(NULL),
97  ValueDisplay(NULL),
98  SpinValue(0.0),
99  IncrementValue(1.0),
100  MinValue(-1),
101  MaxValue(-1),
102  OrderPriority(UI::OP_Horizontal_Vertical)
103  { this->ConstructSpinner(SpinStyle,EditFont); }
104 
105  Spinner::Spinner(const String& RendName, const SpinnerStyle SpinStyle, const String& EditFontName, Screen* Parent) :
106  PageProvider(RendName,Parent),
107  IncrementSpin(NULL),
108  DecrementSpin(NULL),
109  ValueDisplay(NULL),
110  SpinValue(0.0),
111  IncrementValue(1.0),
112  MinValue(-1),
113  MaxValue(-1),
114  OrderPriority(UI::OP_Horizontal_Vertical)
115  { this->ConstructSpinner(SpinStyle,this->ParentScreen->GetFont(EditFontName,this->ParentScreen->GetPrimaryAtlas())); }
116 
117  Spinner::Spinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, FontData* EditFont, Screen* Parent) :
118  PageProvider(RendName,RendRect,Parent),
119  IncrementSpin(NULL),
120  DecrementSpin(NULL),
121  ValueDisplay(NULL),
122  SpinValue(0.0),
123  IncrementValue(1.0),
124  MinValue(-1),
125  MaxValue(-1),
126  OrderPriority(UI::OP_Horizontal_Vertical)
127  { this->ConstructSpinner(SpinStyle,EditFont); }
128 
129  Spinner::Spinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, const String& EditFontName, Screen* Parent) :
130  PageProvider(RendName,RendRect,Parent),
131  IncrementSpin(NULL),
132  DecrementSpin(NULL),
133  ValueDisplay(NULL),
134  SpinValue(0.0),
135  IncrementValue(1.0),
136  MinValue(-1),
137  MaxValue(-1),
138  OrderPriority(UI::OP_Horizontal_Vertical)
139  { this->ConstructSpinner(SpinStyle,this->ParentScreen->GetFont(EditFontName,this->ParentScreen->GetPrimaryAtlas())); }
140 
141  Spinner::Spinner(const XML::Node& XMLNode, Screen* Parent) :
142  PageProvider(Parent),
143  IncrementSpin(NULL),
144  DecrementSpin(NULL),
145  ValueDisplay(NULL),
146  SpinValue(0.0),
147  IncrementValue(1.0),
148  MinValue(-1),
149  MaxValue(-1),
150  OrderPriority(UI::OP_Horizontal_Vertical)
151  { this->ProtoDeSerialize(XMLNode); }
152 
154  {
155  if( this->Container != NULL ) {
156  this->Container->UnbindProvider(this);
157  }
158 
159  this->RemoveChild( this->IncrementSpin );
160  this->ParentScreen->DestroyWidget( this->IncrementSpin );
161  this->RemoveChild( this->DecrementSpin );
162  this->ParentScreen->DestroyWidget( this->DecrementSpin );
163  this->RemoveChild( this->ValueDisplay );
164  this->ParentScreen->DestroyWidget( this->ValueDisplay );
165  }
166 
167  void Spinner::ConstructSpinner(const SpinnerStyle SpinStyle, FontData* EditFont)
168  {
169  this->AddEvent(Spinner::EventSpinValueChanged);
170 
171  // Create the child widgets.
172  this->ValueDisplay = this->ParentScreen->CreateEditBox(this->Name+".Display",UI::RLT_SingleLineText,EditFont);
173  this->IncrementSpin = this->ParentScreen->CreateButton(this->Name+".Increment");
174  this->DecrementSpin = this->ParentScreen->CreateButton(this->Name+".Decrement");
175 
176  this->SetButtonLayout(SpinStyle);
177 
178  this->ValueDisplay->SetInputFilter( &SpinnerFilter );
180 
184  }
185 
187  {
188  if( this->MinValue > 0.0 && this->MaxValue > 0.0 ) {
189  Value = std::max(Value,this->MinValue);
190  Value = std::min(Value,this->MaxValue);
191  }
192  }
193 
194  ///////////////////////////////////////////////////////////////////////////////
195  // Utility Methods
196 
198  { return Spinner::TypeName; }
199 
200  ///////////////////////////////////////////////////////////////////////////////
201  // Spinner Properties
202 
204  {
205  this->ClampToLimits(Value);
206  if( this->SpinValue != Value ) {
207  this->_OnSpinValueChanged(this->SpinValue,Value);
209  this->SpinValue = Value;
210  }
211  }
212 
214  { return this->SpinValue; }
215 
217  { this->IncrementValue = Value; }
218 
220  { return this->IncrementValue; }
221 
222  void Spinner::SetSpinValueLimits(const Real Min, const Real Max)
223  { this->SetMinSpinValue(Min); this->SetMaxSpinValue(Max); }
224 
225  void Spinner::SetMinSpinValue(const Real Value)
226  { this->MinValue = Value; }
227 
229  { return this->MinValue; }
230 
231  void Spinner::SetMaxSpinValue(const Real Value)
232  { this->MaxValue = Value; }
233 
235  { return this->MaxValue; }
236 
238  { this->OrderPriority = Order; }
239 
241  { return this->OrderPriority; }
242 
243  ///////////////////////////////////////////////////////////////////////////////
244  // Spinner Configuration
245 
247  {
248  this->RemoveChild( this->IncrementSpin );
249  this->RemoveChild( this->DecrementSpin );
250  this->RemoveChild( this->ValueDisplay );
251 
252  if( Style == UI::Spn_Separate_Horizontal || Style == Spn_Separate_Vertical ) {
254  this->ValueDisplay->SetUnifiedSize( UnifiedVec2(1,1) );
256 
257  if( Style == UI::Spn_Separate_Horizontal ) {
258 
263 
267 
272 
273  this->AddChild(this->DecrementSpin,1);
274  this->AddChild(this->ValueDisplay,2);
275  this->AddChild(this->IncrementSpin,3);
276 
278  }else if( Style == Spn_Separate_Vertical ) {
283 
287 
292 
293  this->AddChild(this->IncrementSpin,1);
294  this->AddChild(this->ValueDisplay,2);
295  this->AddChild(this->DecrementSpin,3);
296 
298  }
299  }else if( Style == Spn_Together_Left || Style == Spn_Together_Right ) {
300  this->IncrementSpin->SetUnifiedSize( UnifiedVec2(1,0.5) );
302 
303  this->ValueDisplay->SetUnifiedSize( UnifiedVec2(1,1) );
305 
306  this->DecrementSpin->SetUnifiedSize( UnifiedVec2(1,0.5) );
308 
309  if( Style == Spn_Together_Left ) {
314 
319 
324 
325  this->AddChild(this->IncrementSpin,1);
326  this->AddChild(this->DecrementSpin,2);
327  this->AddChild(this->ValueDisplay,3);
328  }else if( Style == Spn_Together_Right ) {
333 
338 
343 
344  this->AddChild(this->ValueDisplay,1);
345  this->AddChild(this->IncrementSpin,2);
346  this->AddChild(this->DecrementSpin,3);
347  }
348 
350  }
351  }
352 
354  { return this->IncrementSpin; }
355 
357  { return this->DecrementSpin; }
358 
360  { return this->ValueDisplay; }
361 
362  ///////////////////////////////////////////////////////////////////////////////
363  // PageProvider Methods
364 
366  {
367  if( this->Container != NULL ) {
368  const Real ContainerXSize = this->Container->GetActualSize().X;
369  if( ContainerXSize > 0 ) {
370  Real Ret = MathTools::Ceil( this->Container->GetWorkAreaSize().X / ContainerXSize );
371  return ( Ret > 1 ? Ret : 1 );
372  }
373  }
374  return 1;
375  }
376 
378  {
379  if( this->Container != NULL ) {
380  const Real ContainerYSize = this->Container->GetActualSize().Y;
381  if( ContainerYSize > 0 ) {
382  Real Ret = MathTools::Ceil( this->Container->GetWorkAreaSize().Y / ContainerYSize );
383  return ( Ret > 1 ? Ret : 1 );
384  }
385  }
386  return 1;
387  }
388 
390  {
391  if( this->OrderPriority == UI::OP_Horizontal_Vertical ) {
392  return MathTools::Ceil( MathTools::Mod( this->SpinValue , this->GetMaxYPages() ) + 1 );
393  }else if( this->OrderPriority == OP_Vertical_Horizontal ) {
394  return MathTools::Ceil( this->SpinValue / this->GetMaxXPages() );
395  }
396  return 1;
397  }
398 
400  {
401  if( this->OrderPriority == UI::OP_Horizontal_Vertical ) {
402  return MathTools::Ceil( this->SpinValue / this->GetMaxYPages() );
403  }else if( this->OrderPriority == OP_Vertical_Horizontal ) {
404  return MathTools::Ceil( MathTools::Mod( this->SpinValue , this->GetMaxXPages() ) + 1 );
405  }
406  return 1;
407  }
408 
409  ///////////////////////////////////////////////////////////////////////////////
410  // Serialization
411 
413  {
414  this->Widget::ProtoSerializeProperties(SelfRoot);
415 
416  XML::Node PropertiesNode = SelfRoot.AppendChild( Spinner::GetSerializableName() + "Properties" );
417 
418  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
419  PropertiesNode.AppendAttribute("SpinValue").SetValue( this->GetSpinValue() ) &&
420  PropertiesNode.AppendAttribute("IncrementValue").SetValue( this->GetIncrementValue() ) &&
421  PropertiesNode.AppendAttribute("MinValue").SetValue( this->GetMinSpinValue() ) &&
422  PropertiesNode.AppendAttribute("MaxValue").SetValue( this->GetMaxSpinValue() ) )
423  {
424  return;
425  }else{
426  SerializeError("Create XML Attribute Values",Spinner::GetSerializableName() + "Properties",true);
427  }
428  }
429 
431  {
432  this->Widget::ProtoDeSerializeProperties(SelfRoot);
433 
434  XML::Attribute CurrAttrib;
435  XML::Node PropertiesNode = SelfRoot.GetChild( Spinner::GetSerializableName() + "Properties" );
436 
437  if( !PropertiesNode.Empty() ) {
438  if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
439  CurrAttrib = PropertiesNode.GetAttribute("SpinValue");
440  if( !CurrAttrib.Empty() )
441  this->SetSpinValue( CurrAttrib.AsReal() );
442 
443  CurrAttrib = PropertiesNode.GetAttribute("IncrementValue");
444  if( !CurrAttrib.Empty() )
445  this->SetIncrementValue( CurrAttrib.AsReal() );
446 
447  CurrAttrib = PropertiesNode.GetAttribute("MinValue");
448  if( !CurrAttrib.Empty() )
449  this->SetMinSpinValue( CurrAttrib.AsReal() );
450 
451  CurrAttrib = PropertiesNode.GetAttribute("MaxValue");
452  if( !CurrAttrib.Empty() )
453  this->SetMaxSpinValue( CurrAttrib.AsReal() );
454  }else{
455  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (Spinner::GetSerializableName() + "Properties") + ": Not Version 1.");
456  }
457  }else{
458  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,Spinner::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
459  }
460  }
461 
463  { return Spinner::TypeName; }
464 
465  ///////////////////////////////////////////////////////////////////////////////
466  // Internal Event Methods
467 
468  void Spinner::_OnSpinValueChanged(const Real OldValue, const Real NewValue)
469  {
470  if( this->Container != NULL ) {
472  }
473 
474  SpinnerValueChangedArgumentsPtr Args( new SpinnerValueChangedArguments(Spinner::EventSpinValueChanged,this->Name,OldValue,NewValue) );
475  this->FireEvent(Args);
476  }
477 
478  ///////////////////////////////////////////////////////////////////////////////
479  // Internal Methods
480 
482  {
483  WidgetEventArgumentsPtr WidArgs = CountedPtrCast<WidgetEventArguments>(Args);
484  Widget* EventWidget = this->ParentScreen->GetWidget(WidArgs->WidgetName);
485  if( EventWidget == NULL )
486  return;
487 
488  if( EventWidget == this->ValueDisplay ) {
489  // Squalch events to prevent an infinite loop.
490  Boole OldMute = this->ValueDisplay->GetMuteEvents();
491  this->ValueDisplay->SetMuteEvents(true);
492  String ValueText = this->ValueDisplay->GetText();
493  Real NewValue = StringTools::ConvertToReal(ValueText);
494  this->SetSpinValue(NewValue);
495  if( this->SpinValue != NewValue ) {
497  }
498  this->ValueDisplay->SetMuteEvents(OldMute);
499  }else if( EventWidget == this->IncrementSpin ) {
500  Real Temp = this->SpinValue + this->IncrementValue;
501  this->SetSpinValue(Temp);
502  }else if( EventWidget == this->DecrementSpin ) {
503  Real Temp = this->SpinValue - this->IncrementValue;
504  this->SetSpinValue(Temp);
505  }
506  }
507 
509  {
510  if( this->Container != NULL ) {
511  const Vector2 View = this->Container->GetActualSize();
512  const Vector2 Work = this->Container->GetWorkAreaSize();
513 
514  if( View.X > 0 && View.Y > 0 ) {
516  if( Config == PagedContainer::PM_Single_X ) {
517  Real MaxPages = MathTools::Ceil( Work.X / View.X );
518  this->SetSpinValueLimits(1,MaxPages);
519  }else if( Config == PagedContainer::PM_Single_Y ) {
520  Real MaxPages = MathTools::Ceil( Work.Y / View.Y );
521  this->SetSpinValueLimits(1,MaxPages);
522  }else if( Config == PagedContainer::PM_Single_XY ) {
523  Real MaxXPages = MathTools::Ceil( Work.X / View.X );
524  Real MaxYPages = MathTools::Ceil( Work.Y / View.Y );
525  this->SetSpinValueLimits(1,MaxXPages * MaxYPages);
526  }
527 
528  this->SetSpinValue(this->SpinValue);
529  }
530  }
531  }
532 
533  ///////////////////////////////////////////////////////////////////////////////
534  // SpinnerFactory Methods
535 
537  { return Spinner::TypeName; }
538 
539  Spinner* SpinnerFactory::CreateSpinner(const String& RendName, const SpinnerStyle SpinStyle, FontData* EditFont, Screen* Parent)
540  { return new Spinner(RendName,SpinStyle,EditFont,Parent); }
541 
542  Spinner* SpinnerFactory::CreateSpinner(const String& RendName, const SpinnerStyle SpinStyle, const String& EditFontName, Screen* Parent)
543  { return new Spinner(RendName,SpinStyle,EditFontName,Parent); }
544 
545  Spinner* SpinnerFactory::CreateSpinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, FontData* EditFont, Screen* Parent)
546  { return new Spinner(RendName,RendRect,SpinStyle,EditFont,Parent); }
547 
548  Spinner* SpinnerFactory::CreateSpinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, const String& EditFontName, Screen* Parent)
549  { return new Spinner(RendName,RendRect,SpinStyle,EditFontName,Parent); }
550 
552  { return new Spinner(XMLNode,Parent); }
553 
555  { return new Spinner(Parent); }
556 
557  Widget* SpinnerFactory::CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent)
558  {
559  String EditFontName;
560  UI::SpinnerStyle SpinStyle = UI::Spn_Together_Right;
561 
562  NameValuePairMap::const_iterator ParamIt;
563  ParamIt = Params.find("EditFontName");
564  if( ParamIt != Params.end() )
565  EditFontName = (*ParamIt).second;
566 
567  ParamIt = Params.find("SpinStyle");
568  if( ParamIt != Params.end() )
569  SpinStyle = static_cast<UI::SpinnerStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
570 
571  return this->CreateSpinner(RendName,SpinStyle,EditFontName,Parent);
572  }
573 
574  Widget* SpinnerFactory::CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent)
575  {
576  String EditFontName;
577  UI::SpinnerStyle SpinStyle = UI::Spn_Together_Right;
578 
579  NameValuePairMap::const_iterator ParamIt;
580  ParamIt = Params.find("EditFontName");
581  if( ParamIt != Params.end() )
582  EditFontName = (*ParamIt).second;
583 
584  ParamIt = Params.find("SpinStyle");
585  if( ParamIt != Params.end() )
586  SpinStyle = static_cast<UI::SpinnerStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
587 
588  return this->CreateSpinner(RendName,RendRect,SpinStyle,EditFontName,Parent);
589  }
590 
592  { return this->CreateSpinner(XMLNode,Parent); }
593 
595  { delete static_cast<Spinner*>( ToBeDestroyed ); }
596  }//UI
597 }//Mezzanine
598 
599 #endif
int32_t Int32
An 32-bit integer.
Definition: datatypes.h:124
Button * DecrementSpin
A pointer to the button that will decrement the spin value.
Definition: spinner.h:143
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
Definition: spinner.cpp:554
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.
Definition: font.h:55
virtual void SetSpinValueLimits(const Real Min, const Real Max)
Sets the minimum and maximum limits for the value this Spinner can have.
Definition: spinner.cpp:222
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
UInt32 ConvertToUInt32(const String &ToConvert)
Converts a string into a UInt32.
Definition: stringtool.cpp:456
Spinner(Screen *Parent)
Blank constructor.
Definition: spinner.cpp:81
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
static const String EventDeactivated
Event name for when this activatable widget is deactivated.
Definition: button.h:97
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.
Definition: spinner.h:136
UI::OrderingPriority OrderPriority
Which axis is primary when determining the current X or Y page.
Definition: spinner.h:161
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.
Definition: spinner.cpp:228
String ConvertToString(const Vector2 &ToConvert)
Converts a Vector2 into a string.
Definition: stringtool.cpp:291
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.
Definition: spinner.cpp:594
Thrown when the requested identity could not be found.
Definition: exception.h:94
virtual EditBox * CreateEditBox(const String &RendName, const RenderLayerType EditLayerType, FontData *EditFont)
Creates a EditBox.
Definition: screen.cpp:686
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
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...
Definition: spinner.cpp:246
A simple reference counting pointer.
Definition: countedptr.h:70
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: widget.cpp:278
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...
Definition: exception.h:112
Value representing a SingleLineTextLayer.
virtual Real GetCurrentYPage() const
Gets the current page position on the Y axis.
Definition: spinner.cpp:399
virtual const String & GetTypeName() const
Gets the type of widget this is.
Definition: spinner.cpp:197
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.
Definition: editbox.cpp:271
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.
Definition: screen.cpp:889
virtual String GetText() const
Gets the text in the edit layer of this EditBox.
Definition: editbox.cpp:280
virtual void SetInputFilter(FilterCallback *Callback)
Sets the filter that will be used by this EditBox to determine if an input will be consumed...
Definition: editbox.cpp:306
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.
Definition: spinner.cpp:539
This is a simple widget for a numeric variable in a box.
Definition: spinner.h:130
PagedContainer * Container
A pointer to the PagedContainer this scrollbar is providing page data for.
Definition: pageprovider.h:60
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: spinner.cpp:412
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
Definition: spinner.cpp:536
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
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.
Definition: spinner.cpp:167
EditBox * ValueDisplay
A pointer to the EditBox that will display the spin value.
Definition: spinner.h:146
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
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.
Definition: vector2.h:69
virtual Button * GetDecrement() const
Gets the decrement Button of this Spinner.
Definition: spinner.cpp:356
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
Definition: spinner.cpp:481
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a widget.
Definition: screen.cpp:585
virtual Real GetMaxYPages() const
Gets the maximum number of pages supported on the Y axis.
Definition: spinner.cpp:377
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Real X
Coordinate on the X vector.
Definition: vector2.h:67
virtual void SetMaxSpinValue(const Real Value)
Sets the maximum limit for the value this spinner can have.
Definition: spinner.cpp:231
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.
Definition: vector2.h:63
bool Empty() const
Is this storing anything at all?
This is the base class for all widgets.
Definition: widget.h:126
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.
Definition: spinner.cpp:365
Real MinValue
The minimum value allowed to be expressed by this Spinner.
Definition: spinner.h:155
Anchors to the left side of the quad.
Button * IncrementSpin
A pointer to the button that will increment the spin value.
Definition: spinner.h:140
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.
Definition: spinner.cpp:225
virtual void _OnSpinValueChanged(const Real OldValue, const Real NewValue)
Self logic to be executed when this Spinner has it's spin value updated.
Definition: spinner.cpp:468
This is the EventArguments class for when the spinvalue of a Spinner is updated.
Definition: spinner.h:58
virtual void SetSpinValue(Real Value)
Sets the value of this Spinner.
Definition: spinner.cpp:203
virtual void ClampToLimits(Real &Value)
Ensures the provided value is within the configured limits.
Definition: spinner.cpp:186
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.
Definition: spinner.cpp:359
virtual ~Spinner()
Class destructor.
Definition: spinner.cpp:153
String Name
The unique name of this Renderable.
Definition: renderable.h:81
virtual void _NotifyContainerUpdated()
Notifies this provider that the container it is providing page data to has been updated.
Definition: spinner.cpp:508
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...
Definition: spinner.cpp:216
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Definition: spinner.cpp:462
This is the base class for interpretting widget values to page positions.
Definition: pageprovider.h:55
virtual Widget * GetWidget(const String &Name)
Gets a widget in this screen by name.
Definition: screen.cpp:573
virtual Button * CreateButton(const String &RendName)
Creates a Button.
Definition: screen.cpp:630
virtual Real GetSpinValue() const
Gets the value of this Spinner.
Definition: spinner.cpp:213
static const String EventTextUpdated
Event name for when the text in this widget has been updated.
Definition: editbox.h:66
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: spinner.cpp:430
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
virtual Real GetCurrentXPage() const
Gets the current page position on the X axis.
Definition: spinner.cpp:389
Real SpinValue
The current spin value of this Spinner.
Definition: spinner.h:149
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.
Definition: unifieddim.h:306
This class is a helper class, specifically for use as a button.
Definition: button.h:66
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.
Definition: spinner.cpp:353
virtual UI::OrderingPriority GetOrderingPriority() const
Gets which axis will be considered first when converting the current value to an X or Y page...
Definition: spinner.cpp:240
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.
Definition: spinner.h:158
virtual Real GetMaxSpinValue() const
Gets the maximum limit for the value this spinner can have.
Definition: spinner.cpp:234
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...
Definition: spinner.cpp:237
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: widget.cpp:337
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. ...
Definition: spinner.h:152
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".
Definition: spinner.h:134
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...
Definition: datatypes.h:209
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
Anchors to the top side of the quad.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
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...
Definition: spinner.cpp:219
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Real ConvertToReal(const String &ToConvert)
Converts a string into a Real.
Definition: stringtool.cpp:392
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.
Definition: renderable.h:72
Widget for handling the input and manipulation of text.
Definition: editbox.h:60