2011-10-15 14:56:47 +04:00
|
|
|
/*
|
|
|
|
Header file for pulldown menu engine for Midnignt Commander
|
|
|
|
*/
|
2009-05-04 20:11:51 +04:00
|
|
|
|
2009-02-05 21:28:18 +03:00
|
|
|
/** \file menu.h
|
|
|
|
* \brief Header: pulldown menu code
|
|
|
|
*/
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
#ifndef MC__WIDGET_MENU_H
|
|
|
|
#define MC__WIDGET_MENU_H
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
|
|
|
#define menu_separator_create() NULL
|
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
2009-05-04 20:11:51 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
typedef struct menu_entry_t
|
|
|
|
{
|
2009-05-04 20:11:51 +04:00
|
|
|
unsigned char first_letter;
|
2010-11-14 11:35:56 +03:00
|
|
|
hotkey_t text;
|
2009-11-06 14:41:54 +03:00
|
|
|
unsigned long command;
|
2009-10-24 12:58:02 +04:00
|
|
|
char *shortcut;
|
2009-05-04 20:11:51 +04:00
|
|
|
} menu_entry_t;
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
typedef struct Menu
|
|
|
|
{
|
|
|
|
int start_x; /* position relative to menubar start */
|
2010-11-14 11:35:56 +03:00
|
|
|
hotkey_t text;
|
2009-08-25 13:08:18 +04:00
|
|
|
GList *entries;
|
2010-11-10 14:09:42 +03:00
|
|
|
size_t max_entry_len; /* cached max length of entry texts (text + shortcut) */
|
|
|
|
size_t max_hotkey_len; /* cached max length of shortcuts */
|
|
|
|
unsigned int selected; /* pointer to current menu entry */
|
2009-05-04 20:11:51 +04:00
|
|
|
char *help_node;
|
2002-11-13 00:01:50 +03:00
|
|
|
} Menu;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* The button bar menu */
|
2010-11-10 14:09:42 +03:00
|
|
|
typedef struct WMenuBar
|
|
|
|
{
|
1998-02-27 07:54:42 +03:00
|
|
|
Widget widget;
|
|
|
|
|
2010-11-14 11:35:56 +03:00
|
|
|
gboolean is_visible; /* If the menubar is visible */
|
2010-11-10 14:09:42 +03:00
|
|
|
gboolean is_active; /* If the menubar is in use */
|
|
|
|
gboolean is_dropped; /* If the menubar has dropped */
|
|
|
|
GList *menu; /* The actual menus */
|
|
|
|
size_t selected; /* Selected menu on the top bar */
|
|
|
|
int previous_widget; /* Selected widget ID before activating menu */
|
2009-05-04 20:11:51 +04:00
|
|
|
} WMenuBar;
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
menu_entry_t *menu_entry_create (const char *name, unsigned long command);
|
|
|
|
void menu_entry_free (menu_entry_t * me);
|
|
|
|
|
|
|
|
Menu *create_menu (const char *name, GList * entries, const char *help_node);
|
2010-11-14 11:35:56 +03:00
|
|
|
void menu_set_name (Menu * menu, const char *name);
|
2010-11-10 14:09:42 +03:00
|
|
|
void destroy_menu (Menu * menu);
|
|
|
|
|
|
|
|
WMenuBar *menubar_new (int y, int x, int cols, GList * menu);
|
|
|
|
void menubar_set_menu (WMenuBar * menubar, GList * menu);
|
|
|
|
void menubar_add_menu (WMenuBar * menubar, Menu * menu);
|
|
|
|
void menubar_arrange (WMenuBar * menubar);
|
2009-05-04 20:11:51 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
WMenuBar *find_menubar (const Dlg_head * h);
|
2009-11-08 13:49:27 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
2010-11-12 11:03:57 +03:00
|
|
|
|
2010-11-14 11:35:56 +03:00
|
|
|
static inline void
|
|
|
|
menubar_set_visible (WMenuBar * menubar, gboolean visible)
|
|
|
|
{
|
|
|
|
menubar->is_visible = visible;
|
|
|
|
}
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
#endif /* MC__WIDGET_MENU_H */
|