Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins

Unigine::WidgetExternBase Class

Unigine Base WidgetExtern class.

To use this class, include the UnigineWidgetExtern.h file.

Unigine::WidgetExternBase Class

Members


ConstructorFunc Type Definition

Description

Full declaration:
typedef WidgetExternBase*(* Unigine::WidgetExternBase::ConstructorFunc)(void *widget)

WidgetExternBase constructor functor.

Arguments

widget - WidgetExtern pointer.

Return value

WidgetExternBase class.

WidgetExternBase (const Ptr< Gui > & gui)

WidgetExternBase constructor.

Arguments

  • const Ptr< Gui > & gui - Gui smart pointer.

WidgetExternBase (void * widget)

WidgetExternBase constructor.

Arguments

  • void * widget - Pointer to an external widget.

virtual ~WidgetExternBase ()

Virtual destructor.

void grab () const

Sets the owner flag to 1 for the widget pointer. The widget should not be handled by the class after this function is called.

void release () const

Sets the owner flag to 0 for the widget pointer. The widget should be handled by the class after this function is called.

int isOwner () const

Returns the owner flag of the pointer. If the pointer is owner, on its deletion the object also will be deleted.

Return value

The owner flag.

virtual int getClassID () =0

Returns a unique class ID.

Return value

Unique class ID.

Ptr< Gui > getGui () const

Returns the Gui smart pointer.

Return value

Gui smart pointer.

Ptr< Widget > getWidget () const

Returns the Widget smart pointer.

Return value

Widget smart pointer.

Ptr< WidgetExtern > getWidgetExtern () const

Returns the WidgetExtern smart pointer.

Return value

WidgetExtern smart pointer.

virtual void update (float ifps)

Widget update function.

Arguments

  • float ifps - Inverse FPS value.

virtual void checkCallbacks (int x, int y)

Checks widget callbacks.

Arguments

  • int x - Mouse X coordinate.
  • int y - Mouse Y coordinate.

virtual void keyPress (unsigned int key)

Keyboard press event.

Arguments

  • unsigned int key - Key code.

virtual int getKeyActivity (unsigned int key)

Checks the keyboard key.

Arguments

  • unsigned int key - Key code.

Return value

Returns 1 if the key is used by widget.

virtual void arrange ()

Calculates the widget size.

virtual void expand (int width, int height)

Expands the widget size.

Arguments

  • int width - Maximum available width.
  • int height - Maximum available height.

virtual void destroy ()

Destroys the widget resources.

virtual void render ()

Renders the widget.

static void addClassID (int class_id, ConstructorFunc func)

Registers a constructor for a specified class ID.

Arguments

  • int class_id - Unique class ID.
  • ConstructorFunc func - Constructor functor.

static void addClassID (int class_id)

Registers a constructor for a specified class type.

Arguments

  • int class_id - Unique class ID.

int get_position_x () const

Returns the current widget X coordinate.

int get_position_y () const

Returns the current widget Y coordinate.

int get_default_width () const

Returns the default widget width.

int get_default_height () const

Returns the default widget height.

void set_width (int width) const

Sets the widget width.

Arguments

  • int width - Widget width.

int get_width () const

Returns the widget width.

Return value

Widget width.

void set_height (int height) const

Sets the widget height.

Arguments

  • int height - Widget height.

int get_height () const

Returns the widget height.

Return value

Widget height.

void check_default_callbacks (int x, int y) const

Checks default widget callbacks.

Arguments

  • int x - Mouse X coordinate.
  • int y - Mouse Y coordinate.

void check_clicked_callbacks (int x, int y) const

Checks clicked widget callbacks.

Arguments

  • int x - Mouse X coordinate.
  • int y - Mouse Y coordinate.

void check_pressed_callbacks (int x, int y) const

Checks pressed widget callbacks.

Arguments

  • int x - Mouse X coordinate.
  • int y - Mouse Y coordinate.

float get_expose () const

Returns the expose widget coefficient.

Return value

Expose widget coefficient.

float get_clicked_fade () const

Returns the clicked fade coefficient.

Return value

Clicked fade coefficient.

float get_selection_fade () const

Returns the selection fade coefficient.

Return value

Selection fade coefficient.

vec4 get_color (int enabled) const

Returns the color of the widget. If the widget is disabled, the standard alpha value of the widget is multiplied by the alpha value of a disabled widget.

Arguments

  • int enabled - Value indicating if the widget is enabled. By default, the widget is enabled.

Return value

Color.

vec4 get_focus_color (float fade, int enabled) const

Returns the color of the focused widget. The alpha value of the focused widget is multiplied by the fade coefficient.

Arguments

  • float fade - Fade coefficient of the color during widget animation.
  • int enabled - Value indicating if the widget is enabled. By default, the widget is enabled.

Return value

Color of the focused widget if it is enabled; otherwise, (0 0 0 0) vector is returned.

vec4 get_selection_color (float fade, int enabled) const

Returns the color of the selected widget.

Arguments

  • float fade - Fade coefficient of the color during widget animation.
  • int enabled - Value indicating if the widget is enabled. By default, the widget is enabled.

Return value

Color of the selected widget.

vec4 get_text_color (const vec4 & color, float fade, int enabled) const

Returns the color of the widget text.

Arguments

  • const vec4 & color - Target text color.
  • float fade - Fade coefficient of the color during widget animation.
  • int enabled - Value indicating if the widget is enabled. By default, the widget is enabled.

Return value

Font color.

vec4 get_text_color (float fade, int enabled) const

Returns the color of the widget text. The default font color is used as the target color.

Arguments

  • float fade - Fade coefficient of the color during widget animation.
  • int enabled - Value indicating if the widget is enabled. By default, the widget is enabled.

Return value

Font color.

int get_text_height () const

Returns the height of the widget text.

Return value

Text height.

int get_text_width (unsigned int code) const

Returns the width of the given symbol.

Arguments

  • unsigned int code - Symbol code.

Return value

Symbol width.

int get_text_space_width () const

Returns the width of the space.

Return value

Space width.

void get_text_size (const char * str, int & width, int & height, int expand) const

Returns the minimal width and height of the given text.
  • If the expand is 0, the width of the text will change depending on the widget width.
  • If the expand is 1, the width of the text won't change depending on the widget width.

Arguments

  • const char * str - Widget text.
  • int & width - Text width.
  • int & height - Text height.
  • int expand - Value indicating if the widget is justified in the available space. By default, the widget is not justified.

void render_text (int x, int y, const vec4 & color, const char * str, int width, int height) const

Renders the text of the given color in the area of the given width and height in the given position.

Arguments

  • int x - Text position relative to the upper left corner along the X axis.
  • int y - Text position relative to the upper left corner along the Y axis.
  • const vec4 & color - Text color.
  • const char * str - Text.
  • int width - Width of the area which will be used for rendering of the wrapped or rich text.
  • int height - Height of the area which will be used for rendering of the wrapped or rich text.

void get_text_size (const unsigned int * str, int & width, int & height) const

Returns the minimal width and height of the given text.

Arguments

  • const unsigned int * str - Widget text.
  • int & width - Text width.
  • int & height - Text height.

void render_text (int x, int y, const vec4 & color, const unsigned int * str) const

Renders the text of the given color with the given offset along the X and Y axes.

Arguments

  • int x - Text offset along the X axis.
  • int y - Text offset along the Y axis.
  • const vec4 & color - Text color.
  • const unsigned int * str - Text.

void push_color () const

Pushes the color multiplier stack.

void pop_color () const

Pops the color multiplier stack.

void set_color (const vec4 & color) const

Sets the color multiplier.

Arguments

  • const vec4 & color - Color multiplier.

void push_transform () const

Pushes the transformations stack.

void pop_transform () const

Pops the transformations stack.

void set_transform (const mat4 & transform) const

Sets the transformation matrix.

Arguments

  • const mat4 & transform - Transformation matrix.

void set_translate (int x, int y) const

Sets the translate transformation.

Arguments

  • int x - X axis translation.
  • int y - Y axis translation.

void set_scale (float x, float y) const

Sets the scale transformation.

Arguments

  • float x - X axis scale.
  • float y - Y axis scale.

void set_blend_func (int src, int dest) const

Sets the blending function.

Arguments

  • int src - Source blending function.
  • int dest - Destination blending function.
Last update: 2017-07-03