40 #ifndef _uilistbox_cpp
41 #define _uilistbox_cpp
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"
53 #include "Input/inputmanager.h"
54 #include "Input/metacode.h"
55 #include "Input/mouse.h"
78 ListItemCharScaling(0.0),
79 ListItemCharScalingMode(
TextLayer::SM_NoAutoScaling),
80 Ordering(
ListBox::LIO_BottomInsert)
86 ListItemCharScaling(0.0),
87 ListItemCharScalingMode(
TextLayer::SM_NoAutoScaling),
88 Ordering(
ListBox::LIO_BottomInsert)
92 Widget(RendName,RendRect,Parent),
94 ListItemCharScaling(0.0),
95 ListItemCharScalingMode(
TextLayer::SM_NoAutoScaling),
96 Ordering(
ListBox::LIO_BottomInsert)
102 ListItemCharScaling(0.0),
103 ListItemCharScalingMode(
TextLayer::SM_NoAutoScaling),
104 Ordering(
ListBox::LIO_BottomInsert)
144 UInt16 ListItemZOrder = 0;
151 ListItemZOrder = std::numeric_limits<UInt16>::max() / 2;
154 ListItemZOrder = std::numeric_limits<UInt16>::max() / 2;
326 if( !PropertiesNode.
Empty() ) {
328 CurrAttrib = PropertiesNode.
GetAttribute(
"ListItemFont");
329 if( !CurrAttrib.
Empty() )
332 CurrAttrib = PropertiesNode.
GetAttribute(
"ListItemCharScalingMode");
333 if( !CurrAttrib.
Empty() )
336 CurrAttrib = PropertiesNode.
GetAttribute(
"ListItemCharScaling");
337 if( !CurrAttrib.
Empty() )
341 if( !CurrAttrib.
Empty() )
419 NameValuePairMap::const_iterator ParamIt;
420 ParamIt = Params.find(
"ScrollbarStyle");
421 if( ParamIt != Params.end() )
431 NameValuePairMap::const_iterator ParamIt;
432 ParamIt = Params.find(
"ScrollbarStyle");
433 if( ParamIt != Params.end() )
443 {
delete static_cast<ListBox*
>( ToBeDestroyed ); }
virtual FontData * GetListItemFont() const
Gets the font that will be used by ListItems in this ListBox.
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.
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.
A light-weight handle for manipulating attributes in DOM tree.
virtual void SetTextLineVerticalAlignment(const UI::LinearAlignment Align)
Sets the alignment used to determine the start position of the textlines in this layer.
FontData * ListItemFont
Stores the default font that will be used by all ListItems generated by this ListBox.
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.
UnifiedDim X
The dimension on the X plane.
bool Boole
Generally acts a single bit, true or false.
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.
virtual VerticalContainer * CreateVerticalContainer(const String &RendName)
Creates a widget container aligned on the Y axis.
virtual void SetListItemSizeEnforcement(const Whole Enforcement)
Sets when the set list item sizing will be applied to any given list item.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
static const String TypeName
String containing the type name for this class: "ListBox".
Real ListItemCharScaling
The amount of auto-scaling to be applied to all created list items.
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.
Thrown when the requested identity could not be found.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
This is a helper class designed to describe the behaviors of a quad when it needs to be resized...
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.
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...
This is a render layer specializing in multi-line text.
virtual void DestroyAllListItems()
Destroys all the ListItems currently owned by this ListBox.
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...
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
virtual ListBox::ListItemOrdering GetListItemOrdering() const
Gets how new entries will be inserted into the list.
virtual void SetListItemSizing(const SizingInfo &ForcedSize, const Whole Enforcement)
Sets both the size and enforcement rules for forced list item sizing in this container.
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.
This class represents a box shaped area on the screen.
virtual const UnifiedDim & GetScrollbarWidth() const
Gets the Unified width of the child scrollbar in this ListBox.
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.
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.
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...
virtual Widget * GetChild(const UInt16 Zorder) const
Gets a child by it's ZOrder.
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.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual Whole GetNumListItems() const
Gets the number of ListItems in this ListBox.
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...
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.
VerticalContainer * ListContainer
A pointer to the vertical container storing all the list items.
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...
ListItemOrdering Ordering
Stores how new entries will be inserted with other elements in this ListBox.
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.
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
A light-weight handle for manipulating nodes in DOM tree.
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.
const String & GetName() const
Gets the name of this font.
bool Empty() const
Is this storing anything at all?
virtual const String & GetTypeName() const
Gets the type of widget this is.
virtual ListItem * GetLastSelectedListItem() const
Gets the last ListItem that was selected/focused.
virtual void SetScrollbarWidth(const UnifiedDim &ScrollWidth)
Sets the Unified width of the child scrollbar in this ListBox.
virtual void UnbindProvider(PageProvider *Prov)
Unbinds a provider being used by this container.
UnifiedDim Y
The dimension on the Y plane.
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.
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.
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
Thrown when the available information should have worked but failed for unknown reasons.
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
virtual ~ListBox()
Class destructor.
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...
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.
virtual const SizingInfo & GetListItemSize() const
Gets the size to be given to children processed by this container if forced sizing is enabled...
This class represents both the relative and absolute values that can be expressed for the values on o...
virtual void SetTextLineHorizontalAlignment(const UI::LinearAlignment Align)
Sets the horizontal alignment of every textline in this layer.
virtual String GetPrimaryAtlas()
Gets the currently set primary atlas.
TextLayer::ScalingMode ListItemCharScalingMode
The auto-scaling mode that is to be applied to all created list items.
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.
MultiLineTextLayer * CreateMultiLineTextLayer()
Creats a MultiLineTextLayer for this renderable.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
virtual Whole GetNumChildren() const
Gets the number of children in this QuadRenderable.
ListBox(Screen *Parent)
Blank constructor.
virtual const Vector2 & GetMouseHitPosition() const
Gets the mouse position from the last call to "FindHoveredQuad(const Vector2&).
This class represents a point in 2D space using UnifiedDim's.
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.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
New entries will be inserted at the bottom of the list.
Boole IsInside(const Vector2 &Point) const
Checks to see if a point in 2D space is inside this rect.
virtual ListItem * GetListItem(const String &Name) const
Gets a ListItem in this ListBox by name.
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.
virtual TextLayer::ScalingMode GetListItemTextScalingMode() const
Gets the automatic scaling mode being used by ListItems created by this ListBox.
virtual void SetText(const String &Text)
Sets the text displayed within this layer.
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
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.
virtual void DestroyChild(Widget *ToBeDestroyed)
Destroys a child Widget currently inside this QuadRenderable.
New entries will be inserted at the top of the list.
VerticalScrollbar * ListScroll
A pointer to the vertical scrollbar responsible for the visible list items.
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...
virtual VerticalScrollbar * GetListScroll() const
Gets the Scrollbar within this widget.
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.
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.
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.
This is a base class for render layers that render text.
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.
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.
This is a widget for displaying a list of captions in a box.
virtual Widget * CreateWidget(const XML::Node &WidgetNode)
Creates a widget from an XML::Node.