Mercurial > emacs
comparison src/macmenu.c @ 90602:b5c13d1564a9
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 437-446)
- Update from CVS
- lisp/url/url-methods.el: Fix format error when http_proxy is empty string
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 137-140)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-111
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 20 Sep 2006 06:04:23 +0000 |
parents | a1a25ac6c88a 93e945b1789c |
children | 02cf29720f31 |
comparison
equal
deleted
inserted
replaced
90601:a1a25ac6c88a | 90602:b5c13d1564a9 |
---|---|
62 | 62 |
63 #include "dispextern.h" | 63 #include "dispextern.h" |
64 | 64 |
65 enum mac_menu_kind { /* Menu ID range */ | 65 enum mac_menu_kind { /* Menu ID range */ |
66 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */ | 66 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */ |
67 MAC_MENU_MENU_BAR, /* 1 .. 234 */ | 67 MAC_MENU_MENU_BAR, /* 1 .. 233 */ |
68 MAC_MENU_M_APPLE, /* 234 (== M_APPLE) */ | |
68 MAC_MENU_POPUP, /* 235 */ | 69 MAC_MENU_POPUP, /* 235 */ |
69 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */ | 70 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */ |
70 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */ | 71 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */ |
71 MAC_MENU_POPUP_SUB, /* 16384 .. 32767 */ | 72 MAC_MENU_POPUP_SUB, /* 16384 .. 32767 */ |
72 MAC_MENU_END /* 32768 */ | 73 MAC_MENU_END /* 32768 */ |
73 }; | 74 }; |
74 | 75 |
75 static const int min_menu_id[] = {0, 1, 235, 236, 256, 16384, 32768}; | 76 static const int min_menu_id[] = {0, 1, 234, 235, 236, 256, 16384, 32768}; |
76 | 77 |
77 #define DIALOG_WINDOW_RESOURCE 130 | 78 #define DIALOG_WINDOW_RESOURCE 130 |
78 | 79 |
79 #define HAVE_DIALOGS 1 | 80 #define HAVE_DIALOGS 1 |
80 | 81 |
194 static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object, | 195 static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object, |
195 int, int)); | 196 int, int)); |
196 static void list_of_panes P_ ((Lisp_Object)); | 197 static void list_of_panes P_ ((Lisp_Object)); |
197 static void list_of_items P_ ((Lisp_Object)); | 198 static void list_of_items P_ ((Lisp_Object)); |
198 | 199 |
200 static void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object, | |
201 void *)); | |
199 static int fill_menu P_ ((MenuHandle, widget_value *, enum mac_menu_kind, int)); | 202 static int fill_menu P_ ((MenuHandle, widget_value *, enum mac_menu_kind, int)); |
200 static void fill_menubar P_ ((widget_value *, int)); | 203 static void fill_menubar P_ ((widget_value *, int)); |
201 static void dispose_menus P_ ((enum mac_menu_kind, int)); | 204 static void dispose_menus P_ ((enum mac_menu_kind, int)); |
202 | 205 |
203 | 206 |
1013 void | 1016 void |
1014 x_activate_menubar (f) | 1017 x_activate_menubar (f) |
1015 FRAME_PTR f; | 1018 FRAME_PTR f; |
1016 { | 1019 { |
1017 SInt32 menu_choice; | 1020 SInt32 menu_choice; |
1021 SInt16 menu_id, menu_item; | |
1018 extern Point saved_menu_event_location; | 1022 extern Point saved_menu_event_location; |
1019 | 1023 |
1020 set_frame_menubar (f, 0, 1); | 1024 set_frame_menubar (f, 0, 1); |
1021 BLOCK_INPUT; | 1025 BLOCK_INPUT; |
1022 | 1026 |
1023 menu_choice = MenuSelect (saved_menu_event_location); | 1027 menu_choice = MenuSelect (saved_menu_event_location); |
1024 do_menu_choice (menu_choice); | 1028 menu_id = HiWord (menu_choice); |
1029 menu_item = LoWord (menu_choice); | |
1030 | |
1031 #if !TARGET_API_MAC_CARBON | |
1032 if (menu_id == min_menu_id[MAC_MENU_M_APPLE]) | |
1033 do_apple_menu (menu_item); | |
1034 else | |
1035 #endif | |
1036 if (menu_id) | |
1037 { | |
1038 MenuHandle menu = GetMenuHandle (menu_id); | |
1039 | |
1040 if (menu) | |
1041 { | |
1042 UInt32 refcon; | |
1043 | |
1044 GetMenuItemRefCon (menu, menu_item, &refcon); | |
1045 find_and_call_menu_selection (f, f->menu_bar_items_used, | |
1046 f->menu_bar_vector, (void *) refcon); | |
1047 } | |
1048 } | |
1049 | |
1050 HiliteMenu (0); | |
1025 | 1051 |
1026 UNBLOCK_INPUT; | 1052 UNBLOCK_INPUT; |
1027 } | 1053 } |
1028 | 1054 |
1029 /* This callback is called from the menu bar pulldown menu | 1055 /* Find the menu selection and store it in the keyboard buffer. |
1030 when the user makes a selection. | 1056 F is the frame the menu is on. |
1031 Figure out what the user chose | 1057 MENU_BAR_ITEMS_USED is the length of VECTOR. |
1032 and put the appropriate events into the keyboard buffer. */ | 1058 VECTOR is an array of menu events for the whole menu. */ |
1033 | 1059 |
1034 void | 1060 static void |
1035 menubar_selection_callback (FRAME_PTR f, int client_data) | 1061 find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) |
1062 FRAME_PTR f; | |
1063 int menu_bar_items_used; | |
1064 Lisp_Object vector; | |
1065 void *client_data; | |
1036 { | 1066 { |
1037 Lisp_Object prefix, entry; | 1067 Lisp_Object prefix, entry; |
1038 Lisp_Object vector; | |
1039 Lisp_Object *subprefix_stack; | 1068 Lisp_Object *subprefix_stack; |
1040 int submenu_depth = 0; | 1069 int submenu_depth = 0; |
1041 int i; | 1070 int i; |
1042 | 1071 |
1043 if (!f) | |
1044 return; | |
1045 entry = Qnil; | 1072 entry = Qnil; |
1046 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); | 1073 subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object)); |
1047 vector = f->menu_bar_vector; | |
1048 prefix = Qnil; | 1074 prefix = Qnil; |
1049 i = 0; | 1075 i = 0; |
1050 while (i < f->menu_bar_items_used) | 1076 |
1077 while (i < menu_bar_items_used) | |
1051 { | 1078 { |
1052 if (EQ (XVECTOR (vector)->contents[i], Qnil)) | 1079 if (EQ (XVECTOR (vector)->contents[i], Qnil)) |
1053 { | 1080 { |
1054 subprefix_stack[submenu_depth++] = prefix; | 1081 subprefix_stack[submenu_depth++] = prefix; |
1055 prefix = entry; | 1082 prefix = entry; |
1103 buf.kind = MENU_BAR_EVENT; | 1130 buf.kind = MENU_BAR_EVENT; |
1104 buf.frame_or_window = frame; | 1131 buf.frame_or_window = frame; |
1105 buf.arg = entry; | 1132 buf.arg = entry; |
1106 kbd_buffer_store_event (&buf); | 1133 kbd_buffer_store_event (&buf); |
1107 | 1134 |
1108 f->output_data.mac->menubar_active = 0; | |
1109 return; | 1135 return; |
1110 } | 1136 } |
1111 i += MENU_ITEMS_ITEM_LENGTH; | 1137 i += MENU_ITEMS_ITEM_LENGTH; |
1112 } | 1138 } |
1113 } | 1139 } |
1114 f->output_data.mac->menubar_active = 0; | |
1115 } | 1140 } |
1116 | 1141 |
1117 /* Allocate a widget_value, blocking input. */ | 1142 /* Allocate a widget_value, blocking input. */ |
1118 | 1143 |
1119 widget_value * | 1144 widget_value * |
1505 Lisp_Object items; | 1530 Lisp_Object items; |
1506 widget_value *wv, *first_wv, *prev_wv = 0; | 1531 widget_value *wv, *first_wv, *prev_wv = 0; |
1507 int i, last_i = 0; | 1532 int i, last_i = 0; |
1508 int *submenu_start, *submenu_end; | 1533 int *submenu_start, *submenu_end; |
1509 int *submenu_top_level_items, *submenu_n_panes; | 1534 int *submenu_top_level_items, *submenu_n_panes; |
1510 | |
1511 /* We must not change the menubar when actually in use. */ | |
1512 if (f->output_data.mac->menubar_active) | |
1513 return; | |
1514 | 1535 |
1515 XSETFRAME (Vmenu_updating_frame, f); | 1536 XSETFRAME (Vmenu_updating_frame, f); |
1516 | 1537 |
1517 if (! menubar_widget) | 1538 if (! menubar_widget) |
1518 deep_p = 1; | 1539 deep_p = 1; |