# WoopsiUI::TextBox Class Reference

`#include <textbox.h>`

Inheritance diagram for WoopsiUI::TextBox:

List of all members.

## Public Member Functions
| TextBox (s16 x, s16 y, u16 width, u16 height, const char *text, FontBase *font=NULL)
| TextBox (s16 x, s16 y, u16 width, u16 height, const char letter, FontBase *font=NULL)
virtual void | draw (Rect clipRect)
virtual void | showCursor ()
virtual void | hideCursor ()
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 | 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 void | moveCursorToPosition (const u32 position)
virtual const u32 | getCursorPosition () const
virtual void | getClientRect (Rect &rect) const
virtual bool | click (s16 x, s16 y)
virtual bool | keyPress (KeyCode keyCode)
## Protected Member Functions
virtual const u16 | getCursorXPos () const
| TextBox (const TextBox &textbox)
## Protected Attributes
u32 | _cursorPos
bool | _showCursor

## Detailed Description

Single-line textbox gadget. Can align text both vertically and horizontally in different ways.

## Constructor & Destructor Documentation

WoopsiUI::TextBox::TextBox | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const char * | text,
|  | FontBase * | font = `NULL` |
| ) |  |  |

Constructor for a textbox containing a string.

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.
  | font | The font to use in this text box.

WoopsiUI::TextBox::TextBox | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const char | letter,
|  | FontBase * | font = `NULL` |
| ) |  |  |

Constructor for a textbox containing a single character.

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.
  | letter | Single character to display in the textbox.
  | font | The font to use in this text box.

WoopsiUI::TextBox::TextBox | ( | const TextBox & | textbox | ) | `[inline, protected]`

Copy constructor is protected to prevent usage.

## Member Function Documentation

virtual void WoopsiUI::TextBox::appendText | ( | const char | text | ) | `[virtual]`

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

Parameters:

  | text | Char to append.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::TextBox::appendText | ( | const char * | text | ) | `[virtual]`

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

Parameters:

  | text | String to append.

Reimplemented from WoopsiUI::Label.

virtual bool WoopsiUI::TextBox::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.

virtual void WoopsiUI::TextBox::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::Label.

virtual void WoopsiUI::TextBox::getClientRect | ( | Rect & | rect | ) | const`[virtual]`

Insert the properties of the space within this gadget that is available for children into the rect passed in as a parameter. All co-ordinates are relative to this gadget.

Parameters:

  | rect | Reference to a rect to populate with data.

Reimplemented from WoopsiUI::Gadget.

virtual const u32 WoopsiUI::TextBox::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.

virtual const u16 WoopsiUI::TextBox::getCursorXPos | ( |  | ) | const`[protected, virtual]`

Get the x co-ordinate of the cursor in pixels.

Returns:
  The x co-ordinate of the cursor in pixels.

virtual void WoopsiUI::TextBox::hideCursor | ( |  | ) | `[virtual]`

Hides the cursor.

virtual void WoopsiUI::TextBox::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.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::TextBox::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.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::TextBox::insertTextAtCursor | ( | const char | text | ) | `[virtual]`

Insert text at the current cursor position.

Parameters:

  | text | Char to insert.

virtual void WoopsiUI::TextBox::insertTextAtCursor | ( | const char * | text | ) | `[virtual]`

Insert text at the current cursor position.

Parameters:

  | text | The text to insert.

virtual bool WoopsiUI::TextBox::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.

virtual void WoopsiUI::TextBox::moveCursorToPosition | ( | const u32 | 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.

virtual void WoopsiUI::TextBox::setText | ( | const char | text | ) | `[virtual]`

Set the text displayed in the label.

Parameters:

  | text | Character to display.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::TextBox::setText | ( | const char * | text | ) | `[virtual]`

Set the text displayed in the label.

Parameters:

  | text | String to display.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::TextBox::showCursor | ( |  | ) | `[virtual]`

Shows the cursor.

## Member Data Documentation

u32 WoopsiUI::TextBox::_cursorPos`[protected]`

Position of the cursor within the string

bool WoopsiUI::TextBox::_showCursor`[protected]`

Set to true to make cursor visible

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

- C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.40/Woopsi/libwoopsi/include/textbox.h