Spinning Topp Logo BlackTopp Studios
inc
listbox.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 _uilistbox_cpp
41 #define _uilistbox_cpp
42 
43 #include "UI/listbox.h"
44 #include "UI/uimanager.h"
45 #include "UI/screen.h"
46 #include "UI/verticalscrollbar.h"
47 #include "UI/verticalcontainer.h"
48 #include "UI/singlelinetextlayer.h"
49 #include "UI/multilinetextlayer.h"
50 #include "UI/renderlayergroup.h"
51 #include "UI/layoutstrategy.h"
52 
53 #include "Input/inputmanager.h"
54 #include "Input/metacode.h"
55 #include "Input/mouse.h"
56 
57 #include "entresol.h"
58 #include "serialization.h"
59 #include "exception.h"
60 
61 #include <cmath>
62 
63 namespace Mezzanine
64 {
65  namespace UI
66  {
67  ///////////////////////////////////////////////////////////////////////////////
68  // ListBox Static Members
69 
70  const String ListBox::TypeName = "ListBox";
71 
72  ///////////////////////////////////////////////////////////////////////////////
73  // ListBox Methods
74 
76  Widget(Parent),
77  ListItemFont(NULL),
78  ListItemCharScaling(0.0),
79  ListItemCharScalingMode(TextLayer::SM_NoAutoScaling),
80  Ordering(ListBox::LIO_BottomInsert)
81  { }
82 
83  ListBox::ListBox(const String& RendName, const UI::ScrollbarStyle& Style, Screen* Parent) :
84  Widget(RendName,Parent),
85  ListItemFont(NULL),
86  ListItemCharScaling(0.0),
87  ListItemCharScalingMode(TextLayer::SM_NoAutoScaling),
88  Ordering(ListBox::LIO_BottomInsert)
89  { this->ConstructListBox(Style); }
90 
91  ListBox::ListBox(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle& Style, Screen* Parent) :
92  Widget(RendName,RendRect,Parent),
93  ListItemFont(NULL),
94  ListItemCharScaling(0.0),
95  ListItemCharScalingMode(TextLayer::SM_NoAutoScaling),
96  Ordering(ListBox::LIO_BottomInsert)
97  { this->ConstructListBox(Style); }
98 
99  ListBox::ListBox(const XML::Node& XMLNode, Screen* Parent) :
100  Widget(Parent),
101  ListItemFont(NULL),
102  ListItemCharScaling(0.0),
103  ListItemCharScalingMode(TextLayer::SM_NoAutoScaling),
104  Ordering(ListBox::LIO_BottomInsert)
105  { this->ProtoDeSerialize(XMLNode); }
106 
108  {
109  this->ListContainer->UnbindProvider( this->ListScroll );
110  this->RemoveChild( this->ListScroll );
111  this->ParentScreen->DestroyWidget( this->ListScroll );
112  this->RemoveChild( this->ListContainer );
113  this->ParentScreen->DestroyWidget( this->ListContainer );
114  }
115 
117  {
118  if( Code.GetCode() == Input::MOUSEWHEELVERTICAL && this->ActDims.IsInside( this->ParentScreen->GetMouseHitPosition() ) ) {
119  return this->ListScroll->_MouseWheelScroll( Code.GetMetaValue() );
120  }
121  return false;
122  }
123 
125  {
126  this->ListScroll = this->ParentScreen->CreateVerticalScrollbar(this->Name+".Scroll",Style);
127  this->ListScroll->SetAutoHide(false);
128  this->AddChild(this->ListScroll,1);
129  this->ListContainer = this->ParentScreen->CreateVerticalContainer(this->Name+".Container");
130  this->ListContainer->SetYProvider( this->ListScroll );
131  this->AddChild(this->ListContainer,2);
132 
135  this->ListScroll->SetUnifiedSize(UnifiedVec2(0.08,1.0,0.0,0.0));
136  this->ListContainer->SetUnifiedSize(UnifiedVec2(0.92,1.0,0.0,0.0));
137 
138  SizingInfo ListItemSizing(UI::SR_Unified_Dims,UI::SR_Size_For_Text,UnifiedVec2(1.0,0.0,0.0,0.0));
140  }
141 
143  {
144  UInt16 ListItemZOrder = 0;
145  if( this->GetNumListItems() > 0 ) {
146  if( this->Ordering == ListBox::LIO_BottomInsert ) {
147  ListItemZOrder = ( this->ListContainer->GetHighestChildZOrder() + 1 );
148  }else if( this->Ordering == ListBox::LIO_TopInsert ) {
149  ListItemZOrder = ( this->ListContainer->GetLowestChildZOrder() - 1 );
150  }else{
151  ListItemZOrder = std::numeric_limits<UInt16>::max() / 2;
152  }
153  }else{
154  ListItemZOrder = std::numeric_limits<UInt16>::max() / 2;
155  }
156 
157  ListItem* NewItem = this->ParentScreen->CreateWidget(ItemName);
158  this->ListContainer->AddChild(NewItem,ListItemZOrder);
159  return NewItem;
160  }
161 
162  ///////////////////////////////////////////////////////////////////////////////
163  // Utility Methods
164 
165  void ListBox::SetListItemSizing(const SizingInfo& ForcedSize, const Whole Enforcement)
166  { this->ListContainer->SetChildSizing(ForcedSize,Enforcement); }
167 
168  void ListBox::SetListItemSize(const SizingInfo& ForcedSize)
169  { this->ListContainer->SetChildSize(ForcedSize); }
170 
172  { return this->ListContainer->GetChildSize(); }
173 
175  { this->ListContainer->SetChildSizeEnforcement(Enforcement); }
176 
178  { return this->ListContainer->GetChildSizeEnforcement(); }
179 
180  void ListBox::SetScrollbarWidth(const UnifiedDim& ScrollWidth)
181  {
182  this->ListScroll->SetUnifiedSize( UnifiedVec2(ScrollWidth,this->ListScroll->GetUnifiedSize().Y) );
183  this->ListContainer->SetUnifiedSize( UnifiedVec2(UnifiedDim(1.0,0.0) - ScrollWidth,this->ListContainer->GetUnifiedSize().Y) );
184  /// @todo Update for Autohide.
185  }
186 
188  {
189  return this->ListScroll->GetUnifiedSize().X;
190  }
191 
192  void ListBox::UpdateDimensions(const Rect& OldSelfRect, const Rect& NewSelfRect)
193  {
194  /// @todo Update for Autohide.
195  this->QuadRenderable::UpdateDimensions(OldSelfRect,NewSelfRect);
196  }
197 
199  {
200  return ListBox::TypeName;
201  }
202 
203  ///////////////////////////////////////////////////////////////////////////////
204  // ListBox Properties
205 
207  { this->ListItemFont = Font; }
208 
209  void ListBox::SetListItemFont(const String& FontName)
210  { this->ListItemFont = this->ParentScreen->GetFont(FontName,this->ParentScreen->GetPrimaryAtlas()); }
211 
213  { return this->ListItemFont; }
214 
216  {
217  this->ListItemCharScalingMode = Mode;
218  this->ListItemCharScaling = Scalar;
219  }
220 
222  { return this->ListItemCharScalingMode; }
223 
225  { return this->ListItemCharScaling; }
226 
228  { this->Ordering = Order; }
229 
231  { return this->Ordering; }
232 
233  ///////////////////////////////////////////////////////////////////////////////
234  // ListBox Configuration
235 
237  {
238  if( this->ListItemFont == NULL ) {
239  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Font is not set when creating ListItem \"" + ItemName + "\" in ListBox \"" + this->Name + "\".");
240  }
241  ListItem* NewItem = this->CreateListItem(ItemName);
242  SingleLineTextLayer* ItemLayer = NewItem->CreateSingleLineTextLayer();
243  ItemLayer->SetDefaultFont( this->ListItemFont );
245  ItemLayer->SetText( Text );
246  ItemLayer->SetTextLineHorizontalAlignment(UI::LA_Center);
247  ItemLayer->SetTextLineVerticalAlignment(UI::LA_Center);
248 
249  NewItem->AddLayerToGroup(ItemLayer,5,Widget::WG_Normal);
250  NewItem->AddLayerToGroup(ItemLayer,5,Widget::WG_Hovered);
251  return NewItem;
252  }
253 
255  {
256  if( this->ListItemFont == NULL ) {
257  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Font is not set when creating ListItem \"" + ItemName + "\" in ListBox \"" + this->Name + "\".");
258  }
259  ListItem* NewItem = this->CreateListItem(ItemName);
260  MultiLineTextLayer* ItemLayer = NewItem->CreateMultiLineTextLayer();
261  ItemLayer->SetDefaultFont( this->ListItemFont );
263  ItemLayer->SetText( Text );
264  ItemLayer->SetTextLineHorizontalAlignment(UI::LA_Center);
265  ItemLayer->SetTextLineVerticalAlignment(UI::LA_Center);
266 
267  NewItem->AddLayerToGroup(ItemLayer,5,Widget::WG_Normal);
268  NewItem->AddLayerToGroup(ItemLayer,5,Widget::WG_Hovered);
269  return NewItem;
270  }
271 
273  { return this->ListContainer->GetChild(Name); }
274 
276  { return this->ListContainer->GetNumChildren(); }
277 
278  void ListBox::DestroyListItem(ListItem* ToBeDestroyed)
279  { this->ListContainer->DestroyChild(ToBeDestroyed); }
280 
282  { this->ListContainer->DestroyAllChildren(); }
283 
285  { return this->ListScroll; }
286 
288  { return this->ListContainer; }
289 
291  { return this->ListContainer->GetLastSelectedChild(); }
292 
293  ///////////////////////////////////////////////////////////////////////////////
294  // Serialization
295 
297  {
298  this->Widget::ProtoSerializeProperties(SelfRoot);
299 
300  XML::Node PropertiesNode = SelfRoot.AppendChild( ListBox::GetSerializableName() + "Properties" );
301 
302  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
303  PropertiesNode.AppendAttribute("ListItemFont").SetValue( this->ListItemFont->GetName() ) &&
304  PropertiesNode.AppendAttribute("ListItemCharScalingMode").SetValue( this->GetListItemTextScalingMode() ) &&
305  PropertiesNode.AppendAttribute("ListItemCharScaling").SetValue( this->GetListItemTextScalar() ) &&
306  PropertiesNode.AppendAttribute("Ordering").SetValue( this->GetListItemOrdering() ) )
307  {
308  return;
309  }else{
310  SerializeError("Create XML Attribute Values",ListBox::GetSerializableName() + "Properties",true);
311  }
312  }
313 
315  {
317  }
318 
320  {
321  this->Widget::ProtoDeSerializeProperties(SelfRoot);
322 
323  XML::Attribute CurrAttrib;
324  XML::Node PropertiesNode = SelfRoot.GetChild( ListBox::GetSerializableName() + "Properties" );
325 
326  if( !PropertiesNode.Empty() ) {
327  if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
328  CurrAttrib = PropertiesNode.GetAttribute("ListItemFont");
329  if( !CurrAttrib.Empty() )
330  this->SetListItemFont( CurrAttrib.AsString() );
331 
332  CurrAttrib = PropertiesNode.GetAttribute("ListItemCharScalingMode");
333  if( !CurrAttrib.Empty() )
334  this->ListItemCharScalingMode = static_cast<TextLayer::ScalingMode>( CurrAttrib.AsUint() );
335 
336  CurrAttrib = PropertiesNode.GetAttribute("ListItemCharScaling");
337  if( !CurrAttrib.Empty() )
338  this->ListItemCharScaling = CurrAttrib.AsReal();
339 
340  CurrAttrib = PropertiesNode.GetAttribute("Ordering");
341  if( !CurrAttrib.Empty() )
342  this->SetListItemOrdering( static_cast<ListBox::ListItemOrdering>( CurrAttrib.AsWhole() ) );
343  }else{
344  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (ListBox::GetSerializableName() + "Properties") + ": Not Version 1.");
345  }
346  }else{
347  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,ListBox::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
348  }
349  }
350 
352  {
354 
355  // Assign the ListScroll
356  this->ListScroll = static_cast<VerticalScrollbar*>( this->GetChild(this->Name+".Scroll") );
357  if( this->ListScroll == NULL ) {
358  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"List scrollbar not found after ListBox deserialization.");
359  }
360 
361  // Assign the ListContainer
362  this->ListContainer = static_cast<VerticalContainer*>( this->GetChild(this->Name+".Container") );
363  if( this->ListContainer == NULL ) {
364  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"List container not found after ListBox deserialization.");
365  }
366  }
367 
369  {
370  return ListBox::TypeName;
371  }
372 
373  ///////////////////////////////////////////////////////////////////////////////
374  // Internal Event Methods
375 
376  ///////////////////////////////////////////////////////////////////////////////
377  // Internal Methods
378 
379 
380 
381  ///////////////////////////////////////////////////////////////////////////////
382  // ListBoxFactory Methods
383 
385  { return ListBox::TypeName; }
386 
387  ListBox* ListBoxFactory::CreateListBox(const String& RendName, const UI::ScrollbarStyle& Style, Screen* Parent)
388  {
389  ListBox* Ret = new ListBox(RendName,Style,Parent);
390  Ret->_SetLayoutStrat( new LayoutStrategy() );
391  return Ret;
392  }
393 
394  ListBox* ListBoxFactory::CreateListBox(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle& Style, Screen* Parent)
395  {
396  ListBox* Ret = new ListBox(RendName,RendRect,Style,Parent);
397  Ret->_SetLayoutStrat( new LayoutStrategy() );
398  return Ret;
399  }
400 
402  {
403  ListBox* Ret = new ListBox(XMLNode,Parent);
404  Ret->_SetLayoutStrat( new LayoutStrategy() );
405  return Ret;
406  }
407 
409  {
410  ListBox* Ret = new ListBox(Parent);
411  Ret->_SetLayoutStrat( new LayoutStrategy() );
412  return Ret;
413  }
414 
415  Widget* ListBoxFactory::CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent)
416  {
417  UI::ScrollbarStyle Style = UI::SB_NoButtons;
418 
419  NameValuePairMap::const_iterator ParamIt;
420  ParamIt = Params.find("ScrollbarStyle");
421  if( ParamIt != Params.end() )
422  Style = static_cast<UI::ScrollbarStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
423 
424  return this->CreateListBox(RendName,Style,Parent);
425  }
426 
427  Widget* ListBoxFactory::CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent)
428  {
429  UI::ScrollbarStyle Style = UI::SB_NoButtons;
430 
431  NameValuePairMap::const_iterator ParamIt;
432  ParamIt = Params.find("ScrollbarStyle");
433  if( ParamIt != Params.end() )
434  Style = static_cast<UI::ScrollbarStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
435 
436  return this->CreateListBox(RendName,RendRect,Style,Parent);
437  }
438 
440  { return this->CreateListBox(XMLNode,Parent); }
441 
443  { delete static_cast<ListBox*>( ToBeDestroyed ); }
444  }//UI
445 }//Mezzanine
446 
447 #endif
virtual FontData * GetListItemFont() const
Gets the font that will be used by ListItems in this ListBox.
Definition: listbox.cpp:212
This is a render layer specializing in single-line text.
ListItemOrdering
This enum is used to describe how new ListItems are inserted into the list.
Definition: listbox.h:70
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
The preset size for children of this container will only be applied when they are added to this conta...
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
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
virtual void SetTextLineVerticalAlignment(const UI::LinearAlignment Align)
Sets the alignment used to determine the start position of the textlines in this layer.
Definition: textlayer.cpp:732
FontData * ListItemFont
Stores the default font that will be used by all ListItems generated by this ListBox.
Definition: listbox.h:81
This is a base class for the algorithms used by QuadRenderables to determine how they should update t...
virtual void AddChild(Widget *Child)
Adds a Widget to this as a child of this quad.
virtual Whole GetListItemSizeEnforcement() const
Gets when the set list item sizing will be applied to any given list item.
Definition: listbox.cpp:177
UInt32 ConvertToUInt32(const String &ToConvert)
Converts a string into a UInt32.
Definition: stringtool.cpp:456
UnifiedDim X
The dimension on the X plane.
Definition: unifieddim.h:313
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual void SetAutoHide(Boole AutoHide)
Sets whether or not this scrollbar will hide when it's set page container has less than one page to d...
Definition: scrollbar.cpp:162
virtual void SetChildSizing(const SizingInfo &ForcedSize, const Whole Enforcement)
Sets both the size and enforcement rules for forced child sizing in this container.
virtual ListBox * CreateListBox(const String &RendName, const UI::ScrollbarStyle &Style, Screen *Parent)
Creates a new ListBox.
Definition: listbox.cpp:387
virtual VerticalContainer * CreateVerticalContainer(const String &RendName)
Creates a widget container aligned on the Y axis.
Definition: screen.cpp:840
virtual void SetListItemSizeEnforcement(const Whole Enforcement)
Sets when the set list item sizing will be applied to any given list item.
Definition: listbox.cpp:174
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Definition: listbox.cpp:368
static const String TypeName
String containing the type name for this class: "ListBox".
Definition: listbox.h:77
Real ListItemCharScaling
The amount of auto-scaling to be applied to all created list items.
Definition: listbox.h:90
virtual void SetAutoTextScale(const TextLayer::ScalingMode Mode, const Real Scalar)
Sets the mode and scaler of auto-scaling applied to the text generated by this textlayer.
Definition: textlayer.cpp:466
Thrown when the requested identity could not be found.
Definition: exception.h:94
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
This is a helper class designed to describe the behaviors of a quad when it needs to be resized...
Definition: sizinginfo.h:56
virtual void SetHorizontalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the X axis...
virtual void DestroyListItem(ListItem *ToBeDestroyed)
Destroys a ListItem owned by this ListBox.
Definition: listbox.cpp:278
virtual UnifiedVec2 GetUnifiedSize() const
Gets the size of this QuadRenderable as a Unified Vector2.
virtual Real GetListItemTextScalar() const
Gets the relative scalar being used to automatically scale text in ListItems created by this ListBox...
Definition: listbox.cpp:224
This is a render layer specializing in multi-line text.
virtual void DestroyAllListItems()
Destroys all the ListItems currently owned by this ListBox.
Definition: listbox.cpp:281
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: widget.cpp:278
virtual ListItem * CreateSingleLineListItem(const String &ItemName, const String &Text)
Convenience method that will create and add a ListItem with a single line text layer to this ListBox...
Definition: listbox.cpp:236
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
virtual ListBox::ListItemOrdering GetListItemOrdering() const
Gets how new entries will be inserted into the list.
Definition: listbox.cpp:230
virtual void SetListItemSizing(const SizingInfo &ForcedSize, const Whole Enforcement)
Sets both the size and enforcement rules for forced list item sizing in this container.
Definition: listbox.cpp:165
Sizes the container so all text in layers will be visible. Only valid for Vertical sizing(exception w...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
virtual void SetUnifiedSize(const UnifiedVec2 &Size)
Sets the size this QuadRenderable will have within it's parent.
FontData * GetFont(const String &FontName, const String &Atlas) const
Gets the specified FontData from an Atlas.
Definition: screen.cpp:889
This class represents a box shaped area on the screen.
Definition: rect.h:55
virtual const UnifiedDim & GetScrollbarWidth() const
Gets the Unified width of the child scrollbar in this ListBox.
Definition: listbox.cpp:187
ScrollbarStyle
Used by the scrollbar class to determine what styling should be used for the scrollbar.
virtual VerticalContainer * GetListContainer() const
Gets the ListItem container within this widget.
Definition: listbox.cpp:287
bool Empty() const
Is this storing anything at all?
virtual void SetListItemOrdering(ListBox::ListItemOrdering Order)
Sets how new entries will be inserted into the list.
Definition: listbox.cpp:227
This implements the exception hiearchy for Mezzanine.
virtual void SetYProvider(PageProvider *YProv)
Sets the PageProvider for the Y axis.
virtual void DestroyAllChildren()
Destroys all child Widgets currently inside this QuadRenderable.
virtual void SetListItemSize(const SizingInfo &ForcedSize)
Sets the size to be given to children processed by this container if forced sizing is enabled...
Definition: listbox.cpp:168
virtual Widget * GetChild(const UInt16 Zorder) const
Gets a child by it's ZOrder.
Int32 GetMetaValue() const
This Returns the MetaValue.
Definition: metacode.cpp:250
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.
Definition: datatypes.h:141
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual Whole GetNumListItems() const
Gets the number of ListItems in this ListBox.
Definition: listbox.cpp:275
virtual ListItem * CreateMultiLineListItem(const String &ItemName, const String &Text)
Convenience method that will create and add a ListItem with a multi-line text layer to this ListBox...
Definition: listbox.cpp:254
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
VerticalContainer * ListContainer
A pointer to the vertical container storing all the list items.
Definition: listbox.h:87
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
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.
ScalingMode
An enum used to describe how the text generated by this layer will be automatically scaled...
Definition: textlayer.h:91
ListItemOrdering Ordering
Stores how new entries will be inserted with other elements in this ListBox.
Definition: listbox.h:96
virtual const SizingInfo & GetChildSize() const
Gets the size to be given to children processed by this container if forced sizing is enabled...
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a widget.
Definition: screen.cpp:585
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
Definition: listbox.cpp:408
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
virtual UInt16 GetHighestChildZOrder() const
Gets the highest ZOrder among the children of this QuadRenderable.
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. ...
virtual void ConstructListBox(const UI::ScrollbarStyle &Style)
Convenience method for the construction of a ListBox.
Definition: listbox.cpp:124
const String & GetName() const
Gets the name of this font.
Definition: font.cpp:91
bool Empty() const
Is this storing anything at all?
This is the base class for all widgets.
Definition: widget.h:126
virtual const String & GetTypeName() const
Gets the type of widget this is.
Definition: listbox.cpp:198
virtual ListItem * GetLastSelectedListItem() const
Gets the last ListItem that was selected/focused.
Definition: listbox.cpp:290
virtual void SetScrollbarWidth(const UnifiedDim &ScrollWidth)
Sets the Unified width of the child scrollbar in this ListBox.
Definition: listbox.cpp:180
virtual void UnbindProvider(PageProvider *Prov)
Unbinds a provider being used by this container.
UnifiedDim Y
The dimension on the Y plane.
Definition: unifieddim.h:315
Anchors to the left side of the quad.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
virtual ListItem * CreateListItem(const String &ItemName)
Helper method that creates a basic ListItem with no TextLayers.
Definition: listbox.cpp:142
virtual Widget * GetLastSelectedChild() const
Gets a pointer to the last selected child widget in this container.
void AddLayerToGroup(RenderLayer *Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
Adds a RenderLayer to the specified group.
A layout container that aligns it's children along a common Y axis.
String Name
The unique name of this Renderable.
Definition: renderable.h:81
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
Definition: listbox.cpp:351
Thrown when the available information should have worked but failed for unknown reasons.
Definition: exception.h:113
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
Definition: listbox.cpp:314
Input::InputCode GetCode() const
This Returns the Inputcode.
Definition: metacode.cpp:244
virtual ~ListBox()
Class destructor.
Definition: listbox.cpp:107
virtual void SetChildSize(const SizingInfo &ForcedSize)
Sets the size to be given to children processed by this container if forced sizing is enabled...
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: listbox.cpp:319
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 SetChildSizeEnforcement(const Whole Enforcement)
Sets when the set child sizing will be applied to any given child.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
Definition: listbox.cpp:442
This Determines the kind of user input.
Definition: metacode.h:93
virtual const SizingInfo & GetListItemSize() const
Gets the size to be given to children processed by this container if forced sizing is enabled...
Definition: listbox.cpp:171
This class represents both the relative and absolute values that can be expressed for the values on o...
Definition: unifieddim.h:56
virtual void SetTextLineHorizontalAlignment(const UI::LinearAlignment Align)
Sets the horizontal alignment of every textline in this layer.
Definition: textlayer.cpp:726
virtual String GetPrimaryAtlas()
Gets the currently set primary atlas.
Definition: screen.cpp:880
TextLayer::ScalingMode ListItemCharScalingMode
The auto-scaling mode that is to be applied to all created list items.
Definition: listbox.h:93
virtual Boole _MouseWheelScroll(const Integer Direction)
Performs the operations for when the scroller is manipulated by the mouse wheel.
virtual Whole GetChildSizeEnforcement() const
Gets when the set child sizing will be applied to any given child.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
MultiLineTextLayer * CreateMultiLineTextLayer()
Creats a MultiLineTextLayer for this renderable.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
virtual Whole GetNumChildren() const
Gets the number of children in this QuadRenderable.
ListBox(Screen *Parent)
Blank constructor.
Definition: listbox.cpp:75
virtual const Vector2 & GetMouseHitPosition() const
Gets the mouse position from the last call to "FindHoveredQuad(const Vector2&).
Definition: screen.cpp:434
This class represents a point in 2D space using UnifiedDim's.
Definition: unifieddim.h:306
Anchors to the right side of the quad.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: listbox.cpp:296
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
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
New entries will be inserted at the bottom of the list.
Definition: listbox.h:73
This is a scrollbar class aligned on the Y axis.
Boole IsInside(const Vector2 &Point) const
Checks to see if a point in 2D space is inside this rect.
Definition: rect.h:207
virtual ListItem * GetListItem(const String &Name) const
Gets a ListItem in this ListBox by name.
Definition: listbox.cpp:272
virtual void UpdateDimensions()
Updates the dimensions of this QuadRenderable based on the transform of it's parent.
SingleLineTextLayer * CreateSingleLineTextLayer()
Creats a SingleLineTextLayer for this renderable.
virtual void SetDefaultFont(FontData *NewFont)
Sets the default font to be used with this layer.
Definition: textlayer.cpp:489
virtual TextLayer::ScalingMode GetListItemTextScalingMode() const
Gets the automatic scaling mode being used by ListItems created by this ListBox.
Definition: listbox.cpp:221
virtual void SetText(const String &Text)
Sets the text displayed within this layer.
Definition: textlayer.cpp:411
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
Definition: listbox.cpp:384
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
virtual VerticalScrollbar * CreateVerticalScrollbar(const String &RendName, const UI::ScrollbarStyle Style)
Creates a Scrollbar aligned on the Y axis.
Definition: screen.cpp:728
virtual void DestroyChild(Widget *ToBeDestroyed)
Destroys a child Widget currently inside this QuadRenderable.
New entries will be inserted at the top of the list.
Definition: listbox.h:72
VerticalScrollbar * ListScroll
A pointer to the vertical scrollbar responsible for the visible list items.
Definition: listbox.h:84
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
virtual VerticalScrollbar * GetListScroll() const
Gets the Scrollbar within this widget.
Definition: listbox.cpp:284
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
virtual Boole HandleInputImpl(const Input::MetaCode &Code)
Consumes input for this widget's use.
Definition: listbox.cpp:116
virtual void SetListItemTextScale(const TextLayer::ScalingMode Mode, const Real Scalar)
Sets the mode and scaler of auto-scaling applied to ListItems created by this ListBox.
Definition: listbox.cpp:215
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This is a base class for render layers that render text.
Definition: textlayer.h:64
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual void SetListItemFont(FontData *Font)
Sets the font that will be used by ListItems in this ListBox.
Definition: listbox.cpp:206
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual UInt16 GetLowestChildZOrder() const
Gets the lowest ZOrder among the children of this QuadRenderable.
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Definition: renderable.h:72
This is a widget for displaying a list of captions in a box.
Definition: listbox.h:63
virtual Widget * CreateWidget(const XML::Node &WidgetNode)
Creates a widget from an XML::Node.
Definition: screen.cpp:542