Public Member Functions | Private Member Functions | Private Attributes

TextBox Class Reference

A box of text that can be wrapped to its dimensions. More...

#include <TextBox.h>

Inheritance diagram for TextBox:
ScrollArea Container Control Broadcaster Listener

List of all members.

Public Member Functions

 TextBox (const std::string &name, int width, int height)
void setText (const std::string &text)
std::string getText () const
void setWrapped (bool wrapped)
void isEditable (bool editable)
bool isEditable ()
StringList Tokenize (const std::string &str, const std::string &delimiter=" ")

Private Member Functions

void drawSkin ()
void drawPlain ()
void drawCursor ()
void drawText ()
void scrollAreaInit ()
void areaChanged ()
void insertCharacter (const char *character)
void formatText ()
void tokenizeText (const std::string &text)
void setTotalLines ()
void onKeyDown (Event *event)

Private Attributes

StringList mFormattedText
StringList mTokens
StringList mLines
string mText
Uint mTotalLines
Uint mCurrentLine
Uint mCursorPositionX
Uint mCursorPositionY
bool mWrapped
bool mEditable

Detailed Description

A box of text that can be wrapped to its dimensions.

Note:
TextBoxes include scrolling capability.

Constructor & Destructor Documentation

TextBox::TextBox ( const std::string &  name,
int  width,
int  height 
)

Member Function Documentation

void TextBox::areaChanged (  )  [private, virtual]

Reimplemented from ScrollArea.

void TextBox::drawCursor (  )  [private]

Draws the insertion point cursor.

void TextBox::drawPlain (  )  [private, virtual]

Draws a Control without a Skin.

Reimplemented from ScrollArea.

void TextBox::drawSkin (  )  [private, virtual]

Draws a Control using a Skin.

Reimplemented from ScrollArea.

void TextBox::drawText (  )  [private]

Draws the formatted text of this Control.

void TextBox::formatText (  )  [private]

Builds a new string with formatting characters.

std::string TextBox::getText (  )  const

Returns the text contained in the TextBox.

void TextBox::insertCharacter ( const char *  character  )  [private]
void TextBox::isEditable ( bool  editable  ) 
bool TextBox::isEditable (  ) 
void TextBox::onKeyDown ( Event event  )  [private, virtual]

Called whenever an EVENT_KEYDOWN event is fired.

Reimplemented from Control.

void TextBox::scrollAreaInit (  )  [private, virtual]

Used to initialize the control and its properties.

This function must be overriden in derived controls, such as the TextBox.

Reimplemented from ScrollArea.

void TextBox::setText ( const std::string &  text  ) 
void TextBox::setTotalLines (  )  [private]

Sets the maximum lines of text to display within the box.

Calculation is done based on the height of the textbox and the font height.

void TextBox::setWrapped ( bool  wrapped  ) 

Breaks our strings to new lines based on textbox size.

Note:
Needs to be tested against resized boxes.

The string is broken down by words so as to properly display each line of text to wrap properly.

StringList TextBox::Tokenize ( const std::string &  str,
const std::string &  delimiter = " " 
)
void TextBox::tokenizeText ( const std::string &  text  )  [private]

Member Data Documentation

Current line based on scrollbar's position.

Position of the Insertion Cursor.

Position of the Insertion Cursor.

bool TextBox::mEditable [private]

Toggle editing of the field.

Vector containing the formatted strings of text.

Todo:
Clarify this comment: Vector containing broken lines based on where
was found.
string TextBox::mText [private]

Text contained within this Control.

Todo:
Clarify this comment: Vector containing each individual word.

Total amount of lines we can render.

bool TextBox::mWrapped [private]

Flag indicating whether the text should wrap within a set region.


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