Mercurial > emacs
comparison src/macmenu.c @ 83542:2d56e13fd23d
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-413
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-414
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-415
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-416
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-417
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-418
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-419
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-420
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-421
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-422
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-423
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-424
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-425
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-426
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-427
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-428
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-429
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-430
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-431
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-432
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-433
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-434
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-435
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-436
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-437
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-438
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-439
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-440
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-441
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
* emacs@sv.gnu.org/emacs--devo--0--patch-442
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-443
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-444
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-445
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-446
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-447
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-448
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-449
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-450
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-451
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-452
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-453
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-454
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-455
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-456
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-457
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-458
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-459
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-460
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-461
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-462
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-463
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-464
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-465
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-466
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-467
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-468
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-469
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-470
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-471
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-472
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-473
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-128
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-129
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-130
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-131
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-132
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-133
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-134
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-135
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-136
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-137
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-138
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-139
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-140
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-141
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-142
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-143
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-144
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-145
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-146
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-147
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-148
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-149
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-582
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 14 Oct 2006 17:36:28 +0000 |
parents | 93e945b1789c |
children | 4d143b423b75 b5c13d1564a9 |
comparison
equal
deleted
inserted
replaced
83541:694bbb62a75d | 83542:2d56e13fd23d |
---|---|
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 |
156 #ifndef TRUE | 157 #ifndef TRUE |
157 #define TRUE 1 | 158 #define TRUE 1 |
158 #define FALSE 0 | 159 #define FALSE 0 |
159 #endif /* no TRUE */ | 160 #endif /* no TRUE */ |
160 | 161 |
161 Lisp_Object Vmenu_updating_frame; | |
162 | |
163 Lisp_Object Qdebug_on_next_call; | 162 Lisp_Object Qdebug_on_next_call; |
163 | |
164 extern Lisp_Object Vmenu_updating_frame; | |
164 | 165 |
165 extern Lisp_Object Qmenu_bar, Qmac_apple_event; | 166 extern Lisp_Object Qmenu_bar, Qmac_apple_event; |
166 | 167 |
167 extern Lisp_Object QCtoggle, QCradio; | 168 extern Lisp_Object QCtoggle, QCradio; |
168 | 169 |
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; |
2628 menu_items = Qnil; | 2649 menu_items = Qnil; |
2629 | 2650 |
2630 Qdebug_on_next_call = intern ("debug-on-next-call"); | 2651 Qdebug_on_next_call = intern ("debug-on-next-call"); |
2631 staticpro (&Qdebug_on_next_call); | 2652 staticpro (&Qdebug_on_next_call); |
2632 | 2653 |
2633 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame, | |
2634 doc: /* Frame for which we are updating a menu. | |
2635 The enable predicate for a menu command should check this variable. */); | |
2636 Vmenu_updating_frame = Qnil; | |
2637 | |
2638 defsubr (&Sx_popup_menu); | 2654 defsubr (&Sx_popup_menu); |
2639 #ifdef HAVE_MENUS | 2655 #ifdef HAVE_MENUS |
2640 defsubr (&Sx_popup_dialog); | 2656 defsubr (&Sx_popup_dialog); |
2641 #endif | 2657 #endif |
2642 } | 2658 } |