Cross-platform C SDK logo

Cross-platform C SDK

Menu

❮ Back
Next ❯
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)
voidmenu_destroy (...)
voidmenu_launch (...)
voidmenu_hide (...)
voidmenu_item (...)
voidmenu_off_items (...)
MenuItem*menu_get_item (...)
uint32_tmenu_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.

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.

Screenshot of the menu bar of a desktop application.
Figure 1: Menu bar in Windows, macOS and Linux.
Screenshot showing a popup menu launched with the right mouse button.
Figure 2: Context menu launched at runtime.

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.

Apple Lisa desktop environment capture.
Figure 3: The Apple Lisa was one of the first systems to incorporate menus as part of the graphical interface.
❮ Back
Next ❯

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 NULL after destruction.


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.

❮ Back
Next ❯