Bubba-3D  0.9.0
Awesome game engine!
Public Member Functions | List of all members
TextLayout Class Reference

#include <TextLayout.h>

Inheritance diagram for TextLayout:
Layout

Public Member Functions

 TextLayout (std::string text, Font *font, Dimension width, Dimension height)
 
virtual Dimension getWidth ()
 
virtual Dimension getHeight ()
 
virtual void getGLSquares (float layoutXPos, float layoutYPos, float layoutWidth, float layoutHeight, std::map< std::string, IHudDrawable * > *map)
 
void setText (std::string text)
 
TextLayoutsetTextId (std::string id)
 
TextLayoutsetPadding (int pixels)
 
TextLayoutsetPadding (int topAndBottom, int rightAndLeft)
 
TextLayoutsetPadding (int top, int right, int bot, int left)
 
- Public Member Functions inherited from Layout
virtual std::map< std::string, IHudDrawable * > getGLSquares (float layoutXPos, float layoutYPos, float layoutWidth, float layoutHeight)
 
virtual HUDGraphicgetGraphic ()
 
virtual LayoutsetBackground (HUDGraphic *graphic)
 
virtual LayoutsetLayoutId (std::string id)
 

Additional Inherited Members

- Public Types inherited from Layout
enum  ListenerType { ON_CLICK_LISTENER, ON_HOVER_LISTENER }
 
typedef std::function< void(int x, int y, Layout *element, bool enteredElseLeaving)> EventFunction
 

Detailed Description

A layout used to present text.

Definition at line 25 of file TextLayout.h.

Constructor & Destructor Documentation

TextLayout::TextLayout ( std::string  text,
Font font,
Dimension  width,
Dimension  height 
)

Creates a text layout. Create a font using FontManager::loadAndFetchFont()

Definition at line 21 of file TextLayout.cpp.

Member Function Documentation

void TextLayout::getGLSquares ( float  layoutXPos,
float  layoutYPos,
float  layoutWidth,
float  layoutHeight,
std::map< std::string, IHudDrawable * > *  map 
)
virtual

The function to fetch all GLSquares from this layout and its children based on the position and dimensions given. The parent calculates the dimensions and implementing classes must assume that the dimensions are correct. The parent uses getWidth() and getHeight() to determine the dimensions.

The overridden method should always call Layout::getGLSquares(float layoutXPos, float layoutYPos, float layoutWidth, float layoutHeight, map<string,IHudDrawable*>* list) before doing anything else. Otherwise Layout::setBackground() won't have an effect.

Implements Layout.

Definition at line 63 of file TextLayout.cpp.

void TextLayout::setText ( std::string  text)

Changes the text of the TextLayout. If you want to change the text of an already drawn text you should use TextObject::setText() instead. You can get a hold of the TextObject by first setting an ID on this object before adding it to the HUD using TextLayout::setTextId(). Then call HudRenderer::getHudDrawableById() and typecast the result to a TextObject.

Definition at line 36 of file TextLayout.cpp.

TextLayout * TextLayout::setTextId ( std::string  id)

Sets the id of the to-be-rendered TextObject. This object can be accessed by HudRenderer::getHudDrawableById().

Definition at line 40 of file TextLayout.cpp.


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