13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1 /* X Communication module for terminals which understand the X protocol.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
2 Copyright (C) 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
3
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
4 This file is part of GNU Emacs.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
5
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
9 any later version.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
10
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
14 GNU General Public License for more details.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
15
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to
|
14186
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
20
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
21 /* Written by Kevin Gallo. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
22
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
23 #include <signal.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
24 #include <config.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
25
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
26 #include <stdio.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
27 #include "lisp.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
28 #include "termhooks.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
29 #include "frame.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
30 #include "window.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
31 #include "keyboard.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
32 #include "blockinput.h"
|
15276
|
33 #include "buffer.h"
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
34
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
35 /* This may include sys/types.h, and that somehow loses
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
36 if this is not done before the other system files. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
37 #include "w32term.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
38
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
39 /* Load sys/types.h if not already loaded.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
40 In some systems loading it twice is suicidal. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
41 #ifndef makedev
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
42 #include <sys/types.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
43 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
44
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
45 #include "dispextern.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
46
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
47 #define min(x, y) (((x) < (y)) ? (x) : (y))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
48 #define max(x, y) (((x) > (y)) ? (x) : (y))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
49
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
50 typedef struct menu_map
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
51 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
52 Lisp_Object menu_items;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
53 int menu_items_allocated;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
54 int menu_items_used;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
55 } menu_map;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
56
|
15276
|
57 Lisp_Object Qdebug_on_next_call;
|
|
58
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
59 extern Lisp_Object Qmenu_enable;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
60 extern Lisp_Object Qmenu_bar;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
61
|
15276
|
62 extern Lisp_Object Voverriding_local_map;
|
|
63 extern Lisp_Object Voverriding_local_map_menu_flag;
|
|
64
|
|
65 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
|
|
66
|
|
67 extern Lisp_Object Qmenu_bar_update_hook;
|
|
68
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
69 static Lisp_Object win32_dialog_show ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
70 static Lisp_Object win32menu_show ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
71
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
72 static HMENU keymap_panes ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
73 static HMENU single_keymap_panes ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
74 static HMENU list_of_panes ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
75 static HMENU list_of_items ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
76
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
77 static HMENU create_menu_items ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
78
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
79 /* Initialize the menu_items structure if we haven't already done so.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
80 Also mark it as currently empty. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
81
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
82 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
83 init_menu_items (lpmm)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
84 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
85 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
86 if (NILP (lpmm->menu_items))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
87 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
88 lpmm->menu_items_allocated = 60;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
89 lpmm->menu_items = Fmake_vector (make_number (lpmm->menu_items_allocated),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
90 Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
91 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
92
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
93 lpmm->menu_items_used = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
94 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
95
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
96 /* Call when finished using the data for the current menu
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
97 in menu_items. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
98
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
99 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
100 discard_menu_items (lpmm)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
101 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
102 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
103 lpmm->menu_items = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
104 lpmm->menu_items_allocated = lpmm->menu_items_used = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
105 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
106
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
107 /* Make the menu_items vector twice as large. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
108
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
109 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
110 grow_menu_items (lpmm)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
111 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
112 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
113 Lisp_Object new;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
114 int old_size = lpmm->menu_items_allocated;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
115
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
116 lpmm->menu_items_allocated *= 2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
117 new = Fmake_vector (make_number (lpmm->menu_items_allocated), Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
118 bcopy (XVECTOR (lpmm->menu_items)->contents, XVECTOR (new)->contents,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
119 old_size * sizeof (Lisp_Object));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
120
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
121 lpmm->menu_items = new;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
122 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
123
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
124 /* Indicate boundary between left and right. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
125
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
126 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
127 add_left_right_boundary (hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
128 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
129 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
130 AppendMenu (hmenu, MF_MENUBARBREAK, 0, NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
131 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
132
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
133 /* Push one menu item into the current pane.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
134 NAME is the string to display. ENABLE if non-nil means
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
135 this item can be selected. KEY is the key generated by
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
136 choosing this item. EQUIV is the textual description
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
137 of the keyboard equivalent for this item (or nil if none). */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
138
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
139 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
140 add_menu_item (lpmm, hmenu, name, enable, key)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
141 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
142 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
143 Lisp_Object name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
144 UINT enable;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
145 Lisp_Object key;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
146 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
147 UINT fuFlags;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
148
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
149 if (NILP (name)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
150 || ((char *) XSTRING (name)->data)[0] == 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
151 || strcmp ((char *) XSTRING (name)->data, "--") == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
152 fuFlags = MF_SEPARATOR;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
153 else if (enable)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
154 fuFlags = MF_STRING;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
155 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
156 fuFlags = MF_STRING | MF_GRAYED;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
157
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
158 AppendMenu (hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
159 fuFlags,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
160 lpmm->menu_items_used + 1,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
161 (fuFlags == MF_SEPARATOR)?NULL: (char *) XSTRING (name)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
162
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
163 lpmm->menu_items_used++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
164 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
165 if (lpmm->menu_items_used >= lpmm->menu_items_allocated)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
166 grow_menu_items (lpmm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
167
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
168 XSET (XVECTOR (lpmm->menu_items)->contents[lpmm->menu_items_used++],
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
169 Lisp_Cons,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
170 key);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
171 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
172 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
173
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
174 /* Figure out the current keyboard equivalent of a menu item ITEM1.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
175 The item string for menu display should be ITEM_STRING.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
176 Store the equivalent keyboard key sequence's
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
177 textual description into *DESCRIP_PTR.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
178 Also cache them in the item itself.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
179 Return the real definition to execute. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
180
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
181 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
182 menu_item_equiv_key (item_string, item1, descrip_ptr)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
183 Lisp_Object item_string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
184 Lisp_Object item1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
185 Lisp_Object *descrip_ptr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
186 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
187 /* This is the real definition--the function to run. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
188 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
189 /* This is the sublist that records cached equiv key data
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
190 so we can save time. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
191 Lisp_Object cachelist;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
192 /* These are the saved equivalent keyboard key sequence
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
193 and its key-description. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
194 Lisp_Object savedkey, descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
195 Lisp_Object def1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
196 int changed = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
197 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
198
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
199 /* If a help string follows the item string, skip it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
200 if (CONSP (XCONS (item1)->cdr)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
201 && STRINGP (XCONS (XCONS (item1)->cdr)->car))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
202 item1 = XCONS (item1)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
203
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
204 def = Fcdr (item1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
205
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
206 /* Get out the saved equivalent-keyboard-key info. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
207 cachelist = savedkey = descrip = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
208 if (CONSP (def) && CONSP (XCONS (def)->car)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
209 && (NILP (XCONS (XCONS (def)->car)->car)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
210 || VECTORP (XCONS (XCONS (def)->car)->car)))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
211 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
212 cachelist = XCONS (def)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
213 def = XCONS (def)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
214 savedkey = XCONS (cachelist)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
215 descrip = XCONS (cachelist)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
216 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
217
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
218 GCPRO4 (def, def1, savedkey, descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
219
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
220 /* Is it still valid? */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
221 def1 = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
222 if (!NILP (savedkey))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
223 def1 = Fkey_binding (savedkey, Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
224 /* If not, update it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
225 if (! EQ (def1, def)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
226 /* If the command is an alias for another
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
227 (such as easymenu.el and lmenu.el set it up),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
228 check if the original command matches the cached command. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
229 && !(SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
230 && EQ (def1, XSYMBOL (def)->function))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
231 /* If something had no key binding before, don't recheck it--
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
232 doing that takes too much time and makes menus too slow. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
233 && !(!NILP (cachelist) && NILP (savedkey)))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
234 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
235 changed = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
236 descrip = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
237 savedkey = Fwhere_is_internal (def, Qnil, Qt, Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
238 /* If the command is an alias for another
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
239 (such as easymenu.el and lmenu.el set it up),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
240 see if the original command name has equivalent keys. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
241 if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
242 savedkey = Fwhere_is_internal (XSYMBOL (def)->function,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
243 Qnil, Qt, Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
244
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
245 if (VECTORP (savedkey)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
246 && EQ (XVECTOR (savedkey)->contents[0], Qmenu_bar))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
247 savedkey = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
248 if (!NILP (savedkey))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
249 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
250 descrip = Fkey_description (savedkey);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
251 descrip = concat2 (make_string (" (", 3), descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
252 descrip = concat2 (descrip, make_string (")", 1));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
253 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
254 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
255
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
256 /* Cache the data we just got in a sublist of the menu binding. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
257 if (NILP (cachelist))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
258 XCONS (item1)->cdr = Fcons (Fcons (savedkey, descrip), def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
259 else if (changed)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
260 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
261 XCONS (cachelist)->car = savedkey;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
262 XCONS (cachelist)->cdr = descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
263 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
264
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
265 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
266 *descrip_ptr = descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
267 return def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
268 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
269
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
270 /* This is used as the handler when calling internal_condition_case_1. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
271
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
272 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
273 menu_item_enabled_p_1 (arg)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
274 Lisp_Object arg;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
275 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
276 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
277 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
278
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
279 /* Return non-nil if the command DEF is enabled when used as a menu item.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
280 This is based on looking for a menu-enable property.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
281 If NOTREAL is set, don't bother really computing this. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
282
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
283 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
284 menu_item_enabled_p (def, notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
285 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
286 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
287 Lisp_Object enabled, tem;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
288
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
289 enabled = Qt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
290 if (notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
291 return enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
292 if (XTYPE (def) == Lisp_Symbol)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
293 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
294 /* No property, or nil, means enable.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
295 Otherwise, enable if value is not nil. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
296 tem = Fget (def, Qmenu_enable);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
297 if (!NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
298 /* (condition-case nil (eval tem)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
299 (error nil)) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
300 enabled = internal_condition_case_1 (Feval, tem, Qerror,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
301 menu_item_enabled_p_1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
302 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
303 return enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
304 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
305
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
306 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
307 and generate menu panes for them in menu_items.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
308 If NOTREAL is nonzero,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
309 don't bother really computing whether an item is enabled. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
310
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
311 static HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
312 keymap_panes (lpmm, keymaps, nmaps, notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
313 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
314 Lisp_Object *keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
315 int nmaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
316 int notreal;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
317 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
318 int mapno;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
319
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
320 // init_menu_items (lpmm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
321
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
322 if (nmaps > 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
323 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
324 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
325
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
326 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
327 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
328 hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
329
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
330 if (!hmenu) return (NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
331 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
332 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
333 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
334 hmenu = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
335 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
336
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
337 /* Loop over the given keymaps, making a pane for each map.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
338 But don't make a pane that is empty--ignore that map instead.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
339 P is the number of panes we have made so far. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
340 for (mapno = 0; mapno < nmaps; mapno++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
341 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
342 HMENU new_hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
343
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
344 new_hmenu = single_keymap_panes (lpmm, keymaps[mapno],
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
345 Qnil, Qnil, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
346
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
347 if (!notreal && new_hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
348 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
349 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu, "");
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
350 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
351 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
352
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
353 return (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
354 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
355 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
356 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
357 return (single_keymap_panes (lpmm, keymaps[0], Qnil, Qnil, notreal));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
358 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
359 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
360
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
361 /* This is a recursive subroutine of keymap_panes.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
362 It handles one keymap, KEYMAP.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
363 The other arguments are passed along
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
364 or point to local variables of the previous function.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
365 If NOTREAL is nonzero,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
366 don't bother really computing whether an item is enabled. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
367
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
368 HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
369 single_keymap_panes (lpmm, keymap, pane_name, prefix, notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
370 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
371 Lisp_Object keymap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
372 Lisp_Object pane_name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
373 Lisp_Object prefix;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
374 int notreal;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
375 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
376 Lisp_Object pending_maps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
377 Lisp_Object tail, item, item1, item_string, table;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
378 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
379 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
380
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
381 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
382 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
383 hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
384 if (hmenu == NULL) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
385 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
386 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
387 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
388 hmenu = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
389 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
390
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
391 pending_maps = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
392
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
393 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
394 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
395 /* Look at each key binding, and if it has a menu string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
396 make a menu item from it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
397
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
398 item = XCONS (tail)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
399
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
400 if (CONSP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
401 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
402 item1 = XCONS (item)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
403
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
404 if (XTYPE (item1) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
405 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
406 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
407 if (XTYPE (item_string) == Lisp_String)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
408 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
409 /* This is the real definition--the function to run. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
410
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
411 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
412
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
413 /* These are the saved equivalent keyboard key sequence
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
414 and its key-description. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
415
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
416 Lisp_Object descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
417 Lisp_Object tem, enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
418
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
419 /* GCPRO because ...enabled_p will call eval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
420 and ..._equiv_key may autoload something.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
421 Protecting KEYMAP preserves everything we use;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
422 aside from that, must protect whatever might be
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
423 a string. Since there's no GCPRO5, we refetch
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
424 item_string instead of protecting it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
425
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
426 descrip = def = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
427 GCPRO4 (keymap, pending_maps, def, prefix);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
428
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
429 def = menu_item_equiv_key (item_string, item1, &descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
430 enabled = menu_item_enabled_p (def, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
431
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
432 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
433
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
434 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
435
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
436 tem = Fkeymapp (def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
437 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
438 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
439 pending_maps = Fcons (Fcons (def,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
440 Fcons (item_string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
441 XCONS (item)->car)),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
442 pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
443 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
444 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
445 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
446 Lisp_Object submap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
447
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
448 GCPRO4 (keymap, pending_maps, item, item_string);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
449
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
450 submap = get_keymap_1 (def, 0, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
451
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
452 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
453
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
454 if (NILP (submap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
455 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
456 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
457 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
458 add_menu_item (lpmm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
459 hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
460 item_string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
461 !NILP (enabled),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
462 Fcons (XCONS (item)->car, prefix));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
463 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
464 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
465 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
466 /* Display a submenu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
467 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
468 HMENU new_hmenu = single_keymap_panes (lpmm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
469 submap,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
470 item_string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
471 XCONS (item)->car,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
472 notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
473
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
474 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
475 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
476 AppendMenu (hmenu, MF_POPUP,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
477 (UINT)new_hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
478 (char *) XSTRING (item_string)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
479 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
480 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
481 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
482 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
483 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
484 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
485 else if (VECTORP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
486 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
487 /* Loop over the char values represented in the vector. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
488 int len = XVECTOR (item)->size;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
489 int c;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
490 for (c = 0; c < len; c++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
491 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
492 Lisp_Object character;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
493 XSETFASTINT (character, c);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
494 item1 = XVECTOR (item)->contents[c];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
495 if (CONSP (item1))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
496 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
497 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
498 if (STRINGP (item_string))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
499 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
500 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
501
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
502 /* These are the saved equivalent keyboard key sequence
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
503 and its key-description. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
504 Lisp_Object descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
505 Lisp_Object tem, enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
506
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
507 /* GCPRO because ...enabled_p will call eval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
508 and ..._equiv_key may autoload something.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
509 Protecting KEYMAP preserves everything we use;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
510 aside from that, must protect whatever might be
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
511 a string. Since there's no GCPRO5, we refetch
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
512 item_string instead of protecting it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
513 GCPRO4 (keymap, pending_maps, def, descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
514 descrip = def = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
515
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
516 def = menu_item_equiv_key (item_string, item1, &descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
517 enabled = menu_item_enabled_p (def, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
518
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
519 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
520
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
521 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
522
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
523 tem = Fkeymapp (def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
524 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
525 pending_maps = Fcons (Fcons (def, Fcons (item_string, character)),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
526 pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
527 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
528 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
529 Lisp_Object submap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
530
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
531 GCPRO4 (keymap, pending_maps, descrip, item_string);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
532
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
533 submap = get_keymap_1 (def, 0, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
534
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
535 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
536
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
537 if (NILP (submap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
538 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
539 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
540 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
541 add_menu_item (lpmm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
542 hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
543 item_string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
544 !NILP (enabled),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
545 character);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
546 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
547 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
548 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
549 /* Display a submenu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
550 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
551 HMENU new_hmenu = single_keymap_panes (lpmm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
552 submap,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
553 Qnil,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
554 character,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
555 notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
556
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
557 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
558 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
559 AppendMenu (hmenu,MF_POPUP,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
560 (UINT)new_hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
561 (char *)XSTRING (item_string)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
562 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
563 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
564 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
565 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
566 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
567 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
568 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
569 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
570
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
571 /* Process now any submenus which want to be panes at this level. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
572 while (!NILP (pending_maps))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
573 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
574 Lisp_Object elt, eltcdr, string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
575 elt = Fcar (pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
576 eltcdr = XCONS (elt)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
577 string = XCONS (eltcdr)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
578 /* We no longer discard the @ from the beginning of the string here.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
579 Instead, we do this in win32menu_show. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
580 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
581 HMENU new_hmenu = single_keymap_panes (lpmm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
582 Fcar (elt),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
583 string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
584 XCONS (eltcdr)->cdr, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
585
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
586 if (!notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
587 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
588 AppendMenu (hmenu, MF_POPUP,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
589 (UINT)new_hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
590 (char *) XSTRING (string)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
591 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
592 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
593
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
594 pending_maps = Fcdr (pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
595 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
596
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
597 return (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
598 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
599
|
14036
|
600 /* Push all the panes and items of a menu described by the
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
601 alist-of-alists MENU.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
602 This handles old-fashioned calls to x-popup-menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
603
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
604 static HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
605 list_of_panes (lpmm, menu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
606 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
607 Lisp_Object menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
608 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
609 Lisp_Object tail;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
610 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
611
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
612 hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
613 if (hmenu == NULL) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
614
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
615 // init_menu_items (lpmm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
616
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
617 for (tail = menu; !NILP (tail); tail = Fcdr (tail))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
618 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
619 Lisp_Object elt, pane_name, pane_data;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
620 HMENU new_hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
621
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
622 elt = Fcar (tail);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
623 pane_name = Fcar (elt);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
624 CHECK_STRING (pane_name, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
625 pane_data = Fcdr (elt);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
626 CHECK_CONS (pane_data, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
627
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
628 new_hmenu = list_of_items (lpmm, pane_data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
629 if (new_hmenu == NULL) goto error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
630
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
631 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
632 (char *) XSTRING (pane_name)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
633 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
634
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
635 return (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
636
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
637 error:
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
638 DestroyMenu (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
639
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
640 return (NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
641 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
642
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
643 /* Push the items in a single pane defined by the alist PANE. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
644
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
645 static HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
646 list_of_items (lpmm, pane)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
647 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
648 Lisp_Object pane;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
649 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
650 Lisp_Object tail, item, item1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
651 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
652
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
653 hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
654 if (hmenu == NULL) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
655
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
656 for (tail = pane; !NILP (tail); tail = Fcdr (tail))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
657 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
658 item = Fcar (tail);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
659 if (STRINGP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
660 add_menu_item (lpmm, hmenu, item, Qnil, Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
661 else if (NILP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
662 add_left_right_boundary ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
663 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
664 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
665 CHECK_CONS (item, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
666 item1 = Fcar (item);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
667 CHECK_STRING (item1, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
668 add_menu_item (lpmm, hmenu, item1, Qt, Fcdr (item));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
669 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
670 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
671
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
672 return (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
673 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
674
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
675
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
676 HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
677 create_menu_items (lpmm, menu, notreal)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
678 menu_map * lpmm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
679 Lisp_Object menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
680 int notreal;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
681 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
682 Lisp_Object title;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
683 Lisp_Object keymap, tem;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
684 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
685
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
686 title = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
687
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
688 /* Decode the menu items from what was specified. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
689
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
690 keymap = Fkeymapp (menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
691 tem = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
692 if (XTYPE (menu) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
693 tem = Fkeymapp (Fcar (menu));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
694
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
695 if (!NILP (keymap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
696 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
697 /* We were given a keymap. Extract menu info from the keymap. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
698 Lisp_Object prompt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
699 keymap = get_keymap (menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
700
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
701 /* Extract the detailed info to make one pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
702 hmenu = keymap_panes (lpmm, &keymap, 1, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
703
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
704 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
705 /* Search for a string appearing directly as an element of the keymap.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
706 That string is the title of the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
707 prompt = map_prompt (keymap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
708
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
709 /* Make that be the pane title of the first pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
710 if (!NILP (prompt) && menu_items_n_panes >= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
711 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
712 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
713 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
714 else if (!NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
715 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
716 /* We were given a list of keymaps. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
717 int nmaps = XFASTINT (Flength (menu));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
718 Lisp_Object *maps
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
719 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
720 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
721
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
722 title = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
723
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
724 /* The first keymap that has a prompt string
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
725 supplies the menu title. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
726 for (tem = menu, i = 0; XTYPE (tem) == Lisp_Cons; tem = Fcdr (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
727 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
728 Lisp_Object prompt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
729
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
730 maps[i++] = keymap = get_keymap (Fcar (tem));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
731 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
732 prompt = map_prompt (keymap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
733 if (NILP (title) && !NILP (prompt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
734 title = prompt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
735 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
736 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
737
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
738 /* Extract the detailed info to make one pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
739 hmenu = keymap_panes (lpmm, maps, nmaps, notreal);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
740
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
741 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
742 /* Make the title be the pane title of the first pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
743 if (!NILP (title) && menu_items_n_panes >= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
744 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
745 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
746 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
747 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
748 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
749 /* We were given an old-fashioned menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
750 title = Fcar (menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
751 CHECK_STRING (title, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
752
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
753 hmenu = list_of_panes (lpmm, Fcdr (menu));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
754 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
755
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
756 return (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
757 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
758
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
759 /* This is a recursive subroutine of keymap_panes.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
760 It handles one keymap, KEYMAP.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
761 The other arguments are passed along
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
762 or point to local variables of the previous function.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
763 If NOTREAL is nonzero,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
764 don't bother really computing whether an item is enabled. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
765
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
766 Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
767 get_single_keymap_event (keymap, lpnum)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
768 Lisp_Object keymap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
769 int * lpnum;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
770 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
771 Lisp_Object pending_maps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
772 Lisp_Object tail, item, item1, item_string, table;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
773 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
774
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
775 pending_maps = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
776
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
777 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
778 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
779 /* Look at each key binding, and if it has a menu string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
780 make a menu item from it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
781
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
782 item = XCONS (tail)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
783
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
784 if (XTYPE (item) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
785 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
786 item1 = XCONS (item)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
787
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
788 if (CONSP (item1))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
789 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
790 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
791 if (XTYPE (item_string) == Lisp_String)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
792 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
793 /* This is the real definition--the function to run. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
794
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
795 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
796
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
797 /* These are the saved equivalent keyboard key sequence
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
798 and its key-description. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
799
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
800 Lisp_Object descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
801 Lisp_Object tem, enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
802
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
803 /* GCPRO because ...enabled_p will call eval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
804 and ..._equiv_key may autoload something.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
805 Protecting KEYMAP preserves everything we use;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
806 aside from that, must protect whatever might be
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
807 a string. Since there's no GCPRO5, we refetch
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
808 item_string instead of protecting it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
809
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
810 descrip = def = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
811 GCPRO3 (keymap, pending_maps, def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
812
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
813 def = menu_item_equiv_key (item_string, item1, &descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
814
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
815 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
816
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
817 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
818
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
819 tem = Fkeymapp (def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
820 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
821 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
822 pending_maps = Fcons (Fcons (def,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
823 Fcons (item_string,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
824 XCONS (item)->car)),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
825 pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
826 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
827 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
828 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
829 Lisp_Object submap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
830
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
831 GCPRO4 (keymap, pending_maps, item, item_string);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
832
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
833 submap = get_keymap_1 (def, 0, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
834
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
835 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
836
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
837 if (NILP (submap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
838 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
839 if (--(*lpnum) == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
840 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
841 return (Fcons (XCONS (item)->car, Qnil));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
842 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
843 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
844 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
845 /* Display a submenu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
846 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
847 Lisp_Object event = get_single_keymap_event (submap,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
848 lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
849
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
850 if (*lpnum <= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
851 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
852 if (!NILP (XCONS (item)->car))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
853 event = Fcons (XCONS (item)->car, event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
854
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
855 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
856 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
857 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
858 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
859 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
860 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
861 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
862 else if (VECTORP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
863 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
864 /* Loop over the char values represented in the vector. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
865 int len = XVECTOR (item)->size;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
866 int c;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
867 for (c = 0; c < len; c++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
868 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
869 Lisp_Object character;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
870 XSETFASTINT (character, c);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
871 item1 = XVECTOR (item)->contents[c];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
872 if (XTYPE (item1) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
873 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
874 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
875 if (XTYPE (item_string) == Lisp_String)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
876 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
877 Lisp_Object def;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
878
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
879 /* These are the saved equivalent keyboard key sequence
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
880 and its key-description. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
881 Lisp_Object descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
882 Lisp_Object tem, enabled;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
883
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
884 /* GCPRO because ...enabled_p will call eval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
885 and ..._equiv_key may autoload something.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
886 Protecting KEYMAP preserves everything we use;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
887 aside from that, must protect whatever might be
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
888 a string. Since there's no GCPRO5, we refetch
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
889 item_string instead of protecting it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
890 GCPRO4 (keymap, pending_maps, def, descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
891 descrip = def = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
892
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
893 def = menu_item_equiv_key (item_string, item1, &descrip);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
894
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
895 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
896
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
897 item_string = XCONS (item1)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
898
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
899 tem = Fkeymapp (def);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
900 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
901 pending_maps = Fcons (Fcons (def, Fcons (item_string, character)),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
902 pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
903 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
904 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
905 Lisp_Object submap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
906
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
907 GCPRO4 (keymap, pending_maps, descrip, item_string);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
908
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
909 submap = get_keymap_1 (def, 0, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
910
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
911 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
912
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
913 if (NILP (submap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
914 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
915 if (--(*lpnum) == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
916 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
917 return (Fcons (character, Qnil));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
918 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
919 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
920 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
921 /* Display a submenu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
922 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
923 Lisp_Object event = get_single_keymap_event (submap,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
924 lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
925
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
926 if (*lpnum <= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
927 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
928 if (!NILP (character))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
929 event = Fcons (character, event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
930
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
931 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
932 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
933 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
934 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
935 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
936 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
937 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
938 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
939 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
940
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
941 /* Process now any submenus which want to be panes at this level. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
942 while (!NILP (pending_maps))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
943 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
944 Lisp_Object elt, eltcdr, string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
945 elt = Fcar (pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
946 eltcdr = XCONS (elt)->cdr;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
947 string = XCONS (eltcdr)->car;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
948 /* We no longer discard the @ from the beginning of the string here.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
949 Instead, we do this in win32menu_show. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
950 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
951 Lisp_Object event = get_single_keymap_event (Fcar (elt), lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
952
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
953 if (*lpnum <= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
954 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
955 if (!NILP (XCONS (eltcdr)->cdr))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
956 event = Fcons (XCONS (eltcdr)->cdr, event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
957
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
958 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
959 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
960 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
961
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
962 pending_maps = Fcdr (pending_maps);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
963 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
964
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
965 return (Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
966 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
967
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
968 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
969 and generate menu panes for them in menu_items.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
970 If NOTREAL is nonzero,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
971 don't bother really computing whether an item is enabled. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
972
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
973 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
974 get_keymap_event (keymaps, nmaps, lpnum)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
975 Lisp_Object *keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
976 int nmaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
977 int * lpnum;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
978 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
979 int mapno;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
980 Lisp_Object event = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
981
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
982 /* Loop over the given keymaps, making a pane for each map.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
983 But don't make a pane that is empty--ignore that map instead.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
984 P is the number of panes we have made so far. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
985 for (mapno = 0; mapno < nmaps; mapno++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
986 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
987 event = get_single_keymap_event (keymaps[mapno], lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
988
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
989 if (*lpnum <= 0) break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
990 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
991
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
992 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
993 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
994
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
995 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
996 get_list_of_items_event (pane, lpnum)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
997 Lisp_Object pane;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
998 int * lpnum;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
999 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1000 Lisp_Object tail, item, item1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1001
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1002 for (tail = pane; !NILP (tail); tail = Fcdr (tail))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1003 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1004 item = Fcar (tail);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1005 if (STRINGP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1006 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1007 if (-- (*lpnum) == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1008 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1009 return (Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1010 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1011 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1012 else if (!NILP (item))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1013 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1014 if (--(*lpnum) == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1015 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1016 CHECK_CONS (item, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1017 return (Fcdr (item));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1018 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1019 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1020 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1021
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1022 return (Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1023 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1024
|
14036
|
1025 /* Push all the panes and items of a menu described by the
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1026 alist-of-alists MENU.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1027 This handles old-fashioned calls to x-popup-menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1028
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1029 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1030 get_list_of_panes_event (menu, lpnum)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1031 Lisp_Object menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1032 int * lpnum;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1033 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1034 Lisp_Object tail;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1035
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1036 for (tail = menu; !NILP (tail); tail = Fcdr (tail))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1037 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1038 Lisp_Object elt, pane_name, pane_data;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1039 Lisp_Object event;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1040
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1041 elt = Fcar (tail);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1042 pane_data = Fcdr (elt);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1043 CHECK_CONS (pane_data, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1044
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1045 event = get_list_of_items_event (pane_data, lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1046
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1047 if (*lpnum <= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1048 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1049 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1050 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1051 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1052
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1053 return (Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1054 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1055
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1056 Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1057 get_menu_event (menu, lpnum)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1058 Lisp_Object menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1059 int * lpnum;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1060 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1061 Lisp_Object keymap, tem;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1062 Lisp_Object event;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1063
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1064 /* Decode the menu items from what was specified. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1065
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1066 keymap = Fkeymapp (menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1067 tem = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1068 if (XTYPE (menu) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1069 tem = Fkeymapp (Fcar (menu));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1070
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1071 if (!NILP (keymap))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1072 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1073 keymap = get_keymap (menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1074
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1075 event = get_keymap_event (menu, 1, lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1076 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1077 else if (!NILP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1078 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1079 /* We were given a list of keymaps. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1080 int nmaps = XFASTINT (Flength (menu));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1081 Lisp_Object *maps
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1082 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1083 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1084
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1085 /* The first keymap that has a prompt string
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1086 supplies the menu title. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1087 for (tem = menu, i = 0; XTYPE (tem) == Lisp_Cons; tem = Fcdr (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1088 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1089 Lisp_Object prompt;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1090
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1091 maps[i++] = keymap = get_keymap (Fcar (tem));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1092 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1093
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1094 event = get_keymap_event (maps, nmaps, lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1095 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1096 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1097 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1098 /* We were given an old-fashioned menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1099 event = get_list_of_panes_event (Fcdr (menu), lpnum);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1100 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1101
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1102 return (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1103 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1104
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1105 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1106 "Pop up a deck-of-cards menu and return user's selection.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1107 POSITION is a position specification. This is either a mouse button event\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1108 or a list ((XOFFSET YOFFSET) WINDOW)\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1109 where XOFFSET and YOFFSET are positions in pixels from the top left\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1110 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1111 This controls the position of the center of the first line\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1112 in the first pane of the menu, not the top left of the menu as a whole.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1113 If POSITION is t, it means to use the current mouse position.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1114 \n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1115 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1116 The menu items come from key bindings that have a menu string as well as\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1117 a definition; actually, the \"definition\" in such a key binding looks like\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1118 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1119 the keymap as a top-level element.\n\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1120 You can also use a list of keymaps as MENU.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1121 Then each keymap makes a separate pane.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1122 When MENU is a keymap or a list of keymaps, the return value\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1123 is a list of events.\n\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1124 Alternatively, you can specify a menu of multiple panes\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1125 with a list of the form (TITLE PANE1 PANE2...),\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1126 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1127 Each ITEM is normally a cons cell (STRING . VALUE);\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1128 but a string can appear as an item--that makes a nonselectable line\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1129 in the menu.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1130 With this form of menu, the return value is VALUE from the chosen item.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1131 \n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1132 If POSITION is nil, don't display the menu at all, just precalculate the\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1133 cached information about equivalent key sequences.")
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1134 (position, menu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1135 Lisp_Object position, menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1136 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1137 int number_of_panes, panes;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1138 Lisp_Object keymap, tem;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1139 int xpos, ypos;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1140 Lisp_Object title;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1141 char *error_name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1142 Lisp_Object selection;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1143 int i, j;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1144 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1145 Lisp_Object x, y, window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1146 int keymaps = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1147 int menubarp = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1148 struct gcpro gcpro1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1149 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1150 menu_map mm;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1151
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1152 if (! NILP (position))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1153 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1154 /* Decode the first argument: find the window and the coordinates. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1155 if (EQ (position, Qt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1156 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1157 /* Use the mouse's current position. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1158 FRAME_PTR new_f = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1159 Lisp_Object bar_window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1160 int part;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1161 unsigned long time;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1162
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1163 if (mouse_position_hook)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1164 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1165 if (new_f != 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1166 XSETFRAME (window, new_f);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1167 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1168 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1169 window = selected_window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1170 XSETFASTINT (x, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1171 XSETFASTINT (y, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1172 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1173 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1174 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1175 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1176 tem = Fcar (position);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1177 if (CONSP (tem))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1178 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1179 window = Fcar (Fcdr (position));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1180 x = Fcar (tem);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1181 y = Fcar (Fcdr (tem));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1182 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1183 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1184 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1185 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1186 window = Fcar (tem); /* POSN_WINDOW (tem) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1187 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1188 x = Fcar (tem);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1189 y = Fcdr (tem);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1190
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1191 /* Determine whether this menu is handling a menu bar click. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1192 tem = Fcar (Fcdr (Fcar (Fcdr (position))));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1193 if (CONSP (tem) && EQ (Fcar (tem), Qmenu_bar))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1194 menubarp = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1195 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1196 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1197
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1198 CHECK_NUMBER (x, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1199 CHECK_NUMBER (y, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1200
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1201 /* Decode where to put the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1202
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1203 if (FRAMEP (window))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1204 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1205 f = XFRAME (window);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1206
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1207 xpos = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1208 ypos = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1209 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1210 else if (WINDOWP (window))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1211 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1212 CHECK_LIVE_WINDOW (window, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1213 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1214
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1215 xpos = (FONT_WIDTH (f->output_data.win32->font) * XWINDOW (window)->left);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1216 ypos = (f->output_data.win32->line_height * XWINDOW (window)->top);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1217 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1218 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1219 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1220 but I don't want to make one now. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1221 CHECK_WINDOW (window, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1222
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1223 xpos += XINT (x);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1224 ypos += XINT (y);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1225 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1226
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1227 title = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1228 GCPRO1 (title);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1229
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1230 discard_menu_items (&mm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1231 hmenu = create_menu_items (&mm, menu, NILP (position));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1232
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1233 if (NILP (position))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1234 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1235 discard_menu_items (&mm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1236 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1237 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1238 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1239
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1240 /* Display them in a menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1241 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1242
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1243 selection = win32menu_show (f, xpos, ypos, menu, &hmenu, &error_name);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1244
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1245 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1246
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1247 discard_menu_items (&mm);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1248 DestroyMenu (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1249
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1250 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1251
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1252 if (error_name) error (error_name);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1253 return selection;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1254 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1255
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1256 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1257 "Pop up a dialog box and return user's selection.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1258 POSITION specifies which frame to use.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1259 This is normally a mouse button event or a window or frame.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1260 If POSITION is t, it means to use the frame the mouse is on.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1261 The dialog box appears in the middle of the specified frame.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1262 \n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1263 CONTENTS specifies the alternatives to display in the dialog box.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1264 It is a list of the form (TITLE ITEM1 ITEM2...).\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1265 Each ITEM is a cons cell (STRING . VALUE).\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1266 The return value is VALUE from the chosen item.\n\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1267 An ITEM may also be just a string--that makes a nonselectable item.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1268 An ITEM may also be nil--that means to put all preceding items\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1269 on the left of the dialog box and all following items on the right.\n\
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1270 \(By default, approximately half appear on each side.)")
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1271 (position, contents)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1272 Lisp_Object position, contents;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1273 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1274 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1275 Lisp_Object window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1276
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1277 /* Decode the first argument: find the window or frame to use. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1278 if (EQ (position, Qt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1279 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1280 /* Decode the first argument: find the window and the coordinates. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1281 if (EQ (position, Qt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1282 window = selected_window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1283 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1284 else if (CONSP (position))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1285 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1286 Lisp_Object tem;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1287 tem = Fcar (position);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1288 if (XTYPE (tem) == Lisp_Cons)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1289 window = Fcar (Fcdr (position));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1290 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1291 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1292 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1293 window = Fcar (tem); /* POSN_WINDOW (tem) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1294 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1295 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1296 else if (WINDOWP (position) || FRAMEP (position))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1297 window = position;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1298
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1299 /* Decode where to put the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1300
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1301 if (FRAMEP (window))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1302 f = XFRAME (window);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1303 else if (WINDOWP (window))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1304 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1305 CHECK_LIVE_WINDOW (window, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1306 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1307 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1308 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1309 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1310 but I don't want to make one now. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1311 CHECK_WINDOW (window, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1312
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1313 #if 1
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1314 /* Display a menu with these alternatives
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1315 in the middle of frame F. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1316 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1317 Lisp_Object x, y, frame, newpos;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1318 XSETFRAME (frame, f);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1319 XSETINT (x, x_pixel_width (f) / 2);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1320 XSETINT (y, x_pixel_height (f) / 2);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1321 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1322
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1323 return Fx_popup_menu (newpos,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1324 Fcons (Fcar (contents), Fcons (contents, Qnil)));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1325 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1326 #else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1327 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1328 Lisp_Object title;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1329 char *error_name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1330 Lisp_Object selection;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1331
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1332 /* Decode the dialog items from what was specified. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1333 title = Fcar (contents);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1334 CHECK_STRING (title, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1335
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1336 list_of_panes (Fcons (contents, Qnil));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1337
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1338 /* Display them in a dialog box. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1339 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1340 selection = win32_dialog_show (f, 0, 0, title, &error_name);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1341 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1342
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1343 discard_menu_items ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1344
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1345 if (error_name) error (error_name);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1346 return selection;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1347 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1348 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1349 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1350
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1351 Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1352 get_frame_menubar_event (f, num)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1353 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1354 int num;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1355 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1356 Lisp_Object tail, items;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1357 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1358 struct gcpro gcpro1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1359
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1360 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1361
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1362 GCPRO1 (items);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1363
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1364 if (NILP (items = FRAME_MENU_BAR_ITEMS (f)))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1365 items = FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1366
|
15110
|
1367 for (i = 0; i < XVECTOR (items)->size; i += 4)
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1368 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1369 Lisp_Object event;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1370
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1371 event = get_menu_event (XVECTOR (items)->contents[i + 2], &num);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1372
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1373 if (num <= 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1374 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1375 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1376 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1377 return (Fcons (XVECTOR (items)->contents[i], event));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1378 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1379 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1380
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1381 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1382 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1383
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1384 return (Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1385 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1386
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1387 void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1388 set_frame_menubar (f, first_time)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1389 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1390 int first_time;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1391 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1392 Lisp_Object tail, items;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1393 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1394 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1395 struct gcpro gcpro1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1396 menu_map mm;
|
15276
|
1397 int count = specpdl_ptr - specpdl;
|
|
1398
|
|
1399 struct buffer *prev = current_buffer;
|
|
1400 Lisp_Object buffer;
|
|
1401
|
|
1402 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
|
|
1403 specbind (Qinhibit_quit, Qt);
|
|
1404 /* Don't let the debugger step into this code
|
|
1405 because it is not reentrant. */
|
|
1406 specbind (Qdebug_on_next_call, Qnil);
|
|
1407
|
|
1408 record_unwind_protect (Fstore_match_data, Fmatch_data ());
|
|
1409 if (NILP (Voverriding_local_map_menu_flag))
|
|
1410 {
|
|
1411 specbind (Qoverriding_terminal_local_map, Qnil);
|
|
1412 specbind (Qoverriding_local_map, Qnil);
|
|
1413 }
|
|
1414
|
|
1415 set_buffer_internal_1 (XBUFFER (buffer));
|
|
1416
|
|
1417 /* Run the Lucid hook. */
|
|
1418 call1 (Vrun_hooks, Qactivate_menubar_hook);
|
|
1419 /* If it has changed current-menubar from previous value,
|
|
1420 really recompute the menubar from the value. */
|
|
1421 if (! NILP (Vlucid_menu_bar_dirty_flag))
|
|
1422 call0 (Qrecompute_lucid_menubar);
|
|
1423 safe_run_hooks (Qmenu_bar_update_hook);
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1424
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1425 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1426
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1427 GCPRO1 (items);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1428
|
15276
|
1429 items = FRAME_MENU_BAR_ITEMS (f);
|
|
1430 if (NILP (items))
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1431 items = FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1432
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1433 hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1434
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1435 if (!hmenu) goto error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1436
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1437 discard_menu_items (&mm);
|
15276
|
1438 UNBLOCK_INPUT;
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1439
|
15110
|
1440 for (i = 0; i < XVECTOR (items)->size; i += 4)
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1441 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1442 Lisp_Object string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1443 int keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1444 CHAR *error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1445 HMENU new_hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1446
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1447 string = XVECTOR (items)->contents[i + 1];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1448 if (NILP (string))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1449 break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1450
|
15276
|
1451 /* Input must not be blocked here
|
|
1452 because we call general Lisp code and internal_condition_case_1. */
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1453 new_hmenu = create_menu_items (&mm,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1454 XVECTOR (items)->contents[i + 2],
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1455 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1456
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1457 if (!new_hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1458 continue;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1459
|
15276
|
1460 BLOCK_INPUT;
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1461 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1462 (char *) XSTRING (string)->data);
|
15276
|
1463 UNBLOCK_INPUT;
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1464 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1465
|
15276
|
1466 BLOCK_INPUT;
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1467 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1468 HMENU old = GetMenu (FRAME_WIN32_WINDOW (f));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1469 SetMenu (FRAME_WIN32_WINDOW (f), hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1470 DestroyMenu (old);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1471 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1472
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1473 error:
|
15276
|
1474 set_buffer_internal_1 (prev);
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1475 UNGCPRO;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1476 UNBLOCK_INPUT;
|
15276
|
1477 unbind_to (count, Qnil);
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1478 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1479
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1480 void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1481 free_frame_menubar (f)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1482 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1483 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1484 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1485
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1486 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1487 HMENU old = GetMenu (FRAME_WIN32_WINDOW (f));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1488 SetMenu (FRAME_WIN32_WINDOW (f), NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1489 DestroyMenu (old);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1490 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1491
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1492 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1493 }
|
14036
|
1494 /* Called from Fwin32_create_frame to create the initial menubar of a frame
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1495 before it is mapped, so that the window is mapped with the menubar already
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1496 there instead of us tacking it on later and thrashing the window after it
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1497 is visible. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1498 void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1499 initialize_frame_menubar (f)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1500 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1501 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1502 set_frame_menubar (f, 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1503 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1504
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1505 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1506 /* If the mouse has moved to another menu bar item,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1507 return 1 and unread a button press event for that item.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1508 Otherwise return 0. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1509
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1510 static int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1511 check_mouse_other_menu_bar (f)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1512 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1513 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1514 FRAME_PTR new_f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1515 Lisp_Object bar_window;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1516 int part;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1517 Lisp_Object x, y;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1518 unsigned long time;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1519
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1520 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1521
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1522 if (f == new_f && other_menu_bar_item_p (f, x, y))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1523 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1524 unread_menu_bar_button (f, x);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1525 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1526 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1527
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1528 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1529 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1530 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1531
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1532
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1533 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1534 static HMENU
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1535 create_menu (keymaps, error)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1536 int keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1537 char **error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1538 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1539 HMENU hmenu = NULL; /* the menu we are currently working on */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1540 HMENU first_hmenu = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1541
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1542 HMENU *submenu_stack = (HMENU *) alloca (menu_items_used * sizeof (HMENU));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1543 Lisp_Object *subprefix_stack = (Lisp_Object *) alloca (menu_items_used *
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1544 sizeof (Lisp_Object));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1545 int submenu_depth = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1546 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1547
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1548 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1549 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1550 *error = "Empty menu";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1551 return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1552 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1553
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1554 i = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1555
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1556 /* Loop over all panes and items, filling in the tree. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1557
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1558 while (i < menu_items_used)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1559 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1560 if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1561 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1562 submenu_stack[submenu_depth++] = hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1563 i++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1564 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1565 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1566 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1567 hmenu = submenu_stack[--submenu_depth];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1568 i++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1569 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1570 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1571 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1572 && submenu_depth != 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1573 i += MENU_ITEMS_PANE_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1574 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1575 /* Ignore a nil in the item list.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1576 It's meaningful only for dialog boxes. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1577 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1578 i += 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1579 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1580 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1581 /* Create a new pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1582
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1583 Lisp_Object pane_name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1584 char *pane_string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1585
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1586 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1587 pane_string = (NILP (pane_name) ? "" : (char *) XSTRING (pane_name)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1588
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1589 if (!hmenu || strcmp (pane_string, ""))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1590 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1591 HMENU new_hmenu = CreateMenu ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1592
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1593 if (!new_hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1594 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1595 *error = "Could not create menu pane";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1596 goto error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1597 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1598
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1599 if (hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1600 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1601 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu, pane_string);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1602 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1603
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1604 hmenu = new_hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1605
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1606 if (!first_hmenu) first_hmenu = hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1607 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1608 i += MENU_ITEMS_PANE_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1609 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1610 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1611 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1612 /* Create a new item within current pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1613
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1614 Lisp_Object item_name, enable, descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1615 UINT fuFlags;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1616
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1617 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1618 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1619 // descrip = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1620
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1621 if (((char *) XSTRING (item_name)->data)[0] == 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1622 || strcmp ((char *) XSTRING (item_name)->data, "--") == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1623 fuFlags = MF_SEPARATOR;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1624 else if (NILP (enable) || !XUINT(enable))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1625 fuFlags = MF_STRING | MF_GRAYED;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1626 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1627 fuFlags = MF_STRING;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1628
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1629 AppendMenu (hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1630 fuFlags,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1631 i,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1632 (char *) XSTRING (item_name)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1633
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1634 // if (!NILP (descrip))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1635 // hmenu->key = (char *) XSTRING (descrip)->data;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1636
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1637 i += MENU_ITEMS_ITEM_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1638 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1639 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1640
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1641 return (first_hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1642
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1643 error:
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1644 if (first_hmenu) DestroyMenu (first_hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1645 return (NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1646 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1647
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1648 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1649
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1650 /* win32menu_show actually displays a menu using the panes and items in
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1651 menu_items and returns the value selected from it.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1652 There are two versions of win32menu_show, one for Xt and one for Xlib.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1653 Both assume input is blocked by the caller. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1654
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1655 /* F is the frame the menu is for.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1656 X and Y are the frame-relative specified position,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1657 relative to the inside upper left corner of the frame F.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1658 MENUBARP is 1 if the click that asked for this menu came from the menu bar.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1659 KEYMAPS is 1 if this menu was specified with keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1660 in that case, we return a list containing the chosen item's value
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1661 and perhaps also the pane's prefix.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1662 TITLE is the specified menu title.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1663 ERROR is a place to store an error message string in case of failure.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1664 (We return nil on failure, but the value doesn't actually matter.) */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1665
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1666
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1667 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1668 win32menu_show (f, x, y, menu, hmenu, error)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1669 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1670 int x;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1671 int y;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1672 Lisp_Object menu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1673 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1674 char **error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1675 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1676 int i , menu_selection;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1677 POINT pos;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1678
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1679 *error = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1680
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1681 if (!hmenu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1682 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1683 *error = "Empty menu";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1684 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1685 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1686
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1687 pos.x = x;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1688 pos.y = y;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1689
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1690 /* Offset the coordinates to root-relative. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1691 ClientToScreen (FRAME_WIN32_WINDOW (f), &pos);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1692
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1693 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1694 /* If the mouse moves out of the menu before we show the menu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1695 don't show it at all. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1696 if (check_mouse_other_menu_bar (f))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1697 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1698 DestroyMenu (hmenu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1699 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1700 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1701 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1702
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1703 /* Display the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1704 menu_selection = TrackPopupMenu (hmenu,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1705 0x10,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1706 pos.x, pos.y,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1707 0,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1708 FRAME_WIN32_WINDOW (f),
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1709 NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1710 if (menu_selection == -1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1711 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1712 *error = "Invalid menu specification";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1713 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1714 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1715
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1716 /* Find the selected item, and its pane, to return
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1717 the proper value. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1718
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1719 #if 1
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1720 if (menu_selection > 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1721 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1722 return get_menu_event (menu, menu_selection);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1723 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1724 #else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1725 if (menu_selection > 0 && menu_selection <= lpmm->menu_items_used)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1726 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1727 return (XVECTOR (lpmm->menu_items)->contents[menu_selection - 1]);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1728 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1729 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1730
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1731 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1732 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1733
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1734 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1735 static char * button_names [] =
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1736 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1737 "button1", "button2", "button3", "button4", "button5",
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1738 "button6", "button7", "button8", "button9", "button10"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1739 };
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1740
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1741 static Lisp_Object
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1742 win32_dialog_show (f, menubarp, keymaps, title, error)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1743 FRAME_PTR f;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1744 int menubarp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1745 int keymaps;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1746 Lisp_Object title;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1747 char **error;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1748 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1749 int i, nb_buttons=0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1750 HMENU hmenu;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1751 char dialog_name[6];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1752
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1753 /* Number of elements seen so far, before boundary. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1754 int left_count = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1755 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1756 int boundary_seen = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1757
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1758 *error = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1759
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1760 if (menu_items_n_panes > 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1761 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1762 *error = "Multiple panes in dialog box";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1763 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1764 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1765
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1766 /* Create a tree of widget_value objects
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1767 representing the text label and buttons. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1768 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1769 Lisp_Object pane_name, prefix;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1770 char *pane_string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1771 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1772 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1773 pane_string = (NILP (pane_name)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1774 ? "" : (char *) XSTRING (pane_name)->data);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1775 prev_wv = malloc_widget_value ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1776 prev_wv->value = pane_string;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1777 if (keymaps && !NILP (prefix))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1778 prev_wv->name++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1779 prev_wv->enabled = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1780 prev_wv->name = "message";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1781 first_wv = prev_wv;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1782
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1783 /* Loop over all panes and items, filling in the tree. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1784 i = MENU_ITEMS_PANE_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1785 while (i < menu_items_used)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1786 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1787
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1788 /* Create a new item within current pane. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1789 Lisp_Object item_name, enable, descrip;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1790 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1791 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1792 descrip
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1793 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1794
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1795 if (NILP (item_name))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1796 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1797 free_menubar_widget_value_tree (first_wv);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1798 *error = "Submenu in dialog items";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1799 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1800 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1801 if (EQ (item_name, Qquote))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1802 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1803 /* This is the boundary between left-side elts
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1804 and right-side elts. Stop incrementing right_count. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1805 boundary_seen = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1806 i++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1807 continue;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1808 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1809 if (nb_buttons >= 10)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1810 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1811 free_menubar_widget_value_tree (first_wv);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1812 *error = "Too many dialog items";
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1813 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1814 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1815
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1816 wv = malloc_widget_value ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1817 prev_wv->next = wv;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1818 wv->name = (char *) button_names[nb_buttons];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1819 if (!NILP (descrip))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1820 wv->key = (char *) XSTRING (descrip)->data;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1821 wv->value = (char *) XSTRING (item_name)->data;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1822 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1823 wv->enabled = !NILP (enable);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1824 prev_wv = wv;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1825
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1826 if (! boundary_seen)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1827 left_count++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1828
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1829 nb_buttons++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1830 i += MENU_ITEMS_ITEM_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1831 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1832
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1833 /* If the boundary was not specified,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1834 by default put half on the left and half on the right. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1835 if (! boundary_seen)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1836 left_count = nb_buttons - nb_buttons / 2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1837
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1838 wv = malloc_widget_value ();
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1839 wv->name = dialog_name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1840
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1841 /* Dialog boxes use a really stupid name encoding
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1842 which specifies how many buttons to use
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1843 and how many buttons are on the right.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1844 The Q means something also. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1845 dialog_name[0] = 'Q';
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1846 dialog_name[1] = '0' + nb_buttons;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1847 dialog_name[2] = 'B';
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1848 dialog_name[3] = 'R';
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1849 /* Number of buttons to put on the right. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1850 dialog_name[4] = '0' + nb_buttons - left_count;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1851 dialog_name[5] = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1852 wv->contents = first_wv;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1853 first_wv = wv;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1854 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1855
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1856 /* Actually create the dialog. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1857 dialog_id = ++popup_id_tick;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1858 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1859 f->output_data.win32->widget, 1, 0,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1860 dialog_selection_callback, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1861 #if 0 /* This causes crashes, and seems to be redundant -- rms. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1862 lw_modify_all_widgets (dialog_id, first_wv, True);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1863 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1864 lw_modify_all_widgets (dialog_id, first_wv->contents, True);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1865 /* Free the widget_value objects we used to specify the contents. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1866 free_menubar_widget_value_tree (first_wv);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1867
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1868 /* No selection has been chosen yet. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1869 menu_item_selection = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1870
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1871 /* Display the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1872 lw_pop_up_all_widgets (dialog_id);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1873
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1874 /* Process events that apply to the menu. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1875 while (1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1876 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1877 XEvent event;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1878
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1879 XtAppNextEvent (Xt_app_con, &event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1880 if (event.type == ButtonRelease)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1881 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1882 XtDispatchEvent (&event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1883 break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1884 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1885 else if (event.type == Expose)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1886 process_expose_from_menu (event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1887 XtDispatchEvent (&event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1888 if (XtWindowToWidget(XDISPLAY event.xany.window) != menu)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1889 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1890 queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1891
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1892 if (queue_tmp != NULL)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1893 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1894 queue_tmp->event = event;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1895 queue_tmp->next = queue;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1896 queue = queue_tmp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1897 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1898 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1899 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1900 pop_down:
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1901
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1902 /* State that no mouse buttons are now held.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1903 That is not necessarily true, but the fiction leads to reasonable
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1904 results, and it is a pain to ask which are actually held now
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1905 or track this in the loop above. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1906 win32_mouse_grabbed = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1907
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1908 /* Unread any events that we got but did not handle. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1909 while (queue != NULL)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1910 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1911 queue_tmp = queue;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1912 XPutBackEvent (XDISPLAY &queue_tmp->event);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1913 queue = queue_tmp->next;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1914 free ((char *)queue_tmp);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1915 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1916 interrupt_input_pending = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1917 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1918
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1919 /* Find the selected item, and its pane, to return
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1920 the proper value. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1921 if (menu_item_selection != 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1922 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1923 Lisp_Object prefix;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1924
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1925 prefix = Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1926 i = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1927 while (i < menu_items_used)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1928 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1929 Lisp_Object entry;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1930
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1931 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1932 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1933 prefix
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1934 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1935 i += MENU_ITEMS_PANE_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1936 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1937 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1938 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1939 entry
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1940 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1941 if (menu_item_selection == &XVECTOR (menu_items)->contents[i])
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1942 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1943 if (keymaps != 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1944 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1945 entry = Fcons (entry, Qnil);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1946 if (!NILP (prefix))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1947 entry = Fcons (prefix, entry);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1948 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1949 return entry;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1950 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1951 i += MENU_ITEMS_ITEM_LENGTH;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1952 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1953 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1954 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1955
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1956 return Qnil;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1957 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1958 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1959
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1960 syms_of_win32menu ()
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1961 {
|
15276
|
1962 Qdebug_on_next_call = intern ("debug-on-next-call");
|
|
1963 staticpro (&Qdebug_on_next_call);
|
|
1964
|
13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1965 defsubr (&Sx_popup_menu);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1966 defsubr (&Sx_popup_dialog);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1967 }
|