Mercurial > emacs
annotate src/w32menu.c @ 41790:27f9d9949ca2
Fix typo in doc-string.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Sun, 02 Dec 2001 17:21:41 +0000 |
parents | 917737801660 |
children | 4d8905b9ee49 |
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 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
122 static HMENU current_popup_menu; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
123 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
124 FARPROC get_menu_item_info; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
125 FARPROC set_menu_item_info; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
126 |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
127 Lisp_Object Vmenu_updating_frame; |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
128 |
15276 | 129 Lisp_Object Qdebug_on_next_call; |
130 | |
13434 | 131 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
|
132 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
|
133 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
134 extern Lisp_Object QCtoggle, QCradio; |
13434 | 135 |
15276 | 136 extern Lisp_Object Voverriding_local_map; |
137 extern Lisp_Object Voverriding_local_map_menu_flag; | |
138 | |
139 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; | |
140 | |
141 extern Lisp_Object Qmenu_bar_update_hook; | |
142 | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
143 void set_frame_menubar (); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
144 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
145 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
|
146 Lisp_Object, Lisp_Object, Lisp_Object, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
147 Lisp_Object, Lisp_Object)); |
41637
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
148 #ifdef HAVE_DIALOGS |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
149 static Lisp_Object w32_dialog_show (); |
41637
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
150 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
151 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
|
152 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
153 static void keymap_panes (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 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
|
158 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
159 /* 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
|
160 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
|
161 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
162 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
|
163 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
175 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
|
176 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
|
177 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
178 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
|
179 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
|
180 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
181 #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
|
182 #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
|
183 #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
|
184 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
185 enum menu_item_idx |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
186 { |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
187 MENU_ITEMS_ITEM_NAME = 0, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
188 MENU_ITEMS_ITEM_ENABLE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
189 MENU_ITEMS_ITEM_VALUE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
190 MENU_ITEMS_ITEM_EQUIV_KEY, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
191 MENU_ITEMS_ITEM_DEFINITION, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
192 MENU_ITEMS_ITEM_TYPE, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
193 MENU_ITEMS_ITEM_SELECTED, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
194 MENU_ITEMS_ITEM_HELP, |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
195 MENU_ITEMS_ITEM_LENGTH |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
196 }; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
197 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
198 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
|
199 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
200 /* 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
|
201 static int menu_items_allocated; |
13434 | 202 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
203 /* 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
|
204 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
|
205 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
206 /* 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
|
207 excluding those within submenus. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
208 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
|
209 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
210 /* Current depth within submenus. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
211 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
|
212 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
213 /* 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
|
214 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
|
215 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
|
216 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
217 static int next_menubar_widget_id; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
218 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
219 /* 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
|
220 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
|
221 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
|
222 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
223 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
|
224 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
|
225 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
226 int pending_menu_activation; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
227 |
13434 | 228 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
229 /* 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
|
230 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
|
231 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
232 static struct frame * |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
233 menubar_id_to_frame (id) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
234 HMENU id; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
235 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
236 Lisp_Object tail, frame; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
237 FRAME_PTR f; |
13434 | 238 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
239 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
|
240 { |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
241 frame = XCAR (tail); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
242 if (!GC_FRAMEP (frame)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
243 continue; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
244 f = XFRAME (frame); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
245 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
|
246 continue; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
247 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
|
248 return f; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
249 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
250 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
251 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
252 |
13434 | 253 /* Initialize the menu_items structure if we haven't already done so. |
254 Also mark it as currently empty. */ | |
255 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
256 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
257 init_menu_items () |
13434 | 258 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
259 if (NILP (menu_items)) |
13434 | 260 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
261 menu_items_allocated = 60; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
262 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
13434 | 263 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
264 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
265 menu_items_used = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
266 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
|
267 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
|
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 /* 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
|
271 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
|
272 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
273 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
274 finish_menu_items () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
275 { |
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 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
278 /* 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
|
279 in menu_items. */ |
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 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
282 discard_menu_items () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
283 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
284 /* 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
|
285 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
|
286 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
|
287 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
288 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
289 menu_items_allocated = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
290 } |
13434 | 291 } |
292 | |
293 /* Make the menu_items vector twice as large. */ | |
294 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
295 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
296 grow_menu_items () |
13434 | 297 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
298 Lisp_Object old; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
299 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
|
300 old = menu_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
301 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
302 menu_items_allocated *= 2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
303 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
|
304 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, |
13434 | 305 old_size * sizeof (Lisp_Object)); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
306 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
307 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
308 /* Begin a submenu. */ |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
309 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
310 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
311 push_submenu_start () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
312 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
313 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
|
314 grow_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
315 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
316 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
|
317 menu_items_submenu_depth++; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
318 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
319 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
320 /* End a submenu. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
321 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
322 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
323 push_submenu_end () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
324 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
325 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
|
326 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
327 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
328 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
|
329 menu_items_submenu_depth--; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
330 } |
13434 | 331 |
332 /* Indicate boundary between left and right. */ | |
333 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
334 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
335 push_left_right_boundary () |
13434 | 336 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
337 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
|
338 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
339 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
340 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
|
341 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
342 |
41251
e6612d08452f
(w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
41108
diff
changeset
|
343 /* Start a new menu pane in menu_items. |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
344 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
|
345 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
346 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
347 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
|
348 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
|
349 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
350 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
|
351 grow_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
352 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
353 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
|
354 menu_items_n_panes++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
355 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
|
356 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
|
357 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec; |
13434 | 358 } |
359 | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
360 /* 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 item, one of nil, `toggle' or `radio'. */ |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
367 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
368 static void |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
369 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
|
370 Lisp_Object name, enable, key, def, equiv, type, selected, help; |
13434 | 371 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
372 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
|
373 grow_menu_items (); |
13434 | 374 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 XVECTOR (menu_items)->contents[menu_items_used++] = help; |
13434 | 383 } |
384 | |
385 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long, | |
386 and generate menu panes for them in menu_items. | |
387 If NOTREAL is nonzero, | |
388 don't bother really computing whether an item is enabled. */ | |
389 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
390 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
391 keymap_panes (keymaps, nmaps, notreal) |
13434 | 392 Lisp_Object *keymaps; |
393 int nmaps; | |
394 int notreal; | |
395 { | |
396 int mapno; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
397 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
398 init_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
399 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
400 /* 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10); |
13434 | 406 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
407 finish_menu_items (); |
13434 | 408 } |
409 | |
410 /* This is a recursive subroutine of keymap_panes. | |
411 It handles one keymap, KEYMAP. | |
412 The other arguments are passed along | |
413 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
|
414 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
|
415 evaluate expressions in menu items and don't make any menu. |
13434 | 416 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
417 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
|
418 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
419 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
420 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) |
13434 | 421 Lisp_Object keymap; |
422 Lisp_Object pane_name; | |
423 Lisp_Object prefix; | |
424 int notreal; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
425 int maxdepth; |
13434 | 426 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
427 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
|
428 Lisp_Object tail, item; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
429 struct gcpro gcpro1, gcpro2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
430 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
431 if (maxdepth <= 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
432 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
433 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
434 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
|
435 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
436 for (tail = keymap; CONSP (tail); tail = XCDR (tail)) |
13434 | 437 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
438 GCPRO2 (keymap, pending_maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
439 /* 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
|
440 to this menu. */ |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
441 item = XCAR (tail); |
13434 | 442 if (CONSP (item)) |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
443 single_menu_item (XCAR (item), XCDR (item), |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
444 &pending_maps, notreal, maxdepth); |
13434 | 445 else if (VECTORP (item)) |
446 { | |
447 /* Loop over the char values represented in the vector. */ | |
448 int len = XVECTOR (item)->size; | |
449 int c; | |
450 for (c = 0; c < len; c++) | |
451 { | |
452 Lisp_Object character; | |
453 XSETFASTINT (character, c); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
454 single_menu_item (character, XVECTOR (item)->contents[c], |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
455 &pending_maps, notreal, maxdepth); |
13434 | 456 } |
457 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
458 UNGCPRO; |
13434 | 459 } |
460 | |
461 /* Process now any submenus which want to be panes at this level. */ | |
462 while (!NILP (pending_maps)) | |
463 { | |
464 Lisp_Object elt, eltcdr, string; | |
465 elt = Fcar (pending_maps); | |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
466 eltcdr = XCDR (elt); |
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
22750
diff
changeset
|
467 string = XCAR (eltcdr); |
13434 | 468 /* 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
|
469 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
|
470 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
|
471 XCDR (eltcdr), notreal, maxdepth - 1); |
13434 | 472 pending_maps = Fcdr (pending_maps); |
473 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
474 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
475 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
476 /* 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
|
477 keymap entry. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
478 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
|
479 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
|
480 separate panes. |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
481 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
|
482 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
|
483 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
|
484 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
485 static void |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
486 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
|
487 Lisp_Object key, item; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
488 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
|
489 int maxdepth, notreal; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
490 { |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
491 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
|
492 struct gcpro gcpro1, gcpro2; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
493 int res; |
13434 | 494 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
495 /* 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
|
496 GCPRO2 (key, item); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
497 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
|
498 UNGCPRO; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
499 if (!res) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
500 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
|
501 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
502 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
|
503 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
504 if (notreal) |
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 /* 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
|
507 precompute equivalent key bindings. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
508 if (!NILP (map)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
509 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
|
510 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
511 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
512 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
513 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
|
514 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
|
515 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
516 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
|
517 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
518 if (!NILP (enabled)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
519 /* 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
|
520 *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
|
521 *pending_maps_ptr); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
522 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
523 } |
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 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
532 /* 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
|
533 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
|
534 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
535 push_submenu_start (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
536 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
|
537 push_submenu_end (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
538 } |
13434 | 539 } |
540 | |
14036 | 541 /* Push all the panes and items of a menu described by the |
13434 | 542 alist-of-alists MENU. |
543 This handles old-fashioned calls to x-popup-menu. */ | |
544 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
545 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
546 list_of_panes (menu) |
13434 | 547 Lisp_Object menu; |
548 { | |
549 Lisp_Object tail; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
550 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
551 init_menu_items (); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
552 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
553 for (tail = menu; !NILP (tail); tail = Fcdr (tail)) |
13434 | 554 { |
555 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
|
556 elt = Fcar (tail); |
13434 | 557 pane_name = Fcar (elt); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
558 CHECK_STRING (pane_name); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
559 push_menu_pane (pane_name, Qnil); |
13434 | 560 pane_data = Fcdr (elt); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
561 CHECK_CONS (pane_data); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
562 list_of_items (pane_data); |
13434 | 563 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
564 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
565 finish_menu_items (); |
13434 | 566 } |
567 | |
568 /* Push the items in a single pane defined by the alist PANE. */ | |
569 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
570 static void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
571 list_of_items (pane) |
13434 | 572 Lisp_Object pane; |
573 { | |
574 Lisp_Object tail, item, item1; | |
575 | |
576 for (tail = pane; !NILP (tail); tail = Fcdr (tail)) | |
577 { | |
578 item = Fcar (tail); | |
579 if (STRINGP (item)) | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
580 push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil); |
13434 | 581 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
|
582 push_left_right_boundary (); |
13434 | 583 else |
584 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
585 CHECK_CONS (item); |
13434 | 586 item1 = Fcar (item); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
587 CHECK_STRING (item1); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
588 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); |
13434 | 589 } |
590 } | |
591 } | |
592 | |
593 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, | |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
594 doc: /* Pop up a deck-of-cards menu and return user's selection. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
595 POSITION is a position specification. This is either a mouse button |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
596 event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
597 are positions in pixels from the top left corner of WINDOW's frame |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
598 \(WINDOW may be a frame object instead of a window). This controls the |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
599 position of the center of the first line in the first pane of the |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
600 menu, not the top left of the menu as a whole. If POSITION is t, it |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
601 means to use the current mouse position. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
602 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
603 MENU is a specifier for a menu. For the simplest case, MENU is a keymap. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
604 The menu items come from key bindings that have a menu string as well as |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
605 a definition; actually, the \"definition\" in such a key binding looks like |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
606 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
607 the keymap as a top-level element. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
608 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
609 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
610 Otherwise, REAL-DEFINITION should be a valid key binding definition. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
611 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
612 You can also use a list of keymaps as MENU. Then each keymap makes a |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
613 separate pane. When MENU is a keymap or a list of keymaps, the return |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
614 value is a list of events. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
615 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
616 Alternatively, you can specify a menu of multiple panes with a list of |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
617 the form (TITLE PANE1 PANE2...), where each pane is a list of |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
618 form (TITLE ITEM1 ITEM2...). |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
619 Each ITEM is normally a cons cell (STRING . VALUE); but a string can |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
620 appear as an item--that makes a nonselectable line in the menu. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
621 With this form of menu, the return value is VALUE from the chosen item. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
622 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
623 If POSITION is nil, don't display the menu at all, just precalculate the |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
624 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
|
625 (position, menu) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
626 Lisp_Object position, menu; |
13434 | 627 { |
628 Lisp_Object keymap, tem; | |
40476
18b1b133e5c1
(Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40119
diff
changeset
|
629 int xpos = 0, ypos = 0; |
13434 | 630 Lisp_Object title; |
631 char *error_name; | |
632 Lisp_Object selection; | |
40476
18b1b133e5c1
(Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40119
diff
changeset
|
633 FRAME_PTR f = NULL; |
13434 | 634 Lisp_Object x, y, window; |
635 int keymaps = 0; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
636 int for_click = 0; |
13434 | 637 struct gcpro gcpro1; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
638 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
639 #ifdef HAVE_MENUS |
13434 | 640 if (! NILP (position)) |
641 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
642 check_w32 (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
643 |
13434 | 644 /* 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
|
645 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
|
646 || (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
|
647 || EQ (XCAR (position), Qtool_bar)))) |
13434 | 648 { |
649 /* 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
|
650 FRAME_PTR new_f = SELECTED_FRAME (); |
13434 | 651 Lisp_Object bar_window; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
652 enum scroll_bar_part part; |
13434 | 653 unsigned long time; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
654 |
13434 | 655 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
|
656 (*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
|
657 &part, &x, &y, &time); |
13434 | 658 if (new_f != 0) |
659 XSETFRAME (window, new_f); | |
660 else | |
661 { | |
662 window = selected_window; | |
663 XSETFASTINT (x, 0); | |
664 XSETFASTINT (y, 0); | |
665 } | |
666 } | |
667 else | |
668 { | |
669 tem = Fcar (position); | |
670 if (CONSP (tem)) | |
671 { | |
672 window = Fcar (Fcdr (position)); | |
673 x = Fcar (tem); | |
674 y = Fcar (Fcdr (tem)); | |
675 } | |
676 else | |
677 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
678 for_click = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
679 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
|
680 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
13434 | 681 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
682 x = Fcar (tem); | |
683 y = Fcdr (tem); | |
684 } | |
685 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
686 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
687 CHECK_NUMBER (x); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
688 CHECK_NUMBER (y); |
13434 | 689 |
690 /* 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
|
691 |
13434 | 692 if (FRAMEP (window)) |
693 { | |
694 f = XFRAME (window); | |
695 xpos = 0; | |
696 ypos = 0; | |
697 } | |
698 else if (WINDOWP (window)) | |
699 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
700 CHECK_LIVE_WINDOW (window); |
13434 | 701 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
|
702 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
703 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
|
704 * XFASTINT (XWINDOW (window)->left)); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
705 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
|
706 * XFASTINT (XWINDOW (window)->top)); |
13434 | 707 } |
708 else | |
709 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, | |
710 but I don't want to make one now. */ | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
711 CHECK_WINDOW (window); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
712 |
13434 | 713 xpos += XINT (x); |
714 ypos += XINT (y); | |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
715 |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
716 XSETFRAME (Vmenu_updating_frame, f); |
13434 | 717 } |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
718 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
|
719 #endif /* HAVE_MENUS */ |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
720 |
13434 | 721 title = Qnil; |
722 GCPRO1 (title); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
723 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
724 /* 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
|
725 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
726 keymap = get_keymap (menu, 0, 0); |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
727 if (CONSP (keymap)) |
21741
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 /* 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
|
730 Lisp_Object prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
731 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
732 /* 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
|
733 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
|
734 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
735 /* 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
|
736 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
|
737 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
|
738 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
|
739 title = prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
740 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
741 /* 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
|
742 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
|
743 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
|
744 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
745 keymaps = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
746 } |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
747 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
|
748 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
749 /* 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
|
750 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
|
751 Lisp_Object *maps |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
752 = (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
|
753 int i; |
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 title = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
756 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
757 /* 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
|
758 supplies the menu title. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
759 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
|
760 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
761 Lisp_Object prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
762 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
763 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
|
764 |
39690
38c1890338cc
(keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
765 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
|
766 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
|
767 title = prompt; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
768 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
769 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
770 /* 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
|
771 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
|
772 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
773 /* 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
|
774 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
|
775 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
|
776 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
777 keymaps = 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 else |
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 /* 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
|
782 title = Fcar (menu); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
783 CHECK_STRING (title); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
784 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
785 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
|
786 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
787 keymaps = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
788 } |
13434 | 789 |
790 if (NILP (position)) | |
791 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
792 discard_menu_items (); |
13434 | 793 UNGCPRO; |
794 return Qnil; | |
795 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
796 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
797 #ifdef HAVE_MENUS |
13434 | 798 /* Display them in a menu. */ |
799 BLOCK_INPUT; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
800 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
801 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
|
802 keymaps, title, &error_name); |
13434 | 803 UNBLOCK_INPUT; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
804 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
805 discard_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
806 |
13434 | 807 UNGCPRO; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
808 #endif /* 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 if (error_name) error (error_name); |
811 return selection; | |
812 } | |
813 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
814 #ifdef HAVE_MENUS |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
815 |
13434 | 816 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
817 doc: /* Pop up a dialog box and return user's selection. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
818 POSITION specifies which frame to use. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
819 This is normally a mouse button event or a window or frame. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
820 If POSITION is t, it means to use the frame the mouse is on. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
821 The dialog box appears in the middle of the specified frame. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
822 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
823 CONTENTS specifies the alternatives to display in the dialog box. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
824 It is a list of the form (TITLE ITEM1 ITEM2...). |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
825 Each ITEM is a cons cell (STRING . VALUE). |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
826 The return value is VALUE from the chosen item. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
827 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
828 An ITEM may also be just a string--that makes a nonselectable item. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
829 An ITEM may also be nil--that means to put all preceding items |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
830 on the left of the dialog box and all following items on the right. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
831 \(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
|
832 (position, contents) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
833 Lisp_Object position, contents; |
13434 | 834 { |
40476
18b1b133e5c1
(Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40119
diff
changeset
|
835 FRAME_PTR f = NULL; |
13434 | 836 Lisp_Object window; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
837 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
838 check_w32 (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
839 |
13434 | 840 /* 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
|
841 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
|
842 || (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
|
843 || EQ (XCAR (position), Qtool_bar)))) |
13434 | 844 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
845 #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
|
846 /* 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
|
847 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
|
848 Lisp_Object bar_window; |
31114
cd392fdf0e9f
Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents:
30989
diff
changeset
|
849 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
|
850 unsigned long time; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
851 Lisp_Object x, y; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
852 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
853 (*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
|
854 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
855 if (new_f != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
856 XSETFRAME (window, new_f); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
857 else |
13434 | 858 window = selected_window; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
859 #endif |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
860 window = selected_window; |
13434 | 861 } |
862 else if (CONSP (position)) | |
863 { | |
864 Lisp_Object tem; | |
865 tem = Fcar (position); | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
866 if (CONSP (tem)) |
13434 | 867 window = Fcar (Fcdr (position)); |
868 else | |
869 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
870 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
|
871 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
13434 | 872 } |
873 } | |
874 else if (WINDOWP (position) || FRAMEP (position)) | |
875 window = position; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
876 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
877 window = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
878 |
13434 | 879 /* 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
|
880 |
13434 | 881 if (FRAMEP (window)) |
882 f = XFRAME (window); | |
883 else if (WINDOWP (window)) | |
884 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
885 CHECK_LIVE_WINDOW (window); |
13434 | 886 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
887 } | |
888 else | |
889 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, | |
890 but I don't want to make one now. */ | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
891 CHECK_WINDOW (window); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
892 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
893 #ifndef HAVE_DIALOGS |
13434 | 894 /* Display a menu with these alternatives |
895 in the middle of frame F. */ | |
896 { | |
897 Lisp_Object x, y, frame, newpos; | |
898 XSETFRAME (frame, f); | |
899 XSETINT (x, x_pixel_width (f) / 2); | |
900 XSETINT (y, x_pixel_height (f) / 2); | |
901 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil)); | |
902 | |
903 return Fx_popup_menu (newpos, | |
904 Fcons (Fcar (contents), Fcons (contents, Qnil))); | |
905 } | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
906 #else /* HAVE_DIALOGS */ |
13434 | 907 { |
908 Lisp_Object title; | |
909 char *error_name; | |
910 Lisp_Object selection; | |
911 | |
912 /* Decode the dialog items from what was specified. */ | |
913 title = Fcar (contents); | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40476
diff
changeset
|
914 CHECK_STRING (title); |
13434 | 915 |
916 list_of_panes (Fcons (contents, Qnil)); | |
917 | |
918 /* Display them in a dialog box. */ | |
919 BLOCK_INPUT; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
920 selection = w32_dialog_show (f, 0, title, &error_name); |
13434 | 921 UNBLOCK_INPUT; |
922 | |
923 discard_menu_items (); | |
924 | |
925 if (error_name) error (error_name); | |
926 return selection; | |
927 } | |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
928 #endif /* HAVE_DIALOGS */ |
13434 | 929 } |
930 | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
931 /* Activate the menu bar of frame F. |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
932 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
|
933 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
|
934 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
935 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
|
936 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
|
937 processing of the menus. |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
938 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
939 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
|
940 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
941 This way we can safely execute Lisp code. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
942 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
943 void |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
944 x_activate_menubar (f) |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
945 FRAME_PTR f; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
946 { |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
947 set_frame_menubar (f, 0, 1); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
948 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
949 /* Lock out further menubar changes while active. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
950 f->output_data.w32->menubar_active = 1; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
951 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
952 /* Signal input thread to return from WM_INITMENU. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
953 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
|
954 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
955 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
956 /* 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
|
957 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
|
958 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
|
959 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
|
960 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
961 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
962 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
|
963 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
964 Lisp_Object prefix, entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
965 Lisp_Object vector; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
966 Lisp_Object *subprefix_stack; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
967 int submenu_depth = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
968 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
969 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
970 if (!f) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
971 return; |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
972 entry = Qnil; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
973 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
|
974 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
|
975 prefix = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
976 i = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
977 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
|
978 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
979 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
|
980 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
981 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
|
982 prefix = entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
983 i++; |
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 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
|
986 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
987 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
|
988 i++; |
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 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
|
991 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
992 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
|
993 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
|
994 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
995 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
996 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
997 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
|
998 /* 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
|
999 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
|
1000 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
|
1001 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1002 int j; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1003 struct input_event buf; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1004 Lisp_Object frame; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1005 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1006 XSETFRAME (frame, f); |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1007 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1008 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1009 buf.arg = frame; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1010 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
|
1011 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1012 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
|
1013 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
|
1014 { |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1015 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1016 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1017 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
|
1018 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
|
1019 } |
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 if (!NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1022 { |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1023 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1024 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1025 buf.arg = prefix; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1026 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
|
1027 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1028 |
30178
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1029 buf.kind = MENU_BAR_EVENT; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1030 buf.frame_or_window = frame; |
6d045b9631ad
(menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents:
30145
diff
changeset
|
1031 buf.arg = entry; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1032 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
|
1033 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1034 return; |
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 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
|
1037 } |
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 } |
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 /* 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
|
1042 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1043 widget_value * |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1044 xmalloc_widget_value () |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1045 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1046 widget_value *value; |
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 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1049 value = malloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1050 UNBLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1051 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1052 return value; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1053 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1054 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1055 /* 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
|
1056 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
|
1057 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
|
1058 must be left alone. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1059 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1060 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1061 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
|
1062 widget_value *wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1063 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1064 if (! wv) return; |
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 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
|
1067 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1068 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
|
1069 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1070 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
|
1071 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
|
1072 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1073 if (wv->next) |
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 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
|
1076 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
|
1077 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1078 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1079 free_widget_value (wv); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1080 UNBLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1081 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1082 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1083 /* 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
|
1084 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
|
1085 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
|
1086 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1087 static widget_value * |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1088 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
|
1089 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
|
1090 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1091 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
|
1092 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1093 int submenu_depth = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1094 Lisp_Object length; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1095 int len; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1096 Lisp_Object *mapvec; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1097 widget_value **submenu_stack; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1098 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
|
1099 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
|
1100 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1101 length = Flength (maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1102 len = XINT (length); |
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 /* 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
|
1105 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
|
1106 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
|
1107 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1108 mapvec[i] = Fcar (maps); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1109 maps = Fcdr (maps); |
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 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1112 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
|
1113 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1114 /* 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
|
1115 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
|
1116 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
|
1117 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1118 if (SYMBOLP (mapvec[i]) |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1119 || (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
|
1120 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1121 /* 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
|
1122 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
|
1123 top_level_items = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1124 push_menu_pane (Qnil, Qnil); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1125 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
|
1126 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
|
1127 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1128 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1129 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
|
1130 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1131 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1132 /* 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
|
1133 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
|
1134 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1135 submenu_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1136 = (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
|
1137 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1138 wv->name = "menu"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1139 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1140 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1141 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
|
1142 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1143 save_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1144 prev_wv = 0; |
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 /* 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
|
1147 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
|
1148 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
|
1149 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
|
1150 i = previous_items; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1151 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
|
1152 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1153 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
|
1154 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1155 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
|
1156 save_wv = prev_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1157 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1158 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1159 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1160 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
|
1161 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1162 prev_wv = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1163 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
|
1164 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1165 } |
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 && submenu_depth != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1168 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
|
1169 /* 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
|
1170 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
|
1171 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
|
1172 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1173 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
|
1174 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1175 /* Create a new pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1176 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
|
1177 char *pane_string; |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1178 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1179 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
|
1180 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1181 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1182 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1183 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1184 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1185 pane_name = ENCODE_SYSTEM (pane_name); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1186 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1187 } |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1188 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1189 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
|
1190 ? "" : (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
|
1191 /* 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
|
1192 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
|
1193 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
|
1194 pane_string = ""; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1195 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1196 /* 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
|
1197 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
|
1198 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
|
1199 if (strcmp (pane_string, "")) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1200 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1201 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1202 if (save_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1203 save_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1204 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1205 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1206 wv->name = pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1207 /* 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
|
1208 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
|
1209 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
|
1210 wv->name++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1211 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1212 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1213 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
|
1214 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1215 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1216 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1217 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
|
1218 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1219 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1220 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1221 /* 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
|
1222 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
|
1223 Lisp_Object help; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1224 |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1225 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1226 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1227 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1228 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1229 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1230 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1231 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1232 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1233 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1234 if (STRING_MULTIBYTE (item_name)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1235 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1236 item_name = ENCODE_SYSTEM (item_name); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1237 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1238 } |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1239 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1240 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1241 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1242 descrip = ENCODE_SYSTEM (descrip); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1243 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1244 } |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1245 #endif /* not HAVE_MULTILINGUAL_MENU */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1246 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1247 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1248 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1249 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1250 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1251 save_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1252 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1253 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
|
1254 if (!NILP (descrip)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1255 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
|
1256 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1257 /* 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
|
1258 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
|
1259 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
|
1260 wv->enabled = !NILP (enable); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1261 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1262 if (NILP (type)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1263 wv->button_type = BUTTON_TYPE_NONE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1264 else if (EQ (type, QCradio)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1265 wv->button_type = BUTTON_TYPE_RADIO; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1266 else if (EQ (type, QCtoggle)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1267 wv->button_type = BUTTON_TYPE_TOGGLE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1268 else |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1269 abort (); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1270 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1271 wv->selected = !NILP (selected); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1272 if (STRINGP (help)) |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1273 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
|
1274 else |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1275 wv->help = NULL; |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1276 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1277 prev_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1278 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1279 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
|
1280 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1281 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1282 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1283 /* 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
|
1284 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
|
1285 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
|
1286 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1287 wv = first_wv->contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1288 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
|
1289 return wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1290 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1291 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1292 return first_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1293 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1294 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1295 /* 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
|
1296 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
|
1297 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
|
1298 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1299 void |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1300 set_frame_menubar (f, first_time, deep_p) |
13434 | 1301 FRAME_PTR f; |
1302 int first_time; | |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1303 int deep_p; |
13434 | 1304 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1305 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
|
1306 Lisp_Object items; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1307 widget_value *wv, *first_wv, *prev_wv = 0; |
13434 | 1308 int i; |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
1309 |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1310 /* 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
|
1311 if (f->output_data.w32->menubar_active) |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1312 return; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1313 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1314 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
|
1315 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1316 if (! menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1317 deep_p = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1318 else if (pending_menu_activation && !deep_p) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1319 deep_p = 1; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1320 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1321 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1322 wv->name = "menubar"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1323 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1324 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1325 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
|
1326 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1327 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1328 if (deep_p) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1329 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1330 /* 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
|
1331 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1332 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
|
1333 Lisp_Object buffer; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1334 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
|
1335 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
|
1336 Lisp_Object *previous_items |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1337 = (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
|
1338 * sizeof (Lisp_Object)); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1339 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1340 /* 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
|
1341 do always reinitialize them. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1342 if (! menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1343 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
|
1344 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1345 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
|
1346 specbind (Qinhibit_quit, Qt); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1347 /* 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
|
1348 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
|
1349 specbind (Qdebug_on_next_call, Qnil); |
15276 | 1350 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1351 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
|
1352 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
|
1353 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1354 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
|
1355 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
|
1356 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1357 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1358 set_buffer_internal_1 (XBUFFER (buffer)); |
15276 | 1359 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1360 /* 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
|
1361 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
|
1362 /* 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
|
1363 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
|
1364 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
|
1365 call0 (Qrecompute_lucid_menubar); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1366 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
|
1367 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
|
1368 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1369 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
|
1370 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1371 inhibit_garbage_collection (); |
15276 | 1372 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1373 /* 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
|
1374 if (previous_menu_items_used) |
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1375 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
|
1376 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
|
1377 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1378 /* 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
|
1379 menu_items = f->menu_bar_vector; |
39507
24530f82048e
(set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents:
38371
diff
changeset
|
1380 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
|
1381 init_menu_items (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1382 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
|
1383 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1384 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
|
1385 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1386 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
|
1387 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
|
1388 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
|
1389 if (NILP (string)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1390 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1391 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1392 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
|
1393 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1394 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1395 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1396 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1397 /* 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
|
1398 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1399 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
|
1400 prev_wv = wv; |
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 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1403 finish_menu_items (); |
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 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
|
1406 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
|
1407 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1408 /* 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
|
1409 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
|
1410 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1411 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
|
1412 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
|
1413 || (!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
|
1414 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1415 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
|
1416 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1417 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
|
1418 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1419 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1420 return; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1421 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1422 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1423 /* Now GC cannot happen during the lifetime of the widget_value, |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1424 so it's safe to store data from a Lisp_String, as long as |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1425 local copies are made when the actual menu is created. |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1426 Windows takes care of this for normal string items, but |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1427 not for owner-drawn items or additional item-info. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1428 wv = first_wv->contents; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1429 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
|
1430 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1431 Lisp_Object string; |
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 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
|
1436 wv = wv->next; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1437 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1438 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1439 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
|
1440 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
|
1441 menu_items = Qnil; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1442 } |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1443 else |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1444 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1445 /* 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
|
1446 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
|
1447 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1448 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
|
1449 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
|
1450 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1451 Lisp_Object string; |
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 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
|
1454 if (NILP (string)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1455 break; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1456 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1457 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1458 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
|
1459 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1460 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1461 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
|
1462 /* 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
|
1463 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
|
1464 /* 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
|
1465 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
|
1466 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
|
1467 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1468 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1469 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1470 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1471 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1472 prev_wv = wv; |
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 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1475 /* 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
|
1476 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
|
1477 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
|
1478 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
|
1479 } |
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 /* 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
|
1482 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1483 BLOCK_INPUT; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1484 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1485 if (menubar_widget) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1486 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1487 /* 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
|
1488 while (DeleteMenu (menubar_widget, 0, MF_BYPOSITION)) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1489 ; |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1490 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1491 else |
13434 | 1492 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1493 menubar_widget = CreateMenu (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1494 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1495 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
|
1496 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1497 free_menubar_widget_value_tree (first_wv); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1498 |
13434 | 1499 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1500 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
|
1501 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1502 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
|
1503 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
|
1504 /* Causes flicker when menu bar is updated |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1505 DrawMenuBar (FRAME_W32_WINDOW (f)); */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1506 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1507 /* 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
|
1508 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
|
1509 if (old_widget == NULL) |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1510 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
13434 | 1511 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1512 |
13434 | 1513 UNBLOCK_INPUT; |
1514 } | |
1515 | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1516 /* 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
|
1517 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
|
1518 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
|
1519 is visible. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1520 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1521 void |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1522 initialize_frame_menubar (f) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1523 FRAME_PTR f; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1524 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1525 /* 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
|
1526 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
|
1527 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
|
1528 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
|
1529 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1530 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1531 /* 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
|
1532 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
|
1533 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1534 void |
13434 | 1535 free_frame_menubar (f) |
1536 FRAME_PTR f; | |
1537 { | |
1538 BLOCK_INPUT; | |
1539 | |
1540 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1541 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
|
1542 SetMenu (FRAME_W32_WINDOW (f), NULL); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1543 f->output_data.w32->menubar_widget = NULL; |
13434 | 1544 DestroyMenu (old); |
1545 } | |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1546 |
13434 | 1547 UNBLOCK_INPUT; |
1548 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1549 |
13434 | 1550 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1551 /* 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
|
1552 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
|
1553 is blocked by the caller. */ |
13434 | 1554 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1555 /* 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
|
1556 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
|
1557 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
|
1558 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
|
1559 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
|
1560 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
|
1561 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
|
1562 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
|
1563 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
|
1564 (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
|
1565 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1566 static Lisp_Object |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1567 w32_menu_show (f, x, y, for_click, keymaps, title, error) |
13434 | 1568 FRAME_PTR f; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1569 int x; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1570 int y; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1571 int for_click; |
13434 | 1572 int keymaps; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1573 Lisp_Object title; |
13434 | 1574 char **error; |
1575 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1576 int i; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1577 int menu_item_selection; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1578 HMENU menu; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1579 POINT pos; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1580 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
|
1581 widget_value **submenu_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1582 = (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
|
1583 Lisp_Object *subprefix_stack |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1584 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); |
13434 | 1585 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
|
1586 int first_pane; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1587 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1588 *error = NULL; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1589 |
13434 | 1590 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
1591 { | |
1592 *error = "Empty menu"; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1593 return Qnil; |
13434 | 1594 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1595 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1596 /* 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
|
1597 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
|
1598 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1599 wv->name = "menu"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1600 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1601 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1602 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
|
1603 first_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1604 first_pane = 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1605 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1606 /* Loop over all panes and items, filling in the tree. */ |
13434 | 1607 i = 0; |
1608 while (i < menu_items_used) | |
1609 { | |
1610 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) | |
1611 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1612 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
|
1613 save_wv = prev_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1614 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1615 first_pane = 1; |
13434 | 1616 i++; |
1617 } | |
1618 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) | |
1619 { | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1620 prev_wv = save_wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1621 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
|
1622 first_pane = 0; |
13434 | 1623 i++; |
1624 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1625 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
|
1626 && submenu_depth != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1627 i += MENU_ITEMS_PANE_LENGTH; |
13434 | 1628 /* Ignore a nil in the item list. |
1629 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
|
1630 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
|
1631 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1632 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
|
1633 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1634 /* Create a new pane. */ |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1635 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
|
1636 char *pane_string; |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1637 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1638 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1639 #ifndef HAVE_MULTILINGUAL_MENU |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1640 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1641 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1642 pane_name = ENCODE_SYSTEM (pane_name); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1643 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1644 } |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1645 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1646 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
|
1647 ? "" : (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
|
1648 /* 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
|
1649 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
|
1650 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
|
1651 pane_string = ""; |
13434 | 1652 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1653 /* 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
|
1654 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
|
1655 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
|
1656 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
|
1657 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1658 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1659 if (save_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1660 save_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1661 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1662 first_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1663 wv->name = pane_string; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1664 if (keymaps && !NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1665 wv->name++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1666 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1667 wv->enabled = 1; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1668 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
|
1669 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1670 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1671 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1672 else if (first_pane) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1673 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1674 save_wv = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1675 prev_wv = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1676 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1677 first_pane = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1678 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
|
1679 } |
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 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1682 /* Create a new item within current pane. */ |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1683 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
|
1684 |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1685 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1686 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1687 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1688 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1689 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1690 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1691 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1692 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1693 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1694 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1695 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1696 item_name = ENCODE_SYSTEM (item_name); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1697 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1698 } |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1699 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1700 { |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1701 descrip = ENCODE_SYSTEM (descrip); |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1702 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1703 } |
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1704 #endif /* not HAVE_MULTILINGUAL_MENU */ |
13434 | 1705 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1706 wv = xmalloc_widget_value (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1707 if (prev_wv) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1708 prev_wv->next = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1709 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1710 save_wv->contents = wv; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1711 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
|
1712 if (!NILP (descrip)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1713 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
|
1714 wv->value = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1715 /* Use the contents index as call_data, since we are |
41251
e6612d08452f
(w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
41108
diff
changeset
|
1716 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
|
1717 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
|
1718 wv->enabled = !NILP (enable); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1719 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1720 if (NILP (type)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1721 wv->button_type = BUTTON_TYPE_NONE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1722 else if (EQ (type, QCtoggle)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1723 wv->button_type = BUTTON_TYPE_TOGGLE; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1724 else if (EQ (type, QCradio)) |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1725 wv->button_type = BUTTON_TYPE_RADIO; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1726 else |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1727 abort (); |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1728 |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1729 wv->selected = !NILP (selected); |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1730 if (STRINGP (help)) |
40119
bf81460680f2
(single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents:
39690
diff
changeset
|
1731 wv->help = XSTRING (help)->data; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
1732 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1733 prev_wv = wv; |
13434 | 1734 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1735 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
|
1736 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1737 } |
13434 | 1738 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1739 /* 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
|
1740 if (!NILP (title)) |
13434 | 1741 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1742 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
|
1743 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
|
1744 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1745 /* 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
|
1746 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
|
1747 wv_sep->name = "--"; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1748 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
|
1749 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1750 #ifndef HAVE_MULTILINGUAL_MENU |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1751 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
|
1752 title = ENCODE_SYSTEM (title); |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1753 #endif |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1754 wv_title->name = (char *) XSTRING (title)->data; |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1755 wv_title->enabled = TRUE; |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1756 wv_title->title = TRUE; |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
1757 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
|
1758 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
|
1759 first_wv->contents = wv_title; |
13434 | 1760 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1761 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1762 /* Actually create the menu. */ |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1763 current_popup_menu = menu = CreatePopupMenu (); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1764 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
|
1765 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1766 /* Adjust coordinates to be root-window-relative. */ |
13434 | 1767 pos.x = x; |
1768 pos.y = y; | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
1769 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
|
1770 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1771 /* 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
|
1772 menu_item_selection = 0; |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1773 |
13434 | 1774 /* Display the menu. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1775 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
|
1776 WM_EMACS_TRACKPOPUPMENU, |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1777 (WPARAM)menu, (LPARAM)&pos); |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1778 |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1779 /* 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
|
1780 during the call. */ |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1781 discard_mouse_events (); |
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1782 |
30238
4a3b87cc6f04
(w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents:
30178
diff
changeset
|
1783 /* 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
|
1784 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
|
1785 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1786 DestroyMenu (menu); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1787 |
13434 | 1788 /* Find the selected item, and its pane, to return |
1789 the proper value. */ | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1790 if (menu_item_selection != 0) |
13434 | 1791 { |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1792 Lisp_Object prefix, entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1793 |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
1794 prefix = entry = Qnil; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1795 i = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1796 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
|
1797 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1798 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
|
1799 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1800 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
|
1801 prefix = entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1802 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1803 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1804 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
|
1805 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1806 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
|
1807 i++; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1808 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1809 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
|
1810 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1811 prefix |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1812 = 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
|
1813 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
|
1814 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1815 /* 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
|
1816 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
|
1817 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
|
1818 i += 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1819 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1820 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1821 entry |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1822 = 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
|
1823 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
|
1824 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1825 if (keymaps != 0) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1826 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1827 int j; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1828 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1829 entry = Fcons (entry, Qnil); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1830 if (!NILP (prefix)) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1831 entry = Fcons (prefix, entry); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1832 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
|
1833 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
|
1834 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
|
1835 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1836 return entry; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1837 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1838 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
|
1839 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1840 } |
13434 | 1841 } |
19711
dc9694ee3f70
(init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1842 |
13434 | 1843 return Qnil; |
1844 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1845 |
13434 | 1846 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
1847 #ifdef HAVE_DIALOGS |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1848 static char * button_names [] = { |
13434 | 1849 "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
|
1850 "button6", "button7", "button8", "button9", "button10" }; |
13434 | 1851 |
1852 static Lisp_Object | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1853 w32_dialog_show (f, keymaps, title, error) |
13434 | 1854 FRAME_PTR f; |
1855 int keymaps; | |
1856 Lisp_Object title; | |
1857 char **error; | |
1858 { | |
1859 int i, nb_buttons=0; | |
1860 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
|
1861 int menu_item_selection; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1862 |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
1863 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
|
1864 |
13434 | 1865 /* Number of elements seen so far, before boundary. */ |
1866 int left_count = 0; | |
1867 /* 1 means we've seen the boundary between left-hand elts and right-hand. */ | |
1868 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
|
1869 |
13434 | 1870 *error = NULL; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1871 |
13434 | 1872 if (menu_items_n_panes > 1) |
1873 { | |
1874 *error = "Multiple panes in dialog box"; | |
1875 return Qnil; | |
1876 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1877 |
13434 | 1878 /* Create a tree of widget_value objects |
1879 representing the text label and buttons. */ | |
1880 { | |
1881 Lisp_Object pane_name, prefix; | |
1882 char *pane_string; | |
1883 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; | |
1884 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; | |
1885 pane_string = (NILP (pane_name) | |
1886 ? "" : (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
|
1887 prev_wv = xmalloc_widget_value (); |
13434 | 1888 prev_wv->value = pane_string; |
1889 if (keymaps && !NILP (prefix)) | |
1890 prev_wv->name++; | |
1891 prev_wv->enabled = 1; | |
1892 prev_wv->name = "message"; | |
1893 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
|
1894 |
13434 | 1895 /* Loop over all panes and items, filling in the tree. */ |
1896 i = MENU_ITEMS_PANE_LENGTH; | |
1897 while (i < menu_items_used) | |
1898 { | |
1899 | |
1900 /* Create a new item within current pane. */ | |
27896
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1901 Lisp_Object item_name, enable, descrip, help; |
75f296b1a872
(single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents:
27400
diff
changeset
|
1902 |
13434 | 1903 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
1904 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; | |
1905 descrip | |
1906 = 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
|
1907 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
13434 | 1908 |
1909 if (NILP (item_name)) | |
1910 { | |
1911 free_menubar_widget_value_tree (first_wv); | |
1912 *error = "Submenu in dialog items"; | |
1913 return Qnil; | |
1914 } | |
1915 if (EQ (item_name, Qquote)) | |
1916 { | |
1917 /* This is the boundary between left-side elts | |
1918 and right-side elts. Stop incrementing right_count. */ | |
1919 boundary_seen = 1; | |
1920 i++; | |
1921 continue; | |
1922 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1923 if (nb_buttons >= 9) |
13434 | 1924 { |
1925 free_menubar_widget_value_tree (first_wv); | |
1926 *error = "Too many dialog items"; | |
1927 return Qnil; | |
1928 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1929 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1930 wv = xmalloc_widget_value (); |
13434 | 1931 prev_wv->next = wv; |
1932 wv->name = (char *) button_names[nb_buttons]; | |
1933 if (!NILP (descrip)) | |
1934 wv->key = (char *) XSTRING (descrip)->data; | |
1935 wv->value = (char *) XSTRING (item_name)->data; | |
1936 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i]; | |
1937 wv->enabled = !NILP (enable); | |
1938 prev_wv = wv; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1939 |
13434 | 1940 if (! boundary_seen) |
1941 left_count++; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1942 |
13434 | 1943 nb_buttons++; |
1944 i += MENU_ITEMS_ITEM_LENGTH; | |
1945 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1946 |
13434 | 1947 /* If the boundary was not specified, |
1948 by default put half on the left and half on the right. */ | |
1949 if (! boundary_seen) | |
1950 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
|
1951 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1952 wv = xmalloc_widget_value (); |
13434 | 1953 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
|
1954 |
13434 | 1955 /* Dialog boxes use a really stupid name encoding |
1956 which specifies how many buttons to use | |
1957 and how many buttons are on the right. | |
1958 The Q means something also. */ | |
1959 dialog_name[0] = 'Q'; | |
1960 dialog_name[1] = '0' + nb_buttons; | |
1961 dialog_name[2] = 'B'; | |
1962 dialog_name[3] = 'R'; | |
1963 /* Number of buttons to put on the right. */ | |
1964 dialog_name[4] = '0' + nb_buttons - left_count; | |
1965 dialog_name[5] = 0; | |
1966 wv->contents = first_wv; | |
1967 first_wv = wv; | |
1968 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1969 |
13434 | 1970 /* Actually create the dialog. */ |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1971 dialog_id = widget_id_tick++; |
13434 | 1972 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
|
1973 f->output_data.w32->widget, 1, 0, |
13434 | 1974 dialog_selection_callback, 0); |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32671
diff
changeset
|
1975 lw_modify_all_widgets (dialog_id, first_wv->contents, TRUE); |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1976 |
13434 | 1977 /* Free the widget_value objects we used to specify the contents. */ |
1978 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
|
1979 |
13434 | 1980 /* No selection has been chosen yet. */ |
1981 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
|
1982 |
13434 | 1983 /* Display the menu. */ |
1984 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
|
1985 popup_activated_flag = 1; |
13434 | 1986 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1987 /* 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
|
1988 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id); |
13434 | 1989 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1990 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
|
1991 |
13434 | 1992 /* Find the selected item, and its pane, to return |
1993 the proper value. */ | |
1994 if (menu_item_selection != 0) | |
1995 { | |
1996 Lisp_Object prefix; | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
1997 |
13434 | 1998 prefix = Qnil; |
1999 i = 0; | |
2000 while (i < menu_items_used) | |
2001 { | |
2002 Lisp_Object entry; | |
2003 | |
2004 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) | |
2005 { | |
2006 prefix | |
2007 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; | |
2008 i += MENU_ITEMS_PANE_LENGTH; | |
2009 } | |
2010 else | |
2011 { | |
2012 entry | |
2013 = 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
|
2014 if (menu_item_selection == i) |
13434 | 2015 { |
2016 if (keymaps != 0) | |
2017 { | |
2018 entry = Fcons (entry, Qnil); | |
2019 if (!NILP (prefix)) | |
2020 entry = Fcons (prefix, entry); | |
2021 } | |
2022 return entry; | |
2023 } | |
2024 i += MENU_ITEMS_ITEM_LENGTH; | |
2025 } | |
2026 } | |
2027 } | |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2028 |
13434 | 2029 return Qnil; |
2030 } | |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2031 #endif /* HAVE_DIALOGS */ |
21741
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 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2034 /* 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
|
2035 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2036 name_is_separator (name) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2037 char *name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2038 { |
38371
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2039 char *start = name; |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2040 |
eb915f0b1d6e
(menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36677
diff
changeset
|
2041 /* 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
|
2042 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
|
2043 /* 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
|
2044 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
|
2045 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
|
2046 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
|
2047 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2048 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2049 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2050 /* 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
|
2051 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2052 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
|
2053 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2054 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
|
2055 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2056 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2057 static int |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2058 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
|
2059 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2060 UINT fuFlags; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2061 char *out_string; |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2062 int return_value; |
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 (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
|
2065 { |
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2066 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
|
2067 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
|
2068 } |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2069 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2070 { |
22750
b38cb406ed80
(add_menu_item): Draw menu items like titles if call_data is 0.
Andrew Innes <andrewi@gnu.org>
parents:
22737
diff
changeset
|
2071 if (wv->enabled) |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2072 fuFlags = MF_STRING; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2073 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2074 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
|
2075 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2076 if (wv->key != NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2077 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2078 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
|
2079 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
|
2080 strcat (out_string, "\t"); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2081 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
|
2082 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2083 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2084 out_string = wv->name; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2085 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2086 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
|
2087 { |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2088 /* Only use MF_OWNERDRAW if GetMenuItemInfo is usable, since |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2089 we can't deallocate the memory otherwise. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2090 if (get_menu_item_info) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2091 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2092 out_string = LocalAlloc (LPTR, strlen (wv->name) + 1); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2093 strcpy (out_string, wv->name); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2094 fuFlags = MF_OWNERDRAW | MF_DISABLED; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2095 } |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2096 else |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2097 fuFlags = MF_DISABLED; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2098 } |
41637
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2099 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2100 /* 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
|
2101 else if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || |
41108
ef7a153a2c68
(add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
2102 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
|
2103 fuFlags |= MF_CHECKED; |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2104 else |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2105 fuFlags |= MF_UNCHECKED; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2106 } |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2107 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2108 if (item != NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2109 fuFlags = MF_POPUP; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2110 |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2111 return_value = |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2112 AppendMenu (menu, |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2113 fuFlags, |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2114 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
|
2115 out_string ); |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2116 |
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2117 /* This must be done after the menu item is created. */ |
41108
ef7a153a2c68
(add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
2118 if (!wv->title && wv->call_data != 0) |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2119 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2120 if (set_menu_item_info) |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2121 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2122 MENUITEMINFO info; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2123 bzero (&info, sizeof (info)); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2124 info.cbSize = sizeof (info); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2125 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
|
2126 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2127 /* Set help string for menu item. Allocate new memory |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2128 from the heap for it, since garbage collection can |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2129 occur while menus are active. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2130 if (wv->help) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2131 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2132 info.dwItemData |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2133 = (DWORD) LocalAlloc (LPTR, strlen(wv->help) + 1); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2134 strcpy (info.dwItemData, wv->help); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2135 } |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2136 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2137 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
|
2138 { |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2139 /* 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
|
2140 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
|
2141 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
|
2142 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
|
2143 info.dwTypeData = out_string; |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2144 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
|
2145 } |
33971
c33b80a45f6a
(add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents:
32988
diff
changeset
|
2146 |
36677
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2147 set_menu_item_info (menu, |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2148 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
|
2149 FALSE, &info); |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2150 } |
eb7af01c7f27
(add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents:
36313
diff
changeset
|
2151 } |
27932
a590f8d0dbd2
[HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents:
27896
diff
changeset
|
2152 return return_value; |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2153 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2154 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2155 /* 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
|
2156 int |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2157 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
|
2158 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2159 int items_added = 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2160 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2161 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
|
2162 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2163 if (wv->contents) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2164 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2165 HMENU sub_menu = CreatePopupMenu (); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2166 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2167 if (sub_menu == NULL) |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2168 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2169 |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2170 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
|
2171 !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
|
2172 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2173 DestroyMenu (sub_menu); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2174 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2175 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2176 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2177 else |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2178 { |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2179 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
|
2180 return 0; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2181 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2182 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2183 return 1; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2184 } |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2185 |
27400
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2186 int |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2187 popup_activated () |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2188 { |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2189 /* 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
|
2190 return 0; |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2191 } |
da3ee40952bf
Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents:
26729
diff
changeset
|
2192 |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2193 /* 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
|
2194 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
|
2195 available. */ |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2196 void |
41646
258fa72efab7
(w32_menu_display_help): Actually add the new argument
Andrew Innes <andrewi@gnu.org>
parents:
41637
diff
changeset
|
2197 w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags) |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2198 { |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2199 if (get_menu_item_info) |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2200 { |
41637
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2201 struct frame *f = x_window_to_frame (&one_w32_display_info, owner); |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2202 Lisp_Object frame, help; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2203 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2204 // No help echo on owner-draw menu items. |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2205 if (flags & MF_OWNERDRAW || flags & MF_POPUP) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2206 help = Qnil; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2207 else |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2208 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2209 MENUITEMINFO info; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2210 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2211 bzero (&info, sizeof (info)); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2212 info.cbSize = sizeof (info); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2213 info.fMask = MIIM_DATA; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2214 get_menu_item_info (menu, item, FALSE, &info); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2215 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2216 help = info.dwItemData ? build_string ((char *)info.dwItemData) : Qnil; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2217 } |
30989
2152817050ff
(keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents:
30238
diff
changeset
|
2218 |
41637
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2219 /* Store the help echo in the keyboard buffer as the X toolkit |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2220 version does, rather than directly showing it. This seems to |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2221 solve the GC problems that were present when we based the |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2222 Windows code on the non-toolkit version. */ |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2223 if (f) |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2224 { |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2225 XSETFRAME (frame, f); |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2226 kbd_buffer_store_help_event (frame, help); |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2227 } |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2228 else |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2229 /* X version has a loop through frames here, which doesn't |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2230 appear to do anything, unless it has some side effect. */ |
d797ce338b4b
(add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents:
41251
diff
changeset
|
2231 show_help_echo (help, Qnil, Qnil, Qnil, 1); |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2232 } |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2233 } |
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2234 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2235 /* Free memory used by owner-drawn and help_echo strings. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2236 static void |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2237 w32_free_submenu_strings (menu) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2238 HMENU menu; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2239 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2240 int i, num = GetMenuItemCount (menu); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2241 for (i = 0; i < num; i++) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2242 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2243 MENUITEMINFO info; |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2244 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2245 info.cbSize = sizeof (info); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2246 info.fMask = MIIM_DATA | MIIM_SUBMENU; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2247 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2248 get_menu_item_info (menu, i, TRUE, &info); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2249 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2250 /* Both owner-drawn names and help strings are held in dwItemData. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2251 if (info.dwItemData) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2252 LocalFree (info.dwItemData); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2253 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2254 /* Recurse down submenus. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2255 if (info.hSubMenu) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2256 w32_free_submenu_strings (info.hSubMenu); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2257 } |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2258 } |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2259 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2260 void |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2261 w32_free_menu_strings (hwnd) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2262 HWND hwnd; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2263 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2264 HMENU menu = current_popup_menu; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2265 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2266 if (get_menu_item_info) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2267 { |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2268 /* If there is no popup menu active, free the strings from the frame's |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2269 menubar. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2270 if (!menu) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2271 menu = GetMenu (hwnd); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2272 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2273 if (menu) |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2274 w32_free_submenu_strings (menu); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2275 } |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2276 |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2277 current_popup_menu = NULL; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2278 } |
28275
2c8492145fc8
(single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents:
27932
diff
changeset
|
2279 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2280 #endif /* HAVE_MENUS */ |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2281 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2282 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15276
diff
changeset
|
2283 syms_of_w32menu () |
13434 | 2284 { |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2285 /* See if Get/SetMenuItemInfo functions are available. */ |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2286 HMODULE user32 = GetModuleHandle ("user32.dll"); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2287 get_menu_item_info = GetProcAddress (user32, "GetMenuItemInfoA"); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2288 set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA"); |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2289 |
21741
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2290 staticpro (&menu_items); |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2291 menu_items = Qnil; |
3d1ce72aa7b9
Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents:
21612
diff
changeset
|
2292 |
41733
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2293 current_popup_menu = NULL; |
917737801660
(current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents:
41646
diff
changeset
|
2294 |
15276 | 2295 Qdebug_on_next_call = intern ("debug-on-next-call"); |
2296 staticpro (&Qdebug_on_next_call); | |
2297 | |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2298 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
2299 doc: /* Frame for which we are updating a menu. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
2300 The enable predicate for a menu command should check this variable. */); |
21612
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2301 Vmenu_updating_frame = Qnil; |
24a01af0cd38
(Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21450
diff
changeset
|
2302 |
13434 | 2303 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
|
2304 #ifdef HAVE_MENUS |
13434 | 2305 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
|
2306 #endif |
13434 | 2307 } |