46 |
precompiled header Carbon.h. */ |
precompiled header Carbon.h. */ |
47 |
#undef max |
#undef max |
48 |
#undef min |
#undef min |
49 |
|
#undef init_process |
50 |
#include <Carbon/Carbon.h> |
#include <Carbon/Carbon.h> |
51 |
#undef Z |
#undef Z |
52 |
#define Z (current_buffer->text->z) |
#define Z (current_buffer->text->z) |
60 |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
61 |
#undef max |
#undef max |
62 |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
63 |
|
#undef init_process |
64 |
|
#define init_process emacs_init_process |
65 |
#else /* not MAC_OSX */ |
#else /* not MAC_OSX */ |
66 |
#include <MacTypes.h> |
#include <MacTypes.h> |
67 |
#include <Menus.h> |
#include <Menus.h> |
89 |
#include "dispextern.h" |
#include "dispextern.h" |
90 |
|
|
91 |
#define POPUP_SUBMENU_ID 235 |
#define POPUP_SUBMENU_ID 235 |
92 |
|
#define MIN_POPUP_SUBMENU_ID 512 |
93 |
#define MIN_MENU_ID 256 |
#define MIN_MENU_ID 256 |
94 |
#define MIN_SUBMENU_ID 1 |
#define MIN_SUBMENU_ID 1 |
95 |
|
|
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 |
180 |
Lisp_Object Qdebug_on_next_call; |
Lisp_Object Qdebug_on_next_call; |
181 |
|
|
182 |
extern Lisp_Object Qmenu_bar; |
extern Lisp_Object Qmenu_bar; |
|
extern Lisp_Object Qmouse_click, Qevent_kind; |
|
183 |
|
|
184 |
extern Lisp_Object QCtoggle, QCradio; |
extern Lisp_Object QCtoggle, QCradio; |
185 |
|
|
206 |
static void list_of_panes (); |
static void list_of_panes (); |
207 |
static void list_of_items (); |
static void list_of_items (); |
208 |
|
|
209 |
static void fill_submenu (MenuHandle, widget_value *, int); |
static void fill_submenu (MenuHandle, widget_value *); |
210 |
static void fill_menubar (widget_value *); |
static void fill_menubar (widget_value *); |
211 |
|
|
212 |
|
|
268 |
Xt on behalf of one of the widget sets. */ |
Xt on behalf of one of the widget sets. */ |
269 |
static int popup_activated_flag; |
static int popup_activated_flag; |
270 |
|
|
271 |
|
/* Index of the next submenu */ |
272 |
|
static int submenu_id; |
273 |
|
|
274 |
static int next_menubar_widget_id; |
static int next_menubar_widget_id; |
275 |
|
|
276 |
/* This is set nonzero after the user activates the menu bar, and set |
/* This is set nonzero after the user activates the menu bar, and set |
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) && XSTRING (item_string)->data[0] == '@') |
if (!NILP (map) && SREF (item_string, 0) == '@') |
549 |
{ |
{ |
550 |
if (!NILP (enabled)) |
if (!NILP (enabled)) |
551 |
/* An enabled separate pane. Remember this to handle it later. */ |
/* An enabled separate pane. Remember this to handle it later. */ |
818 |
|
|
819 |
keymaps = 0; |
keymaps = 0; |
820 |
} |
} |
821 |
|
|
822 |
if (NILP (position)) |
if (NILP (position)) |
823 |
{ |
{ |
824 |
discard_menu_items (); |
discard_menu_items (); |
962 |
|
|
963 |
/* Activate the menu bar of frame F. |
/* Activate the menu bar of frame F. |
964 |
This is called from keyboard.c when it gets the |
This is called from keyboard.c when it gets the |
965 |
menu_bar_activate_event out of the Emacs event queue. |
MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue. |
966 |
|
|
967 |
To activate the menu bar, we signal to the input thread that it can |
To activate the menu bar, we signal to the input thread that it can |
968 |
return from the WM_INITMENU message, allowing the normal Windows |
return from the WM_INITMENU message, allowing the normal Windows |
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 |
1227 |
} |
} |
1228 |
#endif |
#endif |
1229 |
pane_string = (NILP (pane_name) |
pane_string = (NILP (pane_name) |
1230 |
? "" : (char *) XSTRING (pane_name)->data); |
? "" : (char *) SDATA (pane_name)); |
1231 |
/* If there is just one top-level pane, put all its items directly |
/* If there is just one top-level pane, put all its items directly |
1232 |
under the top-level menu. */ |
under the top-level menu. */ |
1233 |
if (menu_items_n_panes == 1) |
if (menu_items_n_panes == 1) |
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; |
1293 |
|
|
1294 |
wv->name = (char *) XSTRING (item_name)->data; |
wv->name = (char *) SDATA (item_name); |
1295 |
if (!NILP (descrip)) |
if (!NILP (descrip)) |
1296 |
wv->key = (char *) XSTRING (descrip)->data; |
wv->key = (char *) SDATA (descrip); |
1297 |
wv->value = 0; |
wv->value = 0; |
1298 |
/* The EMACS_INT cast avoids a warning. There's no problem |
/* The EMACS_INT cast avoids a warning. There's no problem |
1299 |
as long as pointers have enough bits to hold small integers. */ |
as long as pointers have enough bits to hold small integers. */ |
1373 |
|
|
1374 |
struct buffer *prev = current_buffer; |
struct buffer *prev = current_buffer; |
1375 |
Lisp_Object buffer; |
Lisp_Object buffer; |
1376 |
int specpdl_count = specpdl_ptr - specpdl; |
int specpdl_count = SPECPDL_INDEX (); |
1377 |
int previous_menu_items_used = f->menu_bar_items_used; |
int previous_menu_items_used = f->menu_bar_items_used; |
1378 |
Lisp_Object *previous_items |
Lisp_Object *previous_items |
1379 |
= (Lisp_Object *) alloca (previous_menu_items_used |
= (Lisp_Object *) alloca (previous_menu_items_used |
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; |
1474 |
string = XVECTOR (items)->contents[i + 1]; |
string = XVECTOR (items)->contents[i + 1]; |
1475 |
if (NILP (string)) |
if (NILP (string)) |
1476 |
break; |
break; |
1477 |
wv->name = (char *) XSTRING (string)->data; |
wv->name = (char *) SDATA (string); |
1478 |
wv = wv->next; |
wv = wv->next; |
1479 |
} |
} |
1480 |
|
|
1497 |
break; |
break; |
1498 |
|
|
1499 |
wv = xmalloc_widget_value (); |
wv = xmalloc_widget_value (); |
1500 |
wv->name = (char *) XSTRING (string)->data; |
wv->name = (char *) SDATA (string); |
1501 |
wv->value = 0; |
wv->value = 0; |
1502 |
wv->enabled = 1; |
wv->enabled = 1; |
1503 |
wv->button_type = BUTTON_TYPE_NONE; |
wv->button_type = BUTTON_TYPE_NONE; |
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; |
1609 |
char **error; |
char **error; |
1610 |
{ |
{ |
1611 |
int i; |
int i; |
1612 |
|
UInt32 refcon; |
1613 |
|
int menu_item_choice; |
1614 |
int menu_item_selection; |
int menu_item_selection; |
1615 |
MenuHandle menu; |
MenuHandle menu; |
1616 |
Point pos; |
Point pos; |
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) |
1682 |
} |
} |
1683 |
#endif |
#endif |
1684 |
pane_string = (NILP (pane_name) |
pane_string = (NILP (pane_name) |
1685 |
? "" : (char *) XSTRING (pane_name)->data); |
? "" : (char *) SDATA (pane_name)); |
1686 |
/* If there is just one top-level pane, put all its items directly |
/* If there is just one top-level pane, put all its items directly |
1687 |
under the top-level menu. */ |
under the top-level menu. */ |
1688 |
if (menu_items_n_panes == 1) |
if (menu_items_n_panes == 1) |
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 *) XSTRING (item_name)->data; |
wv->name = (char *) SDATA (item_name); |
1751 |
if (!NILP (descrip)) |
if (!NILP (descrip)) |
1752 |
wv->key = (char *) XSTRING (descrip)->data; |
wv->key = (char *) SDATA (descrip); |
1753 |
wv->value = 0; |
wv->value = 0; |
1754 |
/* Use the contents index as call_data, since we are |
/* Use the contents index as call_data, since we are |
1755 |
restricted to 16-bits. */ |
restricted to 16-bits. */ |
1793 |
if (STRING_MULTIBYTE (title)) |
if (STRING_MULTIBYTE (title)) |
1794 |
title = ENCODE_SYSTEM (title); |
title = ENCODE_SYSTEM (title); |
1795 |
#endif |
#endif |
1796 |
wv_title->name = (char *) XSTRING (title)->data; |
wv_title->name = (char *) SDATA (title); |
1797 |
wv_title->enabled = TRUE; |
wv_title->enabled = TRUE; |
1798 |
wv_title->title = TRUE; |
wv_title->title = TRUE; |
1799 |
wv_title->button_type = BUTTON_TYPE_NONE; |
wv_title->button_type = BUTTON_TYPE_NONE; |
1804 |
|
|
1805 |
/* Actually create the menu. */ |
/* Actually create the menu. */ |
1806 |
menu = NewMenu (POPUP_SUBMENU_ID, "\p"); |
menu = NewMenu (POPUP_SUBMENU_ID, "\p"); |
1807 |
fill_submenu (menu, first_wv->contents, 0); |
submenu_id = MIN_POPUP_SUBMENU_ID; |
1808 |
|
fill_submenu (menu, first_wv->contents); |
1809 |
|
|
1810 |
/* Adjust coordinates to be root-window-relative. */ |
/* Adjust coordinates to be root-window-relative. */ |
1811 |
pos.h = x; |
pos.h = x; |
1820 |
LocalToGlobal (&pos); |
LocalToGlobal (&pos); |
1821 |
|
|
1822 |
/* No selection has been chosen yet. */ |
/* No selection has been chosen yet. */ |
1823 |
|
menu_item_choice = 0; |
1824 |
menu_item_selection = 0; |
menu_item_selection = 0; |
1825 |
|
|
1826 |
InsertMenu (menu, -1); |
InsertMenu (menu, -1); |
1827 |
|
|
1828 |
/* Display the menu. */ |
/* Display the menu. */ |
1829 |
menu_item_selection = LoWord (PopUpMenuSelect (menu, pos.v, pos.h, 0)); |
menu_item_choice = PopUpMenuSelect (menu, pos.v, pos.h, 0); |
1830 |
|
menu_item_selection = LoWord (menu_item_choice); |
1831 |
|
|
1832 |
|
/* Get the refcon to find the correct item*/ |
1833 |
|
if (menu_item_selection) |
1834 |
|
{ |
1835 |
|
menu = GetMenuHandle (HiWord (menu_item_choice)); |
1836 |
|
if (menu) { |
1837 |
|
GetMenuItemRefCon (menu, menu_item_selection, &refcon); |
1838 |
|
} |
1839 |
|
} |
1840 |
|
|
|
DeleteMenu (POPUP_SUBMENU_ID); |
|
|
|
|
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. */ |
1848 |
contents. */ |
contents. */ |
1849 |
free_menubar_widget_value_tree (first_wv); |
free_menubar_widget_value_tree (first_wv); |
1850 |
|
|
1851 |
|
/* delete all menus */ |
1852 |
|
{ |
1853 |
|
int i = MIN_POPUP_SUBMENU_ID; |
1854 |
|
MenuHandle submenu = GetMenuHandle (i); |
1855 |
|
while (menu != NULL) |
1856 |
|
{ |
1857 |
|
DeleteMenu (i); |
1858 |
|
DisposeMenu (menu); |
1859 |
|
menu = GetMenuHandle (++i); |
1860 |
|
} |
1861 |
|
} |
1862 |
|
|
1863 |
|
DeleteMenu (POPUP_SUBMENU_ID); |
1864 |
DisposeMenu (menu); |
DisposeMenu (menu); |
1865 |
|
|
1866 |
/* Find the selected item, and its pane, to return |
/* Find the selected item, and its pane, to return |
1898 |
{ |
{ |
1899 |
entry |
entry |
1900 |
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
1901 |
if (menu_item_selection == i) |
if ((int) (EMACS_INT) refcon == i) |
1902 |
{ |
{ |
1903 |
if (keymaps != 0) |
if (keymaps != 0) |
1904 |
{ |
{ |
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 *) XSTRING (pane_name)->data); |
? "" : (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); |
2125 |
prev_wv->next = wv; |
prev_wv->next = wv; |
2126 |
wv->name = (char *) button_names[nb_buttons]; |
wv->name = (char *) button_names[nb_buttons]; |
2127 |
if (!NILP (descrip)) |
if (!NILP (descrip)) |
2128 |
wv->key = (char *) XSTRING (descrip)->data; |
wv->key = (char *) SDATA (descrip); |
2129 |
wv->value = (char *) XSTRING (item_name)->data; |
wv->value = (char *) SDATA (item_name); |
2130 |
wv->call_data = (void *) i; |
wv->call_data = (void *) i; |
2131 |
/* menu item is identified by its index in menu_items table */ |
/* menu item is identified by its index in menu_items table */ |
2132 |
wv->enabled = !NILP (enable); |
wv->enabled = !NILP (enable); |
2232 |
} |
} |
2233 |
|
|
2234 |
static void |
static void |
2235 |
add_menu_item (MenuHandle menu, widget_value *wv, int submenu, int indent, |
add_menu_item (MenuHandle menu, widget_value *wv, int submenu, |
2236 |
int force_disable) |
int force_disable) |
2237 |
{ |
{ |
2238 |
Str255 item_name; |
Str255 item_name; |
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 |
2251 |
#endif |
#endif |
2252 |
|
|
2253 |
strcpy (item_name, ""); |
strcpy (item_name, ""); |
2254 |
for (i = 0; i < indent; i++) |
strncat (item_name, wv->name, 255); |
|
strcat (item_name, " "); |
|
|
strcat (item_name, wv->name); |
|
2255 |
if (wv->key != NULL) |
if (wv->key != NULL) |
2256 |
{ |
{ |
2257 |
strcat (item_name, " "); |
strncat (item_name, " ", 255); |
2258 |
strcat (item_name, wv->key); |
strncat (item_name, wv->key, 255); |
2259 |
} |
} |
2260 |
|
item_name[255] = 0; |
2261 |
c2pstr (item_name); |
c2pstr (item_name); |
2262 |
SetMenuItemText (menu, pos, item_name); |
SetMenuItemText (menu, pos, item_name); |
2263 |
|
|
2290 |
SetMenuItemHierarchicalID (menu, pos, submenu); |
SetMenuItemHierarchicalID (menu, pos, submenu); |
2291 |
} |
} |
2292 |
|
|
|
static int submenu_id; |
|
|
|
|
2293 |
/* Construct native Mac OS menubar based on widget_value tree. */ |
/* Construct native Mac OS menubar based on widget_value tree. */ |
2294 |
|
|
2295 |
static void |
static void |
2296 |
fill_submenu (MenuHandle menu, widget_value *wv, int indent) |
fill_submenu (MenuHandle menu, widget_value *wv) |
2297 |
{ |
{ |
2298 |
for ( ; wv != NULL; wv = wv->next) |
for ( ; wv != NULL; wv = wv->next) |
2299 |
if (wv->contents) |
if (wv->contents) |
2300 |
{ |
{ |
2301 |
add_menu_item (menu, wv, NULL, indent, 1); |
int cur_submenu = submenu_id++; |
2302 |
|
MenuHandle submenu = NewMenu (cur_submenu, "\pX"); |
2303 |
fill_submenu (menu, wv->contents, indent + 1); |
fill_submenu (submenu, wv->contents); |
2304 |
|
InsertMenu (submenu, -1); |
2305 |
|
add_menu_item (menu, wv, cur_submenu, 0); |
2306 |
} |
} |
2307 |
else |
else |
2308 |
add_menu_item (menu, wv, NULL, indent, 0); |
add_menu_item (menu, wv, NULL, 0); |
2309 |
} |
} |
2310 |
|
|
2311 |
|
|
2317 |
for ( ; wv != NULL; wv = wv->next) |
for ( ; wv != NULL; wv = wv->next) |
2318 |
if (wv->contents) |
if (wv->contents) |
2319 |
{ |
{ |
2320 |
MenuHandle submenu = NewMenu (submenu_id, "\pX"); |
int cur_submenu = submenu_id++; |
2321 |
fill_submenu (submenu, wv->contents, 0); |
MenuHandle submenu = NewMenu (cur_submenu, "\pX"); |
2322 |
|
fill_submenu (submenu, wv->contents); |
2323 |
InsertMenu (submenu, -1); |
InsertMenu (submenu, -1); |
2324 |
add_menu_item (menu, wv, submenu_id, 0, 0); |
add_menu_item (menu, wv, cur_submenu, 0); |
|
submenu_id++; |
|
2325 |
} |
} |
2326 |
else |
else |
2327 |
add_menu_item (menu, wv, NULL, 0, 0); |
add_menu_item (menu, wv, NULL, 0); |
2328 |
} |
} |
2329 |
|
|
2330 |
/* Construct native Mac OS menubar based on widget_value tree. */ |
/* Construct native Mac OS menubar based on widget_value tree. */ |
2340 |
{ |
{ |
2341 |
MenuHandle menu; |
MenuHandle menu; |
2342 |
Str255 title; |
Str255 title; |
2343 |
|
|
2344 |
strcpy (title, wv->name); |
strncpy (title, wv->name, 255); |
2345 |
|
title[255] = 0; |
2346 |
c2pstr (title); |
c2pstr (title); |
2347 |
menu = NewMenu (id, title); |
menu = NewMenu (id, 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 |
} |
} |