Neo
0.5.0
Developer Documentation
|
The Widget class contains all information that is common to all GUI widgets. More...
#include <Widget.h>
Public Member Functions | |
Widget (unsigned int x, unsigned int y, unsigned int width, unsigned int height, const char *label) | |
Widget () | |
void | setParent (Widget *w) |
Widget * | getParent () |
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 |
Widget * | m_parent |
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.
Neo2D::Widget::Widget | ( | unsigned int | x, |
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height, | ||
const char * | label | ||
) |
Neo2D::Widget::Widget | ( | ) |
void Neo2D::Widget::doCallback | ( | ) |
Calls the callback with the user data as an argument.
|
inlinevirtual |
Draws the widget to the canvas it belongs to.
Reimplemented in Neo2D::Gui::Label, Neo2D::Gui::Window, Neo2D::Gui::ScrollPane, Neo2D::Gui::Container, and Neo2D::Gui::WindowManager.
|
inlinevirtual |
Draws the widget to the canvas it belongs to.
offset | The offset to apply to the position. Used for emulating a camera. |
Reimplemented in Neo2D::Gui::TreeView, Neo2D::Sprite, Neo2D::Tile, Neo2D::Gui::Label, Neo2D::Gui::InputField, Neo2D::Gui::Slider, Neo2D::Gui::CheckButton, Neo2D::Gui::ScrollBar, Neo2D::Gui::Button, Neo2D::Gui::MenuBar, Neo2D::Gui::List, Neo2D::Gui::ThemedButton, Neo2D::Gui::ThemedInputField, Neo2D::Gui::Menu, Neo2D::Gui::Window, Neo2D::Gui::ScrollPane, and Neo2D::Gui::Container.
|
inline |
|
inline |
|
inline |
Gets the currently displayed label a C string.
|
inline |
|
inline |
|
inline |
Retrieves the current position.
|
inline |
Retrieves the current rotation.
|
inline |
|
inline |
|
inline |
|
inline |
Retrieves the user data that will be given to every callback call.
|
virtual |
Reimplemented in Neo2D::Gui::MenuBar, Neo2D::Gui::Window, and Neo2D::Gui::WindowManager.
|
inline |
Returns if the widget is turned visible.
|
inline |
Rotates the object.
value | The offset to apply. |
|
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
func | The function pointer |
|
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.
func | The function pointer |
data | The user data |
|
inline |
|
inline |
Changes the current label of the widget.
l | The new label. |
|
inline |
|
inline |
|
inline |
Changes the widget position.
pos | The new position. |
|
inline |
Changes the widget rotation.
rot | The new rotation. |
|
inline |
setScale Scale this Widget
scale | The ammount you want to scale with |
|
inline |
|
inline |
|
inline |
Changes the user data that will be given to every callback call.
data | The new user data. |
|
inline |
Sets the visibility status.
v | The new status |
|
inline |
Translates the object.
vec | The offset to apply. |
|
pure virtual |
Updates the widget and calls the callback if necessary.
Implemented in Neo2D::Gui::TreeView, Neo2D::Sprite, Neo2D::Tile, Neo2D::Gui::Label, Neo2D::Gui::InputField, Neo2D::Gui::Slider, Neo2D::Gui::CheckButton, Neo2D::Gui::ScrollBar, Neo2D::Gui::Button, Neo2D::Gui::MenuBar, Neo2D::Gui::List, Neo2D::Gui::ThemedButton, Neo2D::Gui::Menu, Neo2D::Gui::Window, Neo2D::Gui::ScrollPane, Neo2D::Gui::Container, Neo2D::Gui::WindowManager, and Neo2D::Gui::ScaleLayout.
|
protected |
The callback that should be called.
|
protected |
|
protected |
The flip vector.
|
protected |
|
protected |
|
protected |
The label of the widget.
|
protected |
The offset that was used for rendering in the last frame.
|
protected |
|
protected |
The rotation of the widget.
|
protected |
The scale vector.
|
protected |
Some userdata that is given to the callback.
|
protected |
Is the widget visible?
|
protected |
The width and height of the widget.
|
protected |
The 2D coordinates of the widget.
|
protected |