WidgetMenuBox Class
This class creates a menu box. It can be either stand-alone or attached to a menu bar. In the first case it needs to be handled manually.
WidgetMenuBox Class
This class inherits from WidgetMembers
WidgetMenuBox (Gui gui, int space_x, int space_y)
Constructor. Creates an empty menu box with specified spacing between menu items and items and menu borders.Arguments
- Gui gui - GUI, to which the menu will belong.
- int space_x - Horizontal space.
- int space_y - Vertical space.
int addItem (string text, int icon = -1)
Adds a new item with a given text and an icon.Arguments
- string text - Item text.
- int icon = -1 - Zero-based ID of the icon (i.e. number of the icon in the icon texture).
Return value
Number of the added item.void clear ()
Removes all items from the menu.string 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, NULLint getCurrentItem ()
Returns the item, which is currently in focus.Return value
Item number.Image getImage ()
Returns the image with mini-icons.Return value
Image with mini-icons.string getItemText (int item)
Returns the text of a given item.Arguments
- int item - Item number in range from 0 to the total number of items.
Return value
Item text.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 number of items in the menu.Return value
Number of items.int getSpaceX ()
Returns the horizontal space between menu items and between them and menu borders.Return value
Horizontal space.int getSpaceY ()
Returns the vertical space between menu items and between them and menu borders.Return value
Vertical space.string getTexture ()
Returns file name of the image with mini-icons.Return value
Path to the texture file.int isItemEnabled (int item)
Returns a value indicating if a given item can be clicked.Arguments
- int item - Item number.
Return value
Positive number if the item is enabled; otherwise, 0.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.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 setImage (Image image)
Sets an image with mini-icons to be used with items. The image is a vertical strip of square icons.Arguments
- Image image - Image to set.
void setItemEnabled (int item, int mode)
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 mode - Positive number to enable the item, 0 to disable it.
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.
void setItemText (int item, string text)
Sets a text for a given item.Arguments
- int item - Item number in range from 0 to the total number of items.
- string text - Item text.
void setItemTexture (int item, int icon)
Sets an icon for a given item.Arguments
- int item - Item number in range from 0 to the total number of items.
- int icon - Zero-based ID of the icon (i.e. number of the icon in the icon texture).
void setSpace (int space_x, int space_y)
Sets a space between menu items and between them and menu borders.Arguments
- int space_x - Horizontal space. If a negative value is provided, 0 will be used instead.
- int space_y - Vertical space. If a negative value is provided, 0 will be used instead.
void setTexture (string texture)
Sets a texture with mini-icons to be used with items. The texture is a vertical strip of square icons.Arguments
- string texture - Path to a texture file.
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)