120 |
char* name; |
char* name; |
121 |
/* value (meaning depend on widget type) */ |
/* value (meaning depend on widget type) */ |
122 |
char* value; |
char* value; |
123 |
/* keyboard equivalent. no implications for XtTranslations */ |
/* keyboard equivalent. no implications for XtTranslations */ |
124 |
char* key; |
char* key; |
125 |
/* Help string or nil if none. |
/* Help string or nil if none. |
126 |
GC finds this string through the frame's menu_bar_vector |
GC finds this string through the frame's menu_bar_vector |
174 |
#define TRUE 1 |
#define TRUE 1 |
175 |
#define FALSE 0 |
#define FALSE 0 |
176 |
#endif /* no TRUE */ |
#endif /* no TRUE */ |
177 |
|
|
178 |
Lisp_Object Vmenu_updating_frame; |
Lisp_Object Vmenu_updating_frame; |
179 |
|
|
180 |
Lisp_Object Qdebug_on_next_call; |
Lisp_Object Qdebug_on_next_call; |
507 |
|
|
508 |
/* This is a subroutine of single_keymap_panes that handles one |
/* This is a subroutine of single_keymap_panes that handles one |
509 |
keymap entry. |
keymap entry. |
510 |
KEY is a key in a keymap and ITEM is its binding. |
KEY is a key in a keymap and ITEM is its binding. |
511 |
PENDING_MAPS_PTR points to a list of keymaps waiting to be made into |
PENDING_MAPS_PTR points to a list of keymaps waiting to be made into |
512 |
separate panes. |
separate panes. |
513 |
If NOTREAL is nonzero, only check for equivalent key bindings, don't |
If NOTREAL is nonzero, only check for equivalent key bindings, don't |
523 |
Lisp_Object map, item_string, enabled; |
Lisp_Object map, item_string, enabled; |
524 |
struct gcpro gcpro1, gcpro2; |
struct gcpro gcpro1, gcpro2; |
525 |
int res; |
int res; |
526 |
|
|
527 |
/* Parse the menu item and leave the result in item_properties. */ |
/* Parse the menu item and leave the result in item_properties. */ |
528 |
GCPRO2 (key, item); |
GCPRO2 (key, item); |
529 |
res = parse_menu_item (item, notreal, 0); |
res = parse_menu_item (item, notreal, 0); |
532 |
return; /* Not a menu item. */ |
return; /* Not a menu item. */ |
533 |
|
|
534 |
map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP]; |
map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP]; |
535 |
|
|
536 |
if (notreal) |
if (notreal) |
537 |
{ |
{ |
538 |
/* We don't want to make a menu, just traverse the keymaps to |
/* We don't want to make a menu, just traverse the keymaps to |
543 |
} |
} |
544 |
|
|
545 |
enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]; |
enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]; |
546 |
item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]; |
item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]; |
547 |
|
|
548 |
if (!NILP (map) && SREF (item_string, 0) == '@') |
if (!NILP (map) && SREF (item_string, 0) == '@') |
549 |
{ |
{ |
818 |
|
|
819 |
keymaps = 0; |
keymaps = 0; |
820 |
} |
} |
821 |
|
|
822 |
if (NILP (position)) |
if (NILP (position)) |
823 |
{ |
{ |
824 |
discard_menu_items (); |
discard_menu_items (); |
971 |
But first we recompute the menu bar contents (the whole tree). |
But first we recompute the menu bar contents (the whole tree). |
972 |
|
|
973 |
This way we can safely execute Lisp code. */ |
This way we can safely execute Lisp code. */ |
974 |
|
|
975 |
void |
void |
976 |
x_activate_menubar (f) |
x_activate_menubar (f) |
977 |
FRAME_PTR f; |
FRAME_PTR f; |
1182 |
first_wv = wv; |
first_wv = wv; |
1183 |
save_wv = 0; |
save_wv = 0; |
1184 |
prev_wv = 0; |
prev_wv = 0; |
1185 |
|
|
1186 |
/* Loop over all panes and items made during this call |
/* Loop over all panes and items made during this call |
1187 |
and construct a tree of widget_value objects. |
and construct a tree of widget_value objects. |
1188 |
Ignore the panes and items made by previous calls to |
Ignore the panes and items made by previous calls to |
1286 |
#endif /* not HAVE_MULTILINGUAL_MENU */ |
#endif /* not HAVE_MULTILINGUAL_MENU */ |
1287 |
|
|
1288 |
wv = xmalloc_widget_value (); |
wv = xmalloc_widget_value (); |
1289 |
if (prev_wv) |
if (prev_wv) |
1290 |
prev_wv->next = wv; |
prev_wv->next = wv; |
1291 |
else |
else |
1292 |
save_wv->contents = wv; |
save_wv->contents = wv; |
1432 |
break; |
break; |
1433 |
|
|
1434 |
wv = single_submenu (key, string, maps); |
wv = single_submenu (key, string, maps); |
1435 |
if (prev_wv) |
if (prev_wv) |
1436 |
prev_wv->next = wv; |
prev_wv->next = wv; |
1437 |
else |
else |
1438 |
first_wv->contents = wv; |
first_wv->contents = wv; |
1508 |
This value just has to be different from small integers. */ |
This value just has to be different from small integers. */ |
1509 |
wv->call_data = (void *) (EMACS_INT) (-1); |
wv->call_data = (void *) (EMACS_INT) (-1); |
1510 |
|
|
1511 |
if (prev_wv) |
if (prev_wv) |
1512 |
prev_wv->next = wv; |
prev_wv->next = wv; |
1513 |
else |
else |
1514 |
first_wv->contents = wv; |
first_wv->contents = wv; |
1537 |
DisposeMenu (menu); |
DisposeMenu (menu); |
1538 |
menu = GetMenuHandle (++i); |
menu = GetMenuHandle (++i); |
1539 |
} |
} |
1540 |
|
|
1541 |
i = MIN_SUBMENU_ID; |
i = MIN_SUBMENU_ID; |
1542 |
menu = GetMenuHandle (i); |
menu = GetMenuHandle (i); |
1543 |
while (menu != NULL) |
while (menu != NULL) |
1549 |
} |
} |
1550 |
|
|
1551 |
fill_menubar (first_wv->contents); |
fill_menubar (first_wv->contents); |
1552 |
|
|
1553 |
DrawMenuBar (); |
DrawMenuBar (); |
1554 |
|
|
1555 |
free_menubar_widget_value_tree (first_wv); |
free_menubar_widget_value_tree (first_wv); |
1556 |
|
|
1557 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
1640 |
wv->help = Qnil; |
wv->help = Qnil; |
1641 |
first_wv = wv; |
first_wv = wv; |
1642 |
first_pane = 1; |
first_pane = 1; |
1643 |
|
|
1644 |
/* Loop over all panes and items, filling in the tree. */ |
/* Loop over all panes and items, filling in the tree. */ |
1645 |
i = 0; |
i = 0; |
1646 |
while (i < menu_items_used) |
while (i < menu_items_used) |
1743 |
#endif /* not HAVE_MULTILINGUAL_MENU */ |
#endif /* not HAVE_MULTILINGUAL_MENU */ |
1744 |
|
|
1745 |
wv = xmalloc_widget_value (); |
wv = xmalloc_widget_value (); |
1746 |
if (prev_wv) |
if (prev_wv) |
1747 |
prev_wv->next = wv; |
prev_wv->next = wv; |
1748 |
else |
else |
1749 |
save_wv->contents = wv; |
save_wv->contents = wv; |
1750 |
wv->name = (char *) SDATA (item_name); |
wv->name = (char *) SDATA (item_name); |
1751 |
if (!NILP (descrip)) |
if (!NILP (descrip)) |
1830 |
menu_item_selection = LoWord (menu_item_choice); |
menu_item_selection = LoWord (menu_item_choice); |
1831 |
|
|
1832 |
/* Get the refcon to find the correct item*/ |
/* Get the refcon to find the correct item*/ |
1833 |
if (menu_item_selection) |
if (menu_item_selection) |
1834 |
{ |
{ |
1835 |
menu = GetMenuHandle (HiWord (menu_item_choice)); |
menu = GetMenuHandle (HiWord (menu_item_choice)); |
1836 |
if (menu) { |
if (menu) { |
1837 |
GetMenuItemRefCon (menu, menu_item_selection, &refcon); |
GetMenuItemRefCon (menu, menu_item_selection, &refcon); |
1838 |
} |
} |
1839 |
} |
} |
1840 |
|
|
1841 |
#if 0 |
#if 0 |
1842 |
/* Clean up extraneous mouse events which might have been generated |
/* Clean up extraneous mouse events which might have been generated |
1843 |
during the call. */ |
during the call. */ |
1944 |
SInt16 part_code; |
SInt16 part_code; |
1945 |
int control_part_code; |
int control_part_code; |
1946 |
Point mouse; |
Point mouse; |
1947 |
|
|
1948 |
dialog_name = wv->name; |
dialog_name = wv->name; |
1949 |
nb_buttons = dialog_name[1] - '0'; |
nb_buttons = dialog_name[1] - '0'; |
1950 |
left_count = nb_buttons - (dialog_name[4] - '0'); |
left_count = nb_buttons - (dialog_name[4] - '0'); |
1951 |
button_labels = (char **) alloca (sizeof (char *) * nb_buttons); |
button_labels = (char **) alloca (sizeof (char *) * nb_buttons); |
1952 |
ref_cons = (UInt32 *) alloca (sizeof (UInt32) * nb_buttons); |
ref_cons = (UInt32 *) alloca (sizeof (UInt32) * nb_buttons); |
1953 |
|
|
1954 |
wv = wv->contents; |
wv = wv->contents; |
1955 |
prompt = (char *) alloca (strlen (wv->value) + 1); |
prompt = (char *) alloca (strlen (wv->value) + 1); |
1956 |
strcpy (prompt, wv->value); |
strcpy (prompt, wv->value); |
1974 |
#else |
#else |
1975 |
SetPort (window_ptr); |
SetPort (window_ptr); |
1976 |
#endif |
#endif |
1977 |
|
|
1978 |
TextFont (0); |
TextFont (0); |
1979 |
/* Left and right margins in the dialog are 13 pixels each.*/ |
/* Left and right margins in the dialog are 13 pixels each.*/ |
1980 |
dialog_width = 14; |
dialog_width = 14; |
1996 |
#else |
#else |
1997 |
SetPort (window_ptr); |
SetPort (window_ptr); |
1998 |
#endif |
#endif |
1999 |
|
|
2000 |
TextFont (0); |
TextFont (0); |
2001 |
|
|
2002 |
MoveTo (13, 29); |
MoveTo (13, 29); |
2034 |
} |
} |
2035 |
|
|
2036 |
DisposeWindow (window_ptr); |
DisposeWindow (window_ptr); |
2037 |
|
|
2038 |
return i; |
return i; |
2039 |
} |
} |
2040 |
|
|
2076 |
pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; |
pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; |
2077 |
prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; |
prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; |
2078 |
pane_string = (NILP (pane_name) |
pane_string = (NILP (pane_name) |
2079 |
? "" : (char *) SDATA (pane_name)); |
? "" : (char *) SDATA (pane_name)); |
2080 |
prev_wv = xmalloc_widget_value (); |
prev_wv = xmalloc_widget_value (); |
2081 |
prev_wv->value = pane_string; |
prev_wv->value = pane_string; |
2082 |
if (keymaps && !NILP (prefix)) |
if (keymaps && !NILP (prefix)) |
2085 |
prev_wv->name = "message"; |
prev_wv->name = "message"; |
2086 |
prev_wv->help = Qnil; |
prev_wv->help = Qnil; |
2087 |
first_wv = prev_wv; |
first_wv = prev_wv; |
2088 |
|
|
2089 |
/* Loop over all panes and items, filling in the tree. */ |
/* Loop over all panes and items, filling in the tree. */ |
2090 |
i = MENU_ITEMS_PANE_LENGTH; |
i = MENU_ITEMS_PANE_LENGTH; |
2091 |
while (i < menu_items_used) |
while (i < menu_items_used) |
2092 |
{ |
{ |
2093 |
|
|
2094 |
/* Create a new item within current pane. */ |
/* Create a new item within current pane. */ |
2095 |
Lisp_Object item_name, enable, descrip, help; |
Lisp_Object item_name, enable, descrip, help; |
2096 |
|
|
2099 |
descrip |
descrip |
2100 |
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
2101 |
help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
2102 |
|
|
2103 |
if (NILP (item_name)) |
if (NILP (item_name)) |
2104 |
{ |
{ |
2105 |
free_menubar_widget_value_tree (first_wv); |
free_menubar_widget_value_tree (first_wv); |
2240 |
|
|
2241 |
if (name_is_separator (wv->name)) |
if (name_is_separator (wv->name)) |
2242 |
AppendMenu (menu, "\p-"); |
AppendMenu (menu, "\p-"); |
2243 |
else |
else |
2244 |
{ |
{ |
2245 |
AppendMenu (menu, "\pX"); |
AppendMenu (menu, "\pX"); |
2246 |
|
|
2247 |
#if TARGET_API_MAC_CARBON |
#if TARGET_API_MAC_CARBON |
2248 |
pos = CountMenuItems (menu); |
pos = CountMenuItems (menu); |
2249 |
#else |
#else |
2340 |
{ |
{ |
2341 |
MenuHandle menu; |
MenuHandle menu; |
2342 |
Str255 title; |
Str255 title; |
2343 |
|
|
2344 |
strncpy (title, wv->name, 255); |
strncpy (title, wv->name, 255); |
2345 |
title[255] = 0; |
title[255] = 0; |
2346 |
c2pstr (title); |
c2pstr (title); |
2348 |
|
|
2349 |
if (wv->contents) |
if (wv->contents) |
2350 |
fill_menu (menu, wv->contents); |
fill_menu (menu, wv->contents); |
2351 |
|
|
2352 |
InsertMenu (menu, 0); |
InsertMenu (menu, 0); |
2353 |
} |
} |
2354 |
} |
} |