Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Core Library
Containers
Engine Classes
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes

Widget Class

Interface for widget handling. See also UnigineScript analog.

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

Widget Class

Members


Ptr<Gui> getParentGui ()

Returns the parent Gui smart pointer.

Return value

Parent Gui smart pointer.

void setHeight (int height)

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.

int getMouseY ()

Returns the Y coordinate of the mouse pointer position.

Return value

Y coordinate of the mouse pointer position.

int getWidth ()

Returns the current widget width in pixels.

Return value

Widget width in pixels.

int getPositionY ()

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

Return value

Relative Y coordinate.

int isHidden ()

Returns a value indicating if the widget is hidden.

Return value

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

int getScreenPositionY ()

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

Return value

Screen position along the Y axis.

int getFontOutline ()

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.

void setFontColor (const Math::vec4 & color)

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

Arguments

  • const Math::vec4 & color - Font color.

int getType ()

Returns a type of the widget.

Return value

Widget type identifier.

int getFontVSpacing ()

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

Return value

Vertical spacing value.

void addAttach (const Ptr<Widget> & w, const char * format = 0, int multiplier = 1, int flags = 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> & w - 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 Gui:: Enumeration with ATTACH_* prefixes. This is an optional parameter.

int getKeyActivity (unsigned int key)

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.

void setFontSize (int size)

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

Arguments

  • int size - Font size in pixels.

int getFontHSpacing ()

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

Return value

Horizontal spacing value.

int getFontVOffset ()

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

Return value

Vertical offset value in pixels.

void runCallback (int callback)

Runs a given callback function.

Arguments

  • int callback - Callback number: one of the Gui:: Enumeration (for example, SHOW, HIDE, etc).

void setPosition (int x, int y)

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.

int getMouseCursor ()

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.

void setData (const char * data)

Sets user data associated with the widget.

Arguments

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

Ptr<Widget> getParent ()

Returns the pointer to the parent widget.

Return value

Parent widget smart pointer.

void setFontVOffset (int voffset)

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

Arguments

  • int voffset - Vertical offset value in pixels.

void setFont (const char * name)

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

Arguments

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

int getMouseX ()

Returns the X coordinate of the mouse pointer position.

Return value

X coordinate of the mouse pointer position.

void getCallbackAccel (int callback, unsigned int & key, int & ctrl, int & alt, int & shift)

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

Arguments

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

void setFontRich (int rich)

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.

void removeFocus ()

Removes focus from the widget.

int getFontWrap ()

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

Return value

1 if text wrapping is enabled; otherwise, 0.

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

Adds a child to the widget.

Arguments

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

int isCallbackAccel (unsigned int key, int ctrl, int alt, int shift)

Checks if the a given key in combination with CTRL, ALT or/and SHIFT buttons is assigned as a widget callback.

Arguments

  • unsigned int key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.
  • int ctrl - 1 if the CTRL key modifier is used; otherwise, 0.
  • int alt - 1 if the ALT key modifier is used; otherwise, 0.
  • int shift - 1 if the SHIFT key modifier is used; otherwise, 0.

Return value

1 if it is used in combinations; otherwise, 0.

int getFontSize ()

Returns the size of the font used by the widget.

Return value

Font size.

int getHeight ()

Returns the current widget height in pixels.

Return value

Widget height in pixels.

void setFontOutline (int outline)

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.

int getNumChildren ()

Returns the number of child widgets.

Return value

Number of child widgets.

void raise (const Ptr<Widget> & w)

Brings a given widget to the top.

Arguments

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

int isCallback (int callback)

Checks if the given callback is set for the widget.

Arguments

  • int callback - One of the callbacks defined in the Gui class.

Return value

1 is the callback is set for the widget; otherwise, 0.

void replaceChild (const Ptr<Widget> & w, const Ptr<Widget> & old_w, int flags = 0)

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

Arguments

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

void setHidden (int hidden)

Hides or shows the widget.

Arguments

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

void * getInterface ()

Return value

void setFontVSpacing (int vspacing)

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

Arguments

  • int vspacing - Vertical spacing value.

void setNextFocus (const Ptr<Widget> & focus)

Sets a widget which will be focused next if the user presses TAB.

Arguments

  • const Ptr<Widget> & focus - Next widget.

void setFontWrap (int wrap)

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

Arguments

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

void removeAttach (const Ptr<Widget> & w)

Detaches a given widget from the current one.

Arguments

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

int getFontPermanent ()

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.

int getFlags ()

Returns widget flags.

Return value

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

void arrange ()

Rearranges the widget size.

void setToolTip (const char * str, int reset = 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).

const char * getTypeName ()

Returns a name of the widget type.

Return value

Widget type name.

void setMouseCursor (int cursor)

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.

int getIntersection (int x, int y)

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.

Ptr<Widget> getWidget ()

Returns a widget pointer.

Return value

Widget pointer.

int getFontHOffset ()

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

Return value

Horizontal offset value in pixels.

void setFocus ()

Sets focus on the widget.

void setFontHSpacing (int hspacing)

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

Arguments

  • int hspacing - Horizontal spacing value.

void setFontHOffset (int hoffset)

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

Arguments

  • int hoffset - Horizontal offset value in pixels.

void setCallbackEnabled (int callback, int enabled)

Enables or disables a given callback function.

Arguments

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

void setFlags (int flags)

Sets widget flags.

Arguments

  • int flags - flags.

void setPermanentFocus ()

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

Ptr<Widget> getNextFocus ()

Returns a widget which will be focused next if the user presses TAB.

Return value

Next widget.

void setWidth (int width)

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.

void setOrder (int order)

Sets rendering order for the widget.

Arguments

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

const char * getData ()

Returns user data associated with the widget.

Return value

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

void setFontPermanent (int permanent)

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.

Ptr<Gui> getGui ()

Returns the Gui smart pointer.

Return value

Gui smart pointer.

int getPositionX ()

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

Return value

Relative X coordinate.

void setEnabled (int enabled)

Enables or disables the widget.

Arguments

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

int isEnabled ()

Returns a value indicating if the widget is enabled.

Return value

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

int isFocused ()

Returns a value indicating if the widget is in focus.

Return value

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

int isCallbackEnabled (int callback)

Returns a value indicating if a given callback is enabled.

Arguments

  • int callback - Callback number: one of the Gui:: Enumeration (for example, SHOW, HIDE, etc).

Return value

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

void setParent (const Ptr<Widget> & widget)

Sets a parent widget for the current one.

Arguments

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

void setCallbackAccel (int callback, unsigned int key, int ctrl, int alt, int shift)

Assigns a hot key combination to a given callback function.

Arguments

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

int getFontRich ()

Returns a value indicating if rich text formatting is used.

Return value

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

Math::vec4 getFontColor ()

Returns the color of the font used by the widget.

Return value

Font color.

int getOrder ()

Returns rendering order for the widget.

Return value

Rendering order.

const char * getToolTip ()

Returns the widget tooltip text.

Return value

Tooltip text.

Ptr<Widget> getChild (int num)

Returns the widget child by its number.

Arguments

  • int num - Number of the child widget.

Return value

Pointer to the child widget.

int isChild (const Ptr<Widget> & w)

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

Arguments

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

Return value

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

void removeChild (const Ptr<Widget> & w)

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

Arguments

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

int getScreenPositionX ()

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

Return value

Screen position along the X axis in pixels.

int WIDGET_VBOX

Description

Vertical box. See also: WidgetVBox.

int WIDGET_HBOX

Description

Horizontal box. See also: WidgetHBox.

int WIDGET_VPANED

Description

Vertical box that allows resizing of its children. See also: WidgetVPaned.

int WIDGET_HPANED

Description

Horizontal box that allows resizing of its children. See also: WidgetHPaned.

int WIDGET_GRIDBOX

Description

Grid box. See also: WidgetGridBox.

int WIDGET_GROUPBOX

Description

Group box. See also: WidgetGroupBox.

int WIDGET_TABBOX

Description

Tabbed box. See also: WidgetTabBox.

int WIDGET_SCROLLBOX

Description

Box with scrolling. See also: WidgetScrollBox.

int WIDGET_WINDOW

Description

Window. See also: WidgetWindow.

int WIDGET_DIALOG

Description

Dialog window. See also: WidgetDialog.

int WIDGET_LABEL

Description

Text label. See also: WidgetLabel.

int WIDGET_SPRITE

Description

Sprite. See also: WidgetSprite.

int WIDGET_CANVAS

Description

Canvas widget for drawing text, lines and polygons. See also: WidgetCanvas.

int WIDGET_ICON

Description

Icon. See also: WidgetIcon.

int WIDGET_BUTTON

Description

Simple button. See also: WidgetButton.

int WIDGET_CHECKBOX

Description

Checkbox. See also: WidgetCheckbox.

int WIDGET_COMBOBOX

Description

Combobox. See also: WidgetCombobox.

int WIDGET_MENUBAR

Description

Menu bar. See also: WidgetMenuBar.

int WIDGET_MENUBOX

Description

Menu. See also: WidgetMenuBox.

int WIDGET_LISTBOX

Description

List box. See also: WidgetListBox.

int WIDGET_TREEBOX

Description

Tree box. See also: WidgetTreeBox.

int WIDGET_SPACER

Description

Spacer: horizontal or vertical one. See also: WidgetSpacer.

int WIDGET_SLIDER

Description

A slider: horizontal or vertical one. See also: WidgetSlider.

int WIDGET_SCROLL

Description

A scrollbar: horizontal or vertical one. See also: WidgetScroll.

int WIDGET_SPINBOX

Description

Spinbox. See also: WidgetSpinBox.

int WIDGET_EDITLINE

Description

Text field. See also: WidgetEditline.

int WIDGET_EDITTEXT

Description

Multiline text field. See also: WidgetEdittext.

int WIDGET_EXTERN

Description

External widget.

int WIDGET_ENGINE

Description

Engine-specific widget (manipulator). See also: WidgetManipulator.
Last update: 2017-07-03