WoopsiUI::MultiLineTextBox Class Reference

#include <multilinetextbox.h>

Inheritance diagram for WoopsiUI::MultiLineTextBox:
WoopsiUI::ScrollingPanel WoopsiUI::Gadget WoopsiUI::ScrollableBase

List of all members.

Public Types

enum  TextAlignmentHoriz { TEXT_ALIGNMENT_HORIZ_CENTRE = 0, TEXT_ALIGNMENT_HORIZ_LEFT = 1, TEXT_ALIGNMENT_HORIZ_RIGHT = 2 }
enum  TextAlignmentVert { TEXT_ALIGNMENT_VERT_CENTRE = 0, TEXT_ALIGNMENT_VERT_TOP = 1, TEXT_ALIGNMENT_VERT_BOTTOM = 2 }

Public Member Functions

 MultiLineTextBox (s16 x, s16 y, u16 width, u16 height, const char *text, u32 flags, s16 maxRows=0, FontBase *font=NULL)
virtual void draw (Rect clipRect)
virtual void setTextAlignmentHoriz (TextAlignmentHoriz alignment)
virtual void setTextAlignmentVert (TextAlignmentVert alignment)
virtual const u16 getPageCount () const
virtual const u16 getCurrentPage () const
virtual const TextgetText () const
virtual void setText (const char *text)
virtual void setText (const char text)
virtual void appendText (const char *text)
virtual void appendText (const char text)
virtual void removeText (const u32 startIndex)
virtual void removeText (const u32 startIndex, const u32 count)
virtual void setFont (FontBase *font)
virtual bool resize (u16 width, u16 height)
virtual const u32 getTextLength () const
virtual void showCursor ()
virtual void hideCursor ()
virtual void moveCursorToPosition (const s32 position)
virtual const s32 getCursorPosition () const
virtual void insertText (const char *text, const u32 index)
virtual void insertText (const char text, const u32 index)
virtual void insertTextAtCursor (const char *text)
virtual void insertTextAtCursor (const char text)
virtual bool click (s16 x, s16 y)
virtual bool keyPress (KeyCode keyCode)

Protected Member Functions

u8 getRowX (s32 row)
s16 getRowY (s32 row)
void calculateVisibleRows ()
void drawTextTop (Rect clipRect)
void drawText (Rect clipRect, s32 topRow, s32 bottomRow)
void drawCursor (Rect clipRect)
virtual ~MultiLineTextBox ()
 MultiLineTextBox (const MultiLineTextBox &multiLineTextBox)

Protected Attributes

Text_text
u8 _visibleRows
s16 _maxRows
u32 _topRow
u8 _padding
TextAlignmentHoriz _hAlignment
TextAlignmentVert _vAlignment
s32 _cursorPos
bool _showCursor

Detailed Description

Textbox that offers multiple lines of text. Has scrolling capability and can be dragged using the stylus. The text it contains can be changed or added to. It can remember more rows of text than it can display, and these additional rows can be scrolled through.


Member Enumeration Documentation

Enum of horizontal alignment options.

Enumerator:
TEXT_ALIGNMENT_HORIZ_CENTRE 

Centre the text

TEXT_ALIGNMENT_HORIZ_LEFT 

Align left

TEXT_ALIGNMENT_HORIZ_RIGHT 

Align right

Enum of vertical alignment options.

Enumerator:
TEXT_ALIGNMENT_VERT_CENTRE 

Align to centre of textbox

TEXT_ALIGNMENT_VERT_TOP 

Align to top of textbox

TEXT_ALIGNMENT_VERT_BOTTOM 

Align to bottom of textbox


Constructor & Destructor Documentation

MultiLineTextBox::MultiLineTextBox ( s16  x,
s16  y,
u16  width,
u16  height,
const char *  text,
u32  flags,
s16  maxRows = 0,
FontBase font = NULL 
)

Constructor.

Parameters:
x The x co-ordinate of the text box, relative to its parent.
y The y co-ordinate of the text box, relative to its parent.
width The width of the textbox.
height The height of the textbox.
text Pointer to a string to display in the textbox.
flags Standard gadget flag options.
maxRows The maximum number of rows the textbox can track. Adding text beyond this number will cause rows at the start of the text to be forgotten; text is essentially stored as a queue, and adding to the back of a full queue causes the front items to be popped off. Setting this to 0 will make the textbox track only the visible rows.
font The font to use in this text box.
MultiLineTextBox::~MultiLineTextBox (  )  [protected, virtual]

Destructor.

WoopsiUI::MultiLineTextBox::MultiLineTextBox ( const MultiLineTextBox multiLineTextBox  )  [inline, protected]

Copy constructor is protected to prevent usage.


Member Function Documentation

void MultiLineTextBox::appendText ( const char  text  )  [virtual]

Append new text to the end of the current text displayed in the textbox.

Parameters:
text Char to append.
void MultiLineTextBox::appendText ( const char *  text  )  [virtual]

Append new text to the end of the current text displayed in the textbox.

Parameters:
text String to append.
void MultiLineTextBox::calculateVisibleRows (  )  [protected]

Works out the number of visible rows within the textbox.

bool MultiLineTextBox::click ( s16  x,
s16  y 
) [virtual]

Click this gadget at the supplied co-ordinates.

Parameters:
x X co-ordinate of the click.
y Y co-ordinate of the click.
Returns:
True if the click was successful.

Reimplemented from WoopsiUI::Gadget.

void MultiLineTextBox::draw ( Rect  clipRect  )  [virtual]

Draw the region of the textbox within the clipping rect. Should not be called directly.

Parameters:
clipRect The clipping rect to limit drawing to.

Reimplemented from WoopsiUI::ScrollingPanel.

void MultiLineTextBox::drawCursor ( Rect  clipRect  )  [protected]

Draws the cursor.

Parameters:
clipRect The rect to draw to.
void MultiLineTextBox::drawText ( Rect  clipRect,
s32  topRow,
s32  bottomRow 
) [protected]

Draws text previously clipped by one of the drawTextXXX functions.

Parameters:
clipRect The rect to draw to.
topRow The index of top row of text to draw.
bottomRow The index of the bottom row of text to draw.
void MultiLineTextBox::drawTextTop ( Rect  clipRect  )  [protected]

Clips text output for vertical top-aligned text and calls drawText().

Parameters:
clipRect The rect to draw to.
const u16 MultiLineTextBox::getCurrentPage (  )  const [virtual]

Returns the current page.

Returns:
The current page.
See also:
getPageCount().
virtual const s32 WoopsiUI::MultiLineTextBox::getCursorPosition (  )  const [inline, virtual]

Get the cursor position. This is the index within the string that the cursor is currently positioned over.

Returns:
position The cursor position.
const u16 MultiLineTextBox::getPageCount (  )  const [virtual]

Returns the number of "pages" that the text spans. A page is defined as the amount of text that can be displayed within the textbox at one time.

Returns:
The page count.
u8 MultiLineTextBox::getRowX ( s32  row  )  [protected]

Gets the x position of a row of text based on the width of the row and the type of horizontal alignment currently set.

Parameters:
row The index of the row.
Returns:
The x co-ordinate of the row.
s16 MultiLineTextBox::getRowY ( s32  row  )  [protected]

Gets the y position of the specified row of text based on the type of vertical alignment currently set.

Parameters:
row The row number to find the y co-ordinate of.
Returns:
The y co-ordinate of the specified row of text.
const Text * MultiLineTextBox::getText (  )  const [virtual]

Returns a pointer to the Text object that contains the wrapped text used in the textbox. It is used as the pre-processed data source for the textbox, and should not be altered.

Returns:
Pointer to the Text object.
const u32 MultiLineTextBox::getTextLength (  )  const [virtual]

Get the length of the text string.

Returns:
The length of the text string.
void MultiLineTextBox::hideCursor (  )  [virtual]

Hides the cursor.

void MultiLineTextBox::insertText ( const char  text,
const u32  index 
) [virtual]

Insert text at the specified index.

Parameters:
text Char to insert.
index Index at which to insert the char.
void MultiLineTextBox::insertText ( const char *  text,
const u32  index 
) [virtual]

Insert text at the specified index.

Parameters:
text The text to insert.
index Index at which to insert the text.
void MultiLineTextBox::insertTextAtCursor ( const char  text  )  [virtual]

Insert text at the current cursor position.

Parameters:
text Char to insert.
void MultiLineTextBox::insertTextAtCursor ( const char *  text  )  [virtual]

Insert text at the current cursor position.

Parameters:
text The text to insert.
bool MultiLineTextBox::keyPress ( KeyCode  keyCode  )  [virtual]

Send a keypress to the gadget.

Parameters:
keyCode The keycode to send to the gadget.
Returns:
True if the keypress was processed.

Reimplemented from WoopsiUI::Gadget.

void MultiLineTextBox::moveCursorToPosition ( const s32  position  )  [virtual]

Move the cursor to the text position specified. 0 indicates the start of the string. If position is greater than the length of the string, the cursor is moved to the end of the string.

Parameters:
position The new cursor position.
void MultiLineTextBox::removeText ( const u32  startIndex,
const u32  count 
) [virtual]

Remove specified number of characters from the string from the start index onwards.

Parameters:
startIndex Index to remove from.
count Number of characters to remove.
void MultiLineTextBox::removeText ( const u32  startIndex  )  [virtual]

Remove all characters from the string from the start index onwards.

Parameters:
startIndex Index to remove from.
bool MultiLineTextBox::resize ( u16  width,
u16  height 
) [virtual]

Resize the textbox to the new dimensions.

Parameters:
width The new width.
height The new height.
Returns:
True if the resize was successful.

Reimplemented from WoopsiUI::Gadget.

void MultiLineTextBox::setFont ( FontBase font  )  [virtual]

Set the font used in the textbox.

Parameters:
font Pointer to the new font.

Reimplemented from WoopsiUI::Gadget.

void MultiLineTextBox::setText ( const char  text  )  [virtual]

Set the text displayed in the textbox.

Parameters:
text Character to display.
void MultiLineTextBox::setText ( const char *  text  )  [virtual]

Set the text displayed in the textbox.

Parameters:
text String to display.
void MultiLineTextBox::setTextAlignmentHoriz ( TextAlignmentHoriz  alignment  )  [virtual]

Set the horizontal alignment of text within the textbox.

Parameters:
alignment The horizontal position of the text.
void MultiLineTextBox::setTextAlignmentVert ( TextAlignmentVert  alignment  )  [virtual]

Set the vertical alignment of text within the textbox.

Parameters:
alignment The vertical position of the text.
void MultiLineTextBox::showCursor (  )  [virtual]

Shows the cursor.


Member Data Documentation

Position of the cursor within the string

Horizontal alignment of the text

Maximum number of rows that the textbox should buffer

Padding around the text in pixels

Set to true to make cursor visible

Text object that manipulates and wraps the raw text string

Index of the top row of text currently displayed

Vertical alignment of the text

Total number of rows that the textbox can display at once


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

Generated on Sat Oct 24 14:33:11 2009 for Woopsi by  doxygen 1.6.1