menu.h 2.5 KB

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