MezzanineEngine March 18, 2012

Mezzanine::UI::ListBox Class Reference

This is a widget for displaying a list of captions in a box. More...

#include <uilistbox.h>

Inheritance diagram for Mezzanine::UI::ListBox:
Mezzanine::UI::Widget

List of all members.

Public Member Functions

 ListBox (ConstString &name, const RenderableRect &Rect, const UI::ScrollbarStyle &ScrollStyle, Layer *PLayer)
 Standard initialization constructor.
virtual ~ListBox ()
 Standard destructor.
virtual CaptionAddSelection (ConstString &name, ConstString &Text, ConstString &BackgroundSprite="")
 Adds a selectable caption to the list to be displayed.
virtual void DestroySelection (String &ToBeDestroyed)
 Destroys a selectable caption.
virtual void DestroySelection (Caption *ToBeDestroyed)
 Destroys a selectable caption.
virtual RectangleGetBoxBack ()
 Gets the background of this List Box.
virtual CaptionGetSelected ()
 Gets the currently selected caption.
virtual CaptionGetSelection (ConstString &Name)
 Gets a caption by name.
virtual const UI::TemplateParamsGetTemplateInfo ()
 Gets the struct containing all the current template parameters used when creating a new selections.
virtual UI::ScrollbarGetVertScroll ()
 Gets the scrollbar used within this List Box.
virtual void SetActualPosition (const Vector2 &Position)
 Sets the pixel position of this List Box.
virtual void SetActualSize (const Vector2 &Size)
 Sets the pixel size of this List Box.
virtual void SetAutoHideScroll (bool AutoHide)
 Eanbles or disables the scrollbar autohide.
virtual void SetMaxDisplayedSelections (const Whole &MaxSelections)
 Sets the maximum number of selections to display at once before the scrollbar appears.
virtual void SetPosition (const Vector2 &Position)
 Sets the relative position of this List Box.
virtual void SetSelected (Caption *ToBeSelected)
 Sets the selection within this list to be "selected".
virtual void SetSize (const Vector2 &Size)
 Sets the relative size of this List Box.
virtual ListBoxSetTemplateBackgroundColour (const ColourValue &BackgroundColour)
 Sets the background colour to be applied to all created Selections.
virtual ListBoxSetTemplateCursorOffset (const Whole &Offset)
 Set the cursor offset to be applied to all created Selections.
virtual ListBoxSetTemplateGlyphIndex (const Whole &Glyph)
 Sets the glyph index to be applied to all created Selections.
virtual ListBoxSetTemplateHorizontalAlign (const UI::TextHorizontalAlign &HorAlign)
 Sets the horizontal alignment to be applied to all created Selections.
virtual ListBoxSetTemplateRenderPriority (const UI::RenderPriority &Priority)
 Sets the render priority to be applied to all created Selections.
virtual ListBoxSetTemplateSize (const Vector2 &Size, bool Relative=true)
 Sets the size to be applied to all created Selections.
virtual ListBoxSetTemplateTextColour (const ColourValue &TextColour)
 Sets the text colour to be applied to all created Selections.
virtual ListBoxSetTemplateTextScale (const Real &Scale)
 Sets the text scale to be applied to all created Selections.
virtual ListBoxSetTemplateVerticalAlign (const UI::TextVerticalAlign &VertAlign)
 Sets the vertical alignment to be applied to all created Selections.
virtual void UpdateDimensions ()
 Updates the dimensions of this widget to match those of the new screen size.

Public Attributes

TemplateParams Params

Protected Member Functions

virtual bool CheckMouseHoverImpl ()
 Child specific mouse hover method.
virtual void DrawList ()
 Updates the list of Visible buttons and hides the rest.
virtual void ScrollerSizeCheck ()
 Checks to make sure the Scroller is the appropriate size.
virtual void ScrollHideCheck ()
 Checks to see if the scrollbar should be hidden or not.
virtual void SelectionSizeCheck (UI::Caption *Selection)
 Checks to see if the current size of the selection needs adjusting.
virtual void SetArea (const Vector2 &Area)
 Internal utility to set the size of this widget.
virtual void SetVisibleImpl (bool visible)
 Child specific visibility method.
virtual void UpdateImpl (bool Force=false)
 Child specific update method.

Protected Attributes

bool AutoHideScroll
RectangleBoxBack
CaptionHoveredCaption
Real LastScrollValue
Whole MaxDisplay
CaptionSelected
std::vector< Caption * > Selections
Whole SelectionsAdded
UI::TemplateParams SelectionTemplate
ScrollbarVertScroll
std::vector< Caption * > VisibleSelections

Detailed Description

This is a widget for displaying a list of captions in a box.

Definition at line 74 of file uilistbox.h.


Constructor & Destructor Documentation

Mezzanine::UI::ListBox::ListBox ( ConstString name,
const RenderableRect Rect,
const UI::ScrollbarStyle ScrollStyle,
Layer PLayer 
)

Standard initialization constructor.

Parameters:
nameThe name of the List Box.
RectThe Rect representing the position and size of the List Box. The size portion of this rect would be in reference to the size of a single selection. The actual size of this widget will be a result of how many selections are currently being displayed.
ScrollStyleThe style of the scrollbar you want for this List Box. See Scrollbar class for more information.
LayerThe parent layer this List Box belongs to.

Todo:
Currently this class has little support for a border around the selections. Ideally when the UI system is more complete we'll be able to seemlessly move objects around different layers and thus have more control over z-order. When that happens we should add a rect to this class be be placed over the selections for use with a border or other kind of decoration.

Definition at line 61 of file uilistbox.cpp.


Member Function Documentation

Caption * Mezzanine::UI::ListBox::AddSelection ( ConstString name,
ConstString Text,
ConstString BackgroundSprite = "" 
) [virtual]

Adds a selectable caption to the list to be displayed.

If a colour other then white was set as the template and you try to set a background sprite, it will attempt to blend the colour and sprite. Pure white colour will cause the sprite to look normal.

Parameters:
nameA name for the selection.
TextThe text to be displayed within the created caption.
BackgroundSpriteOptional, name of the sprite to set as it's background. Ignored if the string is empty.

Definition at line 346 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::DestroySelection ( Caption ToBeDestroyed) [virtual]

Destroys a selectable caption.

Parameters:
ToBeDestroyedA pointer to the caption you want destroyed and removed from this list.

Definition at line 384 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::DestroySelection ( String ToBeDestroyed) [virtual]

Destroys a selectable caption.

Parameters:
ToBeDestroyedA string naming the caption you want destroyed and removed from this list.

Definition at line 405 of file uilistbox.cpp.

Rectangle * Mezzanine::UI::ListBox::GetBoxBack ( ) [virtual]

Gets the background of this List Box.

Returns:
Returns a pointer to the background of this List Box.

Definition at line 489 of file uilistbox.cpp.

Caption * Mezzanine::UI::ListBox::GetSelected ( ) [virtual]

Gets the currently selected caption.

Returns:
Returns a pointer to the currently selected caption, or NULL if none are selected.

Definition at line 484 of file uilistbox.cpp.

Caption * Mezzanine::UI::ListBox::GetSelection ( ConstString Name) [virtual]

Gets a caption by name.

Parameters:
NameThe name of the selectable caption you want to get.
Returns:
Returns a pointer to the named caption.

Definition at line 371 of file uilistbox.cpp.

const UI::TemplateParams & Mezzanine::UI::ListBox::GetTemplateInfo ( ) [virtual]

Gets the struct containing all the current template parameters used when creating a new selections.

Returns:
Returns a const reference to the structure containing all the template parameters.

Definition at line 341 of file uilistbox.cpp.

UI::Scrollbar * Mezzanine::UI::ListBox::GetVertScroll ( ) [virtual]

Gets the scrollbar used within this List Box.

Returns:
Returns a pointer to the scrollbar of this List Box.

Definition at line 494 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetActualPosition ( const Vector2 Position) [virtual]

Sets the pixel position of this List Box.

Parameters:
PositionA vector2 representing the pixel position of this List Box.

Implements Mezzanine::UI::Widget.

Definition at line 448 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetActualSize ( const Vector2 Size) [virtual]

Sets the pixel size of this List Box.

Parameters:
SizeA vector2 representing the pixel size of this List Box.

Implements Mezzanine::UI::Widget.

Definition at line 462 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetAutoHideScroll ( bool  AutoHide) [virtual]

Eanbles or disables the scrollbar autohide.

Parameters:
AutoHideA bool indicating whether or not to auto hide the scrollbar.

Definition at line 433 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetMaxDisplayedSelections ( const Whole MaxSelections) [virtual]

Sets the maximum number of selections to display at once before the scrollbar appears.

Parameters:
MaxSelectionsThe maximum number of selections to display at once before requiring a scrollbar. This indirectly controls the max size of this widget.

Definition at line 424 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetPosition ( const Vector2 Position) [virtual]

Sets the relative position of this List Box.

The position is relative to the screen size. Values range from 0.0 to 1.0.

Parameters:
PositionA vector2 representing the relative position of this List Box.

Implements Mezzanine::UI::Widget.

Definition at line 439 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetSelected ( Caption ToBeSelected) [virtual]

Sets the selection within this list to be "selected".

Parameters:
ToBeSelectedA pointer to the caption to be set as "selected".

Todo:
Maybe add a checker to verify the caption belongs to this widget?

Definition at line 418 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::SetSize ( const Vector2 Size) [virtual]

Sets the relative size of this List Box.

The size is relative to the screen size. Values range from 0.0 to 1.0.

Parameters:
SizeA vector2 representing the relative size of this List Box.

Implements Mezzanine::UI::Widget.

Definition at line 457 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateBackgroundColour ( const ColourValue BackgroundColour) [virtual]

Sets the background colour to be applied to all created Selections.

Optional parameter.

Parameters:
BackgroundColourThe colour to set for the captions background. This defaults to white.
Returns:
Returns a reference to this List Box.

Definition at line 317 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateCursorOffset ( const Whole Offset) [virtual]

Set the cursor offset to be applied to all created Selections.

Optional parameter.

Parameters:
OffsetThe offset in pixels to adjust where text starts appearing in the caption.
Returns:
Returns a reference to this List Box.

Definition at line 311 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateGlyphIndex ( const Whole Glyph) [virtual]

Sets the glyph index to be applied to all created Selections.

This needs to be called prior to the creation of any selections(captions). This defaults to 0, which may not be a valid font index in your mta file. In which case it will throw an exception.

Parameters:
GlyphThe Glyph index to use for the text generated by all captions in this widget.
Returns:
Returns a reference to this List Box.

Definition at line 293 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateHorizontalAlign ( const UI::TextHorizontalAlign HorAlign) [virtual]

Sets the horizontal alignment to be applied to all created Selections.

Optional parameter.

Parameters:
HorAlignThe horizontal text alignment. This defaults to UI::Middle.
Returns:
Returns a reference to this List Box.

Definition at line 323 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateRenderPriority ( const UI::RenderPriority Priority) [virtual]

Sets the render priority to be applied to all created Selections.

Optional parameter.

Parameters:
PriorityThe priority with which to render the image. This defaults to UI::RP_Medium.
Returns:
Returns a reference to this List Box.

Definition at line 335 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateSize ( const Vector2 Size,
bool  Relative = true 
) [virtual]

Sets the size to be applied to all created Selections.

Parameters:
SizeThe size of the caption to make. Applied to all captions created by this class.
RelativeWhether or not the size provided is in relative units(rather then pixels).
Returns:
Returns a reference to this List Box.

Definition at line 277 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateTextColour ( const ColourValue TextColour) [virtual]

Sets the text colour to be applied to all created Selections.

Optional parameter.

Parameters:
TextColourThe Colour of the text. This defaults to black.
Returns:
Returns a reference to this List Box.

Definition at line 299 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateTextScale ( const Real Scale) [virtual]

Sets the text scale to be applied to all created Selections.

Optional parameter.

Parameters:
ScaleThe scale you wish to apply to the text in all created selections.
Returns:
Returns a reference to this List Box.

Definition at line 305 of file uilistbox.cpp.

ListBox & Mezzanine::UI::ListBox::SetTemplateVerticalAlign ( const UI::TextVerticalAlign VertAlign) [virtual]

Sets the vertical alignment to be applied to all created Selections.

Optional parameter.

Parameters:
VertAlignThe Vertical text alignment. This defaults to UI::Center.
Returns:
Returns a reference to this List Box.

Definition at line 329 of file uilistbox.cpp.

void Mezzanine::UI::ListBox::UpdateDimensions ( ) [virtual]

Updates the dimensions of this widget to match those of the new screen size.

This function is called automatically when a viewport changes in size, and shouldn't need to be called manually.

Implements Mezzanine::UI::Widget.

Definition at line 467 of file uilistbox.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines