WidgetMenuBox Class
Interface for widget menubox handling. See also UnigineScript analog.
To use this class, include the UnigineWidgetMenuBox.h file.
WidgetMenuBox Class
Members
WidgetMenuBox (const Ptr<Gui> & gui, int x = 0, int y = 0)
Constructor. Creates an empty menu box with specified spacing between menu items and items and menu borders.Arguments
- const Ptr<Gui> & gui - GUI, to which the menu will belong.
- int x - Horizontal space.
- int y - Vertical space.
Ptr<WidgetMenuBox> create (const Ptr<Widget> & widget)
WidgetMenuBox constructor.Arguments
- const Ptr<Widget> & widget - Widget smart pointer.
Return value
int isItemSelectable (int item)
Returns 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.
Return value
Returns 1 if the item is selectable; otherwise, 0.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.
int getSpaceY ()
Returns the vertical space between menu items and between them and menu borders.Return value
Vertical space.void setItemEnabled (int item, int 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.
- int enabled - Positive number to enable the item, 0 to disable it.
const char * getItemToolTip (int item)
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.Ptr<Widget> getItemWidget (int item)
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.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.
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.
const char * getItemText (int item)
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 setItemData (int item, const char * str)
Sets the 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 data to set.
int getCurrentItem ()
Returns the item, which is currently in focus.Return value
Item number.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 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 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 getItemTexture (int item)
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).int getNumItems ()
Returns the total number of items in the menu.Return value
Number of items.const char * getItemData (int item)
Returns the data of 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.
Return value
Item data.int isItemEnabled (int item)
Returns a value indicating if a given item 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 clear ()
Removes all items from the menu.int getItemSpace (int item)
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.const char * getCurrentItemText ()
Returns the text of the item, which is currently in focus.Return value
Item text if the item is in range from 0 to the total number of items; otherwise, NULL.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.
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.
int getSpaceX ()
Returns the horizontal space between menu items and between them and menu borders.Return value
Horizontal space.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 type ()
WidgetMenuBox type.Return value
WidgetMenuBox type identifier.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.
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.
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.
const char * getCurrentItemData ()
Returns the data of the item, which is currently in focus. The data can be used as a text identifier of the item (instead of using the number of the item).Return value
Item data if the item is in range from 0 to the total number of items; otherwise, NULL.void getImage (const Ptr<Image> & image)
Gets the image with mini-icons, which are used with menu items.Arguments
- const Ptr<Image> & image - Image with mini-icons (the vertical strip of square icons).
const char * getTexture ()
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 isItemSeparator (int item)
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.Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter