Neo  0.5.0
Developer Documentation
Neo2D::Widget Class Referenceabstract

The Widget class contains all information that is common to all GUI widgets. More...

#include <Widget.h>

+ Inheritance diagram for Neo2D::Widget:

Public Member Functions

 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...
 
virtual void draw (Vector2 offset)
 Draws the widget to the canvas it belongs to. More...
 
virtual void update ()=0
 Updates the widget and calls the callback if necessary. 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 Attributes

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

The Widget class contains all information that is common to all GUI widgets.

Every object that resembles a GUI widget has to derive from this class.

Author
Yannick Pflanzer

Constructor & Destructor Documentation

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

Member Function Documentation

void Neo2D::Widget::doCallback ( )

Calls the callback with the user data as an argument.

virtual void Neo2D::Widget::draw ( )
inlinevirtual

Draws the widget to the canvas it belongs to.

See also
Canvas
draw(Vector2 offset)

Reimplemented in Neo2D::Gui::Label, Neo2D::Gui::Window, Neo2D::Gui::ScrollPane, Neo2D::Gui::Container, and Neo2D::Gui::WindowManager.

virtual void Neo2D::Widget::draw ( Vector2  offset)
inlinevirtual
Vector2 Neo2D::Widget::getFlip ( )
inline
float Neo2D::Widget::getFontSize ( )
inline
const char* Neo2D::Widget::getLabel ( )
inline

Gets the currently displayed label a C string.

Returns
The current label.
Vector2 Neo2D::Widget::getOffset ( )
inline
Widget* Neo2D::Widget::getParent ( )
inline
Vector2 Neo2D::Widget::getPosition ( )
inline

Retrieves the current position.

Returns
The current position.
float Neo2D::Widget::getRotation ( )
inline

Retrieves the current rotation.

Returns
The current rotation.
Vector2 Neo2D::Widget::getScale ( )
inline
Vector2 Neo2D::Widget::getSize ( )
inline
const char* Neo2D::Widget::getStaticName ( )
inline
long int Neo2D::Widget::getUserData ( )
inline

Retrieves the user data that will be given to every callback call.

Returns
The user data.
virtual bool Neo2D::Widget::isMouseOver ( )
virtual
bool Neo2D::Widget::isVisible ( )
inline

Returns if the widget is turned visible.

Returns
The boolean value.
void Neo2D::Widget::rotate ( float  value)
inline

Rotates the object.

Parameters
valueThe offset to apply.
void Neo2D::Widget::setCallback ( NEO_CALLBACK_FUNCTION  func)
inline

Sets the callback.

A callback is a function pointer of the type (*CALLBACK_FUNCTION)(long int) and points to a procedure of the form:

/code void someCallback(long int) {} /endcode

Parameters
funcThe function pointer
void Neo2D::Widget::setCallback ( NEO_CALLBACK_FUNCTION  func,
long int  data 
)
inline

Sets the callback and appends user data to it.

The userdata will be the parameter of your custom callback procedure when it gets called.

See also
Widget::setCallback
Parameters
funcThe function pointer
dataThe user data
void Neo2D::Widget::setFlip ( Vector2  flip)
inline

setFlip Flip this Widget

void Neo2D::Widget::setFontSize ( float  s)
inline
void Neo2D::Widget::setLabel ( const char *  l)
inline

Changes the current label of the widget.

Parameters
lThe new label.
void Neo2D::Widget::setOffset ( Vector2  offset)
inline
void Neo2D::Widget::setParent ( Widget w)
inline
void Neo2D::Widget::setPosition ( Vector2  pos)
inline

Changes the widget position.

Parameters
posThe new position.
void Neo2D::Widget::setRotation ( float  rot)
inline

Changes the widget rotation.

Parameters
rotThe new rotation.
void Neo2D::Widget::setScale ( Vector2  scale)
inline

setScale Scale this Widget

Parameters
scaleThe ammount you want to scale with
void Neo2D::Widget::setScriptCallback ( const char *  name)
inline
void Neo2D::Widget::setSize ( unsigned int  w,
unsigned int  h 
)
inline
void Neo2D::Widget::setUserData ( long int  data)
inline

Changes the user data that will be given to every callback call.

Parameters
dataThe new user data.
void Neo2D::Widget::setVisible ( bool  v)
inline

Sets the visibility status.

Parameters
vThe new status
void Neo2D::Widget::translate ( Vector2  vec)
inline

Translates the object.

Parameters
vecThe offset to apply.

Member Data Documentation

NEO_CALLBACK_FUNCTION Neo2D::Widget::m_callback
protected

The callback that should be called.

String Neo2D::Widget::m_callbackScript
protected
Vector2 Neo2D::Widget::m_flip
protected

The flip vector.

float Neo2D::Widget::m_fontSize
protected
unsigned int Neo2D::Widget::m_height
protected
std::string Neo2D::Widget::m_label
protected

The label of the widget.

Vector2 Neo2D::Widget::m_offset
protected

The offset that was used for rendering in the last frame.

Widget* Neo2D::Widget::m_parent
protected
float Neo2D::Widget::m_rotation
protected

The rotation of the widget.

Vector2 Neo2D::Widget::m_scale
protected

The scale vector.

long int Neo2D::Widget::m_userData
protected

Some userdata that is given to the callback.

bool Neo2D::Widget::m_visible
protected

Is the widget visible?

unsigned int Neo2D::Widget::m_width
protected

The width and height of the widget.

float Neo2D::Widget::m_x
protected

The 2D coordinates of the widget.

float Neo2D::Widget::m_y
protected

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