annotate src/menubar-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children de805c49cfc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
1 /* Implements an elisp-programmable menubar -- Win32
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
4 Copyright (C) 1997 Kirill M. Katsnelson <kkm@kis.ru>.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
5 Copyright (C) 2000 Ben Wing.
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
6
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
7 This file is part of XEmacs.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
8
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
12 later version.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
13
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
17 for more details.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
18
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
23
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
25
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
26 /* Author:
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
27 Initially written by kkm 12/24/97,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
28 peeking into and copying stuff from menubar-x.c
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
29 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
30
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
31 /* Algorithm for handling menus is as follows. When window's menubar
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
32 * is created, current-menubar is not traversed in depth. Rather, only
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
33 * top level items, both items and pulldowns, are added to the
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
34 * menubar. Each pulldown is initially empty. When a pulldown is
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
35 * selected and about to open, corresponding element of
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
36 * current-menubar is found, and the newly open pulldown is
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
37 * populated. This is made again in the same non-recursive manner.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
38 *
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
39 * This algorithm uses hash tables to find out element of the menu
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
40 * descriptor list given menu handle. The key is an opaque ptr data
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
41 * type, keeping menu handle, and the value is a list of strings
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
42 * representing the path from the root of the menu to the item
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
43 * descriptor. Each frame has an associated hash table.
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
44 *
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
45 * Leaf items are assigned a unique id based on item's hash. When an
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
46 * item is selected, Windows sends back the id. Unfortunately, only
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
47 * low 16 bit of the ID are sent, and there's no way to get the 32-bit
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
48 * value. Yes, Win32 is just a different set of bugs than X! Aside
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
49 * from this blame, another hashing mechanism is required to map menu
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
50 * ids to commands (which are actually Lisp_Object's). This mapping is
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
51 * performed in the same hash table, as the lifetime of both maps is
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
52 * exactly the same. This is unambigous, as menu handles are
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
53 * represented by lisp opaques, while command ids are by lisp
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
54 * integers. The additional advantage for this is that command forms
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
55 * are automatically GC-protected, which is important because these
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
56 * may be transient forms generated by :filter functions.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
57 *
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
58 * The hash table is not allowed to grow too much; it is pruned
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
59 * whenever this is safe to do. This is done by re-creating the menu
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
60 * bar, and clearing and refilling the hash table from scratch.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
61 *
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
62 * Popup menus are handled identically to pulldowns. A static hash
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
63 * table is used for popup menus, and lookup is made not in
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
64 * current-menubar but in a lisp form supplied to the `popup'
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
65 * function.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
66 *
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
67 * Another Windows weirdness is that there's no way to tell that a
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
68 * popup has been dismissed without making selection. We need to know
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
69 * that to cleanup the popup menu hash table, but this is not honestly
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
70 * doable using *documented* sequence of messages. Sticking to
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
71 * particular knowledge is bad because this may break in Windows NT
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
72 * 5.0, or Windows 98, or other future version. Instead, I allow the
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
73 * hash tables to hang around, and not clear them, unless WM_COMMAND is
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
74 * received. This is worth some memory but more safe. Hacks welcome,
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
75 * anyways!
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
76 *
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
77 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
78
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
79 #include <config.h>
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
80 #include "lisp.h"
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
81 #include <limits.h>
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
82
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
83 #include "buffer.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
84 #include "commands.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
85 #include "console-msw.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
86 #include "elhash.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
87 #include "events.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
88 #include "frame.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
89 #include "gui.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
90 #include "lisp.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
91 #include "menubar.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
92 #include "menubar-msw.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
93 #include "opaque.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
94 #include "window.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
95
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
96 /* #### */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
97 #define REPLACE_ME_WITH_GLOBAL_VARIABLE_WHICH_CONTROLS_RIGHT_FLUSH 0
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
98
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
99 #define EMPTY_ITEM_ID ((UINT)LISP_TO_VOID (Qunbound))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
100 #define EMPTY_ITEM_NAME "(empty)"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
101
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
102 /* Current menu (bar or popup) descriptor. gcpro'ed */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
103 static Lisp_Object current_menudesc;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
104
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
105 /* Current menubar or popup hash table. gcpro'ed */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
106 static Lisp_Object current_hash_table;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
107
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
108 /* This is used to allocate unique ids to menu items.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
109 Items ids are in MENU_ITEM_ID_MIN to MENU_ITEM_ID_MAX.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
110 Allocation checks that the item is not already in
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
111 the TOP_LEVEL_MENU */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
112
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
113 /* #### defines go to gui-msw.h, as the range is shared with toolbars
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
114 (If only toolbars will be implemented as common controls) */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
115 #define MENU_ITEM_ID_MIN 0x8000
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
116 #define MENU_ITEM_ID_MAX 0xFFFF
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
117 #define MENU_ITEM_ID_BITS(x) (((x) & 0x7FFF) | 0x8000)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
118 static HMENU top_level_menu;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
119
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
120 /* Translate (in place) %_ to &, %% to %.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
121 Return new length, and (through accel) the accelerator character.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
122 (If there is no accelerator, it will be added on the first character.)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
123 len = number of bytes (not including zero terminator).
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
124 maxlen = size of buffer.
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
125 We assume and maintain zero-termination. To be absolutely sure
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
126 of not hitting an error, maxlen should be >= 2*len + 3. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
127
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
128 Bytecount
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
129 msw_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
130 Bytecount maxlen, Emchar *accel,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
131 Lisp_Object error_name)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
132 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
133 Bufbyte *ptr;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
134
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
135 *accel = '\0';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
136
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
137 /* Escape '&' as '&&' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
138
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
139 ptr = item;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
140 while ((ptr = (Bufbyte *) memchr (ptr, '&', len - (ptr - item))) != NULL)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
141 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
142 if (len + 2 > maxlen)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
143 signal_simple_error ("Menu item produces too long displayable string",
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
144 error_name);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
145 memmove (ptr + 1, ptr, (len - (ptr - item)) + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
146 len++;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
147 ptr += 2;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
148 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
149
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
150 /* Replace XEmacs accelerator '%_' with Windows accelerator '&'
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
151 and `%%' with `%'. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
152 ptr = item;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
153 while ((ptr = memchr (ptr, '%', len - (ptr - item))) != NULL)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
154 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
155 if (*(ptr + 1) == '_')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
156 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
157 *ptr = '&';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
158 if (!*accel)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
159 /* #### urk ! We need a reference translation table for
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
160 case changes that aren't buffer-specific. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
161 *accel = DOWNCASE (current_buffer, charptr_emchar (ptr + 2));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
162 memmove (ptr + 1, ptr + 2, len - (ptr - item + 2) + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
163 len--;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
164 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
165 else if (*(ptr + 1) == '%')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
166 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
167 memmove (ptr + 1, ptr + 2, len - (ptr - item + 2) + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
168 len--;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
169 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
170 ptr++;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
171 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
172
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
173 if (!*accel)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
174 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
175 if (len + 2 > maxlen)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
176 signal_simple_error ("Menu item produces too long displayable string",
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
177 error_name);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
178 ptr = item;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
179 memmove (ptr + 1, ptr, len + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
180 /* #### urk ! We need a reference translation table for
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
181 case changes that aren't buffer-specific. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
182 *accel = DOWNCASE (current_buffer, charptr_emchar (ptr + 1));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
183 *ptr = '&';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
184
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
185 len++;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
186 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
187
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
188 return len;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
189 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
190
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
191 /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
192 * This returns Windows-style menu item string:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
193 * "Left Flush\tRight Flush"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
194 */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
195
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
196 /* #### This is junk. Need correct handling of sizes. Use a Bufbyte_dynarr,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
197 not a static buffer. */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
198 static char*
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
199 displayable_menu_item (Lisp_Object gui_item, int bar_p, Emchar *accel)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
200 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
201 unsigned int ll;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
202
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
203 /* We construct the name in a static buffer. That's fine, because
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
204 menu items longer than 128 chars are probably programming errors,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
205 and better be caught than displayed! */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
206
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
207 static char buf[MAX_MENUITEM_LENGTH+2];
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
208
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
209 /* Left flush part of the string */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
210 ll = gui_item_display_flush_left (gui_item, buf, MAX_MENUITEM_LENGTH);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
211
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
212 ll = msw_translate_menu_or_dialog_item ((Bufbyte *) buf, ll,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
213 MAX_MENUITEM_LENGTH, accel,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
214 XGUI_ITEM (gui_item)->name);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
215
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
216 /* Right flush part, unless we're at the top-level where it's not allowed */
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
217 if (!bar_p)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
218 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
219 unsigned int lr;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
220
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
221 assert (MAX_MENUITEM_LENGTH > ll + 1);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
222 lr = gui_item_display_flush_right (gui_item, buf + ll + 1,
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
223 MAX_MENUITEM_LENGTH - ll - 1);
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
224 if (lr)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
225 buf [ll] = '\t';
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
226 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
227
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
228 return buf;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
229 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
230
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
231 /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
232 * hmenu_to_lisp_object() returns an opaque ptr given menu handle.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
233 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
234 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
235 hmenu_to_lisp_object (HMENU hmenu)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
236 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
237 return make_opaque_ptr (hmenu);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
238 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
239
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
240 /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
241 * Allocation tries a hash based on item's path and name first. This
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
242 * almost guarantees that the same item will override its old value in
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
243 * the hash table rather than abandon it.
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
244 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
245 static Lisp_Object
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
246 allocate_menu_item_id (Lisp_Object path, Lisp_Object name, Lisp_Object suffix)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
247 {
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
248 UINT id = MENU_ITEM_ID_BITS (HASH3 (internal_hash (path, 0),
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
249 internal_hash (name, 0),
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
250 internal_hash (suffix, 0)));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
251 do {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
252 id = MENU_ITEM_ID_BITS (id + 1);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
253 } while (GetMenuState (top_level_menu, id, MF_BYCOMMAND) != 0xFFFFFFFF);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
254 return make_int (id);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
255 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
256
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
257 static HMENU
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
258 create_empty_popup_menu (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
259 {
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
260 return CreatePopupMenu ();
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
261 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
262
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
263 static void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
264 empty_menu (HMENU menu, int add_empty_p)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
265 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
266 while (DeleteMenu (menu, 0, MF_BYPOSITION));
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
267 if (add_empty_p)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
268 AppendMenu (menu, MF_STRING | MF_GRAYED, EMPTY_ITEM_ID, EMPTY_ITEM_NAME);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
269 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
270
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
271 /*
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
272 * The idea of checksumming is that we must hash minimal object
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
273 * which is necessarily changes when the item changes. For separator
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
274 * this is a constant, for grey strings and submenus these are hashes
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
275 * of names, since submenus are unpopulated until opened so always
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
276 * equal otherwise. For items, this is a full hash value of a callback,
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
277 * because a callback may me a form which can be changed only somewhere
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
278 * in depth.
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
279 */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
280 static unsigned long
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
281 checksum_menu_item (Lisp_Object item)
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
282 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
283 if (STRINGP (item))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
284 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
285 /* Separator or unselectable text - hash as a string + 13 */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
286 if (separator_string_p (XSTRING_DATA (item)))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
287 return 13;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
288 else
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
289 return internal_hash (item, 0) + 13;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
290 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
291 else if (CONSP (item))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
292 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
293 /* Submenu - hash by its string name + 0 */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
294 return internal_hash (XCAR(item), 0);
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
295 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
296 else if (VECTORP (item))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
297 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
298 /* An ordinary item - hash its name and callback form. */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
299 return HASH2 (internal_hash (XVECTOR_DATA(item)[0], 0),
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
300 internal_hash (XVECTOR_DATA(item)[1], 0));
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
301 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
302
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
303 /* An error - will be caught later */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
304 return 0;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
305 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
306
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
307 static void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
308 populate_menu_add_item (HMENU menu, Lisp_Object path,
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
309 Lisp_Object hash_tab, Lisp_Object item,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
310 Lisp_Object *accel_list,
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
311 int flush_right, int bar_p)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
312 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
313 MENUITEMINFO item_info;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
314
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
315 item_info.cbSize = sizeof (item_info);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
316 item_info.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
317 item_info.fState = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
318 item_info.wID = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
319 item_info.fType = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
320
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
321 if (STRINGP (item))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
322 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
323 /* Separator or unselectable text */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
324 if (separator_string_p (XSTRING_DATA (item)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
325 item_info.fType = MFT_SEPARATOR;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
326 else
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
327 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
328 item_info.fType = MFT_STRING;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
329 item_info.fState = MFS_DISABLED;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
330 item_info.dwTypeData = XSTRING_DATA (item);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
331 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
332 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
333 else if (CONSP (item))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
334 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
335 /* Submenu */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
336 HMENU submenu;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
337 Lisp_Object gui_item = allocate_gui_item ();
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
338 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
339 struct gcpro gcpro1, gcpro2, gcpro3;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
340 Emchar accel;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
341
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
342 GCPRO3 (gui_item, path, *accel_list);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
343
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
344 menu_parse_submenu_keywords (item, gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
345
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
346 if (!STRINGP (pgui_item->name))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
347 signal_simple_error ("Menu name (first element) must be a string",
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
348 item);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
349
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
350 if (!gui_item_included_p (gui_item, Vmenubar_configuration))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
351 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
352 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
353 goto done;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
354 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
355
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
356 if (!gui_item_active_p (gui_item))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
357 item_info.fState = MFS_GRAYED;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
358 /* Temptation is to put 'else' right here. Although, the
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
359 displayed item won't have an arrow indicating that it is a
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
360 popup. So we go ahead a little bit more and create a popup */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
361 submenu = create_empty_popup_menu ();
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
362
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
363 item_info.fMask |= MIIM_SUBMENU;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
364 item_info.dwTypeData = displayable_menu_item (gui_item, bar_p, &accel);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
365 item_info.hSubMenu = submenu;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
366
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
367 if (accel && bar_p)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
368 *accel_list = Fcons (make_char (accel), *accel_list);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
369
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
370 if (!(item_info.fState & MFS_GRAYED))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
371 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
372 /* Now add the full submenu path as a value to the hash table,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
373 keyed by menu handle */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
374 if (NILP(path))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
375 path = list1 (pgui_item->name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
376 else
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
377 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
378 Lisp_Object arg[2];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
379 arg[0] = path;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
380 arg[1] = list1 (pgui_item->name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
381 path = Fappend (2, arg);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
382 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
383
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
384 Fputhash (hmenu_to_lisp_object (submenu), path, hash_tab);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
385 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
386 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
387 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
388 else if (VECTORP (item))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
389 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
390 /* An ordinary item */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
391 Lisp_Object style, id;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
392 Lisp_Object gui_item = gui_parse_item_keywords (item);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
393 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
394 struct gcpro gcpro1, gcpro2;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
395 Emchar accel;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
396
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
397 GCPRO2 (gui_item, *accel_list);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
398
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
399 if (!gui_item_included_p (gui_item, Vmenubar_configuration))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
400 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
401 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
402 goto done;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
403 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
405 if (!STRINGP (pgui_item->name))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
406 pgui_item->name = Feval (pgui_item->name);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
407
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
408 if (!gui_item_active_p (gui_item))
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
409 item_info.fState = MFS_GRAYED;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
410
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
411 style = (NILP (pgui_item->selected) || NILP (Feval (pgui_item->selected))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
412 ? Qnil : pgui_item->style);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
413
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
414 if (EQ (style, Qradio))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
415 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
416 item_info.fType |= MFT_RADIOCHECK;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
417 item_info.fState |= MFS_CHECKED;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
418 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
419 else if (EQ (style, Qtoggle))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
420 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
421 item_info.fState |= MFS_CHECKED;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
422 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
423
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
424 id = allocate_menu_item_id (path, pgui_item->name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
425 pgui_item->suffix);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
426 Fputhash (id, pgui_item->callback, hash_tab);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
427
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
428 item_info.wID = (UINT) XINT (id);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
429 item_info.fType |= MFT_STRING;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
430 item_info.dwTypeData = displayable_menu_item (gui_item, bar_p, &accel);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
431
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
432 if (accel && bar_p)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
433 *accel_list = Fcons (make_char (accel), *accel_list);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
434
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
435 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
436 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
437 else
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
438 {
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
439 signal_simple_error ("Malformed menu item descriptor", item);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
440 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
441
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
442 if (flush_right)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
443 item_info.fType |= MFT_RIGHTJUSTIFY;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
444
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
445 InsertMenuItem (menu, UINT_MAX, TRUE, &item_info);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
446
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
447 done:;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
448 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
449
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
450 /*
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
451 * This function is called from populate_menu and checksum_menu.
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
452 * When called to populate, MENU is a menu handle, PATH is a
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
453 * list of strings representing menu path from root to this submenu,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
454 * DESCRIPTOR is a menu descriptor, HASH_TAB is a hash table associated
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
455 * with root menu, BAR_P indicates whether this called for a menubar or
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
456 * a popup, and POPULATE_P is non-zero. Return value must be ignored.
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
457 * When called to checksum, DESCRIPTOR has the same meaning, POPULATE_P
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
458 * is zero, PATH must be Qnil, and the rest of parameters is ignored.
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
459 * Return value is the menu checksum.
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
460 */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
461 static unsigned long
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
462 populate_or_checksum_helper (HMENU menu, Lisp_Object path, Lisp_Object desc,
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
463 Lisp_Object hash_tab, int bar_p, int populate_p)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
464 {
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
465 Lisp_Object item_desc;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
466 int deep_p, flush_right;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
467 struct gcpro gcpro1, gcpro2, gcpro3;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
468 unsigned long checksum;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
469 Lisp_Object gui_item = allocate_gui_item ();
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
470 Lisp_Object accel_list = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
471 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
472
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
473 GCPRO3 (gui_item, accel_list, desc);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
474
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
475 /* We are sometimes called with the menubar unchanged, and with changed
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
476 right flush. We have to update the menubar in this case,
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
477 so account for the compliance setting in the hash value */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
478 checksum = REPLACE_ME_WITH_GLOBAL_VARIABLE_WHICH_CONTROLS_RIGHT_FLUSH;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
479
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
480 /* Will initially contain only "(empty)" */
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
481 if (populate_p)
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
482 empty_menu (menu, 1);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
483
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
484 /* PATH set to nil indicates top-level popup or menubar */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
485 deep_p = !NILP (path);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
486
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
487 /* Fetch keywords prepending the item list */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
488 desc = menu_parse_submenu_keywords (desc, gui_item);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
489
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
490 /* Check that menu name is specified when expected */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
491 if (NILP (pgui_item->name) && deep_p)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
492 signal_simple_error ("Menu must have a name", desc);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
493
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
494 /* Apply filter if specified */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
495 if (!NILP (pgui_item->filter))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
496 desc = call1 (pgui_item->filter, desc);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
497
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
498 /* Loop thru the desc's CDR and add items for each entry */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
499 flush_right = 0;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
500 EXTERNAL_LIST_LOOP (item_desc, desc)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
501 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
502 if (NILP (XCAR (item_desc)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
503 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
504 /* Do not flush right menubar items when MS style compliant */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
505 if (bar_p && !REPLACE_ME_WITH_GLOBAL_VARIABLE_WHICH_CONTROLS_RIGHT_FLUSH)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
506 flush_right = 1;
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
507 if (!populate_p)
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
508 checksum = HASH2 (checksum, LISP_HASH (Qnil));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
509 }
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
510 else if (populate_p)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
511 populate_menu_add_item (menu, path, hash_tab,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
512 XCAR (item_desc), &accel_list,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
513 flush_right, bar_p);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
514 else
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
515 checksum = HASH2 (checksum,
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
516 checksum_menu_item (XCAR (item_desc)));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
517 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
518
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
519 if (populate_p)
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
520 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
521 /* Remove the "(empty)" item, if there are other ones */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
522 if (GetMenuItemCount (menu) > 1)
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
523 RemoveMenu (menu, EMPTY_ITEM_ID, MF_BYCOMMAND);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
524
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
525 /* Add the header to the popup, if told so. The same as in X - an
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
526 insensitive item, and a separator (Seems to me, there were
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
527 two separators in X... In Windows this looks ugly, anyways.) */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
528 if (!bar_p && !deep_p && popup_menu_titles && !NILP (pgui_item->name))
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
529 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
530 CHECK_STRING (pgui_item->name);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
531 InsertMenu (menu, 0, MF_BYPOSITION | MF_STRING | MF_DISABLED,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
532 0, XSTRING_DATA(pgui_item->name));
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
533 InsertMenu (menu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
534 SetMenuDefaultItem (menu, 0, MF_BYPOSITION);
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
535 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
536 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
537
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
538 if (bar_p)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
539 Fputhash (Qt, accel_list, hash_tab);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
540
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
541 UNGCPRO;
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
542 return checksum;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
543 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
544
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
545 static void
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
546 populate_menu (HMENU menu, Lisp_Object path, Lisp_Object desc,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
547 Lisp_Object hash_tab, int bar_p)
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
548 {
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
549 populate_or_checksum_helper (menu, path, desc, hash_tab, bar_p, 1);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
550 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
551
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
552 static unsigned long
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
553 checksum_menu (Lisp_Object desc)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
554 {
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
555 return populate_or_checksum_helper (NULL, Qnil, desc, Qunbound, 0, 0);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
556 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
557
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
558 static void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
559 update_frame_menubar_maybe (struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
560 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
561 HMENU menubar = GetMenu (FRAME_MSWINDOWS_HANDLE (f));
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
562 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
563 Lisp_Object desc = (!NILP (w->menubar_visible_p)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
564 ? symbol_value_in_buffer (Qcurrent_menubar, w->buffer)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
565 : Qnil);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
566 struct gcpro gcpro1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
567
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
568 GCPRO1 (desc); /* it's safest to do this, just in case some filter
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
569 or something changes the value of current-menubar */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
570
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
571 top_level_menu = menubar;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
572
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
573 if (NILP (desc) && menubar != NULL)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
574 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
575 /* Menubar has gone */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
576 FRAME_MSWINDOWS_MENU_HASH_TABLE (f) = Qnil;
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
577 SetMenu (FRAME_MSWINDOWS_HANDLE (f), NULL);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
578 DestroyMenu (menubar);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
579 DrawMenuBar (FRAME_MSWINDOWS_HANDLE (f));
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
580 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
581 return;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
582 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
583
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
584 if (!NILP (desc) && menubar == NULL)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
585 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
586 /* Menubar has appeared */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
587 menubar = CreateMenu ();
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
588 goto populate;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
589 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
590
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
591 if (NILP (desc))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
592 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
593 /* We did not have the bar and are not going to */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
594 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
595 return;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
596 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
597
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
598 /* Now we bail out if the menubar has not changed */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
599 if (FRAME_MSWINDOWS_MENU_CHECKSUM (f) == checksum_menu (desc))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
600 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
601 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
602 return;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
603 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
604
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
605 populate:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
606 /* Come with empty hash table */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
607 if (NILP (FRAME_MSWINDOWS_MENU_HASH_TABLE (f)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
608 FRAME_MSWINDOWS_MENU_HASH_TABLE (f) =
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
609 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
610 else
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
611 Fclrhash (FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
612
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
613 Fputhash (hmenu_to_lisp_object (menubar), Qnil,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
614 FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
615 populate_menu (menubar, Qnil, desc,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
616 FRAME_MSWINDOWS_MENU_HASH_TABLE (f), 1);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
617 SetMenu (FRAME_MSWINDOWS_HANDLE (f), menubar);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
618 DrawMenuBar (FRAME_MSWINDOWS_HANDLE (f));
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
619
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
620 FRAME_MSWINDOWS_MENU_CHECKSUM (f) = checksum_menu (desc);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
621
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
622 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
623 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
624
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
625 static void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
626 prune_menubar (struct frame *f)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
627 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
628 HMENU menubar = GetMenu (FRAME_MSWINDOWS_HANDLE (f));
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
629 Lisp_Object desc = current_frame_menubar (f);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
630 struct gcpro gcpro1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
631
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
632 if (menubar == NULL)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
633 return;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
634
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
635 /* #### If a filter function has set desc to Qnil, this abort()
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
636 triggers. To resolve, we must prevent filters explicitly from
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
637 mangling with the active menu. In apply_filter probably?
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
638 Is copy-tree on the whole menu too expensive? */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
639 if (NILP (desc))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
640 /* abort(); */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
641 return;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
642
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
643 GCPRO1 (desc); /* just to be safe -- see above */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
644 /* We do the trick by removing all items and re-populating top level */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
645 empty_menu (menubar, 0);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
646
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
647 assert (HASH_TABLEP (FRAME_MSWINDOWS_MENU_HASH_TABLE (f)));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
648 Fclrhash (FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
649
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
650 Fputhash (hmenu_to_lisp_object (menubar), Qnil,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
651 FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
652 populate_menu (menubar, Qnil, desc,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
653 FRAME_MSWINDOWS_MENU_HASH_TABLE (f), 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
654 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
655 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
656
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
657 /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
658 * This is called when cleanup is possible. It is better not to
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
659 * clean things up at all than do it too early!
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
660 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
661 static void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
662 menu_cleanup (struct frame *f)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
663 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
664 /* This function can GC */
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
665 current_menudesc = Qnil;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
666 current_hash_table = Qnil;
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
667 prune_menubar (f);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
668 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
669
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
670 int
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
671 msw_char_is_accelerator (struct frame *f, Emchar ch)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
672 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
673 Lisp_Object hash = FRAME_MSWINDOWS_MENU_HASH_TABLE (f);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
674
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
675 assert (HASH_TABLEP (hash));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
676 /* !!#### not Mule-ized */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
677 return !NILP (memq_no_quit (make_char (tolower (ch)),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
678 Fgethash (Qt, hash, Qnil)));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
679 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
680
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
681
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
682 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
683 /* Message handlers */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
684 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
685 static Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
686 unsafe_handle_wm_initmenupopup_1 (HMENU menu, struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
687 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
688 /* This function can call lisp, beat dogs and stick chewing gum to
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
689 everything! */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
690
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
691 Lisp_Object path, desc;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
692 struct gcpro gcpro1;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
693
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
694 /* Find which guy is going to explode */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
695 path = Fgethash (hmenu_to_lisp_object (menu), current_hash_table, Qunbound);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
696 assert (!UNBOUNDP (path));
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
697 #ifdef DEBUG_XEMACS
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
698 /* Allow to continue in a debugger after assert - not so fatal */
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
699 if (UNBOUNDP (path))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
700 error ("internal menu error");
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
701 #endif
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
702
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
703 /* Now find a desc chunk for it. If none, then probably menu open
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
704 hook has played too much games around stuff */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
705 desc = Fmenu_find_real_submenu (current_menudesc, path);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
706 if (NILP (desc))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
707 signal_simple_error ("This menu does not exist any more", path);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
708
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
709 /* Now, stuff it */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
710 /* DESC may be generated by filter, so we have to gcpro it */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
711 GCPRO1 (desc);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
712 populate_menu (menu, path, desc, current_hash_table, 0);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
713 UNGCPRO;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
714 return Qt;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
715 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
716
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
717 static Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
718 unsafe_handle_wm_initmenu_1 (struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
719 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
720 /* This function can call lisp */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
721
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
722 /* NOTE: This is called for the bar only, WM_INITMENU
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
723 for popups is filtered out */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
724
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
725 /* #### - this menubar update mechanism is expensively anti-social and
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
726 the activate-menubar-hook is now mostly obsolete. */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
727
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
728 /* We simply ignore return value. In any case, we construct the bar
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
729 on the fly */
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
730 run_hook (Qactivate_menubar_hook);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
731
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
732 update_frame_menubar_maybe (f);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
733
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
734 current_menudesc = current_frame_menubar (f);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
735 current_hash_table = FRAME_MSWINDOWS_MENU_HASH_TABLE (f);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
736 assert (HASH_TABLEP (current_hash_table));
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
737
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
738 return Qt;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
739 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
740
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
741 /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
742 * Return value is Qt if we have dispatched the command,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
743 * or Qnil if id has not been mapped to a callback.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
744 * Window procedure may try other targets to route the
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
745 * command if we return nil
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
746 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
747 Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
748 mswindows_handle_wm_command (struct frame *f, WORD id)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
749 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
750 /* Try to map the command id through the proper hash table */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
751 Lisp_Object data, fn, arg, frame;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
752 struct gcpro gcpro1;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
753
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
754 if (NILP (current_hash_table))
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
755 return Qnil;
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
756
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
757 data = Fgethash (make_int (id), current_hash_table, Qunbound);
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
758
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
759 if (UNBOUNDP (data))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
760 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
761 menu_cleanup (f);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
762 return Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
763 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
764
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
765 /* Need to gcpro because the hash table may get destroyed by
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
766 menu_cleanup(), and will not gcpro the data any more */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
767 GCPRO1 (data);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
768 menu_cleanup (f);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
769
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
770 /* Ok, this is our one. Enqueue it. */
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
771 get_gui_callback (data, &fn, &arg);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
772 XSETFRAME (frame, f);
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
773 /* this used to call mswindows_enqueue_misc_user_event but that
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
774 breaks customize because the misc_event gets eval'ed in some
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
775 cicumstances. Don't change it back unless you can fix the
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
776 customize problem also.*/
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
777 enqueue_misc_user_event (frame, fn, arg);
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
778 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
779
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
780 UNGCPRO; /* data */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
781 return Qt;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
782 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
783
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
784
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
785 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
786 /* Message handling proxies */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
787 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
788
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
789 static HMENU wm_initmenu_menu;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
790 static struct frame *wm_initmenu_frame;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
791
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
792 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
793 unsafe_handle_wm_initmenupopup (Lisp_Object u_n_u_s_e_d)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
794 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
795 return unsafe_handle_wm_initmenupopup_1 (wm_initmenu_menu, wm_initmenu_frame);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
796 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
797
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
798 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
799 unsafe_handle_wm_initmenu (Lisp_Object u_n_u_s_e_d)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
800 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
801 return unsafe_handle_wm_initmenu_1 (wm_initmenu_frame);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
802 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
803
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
804 Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
805 mswindows_handle_wm_initmenupopup (HMENU hmenu, struct frame *frm)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
806 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
807 /* We cannot pass hmenu as a lisp object. Use static var */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
808 wm_initmenu_menu = hmenu;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
809 wm_initmenu_frame = frm;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
810 return mswindows_protect_modal_loop (unsafe_handle_wm_initmenupopup, Qnil);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
811 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
812
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
813 Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
814 mswindows_handle_wm_initmenu (HMENU hmenu, struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
815 {
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
816 /* Handle only frame menubar, ignore if from popup or system menu */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
817 if (GetMenu (FRAME_MSWINDOWS_HANDLE (f)) == hmenu)
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
818 {
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
819 wm_initmenu_frame = f;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
820 return mswindows_protect_modal_loop (unsafe_handle_wm_initmenu, Qnil);
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
821 }
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
822 return Qt;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
823 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
824
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
825
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
826 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
827 /* Methods */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
828 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
829
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
830 static void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
831 mswindows_update_frame_menubars (struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
832 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 255
diff changeset
833 update_frame_menubar_maybe (f);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
834 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
835
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
836 static void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
837 mswindows_free_frame_menubars (struct frame *f)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
838 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
839 FRAME_MSWINDOWS_MENU_HASH_TABLE (f) = Qnil;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
840 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
841
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
842 static void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
843 mswindows_popup_menu (Lisp_Object menu_desc, Lisp_Object event)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
844 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
845 struct frame *f = selected_frame ();
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
846 Lisp_Event *eev = NULL;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
847 HMENU menu;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
848 POINT pt;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
849 int ok;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
850 struct gcpro gcpro1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
851
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
852 GCPRO1 (menu_desc); /* to be safe -- see above */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
853
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
854 if (!NILP (event))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
855 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
856 CHECK_LIVE_EVENT (event);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
857 eev = XEVENT (event);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
858 if (eev->event_type != button_press_event
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
859 && eev->event_type != button_release_event)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
860 wrong_type_argument (Qmouse_event_p, event);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
861 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
862 else if (!NILP (Vthis_command_keys))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
863 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
864 /* if an event wasn't passed, use the last event of the event sequence
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
865 currently being executed, if that event is a mouse event */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
866 eev = XEVENT (Vthis_command_keys); /* last event first */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
867 if (eev->event_type != button_press_event
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
868 && eev->event_type != button_release_event)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
869 eev = NULL;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
870 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
871
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
872 /* Default is to put the menu at the point (10, 10) in frame */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
873 if (eev)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
874 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
875 pt.x = eev->event.button.x;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
876 pt.y = eev->event.button.y;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
877 ClientToScreen (FRAME_MSWINDOWS_HANDLE (f), &pt);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
878 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
879 else
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
880 pt.x = pt.y = 10;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
881
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
882 if (SYMBOLP (menu_desc))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
883 menu_desc = Fsymbol_value (menu_desc);
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
884 CHECK_CONS (menu_desc);
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
885 CHECK_STRING (XCAR (menu_desc));
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
886
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
887 current_menudesc = menu_desc;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
888 current_hash_table =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
889 make_lisp_hash_table (10, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
890 menu = create_empty_popup_menu ();
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
891 Fputhash (hmenu_to_lisp_object (menu), Qnil, current_hash_table);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
892 top_level_menu = menu;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
893
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
894 /* see comments in menubar-x.c */
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
895 if (zmacs_regions)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
896 zmacs_region_stays = 1;
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 288
diff changeset
897
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
898 ok = TrackPopupMenu (menu,
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
899 TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
900 pt.x, pt.y, 0,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
901 FRAME_MSWINDOWS_HANDLE (f), NULL);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
902
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
903 DestroyMenu (menu);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
904
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
905 /* Signal a signal if caught by Track...() modal loop */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
906 mswindows_unmodalize_signal_maybe ();
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
907
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
908 /* This is probably the only real reason for failure */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
909 if (!ok)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
910 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
911 menu_cleanup (f);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
912 signal_simple_error ("Cannot track popup menu while in menu",
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
913 menu_desc);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
914 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
915 UNGCPRO;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
916 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
917
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
918
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
919 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
920 /* Initialization */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
921 /*------------------------------------------------------------------------*/
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
922 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
923 syms_of_menubar_mswindows (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
924 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
925 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
926
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
927 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
928 console_type_create_menubar_mswindows (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
929 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
930 CONSOLE_HAS_METHOD (mswindows, update_frame_menubars);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
931 CONSOLE_HAS_METHOD (mswindows, free_frame_menubars);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
932 CONSOLE_HAS_METHOD (mswindows, popup_menu);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
933 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
934
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
935 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
936 vars_of_menubar_mswindows (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
937 {
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
938 current_menudesc = Qnil;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
939 current_hash_table = Qnil;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents:
diff changeset
940
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
941 staticpro (&current_menudesc);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
942 staticpro (&current_hash_table);
253
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 251
diff changeset
943 }