menu.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Header file for pulldown menu engine for Midnignt Commander
  2. Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  3. 2007, 2009 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  15. /** \file menu.h
  16. * \brief Header: pulldown menu code
  17. */
  18. #ifndef MC__WIDGET_MENU_H
  19. #define MC__WIDGET_MENU_H
  20. /*** typedefs(not structures) and defined constants **********************************************/
  21. #define menu_separator_create() NULL
  22. /*** enums ***************************************************************************************/
  23. /*** structures declarations (and typedefs of structures)*****************************************/
  24. typedef struct menu_entry_t
  25. {
  26. unsigned char first_letter;
  27. hotkey_t text;
  28. unsigned long command;
  29. char *shortcut;
  30. } menu_entry_t;
  31. typedef struct Menu
  32. {
  33. int start_x; /* position relative to menubar start */
  34. hotkey_t text;
  35. GList *entries;
  36. size_t max_entry_len; /* cached max length of entry texts (text + shortcut) */
  37. size_t max_hotkey_len; /* cached max length of shortcuts */
  38. unsigned int selected; /* pointer to current menu entry */
  39. char *help_node;
  40. } Menu;
  41. /* The button bar menu */
  42. typedef struct WMenuBar
  43. {
  44. Widget widget;
  45. gboolean is_visible; /* If the menubar is visible */
  46. gboolean is_active; /* If the menubar is in use */
  47. gboolean is_dropped; /* If the menubar has dropped */
  48. GList *menu; /* The actual menus */
  49. size_t selected; /* Selected menu on the top bar */
  50. int previous_widget; /* Selected widget ID before activating menu */
  51. } WMenuBar;
  52. /*** global variables defined in .c file *********************************************************/
  53. /*** declarations of public functions ************************************************************/
  54. menu_entry_t *menu_entry_create (const char *name, unsigned long command);
  55. void menu_entry_free (menu_entry_t * me);
  56. Menu *create_menu (const char *name, GList * entries, const char *help_node);
  57. void menu_set_name (Menu * menu, const char *name);
  58. void destroy_menu (Menu * menu);
  59. WMenuBar *menubar_new (int y, int x, int cols, GList * menu);
  60. void menubar_set_menu (WMenuBar * menubar, GList * menu);
  61. void menubar_add_menu (WMenuBar * menubar, Menu * menu);
  62. void menubar_arrange (WMenuBar * menubar);
  63. WMenuBar *find_menubar (const Dlg_head * h);
  64. /*** inline functions ****************************************************************************/
  65. static inline void
  66. menubar_set_visible (WMenuBar * menubar, gboolean visible)
  67. {
  68. menubar->is_visible = visible;
  69. }
  70. #endif /* MC__WIDGET_MENU_H */