MAUI::EditBox Class Reference

#include <MAUI/EditBox.h>

Inheritance diagram for MAUI::EditBox:

MAUI::Label MAUtil::CharInputListener MAUtil::KeyListener MAUI::Widget List of all members.

Detailed Description

This is an EditBox widget. It has two modes: multi line and single line. You can either make a custom behaviour of navigating in the editbox by calling the navigation functions such as: moveCursorVertical, moveCursorHorizontal etc. or use the default behaviour. Be sure to set the editbox as selected when you want to use it (when using the default behaviour it is then added as a keylistener to the system and responds to all keypresses until it is deselected. Be sure to implement this behaviour using a widgetlistener and the activate/deactivate functions if you are making a custom behaviour).


Public Types

enum  InputMode { IM_NUMBERS, IM_STANDARD }
enum  HorizontalAlignment { HA_LEFT, HA_CENTER, HA_RIGHT }
enum  VerticalAlignment { VA_TOP, VA_CENTER, VA_BOTTOM }

Public Member Functions

 EditBox (int x, int y, int width, int height, Widget *parent, const String &text="", int backColor=0, Font *font=0, bool manageNavigation=true, bool multiLine=false, int maxLength=64, InputMode inputMode=IM_STANDARD)
void setCursorColor (int color)
int getCursorColor () const
void setManageNavigation (bool b=true)
bool isManagingNavigation ()
void setMaxLength (int maxLength)
int getMaxLength ()
void setSelected (bool selected=true)
void activate ()
void deactivate ()
bool isActive () const
void keyPressEvent (int keyCode, int nativeCode)
void keyReleaseEvent (int keyCode, int nativeCode)
void characterChanged (char c)
void characterDeployed (char c)
bool moveCursorHorizontal (int steps, bool fireListeners=true)
bool deleteCurrentCharacter ()
bool deletePreviousCharacter ()
void clearText ()
virtual void setCaption (const String &caption)
void setText (const String &text)
const StringgetText () const
void setInputMode (InputMode inputMode)
InputMode getInputMode () const
void setEnabled (bool enabled=true)
void addEditBoxListener (EditBoxListener *ebl)
void setCaseToggle (bool caseToggle=true)
void setPasswordMode (bool enabled=true)
void setQwerty (bool enabled=true)
bool getQwerty () const
void setMultiLine (bool b=true)
bool isMultiLine ()
void setHorizontalAlignment (HorizontalAlignment alignment)
void setVerticalAlignment (VerticalAlignment alignment)
void setFont (Font *font)
void setAutoSizeX (bool f=true)
void setAutoSizeY (bool f=true)
const StringgetCaption () const
FontgetFont () const
HorizontalAlignment getHorizontalAlignment () const
VerticalAlignment getVerticalAlignment () const
bool getAutoSizeX () const
bool getAutoSizeY () const
void setPaddingLeft (int l)
void setPaddingTop (int t)
void setPaddingRight (int r)
void setPaddingBottom (int b)
virtual void setParameter (const String &name, const String &value)
void update ()
virtual void add (Widget *w)
void setParent (Widget *w)
WidgetgetParent ()
Vector< Widget * > & getChildren ()
const Vector< Widget * > & getChildren () const
virtual void draw (bool forceDraw=false)
void requestRepaint ()
virtual bool isTransparent () const
virtual void setSkin (WidgetSkin *widgetSkin)
void setDrawBackground (bool b=true)
void setBackgroundColor (int col)
WidgetwidgetAt (const Point &p)
WidgetwidgetAt (int x, int y)
virtual void setPosition (int x, int y)
const PointgetPosition () const
const PointgetPaddedPosition () const
virtual void setWidth (int width)
int getWidth () const
virtual void setHeight (int height)
int getHeight () const
virtual const RectgetBounds ()
virtual bool contains (const Point &p)
virtual bool contains (int x, int y)
bool isSelected () const
bool isEnabled () const
virtual void trigger ()
void addWidgetListener (WidgetListener *wl)
void removeWidgetListener (WidgetListener *wl)
Vector< WidgetListener * > & getWidgetListeners ()
void setInputManager (InputManager *inputManager)
int getPaddingLeft () const
int getPaddingTop () const
int getPaddingRight () const
int getPaddingBottom () const
const RectgetPaddedBounds () const

Protected Member Functions

void getTextStart (int *x, int *y)
void resize (int width, int height)
void calcStrSize ()
void drawBackground ()
void updateAbsolutePosition ()
void updateAbsolutePositionChildren (int x, int y)
void updatePaddedBounds ()
bool isDirty () const
void setDirty (bool d=true)

Protected Attributes

bool mustCalcStrSize
String caption
String cuttedCaption
Fontfont
bool autoSizeX
bool autoSizeY
bool multiLine
HorizontalAlignment horizontalAlignment
VerticalAlignment verticalAlignment
MAExtent strSize
int strWidth
int strHeight
Vector< Widget * > children
Widgetparent
Rect bounds
int relX
int relY
bool dirty
WidgetSkinskin
int backColor
bool shouldDrawBackground
bool selected
bool enabled
Vector< WidgetListener * > widgetListeners
InputManagermInputManager
Rect paddedBounds
int paddingLeft
int paddingTop
int paddingBottom
int paddingRight


Member Enumeration Documentation

enum MAUI::EditBox::InputMode
 

Enumeration for modes

Enumerator:
IM_NUMBERS 
IM_STANDARD 

enum MAUI::Label::HorizontalAlignment [inherited]
 

Enumerator:
HA_LEFT 
HA_CENTER 
HA_RIGHT 

enum MAUI::Label::VerticalAlignment [inherited]
 

Enumerator:
VA_TOP 
VA_CENTER 
VA_BOTTOM 


Constructor & Destructor Documentation

MAUI::EditBox::EditBox int  x,
int  y,
int  width,
int  height,
Widget parent,
const String text = "",
int  backColor = 0,
Font font = 0,
bool  manageNavigation = true,
bool  multiLine = false,
int  maxLength = 64,
InputMode  inputMode = IM_STANDARD
 

Constructor.

Parameters:
x the horizontal position of the Label relative to its parent's top left padded corner.
y the vertical position of the Label relative to its parent's top left padded corner
width the width of the Label.
height the height of the Label.
parent pointer to the parent widget. Passing anything else than NULL causes the Label to be added to the parent's children.
text dictates the initial content.
backColor controls the background color.
font the font used to draw the text in this widget. If NULL, the default font is used. See Engine::getDefaultFont().
manageNavigation determines whether the EditBox should automatically respond to key presses when it is selected in a default fashion.
multiLine controls whether multiple lines of text are supported.
maxLength controls the maximum number of characters that can be entered.
inputMode the input mode.


Member Function Documentation

void MAUI::EditBox::setCursorColor int  color  ) 
 

Sets the color of the cursor

int MAUI::EditBox::getCursorColor  )  const
 

Returns the color used to draw the cursor.

void MAUI::EditBox::setManageNavigation bool  b = true  ) 
 

Turns automatic managment of navigation on or off

bool MAUI::EditBox::isManagingNavigation  ) 
 

Returns whether navigation is being managed

void MAUI::EditBox::setMaxLength int  maxLength  ) 
 

Sets the maximum number of characters allowed

int MAUI::EditBox::getMaxLength  ) 
 

Returns the maximum number of characters allowed

void MAUI::EditBox::setSelected bool  selected = true  )  [virtual]
 

Returns whether the EditBox is selected

Reimplemented from MAUI::Widget.

void MAUI::EditBox::activate  ) 
 

Registers the EditBox as a KeyListener with the current Environment, updating the content in response to key presses

void MAUI::EditBox::deactivate  ) 
 

Unregisters the KeyListener used to update the content

bool MAUI::EditBox::isActive  )  const
 

Returns whether the EditBox is listening for input

void MAUI::EditBox::keyPressEvent int  keyCode,
int  nativeCode
[virtual]
 

Implementation of the KeyListener interface, updating the content

Reimplemented from MAUtil::KeyListener.

void MAUI::EditBox::keyReleaseEvent int  keyCode,
int  nativeCode
[virtual]
 

Implementation of the KeyListener interface, updating the content

Reimplemented from MAUtil::KeyListener.

void MAUI::EditBox::characterChanged char  c  )  [virtual]
 

Implementation of the CharInputListener interface function

Implements MAUtil::CharInputListener.

void MAUI::EditBox::characterDeployed char  c  )  [virtual]
 

Implementation of the CharInputListener interface function

Implements MAUtil::CharInputListener.

bool MAUI::EditBox::moveCursorHorizontal int  steps,
bool  fireListeners = true
 

Moves the cursor horizontally the specified number of steps. Negative steps go left, positive right.

bool MAUI::EditBox::deleteCurrentCharacter  ) 
 

Removes the character at the current cursor position.

bool MAUI::EditBox::deletePreviousCharacter  ) 
 

Removes the character before the current cursor position.

void MAUI::EditBox::clearText  ) 
 

Clears the text.

virtual void MAUI::EditBox::setCaption const String caption  )  [virtual]
 

Sets the text that appears on the label

Reimplemented from MAUI::Label.

void MAUI::EditBox::setText const String text  ) 
 

Sets the text.

const String& MAUI::EditBox::getText  )  const
 

Returns the text.

void MAUI::EditBox::setInputMode InputMode  inputMode  ) 
 

Selects the input mode.

InputMode MAUI::EditBox::getInputMode  )  const
 

Returns the input mode

void MAUI::EditBox::setEnabled bool  enabled = true  )  [virtual]
 

Set Widget enabled state

Reimplemented from MAUI::Widget.

void MAUI::EditBox::addEditBoxListener EditBoxListener ebl  ) 
 

void MAUI::EditBox::setCaseToggle bool  caseToggle = true  ) 
 

void MAUI::EditBox::setPasswordMode bool  enabled = true  ) 
 

Sets password mode. Finished characters will be rendered only as asterisks (*).

void MAUI::EditBox::setQwerty bool  enabled = true  ) 
 

bool MAUI::EditBox::getQwerty  )  const
 

void MAUI::Label::setMultiLine bool  b = true  )  [inherited]
 

Turns multiline mode on or off

bool MAUI::Label::isMultiLine  )  [inherited]
 

Returns whether multiline is enabled or not

void MAUI::Label::setHorizontalAlignment HorizontalAlignment  alignment  )  [inherited]
 

Controls the horizontal alignment of the labels text.

void MAUI::Label::setVerticalAlignment VerticalAlignment  alignment  )  [inherited]
 

Controls the horizontal alignment of the labels text.

void MAUI::Label::setFont Font font  )  [inherited]
 

Sets the font used to render text on the label

void MAUI::Label::setAutoSizeX bool  f = true  )  [inherited]
 

When this is set to true the label will automatically be resized in the horizontal axis to perfectly fit the text. Then only new line characters in the label string will line break the text.

void MAUI::Label::setAutoSizeY bool  f = true  )  [inherited]
 

When this is set to true the label will automatically be resized in the vertical axis to perfectly fit the text.

const String& MAUI::Label::getCaption  )  const [inherited]
 

Returns the text displayed on the label

Font* MAUI::Label::getFont  )  const [inherited]
 

Returns the font used by this label

HorizontalAlignment MAUI::Label::getHorizontalAlignment  )  const [inherited]
 

Returns the horizontal alignment of the label

VerticalAlignment MAUI::Label::getVerticalAlignment  )  const [inherited]
 

Returns the vertical alignment of the label

bool MAUI::Label::getAutoSizeX  )  const [inherited]
 

Returns wether the label automatically adjusts its width to accomodate its caption

bool MAUI::Label::getAutoSizeY  )  const [inherited]
 

Returns wether the label automatically adjusts its height to acommodate its caption

void MAUI::Label::setPaddingLeft int  l  )  [virtual, inherited]
 

Set left padding width.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingTop int  t  )  [virtual, inherited]
 

Set top padding height.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingRight int  r  )  [virtual, inherited]
 

Set right padding width.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingBottom int  b  )  [virtual, inherited]
 

Set bottom padding height.

Reimplemented from MAUI::Widget.

virtual void MAUI::Label::setParameter const String name,
const String value
[virtual, inherited]
 

Reimplemented from MAUI::Widget.

void MAUI::Label::update  )  [virtual, inherited]
 

Reimplemented from MAUI::Widget.

void MAUI::Label::getTextStart int *  x,
int *  y
[protected, inherited]
 

void MAUI::Label::resize int  width,
int  height
[protected, inherited]
 

void MAUI::Label::calcStrSize  )  [protected, inherited]
 

virtual void MAUI::Widget::add Widget w  )  [virtual, inherited]
 

Function used to add childs to a widget. The parent of the children will automatically be set. The widget cannot have a parent already.

Reimplemented in MAUI::Layout, and MAUI::ListBox.

void MAUI::Widget::setParent Widget w  )  [inherited]
 

Function used to set the parent of a widget. The widget will not be added to the parent as a child. The widget cannot have a parent already.

Widget* MAUI::Widget::getParent  )  [inherited]
 

Function to retrieve the parent of a widget.

Vector<Widget*>& MAUI::Widget::getChildren  )  [inherited]
 

Function to retrieve a reference to the list of childrens for a widget.

const Vector<Widget*>& MAUI::Widget::getChildren  )  const [inherited]
 

const version of getChildren()

virtual void MAUI::Widget::draw bool  forceDraw = false  )  [virtual, inherited]
 

Renders the Widget and all its children recursively.

Reimplemented in MAUI::ListBox.

void MAUI::Widget::requestRepaint  )  [inherited]
 

Registers an idle listener with the current environment that will redraw the widget and anything else that may be made dirty by doing so. For instance, if the widget is transparent its parent also has to be repainted, and so on recursively.

virtual bool MAUI::Widget::isTransparent  )  const [virtual, inherited]
 

Returns whether or not the widget is transparent. A widget is transparent if it has a skin that is transparent in the current selection state (selected/unselected) or if it has no solid background color.

virtual void MAUI::Widget::setSkin WidgetSkin widgetSkin  )  [virtual, inherited]
 

Assigns a widget skin to be used during the rendering of the widget. What The skin applies to varies depending on the widget. Labels extend the skin over their entire area, while listboxes apply the skin to each individual item they contain.

void MAUI::Widget::setDrawBackground bool  b = true  )  [inherited]
 

Sets the background drawing state. If b is true, the Widget's background will be drawn - otherwise not. In most cases, the background is either a constant color or a skin.

void MAUI::Widget::setBackgroundColor int  col  )  [inherited]
 

Widget* MAUI::Widget::widgetAt const Point p  )  [inherited]
 

Returns a pointer to the first child widget or deeper descendant, surrounding the point. Returns NULL if no widget is found.

Widget* MAUI::Widget::widgetAt int  x,
int  y
[inherited]
 

virtual void MAUI::Widget::setPosition int  x,
int  y
[virtual, inherited]
 

Sets the widget's position relative to its parent.

Reimplemented in MAUI::Layout.

const Point& MAUI::Widget::getPosition  )  const [inherited]
 

Gets the widget's position relative to its parent.

const Point& MAUI::Widget::getPaddedPosition  )  const [inherited]
 

Gets the widget's padded position relative to its parent.

virtual void MAUI::Widget::setWidth int  width  )  [virtual, inherited]
 

Sets the width of the widget

Reimplemented in MAUI::Layout, MAUI::ListBox, and MAP::MapWidget.

int MAUI::Widget::getWidth  )  const [inherited]
 

Returns the width of the widget

virtual void MAUI::Widget::setHeight int  height  )  [virtual, inherited]
 

Sets the height of the widget

Reimplemented in MAUI::Layout, MAUI::ListBox, and MAP::MapWidget.

int MAUI::Widget::getHeight  )  const [inherited]
 

Returns the height of the widget

virtual const Rect& MAUI::Widget::getBounds  )  [virtual, inherited]
 

Returns a Rect containing the absolute screen position of the widget together with its dimensions.

virtual bool MAUI::Widget::contains const Point p  )  [virtual, inherited]
 

Check if widget surrounds position 'p'.

virtual bool MAUI::Widget::contains int  x,
int  y
[virtual, inherited]
 

Check if widget surrounds position 'x' and 'y'.

bool MAUI::Widget::isSelected  )  const [inherited]
 

Is widget selected?.

bool MAUI::Widget::isEnabled  )  const [inherited]
 

Is Widget enabled ?

virtual void MAUI::Widget::trigger  )  [virtual, inherited]
 

This function is called whenever the widget is "triggered", which is roughly equivalent to having been "clicked" on. However, sice MAUI is independant of input facilities, the more input-neutral concept of triggering is used.

Reimplemented in MAUI::Layout.

void MAUI::Widget::addWidgetListener WidgetListener wl  )  [inherited]
 

Add WidgetListener.

void MAUI::Widget::removeWidgetListener WidgetListener wl  )  [inherited]
 

Remove WidgetListener.

Vector<WidgetListener*>& MAUI::Widget::getWidgetListeners  )  [inherited]
 

returns a reference the the vector of Widget listeners

void MAUI::Widget::setInputManager InputManager inputManager  )  [inherited]
 

Sets the input manager to use for this widget

int MAUI::Widget::getPaddingLeft  )  const [inherited]
 

Get left padding width.

int MAUI::Widget::getPaddingTop  )  const [inherited]
 

Get top padding height.

int MAUI::Widget::getPaddingRight  )  const [inherited]
 

Get right padding width.

int MAUI::Widget::getPaddingBottom  )  const [inherited]
 

Get bottom padding height.

const Rect& MAUI::Widget::getPaddedBounds  )  const [inherited]
 

void MAUI::Widget::drawBackground  )  [protected, inherited]
 

void MAUI::Widget::updateAbsolutePosition  )  [protected, inherited]
 

This function is used to regenerate the absolute positions of each widget in the tree. This is done in a depth first manner where each widget takes the parent absolute position and adds it to their own relative position to calculate their absolute position.

void MAUI::Widget::updateAbsolutePositionChildren int  x,
int  y
[protected, inherited]
 

the recursive function used by updateAbsolutePosition().

void MAUI::Widget::updatePaddedBounds  )  [protected, inherited]
 

Used to recalculate the padded bounds from the global bounds.

bool MAUI::Widget::isDirty  )  const [protected, inherited]
 

Returns the dirty state of the widget, indicating whether it requires to be redrawn or not. When a widget calls requestRepaint(), it's dirty state is set to true. Normally, you shouldn't have to use isDirty() or setDirty() unless possibly when implementing your own widgets.

void MAUI::Widget::setDirty bool  d = true  )  [protected, inherited]
 

Sets the dirty state of the widget.


Member Data Documentation

bool MAUI::Label::mustCalcStrSize [protected, inherited]
 

String MAUI::Label::caption [protected, inherited]
 

String MAUI::Label::cuttedCaption [protected, inherited]
 

Font* MAUI::Label::font [protected, inherited]
 

bool MAUI::Label::autoSizeX [protected, inherited]
 

bool MAUI::Label::autoSizeY [protected, inherited]
 

bool MAUI::Label::multiLine [protected, inherited]
 

HorizontalAlignment MAUI::Label::horizontalAlignment [protected, inherited]
 

VerticalAlignment MAUI::Label::verticalAlignment [protected, inherited]
 

MAExtent MAUI::Label::strSize [protected, inherited]
 

int MAUI::Label::strWidth [protected, inherited]
 

int MAUI::Label::strHeight [protected, inherited]
 

Vector<Widget*> MAUI::Widget::children [protected, inherited]
 

Widget* MAUI::Widget::parent [protected, inherited]
 

Rect MAUI::Widget::bounds [protected, inherited]
 

int MAUI::Widget::relX [protected, inherited]
 

int MAUI::Widget::relY [protected, inherited]
 

bool MAUI::Widget::dirty [protected, inherited]
 

WidgetSkin* MAUI::Widget::skin [protected, inherited]
 

int MAUI::Widget::backColor [protected, inherited]
 

bool MAUI::Widget::shouldDrawBackground [protected, inherited]
 

bool MAUI::Widget::selected [protected, inherited]
 

bool MAUI::Widget::enabled [protected, inherited]
 

Vector<WidgetListener*> MAUI::Widget::widgetListeners [protected, inherited]
 

InputManager* MAUI::Widget::mInputManager [protected, inherited]
 

Rect MAUI::Widget::paddedBounds [protected, inherited]
 

int MAUI::Widget::paddingLeft [protected, inherited]
 

int MAUI::Widget::paddingTop [protected, inherited]
 

int MAUI::Widget::paddingBottom [protected, inherited]
 

int MAUI::Widget::paddingRight [protected, inherited]
 


Generated on Sat Feb 13 00:15:38 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO