Mercurial > emacs
annotate src/xmenu.c @ 33920:9fd4e6727f6b
(Clipboard): New.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 27 Nov 2000 17:24:54 +0000 |
parents | c3435dc00ed7 |
children | 743849495725 |
rev | line source |
---|---|
118 | 1 /* X Communication module for terminals which understand the X protocol. |
32179
15fe3fd7b8fc
(Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents:
31829
diff
changeset
|
2 Copyright (C) 1986, 88, 93, 94, 96, 99, 2000 Free Software Foundation, Inc. |
118 | 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 | |
1437
36ef55ecb265
* frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents:
1304
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
118 | 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. */ |
118 | 20 |
21 /* X pop-up deck-of-cards menu facility for gnuemacs. | |
22 * | |
23 * Written by Jon Arnold and Roman Budzianowski | |
24 * Mods and rewrite by Robert Krawitz | |
25 * | |
26 */ | |
27 | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
28 /* Modified by Fred Pierresteguy on December 93 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
29 to make the popup menus and menubar use the Xt. */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
30 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
31 /* Rewritten for clarity and GC protection by rms in Feb 94. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
32 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26036
diff
changeset
|
33 #include <config.h> |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26036
diff
changeset
|
34 |
118 | 35 /* On 4.3 this loses if it comes after xterm.h. */ |
36 #include <signal.h> | |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
37 |
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
38 #include <stdio.h> |
118 | 39 #include "lisp.h" |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
40 #include "termhooks.h" |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
41 #include "keyboard.h" |
770 | 42 #include "frame.h" |
118 | 43 #include "window.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
44 #include "blockinput.h" |
12661 | 45 #include "buffer.h" |
118 | 46 |
10502
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
47 #ifdef MSDOS |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
48 #include "msdos.h" |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
49 #endif |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
50 |
9572 | 51 #ifdef HAVE_X_WINDOWS |
118 | 52 /* This may include sys/types.h, and that somehow loses |
53 if this is not done before the other system files. */ | |
54 #include "xterm.h" | |
9572 | 55 #endif |
118 | 56 |
57 /* Load sys/types.h if not already loaded. | |
58 In some systems loading it twice is suicidal. */ | |
59 #ifndef makedev | |
60 #include <sys/types.h> | |
61 #endif | |
62 | |
63 #include "dispextern.h" | |
64 | |
9572 | 65 #ifdef HAVE_X_WINDOWS |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
66 #undef HAVE_MULTILINGUAL_MENU |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
67 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
68 #include <X11/Xlib.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
69 #include <X11/IntrinsicP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
70 #include <X11/CoreP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
71 #include <X11/StringDefs.h> |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
72 #include <X11/Shell.h> |
13489
ddf90bfd3744
Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents:
13071
diff
changeset
|
73 #ifdef USE_LUCID |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
74 #include <X11/Xaw/Paned.h> |
13489
ddf90bfd3744
Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents:
13071
diff
changeset
|
75 #endif /* USE_LUCID */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
76 #include "../lwlib/lwlib.h" |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
77 #else /* not USE_X_TOOLKIT */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
78 #include "../oldXMenu/XMenu.h" |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
79 #endif /* not USE_X_TOOLKIT */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
80 #endif /* HAVE_X_WINDOWS */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
81 |
24993 | 82 #ifdef USE_MOTIF |
83 #include <Xm/Xm.h> /* for LESSTIF_VERSION */ | |
84 #endif | |
85 | |
118 | 86 #define min(x,y) (((x) < (y)) ? (x) : (y)) |
87 #define max(x,y) (((x) > (y)) ? (x) : (y)) | |
88 | |
89 #ifndef TRUE | |
90 #define TRUE 1 | |
91 #define FALSE 0 | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
92 #endif /* no TRUE */ |
118 | 93 |
16656
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
94 Lisp_Object Vmenu_updating_frame; |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
95 |
12625
e2831d2f5b09
(syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents:
12432
diff
changeset
|
96 Lisp_Object Qdebug_on_next_call; |
e2831d2f5b09
(syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents:
12432
diff
changeset
|
97 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
98 extern Lisp_Object Qmenu_bar; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
99 extern Lisp_Object Qmouse_click, Qevent_kind; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
100 |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
101 extern Lisp_Object QCtoggle, QCradio; |
12298
7c4b729e4b21
(menu_item_equiv_key): Do reconsider a command that had
Richard M. Stallman <rms@gnu.org>
parents:
12196
diff
changeset
|
102 |
12661 | 103 extern Lisp_Object Voverriding_local_map; |
104 extern Lisp_Object Voverriding_local_map_menu_flag; | |
105 | |
106 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; | |
107 | |
108 extern Lisp_Object Qmenu_bar_update_hook; | |
109 | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
110 #ifdef USE_X_TOOLKIT |
12661 | 111 extern void set_frame_menubar (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
112 extern void process_expose_from_menu (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
113 extern XtAppContext Xt_app_con; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
114 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
115 static Lisp_Object xdialog_show (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
116 void popup_get_selection (); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
117 #endif |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
118 |
24993 | 119 #ifdef USE_X_TOOLKIT |
120 | |
121 /* Define HAVE_BOXES if meus can handle radio and toggle buttons. */ | |
122 | |
123 #define HAVE_BOXES 1 | |
124 #endif | |
125 | |
126 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, | |
127 Lisp_Object, Lisp_Object, Lisp_Object, | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
128 Lisp_Object, Lisp_Object)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
129 static Lisp_Object xmenu_show (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
130 static void keymap_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
131 static void single_keymap_panes (); |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
132 static void single_menu_item (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
133 static void list_of_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
134 static void list_of_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
135 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
136 /* This holds a Lisp vector that holds the results of decoding |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
137 the keymaps or alist-of-alists that specify a menu. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
138 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
139 It describes the panes and items within the panes. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
140 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
141 Each pane is described by 3 elements in the vector: |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
142 t, the pane name, the pane's prefix key. |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
143 Then follow the pane's items, with 5 elements per item: |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
144 the item string, the enable flag, the item's value, |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
145 the definition, and the equivalent keyboard key's description string. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
146 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
147 In some cases, multiple levels of menus may be described. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
148 A single vector slot containing nil indicates the start of a submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
149 A single vector slot containing lambda indicates the end of a submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
150 The submenu follows a menu item which is the way to reach the submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
151 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
152 A single vector slot containing quote indicates that the |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
153 following items should appear on the right of a dialog box. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
154 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
155 Using a Lisp vector to hold this information while we decode it |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
156 takes care of protecting all the data from GC. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
157 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
158 #define MENU_ITEMS_PANE_NAME 1 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
159 #define MENU_ITEMS_PANE_PREFIX 2 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
160 #define MENU_ITEMS_PANE_LENGTH 3 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
161 |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
162 enum menu_item_idx |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
163 { |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
164 MENU_ITEMS_ITEM_NAME = 0, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
165 MENU_ITEMS_ITEM_ENABLE, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
166 MENU_ITEMS_ITEM_VALUE, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
167 MENU_ITEMS_ITEM_EQUIV_KEY, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
168 MENU_ITEMS_ITEM_DEFINITION, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
169 MENU_ITEMS_ITEM_TYPE, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
170 MENU_ITEMS_ITEM_SELECTED, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
171 MENU_ITEMS_ITEM_HELP, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
172 MENU_ITEMS_ITEM_LENGTH |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
173 }; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
174 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
175 static Lisp_Object menu_items; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
176 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
177 /* Number of slots currently allocated in menu_items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
178 static int menu_items_allocated; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
179 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
180 /* This is the index in menu_items of the first empty slot. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
181 static int menu_items_used; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
182 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
183 /* The number of panes currently recorded in menu_items, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
184 excluding those within submenus. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
185 static int menu_items_n_panes; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
186 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
187 /* Current depth within submenus. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
188 static int menu_items_submenu_depth; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
189 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
190 /* Flag which when set indicates a dialog or menu has been posted by |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
191 Xt on behalf of one of the widget sets. */ |
27425
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
192 int popup_activated_flag; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
193 |
12661 | 194 static int next_menubar_widget_id; |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
195 |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
196 /* This is set nonzero after the user activates the menu bar, and set |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
197 to zero again after the menu bars are redisplayed by prepare_menu_bar. |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
198 While it is nonzero, all calls to set_frame_menubar go deep. |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
199 |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
200 I don't understand why this is needed, but it does seem to be |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
201 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */ |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
202 |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
203 int pending_menu_activation; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
204 |
12661 | 205 #ifdef USE_X_TOOLKIT |
206 | |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
207 /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
208 |
12661 | 209 static struct frame * |
210 menubar_id_to_frame (id) | |
211 LWLIB_ID id; | |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
212 { |
12661 | 213 Lisp_Object tail, frame; |
214 FRAME_PTR f; | |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
215 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
216 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
217 { |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
218 frame = XCAR (tail); |
12661 | 219 if (!GC_FRAMEP (frame)) |
220 continue; | |
221 f = XFRAME (frame); | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26088
diff
changeset
|
222 if (!FRAME_WINDOW_P (f)) |
12661 | 223 continue; |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
224 if (f->output_data.x->id == id) |
12661 | 225 return f; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
226 } |
12661 | 227 return 0; |
228 } | |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
229 |
12661 | 230 #endif |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
231 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
232 /* Initialize the menu_items structure if we haven't already done so. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
233 Also mark it as currently empty. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
234 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
235 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
236 init_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
237 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
238 if (NILP (menu_items)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
239 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
240 menu_items_allocated = 60; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
241 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
242 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
243 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
244 menu_items_used = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
245 menu_items_n_panes = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
246 menu_items_submenu_depth = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
247 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
248 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
249 /* Call at the end of generating the data in menu_items. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
250 This fills in the number of items in the last pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
251 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
252 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
253 finish_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
254 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
255 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
256 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
257 /* Call when finished using the data for the current menu |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
258 in menu_items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
259 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
260 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
261 discard_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
262 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
263 /* Free the structure if it is especially large. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
264 Otherwise, hold on to it, to save time. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
265 if (menu_items_allocated > 200) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
266 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
267 menu_items = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
268 menu_items_allocated = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
269 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
270 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
271 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
272 /* Make the menu_items vector twice as large. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
273 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
274 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
275 grow_menu_items () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
276 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
277 Lisp_Object old; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
278 int old_size = menu_items_allocated; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
279 old = menu_items; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
280 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
281 menu_items_allocated *= 2; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
282 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
283 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
284 old_size * sizeof (Lisp_Object)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
285 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
286 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
287 /* Begin a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
288 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
289 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
290 push_submenu_start () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
291 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
292 if (menu_items_used + 1 > menu_items_allocated) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
293 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
294 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
295 XVECTOR (menu_items)->contents[menu_items_used++] = Qnil; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
296 menu_items_submenu_depth++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
297 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
298 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
299 /* End a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
300 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
301 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
302 push_submenu_end () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
303 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
304 if (menu_items_used + 1 > menu_items_allocated) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
305 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
306 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
307 XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
308 menu_items_submenu_depth--; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
309 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
310 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
311 /* Indicate boundary between left and right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
312 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
313 static void |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
314 push_left_right_boundary () |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
315 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
316 if (menu_items_used + 1 > menu_items_allocated) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
317 grow_menu_items (); |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
318 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
319 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
320 } |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
321 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
322 /* Start a new menu pane in menu_items.. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
323 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
324 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
325 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
326 push_menu_pane (name, prefix_vec) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
327 Lisp_Object name, prefix_vec; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
328 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
329 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
330 grow_menu_items (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
331 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
332 if (menu_items_submenu_depth == 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
333 menu_items_n_panes++; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
334 XVECTOR (menu_items)->contents[menu_items_used++] = Qt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
335 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
336 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
337 } |
118 | 338 |
24993 | 339 /* Push one menu item into the current pane. NAME is the string to |
340 display. ENABLE if non-nil means this item can be selected. KEY | |
341 is the key generated by choosing this item, or nil if this item | |
342 doesn't really have a definition. DEF is the definition of this | |
343 item. EQUIV is the textual description of the keyboard equivalent | |
344 for this item (or nil if none). TYPE is the type of this menu | |
345 item, one of nil, `toggle' or `radio'. */ | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
346 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
347 static void |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
348 push_menu_item (name, enable, key, def, equiv, type, selected, help) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
349 Lisp_Object name, enable, key, def, equiv, type, selected, help; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
350 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
351 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
352 grow_menu_items (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
353 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
354 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
355 XVECTOR (menu_items)->contents[menu_items_used++] = enable; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
356 XVECTOR (menu_items)->contents[menu_items_used++] = key; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
357 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
358 XVECTOR (menu_items)->contents[menu_items_used++] = def; |
24993 | 359 XVECTOR (menu_items)->contents[menu_items_used++] = type; |
360 XVECTOR (menu_items)->contents[menu_items_used++] = selected; | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
361 XVECTOR (menu_items)->contents[menu_items_used++] = help; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
362 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
363 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
364 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long, |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
365 and generate menu panes for them in menu_items. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
366 If NOTREAL is nonzero, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
367 don't bother really computing whether an item is enabled. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
368 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
369 static void |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
370 keymap_panes (keymaps, nmaps, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
371 Lisp_Object *keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
372 int nmaps; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
373 int notreal; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
374 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
375 int mapno; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
376 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
377 init_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
378 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
379 /* Loop over the given keymaps, making a pane for each map. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
380 But don't make a pane that is empty--ignore that map instead. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
381 P is the number of panes we have made so far. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
382 for (mapno = 0; mapno < nmaps; mapno++) |
30420
3ed29d254c6c
(keymap_panes): Pass the keymap's prompt as the pane
Eli Zaretskii <eliz@gnu.org>
parents:
30363
diff
changeset
|
383 single_keymap_panes (keymaps[mapno], |
3ed29d254c6c
(keymap_panes): Pass the keymap's prompt as the pane
Eli Zaretskii <eliz@gnu.org>
parents:
30363
diff
changeset
|
384 map_prompt (keymaps[mapno]), Qnil, notreal, 10); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
385 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
386 finish_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
387 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
388 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
389 /* This is a recursive subroutine of keymap_panes. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
390 It handles one keymap, KEYMAP. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
391 The other arguments are passed along |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
392 or point to local variables of the previous function. |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
393 If NOTREAL is nonzero, only check for equivalent key bindings, don't |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
394 evaluate expressions in menu items and don't make any menu. |
16752
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
395 |
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
396 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
397 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
398 static void |
16752
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
399 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
400 Lisp_Object keymap; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
401 Lisp_Object pane_name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
402 Lisp_Object prefix; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
403 int notreal; |
16752
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
404 int maxdepth; |
118 | 405 { |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
406 Lisp_Object pending_maps = Qnil; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
407 Lisp_Object tail, item; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
408 struct gcpro gcpro1, gcpro2; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
409 int notbuttons = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
410 |
16752
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
411 if (maxdepth <= 0) |
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
412 return; |
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
413 |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
414 push_menu_pane (pane_name, prefix); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
415 |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
416 #ifndef HAVE_BOXES |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
417 /* Remember index for first item in this pane so we can go back and |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
418 add a prefix when (if) we see the first button. After that, notbuttons |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
419 is set to 0, to mark that we have seen a button and all non button |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
420 items need a prefix. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
421 notbuttons = menu_items_used; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
422 #endif |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
423 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
424 for (tail = keymap; CONSP (tail); tail = XCDR (tail)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
425 { |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
426 GCPRO2 (keymap, pending_maps); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
427 /* Look at each key binding, and if it is a menu item add it |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
428 to this menu. */ |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
429 item = XCAR (tail); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
430 if (CONSP (item)) |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
431 single_menu_item (XCAR (item), XCDR (item), |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
432 &pending_maps, notreal, maxdepth, ¬buttons); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
433 else if (VECTORP (item)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
434 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
435 /* Loop over the char values represented in the vector. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
436 int len = XVECTOR (item)->size; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
437 int c; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
438 for (c = 0; c < len; c++) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
439 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
440 Lisp_Object character; |
9341
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
441 XSETFASTINT (character, c); |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
442 single_menu_item (character, XVECTOR (item)->contents[c], |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
443 &pending_maps, notreal, maxdepth, ¬buttons); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
444 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
445 } |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
446 UNGCPRO; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
447 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
448 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
449 /* Process now any submenus which want to be panes at this level. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
450 while (!NILP (pending_maps)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
451 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
452 Lisp_Object elt, eltcdr, string; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
453 elt = Fcar (pending_maps); |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
454 eltcdr = XCDR (elt); |
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
455 string = XCAR (eltcdr); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
456 /* We no longer discard the @ from the beginning of the string here. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
457 Instead, we do this in xmenu_show. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
458 single_keymap_panes (Fcar (elt), string, |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
25322
diff
changeset
|
459 XCDR (eltcdr), notreal, maxdepth - 1); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
460 pending_maps = Fcdr (pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
461 } |
118 | 462 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
463 |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
464 /* This is a subroutine of single_keymap_panes that handles one |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
465 keymap entry. |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
466 KEY is a key in a keymap and ITEM is its binding. |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
467 PENDING_MAPS_PTR points to a list of keymaps waiting to be made into |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
468 separate panes. |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
469 If NOTREAL is nonzero, only check for equivalent key bindings, don't |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
470 evaluate expressions in menu items and don't make any menu. |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
471 If we encounter submenus deeper than MAXDEPTH levels, ignore them. |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
472 NOTBUTTONS_PTR is only used when simulating toggle boxes and radio |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
473 buttons. It points to variable notbuttons in single_keymap_panes, |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
474 which keeps track of if we have seen a button in this menu or not. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
475 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
476 static void |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
477 single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth, |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
478 notbuttons_ptr) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
479 Lisp_Object key, item; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
480 Lisp_Object *pending_maps_ptr; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
481 int maxdepth, notreal; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
482 int *notbuttons_ptr; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
483 { |
25730
db88a4b84d91
(single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents:
25680
diff
changeset
|
484 Lisp_Object map, item_string, enabled; |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
485 struct gcpro gcpro1, gcpro2; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
486 int res; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
487 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
488 /* Parse the menu item and leave the result in item_properties. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
489 GCPRO2 (key, item); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
490 res = parse_menu_item (item, notreal, 0); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
491 UNGCPRO; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
492 if (!res) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
493 return; /* Not a menu item. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
494 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
495 map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
496 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
497 if (notreal) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
498 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
499 /* We don't want to make a menu, just traverse the keymaps to |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
500 precompute equivalent key bindings. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
501 if (!NILP (map)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
502 single_keymap_panes (map, Qnil, key, 1, maxdepth - 1); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
503 return; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
504 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
505 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
506 enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
507 item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
508 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
509 if (!NILP (map) && XSTRING (item_string)->data[0] == '@') |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
510 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
511 if (!NILP (enabled)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
512 /* An enabled separate pane. Remember this to handle it later. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
513 *pending_maps_ptr = Fcons (Fcons (map, Fcons (item_string, key)), |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
514 *pending_maps_ptr); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
515 return; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
516 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
517 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
518 #ifndef HAVE_BOXES |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
519 /* Simulate radio buttons and toggle boxes by putting a prefix in |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
520 front of them. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
521 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
522 Lisp_Object prefix = Qnil; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
523 Lisp_Object type = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
524 if (!NILP (type)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
525 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
526 Lisp_Object selected |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
527 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
528 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
529 if (*notbuttons_ptr) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
530 /* The first button. Line up previous items in this menu. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
531 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
532 int index = *notbuttons_ptr; /* Index for first item this menu. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
533 int submenu = 0; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
534 Lisp_Object tem; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
535 while (index < menu_items_used) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
536 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
537 tem |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
538 = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
539 if (NILP (tem)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
540 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
541 index++; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
542 submenu++; /* Skip sub menu. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
543 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
544 else if (EQ (tem, Qlambda)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
545 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
546 index++; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
547 submenu--; /* End sub menu. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
548 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
549 else if (EQ (tem, Qt)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
550 index += 3; /* Skip new pane marker. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
551 else if (EQ (tem, Qquote)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
552 index++; /* Skip a left, right divider. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
553 else |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
554 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
555 if (!submenu && XSTRING (tem)->data[0] != '\0' |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
556 && XSTRING (tem)->data[0] != '-') |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
557 XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME] |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
558 = concat2 (build_string (" "), tem); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
559 index += MENU_ITEMS_ITEM_LENGTH; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
560 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
561 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
562 *notbuttons_ptr = 0; |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
563 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
564 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
565 /* Calculate prefix, if any, for this item. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
566 if (EQ (type, QCtoggle)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
567 prefix = build_string (NILP (selected) ? "[ ] " : "[X] "); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
568 else if (EQ (type, QCradio)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
569 prefix = build_string (NILP (selected) ? "( ) " : "(*) "); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
570 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
571 /* Not a button. If we have earlier buttons, then we need a prefix. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
572 else if (!*notbuttons_ptr && XSTRING (item_string)->data[0] != '\0' |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
573 && XSTRING (item_string)->data[0] != '-') |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
574 prefix = build_string (" "); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
575 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
576 if (!NILP (prefix)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
577 item_string = concat2 (prefix, item_string); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
578 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
579 #endif /* not HAVE_BOXES */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
580 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
581 #ifndef USE_X_TOOLKIT |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
582 if (!NILP(map)) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
583 /* Indicate visually that this is a submenu. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
584 item_string = concat2 (item_string, build_string (" >")); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
585 #endif |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
586 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
587 push_menu_item (item_string, enabled, key, |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
588 XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], |
24993 | 589 XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], |
590 XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE], | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
591 XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
592 XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); |
21242
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
593 |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
594 #ifdef USE_X_TOOLKIT |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
595 /* Display a submenu using the toolkit. */ |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
596 if (! (NILP (map) || NILP (enabled))) |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
597 { |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
598 push_submenu_start (); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
599 single_keymap_panes (map, Qnil, key, 0, maxdepth - 1); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
600 push_submenu_end (); |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
601 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
602 #endif |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
603 } |
10e1764f84b8
Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents:
21178
diff
changeset
|
604 |
14036 | 605 /* Push all the panes and items of a menu described by the |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
606 alist-of-alists MENU. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
607 This handles old-fashioned calls to x-popup-menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
608 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
609 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
610 list_of_panes (menu) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
611 Lisp_Object menu; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
612 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
613 Lisp_Object tail; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
614 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
615 init_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
616 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
617 for (tail = menu; !NILP (tail); tail = Fcdr (tail)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
618 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
619 Lisp_Object elt, pane_name, pane_data; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
620 elt = Fcar (tail); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
621 pane_name = Fcar (elt); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
622 CHECK_STRING (pane_name, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
623 push_menu_pane (pane_name, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
624 pane_data = Fcdr (elt); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
625 CHECK_CONS (pane_data, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
626 list_of_items (pane_data); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
627 } |
118 | 628 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
629 finish_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
630 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
631 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
632 /* Push the items in a single pane defined by the alist PANE. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
633 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
634 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
635 list_of_items (pane) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
636 Lisp_Object pane; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
637 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
638 Lisp_Object tail, item, item1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
639 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
640 for (tail = pane; !NILP (tail); tail = Fcdr (tail)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
641 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
642 item = Fcar (tail); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
643 if (STRINGP (item)) |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
644 push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil); |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
645 else if (NILP (item)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
646 push_left_right_boundary (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
647 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
648 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
649 CHECK_CONS (item, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
650 item1 = Fcar (item); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
651 CHECK_STRING (item1, 1); |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
652 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
653 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
654 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
655 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
656 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
657 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, |
118 | 658 "Pop up a deck-of-cards menu and return user's selection.\n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
659 POSITION is a position specification. This is either a mouse button event\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
660 or a list ((XOFFSET YOFFSET) WINDOW)\n\ |
7175
5fa65268508b
(Fx_popup_menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7129
diff
changeset
|
661 where XOFFSET and YOFFSET are positions in pixels from the top left\n\ |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
662 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\ |
118 | 663 This controls the position of the center of the first line\n\ |
664 in the first pane of the menu, not the top left of the menu as a whole.\n\ | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
665 If POSITION is t, it means to use the current mouse position.\n\ |
118 | 666 \n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
667 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
668 The menu items come from key bindings that have a menu string as well as\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
669 a definition; actually, the \"definition\" in such a key binding looks like\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
670 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
671 the keymap as a top-level element.\n\n\ |
17709
c93b19665c14
(Fx_popup_menu): Do fix.
Richard M. Stallman <rms@gnu.org>
parents:
17554
diff
changeset
|
672 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.\n\ |
c93b19665c14
(Fx_popup_menu): Do fix.
Richard M. Stallman <rms@gnu.org>
parents:
17554
diff
changeset
|
673 Otherwise, REAL-DEFINITION should be a valid key binding definition.\n\ |
c93b19665c14
(Fx_popup_menu): Do fix.
Richard M. Stallman <rms@gnu.org>
parents:
17554
diff
changeset
|
674 \n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
675 You can also use a list of keymaps as MENU.\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
676 Then each keymap makes a separate pane.\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
677 When MENU is a keymap or a list of keymaps, the return value\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
678 is a list of events.\n\n\ |
17709
c93b19665c14
(Fx_popup_menu): Do fix.
Richard M. Stallman <rms@gnu.org>
parents:
17554
diff
changeset
|
679 \n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
680 Alternatively, you can specify a menu of multiple panes\n\ |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
681 with a list of the form (TITLE PANE1 PANE2...),\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
682 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
683 Each ITEM is normally a cons cell (STRING . VALUE);\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
684 but a string can appear as an item--that makes a nonselectable line\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
685 in the menu.\n\ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
686 With this form of menu, the return value is VALUE from the chosen item.\n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
687 \n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
688 If POSITION is nil, don't display the menu at all, just precalculate the\n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
689 cached information about equivalent key sequences.") |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
690 (position, menu) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
691 Lisp_Object position, menu; |
118 | 692 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
693 Lisp_Object keymap, tem; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31465
diff
changeset
|
694 int xpos = 0, ypos = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
695 Lisp_Object title; |
118 | 696 char *error_name; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
697 Lisp_Object selection; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31465
diff
changeset
|
698 struct frame *f = NULL; |
118 | 699 Lisp_Object x, y, window; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
700 int keymaps = 0; |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
701 int for_click = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
702 struct gcpro gcpro1; |
118 | 703 |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
704 #ifdef HAVE_MENUS |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
705 if (! NILP (position)) |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
706 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
707 check_x (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
708 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
709 /* Decode the first argument: find the window and the coordinates. */ |
11614
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
710 if (EQ (position, Qt) |
32179
15fe3fd7b8fc
(Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents:
31829
diff
changeset
|
711 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) |
15fe3fd7b8fc
(Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents:
31829
diff
changeset
|
712 || EQ (XCAR (position), Qtool_bar)))) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
713 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
714 /* Use the mouse's current position. */ |
25680
841eb01263ef
(Fx_popup_menu): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25646
diff
changeset
|
715 FRAME_PTR new_f = SELECTED_FRAME (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
716 Lisp_Object bar_window; |
21514 | 717 enum scroll_bar_part part; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
718 unsigned long time; |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
719 |
7334
fcea4173315d
(Fx_popup_menu): Restore accidentally-deleted call to mouse_position_hook.
Karl Heuer <kwzh@gnu.org>
parents:
7208
diff
changeset
|
720 if (mouse_position_hook) |
11125
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
721 (*mouse_position_hook) (&new_f, 1, &bar_window, |
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
722 &part, &x, &y, &time); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
723 if (new_f != 0) |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
724 XSETFRAME (window, new_f); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
725 else |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
726 { |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
727 window = selected_window; |
9341
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
728 XSETFASTINT (x, 0); |
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
729 XSETFASTINT (y, 0); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
730 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
731 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
732 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
733 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
734 tem = Fcar (position); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
735 if (CONSP (tem)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
736 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
737 window = Fcar (Fcdr (position)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
738 x = Fcar (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
739 y = Fcar (Fcdr (tem)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
740 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
741 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
742 { |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
743 for_click = 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
744 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
745 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
746 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
747 x = Fcar (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
748 y = Fcdr (tem); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
749 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
750 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
751 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
752 CHECK_NUMBER (x, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
753 CHECK_NUMBER (y, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
754 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
755 /* Decode where to put the menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
756 |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
757 if (FRAMEP (window)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
758 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
759 f = XFRAME (window); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
760 xpos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
761 ypos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
762 } |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
763 else if (WINDOWP (window)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
764 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
765 CHECK_LIVE_WINDOW (window, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
766 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
767 |
17364
573189779804
(Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents:
16752
diff
changeset
|
768 xpos = (FONT_WIDTH (f->output_data.x->font) |
573189779804
(Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents:
16752
diff
changeset
|
769 * XFASTINT (XWINDOW (window)->left)); |
573189779804
(Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents:
16752
diff
changeset
|
770 ypos = (f->output_data.x->line_height |
573189779804
(Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents:
16752
diff
changeset
|
771 * XFASTINT (XWINDOW (window)->top)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
772 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
773 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
774 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
775 but I don't want to make one now. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
776 CHECK_WINDOW (window, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
777 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
778 xpos += XINT (x); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
779 ypos += XINT (y); |
16656
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
780 |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
781 XSETFRAME (Vmenu_updating_frame, f); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
782 } |
16656
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
783 Vmenu_updating_frame = Qnil; |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
784 #endif /* HAVE_MENUS */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
785 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
786 title = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
787 GCPRO1 (title); |
4627
340c18d50337
(Fx_popup_menu): Adjust coords so they are relative to the inner window.
Richard M. Stallman <rms@gnu.org>
parents:
3747
diff
changeset
|
788 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
789 /* Decode the menu items from what was specified. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
790 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
791 keymap = get_keymap (menu, 0, 0); |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
792 if (CONSP (keymap)) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
793 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
794 /* We were given a keymap. Extract menu info from the keymap. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
795 Lisp_Object prompt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
796 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
797 /* Extract the detailed info to make one pane. */ |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
798 keymap_panes (&menu, 1, NILP (position)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
799 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
800 /* Search for a string appearing directly as an element of the keymap. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
801 That string is the title of the menu. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
802 prompt = map_prompt (keymap); |
16411
939831bf2103
(Fx_popup_menu): Give the menu a title when the menu is a single keymap.
Richard M. Stallman <rms@gnu.org>
parents:
15943
diff
changeset
|
803 if (NILP (title) && !NILP (prompt)) |
939831bf2103
(Fx_popup_menu): Give the menu a title when the menu is a single keymap.
Richard M. Stallman <rms@gnu.org>
parents:
15943
diff
changeset
|
804 title = prompt; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
805 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
806 /* Make that be the pane title of the first pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
807 if (!NILP (prompt) && menu_items_n_panes >= 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
808 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
809 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
810 keymaps = 1; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
811 } |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
812 else if (CONSP (menu) && KEYMAPP (XCAR (menu))) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
813 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
814 /* We were given a list of keymaps. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
815 int nmaps = XFASTINT (Flength (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
816 Lisp_Object *maps |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
817 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
818 int i; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
819 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
820 title = Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
821 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
822 /* The first keymap that has a prompt string |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
823 supplies the menu title. */ |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
824 for (tem = menu, i = 0; CONSP (tem); tem = Fcdr (tem)) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
825 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
826 Lisp_Object prompt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
827 |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
828 maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0); |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
829 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
830 prompt = map_prompt (keymap); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
831 if (NILP (title) && !NILP (prompt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
832 title = prompt; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
833 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
834 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
835 /* Extract the detailed info to make one pane. */ |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
836 keymap_panes (maps, nmaps, NILP (position)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
837 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
838 /* Make the title be the pane title of the first pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
839 if (!NILP (title) && menu_items_n_panes >= 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
840 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
841 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
842 keymaps = 1; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
843 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
844 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
845 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
846 /* We were given an old-fashioned menu. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
847 title = Fcar (menu); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
848 CHECK_STRING (title, 1); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
849 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
850 list_of_panes (Fcdr (menu)); |
1828
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
851 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
852 keymaps = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
853 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
854 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
855 if (NILP (position)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
856 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
857 discard_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
858 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
859 return Qnil; |
118 | 860 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
861 |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
862 #ifdef HAVE_MENUS |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
863 /* Display them in a menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
864 BLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
865 |
11491
272baf4a077a
(xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents:
11449
diff
changeset
|
866 selection = xmenu_show (f, xpos, ypos, for_click, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
867 keymaps, title, &error_name); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
868 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
869 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
870 discard_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
871 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
872 UNGCPRO; |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
873 #endif /* HAVE_MENUS */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
874 |
118 | 875 if (error_name) error (error_name); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
876 return selection; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
877 } |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
878 |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
879 #ifdef HAVE_MENUS |
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
880 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
881 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0, |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
882 "Pop up a dialog box and return user's selection.\n\ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
883 POSITION specifies which frame to use.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
884 This is normally a mouse button event or a window or frame.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
885 If POSITION is t, it means to use the frame the mouse is on.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
886 The dialog box appears in the middle of the specified frame.\n\ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
887 \n\ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
888 CONTENTS specifies the alternatives to display in the dialog box.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
889 It is a list of the form (TITLE ITEM1 ITEM2...).\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
890 Each ITEM is a cons cell (STRING . VALUE).\n\ |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
891 The return value is VALUE from the chosen item.\n\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
892 An ITEM may also be just a string--that makes a nonselectable item.\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
893 An ITEM may also be nil--that means to put all preceding items\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
894 on the left of the dialog box and all following items on the right.\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
895 \(By default, approximately half appear on each side.)") |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
896 (position, contents) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
897 Lisp_Object position, contents; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
898 { |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31465
diff
changeset
|
899 struct frame * f = NULL; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
900 Lisp_Object window; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
901 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
902 check_x (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
903 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
904 /* Decode the first argument: find the window or frame to use. */ |
11907
0f03ad1cac1e
(Fx_popup_dialog): Treat (menu-bar) like t, for POSITION.
Karl Heuer <kwzh@gnu.org>
parents:
11898
diff
changeset
|
905 if (EQ (position, Qt) |
32179
15fe3fd7b8fc
(Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents:
31829
diff
changeset
|
906 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) |
15fe3fd7b8fc
(Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents:
31829
diff
changeset
|
907 || EQ (XCAR (position), Qtool_bar)))) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
908 { |
6653
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
909 #if 0 /* Using the frame the mouse is on may not be right. */ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
910 /* Use the mouse's current position. */ |
25680
841eb01263ef
(Fx_popup_menu): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25646
diff
changeset
|
911 FRAME_PTR new_f = SELECTED_FRAME (); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
912 Lisp_Object bar_window; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
913 int part; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
914 unsigned long time; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
915 Lisp_Object x, y; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
916 |
11125
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
917 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
918 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
919 if (new_f != 0) |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
920 XSETFRAME (window, new_f); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
921 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
922 window = selected_window; |
6653
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
923 #endif |
11907
0f03ad1cac1e
(Fx_popup_dialog): Treat (menu-bar) like t, for POSITION.
Karl Heuer <kwzh@gnu.org>
parents:
11898
diff
changeset
|
924 window = selected_window; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
925 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
926 else if (CONSP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
927 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
928 Lisp_Object tem; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
929 tem = Fcar (position); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
930 if (CONSP (tem)) |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
931 window = Fcar (Fcdr (position)); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
932 else |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
933 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
934 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
935 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
936 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
937 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
938 else if (WINDOWP (position) || FRAMEP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
939 window = position; |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
940 else |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
941 window = Qnil; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
942 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
943 /* Decode where to put the menu. */ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
944 |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
945 if (FRAMEP (window)) |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
946 f = XFRAME (window); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
947 else if (WINDOWP (window)) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
948 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
949 CHECK_LIVE_WINDOW (window, 0); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
950 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
951 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
952 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
953 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
954 but I don't want to make one now. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
955 CHECK_WINDOW (window, 0); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
956 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
957 #ifndef USE_X_TOOLKIT |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
958 /* Display a menu with these alternatives |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
959 in the middle of frame F. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
960 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
961 Lisp_Object x, y, frame, newpos; |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
962 XSETFRAME (frame, f); |
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
963 XSETINT (x, x_pixel_width (f) / 2); |
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
964 XSETINT (y, x_pixel_height (f) / 2); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
965 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil)); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
966 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
967 return Fx_popup_menu (newpos, |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
968 Fcons (Fcar (contents), Fcons (contents, Qnil))); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
969 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
970 #else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
971 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
972 Lisp_Object title; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
973 char *error_name; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
974 Lisp_Object selection; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
975 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
976 /* Decode the dialog items from what was specified. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
977 title = Fcar (contents); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
978 CHECK_STRING (title, 1); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
979 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
980 list_of_panes (Fcons (contents, Qnil)); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
981 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
982 /* Display them in a dialog box. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
983 BLOCK_INPUT; |
11502
7ecd4aa33faa
(Fx_popup_dialog): Don't pass menubarp arg to xdialog_show.
Karl Heuer <kwzh@gnu.org>
parents:
11491
diff
changeset
|
984 selection = xdialog_show (f, 0, title, &error_name); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
985 UNBLOCK_INPUT; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
986 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
987 discard_menu_items (); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
988 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
989 if (error_name) error (error_name); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
990 return selection; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
991 } |
6325
d6817c9c0413
Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents:
6324
diff
changeset
|
992 #endif |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
993 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
994 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
995 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
996 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
997 /* Loop in Xt until the menu pulldown or dialog popup has been |
13821 | 998 popped down (deactivated). This is used for x-popup-menu |
999 and x-popup-dialog; it is not used for the menu bar any more. | |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1000 |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1001 NOTE: All calls to popup_get_selection should be protected |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1002 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1003 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1004 void |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1005 popup_get_selection (initial_event, dpyinfo, id) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1006 XEvent *initial_event; |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1007 struct x_display_info *dpyinfo; |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1008 LWLIB_ID id; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1009 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1010 XEvent event; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1011 |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1012 /* Define a queue to save up for later unreading |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1013 all X events that don't pertain to the menu. */ |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1014 struct event_queue |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1015 { |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1016 XEvent event; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1017 struct event_queue *next; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1018 }; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1019 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1020 struct event_queue *queue = NULL; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1021 struct event_queue *queue_tmp; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1022 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1023 if (initial_event) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1024 event = *initial_event; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1025 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1026 XtAppNextEvent (Xt_app_con, &event); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1027 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1028 while (1) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1029 { |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1030 /* Handle expose events for editor frames right away. */ |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1031 if (event.type == Expose) |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1032 process_expose_from_menu (event); |
15628
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1033 /* Make sure we don't consider buttons grabbed after menu goes. |
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1034 And make sure to deactivate for any ButtonRelease, |
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1035 even if XtDispatchEvent doesn't do that. */ |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1036 else if (event.type == ButtonRelease |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1037 && dpyinfo->display == event.xbutton.display) |
15628
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1038 { |
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1039 dpyinfo->grabbed &= ~(1 << event.xbutton.button); |
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1040 popup_activated_flag = 0; |
15839
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1041 #ifdef USE_MOTIF /* Pretending that the event came from a |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1042 Btn1Down seems the only way to convince Motif to |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1043 activate its callbacks; setting the XmNmenuPost |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1044 isn't working. --marcus@sysc.pdx.edu. */ |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1045 event.xbutton.button = 1; |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1046 #endif |
15628
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1047 } |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1048 /* If the user presses a key, deactivate the menu. |
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1049 The user is likely to do that if we get wedged. */ |
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1050 else if (event.type == KeyPress |
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1051 && dpyinfo->display == event.xbutton.display) |
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1052 { |
21268
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1053 KeySym keysym = XLookupKeysym (&event.xkey, 0); |
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1054 if (!IsModifierKey (keysym)) |
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1055 { |
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1056 popup_activated_flag = 0; |
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1057 break; |
74fc1642fe30
(popup_get_selection): On receiving a KeyPress event
Andreas Schwab <schwab@suse.de>
parents:
21244
diff
changeset
|
1058 } |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
1059 } |
13071
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1060 /* Button presses outside the menu also pop it down. */ |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1061 else if (event.type == ButtonPress |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1062 && event.xany.display == dpyinfo->display |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1063 && x_any_window_to_frame (dpyinfo, event.xany.window)) |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1064 { |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1065 popup_activated_flag = 0; |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1066 break; |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
1067 } |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1068 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1069 /* Queue all events not for this popup, |
15628
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1070 except for Expose, which we've already handled, and ButtonRelease. |
11614
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1071 Note that the X window is associated with the frame if this |
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1072 is a menu bar popup, but not if it's a dialog box. So we use |
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1073 x_non_menubar_window_to_frame, not x_any_window_to_frame. */ |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1074 if (event.type != Expose |
15628
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1075 && !(event.type == ButtonRelease |
f74c79dcaf8d
(popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents:
15428
diff
changeset
|
1076 && dpyinfo->display == event.xbutton.display) |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1077 && (event.xany.display != dpyinfo->display |
11614
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1078 || x_non_menubar_window_to_frame (dpyinfo, event.xany.window))) |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1079 { |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1080 queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue)); |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1081 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1082 if (queue_tmp != NULL) |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1083 { |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1084 queue_tmp->event = event; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1085 queue_tmp->next = queue; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1086 queue = queue_tmp; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1087 } |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1088 } |
11614
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1089 else |
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
1090 XtDispatchEvent (&event); |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1091 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1092 if (!popup_activated ()) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1093 break; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1094 XtAppNextEvent (Xt_app_con, &event); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1095 } |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1096 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1097 /* Unread any events that we got but did not handle. */ |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1098 while (queue != NULL) |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1099 { |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1100 queue_tmp = queue; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1101 XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event); |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1102 queue = queue_tmp->next; |
30604
07c39ec7b96b
(popup_get_selection): Use xfree instead of free.
Gerd Moellmann <gerd@gnu.org>
parents:
30574
diff
changeset
|
1103 xfree ((char *)queue_tmp); |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1104 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1105 interrupt_input_pending = 1; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1106 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1107 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1108 |
12661 | 1109 /* Activate the menu bar of frame F. |
1110 This is called from keyboard.c when it gets the | |
1111 menu_bar_activate_event out of the Emacs event queue. | |
1112 | |
1113 To activate the menu bar, we use the X button-press event | |
15710
85d87cd0f655
(x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents:
15628
diff
changeset
|
1114 that was saved in saved_menu_event. |
12661 | 1115 That makes the toolkit do its thing. |
1116 | |
1117 But first we recompute the menu bar contents (the whole tree). | |
1118 | |
1119 The reason for saving the button event until here, instead of | |
1120 passing it to the toolkit right away, is that we can safely | |
1121 execute Lisp code. */ | |
1122 | |
21514 | 1123 void |
12661 | 1124 x_activate_menubar (f) |
1125 FRAME_PTR f; | |
1126 { | |
15710
85d87cd0f655
(x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents:
15628
diff
changeset
|
1127 if (!f->output_data.x->saved_menu_event->type) |
12661 | 1128 return; |
1129 | |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1130 set_frame_menubar (f, 0, 1); |
12661 | 1131 BLOCK_INPUT; |
15710
85d87cd0f655
(x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents:
15628
diff
changeset
|
1132 XtDispatchEvent ((XEvent *) f->output_data.x->saved_menu_event); |
12661 | 1133 UNBLOCK_INPUT; |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1134 #ifdef USE_MOTIF |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1135 if (f->output_data.x->saved_menu_event->type == ButtonRelease) |
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1136 pending_menu_activation = 1; |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1137 #endif |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1138 |
12661 | 1139 /* Ignore this if we get it a second time. */ |
15710
85d87cd0f655
(x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents:
15628
diff
changeset
|
1140 f->output_data.x->saved_menu_event->type = 0; |
12661 | 1141 } |
1142 | |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1143 /* Detect if a dialog or menu has been posted. */ |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1144 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1145 int |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1146 popup_activated () |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1147 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1148 return popup_activated_flag; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1149 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1150 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1151 /* This callback is invoked when the user selects a menubar cascade |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1152 pushbutton, but before the pulldown menu is posted. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1153 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1154 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1155 popup_activate_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1156 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1157 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1158 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1159 { |
27425
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1160 #ifdef USE_MOTIF |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1161 ++popup_activated_flag; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1162 #else |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1163 popup_activated_flag = 1; |
27425
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1164 #endif |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1165 } |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1166 |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1167 /* This callback is invoked when a dialog or menu is finished being |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1168 used and has been unposted. */ |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1169 |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1170 static void |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1171 popup_deactivate_callback (widget, id, client_data) |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1172 Widget widget; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1173 LWLIB_ID id; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1174 XtPointer client_data; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1175 { |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1176 #ifdef USE_MOTIF |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1177 --popup_activated_flag; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1178 #else |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1179 popup_activated_flag = 0; |
e575223479a1
(popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents:
27341
diff
changeset
|
1180 #endif |
118 | 1181 } |
1182 | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1183 /* Lwlib callback called when menu items are highlighted/unhighlighted |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1184 while moving the mouse over them. WIDGET is the menu bar or menu |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1185 popup widget. ID is its LWLIB_ID. CALL_DATA contains a pointer to |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1186 the widget_value structure for the menu item, or null in case of |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1187 unhighlighting. */ |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1188 |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1189 void |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1190 menu_highlight_callback (widget, id, call_data) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1191 Widget widget; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1192 LWLIB_ID id; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1193 void *call_data; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1194 { |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1195 widget_value *wv = (widget_value *) call_data; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1196 struct frame *f; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1197 Lisp_Object frame, help; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1198 |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1199 help = wv && wv->help ? build_string (wv->help) : Qnil; |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1200 |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1201 /* Determine the frame for the help event. */ |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1202 f = menubar_id_to_frame (id); |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1203 if (f) |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1204 { |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1205 XSETFRAME (frame, f); |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1206 kbd_buffer_store_help_event (frame, help); |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1207 } |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1208 else |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1209 { |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1210 /* WIDGET is the popup menu. It's parent is the frame's |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1211 widget. See which frame that is. */ |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1212 Widget frame_widget = XtParent (widget); |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1213 Lisp_Object tail; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1214 |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1215 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1216 { |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1217 frame = XCAR (tail); |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1218 if (GC_FRAMEP (frame) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1219 && (f = XFRAME (frame), |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1220 FRAME_X_P (f) && f->output_data.x->widget == frame_widget)) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1221 break; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1222 } |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1223 |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
1224 show_help_echo (help, Qnil, Qnil, Qnil, 1); |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1225 } |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1226 } |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1227 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1228 /* This callback is called from the menu bar pulldown menu |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1229 when the user makes a selection. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1230 Figure out what the user chose |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1231 and put the appropriate events into the keyboard buffer. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1232 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1233 static void |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1234 menubar_selection_callback (widget, id, client_data) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1235 Widget widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1236 LWLIB_ID id; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1237 XtPointer client_data; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1238 { |
11655
a9f93ce6e1b4
(xmenu_show, menubar_selection_callback): Move declaration
Karl Heuer <kwzh@gnu.org>
parents:
11614
diff
changeset
|
1239 Lisp_Object prefix, entry; |
12661 | 1240 FRAME_PTR f = menubar_id_to_frame (id); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1241 Lisp_Object vector; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1242 Lisp_Object *subprefix_stack; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1243 int submenu_depth = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1244 int i; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1245 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1246 if (!f) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1247 return; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31465
diff
changeset
|
1248 entry = Qnil; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1249 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1250 vector = f->menu_bar_vector; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1251 prefix = Qnil; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1252 i = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1253 while (i < f->menu_bar_items_used) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1254 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1255 if (EQ (XVECTOR (vector)->contents[i], Qnil)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1256 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1257 subprefix_stack[submenu_depth++] = prefix; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1258 prefix = entry; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1259 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1260 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1261 else if (EQ (XVECTOR (vector)->contents[i], Qlambda)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1262 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1263 prefix = subprefix_stack[--submenu_depth]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1264 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1265 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1266 else if (EQ (XVECTOR (vector)->contents[i], Qt)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1267 { |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1268 prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1269 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1270 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1271 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1272 { |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1273 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1274 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1275 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1276 if ((int) (EMACS_INT) client_data == i) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1277 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1278 int j; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1279 struct input_event buf; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1280 Lisp_Object frame; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1281 |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1282 XSETFRAME (frame, f); |
30181
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1283 buf.kind = MENU_BAR_EVENT; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1284 buf.frame_or_window = frame; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1285 buf.arg = frame; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1286 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1287 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1288 for (j = 0; j < submenu_depth; j++) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1289 if (!NILP (subprefix_stack[j])) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1290 { |
30181
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1291 buf.kind = MENU_BAR_EVENT; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1292 buf.frame_or_window = frame; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1293 buf.arg = subprefix_stack[j]; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1294 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1295 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1296 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1297 if (!NILP (prefix)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1298 { |
30181
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1299 buf.kind = MENU_BAR_EVENT; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1300 buf.frame_or_window = frame; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1301 buf.arg = prefix; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1302 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1303 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1304 |
30181
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1305 buf.kind = MENU_BAR_EVENT; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1306 buf.frame_or_window = frame; |
770a280db6ee
(menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents:
30144
diff
changeset
|
1307 buf.arg = entry; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1308 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1309 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1310 return; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1311 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1312 i += MENU_ITEMS_ITEM_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1313 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1314 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1315 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1316 |
14553
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1317 /* Allocate a widget_value, blocking input. */ |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1318 |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1319 widget_value * |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1320 xmalloc_widget_value () |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1321 { |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1322 widget_value *value; |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1323 |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1324 BLOCK_INPUT; |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1325 value = malloc_widget_value (); |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1326 UNBLOCK_INPUT; |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1327 |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1328 return value; |
00521a7aaa75
(xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
14548
diff
changeset
|
1329 } |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1330 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1331 /* This recursively calls free_widget_value on the tree of widgets. |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1332 It must free all data that was malloc'ed for these widget_values. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1333 In Emacs, many slots are pointers into the data of Lisp_Strings, and |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1334 must be left alone. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1335 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1336 void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1337 free_menubar_widget_value_tree (wv) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1338 widget_value *wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1339 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1340 if (! wv) return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1341 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1342 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1343 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1344 if (wv->contents && (wv->contents != (widget_value*)1)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1345 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1346 free_menubar_widget_value_tree (wv->contents); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1347 wv->contents = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1348 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1349 if (wv->next) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1350 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1351 free_menubar_widget_value_tree (wv->next); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1352 wv->next = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1353 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1354 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1355 free_widget_value (wv); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1356 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1357 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1358 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1359 /* Return a tree of widget_value structures for a menu bar item |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1360 whose event type is ITEM_KEY (with string ITEM_NAME) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1361 and whose contents come from the list of keymaps MAPS. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1362 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1363 static widget_value * |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1364 single_submenu (item_key, item_name, maps) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1365 Lisp_Object item_key, item_name, maps; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1366 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1367 widget_value *wv, *prev_wv, *save_wv, *first_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1368 int i; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1369 int submenu_depth = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1370 Lisp_Object length; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1371 int len; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1372 Lisp_Object *mapvec; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1373 widget_value **submenu_stack; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1374 int previous_items = menu_items_used; |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1375 int top_level_items = 0; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1376 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1377 length = Flength (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1378 len = XINT (length); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1379 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1380 /* Convert the list MAPS into a vector MAPVEC. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1381 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1382 for (i = 0; i < len; i++) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1383 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1384 mapvec[i] = Fcar (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1385 maps = Fcdr (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1386 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1387 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1388 menu_items_n_panes = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1389 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1390 /* Loop over the given keymaps, making a pane for each map. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1391 But don't make a pane that is empty--ignore that map instead. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1392 for (i = 0; i < len; i++) |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1393 { |
15311
a9ed91ec0700
(single_submenu): Handle non-keymap lists like symbols.
Richard M. Stallman <rms@gnu.org>
parents:
15107
diff
changeset
|
1394 if (SYMBOLP (mapvec[i]) |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32179
diff
changeset
|
1395 || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i]))) |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1396 { |
15311
a9ed91ec0700
(single_submenu): Handle non-keymap lists like symbols.
Richard M. Stallman <rms@gnu.org>
parents:
15107
diff
changeset
|
1397 /* Here we have a command at top level in the menu bar |
a9ed91ec0700
(single_submenu): Handle non-keymap lists like symbols.
Richard M. Stallman <rms@gnu.org>
parents:
15107
diff
changeset
|
1398 as opposed to a submenu. */ |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1399 top_level_items = 1; |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1400 push_menu_pane (Qnil, Qnil); |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1401 push_menu_item (item_name, Qt, item_key, mapvec[i], |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1402 Qnil, Qnil, Qnil, Qnil); |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1403 } |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1404 else |
16752
6409ef81a2a8
(single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents:
16729
diff
changeset
|
1405 single_keymap_panes (mapvec[i], item_name, item_key, 0, 10); |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1406 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1407 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1408 /* Create a tree of widget_value objects |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1409 representing the panes and their items. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1410 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1411 submenu_stack |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1412 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1413 wv = xmalloc_widget_value (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1414 wv->name = "menu"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1415 wv->value = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1416 wv->enabled = 1; |
24993 | 1417 wv->button_type = BUTTON_TYPE_NONE; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1418 first_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1419 save_wv = 0; |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1420 prev_wv = 0; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1421 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1422 /* Loop over all panes and items made during this call |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1423 and construct a tree of widget_value objects. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1424 Ignore the panes and items made by previous calls to |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1425 single_submenu, even though those are also in menu_items. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1426 i = previous_items; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1427 while (i < menu_items_used) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1428 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1429 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1430 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1431 submenu_stack[submenu_depth++] = save_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1432 save_wv = prev_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1433 prev_wv = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1434 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1435 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1436 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1437 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1438 prev_wv = save_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1439 save_wv = submenu_stack[--submenu_depth]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1440 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1441 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1442 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1443 && submenu_depth != 0) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1444 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1445 /* Ignore a nil in the item list. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1446 It's meaningful only for dialog boxes. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1447 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1448 i += 1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1449 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1450 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1451 /* Create a new pane. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1452 Lisp_Object pane_name, prefix; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1453 char *pane_string; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1454 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1455 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1456 #ifndef HAVE_MULTILINGUAL_MENU |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1457 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1458 pane_name = string_make_unibyte (pane_name); |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1459 #endif |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1460 pane_string = (NILP (pane_name) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1461 ? "" : (char *) XSTRING (pane_name)->data); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1462 /* If there is just one top-level pane, put all its items directly |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1463 under the top-level menu. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1464 if (menu_items_n_panes == 1) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1465 pane_string = ""; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1466 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1467 /* If the pane has a meaningful name, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1468 make the pane a top-level menu item |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1469 with its items as a submenu beneath it. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1470 if (strcmp (pane_string, "")) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1471 { |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1472 wv = xmalloc_widget_value (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1473 if (save_wv) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1474 save_wv->next = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1475 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1476 first_wv->contents = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1477 wv->name = pane_string; |
12747
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
1478 /* Ignore the @ that means "separate pane". |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
1479 This is a kludge, but this isn't worth more time. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
1480 if (!NILP (prefix) && wv->name[0] == '@') |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1481 wv->name++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1482 wv->value = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1483 wv->enabled = 1; |
24993 | 1484 wv->button_type = BUTTON_TYPE_NONE; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1485 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1486 save_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1487 prev_wv = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1488 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1489 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1490 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1491 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1492 /* Create a new item within current pane. */ |
24993 | 1493 Lisp_Object item_name, enable, descrip, def, type, selected; |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1494 Lisp_Object help; |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1495 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1496 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1497 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1498 descrip |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1499 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1500 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
24993 | 1501 type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE]; |
1502 selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED]; | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1503 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
24993 | 1504 |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1505 #ifndef HAVE_MULTILINGUAL_MENU |
24993 | 1506 if (STRING_MULTIBYTE (item_name)) |
1507 item_name = string_make_unibyte (item_name); | |
1508 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) | |
1509 descrip = string_make_unibyte (descrip); | |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
1510 #endif |
24993 | 1511 |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1512 wv = xmalloc_widget_value (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1513 if (prev_wv) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1514 prev_wv->next = wv; |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1515 else |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1516 save_wv->contents = wv; |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1517 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1518 wv->name = (char *) XSTRING (item_name)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1519 if (!NILP (descrip)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1520 wv->key = (char *) XSTRING (descrip)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1521 wv->value = 0; |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1522 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1523 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1524 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1525 wv->enabled = !NILP (enable); |
24993 | 1526 |
1527 if (NILP (type)) | |
1528 wv->button_type = BUTTON_TYPE_NONE; | |
1529 else if (EQ (type, QCradio)) | |
1530 wv->button_type = BUTTON_TYPE_RADIO; | |
1531 else if (EQ (type, QCtoggle)) | |
1532 wv->button_type = BUTTON_TYPE_TOGGLE; | |
1533 else | |
1534 abort (); | |
1535 | |
1536 wv->selected = !NILP (selected); | |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1537 if (STRINGP (help)) |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1538 wv->help = XSTRING (help)->data; |
24993 | 1539 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1540 prev_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1541 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1542 i += MENU_ITEMS_ITEM_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1543 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1544 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1545 |
12432
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1546 /* If we have just one "menu item" |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1547 that was originally a button, return it by itself. */ |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1548 if (top_level_items && first_wv->contents && first_wv->contents->next == 0) |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1549 { |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1550 wv = first_wv->contents; |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1551 free_widget_value (first_wv); |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1552 return wv; |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1553 } |
a46766b7288a
(single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
12361
diff
changeset
|
1554 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1555 return first_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1556 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1557 |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1558 extern void EmacsFrameSetCharSize (); |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1559 |
12018
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1560 /* Recompute all the widgets of frame F, when the menu bar |
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1561 has been changed. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1562 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1563 static void |
6481
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1564 update_frame_menubar (f) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1565 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1566 { |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1567 struct x_output *x = f->output_data.x; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1568 int columns, rows; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1569 int menubar_changed; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1570 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1571 /* We assume the menubar contents has changed if the global flag is set, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1572 or if the current buffer has changed, or if the menubar has never |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1573 been updated before. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1574 */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1575 menubar_changed = (x->menubar_widget |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1576 && !XtIsManaged (x->menubar_widget)); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1577 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1578 if (! (menubar_changed)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1579 return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1580 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1581 BLOCK_INPUT; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1582 /* Save the size of the frame because the pane widget doesn't accept to |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1583 resize itself. So force it. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1584 columns = f->width; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1585 rows = f->height; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1586 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1587 /* Do the voodoo which means "I'm changing lots of things, don't try to |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1588 refigure sizes until I'm done." */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1589 lw_refigure_widget (x->column_widget, False); |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1590 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1591 /* the order in which children are managed is the top to |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1592 bottom order in which they are displayed in the paned window. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1593 First, remove the text-area widget. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1594 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1595 XtUnmanageChild (x->edit_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1596 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1597 /* remove the menubar that is there now, and put up the menubar that |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1598 should be there. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1599 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1600 if (menubar_changed) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1601 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1602 XtManageChild (x->menubar_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1603 XtMapWidget (x->menubar_widget); |
30574
2a22be2633b2
(update_frame_menubar): Use NULL instead of 0 at the end
Gerd Moellmann <gerd@gnu.org>
parents:
30472
diff
changeset
|
1604 XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, NULL); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1605 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1606 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1607 /* Re-manage the text-area widget, and then thrash the sizes. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1608 XtManageChild (x->edit_widget); |
26036
b89acbeca64b
(set_frame_menubar): Don't call
Gerd Moellmann <gerd@gnu.org>
parents:
25884
diff
changeset
|
1609 x_set_menu_resources_from_menu_face (f, x->menubar_widget); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1610 lw_refigure_widget (x->column_widget, True); |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1611 |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1612 /* Force the pane widget to resize itself with the right values. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1613 EmacsFrameSetCharSize (x->edit_widget, columns, rows); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1614 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1615 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1616 |
12018
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1617 /* Set the contents of the menubar widgets of frame F. |
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1618 The argument FIRST_TIME is currently ignored; |
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1619 it is set the first time this is called, from initialize_frame_menubar. */ |
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1620 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1621 void |
12661 | 1622 set_frame_menubar (f, first_time, deep_p) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1623 FRAME_PTR f; |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1624 int first_time; |
12661 | 1625 int deep_p; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1626 { |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1627 Widget menubar_widget = f->output_data.x->menubar_widget; |
25730
db88a4b84d91
(single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents:
25680
diff
changeset
|
1628 Lisp_Object items; |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1629 widget_value *wv, *first_wv, *prev_wv = 0; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1630 int i; |
12661 | 1631 LWLIB_ID id; |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1632 |
16656
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
1633 XSETFRAME (Vmenu_updating_frame, f); |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
1634 |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1635 if (f->output_data.x->id == 0) |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1636 f->output_data.x->id = next_menubar_widget_id++; |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1637 id = f->output_data.x->id; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1638 |
12661 | 1639 if (! menubar_widget) |
1640 deep_p = 1; | |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1641 else if (pending_menu_activation && !deep_p) |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1642 deep_p = 1; |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1643 /* Make the first call for any given frame always go deep. */ |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1644 else if (!f->output_data.x->saved_menu_event && !deep_p) |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1645 { |
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1646 deep_p = 1; |
15807
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1647 f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent)); |
508ec69917b1
(pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents:
15795
diff
changeset
|
1648 f->output_data.x->saved_menu_event->type = 0; |
15792
feeb1f7c1cec
(pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15785
diff
changeset
|
1649 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1650 |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1651 wv = xmalloc_widget_value (); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1652 wv->name = "menubar"; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1653 wv->value = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1654 wv->enabled = 1; |
24993 | 1655 wv->button_type = BUTTON_TYPE_NONE; |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1656 first_wv = wv; |
12661 | 1657 |
1658 if (deep_p) | |
1659 { | |
1660 /* Make a widget-value tree representing the entire menu trees. */ | |
1661 | |
1662 struct buffer *prev = current_buffer; | |
1663 Lisp_Object buffer; | |
1664 int specpdl_count = specpdl_ptr - specpdl; | |
1665 int previous_menu_items_used = f->menu_bar_items_used; | |
1666 Lisp_Object *previous_items | |
1667 = (Lisp_Object *) alloca (previous_menu_items_used | |
1668 * sizeof (Lisp_Object)); | |
12634
eec80ea06395
(set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents:
12625
diff
changeset
|
1669 |
17554
0a75fcee3cb8
(set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents:
17364
diff
changeset
|
1670 /* If we are making a new widget, its contents are empty, |
0a75fcee3cb8
(set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents:
17364
diff
changeset
|
1671 do always reinitialize them. */ |
0a75fcee3cb8
(set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents:
17364
diff
changeset
|
1672 if (! menubar_widget) |
0a75fcee3cb8
(set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents:
17364
diff
changeset
|
1673 previous_menu_items_used = 0; |
0a75fcee3cb8
(set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents:
17364
diff
changeset
|
1674 |
12661 | 1675 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; |
1676 specbind (Qinhibit_quit, Qt); | |
1677 /* Don't let the debugger step into this code | |
1678 because it is not reentrant. */ | |
1679 specbind (Qdebug_on_next_call, Qnil); | |
1680 | |
21178
85fd58cb0654
(set_frame_menubar): Fstore_match_data => Fset_match_data.
Richard M. Stallman <rms@gnu.org>
parents:
20630
diff
changeset
|
1681 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
12661 | 1682 if (NILP (Voverriding_local_map_menu_flag)) |
1683 { | |
1684 specbind (Qoverriding_terminal_local_map, Qnil); | |
1685 specbind (Qoverriding_local_map, Qnil); | |
1686 } | |
1687 | |
1688 set_buffer_internal_1 (XBUFFER (buffer)); | |
12634
eec80ea06395
(set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents:
12625
diff
changeset
|
1689 |
12661 | 1690 /* Run the Lucid hook. */ |
1691 call1 (Vrun_hooks, Qactivate_menubar_hook); | |
1692 /* If it has changed current-menubar from previous value, | |
1693 really recompute the menubar from the value. */ | |
1694 if (! NILP (Vlucid_menu_bar_dirty_flag)) | |
1695 call0 (Qrecompute_lucid_menubar); | |
14298 | 1696 safe_run_hooks (Qmenu_bar_update_hook); |
12661 | 1697 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
1698 | |
1699 items = FRAME_MENU_BAR_ITEMS (f); | |
1700 | |
1701 inhibit_garbage_collection (); | |
1702 | |
1703 /* Save the frame's previous menu bar contents data. */ | |
1704 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, | |
1705 previous_menu_items_used * sizeof (Lisp_Object)); | |
1706 | |
1707 /* Fill in the current menu bar contents. */ | |
1708 menu_items = f->menu_bar_vector; | |
1709 menu_items_allocated = XVECTOR (menu_items)->size; | |
1710 init_menu_items (); | |
15107
e025990722ca
(set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents:
14741
diff
changeset
|
1711 for (i = 0; i < XVECTOR (items)->size; i += 4) |
12661 | 1712 { |
1713 Lisp_Object key, string, maps; | |
1714 | |
1715 key = XVECTOR (items)->contents[i]; | |
1716 string = XVECTOR (items)->contents[i + 1]; | |
1717 maps = XVECTOR (items)->contents[i + 2]; | |
1718 if (NILP (string)) | |
1719 break; | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1720 |
12661 | 1721 wv = single_submenu (key, string, maps); |
1722 if (prev_wv) | |
1723 prev_wv->next = wv; | |
1724 else | |
1725 first_wv->contents = wv; | |
1726 /* Don't set wv->name here; GC during the loop might relocate it. */ | |
1727 wv->enabled = 1; | |
24993 | 1728 wv->button_type = BUTTON_TYPE_NONE; |
12661 | 1729 prev_wv = wv; |
1730 } | |
1731 | |
1732 finish_menu_items (); | |
1733 | |
1734 set_buffer_internal_1 (prev); | |
1735 unbind_to (specpdl_count, Qnil); | |
1736 | |
1737 /* If there has been no change in the Lisp-level contents | |
1738 of the menu bar, skip redisplaying it. Just exit. */ | |
1739 | |
1740 for (i = 0; i < previous_menu_items_used; i++) | |
1741 if (menu_items_used == i | |
17364
573189779804
(Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents:
16752
diff
changeset
|
1742 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i]))) |
12661 | 1743 break; |
13654
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1744 if (i == menu_items_used && i == previous_menu_items_used && i != 0) |
12661 | 1745 { |
1746 free_menubar_widget_value_tree (first_wv); | |
1747 menu_items = Qnil; | |
1748 | |
1749 return; | |
1750 } | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1751 |
12661 | 1752 /* Now GC cannot happen during the lifetime of the widget_value, |
1753 so it's safe to store data from a Lisp_String. */ | |
1754 wv = first_wv->contents; | |
15107
e025990722ca
(set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents:
14741
diff
changeset
|
1755 for (i = 0; i < XVECTOR (items)->size; i += 4) |
12661 | 1756 { |
1757 Lisp_Object string; | |
1758 string = XVECTOR (items)->contents[i + 1]; | |
1759 if (NILP (string)) | |
1760 break; | |
1761 wv->name = (char *) XSTRING (string)->data; | |
1762 wv = wv->next; | |
1763 } | |
1764 | |
1765 f->menu_bar_vector = menu_items; | |
1766 f->menu_bar_items_used = menu_items_used; | |
1767 menu_items = Qnil; | |
1768 } | |
1769 else | |
1770 { | |
1771 /* Make a widget-value tree containing | |
1772 just the top level menu bar strings. */ | |
1773 | |
1774 items = FRAME_MENU_BAR_ITEMS (f); | |
15107
e025990722ca
(set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents:
14741
diff
changeset
|
1775 for (i = 0; i < XVECTOR (items)->size; i += 4) |
12661 | 1776 { |
1777 Lisp_Object string; | |
1778 | |
1779 string = XVECTOR (items)->contents[i + 1]; | |
1780 if (NILP (string)) | |
1781 break; | |
1782 | |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1783 wv = xmalloc_widget_value (); |
12661 | 1784 wv->name = (char *) XSTRING (string)->data; |
1785 wv->value = 0; | |
1786 wv->enabled = 1; | |
24993 | 1787 wv->button_type = BUTTON_TYPE_NONE; |
15785
9902d8a8a548
(set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents:
15710
diff
changeset
|
1788 /* This prevents lwlib from assuming this |
9902d8a8a548
(set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents:
15710
diff
changeset
|
1789 menu item is really supposed to be empty. */ |
9902d8a8a548
(set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents:
15710
diff
changeset
|
1790 /* The EMACS_INT cast avoids a warning. |
9902d8a8a548
(set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents:
15710
diff
changeset
|
1791 This value just has to be different from small integers. */ |
9902d8a8a548
(set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents:
15710
diff
changeset
|
1792 wv->call_data = (void *) (EMACS_INT) (-1); |
12661 | 1793 |
1794 if (prev_wv) | |
1795 prev_wv->next = wv; | |
1796 else | |
1797 first_wv->contents = wv; | |
1798 prev_wv = wv; | |
1799 } | |
13654
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1800 |
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1801 /* Forget what we thought we knew about what is in the |
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1802 detailed contents of the menu bar menus. |
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1803 Changing the top level always destroys the contents. */ |
645e14e39a2b
(set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents:
13489
diff
changeset
|
1804 f->menu_bar_items_used = 0; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1805 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1806 |
12661 | 1807 /* Create or update the menu bar widget. */ |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1808 |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1809 BLOCK_INPUT; |
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
1810 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1811 if (menubar_widget) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1812 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1813 /* Disable resizing (done for Motif!) */ |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1814 lw_allow_resizing (f->output_data.x->widget, False); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1815 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1816 /* The third arg is DEEP_P, which says to consider the entire |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1817 menu trees we supply, rather than just the menu bar item names. */ |
12661 | 1818 lw_modify_all_widgets (id, first_wv, deep_p); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1819 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1820 /* Re-enable the edit widget to resize. */ |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1821 lw_allow_resizing (f->output_data.x->widget, True); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1822 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1823 else |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1824 { |
12661 | 1825 menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv, |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1826 f->output_data.x->column_widget, |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1827 0, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1828 popup_activate_callback, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1829 menubar_selection_callback, |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1830 popup_deactivate_callback, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
1831 menu_highlight_callback); |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1832 f->output_data.x->menubar_widget = menubar_widget; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1833 } |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1834 |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1835 { |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1836 int menubar_size |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1837 = (f->output_data.x->menubar_widget |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1838 ? (f->output_data.x->menubar_widget->core.height |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1839 + f->output_data.x->menubar_widget->core.border_width) |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1840 : 0); |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1841 |
15943
16fb6dcfa4e8
(set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents:
15912
diff
changeset
|
1842 #if 0 /* Experimentally, we now get the right results |
16fb6dcfa4e8
(set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents:
15912
diff
changeset
|
1843 for -geometry -0-0 without this. 24 Aug 96, rms. */ |
13489
ddf90bfd3744
Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents:
13071
diff
changeset
|
1844 #ifdef USE_LUCID |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1845 if (FRAME_EXTERNAL_MENU_BAR (f)) |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1846 { |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1847 Dimension ibw = 0; |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1848 XtVaGetValues (f->output_data.x->column_widget, |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1849 XtNinternalBorderWidth, &ibw, NULL); |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1850 menubar_size += ibw; |
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1851 } |
13489
ddf90bfd3744
Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents:
13071
diff
changeset
|
1852 #endif /* USE_LUCID */ |
15943
16fb6dcfa4e8
(set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents:
15912
diff
changeset
|
1853 #endif /* 0 */ |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1854 |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1855 f->output_data.x->menubar_height = menubar_size; |
11898
a23359be806b
(set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents:
11655
diff
changeset
|
1856 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1857 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1858 free_menubar_widget_value_tree (first_wv); |
12018
f5d820ad7a13
(set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents:
11954
diff
changeset
|
1859 update_frame_menubar (f); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1860 |
12634
eec80ea06395
(set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents:
12625
diff
changeset
|
1861 UNBLOCK_INPUT; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1862 } |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1863 |
14036 | 1864 /* Called from Fx_create_frame to create the initial menubar of a frame |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1865 before it is mapped, so that the window is mapped with the menubar already |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1866 there instead of us tacking it on later and thrashing the window after it |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1867 is visible. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1868 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1869 void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1870 initialize_frame_menubar (f) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1871 FRAME_PTR f; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1872 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1873 /* This function is called before the first chance to redisplay |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1874 the frame. It has to be, so the frame will have the right size. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1875 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
12661 | 1876 set_frame_menubar (f, 1, 1); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1877 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1878 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1879 /* Get rid of the menu bar of frame F, and free its storage. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1880 This is used when deleting a frame, and when turning off the menu bar. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1881 |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1882 void |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1883 free_frame_menubar (f) |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1884 FRAME_PTR f; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1885 { |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1886 Widget menubar_widget; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1887 |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1888 menubar_widget = f->output_data.x->menubar_widget; |
19624
c73494a6bcd3
(free_frame_menubar): Clear menubar_height field.
Richard M. Stallman <rms@gnu.org>
parents:
17709
diff
changeset
|
1889 |
c73494a6bcd3
(free_frame_menubar): Clear menubar_height field.
Richard M. Stallman <rms@gnu.org>
parents:
17709
diff
changeset
|
1890 f->output_data.x->menubar_height = 0; |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1891 |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1892 if (menubar_widget) |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1893 { |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1894 BLOCK_INPUT; |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
1895 lw_destroy_all_widgets ((LWLIB_ID) f->output_data.x->id); |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1896 UNBLOCK_INPUT; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1897 } |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1898 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1899 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1900 #endif /* USE_X_TOOLKIT */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1901 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1902 /* xmenu_show actually displays a menu using the panes and items in menu_items |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1903 and returns the value selected from it. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1904 There are two versions of xmenu_show, one for Xt and one for Xlib. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1905 Both assume input is blocked by the caller. */ |
118 | 1906 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1907 /* F is the frame the menu is for. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1908 X and Y are the frame-relative specified position, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1909 relative to the inside upper left corner of the frame F. |
15839
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
1910 FOR_CLICK is nonzero if this menu was invoked for a mouse click. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1911 KEYMAPS is 1 if this menu was specified with keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1912 in that case, we return a list containing the chosen item's value |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1913 and perhaps also the pane's prefix. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1914 TITLE is the specified menu title. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1915 ERROR is a place to store an error message string in case of failure. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1916 (We return nil on failure, but the value doesn't actually matter.) */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1917 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1918 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1919 |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1920 /* We need a unique id for each widget handled by the Lucid Widget |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
1921 library. |
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
1922 |
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
1923 For the main windows, and popup menus, we use this counter, |
12661 | 1924 which we increment each time after use. This starts from 1<<16. |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
1925 |
12661 | 1926 For menu bars, we use numbers starting at 0, counted in |
1927 next_menubar_widget_id. */ | |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1928 LWLIB_ID widget_id_tick; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1929 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1930 static Lisp_Object *volatile menu_item_selection; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1931 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1932 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1933 popup_selection_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1934 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1935 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1936 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1937 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1938 menu_item_selection = (Lisp_Object *) client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1939 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1940 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1941 static Lisp_Object |
11491
272baf4a077a
(xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents:
11449
diff
changeset
|
1942 xmenu_show (f, x, y, for_click, keymaps, title, error) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1943 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1944 int x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1945 int y; |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
1946 int for_click; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1947 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1948 Lisp_Object title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1949 char **error; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1950 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1951 int i; |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
1952 LWLIB_ID menu_id; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1953 Widget menu; |
12747
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
1954 Arg av[2]; |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1955 int ac = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1956 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1957 widget_value **submenu_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1958 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1959 Lisp_Object *subprefix_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1960 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1961 int submenu_depth = 0; |
12747
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
1962 XButtonPressedEvent dummy; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1963 |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1964 int first_pane; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1965 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1966 *error = NULL; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1967 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1968 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1969 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1970 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1971 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1972 } |
5896
b20145eafe0c
(xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5881
diff
changeset
|
1973 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1974 /* Create a tree of widget_value objects |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1975 representing the panes and their items. */ |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
1976 wv = xmalloc_widget_value (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1977 wv->name = "menu"; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1978 wv->value = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1979 wv->enabled = 1; |
24993 | 1980 wv->button_type = BUTTON_TYPE_NONE; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1981 first_wv = wv; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1982 first_pane = 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1983 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1984 /* Loop over all panes and items, filling in the tree. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1985 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1986 while (i < menu_items_used) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1987 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1988 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1989 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1990 submenu_stack[submenu_depth++] = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1991 save_wv = prev_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1992 prev_wv = 0; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1993 first_pane = 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1994 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1995 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1996 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1997 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1998 prev_wv = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1999 save_wv = submenu_stack[--submenu_depth]; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2000 first_pane = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2001 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2002 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2003 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2004 && submenu_depth != 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2005 i += MENU_ITEMS_PANE_LENGTH; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2006 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2007 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2008 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2009 i += 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2010 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2011 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2012 /* Create a new pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2013 Lisp_Object pane_name, prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2014 char *pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2015 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2016 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2017 #ifndef HAVE_MULTILINGUAL_MENU |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2018 if (!NILP (pane_name) && STRING_MULTIBYTE (pane_name)) |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2019 pane_name = string_make_unibyte (pane_name); |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2020 #endif |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2021 pane_string = (NILP (pane_name) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2022 ? "" : (char *) XSTRING (pane_name)->data); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2023 /* If there is just one top-level pane, put all its items directly |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2024 under the top-level menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2025 if (menu_items_n_panes == 1) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2026 pane_string = ""; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2027 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2028 /* If the pane has a meaningful name, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2029 make the pane a top-level menu item |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2030 with its items as a submenu beneath it. */ |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2031 if (!keymaps && strcmp (pane_string, "")) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2032 { |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2033 wv = xmalloc_widget_value (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2034 if (save_wv) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2035 save_wv->next = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2036 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2037 first_wv->contents = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2038 wv->name = pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2039 if (keymaps && !NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2040 wv->name++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2041 wv->value = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2042 wv->enabled = 1; |
24993 | 2043 wv->button_type = BUTTON_TYPE_NONE; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2044 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2045 prev_wv = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2046 } |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2047 else if (first_pane) |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2048 { |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2049 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2050 prev_wv = 0; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2051 } |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
2052 first_pane = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2053 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2054 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2055 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2056 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2057 /* Create a new item within current pane. */ |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
2058 Lisp_Object item_name, enable, descrip, def, type, selected, help; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2059 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2060 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2061 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2062 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2063 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
24993 | 2064 type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE]; |
2065 selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED]; | |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
2066 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
24993 | 2067 |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2068 #ifndef HAVE_MULTILINGUAL_MENU |
24993 | 2069 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) |
2070 item_name = string_make_unibyte (item_name); | |
2071 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) | |
2072 item_name = string_make_unibyte (descrip); | |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2073 #endif |
24993 | 2074 |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2075 wv = xmalloc_widget_value (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2076 if (prev_wv) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2077 prev_wv->next = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2078 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2079 save_wv->contents = wv; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2080 wv->name = (char *) XSTRING (item_name)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2081 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2082 wv->key = (char *) XSTRING (descrip)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2083 wv->value = 0; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2084 /* If this item has a null value, |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2085 make the call_data null so that it won't display a box |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2086 when the mouse is on it. */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2087 wv->call_data |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2088 = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2089 wv->enabled = !NILP (enable); |
24993 | 2090 |
2091 if (NILP (type)) | |
2092 wv->button_type = BUTTON_TYPE_NONE; | |
2093 else if (EQ (type, QCtoggle)) | |
2094 wv->button_type = BUTTON_TYPE_TOGGLE; | |
2095 else if (EQ (type, QCradio)) | |
2096 wv->button_type = BUTTON_TYPE_RADIO; | |
2097 else | |
2098 abort (); | |
2099 | |
2100 wv->selected = !NILP (selected); | |
30472
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
2101 if (STRINGP (help)) |
0c982ed8515f
(menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents:
30420
diff
changeset
|
2102 wv->help = XSTRING (help)->data; |
24993 | 2103 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2104 prev_wv = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2105 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2106 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2107 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2108 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2109 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
2110 /* Deal with the title, if it is non-nil. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2111 if (!NILP (title)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2112 { |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2113 widget_value *wv_title = xmalloc_widget_value (); |
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2114 widget_value *wv_sep1 = xmalloc_widget_value (); |
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2115 widget_value *wv_sep2 = xmalloc_widget_value (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2116 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2117 wv_sep2->name = "--"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2118 wv_sep2->next = first_wv->contents; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2119 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2120 wv_sep1->name = "--"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2121 wv_sep1->next = wv_sep2; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2122 |
23302
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2123 #ifndef HAVE_MULTILINGUAL_MENU |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2124 if (STRING_MULTIBYTE (title)) |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2125 title = string_make_unibyte (title); |
dcff2a4b6cb4
(single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents:
21514
diff
changeset
|
2126 #endif |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2127 wv_title->name = (char *) XSTRING (title)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2128 wv_title->enabled = True; |
24993 | 2129 wv_title->button_type = BUTTON_TYPE_NONE; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2130 wv_title->next = wv_sep1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2131 first_wv->contents = wv_title; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2132 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2133 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2134 /* Actually create the menu. */ |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
2135 menu_id = widget_id_tick++; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2136 menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv, |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2137 f->output_data.x->widget, 1, 0, |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2138 popup_selection_callback, |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
2139 popup_deactivate_callback, |
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
2140 menu_highlight_callback); |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
2141 |
12747
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2142 /* Adjust coordinates to relative to the outer (window manager) window. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2143 { |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2144 Window child; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2145 int win_x = 0, win_y = 0; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2146 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2147 /* Find the position of the outside upper-left corner of |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2148 the inner window, with respect to the outer window. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2149 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2150 { |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2151 BLOCK_INPUT; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2152 XTranslateCoordinates (FRAME_X_DISPLAY (f), |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2153 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2154 /* From-window, to-window. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2155 f->output_data.x->window_desc, |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2156 f->output_data.x->parent_desc, |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2157 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2158 /* From-position, to-position. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2159 0, 0, &win_x, &win_y, |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2160 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2161 /* Child of window. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2162 &child); |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2163 UNBLOCK_INPUT; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2164 x += win_x; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2165 y += win_y; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2166 } |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2167 } |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2168 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2169 /* Adjust coordinates to be root-window-relative. */ |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2170 x += f->output_data.x->left_pos; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2171 y += f->output_data.x->top_pos; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2172 |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2173 dummy.type = ButtonPress; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2174 dummy.serial = 0; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2175 dummy.send_event = 0; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2176 dummy.display = FRAME_X_DISPLAY (f); |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2177 dummy.time = CurrentTime; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2178 dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2179 dummy.window = dummy.root; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2180 dummy.subwindow = dummy.root; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2181 dummy.x_root = x; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2182 dummy.y_root = y; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2183 dummy.x = x; |
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2184 dummy.y = y; |
15839
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
2185 dummy.state = (FRAME_X_DISPLAY_INFO (f)->grabbed >> 1) * Button1Mask; |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
2186 dummy.button = 0; |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
2187 for (i = 0; i < 5; i++) |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
2188 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i)) |
e66ccb471d26
(xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents:
15807
diff
changeset
|
2189 dummy.button = i; |
12747
a36d5f3940b5
[USE_X_TOOLKIT] (xmenu_show): Compute root-based
Richard M. Stallman <rms@gnu.org>
parents:
12672
diff
changeset
|
2190 |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
2191 /* Don't allow any geometry request from the user. */ |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
2192 XtSetArg (av[ac], XtNgeometry, 0); ac++; |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
2193 XtSetValues (menu, av, ac); |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
2194 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2195 /* Free the widget_value objects we used to specify the contents. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2196 free_menubar_widget_value_tree (first_wv); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2197 |
31365 | 2198 /* Override any default settings with ones from the `menu' face. */ |
2199 x_set_menu_resources_from_menu_face (f, menu); | |
2200 | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2201 /* No selection has been chosen yet. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2202 menu_item_selection = 0; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2203 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2204 /* Display the menu. */ |
29554
98ee5ca6cdcb
(xmenu_show): Case second parameter of lw_popup_menu
Gerd Moellmann <gerd@gnu.org>
parents:
29441
diff
changeset
|
2205 lw_popup_menu (menu, (XEvent *) &dummy); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2206 popup_activated_flag = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2207 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2208 /* Process events that apply to the menu. */ |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
2209 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2210 |
24993 | 2211 #ifdef LESSTIF_VERSION |
2212 /* Nov 1998: For an unknown reason a button grab remains active | |
2213 after the popup menu has gone. */ | |
2214 XUngrabButton (XtDisplay (f->output_data.x->widget), | |
2215 AnyButton, AnyModifier, | |
2216 XtWindow (f->output_data.x->widget)); | |
2217 XUngrabButton (XtDisplay (f->output_data.x->edit_widget), | |
2218 AnyButton, AnyModifier, | |
2219 XtWindow (f->output_data.x->edit_widget)); | |
2220 #endif /* LESSTIF_VERSION */ | |
2221 | |
6625
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
2222 /* fp turned off the following statement and wrote a comment |
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
2223 that it is unnecessary--that the menu has already disappeared. |
12149
f1585a0ecd0c
(xmenu_show): Do call lw_destroy_all_widgets.
Karl Heuer <kwzh@gnu.org>
parents:
12131
diff
changeset
|
2224 Nowadays the menu disappears ok, all right, but |
f1585a0ecd0c
(xmenu_show): Do call lw_destroy_all_widgets.
Karl Heuer <kwzh@gnu.org>
parents:
12131
diff
changeset
|
2225 we need to delete the widgets or multiple ones will pile up. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2226 lw_destroy_all_widgets (menu_id); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2227 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2228 /* Find the selected item, and its pane, to return |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2229 the proper value. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2230 if (menu_item_selection != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2231 { |
11655
a9f93ce6e1b4
(xmenu_show, menubar_selection_callback): Move declaration
Karl Heuer <kwzh@gnu.org>
parents:
11614
diff
changeset
|
2232 Lisp_Object prefix, entry; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2233 |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31465
diff
changeset
|
2234 prefix = entry = Qnil; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2235 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2236 while (i < menu_items_used) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2237 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2238 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2239 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2240 subprefix_stack[submenu_depth++] = prefix; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2241 prefix = entry; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2242 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2243 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2244 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2245 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2246 prefix = subprefix_stack[--submenu_depth]; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2247 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2248 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2249 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2250 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2251 prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2252 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2253 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2254 } |
13071
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
2255 /* Ignore a nil in the item list. |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
2256 It's meaningful only for dialog boxes. */ |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
2257 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
2e514396cbc8
(popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents:
12747
diff
changeset
|
2258 i += 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2259 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2260 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2261 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2262 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2263 if (menu_item_selection == &XVECTOR (menu_items)->contents[i]) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2264 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2265 if (keymaps != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2266 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2267 int j; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2268 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2269 entry = Fcons (entry, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2270 if (!NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2271 entry = Fcons (prefix, entry); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
2272 for (j = submenu_depth - 1; j >= 0; j--) |
6931
2d0ee7ef620a
(xmenu_show): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents:
6913
diff
changeset
|
2273 if (!NILP (subprefix_stack[j])) |
6913
f167828a3ec2
(xmenu_show): Don't cons on subprefix_stck[j] if nil.
Richard M. Stallman <rms@gnu.org>
parents:
6881
diff
changeset
|
2274 entry = Fcons (subprefix_stack[j], entry); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2275 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2276 return entry; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2277 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2278 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2279 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2280 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2281 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2282 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2283 return Qnil; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2284 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2285 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2286 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2287 dialog_selection_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2288 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2289 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2290 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2291 { |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
2292 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
2293 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
2294 if ((int) (EMACS_INT) client_data != -1) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2295 menu_item_selection = (Lisp_Object *) client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2296 BLOCK_INPUT; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2297 lw_destroy_all_widgets (id); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2298 UNBLOCK_INPUT; |
11614
fdd0d5bdd8c6
(popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents:
11528
diff
changeset
|
2299 popup_activated_flag = 0; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2300 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2301 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2302 static char * button_names [] = { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2303 "button1", "button2", "button3", "button4", "button5", |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2304 "button6", "button7", "button8", "button9", "button10" }; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2305 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2306 static Lisp_Object |
11491
272baf4a077a
(xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents:
11449
diff
changeset
|
2307 xdialog_show (f, keymaps, title, error) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2308 FRAME_PTR f; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2309 int keymaps; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2310 Lisp_Object title; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2311 char **error; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2312 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2313 int i, nb_buttons=0; |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
2314 LWLIB_ID dialog_id; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2315 Widget menu; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2316 char dialog_name[6]; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2317 |
25730
db88a4b84d91
(single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents:
25680
diff
changeset
|
2318 widget_value *wv, *first_wv = 0, *prev_wv = 0; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2319 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2320 /* Number of elements seen so far, before boundary. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2321 int left_count = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2322 /* 1 means we've seen the boundary between left-hand elts and right-hand. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2323 int boundary_seen = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2324 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2325 *error = NULL; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2326 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2327 if (menu_items_n_panes > 1) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2328 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2329 *error = "Multiple panes in dialog box"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2330 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2331 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2332 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2333 /* Create a tree of widget_value objects |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2334 representing the text label and buttons. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2335 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2336 Lisp_Object pane_name, prefix; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2337 char *pane_string; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2338 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2339 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2340 pane_string = (NILP (pane_name) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2341 ? "" : (char *) XSTRING (pane_name)->data); |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2342 prev_wv = xmalloc_widget_value (); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2343 prev_wv->value = pane_string; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2344 if (keymaps && !NILP (prefix)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2345 prev_wv->name++; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2346 prev_wv->enabled = 1; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2347 prev_wv->name = "message"; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2348 first_wv = prev_wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2349 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2350 /* Loop over all panes and items, filling in the tree. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2351 i = MENU_ITEMS_PANE_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2352 while (i < menu_items_used) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2353 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2354 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2355 /* Create a new item within current pane. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2356 Lisp_Object item_name, enable, descrip; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2357 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2358 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2359 descrip |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2360 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2361 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2362 if (NILP (item_name)) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2363 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2364 free_menubar_widget_value_tree (first_wv); |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2365 *error = "Submenu in dialog items"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2366 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2367 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2368 if (EQ (item_name, Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2369 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2370 /* This is the boundary between left-side elts |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2371 and right-side elts. Stop incrementing right_count. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2372 boundary_seen = 1; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2373 i++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2374 continue; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2375 } |
15912
afb0bb1cdbe6
(xdialog_show): Don't allow 9 buttons.
Richard M. Stallman <rms@gnu.org>
parents:
15839
diff
changeset
|
2376 if (nb_buttons >= 9) |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2377 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2378 free_menubar_widget_value_tree (first_wv); |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2379 *error = "Too many dialog items"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2380 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2381 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2382 |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2383 wv = xmalloc_widget_value (); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2384 prev_wv->next = wv; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2385 wv->name = (char *) button_names[nb_buttons]; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2386 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2387 wv->key = (char *) XSTRING (descrip)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2388 wv->value = (char *) XSTRING (item_name)->data; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2389 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2390 wv->enabled = !NILP (enable); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2391 prev_wv = wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2392 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2393 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2394 left_count++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2395 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2396 nb_buttons++; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2397 i += MENU_ITEMS_ITEM_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2398 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2399 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2400 /* If the boundary was not specified, |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2401 by default put half on the left and half on the right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2402 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2403 left_count = nb_buttons - nb_buttons / 2; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2404 |
14546
bc0388a7c282
(xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14298
diff
changeset
|
2405 wv = xmalloc_widget_value (); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2406 wv->name = dialog_name; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2407 |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2408 /* Dialog boxes use a really stupid name encoding |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2409 which specifies how many buttons to use |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2410 and how many buttons are on the right. |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2411 The Q means something also. */ |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2412 dialog_name[0] = 'Q'; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2413 dialog_name[1] = '0' + nb_buttons; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2414 dialog_name[2] = 'B'; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2415 dialog_name[3] = 'R'; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2416 /* Number of buttons to put on the right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2417 dialog_name[4] = '0' + nb_buttons - left_count; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2418 dialog_name[5] = 0; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2419 wv->contents = first_wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2420 first_wv = wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2421 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2422 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2423 /* Actually create the dialog. */ |
11918
da016ba65a6c
(xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents:
11907
diff
changeset
|
2424 dialog_id = widget_id_tick++; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2425 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2426 f->output_data.x->widget, 1, 0, |
27341
ab22130d8fe3
(enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents:
26729
diff
changeset
|
2427 dialog_selection_callback, 0, 0); |
7770
41dda174ca7c
(xdialog_show): Fix problem with message in dialog box.
Karl Heuer <kwzh@gnu.org>
parents:
7679
diff
changeset
|
2428 lw_modify_all_widgets (dialog_id, first_wv->contents, True); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2429 /* Free the widget_value objects we used to specify the contents. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2430 free_menubar_widget_value_tree (first_wv); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2431 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2432 /* No selection has been chosen yet. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2433 menu_item_selection = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2434 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2435 /* Display the menu. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2436 lw_pop_up_all_widgets (dialog_id); |
11449
fca5a32f7806
(popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents:
11266
diff
changeset
|
2437 popup_activated_flag = 1; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2438 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2439 /* Process events that apply to the menu. */ |
11954
4117d74ba254
(popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents:
11918
diff
changeset
|
2440 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2441 |
12149
f1585a0ecd0c
(xmenu_show): Do call lw_destroy_all_widgets.
Karl Heuer <kwzh@gnu.org>
parents:
12131
diff
changeset
|
2442 lw_destroy_all_widgets (dialog_id); |
f1585a0ecd0c
(xmenu_show): Do call lw_destroy_all_widgets.
Karl Heuer <kwzh@gnu.org>
parents:
12131
diff
changeset
|
2443 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2444 /* Find the selected item, and its pane, to return |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2445 the proper value. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2446 if (menu_item_selection != 0) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2447 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2448 Lisp_Object prefix; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2449 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2450 prefix = Qnil; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2451 i = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2452 while (i < menu_items_used) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2453 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2454 Lisp_Object entry; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2455 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2456 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2457 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2458 prefix |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2459 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2460 i += MENU_ITEMS_PANE_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2461 } |
31465
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2462 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2463 { |
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2464 /* This is the boundary between left-side elts and |
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2465 right-side elts. */ |
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2466 ++i; |
b58d8e366faa
(xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents:
31365
diff
changeset
|
2467 } |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2468 else |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2469 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2470 entry |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2471 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2472 if (menu_item_selection == &XVECTOR (menu_items)->contents[i]) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2473 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2474 if (keymaps != 0) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2475 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2476 entry = Fcons (entry, Qnil); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2477 if (!NILP (prefix)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2478 entry = Fcons (prefix, entry); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2479 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2480 return entry; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2481 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2482 i += MENU_ITEMS_ITEM_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2483 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2484 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2485 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2486 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2487 return Qnil; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2488 } |
30299
f2cd2bf063c9
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30215
diff
changeset
|
2489 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2490 #else /* not USE_X_TOOLKIT */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2491 |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2492 /* The frame of the last activated non-toolkit menu bar. |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2493 Used to generate menu help events. */ |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2494 |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2495 static struct frame *menu_help_frame; |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2496 |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2497 |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2498 /* Show help HELP_STRING, or clear help if HELP_STRING is null. |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2499 |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2500 PANE is the pane number, and ITEM is the menu item number in |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2501 the menu (currently not used). |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2502 |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2503 This cannot be done with generating a HELP_EVENT because |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2504 XMenuActivate contains a loop that doesn't let Emacs process |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2505 keyboard events. */ |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2506 |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2507 static void |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2508 menu_help_callback (help_string, pane, item) |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2509 char *help_string; |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2510 int pane, item; |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2511 { |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2512 extern Lisp_Object Qmenu_item; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2513 Lisp_Object *first_item; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2514 Lisp_Object pane_name; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2515 Lisp_Object menu_object; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2516 |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2517 first_item = XVECTOR (menu_items)->contents; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2518 if (EQ (first_item[0], Qt)) |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2519 pane_name = first_item[MENU_ITEMS_PANE_NAME]; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2520 else if (EQ (first_item[0], Qquote)) |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2521 /* This shouldn't happen, see xmenu_show. */ |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2522 pane_name = build_string (""); |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2523 else |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2524 pane_name = first_item[MENU_ITEMS_ITEM_NAME]; |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2525 |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2526 /* (menu-item MENU-NAME PANE-NUMBER) */ |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2527 menu_object = Fcons (Qmenu_item, |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2528 Fcons (pane_name, |
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2529 Fcons (make_number (pane), Qnil))); |
30299
f2cd2bf063c9
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30215
diff
changeset
|
2530 show_help_echo (help_string ? build_string (help_string) : Qnil, |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2531 Qnil, menu_object, make_number (item), 1); |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2532 } |
30363
8f11e306dc02
(menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents:
30299
diff
changeset
|
2533 |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2534 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2535 static Lisp_Object |
11491
272baf4a077a
(xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents:
11449
diff
changeset
|
2536 xmenu_show (f, x, y, for_click, keymaps, title, error) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2537 FRAME_PTR f; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2538 int x, y; |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
2539 int for_click; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2540 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2541 Lisp_Object title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2542 char **error; |
118 | 2543 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2544 Window root; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2545 XMenu *menu; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2546 int pane, selidx, lpane, status; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2547 Lisp_Object entry, pane_prefix; |
118 | 2548 char *datap; |
2549 int ulx, uly, width, height; | |
2550 int dispwidth, dispheight; | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2551 int i, j; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2552 int maxwidth; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2553 int dummy_int; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2554 unsigned int dummy_uint; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2555 |
3747
6506b2fd475a
(xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
3501
diff
changeset
|
2556 *error = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2557 if (menu_items_n_panes == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2558 return Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2559 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2560 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2561 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2562 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2563 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2564 } |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2565 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2566 /* Figure out which root window F is on. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2567 XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &root, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2568 &dummy_int, &dummy_int, &dummy_uint, &dummy_uint, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2569 &dummy_uint, &dummy_uint); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2570 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2571 /* Make the menu on that window. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2572 menu = XMenuCreate (FRAME_X_DISPLAY (f), root, "emacs"); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2573 if (menu == NULL) |
118 | 2574 { |
2575 *error = "Can't create menu"; | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2576 return Qnil; |
118 | 2577 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2578 |
9572 | 2579 #ifdef HAVE_X_WINDOWS |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2580 /* Adjust coordinates to relative to the outer (window manager) window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2581 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2582 Window child; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2583 int win_x = 0, win_y = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2584 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2585 /* Find the position of the outside upper-left corner of |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2586 the inner window, with respect to the outer window. */ |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2587 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2588 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2589 BLOCK_INPUT; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2590 XTranslateCoordinates (FRAME_X_DISPLAY (f), |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2591 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2592 /* From-window, to-window. */ |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2593 f->output_data.x->window_desc, |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2594 f->output_data.x->parent_desc, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2595 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2596 /* From-position, to-position. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2597 0, 0, &win_x, &win_y, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2598 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2599 /* Child of window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2600 &child); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2601 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2602 x += win_x; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2603 y += win_y; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2604 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2605 } |
9572 | 2606 #endif /* HAVE_X_WINDOWS */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2607 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2608 /* Adjust coordinates to be root-window-relative. */ |
12667
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2609 x += f->output_data.x->left_pos; |
a3466dad7d6d
Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents:
12661
diff
changeset
|
2610 y += f->output_data.x->top_pos; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2611 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2612 /* Create all the necessary panes and their items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2613 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2614 while (i < menu_items_used) |
118 | 2615 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2616 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
118 | 2617 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2618 /* Create a new pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2619 Lisp_Object pane_name, prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2620 char *pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2621 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2622 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2623 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2624 pane_string = (NILP (pane_name) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2625 ? "" : (char *) XSTRING (pane_name)->data); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2626 if (keymaps && !NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2627 pane_string++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2628 |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2629 lpane = XMenuAddPane (FRAME_X_DISPLAY (f), menu, pane_string, TRUE); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2630 if (lpane == XM_FAILURE) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2631 { |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2632 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2633 *error = "Can't create pane"; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2634 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2635 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2636 i += MENU_ITEMS_PANE_LENGTH; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2637 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2638 /* Find the width of the widest item in this pane. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2639 maxwidth = 0; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2640 j = i; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2641 while (j < menu_items_used) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2642 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2643 Lisp_Object item; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2644 item = XVECTOR (menu_items)->contents[j]; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2645 if (EQ (item, Qt)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2646 break; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2647 if (NILP (item)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2648 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2649 j++; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2650 continue; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2651 } |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2652 width = STRING_BYTES (XSTRING (item)); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2653 if (width > maxwidth) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2654 maxwidth = width; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2655 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2656 j += MENU_ITEMS_ITEM_LENGTH; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2657 } |
118 | 2658 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2659 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2660 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2661 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2662 i += 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2663 else |
118 | 2664 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2665 /* Create a new item within current pane. */ |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2666 Lisp_Object item_name, enable, descrip, help; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2667 unsigned char *item_data; |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2668 char *help_string; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2669 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2670 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2671 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2672 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2673 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2674 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2675 help_string = STRINGP (help) ? XSTRING (help)->data : NULL; |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2676 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2677 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2678 { |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2679 int gap = maxwidth - STRING_BYTES (XSTRING (item_name)); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2680 #ifdef C_ALLOCA |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2681 Lisp_Object spacer; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2682 spacer = Fmake_string (make_number (gap), make_number (' ')); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2683 item_name = concat2 (item_name, spacer); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2684 item_name = concat2 (item_name, descrip); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2685 item_data = XSTRING (item_name)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2686 #else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2687 /* if alloca is fast, use that to make the space, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2688 to reduce gc needs. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2689 item_data |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2690 = (unsigned char *) alloca (maxwidth |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2691 + STRING_BYTES (XSTRING (descrip)) + 1); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2692 bcopy (XSTRING (item_name)->data, item_data, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2693 STRING_BYTES (XSTRING (item_name))); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2694 for (j = XSTRING (item_name)->size; j < maxwidth; j++) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2695 item_data[j] = ' '; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2696 bcopy (XSTRING (descrip)->data, item_data + j, |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2697 STRING_BYTES (XSTRING (descrip))); |
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21242
diff
changeset
|
2698 item_data[j + STRING_BYTES (XSTRING (descrip))] = 0; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2699 #endif |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2700 } |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2701 else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2702 item_data = XSTRING (item_name)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2703 |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2704 if (XMenuAddSelection (FRAME_X_DISPLAY (f), |
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2705 menu, lpane, 0, item_data, |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2706 !NILP (enable), help_string) |
118 | 2707 == XM_FAILURE) |
2708 { | |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2709 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
118 | 2710 *error = "Can't add selection to menu"; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2711 return Qnil; |
118 | 2712 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2713 i += MENU_ITEMS_ITEM_LENGTH; |
118 | 2714 } |
2715 } | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2716 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2717 /* All set and ready to fly. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2718 XMenuRecompute (FRAME_X_DISPLAY (f), menu); |
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2719 dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), |
9649
910da93766c8
(xmenu_show): Get the screen number for DisplayHeight
Richard M. Stallman <rms@gnu.org>
parents:
9619
diff
changeset
|
2720 XScreenNumberOfScreen (FRAME_X_SCREEN (f))); |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2721 dispheight = DisplayHeight (FRAME_X_DISPLAY (f), |
9649
910da93766c8
(xmenu_show): Get the screen number for DisplayHeight
Richard M. Stallman <rms@gnu.org>
parents:
9619
diff
changeset
|
2722 XScreenNumberOfScreen (FRAME_X_SCREEN (f))); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2723 x = min (x, dispwidth); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2724 y = min (y, dispheight); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2725 x = max (x, 1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2726 y = max (y, 1); |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2727 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y, |
118 | 2728 &ulx, &uly, &width, &height); |
2729 if (ulx+width > dispwidth) | |
2730 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2731 x -= (ulx + width) - dispwidth; |
118 | 2732 ulx = dispwidth - width; |
2733 } | |
2734 if (uly+height > dispheight) | |
2735 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2736 y -= (uly + height) - dispheight; |
118 | 2737 uly = dispheight - height; |
2738 } | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2739 if (ulx < 0) x -= ulx; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2740 if (uly < 0) y -= uly; |
6526
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2741 |
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2742 XMenuSetAEQ (menu, TRUE); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2743 XMenuSetFreeze (menu, TRUE); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2744 pane = selidx = 0; |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2745 |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2746 /* Help display under X won't work because XMenuActivate contains |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2747 a loop that doesn't give Emacs a chance to process it. */ |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2748 menu_help_frame = f; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2749 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, |
27458
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2750 x, y, ButtonReleaseMask, &datap, |
2bfd43d89c8e
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents:
27425
diff
changeset
|
2751 menu_help_callback); |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2752 |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2753 |
12131
fa4e74485660
(xmenu_show): If !HAVE_X_WINDOWS, don't reference X display.
Karl Heuer <kwzh@gnu.org>
parents:
12018
diff
changeset
|
2754 #ifdef HAVE_X_WINDOWS |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2755 /* Assume the mouse has moved out of the X window. |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2756 If it has actually moved in, we will get an EnterNotify. */ |
11528
29d1cbdd2ca4
(xmenu_show): x_mouse_leave needs an arg.
Karl Heuer <kwzh@gnu.org>
parents:
11502
diff
changeset
|
2757 x_mouse_leave (FRAME_X_DISPLAY_INFO (f)); |
12131
fa4e74485660
(xmenu_show): If !HAVE_X_WINDOWS, don't reference X display.
Karl Heuer <kwzh@gnu.org>
parents:
12018
diff
changeset
|
2758 #endif |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2759 |
118 | 2760 switch (status) |
2761 { | |
2762 case XM_SUCCESS: | |
2763 #ifdef XDEBUG | |
2764 fprintf (stderr, "pane= %d line = %d\n", panes, selidx); | |
2765 #endif | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2766 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2767 /* Find the item number SELIDX in pane number PANE. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2768 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2769 while (i < menu_items_used) |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
2770 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2771 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2772 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2773 if (pane == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2774 pane_prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2775 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2776 pane--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2777 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2778 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2779 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2780 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2781 if (pane == -1) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2782 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2783 if (selidx == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2784 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2785 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2786 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2787 if (keymaps != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2788 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2789 entry = Fcons (entry, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2790 if (!NILP (pane_prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2791 entry = Fcons (pane_prefix, entry); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2792 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2793 break; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2794 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2795 selidx--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2796 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2797 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2798 } |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
2799 } |
118 | 2800 break; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2801 |
118 | 2802 case XM_FAILURE: |
2803 *error = "Can't activate menu"; | |
2804 case XM_IA_SELECT: | |
2805 case XM_NO_SELECT: | |
2806 entry = Qnil; | |
2807 break; | |
2808 } | |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2809 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2810 |
9572 | 2811 #ifdef HAVE_X_WINDOWS |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2812 /* State that no mouse buttons are now held. |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2813 (The oldXMenu code doesn't track this info for us.) |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2814 That is not necessarily true, but the fiction leads to reasonable |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2815 results, and it is a pain to ask which are actually held now. */ |
9619
1c985426ad84
(xdialog_show, xmenu_show): Use grabbed field instead of x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
9608
diff
changeset
|
2816 FRAME_X_DISPLAY_INFO (f)->grabbed = 0; |
9572 | 2817 #endif |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2818 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2819 return entry; |
118 | 2820 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2821 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2822 #endif /* not USE_X_TOOLKIT */ |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
2823 |
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
2824 #endif /* HAVE_MENUS */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2825 |
21514 | 2826 void |
118 | 2827 syms_of_xmenu () |
2828 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2829 staticpro (&menu_items); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2830 menu_items = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2831 |
12625
e2831d2f5b09
(syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents:
12432
diff
changeset
|
2832 Qdebug_on_next_call = intern ("debug-on-next-call"); |
e2831d2f5b09
(syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents:
12432
diff
changeset
|
2833 staticpro (&Qdebug_on_next_call); |
e2831d2f5b09
(syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents:
12432
diff
changeset
|
2834 |
16656
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
2835 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame, |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
2836 "Frame for which we are updating a menu.\n\ |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
2837 The enable predicate for a menu command should check this variable."); |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
2838 Vmenu_updating_frame = Qnil; |
9cbbf721b91c
(Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16411
diff
changeset
|
2839 |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2840 #ifdef USE_X_TOOLKIT |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2841 widget_id_tick = (1<<16); |
12661 | 2842 next_menubar_widget_id = 1; |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2843 #endif |
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2844 |
118 | 2845 defsubr (&Sx_popup_menu); |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
2846 #ifdef HAVE_MENUS |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2847 defsubr (&Sx_popup_dialog); |
14741
9f9c4d4581e4
Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents:
14553
diff
changeset
|
2848 #endif |
118 | 2849 } |