Mercurial > emacs
annotate src/w32menu.c @ 39874:29644872e1e4
(EMACSVER): Bump to 21.1.50.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 13 Oct 2001 10:44:31 +0000 |
parents | 38c1890338cc |
children | bf81460680f2 |
rev | line source |
---|---|
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16860
diff
changeset
|
1 /* Menu support for GNU Emacs on the Microsoft W32 API. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
2 Copyright (C) 1986, 88, 93, 94, 96, 98, 1999 Free Software Foundation, Inc. |
13434 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13434 | 20 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
21 #include <config.h> |
13434 | 22 #include <signal.h> |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
23 |
13434 | 24 #include <stdio.h> |
25 #include "lisp.h" | |
26 #include "termhooks.h" | |
31114
cd392fdf0e9f
Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents:
30989
diff
changeset
|
27 #include "keyboard.h" |
39690
38c1890338cc
(keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
28 #include "keymap.h" |
13434 | 29 #include "frame.h" |
30 #include "window.h" | |
31 #include "blockinput.h" | |
15276 | 32 #include "buffer.h" |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
33 #include "charset.h" |
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
34 #include "coding.h" |
13434 | 35 |
36 /* This may include sys/types.h, and that somehow loses | |
37 if this is not done before the other system files. */ | |
38 #include "w32term.h" | |
39 | |
40 /* Load sys/types.h if not already loaded. | |
41 In some systems loading it twice is suicidal. */ | |
42 #ifndef makedev | |
43 #include <sys/types.h> | |
44 #endif | |
45 | |
46 #include "dispextern.h" | |
47 | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
48 #undef HAVE_MULTILINGUAL_MENU |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
49 #undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
50 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
51 /******************************************************************/ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
52 /* Definitions copied from lwlib.h */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
53 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
54 typedef void * XtPointer; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
55 typedef char Boolean; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
56 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
57 enum button_type |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
58 { |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
59 BUTTON_TYPE_NONE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
60 BUTTON_TYPE_TOGGLE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
61 BUTTON_TYPE_RADIO |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
62 }; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
63 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
64 typedef struct _widget_value |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
65 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
66 /* name of widget */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
67 char* name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
68 /* value (meaning depend on widget type) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
69 char* value; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
70 /* keyboard equivalent. no implications for XtTranslations */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
71 char* key; |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
72 /* Help string or null if none. */ |
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
73 char *help; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
74 /* true if enabled */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
75 Boolean enabled; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
76 /* true if selected */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
77 Boolean selected; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
78 /* The type of a button. */ |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
79 enum button_type button_type; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
80 /* true if menu title */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
81 Boolean title; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
82 #if 0 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
83 /* true if was edited (maintained by get_value) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
84 Boolean edited; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
85 /* true if has changed (maintained by lw library) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
86 change_type change; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
87 /* true if this widget itself has changed, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
88 but not counting the other widgets found in the `next' field. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
89 change_type this_one_change; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
90 #endif |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
91 /* Contents of the sub-widgets, also selected slot for checkbox */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
92 struct _widget_value* contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
93 /* data passed to callback */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
94 XtPointer call_data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
95 /* next one in the list */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
96 struct _widget_value* next; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
97 #if 0 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
98 /* slot for the toolkit dependent part. Always initialize to NULL. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
99 void* toolkit_data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
100 /* tell us if we should free the toolkit data slot when freeing the |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
101 widget_value itself. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
102 Boolean free_toolkit_data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
103 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
104 /* we resource the widget_value structures; this points to the next |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
105 one on the free list if this one has been deallocated. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
106 */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
107 struct _widget_value *free_list; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
108 #endif |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
109 } widget_value; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
110 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
111 /* LocalAlloc/Free is a reasonably good allocator. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
112 #define malloc_widget_value() (void*)LocalAlloc (LMEM_ZEROINIT, sizeof (widget_value)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
113 #define free_widget_value(wv) LocalFree (wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
114 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
115 /******************************************************************/ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
116 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
117 #ifndef TRUE |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
118 #define TRUE 1 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
119 #define FALSE 0 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
120 #endif /* no TRUE */ |
13434 | 121 |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
122 Lisp_Object Vmenu_updating_frame; |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
123 |
15276 | 124 Lisp_Object Qdebug_on_next_call; |
125 | |
13434 | 126 extern Lisp_Object Qmenu_bar; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
127 extern Lisp_Object Qmouse_click, Qevent_kind; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
128 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
129 extern Lisp_Object QCtoggle, QCradio; |
13434 | 130 |
15276 | 131 extern Lisp_Object Voverriding_local_map; |
132 extern Lisp_Object Voverriding_local_map_menu_flag; | |
133 | |
134 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; | |
135 | |
136 extern Lisp_Object Qmenu_bar_update_hook; | |
137 | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
138 void set_frame_menubar (); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
139 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
140 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
141 Lisp_Object, Lisp_Object, Lisp_Object, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
142 Lisp_Object, Lisp_Object)); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
143 static Lisp_Object w32_dialog_show (); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
144 static Lisp_Object w32_menu_show (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
145 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
146 static void keymap_panes (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
147 static void single_keymap_panes (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
148 static void single_menu_item (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
149 static void list_of_panes (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
150 static void list_of_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
151 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
152 /* This holds a Lisp vector that holds the results of decoding |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
153 the keymaps or alist-of-alists that specify a menu. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
154 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
155 It describes the panes and items within the panes. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
156 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
157 Each pane is described by 3 elements in the vector: |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
158 t, the pane name, the pane's prefix key. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
159 Then follow the pane's items, with 5 elements per item: |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
160 the item string, the enable flag, the item's value, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
161 the definition, and the equivalent keyboard key's description string. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
162 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
163 In some cases, multiple levels of menus may be described. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
164 A single vector slot containing nil indicates the start of a submenu. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
165 A single vector slot containing lambda indicates the end of a submenu. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
166 The submenu follows a menu item which is the way to reach the submenu. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
167 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
168 A single vector slot containing quote indicates that the |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
169 following items should appear on the right of a dialog box. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
170 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
171 Using a Lisp vector to hold this information while we decode it |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
172 takes care of protecting all the data from GC. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
173 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
174 #define MENU_ITEMS_PANE_NAME 1 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
175 #define MENU_ITEMS_PANE_PREFIX 2 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
176 #define MENU_ITEMS_PANE_LENGTH 3 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
177 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
178 enum menu_item_idx |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
179 { |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
180 MENU_ITEMS_ITEM_NAME = 0, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
181 MENU_ITEMS_ITEM_ENABLE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
182 MENU_ITEMS_ITEM_VALUE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
183 MENU_ITEMS_ITEM_EQUIV_KEY, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
184 MENU_ITEMS_ITEM_DEFINITION, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
185 MENU_ITEMS_ITEM_TYPE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
186 MENU_ITEMS_ITEM_SELECTED, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
187 MENU_ITEMS_ITEM_HELP, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
188 MENU_ITEMS_ITEM_LENGTH |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
189 }; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
190 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
191 static Lisp_Object menu_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
192 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
193 /* Number of slots currently allocated in menu_items. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
194 static int menu_items_allocated; |
13434 | 195 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
196 /* This is the index in menu_items of the first empty slot. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
197 static int menu_items_used; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
198 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
199 /* The number of panes currently recorded in menu_items, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
200 excluding those within submenus. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
201 static int menu_items_n_panes; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
202 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
203 /* Current depth within submenus. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
204 static int menu_items_submenu_depth; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
205 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
206 /* Flag which when set indicates a dialog or menu has been posted by |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
207 Xt on behalf of one of the widget sets. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
208 static int popup_activated_flag; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
209 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
210 static int next_menubar_widget_id; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
211 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
212 /* This is set nonzero after the user activates the menu bar, and set |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
213 to zero again after the menu bars are redisplayed by prepare_menu_bar. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
214 While it is nonzero, all calls to set_frame_menubar go deep. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
215 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
216 I don't understand why this is needed, but it does seem to be |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
217 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
218 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
219 int pending_menu_activation; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
220 |
13434 | 221 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
222 /* Return the frame whose ->output_data.w32->menubar_widget equals |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
223 ID, or 0 if none. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
224 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
225 static struct frame * |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
226 menubar_id_to_frame (id) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
227 HMENU id; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
228 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
229 Lisp_Object tail, frame; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
230 FRAME_PTR f; |
13434 | 231 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
232 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
233 { |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
234 frame = XCAR (tail); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
235 if (!GC_FRAMEP (frame)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
236 continue; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
237 f = XFRAME (frame); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
238 if (!FRAME_WINDOW_P (f)) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
239 continue; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
240 if (f->output_data.w32->menubar_widget == id) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
241 return f; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
242 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
243 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
244 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
245 |
13434 | 246 /* Initialize the menu_items structure if we haven't already done so. |
247 Also mark it as currently empty. */ | |
248 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
249 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
250 init_menu_items () |
13434 | 251 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
252 if (NILP (menu_items)) |
13434 | 253 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
254 menu_items_allocated = 60; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
255 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
13434 | 256 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
257 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
258 menu_items_used = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
259 menu_items_n_panes = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
260 menu_items_submenu_depth = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
261 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
262 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
263 /* Call at the end of generating the data in menu_items. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
264 This fills in the number of items in the last pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
265 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
266 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
267 finish_menu_items () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
268 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
269 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
270 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
271 /* Call when finished using the data for the current menu |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
272 in menu_items. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
273 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
274 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
275 discard_menu_items () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
276 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
277 /* Free the structure if it is especially large. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
278 Otherwise, hold on to it, to save time. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
279 if (menu_items_allocated > 200) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
280 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
281 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
282 menu_items_allocated = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
283 } |
13434 | 284 } |
285 | |
286 /* Make the menu_items vector twice as large. */ | |
287 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
288 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
289 grow_menu_items () |
13434 | 290 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
291 Lisp_Object old; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
292 int old_size = menu_items_allocated; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
293 old = menu_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
294 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
295 menu_items_allocated *= 2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
296 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
297 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, |
13434 | 298 old_size * sizeof (Lisp_Object)); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
299 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
300 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
301 /* Begin a submenu. */ |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
302 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
303 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
304 push_submenu_start () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
305 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
306 if (menu_items_used + 1 > menu_items_allocated) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
307 grow_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
308 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
309 XVECTOR (menu_items)->contents[menu_items_used++] = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
310 menu_items_submenu_depth++; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
311 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
312 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
313 /* End a submenu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
314 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
315 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
316 push_submenu_end () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
317 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
318 if (menu_items_used + 1 > menu_items_allocated) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
319 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
320 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
321 XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
322 menu_items_submenu_depth--; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
323 } |
13434 | 324 |
325 /* Indicate boundary between left and right. */ | |
326 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
327 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
328 push_left_right_boundary () |
13434 | 329 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
330 if (menu_items_used + 1 > menu_items_allocated) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
331 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
332 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
333 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
334 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
335 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
336 /* Start a new menu pane in menu_items.. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
337 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
338 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
339 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
340 push_menu_pane (name, prefix_vec) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
341 Lisp_Object name, prefix_vec; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
342 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
343 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
344 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
345 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
346 if (menu_items_submenu_depth == 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
347 menu_items_n_panes++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
348 XVECTOR (menu_items)->contents[menu_items_used++] = Qt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
349 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
350 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec; |
13434 | 351 } |
352 | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
353 /* Push one menu item into the current pane. NAME is the string to |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
354 display. ENABLE if non-nil means this item can be selected. KEY |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
355 is the key generated by choosing this item, or nil if this item |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
356 doesn't really have a definition. DEF is the definition of this |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
357 item. EQUIV is the textual description of the keyboard equivalent |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
358 for this item (or nil if none). TYPE is the type of this menu |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
359 item, one of nil, `toggle' or `radio'. */ |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
360 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
361 static void |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
362 push_menu_item (name, enable, key, def, equiv, type, selected, help) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
363 Lisp_Object name, enable, key, def, equiv, type, selected, help; |
13434 | 364 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
365 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
366 grow_menu_items (); |
13434 | 367 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
368 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
369 XVECTOR (menu_items)->contents[menu_items_used++] = enable; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
370 XVECTOR (menu_items)->contents[menu_items_used++] = key; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
371 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
372 XVECTOR (menu_items)->contents[menu_items_used++] = def; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
373 XVECTOR (menu_items)->contents[menu_items_used++] = type; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
374 XVECTOR (menu_items)->contents[menu_items_used++] = selected; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
375 XVECTOR (menu_items)->contents[menu_items_used++] = help; |
13434 | 376 } |
377 | |
378 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long, | |
379 and generate menu panes for them in menu_items. | |
380 If NOTREAL is nonzero, | |
381 don't bother really computing whether an item is enabled. */ | |
382 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
383 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
384 keymap_panes (keymaps, nmaps, notreal) |
13434 | 385 Lisp_Object *keymaps; |
386 int nmaps; | |
387 int notreal; | |
388 { | |
389 int mapno; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
390 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
391 init_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
392 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
393 /* Loop over the given keymaps, making a pane for each map. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
394 But don't make a pane that is empty--ignore that map instead. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
395 P is the number of panes we have made so far. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
396 for (mapno = 0; mapno < nmaps; mapno++) |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
397 single_keymap_panes (keymaps[mapno], |
39690
38c1890338cc
(keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
398 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10); |
13434 | 399 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
400 finish_menu_items (); |
13434 | 401 } |
402 | |
403 /* This is a recursive subroutine of keymap_panes. | |
404 It handles one keymap, KEYMAP. | |
405 The other arguments are passed along | |
406 or point to local variables of the previous function. | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
407 If NOTREAL is nonzero, only check for equivalent key bindings, don't |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
408 evaluate expressions in menu items and don't make any menu. |
13434 | 409 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
410 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
411 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
412 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
413 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) |
13434 | 414 Lisp_Object keymap; |
415 Lisp_Object pane_name; | |
416 Lisp_Object prefix; | |
417 int notreal; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
418 int maxdepth; |
13434 | 419 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
420 Lisp_Object pending_maps = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
421 Lisp_Object tail, item; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
422 struct gcpro gcpro1, gcpro2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
423 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
424 if (maxdepth <= 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
425 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
426 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
427 push_menu_pane (pane_name, prefix); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
428 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
429 for (tail = keymap; CONSP (tail); tail = XCDR (tail)) |
13434 | 430 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
431 GCPRO2 (keymap, pending_maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
432 /* Look at each key binding, and if it is a menu item add it |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
433 to this menu. */ |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
434 item = XCAR (tail); |
13434 | 435 if (CONSP (item)) |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
436 single_menu_item (XCAR (item), XCDR (item), |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
437 &pending_maps, notreal, maxdepth); |
13434 | 438 else if (VECTORP (item)) |
439 { | |
440 /* Loop over the char values represented in the vector. */ | |
441 int len = XVECTOR (item)->size; | |
442 int c; | |
443 for (c = 0; c < len; c++) | |
444 { | |
445 Lisp_Object character; | |
446 XSETFASTINT (character, c); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
447 single_menu_item (character, XVECTOR (item)->contents[c], |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
448 &pending_maps, notreal, maxdepth); |
13434 | 449 } |
450 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
451 UNGCPRO; |
13434 | 452 } |
453 | |
454 /* Process now any submenus which want to be panes at this level. */ | |
455 while (!NILP (pending_maps)) | |
456 { | |
457 Lisp_Object elt, eltcdr, string; | |
458 elt = Fcar (pending_maps); | |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
459 eltcdr = XCDR (elt); |
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
460 string = XCAR (eltcdr); |
13434 | 461 /* We no longer discard the @ from the beginning of the string here. |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
462 Instead, we do this in w32_menu_show. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
463 single_keymap_panes (Fcar (elt), string, |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
464 XCDR (eltcdr), notreal, maxdepth - 1); |
13434 | 465 pending_maps = Fcdr (pending_maps); |
466 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
467 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
468 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
469 /* This is a subroutine of single_keymap_panes that handles one |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
470 keymap entry. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
471 KEY is a key in a keymap and ITEM is its binding. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
472 PENDING_MAPS_PTR points to a list of keymaps waiting to be made into |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
473 separate panes. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
474 If NOTREAL is nonzero, only check for equivalent key bindings, don't |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
475 evaluate expressions in menu items and don't make any menu. |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
476 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
477 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
478 static void |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
479 single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
480 Lisp_Object key, item; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
481 Lisp_Object *pending_maps_ptr; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
482 int maxdepth, notreal; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
483 { |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
484 Lisp_Object map, item_string, enabled; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
485 struct gcpro gcpro1, gcpro2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
486 int res; |
13434 | 487 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
488 /* Parse the menu item and leave the result in item_properties. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
489 GCPRO2 (key, item); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
490 res = parse_menu_item (item, notreal, 0); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
491 UNGCPRO; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
492 if (!res) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
493 return; /* Not a menu item. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
494 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
495 map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
496 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
497 if (notreal) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
498 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
499 /* We don't want to make a menu, just traverse the keymaps to |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
500 precompute equivalent key bindings. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
501 if (!NILP (map)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
502 single_keymap_panes (map, Qnil, key, 1, maxdepth - 1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
503 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
504 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
505 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
506 enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
507 item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
508 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
509 if (!NILP (map) && XSTRING (item_string)->data[0] == '@') |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
510 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
511 if (!NILP (enabled)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
512 /* An enabled separate pane. Remember this to handle it later. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
513 *pending_maps_ptr = Fcons (Fcons (map, Fcons (item_string, key)), |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
514 *pending_maps_ptr); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
515 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
516 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
517 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
518 push_menu_item (item_string, enabled, key, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
519 XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
520 XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
521 XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE], |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
522 XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
523 XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
524 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
525 /* Display a submenu using the toolkit. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
526 if (! (NILP (map) || NILP (enabled))) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
527 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
528 push_submenu_start (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
529 single_keymap_panes (map, Qnil, key, 0, maxdepth - 1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
530 push_submenu_end (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
531 } |
13434 | 532 } |
533 | |
14036 | 534 /* Push all the panes and items of a menu described by the |
13434 | 535 alist-of-alists MENU. |
536 This handles old-fashioned calls to x-popup-menu. */ | |
537 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
538 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
539 list_of_panes (menu) |
13434 | 540 Lisp_Object menu; |
541 { | |
542 Lisp_Object tail; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
543 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
544 init_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
545 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
546 for (tail = menu; !NILP (tail); tail = Fcdr (tail)) |
13434 | 547 { |
548 Lisp_Object elt, pane_name, pane_data; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
549 elt = Fcar (tail); |
13434 | 550 pane_name = Fcar (elt); |
551 CHECK_STRING (pane_name, 0); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
552 push_menu_pane (pane_name, Qnil); |
13434 | 553 pane_data = Fcdr (elt); |
554 CHECK_CONS (pane_data, 0); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
555 list_of_items (pane_data); |
13434 | 556 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
557 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
558 finish_menu_items (); |
13434 | 559 } |
560 | |
561 /* Push the items in a single pane defined by the alist PANE. */ | |
562 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
563 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
564 list_of_items (pane) |
13434 | 565 Lisp_Object pane; |
566 { | |
567 Lisp_Object tail, item, item1; | |
568 | |
569 for (tail = pane; !NILP (tail); tail = Fcdr (tail)) | |
570 { | |
571 item = Fcar (tail); | |
572 if (STRINGP (item)) | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
573 push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil); |
13434 | 574 else if (NILP (item)) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
575 push_left_right_boundary (); |
13434 | 576 else |
577 { | |
578 CHECK_CONS (item, 0); | |
579 item1 = Fcar (item); | |
580 CHECK_STRING (item1, 1); | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
581 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); |
13434 | 582 } |
583 } | |
584 } | |
585 | |
586 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
587 "Pop up a deck-of-cards menu and return user's selection.\n\ |
13434 | 588 POSITION is a position specification. This is either a mouse button event\n\ |
589 or a list ((XOFFSET YOFFSET) WINDOW)\n\ | |
590 where XOFFSET and YOFFSET are positions in pixels from the top left\n\ | |
591 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\ | |
592 This controls the position of the center of the first line\n\ | |
593 in the first pane of the menu, not the top left of the menu as a whole.\n\ | |
594 If POSITION is t, it means to use the current mouse position.\n\ | |
595 \n\ | |
596 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\ | |
597 The menu items come from key bindings that have a menu string as well as\n\ | |
598 a definition; actually, the \"definition\" in such a key binding looks like\n\ | |
599 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\ | |
600 the keymap as a top-level element.\n\n\ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
601 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.\n\ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
602 Otherwise, REAL-DEFINITION should be a valid key binding definition.\n\ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
603 \n\ |
13434 | 604 You can also use a list of keymaps as MENU.\n\ |
605 Then each keymap makes a separate pane.\n\ | |
606 When MENU is a keymap or a list of keymaps, the return value\n\ | |
607 is a list of events.\n\n\ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
608 \n\ |
13434 | 609 Alternatively, you can specify a menu of multiple panes\n\ |
610 with a list of the form (TITLE PANE1 PANE2...),\n\ | |
611 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\ | |
612 Each ITEM is normally a cons cell (STRING . VALUE);\n\ | |
613 but a string can appear as an item--that makes a nonselectable line\n\ | |
614 in the menu.\n\ | |
615 With this form of menu, the return value is VALUE from the chosen item.\n\ | |
616 \n\ | |
617 If POSITION is nil, don't display the menu at all, just precalculate the\n\ | |
618 cached information about equivalent key sequences.") | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
619 (position, menu) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
620 Lisp_Object position, menu; |
13434 | 621 { |
622 Lisp_Object keymap, tem; | |
623 int xpos, ypos; | |
624 Lisp_Object title; | |
625 char *error_name; | |
626 Lisp_Object selection; | |
627 FRAME_PTR f; | |
628 Lisp_Object x, y, window; | |
629 int keymaps = 0; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
630 int for_click = 0; |
13434 | 631 struct gcpro gcpro1; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
632 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
633 #ifdef HAVE_MENUS |
13434 | 634 if (! NILP (position)) |
635 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
636 check_w32 (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
637 |
13434 | 638 /* Decode the first argument: find the window and the coordinates. */ |
16860
247f0b107588
(x-popup-menu): Pass in insist flag to mouse_position_hook.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16729
diff
changeset
|
639 if (EQ (position, Qt) |
32671
bbd3be4db5f2
(add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents:
31114
diff
changeset
|
640 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) |
bbd3be4db5f2
(add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents:
31114
diff
changeset
|
641 || EQ (XCAR (position), Qtool_bar)))) |
13434 | 642 { |
643 /* Use the mouse's current position. */ | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
644 FRAME_PTR new_f = SELECTED_FRAME (); |
13434 | 645 Lisp_Object bar_window; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
646 enum scroll_bar_part part; |
13434 | 647 unsigned long time; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
648 |
13434 | 649 if (mouse_position_hook) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
650 (*mouse_position_hook) (&new_f, 1, &bar_window, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
651 &part, &x, &y, &time); |
13434 | 652 if (new_f != 0) |
653 XSETFRAME (window, new_f); | |
654 else | |
655 { | |
656 window = selected_window; | |
657 XSETFASTINT (x, 0); | |
658 XSETFASTINT (y, 0); | |
659 } | |
660 } | |
661 else | |
662 { | |
663 tem = Fcar (position); | |
664 if (CONSP (tem)) | |
665 { | |
666 window = Fcar (Fcdr (position)); | |
667 x = Fcar (tem); | |
668 y = Fcar (Fcdr (tem)); | |
669 } | |
670 else | |
671 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
672 for_click = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
673 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
674 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
13434 | 675 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
676 x = Fcar (tem); | |
677 y = Fcdr (tem); | |
678 } | |
679 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
680 |
13434 | 681 CHECK_NUMBER (x, 0); |
682 CHECK_NUMBER (y, 0); | |
683 | |
684 /* Decode where to put the menu. */ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
685 |
13434 | 686 if (FRAMEP (window)) |
687 { | |
688 f = XFRAME (window); | |
689 xpos = 0; | |
690 ypos = 0; | |
691 } | |
692 else if (WINDOWP (window)) | |
693 { | |
694 CHECK_LIVE_WINDOW (window, 0); | |
695 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
696 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
697 xpos = (FONT_WIDTH (FRAME_FONT (f)) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
698 * XFASTINT (XWINDOW (window)->left)); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
699 ypos = (FRAME_LINE_HEIGHT (f) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
700 * XFASTINT (XWINDOW (window)->top)); |
13434 | 701 } |
702 else | |
703 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, | |
704 but I don't want to make one now. */ | |
705 CHECK_WINDOW (window, 0); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
706 |
13434 | 707 xpos += XINT (x); |
708 ypos += XINT (y); | |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
709 |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
710 XSETFRAME (Vmenu_updating_frame, f); |
13434 | 711 } |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
712 Vmenu_updating_frame = Qnil; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
713 #endif /* HAVE_MENUS */ |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
714 |
13434 | 715 title = Qnil; |
716 GCPRO1 (title); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
717 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
718 /* Decode the menu items from what was specified. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
719 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
720 keymap = get_keymap (menu, 0, 0); |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
721 if (CONSP (keymap)) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
722 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
723 /* We were given a keymap. Extract menu info from the keymap. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
724 Lisp_Object prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
725 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
726 /* Extract the detailed info to make one pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
727 keymap_panes (&menu, 1, NILP (position)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
728 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
729 /* Search for a string appearing directly as an element of the keymap. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
730 That string is the title of the menu. */ |
39690
38c1890338cc
(keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
731 prompt = Fkeymap_prompt (keymap); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
732 if (NILP (title) && !NILP (prompt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
733 title = prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
734 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
735 /* Make that be the pane title of the first pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
736 if (!NILP (prompt) && menu_items_n_panes >= 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
737 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
738 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
739 keymaps = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
740 } |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
741 else if (CONSP (menu) && KEYMAPP (XCAR (menu))) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
742 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
743 /* We were given a list of keymaps. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
744 int nmaps = XFASTINT (Flength (menu)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
745 Lisp_Object *maps |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
746 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
747 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
748 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
749 title = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
750 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
751 /* The first keymap that has a prompt string |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
752 supplies the menu title. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
753 for (tem = menu, i = 0; CONSP (tem); tem = Fcdr (tem)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
754 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
755 Lisp_Object prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
756 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
757 maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
758 |
39690
38c1890338cc
(keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
759 prompt = Fkeymap_prompt (keymap); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
760 if (NILP (title) && !NILP (prompt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
761 title = prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
762 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
763 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
764 /* Extract the detailed info to make one pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
765 keymap_panes (maps, nmaps, NILP (position)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
766 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
767 /* Make the title be the pane title of the first pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
768 if (!NILP (title) && menu_items_n_panes >= 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
769 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
770 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
771 keymaps = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
772 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
773 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
774 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
775 /* We were given an old-fashioned menu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
776 title = Fcar (menu); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
777 CHECK_STRING (title, 1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
778 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
779 list_of_panes (Fcdr (menu)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
780 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
781 keymaps = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
782 } |
13434 | 783 |
784 if (NILP (position)) | |
785 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
786 discard_menu_items (); |
13434 | 787 UNGCPRO; |
788 return Qnil; | |
789 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
790 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
791 #ifdef HAVE_MENUS |
13434 | 792 /* Display them in a menu. */ |
793 BLOCK_INPUT; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
794 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
795 selection = w32_menu_show (f, xpos, ypos, for_click, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
796 keymaps, title, &error_name); |
13434 | 797 UNBLOCK_INPUT; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
798 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
799 discard_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
800 |
13434 | 801 UNGCPRO; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
802 #endif /* HAVE_MENUS */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
803 |
13434 | 804 if (error_name) error (error_name); |
805 return selection; | |
806 } | |
807 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
808 #ifdef HAVE_MENUS |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
809 |
13434 | 810 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0, |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
811 "Pop up a dialog box and return user's selection.\n\ |
13434 | 812 POSITION specifies which frame to use.\n\ |
813 This is normally a mouse button event or a window or frame.\n\ | |
814 If POSITION is t, it means to use the frame the mouse is on.\n\ | |
815 The dialog box appears in the middle of the specified frame.\n\ | |
816 \n\ | |
817 CONTENTS specifies the alternatives to display in the dialog box.\n\ | |
818 It is a list of the form (TITLE ITEM1 ITEM2...).\n\ | |
819 Each ITEM is a cons cell (STRING . VALUE).\n\ | |
820 The return value is VALUE from the chosen item.\n\n\ | |
821 An ITEM may also be just a string--that makes a nonselectable item.\n\ | |
822 An ITEM may also be nil--that means to put all preceding items\n\ | |
823 on the left of the dialog box and all following items on the right.\n\ | |
824 \(By default, approximately half appear on each side.)") | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
825 (position, contents) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
826 Lisp_Object position, contents; |
13434 | 827 { |
828 FRAME_PTR f; | |
829 Lisp_Object window; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
830 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
831 check_w32 (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
832 |
13434 | 833 /* Decode the first argument: find the window or frame to use. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
834 if (EQ (position, Qt) |
32671
bbd3be4db5f2
(add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents:
31114
diff
changeset
|
835 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) |
bbd3be4db5f2
(add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents:
31114
diff
changeset
|
836 || EQ (XCAR (position), Qtool_bar)))) |
13434 | 837 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
838 #if 0 /* Using the frame the mouse is on may not be right. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
839 /* Use the mouse's current position. */ |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
840 FRAME_PTR new_f = SELECTED_FRAME (); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
841 Lisp_Object bar_window; |
31114
cd392fdf0e9f
Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents:
30989
diff
changeset
|
842 enum scroll_bar_part part; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
843 unsigned long time; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
844 Lisp_Object x, y; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
845 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
846 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
847 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
848 if (new_f != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
849 XSETFRAME (window, new_f); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
850 else |
13434 | 851 window = selected_window; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
852 #endif |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
853 window = selected_window; |
13434 | 854 } |
855 else if (CONSP (position)) | |
856 { | |
857 Lisp_Object tem; | |
858 tem = Fcar (position); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
859 if (CONSP (tem)) |
13434 | 860 window = Fcar (Fcdr (position)); |
861 else | |
862 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
863 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
864 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
13434 | 865 } |
866 } | |
867 else if (WINDOWP (position) || FRAMEP (position)) | |
868 window = position; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
869 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
870 window = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
871 |
13434 | 872 /* Decode where to put the menu. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
873 |
13434 | 874 if (FRAMEP (window)) |
875 f = XFRAME (window); | |
876 else if (WINDOWP (window)) | |
877 { | |
878 CHECK_LIVE_WINDOW (window, 0); | |
879 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); | |
880 } | |
881 else | |
882 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, | |
883 but I don't want to make one now. */ | |
884 CHECK_WINDOW (window, 0); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
885 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
886 #ifndef HAVE_DIALOGS |
13434 | 887 /* Display a menu with these alternatives |
888 in the middle of frame F. */ | |
889 { | |
890 Lisp_Object x, y, frame, newpos; | |
891 XSETFRAME (frame, f); | |
892 XSETINT (x, x_pixel_width (f) / 2); | |
893 XSETINT (y, x_pixel_height (f) / 2); | |
894 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil)); | |
895 | |
896 return Fx_popup_menu (newpos, | |
897 Fcons (Fcar (contents), Fcons (contents, Qnil))); | |
898 } | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
899 #else /* HAVE_DIALOGS */ |
13434 | 900 { |
901 Lisp_Object title; | |
902 char *error_name; | |
903 Lisp_Object selection; | |
904 | |
905 /* Decode the dialog items from what was specified. */ | |
906 title = Fcar (contents); | |
907 CHECK_STRING (title, 1); | |
908 | |
909 list_of_panes (Fcons (contents, Qnil)); | |
910 | |
911 /* Display them in a dialog box. */ | |
912 BLOCK_INPUT; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
913 selection = w32_dialog_show (f, 0, title, &error_name); |
13434 | 914 UNBLOCK_INPUT; |
915 | |
916 discard_menu_items (); | |
917 | |
918 if (error_name) error (error_name); | |
919 return selection; | |
920 } | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
921 #endif /* HAVE_DIALOGS */ |
13434 | 922 } |
923 | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
924 /* Activate the menu bar of frame F. |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
925 This is called from keyboard.c when it gets the |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
926 menu_bar_activate_event out of the Emacs event queue. |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
927 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
928 To activate the menu bar, we signal to the input thread that it can |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
929 return from the WM_INITMENU message, allowing the normal Windows |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
930 processing of the menus. |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
931 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
932 But first we recompute the menu bar contents (the whole tree). |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
933 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
934 This way we can safely execute Lisp code. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
935 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
936 void |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
937 x_activate_menubar (f) |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
938 FRAME_PTR f; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
939 { |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
940 set_frame_menubar (f, 0, 1); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
941 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
942 /* Lock out further menubar changes while active. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
943 f->output_data.w32->menubar_active = 1; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
944 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
945 /* Signal input thread to return from WM_INITMENU. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
946 complete_deferred_msg (FRAME_W32_WINDOW (f), WM_INITMENU, 0); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
947 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
948 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
949 /* This callback is called from the menu bar pulldown menu |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
950 when the user makes a selection. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
951 Figure out what the user chose |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
952 and put the appropriate events into the keyboard buffer. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
953 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
954 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
955 menubar_selection_callback (FRAME_PTR f, void * client_data) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
956 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
957 Lisp_Object prefix, entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
958 Lisp_Object vector; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
959 Lisp_Object *subprefix_stack; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
960 int submenu_depth = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
961 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
962 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
963 if (!f) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
964 return; |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
965 entry = Qnil; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
966 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
967 vector = f->menu_bar_vector; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
968 prefix = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
969 i = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
970 while (i < f->menu_bar_items_used) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
971 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
972 if (EQ (XVECTOR (vector)->contents[i], Qnil)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
973 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
974 subprefix_stack[submenu_depth++] = prefix; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
975 prefix = entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
976 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
977 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
978 else if (EQ (XVECTOR (vector)->contents[i], Qlambda)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
979 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
980 prefix = subprefix_stack[--submenu_depth]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
981 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
982 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
983 else if (EQ (XVECTOR (vector)->contents[i], Qt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
984 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
985 prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
986 i += MENU_ITEMS_PANE_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
987 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
988 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
989 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
990 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
991 /* The EMACS_INT cast avoids a warning. There's no problem |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
992 as long as pointers have enough bits to hold small integers. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
993 if ((int) (EMACS_INT) client_data == i) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
994 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
995 int j; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
996 struct input_event buf; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
997 Lisp_Object frame; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
998 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
999 XSETFRAME (frame, f); |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1000 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1001 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1002 buf.arg = frame; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1003 kbd_buffer_store_event (&buf); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1004 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1005 for (j = 0; j < submenu_depth; j++) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1006 if (!NILP (subprefix_stack[j])) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1007 { |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1008 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1009 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1010 buf.arg = subprefix_stack[j]; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1011 kbd_buffer_store_event (&buf); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1012 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1013 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1014 if (!NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1015 { |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1016 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1017 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1018 buf.arg = prefix; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1019 kbd_buffer_store_event (&buf); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1020 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1021 |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1022 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1023 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1024 buf.arg = entry; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1025 kbd_buffer_store_event (&buf); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1026 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1027 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1028 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1029 i += MENU_ITEMS_ITEM_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1030 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1031 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1032 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1033 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1034 /* Allocate a widget_value, blocking input. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1035 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1036 widget_value * |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1037 xmalloc_widget_value () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1038 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1039 widget_value *value; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1040 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1041 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1042 value = malloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1043 UNBLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1044 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1045 return value; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1046 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1047 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1048 /* This recursively calls free_widget_value on the tree of widgets. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1049 It must free all data that was malloc'ed for these widget_values. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1050 In Emacs, many slots are pointers into the data of Lisp_Strings, and |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1051 must be left alone. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1052 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1053 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1054 free_menubar_widget_value_tree (wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1055 widget_value *wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1056 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1057 if (! wv) return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1058 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1059 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1060 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1061 if (wv->contents && (wv->contents != (widget_value*)1)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1062 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1063 free_menubar_widget_value_tree (wv->contents); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1064 wv->contents = (widget_value *) 0xDEADBEEF; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1065 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1066 if (wv->next) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1067 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1068 free_menubar_widget_value_tree (wv->next); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1069 wv->next = (widget_value *) 0xDEADBEEF; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1070 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1071 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1072 free_widget_value (wv); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1073 UNBLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1074 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1075 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1076 /* Return a tree of widget_value structures for a menu bar item |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1077 whose event type is ITEM_KEY (with string ITEM_NAME) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1078 and whose contents come from the list of keymaps MAPS. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1079 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1080 static widget_value * |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1081 single_submenu (item_key, item_name, maps) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1082 Lisp_Object item_key, item_name, maps; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1083 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1084 widget_value *wv, *prev_wv, *save_wv, *first_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1085 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1086 int submenu_depth = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1087 Lisp_Object length; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1088 int len; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1089 Lisp_Object *mapvec; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1090 widget_value **submenu_stack; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1091 int previous_items = menu_items_used; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1092 int top_level_items = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1093 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1094 length = Flength (maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1095 len = XINT (length); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1096 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1097 /* Convert the list MAPS into a vector MAPVEC. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1098 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1099 for (i = 0; i < len; i++) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1100 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1101 mapvec[i] = Fcar (maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1102 maps = Fcdr (maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1103 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1104 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1105 menu_items_n_panes = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1106 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1107 /* Loop over the given keymaps, making a pane for each map. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1108 But don't make a pane that is empty--ignore that map instead. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1109 for (i = 0; i < len; i++) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1110 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1111 if (SYMBOLP (mapvec[i]) |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1112 || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i]))) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1113 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1114 /* Here we have a command at top level in the menu bar |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1115 as opposed to a submenu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1116 top_level_items = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1117 push_menu_pane (Qnil, Qnil); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1118 push_menu_item (item_name, Qt, item_key, mapvec[i], |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1119 Qnil, Qnil, Qnil, Qnil); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1120 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1121 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1122 single_keymap_panes (mapvec[i], item_name, item_key, 0, 10); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1123 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1124 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1125 /* Create a tree of widget_value objects |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1126 representing the panes and their items. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1127 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1128 submenu_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1129 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1130 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1131 wv->name = "menu"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1132 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1133 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1134 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1135 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1136 save_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1137 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1138 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1139 /* Loop over all panes and items made during this call |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1140 and construct a tree of widget_value objects. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1141 Ignore the panes and items made by previous calls to |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1142 single_submenu, even though those are also in menu_items. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1143 i = previous_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1144 while (i < menu_items_used) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1145 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1146 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1147 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1148 submenu_stack[submenu_depth++] = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1149 save_wv = prev_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1150 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1151 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1152 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1153 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1154 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1155 prev_wv = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1156 save_wv = submenu_stack[--submenu_depth]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1157 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1158 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1159 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1160 && submenu_depth != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1161 i += MENU_ITEMS_PANE_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1162 /* Ignore a nil in the item list. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1163 It's meaningful only for dialog boxes. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1164 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1165 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1166 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1167 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1168 /* Create a new pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1169 Lisp_Object pane_name, prefix; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1170 char *pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1171 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1172 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1173 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1174 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1175 pane_name = ENCODE_SYSTEM (pane_name); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1176 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1177 pane_string = (NILP (pane_name) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1178 ? "" : (char *) XSTRING (pane_name)->data); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1179 /* If there is just one top-level pane, put all its items directly |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1180 under the top-level menu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1181 if (menu_items_n_panes == 1) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1182 pane_string = ""; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1183 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1184 /* If the pane has a meaningful name, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1185 make the pane a top-level menu item |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1186 with its items as a submenu beneath it. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1187 if (strcmp (pane_string, "")) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1188 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1189 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1190 if (save_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1191 save_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1192 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1193 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1194 wv->name = pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1195 /* Ignore the @ that means "separate pane". |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1196 This is a kludge, but this isn't worth more time. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1197 if (!NILP (prefix) && wv->name[0] == '@') |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1198 wv->name++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1199 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1200 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1201 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1202 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1203 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1204 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1205 i += MENU_ITEMS_PANE_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1206 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1207 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1208 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1209 /* Create a new item within current pane. */ |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1210 Lisp_Object item_name, enable, descrip, def, type, selected; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1211 Lisp_Object help; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1212 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1213 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1214 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1215 descrip |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1216 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1217 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1218 type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE]; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1219 selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED]; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1220 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1221 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1222 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1223 if (STRING_MULTIBYTE (item_name)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1224 item_name = ENCODE_SYSTEM (item_name); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1225 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1226 descrip = ENCODE_SYSTEM (descrip); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1227 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1228 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1229 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1230 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1231 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1232 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1233 save_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1234 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1235 wv->name = (char *) XSTRING (item_name)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1236 if (!NILP (descrip)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1237 wv->key = (char *) XSTRING (descrip)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1238 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1239 /* The EMACS_INT cast avoids a warning. There's no problem |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1240 as long as pointers have enough bits to hold small integers. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1241 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1242 wv->enabled = !NILP (enable); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1243 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1244 if (NILP (type)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1245 wv->button_type = BUTTON_TYPE_NONE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1246 else if (EQ (type, QCradio)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1247 wv->button_type = BUTTON_TYPE_RADIO; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1248 else if (EQ (type, QCtoggle)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1249 wv->button_type = BUTTON_TYPE_TOGGLE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1250 else |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1251 abort (); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1252 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1253 wv->selected = !NILP (selected); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1254 if (STRINGP (help)) |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1255 wv->help = (char *) XSTRING (help)->data; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1256 else |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1257 wv->help = NULL; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1258 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1259 prev_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1260 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1261 i += MENU_ITEMS_ITEM_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1262 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1263 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1264 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1265 /* If we have just one "menu item" |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1266 that was originally a button, return it by itself. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1267 if (top_level_items && first_wv->contents && first_wv->contents->next == 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1268 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1269 wv = first_wv->contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1270 free_widget_value (first_wv); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1271 return wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1272 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1273 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1274 return first_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1275 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1276 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1277 /* Set the contents of the menubar widgets of frame F. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1278 The argument FIRST_TIME is currently ignored; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1279 it is set the first time this is called, from initialize_frame_menubar. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1280 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1281 void |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1282 set_frame_menubar (f, first_time, deep_p) |
13434 | 1283 FRAME_PTR f; |
1284 int first_time; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1285 int deep_p; |
13434 | 1286 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1287 HMENU menubar_widget = f->output_data.w32->menubar_widget; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1288 Lisp_Object items; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1289 widget_value *wv, *first_wv, *prev_wv = 0; |
13434 | 1290 int i; |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
1291 |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1292 /* We must not change the menubar when actually in use. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1293 if (f->output_data.w32->menubar_active) |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1294 return; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1295 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1296 XSETFRAME (Vmenu_updating_frame, f); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1297 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1298 if (! menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1299 deep_p = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1300 else if (pending_menu_activation && !deep_p) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1301 deep_p = 1; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1302 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1303 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1304 wv->name = "menubar"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1305 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1306 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1307 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1308 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1309 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1310 if (deep_p) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1311 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1312 /* Make a widget-value tree representing the entire menu trees. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1313 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1314 struct buffer *prev = current_buffer; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1315 Lisp_Object buffer; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1316 int specpdl_count = specpdl_ptr - specpdl; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1317 int previous_menu_items_used = f->menu_bar_items_used; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1318 Lisp_Object *previous_items |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1319 = (Lisp_Object *) alloca (previous_menu_items_used |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1320 * sizeof (Lisp_Object)); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1321 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1322 /* If we are making a new widget, its contents are empty, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1323 do always reinitialize them. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1324 if (! menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1325 previous_menu_items_used = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1326 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1327 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1328 specbind (Qinhibit_quit, Qt); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1329 /* Don't let the debugger step into this code |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1330 because it is not reentrant. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1331 specbind (Qdebug_on_next_call, Qnil); |
15276 | 1332 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1333 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1334 if (NILP (Voverriding_local_map_menu_flag)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1335 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1336 specbind (Qoverriding_terminal_local_map, Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1337 specbind (Qoverriding_local_map, Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1338 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1339 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1340 set_buffer_internal_1 (XBUFFER (buffer)); |
15276 | 1341 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1342 /* Run the Lucid hook. */ |
36313
77093a87f2de
* w32menu.c (set_frame_menubar): Run activate-menu-bar-hook with
Jason Rumney <jasonr@gnu.org>
parents:
33971
diff
changeset
|
1343 safe_run_hooks (Qactivate_menubar_hook); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1344 /* If it has changed current-menubar from previous value, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1345 really recompute the menubar from the value. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1346 if (! NILP (Vlucid_menu_bar_dirty_flag)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1347 call0 (Qrecompute_lucid_menubar); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1348 safe_run_hooks (Qmenu_bar_update_hook); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1349 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1350 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1351 items = FRAME_MENU_BAR_ITEMS (f); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1352 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1353 inhibit_garbage_collection (); |
15276 | 1354 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1355 /* Save the frame's previous menu bar contents data. */ |
39507
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1356 if (previous_menu_items_used) |
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1357 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, |
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1358 previous_menu_items_used * sizeof (Lisp_Object)); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1359 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1360 /* Fill in the current menu bar contents. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1361 menu_items = f->menu_bar_vector; |
39507
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1362 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1363 init_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1364 for (i = 0; i < XVECTOR (items)->size; i += 4) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1365 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1366 Lisp_Object key, string, maps; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1367 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1368 key = XVECTOR (items)->contents[i]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1369 string = XVECTOR (items)->contents[i + 1]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1370 maps = XVECTOR (items)->contents[i + 2]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1371 if (NILP (string)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1372 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1373 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1374 wv = single_submenu (key, string, maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1375 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1376 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1377 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1378 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1379 /* Don't set wv->name here; GC during the loop might relocate it. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1380 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1381 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1382 prev_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1383 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1384 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1385 finish_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1386 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1387 set_buffer_internal_1 (prev); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1388 unbind_to (specpdl_count, Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1389 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1390 /* If there has been no change in the Lisp-level contents |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1391 of the menu bar, skip redisplaying it. Just exit. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1392 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1393 for (i = 0; i < previous_menu_items_used; i++) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1394 if (menu_items_used == i |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1395 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i]))) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1396 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1397 if (i == menu_items_used && i == previous_menu_items_used && i != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1398 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1399 free_menubar_widget_value_tree (first_wv); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1400 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1401 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1402 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1403 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1404 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1405 /* Now GC cannot happen during the lifetime of the widget_value, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1406 so it's safe to store data from a Lisp_String. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1407 wv = first_wv->contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1408 for (i = 0; i < XVECTOR (items)->size; i += 4) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1409 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1410 Lisp_Object string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1411 string = XVECTOR (items)->contents[i + 1]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1412 if (NILP (string)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1413 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1414 wv->name = (char *) XSTRING (string)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1415 wv = wv->next; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1416 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1417 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1418 f->menu_bar_vector = menu_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1419 f->menu_bar_items_used = menu_items_used; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1420 menu_items = Qnil; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1421 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1422 else |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1423 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1424 /* Make a widget-value tree containing |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1425 just the top level menu bar strings. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1426 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1427 items = FRAME_MENU_BAR_ITEMS (f); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1428 for (i = 0; i < XVECTOR (items)->size; i += 4) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1429 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1430 Lisp_Object string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1431 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1432 string = XVECTOR (items)->contents[i + 1]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1433 if (NILP (string)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1434 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1435 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1436 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1437 wv->name = (char *) XSTRING (string)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1438 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1439 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1440 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1441 /* This prevents lwlib from assuming this |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1442 menu item is really supposed to be empty. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1443 /* The EMACS_INT cast avoids a warning. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1444 This value just has to be different from small integers. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1445 wv->call_data = (void *) (EMACS_INT) (-1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1446 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1447 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1448 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1449 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1450 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1451 prev_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1452 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1453 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1454 /* Forget what we thought we knew about what is in the |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1455 detailed contents of the menu bar menus. |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1456 Changing the top level always destroys the contents. */ |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1457 f->menu_bar_items_used = 0; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1458 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1459 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1460 /* Create or update the menu bar widget. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1461 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1462 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1463 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1464 if (menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1465 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1466 /* Empty current menubar, rather than creating a fresh one. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1467 while (DeleteMenu (menubar_widget, 0, MF_BYPOSITION)) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1468 ; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1469 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1470 else |
13434 | 1471 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1472 menubar_widget = CreateMenu (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1473 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1474 fill_in_menu (menubar_widget, first_wv->contents); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1475 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1476 free_menubar_widget_value_tree (first_wv); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1477 |
13434 | 1478 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1479 HMENU old_widget = f->output_data.w32->menubar_widget; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1480 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1481 f->output_data.w32->menubar_widget = menubar_widget; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1482 SetMenu (FRAME_W32_WINDOW (f), f->output_data.w32->menubar_widget); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1483 /* Causes flicker when menu bar is updated |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1484 DrawMenuBar (FRAME_W32_WINDOW (f)); */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1485 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1486 /* Force the window size to be recomputed so that the frame's text |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1487 area remains the same, if menubar has just been created. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1488 if (old_widget == NULL) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1489 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
13434 | 1490 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1491 |
13434 | 1492 UNBLOCK_INPUT; |
1493 } | |
1494 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1495 /* Called from Fx_create_frame to create the initial menubar of a frame |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1496 before it is mapped, so that the window is mapped with the menubar already |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1497 there instead of us tacking it on later and thrashing the window after it |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1498 is visible. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1499 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1500 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1501 initialize_frame_menubar (f) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1502 FRAME_PTR f; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1503 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1504 /* This function is called before the first chance to redisplay |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1505 the frame. It has to be, so the frame will have the right size. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1506 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1507 set_frame_menubar (f, 1, 1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1508 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1509 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1510 /* Get rid of the menu bar of frame F, and free its storage. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1511 This is used when deleting a frame, and when turning off the menu bar. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1512 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1513 void |
13434 | 1514 free_frame_menubar (f) |
1515 FRAME_PTR f; | |
1516 { | |
1517 BLOCK_INPUT; | |
1518 | |
1519 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1520 HMENU old = GetMenu (FRAME_W32_WINDOW (f)); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1521 SetMenu (FRAME_W32_WINDOW (f), NULL); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1522 f->output_data.w32->menubar_widget = NULL; |
13434 | 1523 DestroyMenu (old); |
1524 } | |
1525 | |
1526 UNBLOCK_INPUT; | |
1527 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1528 |
13434 | 1529 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1530 /* w32_menu_show actually displays a menu using the panes and items in |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1531 menu_items and returns the value selected from it; we assume input |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1532 is blocked by the caller. */ |
13434 | 1533 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1534 /* F is the frame the menu is for. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1535 X and Y are the frame-relative specified position, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1536 relative to the inside upper left corner of the frame F. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1537 FOR_CLICK is nonzero if this menu was invoked for a mouse click. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1538 KEYMAPS is 1 if this menu was specified with keymaps; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1539 in that case, we return a list containing the chosen item's value |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1540 and perhaps also the pane's prefix. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1541 TITLE is the specified menu title. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1542 ERROR is a place to store an error message string in case of failure. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1543 (We return nil on failure, but the value doesn't actually matter.) */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1544 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1545 static Lisp_Object |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1546 w32_menu_show (f, x, y, for_click, keymaps, title, error) |
13434 | 1547 FRAME_PTR f; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1548 int x; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1549 int y; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1550 int for_click; |
13434 | 1551 int keymaps; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1552 Lisp_Object title; |
13434 | 1553 char **error; |
1554 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1555 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1556 int menu_item_selection; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1557 HMENU menu; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1558 POINT pos; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1559 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1560 widget_value **submenu_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1561 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1562 Lisp_Object *subprefix_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1563 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); |
13434 | 1564 int submenu_depth = 0; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1565 int first_pane; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1566 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1567 *error = NULL; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1568 |
13434 | 1569 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
1570 { | |
1571 *error = "Empty menu"; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1572 return Qnil; |
13434 | 1573 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1574 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1575 /* Create a tree of widget_value objects |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1576 representing the panes and their items. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1577 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1578 wv->name = "menu"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1579 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1580 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1581 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1582 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1583 first_pane = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1584 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1585 /* Loop over all panes and items, filling in the tree. */ |
13434 | 1586 i = 0; |
1587 while (i < menu_items_used) | |
1588 { | |
1589 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) | |
1590 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1591 submenu_stack[submenu_depth++] = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1592 save_wv = prev_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1593 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1594 first_pane = 1; |
13434 | 1595 i++; |
1596 } | |
1597 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) | |
1598 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1599 prev_wv = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1600 save_wv = submenu_stack[--submenu_depth]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1601 first_pane = 0; |
13434 | 1602 i++; |
1603 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1604 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1605 && submenu_depth != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1606 i += MENU_ITEMS_PANE_LENGTH; |
13434 | 1607 /* Ignore a nil in the item list. |
1608 It's meaningful only for dialog boxes. */ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1609 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1610 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1611 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1612 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1613 /* Create a new pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1614 Lisp_Object pane_name, prefix; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1615 char *pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1616 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1617 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1618 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1619 if (!NILP (pane_name) && STRING_MULTIBYTE (pane_name)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1620 pane_name = ENCODE_SYSTEM (pane_name); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1621 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1622 pane_string = (NILP (pane_name) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1623 ? "" : (char *) XSTRING (pane_name)->data); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1624 /* If there is just one top-level pane, put all its items directly |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1625 under the top-level menu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1626 if (menu_items_n_panes == 1) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1627 pane_string = ""; |
13434 | 1628 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1629 /* If the pane has a meaningful name, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1630 make the pane a top-level menu item |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1631 with its items as a submenu beneath it. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1632 if (!keymaps && strcmp (pane_string, "")) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1633 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1634 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1635 if (save_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1636 save_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1637 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1638 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1639 wv->name = pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1640 if (keymaps && !NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1641 wv->name++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1642 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1643 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1644 wv->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1645 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1646 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1647 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1648 else if (first_pane) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1649 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1650 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1651 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1652 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1653 first_pane = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1654 i += MENU_ITEMS_PANE_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1655 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1656 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1657 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1658 /* Create a new item within current pane. */ |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1659 Lisp_Object item_name, enable, descrip, def, type, selected, help; |
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1660 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1661 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1662 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1663 descrip |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1664 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1665 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1666 type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE]; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1667 selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED]; |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1668 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1669 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1670 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1671 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1672 item_name = ENCODE_SYSTEM (item_name); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1673 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1674 descrip = ENCODE_SYSTEM (descrip); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1675 #endif |
13434 | 1676 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1677 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1678 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1679 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1680 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1681 save_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1682 wv->name = (char *) XSTRING (item_name)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1683 if (!NILP (descrip)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1684 wv->key = (char *) XSTRING (descrip)->data; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1685 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1686 /* Use the contents index as call_data, since we are |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1687 restricted to 16-bits.. */ |
22737
41e01b5de7cc
(w32_menu_show): Set widget call_data to 0 if definition is nil.
Andrew Innes <andrewi@gnu.org>
parents:
21741
diff
changeset
|
1688 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1689 wv->enabled = !NILP (enable); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1690 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1691 if (NILP (type)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1692 wv->button_type = BUTTON_TYPE_NONE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1693 else if (EQ (type, QCtoggle)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1694 wv->button_type = BUTTON_TYPE_TOGGLE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1695 else if (EQ (type, QCradio)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1696 wv->button_type = BUTTON_TYPE_RADIO; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1697 else |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1698 abort (); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1699 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1700 wv->selected = !NILP (selected); |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1701 |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1702 if (STRINGP (help)) |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1703 wv->help = (char *) XSTRING (help)->data; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1704 else |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1705 wv->help = NULL; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1706 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1707 prev_wv = wv; |
13434 | 1708 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1709 i += MENU_ITEMS_ITEM_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1710 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1711 } |
13434 | 1712 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1713 /* Deal with the title, if it is non-nil. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1714 if (!NILP (title)) |
13434 | 1715 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1716 widget_value *wv_title = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1717 widget_value *wv_sep = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1718 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1719 /* Maybe replace this separator with a bitmap or owner-draw item |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1720 so that it looks better. Having two separators looks odd. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1721 wv_sep->name = "--"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1722 wv_sep->next = first_wv->contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1723 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1724 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1725 if (STRING_MULTIBYTE (title)) |
29320
33aa00975055
(single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents:
28275
diff
changeset
|
1726 title = ENCODE_SYSTEM (title); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1727 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1728 wv_title->name = (char *) XSTRING (title)->data; |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1729 wv_title->enabled = TRUE; |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1730 wv_title->title = TRUE; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1731 wv_title->button_type = BUTTON_TYPE_NONE; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1732 wv_title->next = wv_sep; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1733 first_wv->contents = wv_title; |
13434 | 1734 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1735 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1736 /* Actually create the menu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1737 menu = CreatePopupMenu (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1738 fill_in_menu (menu, first_wv->contents); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1739 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1740 /* Adjust coordinates to be root-window-relative. */ |
13434 | 1741 pos.x = x; |
1742 pos.y = y; | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1743 ClientToScreen (FRAME_W32_WINDOW (f), &pos); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1744 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1745 /* No selection has been chosen yet. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1746 menu_item_selection = 0; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1747 |
13434 | 1748 /* Display the menu. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1749 menu_item_selection = SendMessage (FRAME_W32_WINDOW (f), |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1750 WM_EMACS_TRACKPOPUPMENU, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1751 (WPARAM)menu, (LPARAM)&pos); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1752 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1753 /* Clean up extraneous mouse events which might have been generated |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1754 during the call. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1755 discard_mouse_events (); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1756 |
30238
4a3b87cc6f04
(w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents:
30178
diff
changeset
|
1757 /* Free the widget_value objects we used to specify the contents. */ |
4a3b87cc6f04
(w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents:
30178
diff
changeset
|
1758 free_menubar_widget_value_tree (first_wv); |
4a3b87cc6f04
(w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents:
30178
diff
changeset
|
1759 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1760 DestroyMenu (menu); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1761 |
13434 | 1762 /* Find the selected item, and its pane, to return |
1763 the proper value. */ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1764 if (menu_item_selection != 0) |
13434 | 1765 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1766 Lisp_Object prefix, entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1767 |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
1768 prefix = entry = Qnil; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1769 i = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1770 while (i < menu_items_used) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1771 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1772 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1773 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1774 subprefix_stack[submenu_depth++] = prefix; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1775 prefix = entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1776 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1777 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1778 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1779 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1780 prefix = subprefix_stack[--submenu_depth]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1781 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1782 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1783 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1784 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1785 prefix |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1786 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1787 i += MENU_ITEMS_PANE_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1788 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1789 /* Ignore a nil in the item list. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1790 It's meaningful only for dialog boxes. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1791 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1792 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1793 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1794 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1795 entry |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1796 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1797 if (menu_item_selection == i) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1798 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1799 if (keymaps != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1800 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1801 int j; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1802 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1803 entry = Fcons (entry, Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1804 if (!NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1805 entry = Fcons (prefix, entry); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1806 for (j = submenu_depth - 1; j >= 0; j--) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1807 if (!NILP (subprefix_stack[j])) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1808 entry = Fcons (subprefix_stack[j], entry); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1809 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1810 return entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1811 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1812 i += MENU_ITEMS_ITEM_LENGTH; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1813 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1814 } |
13434 | 1815 } |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1816 |
13434 | 1817 return Qnil; |
1818 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1819 |
13434 | 1820 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1821 static char * button_names [] = { |
13434 | 1822 "button1", "button2", "button3", "button4", "button5", |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1823 "button6", "button7", "button8", "button9", "button10" }; |
13434 | 1824 |
1825 static Lisp_Object | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1826 w32_dialog_show (f, keymaps, title, error) |
13434 | 1827 FRAME_PTR f; |
1828 int keymaps; | |
1829 Lisp_Object title; | |
1830 char **error; | |
1831 { | |
1832 int i, nb_buttons=0; | |
1833 char dialog_name[6]; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1834 int menu_item_selection; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1835 |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
1836 widget_value *wv, *first_wv = 0, *prev_wv = 0; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1837 |
13434 | 1838 /* Number of elements seen so far, before boundary. */ |
1839 int left_count = 0; | |
1840 /* 1 means we've seen the boundary between left-hand elts and right-hand. */ | |
1841 int boundary_seen = 0; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1842 |
13434 | 1843 *error = NULL; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1844 |
13434 | 1845 if (menu_items_n_panes > 1) |
1846 { | |
1847 *error = "Multiple panes in dialog box"; | |
1848 return Qnil; | |
1849 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1850 |
13434 | 1851 /* Create a tree of widget_value objects |
1852 representing the text label and buttons. */ | |
1853 { | |
1854 Lisp_Object pane_name, prefix; | |
1855 char *pane_string; | |
1856 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; | |
1857 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; | |
1858 pane_string = (NILP (pane_name) | |
1859 ? "" : (char *) XSTRING (pane_name)->data); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1860 prev_wv = xmalloc_widget_value (); |
13434 | 1861 prev_wv->value = pane_string; |
1862 if (keymaps && !NILP (prefix)) | |
1863 prev_wv->name++; | |
1864 prev_wv->enabled = 1; | |
1865 prev_wv->name = "message"; | |
1866 first_wv = prev_wv; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1867 |
13434 | 1868 /* Loop over all panes and items, filling in the tree. */ |
1869 i = MENU_ITEMS_PANE_LENGTH; | |
1870 while (i < menu_items_used) | |
1871 { | |
1872 | |
1873 /* Create a new item within current pane. */ | |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1874 Lisp_Object item_name, enable, descrip, help; |
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1875 |
13434 | 1876 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
1877 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; | |
1878 descrip | |
1879 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; | |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1880 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
13434 | 1881 |
1882 if (NILP (item_name)) | |
1883 { | |
1884 free_menubar_widget_value_tree (first_wv); | |
1885 *error = "Submenu in dialog items"; | |
1886 return Qnil; | |
1887 } | |
1888 if (EQ (item_name, Qquote)) | |
1889 { | |
1890 /* This is the boundary between left-side elts | |
1891 and right-side elts. Stop incrementing right_count. */ | |
1892 boundary_seen = 1; | |
1893 i++; | |
1894 continue; | |
1895 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1896 if (nb_buttons >= 9) |
13434 | 1897 { |
1898 free_menubar_widget_value_tree (first_wv); | |
1899 *error = "Too many dialog items"; | |
1900 return Qnil; | |
1901 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1902 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1903 wv = xmalloc_widget_value (); |
13434 | 1904 prev_wv->next = wv; |
1905 wv->name = (char *) button_names[nb_buttons]; | |
1906 if (!NILP (descrip)) | |
1907 wv->key = (char *) XSTRING (descrip)->data; | |
1908 wv->value = (char *) XSTRING (item_name)->data; | |
1909 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i]; | |
1910 wv->enabled = !NILP (enable); | |
1911 prev_wv = wv; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1912 |
13434 | 1913 if (! boundary_seen) |
1914 left_count++; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1915 |
13434 | 1916 nb_buttons++; |
1917 i += MENU_ITEMS_ITEM_LENGTH; | |
1918 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1919 |
13434 | 1920 /* If the boundary was not specified, |
1921 by default put half on the left and half on the right. */ | |
1922 if (! boundary_seen) | |
1923 left_count = nb_buttons - nb_buttons / 2; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1924 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1925 wv = xmalloc_widget_value (); |
13434 | 1926 wv->name = dialog_name; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1927 |
13434 | 1928 /* Dialog boxes use a really stupid name encoding |
1929 which specifies how many buttons to use | |
1930 and how many buttons are on the right. | |
1931 The Q means something also. */ | |
1932 dialog_name[0] = 'Q'; | |
1933 dialog_name[1] = '0' + nb_buttons; | |
1934 dialog_name[2] = 'B'; | |
1935 dialog_name[3] = 'R'; | |
1936 /* Number of buttons to put on the right. */ | |
1937 dialog_name[4] = '0' + nb_buttons - left_count; | |
1938 dialog_name[5] = 0; | |
1939 wv->contents = first_wv; | |
1940 first_wv = wv; | |
1941 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1942 |
13434 | 1943 /* Actually create the dialog. */ |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1944 #ifdef HAVE_DIALOGS |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1945 dialog_id = widget_id_tick++; |
13434 | 1946 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1947 f->output_data.w32->widget, 1, 0, |
13434 | 1948 dialog_selection_callback, 0); |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1949 lw_modify_all_widgets (dialog_id, first_wv->contents, TRUE); |
13434 | 1950 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1951 |
13434 | 1952 /* Free the widget_value objects we used to specify the contents. */ |
1953 free_menubar_widget_value_tree (first_wv); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1954 |
13434 | 1955 /* No selection has been chosen yet. */ |
1956 menu_item_selection = 0; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1957 |
13434 | 1958 /* Display the menu. */ |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1959 #ifdef HAVE_DIALOGS |
13434 | 1960 lw_pop_up_all_widgets (dialog_id); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1961 popup_activated_flag = 1; |
13434 | 1962 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1963 /* Process events that apply to the menu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1964 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id); |
13434 | 1965 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1966 lw_destroy_all_widgets (dialog_id); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1967 #endif |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1968 |
13434 | 1969 /* Find the selected item, and its pane, to return |
1970 the proper value. */ | |
1971 if (menu_item_selection != 0) | |
1972 { | |
1973 Lisp_Object prefix; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1974 |
13434 | 1975 prefix = Qnil; |
1976 i = 0; | |
1977 while (i < menu_items_used) | |
1978 { | |
1979 Lisp_Object entry; | |
1980 | |
1981 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) | |
1982 { | |
1983 prefix | |
1984 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; | |
1985 i += MENU_ITEMS_PANE_LENGTH; | |
1986 } | |
1987 else | |
1988 { | |
1989 entry | |
1990 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1991 if (menu_item_selection == i) |
13434 | 1992 { |
1993 if (keymaps != 0) | |
1994 { | |
1995 entry = Fcons (entry, Qnil); | |
1996 if (!NILP (prefix)) | |
1997 entry = Fcons (prefix, entry); | |
1998 } | |
1999 return entry; | |
2000 } | |
2001 i += MENU_ITEMS_ITEM_LENGTH; | |
2002 } | |
2003 } | |
2004 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2005 |
13434 | 2006 return Qnil; |
2007 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2008 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2009 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2010 /* Is this item a separator? */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2011 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2012 name_is_separator (name) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2013 char *name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2014 { |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2015 char *start = name; |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2016 |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2017 /* Check if name string consists of only dashes ('-'). */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2018 while (*name == '-') name++; |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2019 /* Separators can also be of the form "--:TripleSuperMegaEtched" |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2020 or "--deep-shadow". We don't implement them yet, se we just treat |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2021 them like normal separators. */ |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2022 return (*name == '\0' || start + 2 == name); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2023 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2024 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2025 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2026 /* Indicate boundary between left and right. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2027 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2028 add_left_right_boundary (HMENU menu) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2029 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2030 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2031 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2032 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2033 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2034 add_menu_item (HMENU menu, widget_value *wv, HMENU item) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2035 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2036 UINT fuFlags; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2037 char *out_string; |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2038 int return_value; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2039 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2040 if (name_is_separator (wv->name)) |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2041 { |
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2042 fuFlags = MF_SEPARATOR; |
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2043 out_string = NULL; |
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2044 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2045 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2046 { |
22750
b38cb406ed80
(add_menu_item): Draw menu items like titles if call_data is 0.
Andrew Innes <andrewi@gnu.org>
parents:
22737
diff
changeset
|
2047 if (wv->enabled) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2048 fuFlags = MF_STRING; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2049 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2050 fuFlags = MF_STRING | MF_GRAYED; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2051 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2052 if (wv->key != NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2053 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2054 out_string = alloca (strlen (wv->name) + strlen (wv->key) + 2); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2055 strcpy (out_string, wv->name); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2056 strcat (out_string, "\t"); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2057 strcat (out_string, wv->key); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2058 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2059 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2060 out_string = wv->name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2061 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2062 if (wv->title || wv->call_data == 0) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2063 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2064 #if 0 /* no GC while popup menu is active */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2065 out_string = LocalAlloc (0, strlen (wv->name) + 1); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2066 strcpy (out_string, wv->name); |
13434 | 2067 #endif |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2068 fuFlags = MF_OWNERDRAW | MF_DISABLED; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2069 } |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2070 /* Draw radio buttons and tickboxes. */ |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2071 else if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2072 wv->button_type == BUTTON_TYPE_RADIO)) |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2073 fuFlags |= MF_CHECKED; |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2074 else |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2075 fuFlags |= MF_UNCHECKED; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2076 } |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2077 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2078 if (item != NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2079 fuFlags = MF_POPUP; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2080 |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2081 return_value = |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2082 AppendMenu (menu, |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2083 fuFlags, |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2084 item != NULL ? (UINT) item : (UINT) wv->call_data, |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2085 out_string ); |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2086 |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2087 /* This must be done after the menu item is created. */ |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2088 if ((fuFlags & MF_STRING) != 0) |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2089 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2090 HMODULE user32 = GetModuleHandle ("user32.dll"); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2091 FARPROC set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA"); |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2092 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2093 if (set_menu_item_info) |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2094 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2095 MENUITEMINFO info; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2096 bzero (&info, sizeof (info)); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2097 info.cbSize = sizeof (info); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2098 info.fMask = MIIM_DATA; |
32671
bbd3be4db5f2
(add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents:
31114
diff
changeset
|
2099 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2100 /* Set help string for menu item. */ |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2101 info.dwItemData = (DWORD)wv->help; |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2102 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2103 if (wv->button_type == BUTTON_TYPE_RADIO) |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2104 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2105 /* CheckMenuRadioItem allows us to differentiate TOGGLE and |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2106 RADIO items, but is not available on NT 3.51 and earlier. */ |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2107 info.fMask |= MIIM_TYPE | MIIM_STATE; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2108 info.fType = MFT_RADIOCHECK | MFT_STRING; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2109 info.dwTypeData = out_string; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2110 info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2111 } |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2112 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2113 set_menu_item_info (menu, |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2114 item != NULL ? (UINT) item : (UINT) wv->call_data, |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2115 FALSE, &info); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2116 } |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2117 } |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2118 return return_value; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2119 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2120 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2121 /* Construct native Windows menu(bar) based on widget_value tree. */ |
31114
cd392fdf0e9f
Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents:
30989
diff
changeset
|
2122 int |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2123 fill_in_menu (HMENU menu, widget_value *wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2124 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2125 int items_added = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2126 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2127 for ( ; wv != NULL; wv = wv->next) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2128 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2129 if (wv->contents) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2130 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2131 HMENU sub_menu = CreatePopupMenu (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2132 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2133 if (sub_menu == NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2134 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2135 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2136 if (!fill_in_menu (sub_menu, wv->contents) || |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2137 !add_menu_item (menu, wv, sub_menu)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2138 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2139 DestroyMenu (sub_menu); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2140 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2141 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2142 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2143 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2144 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2145 if (!add_menu_item (menu, wv, NULL)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2146 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2147 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2148 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2149 return 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2150 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2151 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2152 int |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2153 popup_activated () |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2154 { |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2155 /* popup_activated_flag not actually used on W32 */ |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2156 return 0; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2157 } |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2158 |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2159 /* Display help string for currently pointed to menu item. Not |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2160 supported on NT 3.51 and earlier, as GetMenuItemInfo is not |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2161 available. */ |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2162 void |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2163 w32_menu_display_help (HMENU menu, UINT item, UINT flags) |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2164 { |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2165 int pane = 0; /* TODO: Set this to pane number. */ |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2166 |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2167 HMODULE user32 = GetModuleHandle ("user32.dll"); |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2168 FARPROC get_menu_item_info = GetProcAddress (user32, "GetMenuItemInfoA"); |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2169 |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2170 if (get_menu_item_info) |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2171 { |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2172 extern Lisp_Object Qmenu_item; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2173 Lisp_Object *first_item; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2174 Lisp_Object pane_name; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2175 Lisp_Object menu_object; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2176 MENUITEMINFO info; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2177 |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2178 bzero (&info, sizeof (info)); |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2179 info.cbSize = sizeof (info); |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2180 info.fMask = MIIM_DATA; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2181 get_menu_item_info (menu, item, FALSE, &info); |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2182 |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2183 first_item = XVECTOR (menu_items)->contents; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2184 if (EQ (first_item[0], Qt)) |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2185 pane_name = first_item[MENU_ITEMS_PANE_NAME]; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2186 else if (EQ (first_item[0], Qquote)) |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2187 /* This shouldn't happen, see w32_menu_show. */ |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2188 pane_name = build_string (""); |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2189 else |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2190 pane_name = first_item[MENU_ITEMS_ITEM_NAME]; |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2191 |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2192 /* (menu-item MENU-NAME PANE-NUMBER) */ |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2193 menu_object = Fcons (Qmenu_item, |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2194 Fcons (pane_name, |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2195 Fcons (make_number (pane), Qnil))); |
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2196 |
30053
baccf5e9ab70
* w32menu.c (w32_menu_display_help):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29320
diff
changeset
|
2197 show_help_echo (info.dwItemData ? |
30238
4a3b87cc6f04
(w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents:
30178
diff
changeset
|
2198 build_string ((char *) info.dwItemData) : Qnil, |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2199 Qnil, menu_object, make_number (item), 1); |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2200 } |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2201 } |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2202 |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2203 |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2204 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2205 #endif /* HAVE_MENUS */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2206 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
2207 syms_of_w32menu () |
13434 | 2208 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2209 staticpro (&menu_items); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2210 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2211 |
15276 | 2212 Qdebug_on_next_call = intern ("debug-on-next-call"); |
2213 staticpro (&Qdebug_on_next_call); | |
2214 | |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2215 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame, |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2216 "Frame for which we are updating a menu.\n\ |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2217 The enable predicate for a menu command should check this variable."); |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2218 Vmenu_updating_frame = Qnil; |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2219 |
13434 | 2220 defsubr (&Sx_popup_menu); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2221 #ifdef HAVE_MENUS |
13434 | 2222 defsubr (&Sx_popup_dialog); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2223 #endif |
13434 | 2224 } |