d6cb0f04efc9fbefd0545c0fcc9d93a4d9918ae7
[midnight-commander.git] / lib / widget / menu.h
blobd6cb0f04efc9fbefd0545c0fcc9d93a4d9918ae7
1 /*
2 Header file for pulldown menu engine for Midnignt Commander
3 */
5 /** \file menu.h
6 * \brief Header: pulldown menu code
7 */
9 #ifndef MC__WIDGET_MENU_H
10 #define MC__WIDGET_MENU_H
12 /*** typedefs(not structures) and defined constants **********************************************/
14 #define menu_separator_create() NULL
16 /*** enums ***************************************************************************************/
18 /*** structures declarations (and typedefs of structures)*****************************************/
20 typedef struct menu_entry_t
22 unsigned char first_letter;
23 hotkey_t text;
24 unsigned long command;
25 char *shortcut;
26 } menu_entry_t;
28 typedef struct Menu
30 int start_x; /* position relative to menubar start */
31 hotkey_t text;
32 GList *entries;
33 size_t max_entry_len; /* cached max length of entry texts (text + shortcut) */
34 size_t max_hotkey_len; /* cached max length of shortcuts */
35 unsigned int selected; /* pointer to current menu entry */
36 char *help_node;
37 } Menu;
39 /* The button bar menu */
40 typedef struct WMenuBar
42 Widget widget;
44 gboolean is_visible; /* If the menubar is visible */
45 gboolean is_active; /* If the menubar is in use */
46 gboolean is_dropped; /* If the menubar has dropped */
47 GList *menu; /* The actual menus */
48 size_t selected; /* Selected menu on the top bar */
49 unsigned long previous_widget; /* Selected widget ID before activating menu */
50 } WMenuBar;
52 /*** global variables defined in .c file *********************************************************/
54 /*** declarations of public functions ************************************************************/
56 menu_entry_t *menu_entry_create (const char *name, unsigned long command);
57 void menu_entry_free (menu_entry_t * me);
59 Menu *create_menu (const char *name, GList * entries, const char *help_node);
60 void menu_set_name (Menu * menu, const char *name);
61 void destroy_menu (Menu * menu);
63 WMenuBar *menubar_new (int y, int x, int cols, GList * menu);
64 void menubar_set_menu (WMenuBar * menubar, GList * menu);
65 void menubar_add_menu (WMenuBar * menubar, Menu * menu);
66 void menubar_arrange (WMenuBar * menubar);
68 WMenuBar *find_menubar (const WDialog * h);
70 /*** inline functions ****************************************************************************/
72 static inline void
73 menubar_set_visible (WMenuBar * menubar, gboolean visible)
75 menubar->is_visible = visible;
78 #endif /* MC__WIDGET_MENU_H */