This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
VR Development
双精度坐标
应用程序接口
Animations-Related Classes
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
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::WidgetMenuBox Class

Header: #include <UnigineWidgets.h>
Inherits from: Widget

This class creates a menu box. A menu box can be either stand-alone or attached to a menu bar. In the first case, it needs to be handled manually. By using this widget, you can do the following:

  • Create hierarchical menus.
  • Use the other widgets as menu items (See the example).

See Also#

  • Widgets sample in C# Component Samples suite
  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder:
    • menubox_00
    • menubox_01
    • menubox_02
  • The Widgets article providing details on menubox features

WidgetMenuBox Class

Members


static WidgetMenuBoxPtr create ( const Ptr<Gui> & gui, int x = 0, int y = 0 ) #

Constructor. Creates an empty menu box with specified spacing between menu items as well as items and menu borders and adds it to the specified GUI.

Arguments

  • const Ptr<Gui> & gui - GUI, to which the menu will belong.
  • int x - Horizontal space.
  • int y - Vertical space.

static WidgetMenuBoxPtr create ( int x = 0, int y = 0 ) #

Constructor. Creates an empty menu box with specified spacing between menu items as well as items and menu borders and adds it to the Engine GUI.

Arguments

  • int x - Horizontal space.
  • int y - Vertical space.

void setCurrentItem ( int item ) #

Sets the item that is clicked last.

Arguments

  • int item - Item number.

int getCurrentItem ( ) const#

Returns the item that is clicked last.

Return value

Item number.

const char * getCurrentItemData ( ) const#

Returns the text data of the item that is clicked last. The data can be used as a text identifier of the item (instead of using the item number).

Return value

Item text data as a string, if the item is in range from 0 to the total number of items; otherwise, NULL.

const char * getCurrentItemText ( ) const#

Returns the text of the item that is clicked last.

Return value

Item text if the item is in range from 0 to the total number of items; otherwise, NULL.

void setImage ( const Ptr<Image> & image ) #

Sets an image with mini icons to be used with items. The image is a vertical strip of square icons.

Arguments

  • const Ptr<Image> & image - Image to set.

Ptr<Image> getImage ( ) const#

Gets the image with mini icons that are used with menu items.

Return value

Image with mini icons (the vertical strip of square icons).

void setItemData ( int item, const char * str ) #

Sets the text data for a given item. The data can be used as a text identifier of the item (instead of using the number of the item).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • const char * str - Item text data to set.

const char * getItemData ( int item ) const#

Returns the text data of the item with the specified number. The data can be used as a text identifier of the item (instead of using the item number).

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item text data.

void setItemEnabled ( int item, bool enabled ) #

Sets a value indicating if a given item is enabled (i.e. can be clicked).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • bool enabled - Positive number to enable the item, 0 to disable it.

int isItemEnabled ( int item ) const#

Returns a value indicating if a given item is enabled (i.e. can be clicked).

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Positive number if the item is enabled; otherwise, 0.

void setItemSelectable ( int item, int selectable ) #

Sets a value indicating if a given item can be selected.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int selectable - 1 to set the item as selectable; otherwise, 0.

int isItemSelectable ( int item ) const#

Returns a value indicating if the given item can be selected. By default, the item is selectable.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Returns 1 if the item is selectable; otherwise, 0.

void setItemSeparator ( int item, int separator ) #

Adds or removes a separator after a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int separator - Positive number to add a separator, 0 to remove it.

int isItemSeparator ( int item ) const#

Checks whether a separator is placed after the given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Positive number if separator is placed; otherwise, 0.

void setItemSpace ( int item, int space ) #

Sets a space after the given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int space - Item space to set.

int getItemSpace ( int item ) const#

Returns the space after the given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item space.

void setItemText ( int item, const char * str ) #

Sets a text for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • const char * str - Item text.

const char * getItemText ( int item ) const#

Returns the text of a given item in range from 0 to the total number of items.

Arguments

  • int item - Item number.

Return value

Item text.

void setItemTexture ( int item, int texture ) #

Sets an icon for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int texture - Zero-based ID of the icon (i.e. number of the icon in the icon texture).

int getItemTexture ( int item ) const#

Returns the icon of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Zero-based ID of the icon (i.e. number of the icon in the icon texture).

void setItemToolTip ( int item, const char * str ) #

Sets a tooltip for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • const char * str - Text of a tooltip to set.

const char * getItemToolTip ( int item ) const#

Returns the tooltip of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Text of the item tooltip.

void setItemWidget ( int item, const Ptr<Widget> & w ) #

Sets a menu widget for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of menu items.
  • const Ptr<Widget> & w - Menu widget.

Ptr<Widget> getItemWidget ( int item ) const#

Returns the menu widget of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of menu items.

Return value

Menu widget.

int getNumItems ( ) const#

Returns the total number of items in the menu.

Return value

Number of items.

void setSpace ( int x, int y ) #

Sets a space between menu items and between them and menu borders.

Arguments

  • int x - Horizontal space. If a negative value is provided, 0 will be used instead.
  • int y - Vertical space. If a negative value is provided, 0 will be used instead.

int getSpaceX ( ) const#

Returns the horizontal space between menu items and between them and menu borders.

Return value

Horizontal space.

int getSpaceY ( ) const#

Returns the vertical space between menu items and between them and menu borders.

Return value

Vertical space.

void setTexture ( const char * texture ) #

Sets a texture with mini icons to be used with items. The texture is a vertical strip of square icons.

Arguments

  • const char * texture - Path to a texture file.

const char * getTexture ( ) const#

Returns the path to the texture with mini icons, which are used with the list items. The texture is a vertical strip of square icons.

Return value

Path to the texture file.

int addItem ( const char * str, int texture = -1 ) #

Adds a new item with a given text and an icon.

Arguments

  • const char * str - Item text.
  • int texture - Zero-based ID of the icon (i.e. number of the icon in the icon texture). -1 means that an item has no icon.

Return value

Number of the added item.

void clear ( ) #

Removes all items from the menu.

void removeItem ( int item ) #

Removes a given item from the menu.

Arguments

  • int item - Item number in range from 0 to the total number of items.

void setBackgroundColor ( const Math::vec4 & color ) #

Sets the background color to be used for the widget.

Arguments

  • const Math::vec4 & color - Four-component vector specifying the color in the RGBA format.

Math::vec4 getBackgroundColor ( ) const#

Returns the current background color used for the widget.

Return value

Four-component vector specifying the color in the RGBA format.

void setSelectionColor ( const Math::vec4 & color ) #

Sets the color to be used to highlight the selection for the widget.

Arguments

  • const Math::vec4 & color - Four-component vector specifying the color in the RGBA format.

Math::vec4 getSelectionColor ( ) const#

Returns the current color used to highlight the selection for the widget.

Return value

Four-component vector specifying the color in the RGBA format.

void setBorderColor ( const Math::vec4 & color ) #

Sets the border color for the widget.

Arguments

  • const Math::vec4 & color - Four-component vector specifying the color in the RGBA format.

Math::vec4 getBorderColor ( ) const#

Returns the current border color for the widget.

Return value

Four-component vector specifying the color in the RGBA format.

void setCurrentItemHighlight ( bool highlight = false ) #

Sets the highlight flag for the item that is clicked last.

Arguments

  • bool highlight - true to enable highlight; false to disable it.

bool isCurrentItemHighlight ( ) const#

Returns the highlight flag for the item that is clicked last.

Return value

true if highlight is enabled; otherwise false.

void setCurrentItemColor ( const Math::vec4 & color ) #

Sets the color of the highlight for item that is clicked last. The highlight state should be enabled.

Arguments

  • const Math::vec4 & color - Four-component vector specifying the color in the RGBA format.

Math::vec4 getCurrentItemColor ( ) const#

Returns the color of the highlight for item that is clicked last. The highlight state should be enabled.

Return value

Four-component vector specifying the color in the RGBA format.

void resetCurrentItem ( ) #

Resets the item clicked last.
Last update: 2023-12-19
Build: ()