This page has been translated automatically.
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
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::Widget Class

Interface for widget handling. See also UnigineScript analog.

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

Unigine::Widget Class

Members


virtual ~Widget ()

Virtual destructor.

virtual void grab () =0

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

virtual void release () =0

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

virtual int isOwner () const =0

Returns the owner flag. If the pointer is the owner, on its deletion the object also will be deleted. Use grab() and release() functions to change ownership.

Return value

Returns the owner flag.

virtual Ptr< Widget > getWidget () const =0

Returns a widget pointer.

Return value

Widget pointer.

virtual int getType () const =0

Returns a type of the widget.

Return value

Widget type identifier.

virtual const char * getTypeName () const =0

Returns a name of the widget type.

Return value

Widget type name.

virtual Ptr< Gui > getGui () const =0

Returns the Gui smart pointer.

Return value

Gui smart pointer.

virtual Ptr< Gui > getParentGui () const =0

Returns the parent Gui smart pointer.

Return value

Parent Gui smart pointer.

virtual void setParent (const Ptr< Widget > & widget) const =0

Sets a parent widget for the current one.

Arguments

  • const Ptr< Widget > & widget - Parent widget to set.

virtual Ptr< Widget > getParent () const =0

Returns the pointer to the parent widget.

Return value

Parent widget smart pointer.

virtual void setFlags (int Widget) const =0

Sets widget flags.

Arguments

  • int Widget - flags.

virtual int getFlags () const =0

Returns widget flags.

Return value

Widget flags: one of the Unigine::Gui:: Enumeration with ALIGN_* prefixes. This is an optional parameter.

virtual void setEnabled (int enable) const =0

Enables or disables the widget.

Arguments

  • int enable - 1 to enable the widget, 0 to disable it.

virtual int isEnabled () const =0

Returns a value indicating if the widget is enabled.

Return value

Returns 1 if the widget is disabled; otherwise, 0.

virtual void setHidden (int hidden) const =0

Hides or shows the widget.

Arguments

  • int hidden - 1 to show the widget, 0 to hide it.

virtual int isHidden () const =0

Returns a value indicating if the widget is hidden.

Return value

Return 1 if the widget is hidden; otherwise, 0.

virtual void setOrder (int order) const =0

Sets rendering order for the widget.

Arguments

  • int order - Rendering order in range [-128;127].

virtual int getOrder () const =0

Returns rendering order for the widget.

Return value

Rendering order.

virtual void setData (const char * User) const =0

Sets user data associated with the widget.

Arguments

  • const char * User - string data. Data can be an xml formatted string.

virtual const char * getData () const =0

Returns user data associated with the widget.

Return value

User string data. Data can be an xml formatted string.

virtual void setFocus () const =0

Sets focus on the widget.

virtual void setPermanentFocus () const =0

Sets permanent focus on the widget (it means that the widget is always in focus).

virtual void removeFocus () const =0

Removes focus from the widget.

virtual int isFocused () const =0

Returns a value indicating if the widget is in focus.

Return value

1 if the widget is in focus; otherwise, 0.

virtual void setPosition (int x, int y) const =0

Sets a position of the widget relative to its parent.

Arguments

  • int x - X coordinate of the upper left corner of the widget.
  • int y - Y coordinate of the upper left corner of the widget.

virtual int getPositionX () const =0

Returns the x coordinate of the widget position relative to its parent.

Return value

Relative X coordinate.

virtual int getPositionY () const =0

Returns the y coordinate of the widget position relative to its parent.

Return value

Relative Y coordinate.

virtual int getScreenPositionX () const =0

Returns the screen position of the widget on the screen along the X axis.

Return value

Screen position along the X axis in pixels.

virtual int getScreenPositionY () const =0

Returns the screen position of the widget on the screen along the Y axis.

Return value

Screen position along the Y axis.

virtual void setWidth (int width) const =0

Sets minimal width of the widget in pixels.

Arguments

  • int width - Widget minimal width. If a negative value is provided, the 0 will be used instead.

virtual int getWidth () const =0

Returns the current widget width in pixels.

Return value

Widget width in pixels.

virtual void setHeight (int height) const =0

Sets minimal height of the widget in pixels.

Arguments

  • int height - Widget minimal height. If a negative value is provided, the 0 will be used instead.

virtual int getHeight () const =0

Returns the current widget height in pixels.

Return value

Widget height in pixels.

virtual int getIntersection (int x, int y) const =0

Check the intersection with widget bounds.

Arguments

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

Return value

Returns 1 if the input coordinate is inside the widget; otherwise, 0.

virtual int getMouseX () const =0

Returns the X coordinate of the mouse pointer position.

Return value

X coordinate of the mouse pointer position.

virtual int getMouseY () const =0

Returns the Y coordinate of the mouse pointer position.

Return value

Y coordinate of the mouse pointer position.

virtual void setMouseCursor (int cursor) const =0

Sets a mouse pointer to display.

Arguments

  • int cursor - Mouse pointer. See the list of available pointers with CURSOR_* prefixes in the article on Gui class functions.

virtual int getMouseCursor () const =0

Returns the current mouse pointer.

Return value

Mouse pointer. One of the available pointers with CURSOR_* prefixes described in the article on Gui class functions.

virtual void setFont (const char * name) const =0

Sets a font that will be used to render text on the widget.

Arguments

  • const char * name - Path to the font file (*.ttf).

virtual void setFontSize (int size) const =0

Sets a font size that will be used to render text on the widget.

Arguments

  • int size - Font size in pixels.

virtual int getFontSize () const =0

Returns the size of the font used by the widget.

Return value

Font size.

virtual void setFontColor (const vec4 & color) const =0

Sets a font color that will be used to render text on the widget.

Arguments

  • const vec4 & color - Font color.

virtual vec4 getFontColor () const =0

Returns the color of the font used by the widget.

Return value

Font color.

virtual void setFontPermanent (int permanent) const =0

Sets a flag to prevent color change for the widget text (for example, when the widget becomes non-active or loses focus).

Arguments

  • int permanent - 1 not to change text color; 0 to change it.

virtual int getFontPermanent () const =0

Returns a flag indicating if color of the widget text is not changed (for example, when the widget becomes non-active or loses focus).

Return value

1 if color of the widget text is not changed; otherwise, 0.

virtual void setFontHSpacing (int spacing) const =0

Sets the spacing (in pixels) between widget text characters.

Arguments

  • int spacing - Horizontal spacing value.

virtual int getFontHSpacing () const =0

Returns the spacing (in pixels) between widget text characters.

Return value

Horizontal spacing value.

virtual void setFontVSpacing (int spacing) const =0

Sets the spacing (in pixels) between widget text lines.

Arguments

  • int spacing - Vertical spacing value.

virtual int getFontVSpacing () const =0

Returns the spacing (in pixels) between widget text lines.

Return value

Vertical spacing value.

virtual void setFontHOffset (int offset) const =0

Sets the horizontal offset of the font used by the widget.

Arguments

  • int offset - Horizontal offset value in pixels.

virtual int getFontHOffset () const =0

Returns the horizontal offset of the font used by the widget.

Return value

Horizontal offset value in pixels.

virtual void setFontVOffset (int offset) const =0

Sets the vertical offset of the font used by the widget.

Arguments

  • int offset - Vertical offset value in pixels.

virtual int getFontVOffset () const =0

Returns the vertical offset of the font used by the widget.

Return value

Vertical offset value in pixels.

virtual void setFontOutline (int outline) const =0

Sets a value indicating if widget text should be rendered casting a shadow. Positive or negative values set the distance in pixels to offset the font outline. The default is 0 (no outlining).

Arguments

  • int outline - Outline offset:
    • Positive values set offset in the bottom-right corner direction.
    • Negative values set offset in the top-left corner direction (the outline will overlap widget text).
    • 0 is not to use font outlining.

virtual int getFontOutline () const =0

Returns a value indicating if widget text is rendered casting a shadow. Positive or negative values determine the distance in pixels used to offset the font outline.

Return value

Positive value if outline is offset in the bottom-right corner direction. Negative value if outline is offset in the top-left corner direction. 0 if font is not outlined.

virtual void setFontRich (int rich) const =0

Sets a value indicating if rich text formatting should be used. The default is 0.

Arguments

  • int rich - 1 to use rich text formatting, 0 to use plain text formatting.

virtual int getFontRich () const =0

Returns a value indicating if rich text formatting is used.

Return value

1 if rich text formatting is used; otherwise, 0.

virtual void setFontWrap (int wrap) const =0

Enables or disables text wrapping to widget width. The default is 0.

Arguments

  • int wrap - 1 to enable text wrapping, 0 to disable it.

virtual int getFontWrap () const =0

Returns a value indicating if text wrapping to widget width is enabled.

Return value

1 if text wrapping is enabled; otherwise, 0.

virtual void setToolTip (const char * str, int reset) const =0

Sets a tooltip used for the widget.

Arguments

  • const char * str - Tooltip text.
  • int reset - 1 to recalculate a tooltip position under the mouse cursor; otherwise, 0 (by default).

virtual const char * getToolTip () const =0

Returns the widget tooltip text.

Return value

Tooltip text.

virtual void setCallback0 (int callback, CallbackBase * func) const =0

Sets a 0-argument callback function for the widget.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • CallbackBase * func - Callback pointer. Callback arguments must be in the following format: (argument1,argument2,...).

virtual void setCallback1 (int callback, CallbackBase * func) const =0

Sets a 1-argument callback function for the widget.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • CallbackBase * func - Callback pointer. Callback arguments must be in the following format: (WidgetPtr,argument1,argument2,...).

virtual void setCallback2 (int callback, CallbackBase * func) const =0

Sets a 2-argument callback function for the widget.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • CallbackBase * func - Callback pointer. Callback arguments must be in the following format: (WidgetPtr,WidgetPtr,argument1,argument2,...).

virtual void setCallback3 (int callback, CallbackBase * func) const =0

Sets a 3-argument callback function for the widget.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • CallbackBase * func - Callback pointer. Callback arguments must be in the following format: (WidgetPtr,WidgetPtr,data,argument1,argument2,...).

virtual void setCallbackAccel (int callback, unsigned int key, int ctrl, int alt, int shift) const =0

Assigns a hot key combination to a given callback function.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • unsigned int key - ASCII key code: one of the Unigine::App:: Enumeration with KEY_* prefixes.
  • int ctrl - CTRL key modifier.
  • int alt - ALT key modifier.
  • int shift - SHIFT key modifier.

virtual void getCallbackAccel (int callback, unsigned int & key, int & ctrl, int & alt, int & shift) const =0

Returns the current hot key combination for a given callback function.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • unsigned int & key - ASCII key code: one of the Unigine::App:: Enumeration with KEY_* prefixes.
  • int & ctrl - CTRL key modifier.
  • int & alt - ALT key modifier.
  • int & shift - SHIFT key modifier.

virtual void setCallbackEnabled (int callback, int enable) const =0

Enables or disables a given callback function.

Arguments

  • int callback - Callback number: one of the Unigine::Gui:: Enumeration (for example, SHOW, HIDE, etc).
  • int enable - 1 to enable the callback, 0 to disable it.

virtual int isCallbackEnabled (int callback) const =0

Returns a value indicating if a given callback is enabled.

Arguments

Return value

Returns 1 if the callback is disabled; otherwise, 0.

virtual void runCallback (int callback) const =0

Runs a given callback function.

Arguments

virtual void addAttach (const Ptr< Widget > & widget, const char * format, int multiplier, int flags) const =0

Attaches a given widget to the current one. When applied to checkboxes, converts them into a group of radio buttons. A horizontal/vertical slider can be attached to a label or a text field. The text field can be attached to any of the sliders.

Arguments

  • const Ptr< Widget > & widget - Widget to attach.
  • const char * format - Format string or values entered into the attached widget. If none specified, "%d" is implied. This is an optional parameter.
  • int multiplier - Multiplier value, which is used to scale values provided by the attached widget. This is an optional parameter.
  • int flags - Attachment flags: one of the Unigine::Gui:: Enumeration with ATTACH_* prefixes. This is an optional parameter.

virtual void removeAttach (const Ptr< Widget > & widget) const =0

Detaches a given widget from the current one.

Arguments

  • const Ptr< Widget > & widget - Widget to detach.

virtual void addChild (const Ptr< Widget > & widget, int flags) const =0

Adds a child to the widget.

Arguments

  • const Ptr< Widget > & widget - Widget smart pointer.
  • int flags - Widget flags: one of the Unigine::Gui:: Enumeration with ALIGN_* prefixes. This is an optional parameter.

virtual void removeChild (const Ptr< Widget > & widget) const =0

Removes a child widget from the list of children of the current widget.

Arguments

  • const Ptr< Widget > & widget - Child widget smart pointer.

virtual void replaceChild (const Ptr< Widget > & widget, const Ptr< Widget > & old_widget, int flags) const =0

Replaces a child widget from the list of children with another one.

Arguments

  • const Ptr< Widget > & widget - New child widget smart pointer.
  • const Ptr< Widget > & old_widget - Child widget to replace.
  • int flags - Widget flags: one of the Unigine::Gui:: Enumeration with ALIGN_* prefixes. This is an optional parameter.

virtual int isChild (const Ptr< Widget > & widget) const =0

Checks if a given widget is a child of the current widget.

Arguments

  • const Ptr< Widget > & widget - Widget to check.

Return value

Returns 1 if the given widget is a child; otherwise, 0.

virtual int getNumChilds () const =0

Returns the number of child widgets.
Warning
The function is deprecated. It is provided to keep your code working until the next release. Please, replace it with getNumChildren().

Return value

Number of child widgets.

virtual int getNumChildren () const =0

Returns the number of child widgets.

Return value

Number of child widgets.

virtual Ptr< Widget > getChild (int num) const =0

Returns the widget child by its number.

Arguments

  • int num - Number of the child widget.

Return value

Pointer to the child widget.

virtual int getKeyActivity (unsigned int key) const =0

Checks if a given key already has a special purpose for the widget.

Arguments

Return value

1 if the key cannot be used; otherwise, 0.

virtual void raise (const Ptr< Widget > & widget) const =0

Brings a given widget to the top.

Arguments

  • const Ptr< Widget > & widget - Widget to raise.

virtual void arrange () const =0

Rearranges the widget size.
Last update: 2017-07-03
Build: ()