Menu
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Functions
Menu* | menu_create (void) |
void | menu_destroy (...) |
void | menu_launch (...) |
void | menu_hide (...) |
void | menu_item (...) |
void | menu_off_items (...) |
MenuItem* | menu_get_item (...) |
uint32_t | menu_size (...) |
A Menu is a type of control that integrates a series of options, also called items or MenuItems. Each of them consists of a short text, optionally an icon and optionally also a keyboard shortcut, such as the classic Ctrl+C/Ctrl+V
for copy and paste. Additionally, an item can host a submenu, forming a hierarchy with different levels of depth. In Products you have an example application that uses menus.
- Use menu_create to create a menu.
- Use menu_destroy to destroy a menu.
- Use menu_item to add an option.
- Use menu_launch to launch a popup menu.
- Use osapp_menubar to set the application menu bar.
We must explicitly destroy any menu that we create in the application, just as happens with windows.
By destroying a menu, all its elements are implicitly destroyed.
Generally, we have two ways to launch or show menu. On the one hand, the menu bars (Figure 1), which are anchored to a window, although there are operating systems (such as macOS) that display the menu bar at the top of the screen. On the other hand, the popup or contextual menus (Figure 2) that are displayed at any time during execution as an overlaid window, normally when you right-click on some element of the interface.
The concept of the menu, like that of the window, exists from the origin of the graphic interfaces. The first computer to incorporate them was the Xerox Alto that appeared in 1973 and its commercial successor the Xerox Star. Concepts still very alive today such as: Menu, Window, Icon, Desk, or Mouse were already present on these computers that served as inspiration to Steve Jobs in the creation of Apple Lisa (Figure 3), predecessor of Machintosh and inspirer of Microsoft Windows.
menu_create ()
Create a new menu.
Menu* menu_create(void);
Return
The new menu.
menu_destroy ()
Destroy a menu and its entire hierarchy.
void menu_destroy(Menu **menu);
menu | The menu. Will be set to |
menu_launch ()
Launch a menu as secondary or PopUp.
void menu_launch(Menu *menu, const V2Df position);
menu | The menu. |
position | Coordinates of the upper left corner. |
menu_hide ()
Hides a secondary PopUp menu.
void menu_hide(Menu *menu);
menu | The menu. |
menu_item ()
Add an item to the menu.
void menu_item(Menu *menu, MenuItem *item);
menu | The menu. |
item | The item to add. |
menu_off_items ()
Set status ekGUI_OFF for all menu items.
void menu_off_items(Menu *menu);
menu | The menu. |
menu_get_item ()
Get an item from the menu.
MenuItem* menu_get_item(Menu *menu, const uint32_t index);
menu | The menu. |
index | The index of the item. |
Return
The item.
menu_size ()
Gets the number of items.
uint32_t menu_size(const Menu *menu);
menu | The menu. |
Return
Number of items.