Neo  0.5.0
Developer Documentation
Neo2D::Gui::InputField Class Reference

Implements a basic input field that takes keyboard input and delivers it to the program. More...

#include <InputField.h>

+ Inheritance diagram for Neo2D::Gui::InputField:

Public Member Functions

 InputField (unsigned int x, unsigned int y, unsigned int width, unsigned int height, const char *label)
 
void draw (Vector2 offset)
 Draws the widget to the canvas it belongs to. More...
 
void update ()
 Updates the widget and calls the callback if necessary. More...
 
void setState (INPUT_STATE state)
 
const char * getStaticName ()
 
void setLabel (const char *str)
 
INPUT_TYPE getType ()
 
void setType (INPUT_TYPE t)
 
bool isMultiline ()
 
void setMultiline (bool b)
 
- Public Member Functions inherited from Neo2D::Widget
 Widget (unsigned int x, unsigned int y, unsigned int width, unsigned int height, const char *label)
 
 Widget ()
 
void setParent (Widget *w)
 
WidgetgetParent ()
 
float getFontSize ()
 
void setFontSize (float s)
 
void setOffset (Vector2 offset)
 
Vector2 getOffset ()
 
void setSize (unsigned int w, unsigned int h)
 
Vector2 getSize ()
 
virtual void draw ()
 Draws the widget to the canvas it belongs to. More...
 
void setCallback (NEO_CALLBACK_FUNCTION func)
 Sets the callback. More...
 
void setScriptCallback (const char *name)
 
void setCallback (NEO_CALLBACK_FUNCTION func, long int data)
 Sets the callback and appends user data to it. More...
 
long int getUserData ()
 Retrieves the user data that will be given to every callback call. More...
 
void setUserData (long int data)
 Changes the user data that will be given to every callback call. More...
 
const char * getLabel ()
 Gets the currently displayed label a C string. More...
 
void setLabel (const char *l)
 Changes the current label of the widget. More...
 
void setPosition (Vector2 pos)
 Changes the widget position. More...
 
Vector2 getPosition ()
 Retrieves the current position. More...
 
void setRotation (float rot)
 Changes the widget rotation. More...
 
float getRotation ()
 Retrieves the current rotation. More...
 
void translate (Vector2 vec)
 Translates the object. More...
 
void rotate (float value)
 Rotates the object. More...
 
void doCallback ()
 Calls the callback with the user data as an argument. More...
 
bool isVisible ()
 Returns if the widget is turned visible. More...
 
void setVisible (bool v)
 Sets the visibility status. More...
 
void setScale (Vector2 scale)
 setScale Scale this Widget More...
 
Vector2 getScale ()
 
void setFlip (Vector2 flip)
 setFlip Flip this Widget More...
 
Vector2 getFlip ()
 
const char * getStaticName ()
 
virtual bool isMouseOver ()
 

Protected Member Functions

void updateLabel (string s)
 
Vector2 calculateCursorPos (OText *text, int pos=-1)
 Calculates the full width of the given text object. More...
 
void addChar (unsigned int c)
 

Protected Attributes

OTextm_labelText
 
INPUT_STATE m_state
 
unsigned int m_cursorpos
 
INPUT_TYPE m_inputType
 
bool m_multiline
 
- Protected Attributes inherited from Neo2D::Widget
float m_x
 The 2D coordinates of the widget. More...
 
float m_y
 
float m_rotation
 The rotation of the widget. More...
 
unsigned int m_width
 The width and height of the widget. More...
 
unsigned int m_height
 
std::string m_label
 The label of the widget. More...
 
Vector2 m_offset
 The offset that was used for rendering in the last frame. More...
 
NEO_CALLBACK_FUNCTION m_callback
 The callback that should be called. More...
 
String m_callbackScript
 
long int m_userData
 Some userdata that is given to the callback. More...
 
bool m_visible
 Is the widget visible? More...
 
Vector2 m_scale
 The scale vector. More...
 
Vector2 m_flip
 The flip vector. More...
 
float m_fontSize
 
Widgetm_parent
 

Detailed Description

Implements a basic input field that takes keyboard input and delivers it to the program.

Author
Yannick Pflanzer

Constructor & Destructor Documentation

Neo2D::Gui::InputField::InputField ( unsigned int  x,
unsigned int  y,
unsigned int  width,
unsigned int  height,
const char *  label 
)

Member Function Documentation

void Neo2D::Gui::InputField::addChar ( unsigned int  c)
protected
Vector2 Neo2D::Gui::InputField::calculateCursorPos ( OText text,
int  pos = -1 
)
protected

Calculates the full width of the given text object.

Parameters
textThe text object to operate on.
Returns
The full width in pixels
void Neo2D::Gui::InputField::draw ( Vector2  offset)
virtual

Draws the widget to the canvas it belongs to.

Parameters
offsetThe offset to apply to the position. Used for emulating a camera.
See also
Canvas

Reimplemented from Neo2D::Widget.

Reimplemented in Neo2D::Gui::ThemedInputField.

const char* Neo2D::Gui::InputField::getStaticName ( )
inline
INPUT_TYPE Neo2D::Gui::InputField::getType ( )
inline
bool Neo2D::Gui::InputField::isMultiline ( )
inline
void Neo2D::Gui::InputField::setLabel ( const char *  str)
inline
void Neo2D::Gui::InputField::setMultiline ( bool  b)
inline
void Neo2D::Gui::InputField::setState ( INPUT_STATE  state)
inline
void Neo2D::Gui::InputField::setType ( INPUT_TYPE  t)
inline
void Neo2D::Gui::InputField::update ( )
virtual

Updates the widget and calls the callback if necessary.

Implements Neo2D::Widget.

void Neo2D::Gui::InputField::updateLabel ( string  s)
protected

Member Data Documentation

unsigned int Neo2D::Gui::InputField::m_cursorpos
protected
INPUT_TYPE Neo2D::Gui::InputField::m_inputType
protected
OText* Neo2D::Gui::InputField::m_labelText
protected
bool Neo2D::Gui::InputField::m_multiline
protected
INPUT_STATE Neo2D::Gui::InputField::m_state
protected

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