Xrb::Label Class Reference

Non-interactive display widget, for pictures or text. More...

#include <xrb_label.hpp>

Inheritance diagram for Xrb::Label:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Label (std::string const &text, ContainerWidget *const parent, std::string const &name="Label")
 Constructs a text label.
 Label (Resource< GLTexture > const &picture, ContainerWidget *const parent, std::string const &name="Label")
 Constructs a picture label.
virtual ~Label ()
 Destructor.
Alignment2 const & GetAlignment () const
 Returns the alignment vector.
bool WordWrap () const
 Returns true iff word-wrapping is enabled.
bool IsPictureLabel () const
 Returns true if this is a picture label, false for text label.
Resource< GLTexture > const & Picture () const
 Returns the resourced GLTexture picture for this label.
bool PictureKeepsAspectRatio () const
 Iff true, indicates that the picture will be resized just small enough to preserve its aspect ratio.
virtual void SetText (std::string const &text)
void SetAlignment (Alignment2 const &alignment)
void SetAlignment (Uint32 component, Alignment alignment)
virtual void SetWordWrap (bool word_wrap)
virtual void SetPicture (std::string const &picture_name)
virtual void SetPicture (Resource< GLTexture > const &picture)
void SetPictureKeepsAspectRatio (bool picture_keeps_aspect_ratio)
virtual void Draw (RenderContext const &render_context) const
 Draws the widget using the provided RenderContext.
virtual ScreenCoordVector2 Resize (ScreenCoordVector2 const &size)
 Attempt to resize this widget to the given size.

Protected Member Functions

void DrawText (RenderContext const &render_context) const
void DrawPicture (RenderContext const &render_context) const
Resource< GLTexture > const & RenderPicture () const
virtual void SetRenderFont (Resource< Font > const &render_font)
void SetRenderPicture (Resource< GLTexture > const &render_picture)
virtual void HandleChangedFrameMargins ()
 Handler that is called when the frame margins have been changed.
virtual void HandleChangedContentMargins ()
 Handler that is called when the content margins have been changed.
virtual void UpdateRenderFont ()
virtual void UpdateRenderPicture ()
virtual ScreenCoordRect TextRect () const
virtual void UpdateMinAndMaxSizesFromText ()
void DirtyTextFormatting ()


Detailed Description

Non-interactive display widget, for pictures or text.

Displays pictures or text (justified or unjustified). There is no interaction at this level. This class acts as a baseclass for several widgets which have similar contents and rendering (e.g. Button).

Definition at line 29 of file xrb_label.hpp.


Constructor & Destructor Documentation

Xrb::Label::Label ( std::string const &  text,
ContainerWidget *const   parent,
std::string const &  name = "Label" 
)

Constructs a text label.

Constructs a Label using the specified text. By default, no justification will be done, though the text will be centered horizontally and vertically.

Definition at line 22 of file xrb_label.cpp.

References Xrb::CENTER, and Xrb::Resource< T >::IsValid().

Xrb::Label::Label ( Resource< GLTexture > const &  picture,
ContainerWidget *const   parent,
std::string const &  name = "Label" 
)

Constructs a picture label.

The picture texture is stretched to fill the area inside the frame margins, adding the content margins.

Definition at line 39 of file xrb_label.cpp.


Member Function Documentation

Alignment2 const& Xrb::Label::GetAlignment (  )  const [inline]

Returns the alignment vector.

Alignment values for the X and Y components. The X component alignment can be one of LEFT , CENTER , RIGHT , or SPACED . The Y component alignment can be one of TOP , CENTER , BOTTOM , or SPACED .

Definition at line 64 of file xrb_label.hpp.

Resource<GLTexture> const& Xrb::Label::Picture (  )  const [inline]

Returns the resourced GLTexture picture for this label.

If this is a text label, the returned resource will be invalid.

Definition at line 74 of file xrb_label.hpp.

bool Xrb::Label::PictureKeepsAspectRatio (  )  const [inline]

Iff true, indicates that the picture will be resized just small enough to preserve its aspect ratio.

Applies only when this is a picture label. When the picture doesn't fill up the entire content area, it will be centered appropriately.

Definition at line 80 of file xrb_label.hpp.

void Xrb::Label::Draw ( RenderContext const &  render_context  )  const [virtual]

Draws the widget using the provided RenderContext.

This function should be overridden in subclasses to provide the means to draw whatever is necessary. Generally the subclass's Draw function should call the Draw function of its immediate superclass before doing anything else, in order to have the background and other necessary visual elements drawn.

Draw should only be called on top-level widgets -- the Widget baseclass takes care of setting up the RenderContext and calling Draw on its child widgets appropriately.

Note:
You can NOT count on Draw being called every single video frame, since it will not be called if the clip_rect is not valid (0 area).

Reimplemented from Xrb::Widget.

Definition at line 127 of file xrb_label.cpp.

ScreenCoordVector2 Xrb::Label::Resize ( ScreenCoordVector2 const &  size  )  [virtual]

Attempt to resize this widget to the given size.

This function should be overridden when it is necessary to know when a widget has been resized.

The Widget baseclass will resize the widget based on its minimum and maximum sizes, if applicable. If there is a main widget, Resize will be called on the main widget with the min/max adjusted size.

If the size of the widget was actually changed, then its parent will be notified of the change via ParentChildSizePropertiesUpdate.

For examples of overriding these and related functions, see Layout and CellPaddingWidget.

Parameters:
size The requested size.
Returns:
The actual size of the widget after the resize operation.

Reimplemented from Xrb::Widget.

Definition at line 140 of file xrb_label.cpp.

References Xrb::Widget::Size(), and Xrb::Dim::X.

void Xrb::Label::HandleChangedFrameMargins (  )  [protected, virtual]

Handler that is called when the frame margins have been changed.

Subclasses should override this when they need to do something when the frame margins have been changed.

See also:
Layout

Reimplemented from Xrb::Widget.

Definition at line 149 of file xrb_label.cpp.

void Xrb::Label::HandleChangedContentMargins (  )  [protected, virtual]

Handler that is called when the content margins have been changed.

Subclasses should override this when they need to do something when the content margins have been changed.

See also:
Layout

Reimplemented from Xrb::Widget.

Definition at line 155 of file xrb_label.cpp.


The documentation for this class was generated from the following files:

Hosted by SourceForge.net Logo -- Generated on Fri Aug 21 21:46:39 2009 for XuqRijBuh by doxygen 1.5.8