This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
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

This base class is used to create graphical user interface widgets of different types.

See Also#

  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder

Widget Class

Properties

int NumChildren#

The number of child widgets.

int FontWrap#

A value indicating if text wrapping to widget width is enabled.
set
Enables or disables text wrapping to widget width. The default is 0.
set value - 1 to enable text wrapping, 0 to disable it.

int FontRich#

A value indicating if rich text formatting is used.
set
Sets a value indicating if rich text formatting should be used. The default is 0.
set value - 1 to use rich text formatting, 0 to use plain text formatting.

int FontOutline#

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.
set
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).
set value - 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 FontVOffset#

The vertical offset of the font used by the widget.
set
Sets the vertical offset of the font used by the widget.
set value - Vertical offset value, pixels.

int FontHOffset#

The horizontal offset of the font used by the widget.
set
Sets the horizontal offset of the font used by the widget.
set value - Horizontal offset value, pixels.

int FontVSpacing#

The spacing (in pixels) between widget text lines.
set
Sets the spacing (in pixels) between widget text lines.
set value - Vertical spacing value.

int FontHSpacing#

The spacing (in pixels) between widget text characters.
set
Sets the spacing (in pixels) between widget text characters.
set value - Horizontal spacing value.

int FontPermanent#

A flag indicating if color of the widget text is not changed (for example, when the widget becomes non-active or loses focus).
set
Sets a flag to prevent color change for the widget text (for example, when the widget becomes non-active or loses focus).
set value - 1 not to change text color; 0 to change it.

vec4 FontColor#

The color of the font used by the widget.
set
Sets a font color that will be used to render text on the widget.
set value - Font color.

int FontSize#

The size of the font used by the widget.
set
Sets a font size that will be used to render text on the widget.
set value - Font size.

int MouseCursor#

The current mouse pointer.
set
Sets a mouse pointer to display.
set value - One of the CURSOR_* pre-defined variables.

int MouseY#

The y coordinate of the mouse pointer position on the screen.

int MouseX#

The x coordinate of the mouse pointer position on the screen.

int Height#

The current widget height in pixels.
set
Sets minimal height of the widget in pixels.
set value - Height in pixels. If a negative value is provided, 0 will be used instead.

int Width#

The current widget width in pixels.
set
Sets minimal width of the widget in pixels.
set value - Width in pixels. If a negative value is provided, 0 will be used instead.

int ScreenPositionY#

The screen position of the widget (its top left corner) on the screen along the y axis.

int ScreenPositionX#

The screen position of the widget (its top left corner) on the screen along the x axis.

int PositionY#

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

int PositionX#

Widget NextFocus#

A widget which will be focused next if the user presses TAB.
set
Sets a widget which will be focused next if the user presses TAB.
set value - Next widget.

string Data#

User data associated with the widget.
set
Sets user data associated with the widget.
set value - String to be associated

int Order#

Rendering order (z-order) for the widget.
set
Sets rendering order (Z-order) for the widget. The higher the value, the higher the order of the widget will be.
Notice
Works only for widgets added to GUI via the Gui.addChild() function with the Gui.ALIGN_OVERLAP flag specified (should not be Gui.ALIGN_FIXED).
set value - Rendering order (Z-order) of the widget, in the range [-128;127]. (126 for the Profiler, 127 for the Console).

bool IsHidden#

A value indicating if the widget is hidden.
set
Hides or shows the widget.
set value - 1 to hide the widget, 0 to render it.

bool IsEnabled#

A value indicating if the widget is enabled.
set
Enables or disables the widget.
set value - 1 to enable the widget, 0 to disable it.

int Flags#

Widget flags.
set
Sets widget flags.
set value - ALIGN_* pre-defined variables.

Widget Parent#

The pointer to the parent widget.
set
Sets a parent widget for the current one.
set value - Widget to be set as a parent.

Gui ParentGui#

The parent gui smart pointer.

Gui Gui#

The gui smart pointer.

string TypeName#

A name of the widget type.

int Type#

A type of the widget.

Members


bool IsCallback ( int callback ) #

Returns a value indicating if there are any callbacks of the specified type set for the widget.

Arguments

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

Return value

true if at least one callback of the specified type is set for the widget; otherwise, false.

IntPtr addCallback ( int callback, Callback0Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name();

Arguments

  • int callback
  • Callback0Delegate func - Callback function with the following signature: void Callback0Delegate()

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( int callback, Callback1Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender);

Arguments

  • int callback
  • Callback1Delegate func - Callback function with the following signature: void Callback1Delegate(Widget sender)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( int callback, Call2backDelegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender, Widget pointer);

Arguments

  • int callback
  • Call2backDelegate func - Callback function with the following signature: void Callback2Delegate(Widget sender, Widget pointer)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

IntPtr addCallback ( int callback, Callback3Delegate func ) #

Adds a callback function of the specified type for the widget.The signature of the callback function must be as follows:
Source code (C#)
void callback_function_name(Widget sender, Widget pointer, int data);

Arguments

  • int callback
  • Callback3Delegate func - Callback function with the following signature: void Callback3Delegate(Widget sender, Widget pointer, int data)

Return value

ID of the last added callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeCallback ( int callback, IntPtr id ) #

Removes the specified callback from the list of callbacks of the specified type added for the widget.

Arguments

  • int callback
  • IntPtr id - Callback ID obtained when adding it.

Return value

True if the callback with the given ID was removed successfully; otherwise false.

void clearCallbacks ( int callback ) #

Clears all callbacks of the specified type added for the widget.

Arguments

  • int callback

void SetCallbackAccel ( int callback, uint key, int ctrl, int alt, int shift ) #

Assigns a hot key combination to a given callback function.

Arguments

  • int callback - One of the callbacks defined in the Gui class.
  • uint key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.
  • int ctrl - 1 to use the CTRL key modifier, 0 not to use.
  • int alt - 1 to use the ALT key modifier, 0 not to use.
  • int shift - 1 to use the SHIFT key modifier, 0 not to use.

bool GetCallbackAccel ( int callback, out uint key, out int ctrl, out int alt, out int shift ) #

Gets 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).
  • out uint key - ASCII key code: one of the App:: Enumeration with KEY_* prefixes.
  • out int ctrl - CTRL key modifier.
  • out int alt - ALT key modifier.
  • out int shift - SHIFT key modifier.

Return value

true if the specified callback type exists; otherwise, false.

int IsCallbackAccel ( uint key, int ctrl, int alt, int shift ) #

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

Arguments

  • uint 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.

void SetCallbackEnabled ( int callback, bool enabled ) #

Enables or disables a given callback function.

Arguments

  • int callback - One of the callbacks defined in the Gui class.
  • bool enabled - 1 to enable the callback, 0 to disable it.

int IsCallbackEnabled ( int callback ) #

Returns a value indicating if a given callback is enabled.

Arguments

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

Return value

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

Widget GetChild ( int num ) #

Returns the widget child by its number.

Arguments

  • int num - Widget number.

Return value

Pointer to the child widget.

int IsChild ( Widget w ) #

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

Arguments

  • Widget w - Widget to check.

Return value

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

void SetFocus ( ) #

Sets focus on the widget.

int IsFocused ( ) #

Returns a value indicating if the widget is in focus.

Return value

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

void SetFont ( string name ) #

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

Arguments

  • string name - Font name.

IntPtr GetInterface ( ) #

Returns an interface pointer.

Return value

Interface pointer.

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.

int GetKeyActivity ( uint key ) #

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

Arguments

  • uint key - One of the standard ASCII keycodes or one of the APP_KEY_* pre-defined variables.

Return value

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

int IsOwner ( ) #

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

Return value

1 if the pointer is the owner; otherwise, 0.

void SetPermanentFocus ( ) #

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

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.

void SetToolTip ( string str, int reset = 0 ) #

Sets a tooltip used for the widget.

Arguments

  • string str - Tooltip to display.
  • int reset - 1 to recalculate a tooltip location if the mouse cursor was relocated; otherwise - 0.

string GetToolTip ( ) #

Returns the widget tooltip text.

Return value

Tooltip text.

Widget GetWidget ( ) #

Returns a widget pointer.

Return value

Widget pointer.

void AddAttach ( Widget w, string 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

  • Widget w - Widget to attach.
  • string format - Format string for values entered into the attached widget. If none specified, "%d" is implied. This is an optional parameter.
  • int multiplier - Multiplier used to scale values provided by the attached widget. This is an optional parameter.
  • int flags - One of the ATTACH_* pre-defined variables. This is an optional parameter.

void AddChild ( Widget w, int flags = 0 ) #

Adds a child to the widget.

Arguments

  • Widget w - Child widget.
  • int flags - One of the ALIGN_* pre-defined variables. This is an optional parameter.

void Arrange ( ) #

Rearranges the widget size.

void Grab ( ) #

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 Raise ( Widget w ) #

Brings a given widget to the top.
Notice
Works only for widgets added to GUI via the Gui.addChild() function with the Gui.ALIGN_OVERLAP flag specified (hould not be Gui.ALIGN_FIXED).

Arguments

  • Widget w - Widget to be brought up.

void Release ( ) #

Releases the Widget (sets the owner flag to 0 for the pointer). The Widget should be handled by the class after this function is called

void RemoveAttach ( Widget w ) #

Detaches a given widget from the current one.

Arguments

  • Widget w - Widget to detach.

void RemoveChild ( Widget w ) #

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

Arguments

  • Widget w - Child widget.

void RemoveFocus ( ) #

Removes focus from the widget.

void ReplaceChild ( Widget w, Widget old_w, int flags = 0 ) #

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

Arguments

  • Widget w - Replacement widget.
  • Widget old_w - Widget to be replaced.
  • int flags - One of the ALIGN_* pre-defined variables. This is an optional parameter.

void RunCallback ( int callback ) #

Runs a given callback function.

Arguments

  • int callback - One of the callbacks defined in the Gui class.
Last update: 2019-08-16
Build: ()