Mercurial > emacs
annotate src/xmenu.c @ 7948:ded078d63369
(GETTIMEOFDAY_ONE_ARGUMENT): Undef it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 17 Jun 1994 23:51:52 +0000 |
parents | 60795e826dad |
children | dda8e966edf5 |
rev | line source |
---|---|
118 | 1 /* X Communication module for terminals which understand the X protocol. |
6018
51d9a0c72a29
(single_keymap_panes): Properly skip help-string if any.
Richard M. Stallman <rms@gnu.org>
parents:
6007
diff
changeset
|
2 Copyright (C) 1986, 1988, 1993, 1994 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 | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* X pop-up deck-of-cards menu facility for gnuemacs. | |
21 * | |
22 * Written by Jon Arnold and Roman Budzianowski | |
23 * Mods and rewrite by Robert Krawitz | |
24 * | |
25 */ | |
26 | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
27 /* 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
|
28 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
|
29 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
30 /* 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
|
31 |
118 | 32 /* On 4.3 this loses if it comes after xterm.h. */ |
33 #include <signal.h> | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4627
diff
changeset
|
34 #include <config.h> |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
35 |
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
36 #include <stdio.h> |
118 | 37 #include "lisp.h" |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
38 #include "termhooks.h" |
770 | 39 #include "frame.h" |
118 | 40 #include "window.h" |
1304
93d55019750e
* xmenu.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1213
diff
changeset
|
41 #include "keyboard.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
42 #include "blockinput.h" |
118 | 43 |
44 /* This may include sys/types.h, and that somehow loses | |
45 if this is not done before the other system files. */ | |
46 #include "xterm.h" | |
47 | |
48 /* Load sys/types.h if not already loaded. | |
49 In some systems loading it twice is suicidal. */ | |
50 #ifndef makedev | |
51 #include <sys/types.h> | |
52 #endif | |
53 | |
54 #include "dispextern.h" | |
55 | |
56 #ifdef HAVE_X11 | |
57 #include "../oldXMenu/XMenu.h" | |
58 #else | |
59 #include <X/XMenu.h> | |
60 #endif | |
61 | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
62 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
63 #include <X11/Xlib.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
64 #include <X11/IntrinsicP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
65 #include <X11/CoreP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
66 #include <X11/StringDefs.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
67 #include <X11/Xaw/Paned.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
68 #include "../lwlib/lwlib.h" |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
69 #include "../lwlib/xlwmenuP.h" |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
70 #endif /* USE_X_TOOLKIT */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
71 |
118 | 72 #define min(x,y) (((x) < (y)) ? (x) : (y)) |
73 #define max(x,y) (((x) > (y)) ? (x) : (y)) | |
74 | |
75 #ifndef TRUE | |
76 #define TRUE 1 | |
77 #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
|
78 #endif /* no TRUE */ |
118 | 79 |
80 #ifdef HAVE_X11 | |
81 extern Display *x_current_display; | |
82 #else | |
83 #define ButtonReleaseMask ButtonReleased | |
84 #endif /* not HAVE_X11 */ | |
85 | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
86 /* We need a unique id for each popup menu and dialog box. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
87 static unsigned int popup_id_tick; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
88 |
2514
6700e25af205
Since Qmenu_enable is used by non-X-specific code, it shouldn't be
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
89 extern Lisp_Object Qmenu_enable; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
90 extern Lisp_Object Qmenu_bar; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
91 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
92 #ifdef 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
|
93 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
|
94 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
|
95 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
96 static Lisp_Object xdialog_show (); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
97 #endif |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
98 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
99 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
|
100 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
|
101 static void single_keymap_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
102 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
|
103 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
|
104 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
105 /* 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
|
106 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
|
107 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
108 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
|
109 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
110 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
|
111 t, the pane name, the pane's prefix key. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
112 Then follow the pane's items, with 4 elements per item: |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
113 the item string, the enable flag, the 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
|
114 and the equivalent keyboard key's description string. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
115 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 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
|
120 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
121 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
|
122 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
|
123 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
124 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
|
125 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
|
126 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
127 #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
|
128 #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
|
129 #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
|
130 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
131 #define MENU_ITEMS_ITEM_NAME 0 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
132 #define MENU_ITEMS_ITEM_ENABLE 1 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
133 #define MENU_ITEMS_ITEM_VALUE 2 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
134 #define MENU_ITEMS_ITEM_EQUIV_KEY 3 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
135 #define MENU_ITEMS_ITEM_LENGTH 4 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
136 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
137 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
|
138 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
139 /* 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
|
140 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
|
141 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
142 /* 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
|
143 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
|
144 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
145 /* 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
|
146 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
|
147 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
|
148 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
149 /* Current depth within submenus. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
150 static int menu_items_submenu_depth; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
151 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
152 /* 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
|
153 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
|
154 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
155 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
156 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
|
157 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
158 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
|
159 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
160 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
|
161 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
|
162 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
163 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
164 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
|
165 menu_items_n_panes = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
166 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
|
167 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
168 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
169 /* 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
|
170 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
|
171 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
172 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
173 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
|
174 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
175 } |
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 /* 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
|
178 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
|
179 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
180 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
181 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
|
182 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
183 /* 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
|
184 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
|
185 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
|
186 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
187 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
|
188 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
|
189 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
190 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
191 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
192 /* 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
|
193 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
194 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
195 grow_menu_items () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
196 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
197 Lisp_Object old; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
198 int old_size = menu_items_allocated; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
199 old = menu_items; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
200 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
201 menu_items_allocated *= 2; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
202 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
|
203 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
|
204 old_size * sizeof (Lisp_Object)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
205 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
206 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
207 /* Begin a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
208 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
209 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
210 push_submenu_start () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
211 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
212 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
|
213 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
214 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
215 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
|
216 menu_items_submenu_depth++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
217 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
218 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
219 /* End a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
220 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
221 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
222 push_submenu_end () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
223 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
224 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
|
225 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
226 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
227 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
|
228 menu_items_submenu_depth--; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
229 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
230 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
231 /* Indicate boundary between left and right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
232 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
233 static void |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
234 push_left_right_boundary () |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
235 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
236 if (menu_items_used + 1 > menu_items_allocated) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
237 grow_menu_items (); |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
238 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
239 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
240 } |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
241 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
242 /* 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
|
243 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
|
244 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
245 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
246 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
|
247 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
|
248 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
249 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
|
250 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
|
251 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
252 if (menu_items_submenu_depth == 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
253 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
|
254 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
|
255 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
|
256 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
|
257 } |
118 | 258 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
259 /* Push one menu item into the current pane. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
260 NAME is the string to display. ENABLE if non-nil means |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
261 this item can be selected. KEY is the key generated by |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
262 choosing this item. EQUIV is the textual description |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
263 of the keyboard equivalent for this item (or nil if none). */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
264 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
265 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
266 push_menu_item (name, enable, key, equiv) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
267 Lisp_Object name, enable, key, equiv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
268 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
269 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
|
270 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
|
271 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
272 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
|
273 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
|
274 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
|
275 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
276 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
277 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
278 /* Figure out the current keyboard equivalent of a menu item ITEM1. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
279 The item string for menu display should be ITEM_STRING. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
280 Store the equivalent keyboard key sequence's |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
281 textual description into *DESCRIP_PTR. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
282 Also cache them in the item itself. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
283 Return the real definition to execute. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
284 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
285 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
286 menu_item_equiv_key (item_string, item1, descrip_ptr) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
287 Lisp_Object item_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
288 Lisp_Object item1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
289 Lisp_Object *descrip_ptr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
290 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
291 /* This is the real definition--the function to run. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
292 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
293 /* This is the sublist that records cached equiv key data |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
294 so we can save time. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
295 Lisp_Object cachelist; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
296 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
297 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
298 Lisp_Object savedkey, descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
299 Lisp_Object def1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
300 int changed = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
301 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
302 /* If a help string follows the item string, skip it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
303 if (CONSP (XCONS (item1)->cdr) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
304 && STRINGP (XCONS (XCONS (item1)->cdr)->car)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
305 item1 = XCONS (item1)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
306 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
307 def = Fcdr (item1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
308 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
309 /* Get out the saved equivalent-keyboard-key info. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
310 cachelist = savedkey = descrip = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
311 if (CONSP (def) && CONSP (XCONS (def)->car) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
312 && (NILP (XCONS (XCONS (def)->car)->car) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
313 || VECTORP (XCONS (XCONS (def)->car)->car))) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
314 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
315 cachelist = XCONS (def)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
316 def = XCONS (def)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
317 savedkey = XCONS (cachelist)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
318 descrip = XCONS (cachelist)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
319 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
320 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
321 /* Is it still valid? */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
322 def1 = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
323 if (!NILP (savedkey)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
324 def1 = Fkey_binding (savedkey, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
325 /* If not, update it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
326 if (! EQ (def1, def) |
7832
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
327 /* If the command is an alias for another |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
328 (such as easymenu.el and lmenu.el set it up), |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
329 check if the original command matches the cached command. */ |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
330 && !(SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function) |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
331 && EQ (def1, XSYMBOL (def)->function)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
332 /* If something had no key binding before, don't recheck it-- |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
333 doing that takes too much time and makes menus too slow. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
334 && !(!NILP (cachelist) && NILP (savedkey))) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
335 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
336 changed = 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
337 descrip = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
338 savedkey = Fwhere_is_internal (def, Qnil, Qt, Qnil); |
7679
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
339 /* If the command is an alias for another |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
340 (such as easymenu.el and lmenu.el set it up), |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
341 see if the original command name has equivalent keys. */ |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
342 if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function)) |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
343 savedkey = Fwhere_is_internal (XSYMBOL (def)->function, |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
344 Qnil, Qt, Qnil); |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
345 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
346 if (VECTORP (savedkey) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
347 && EQ (XVECTOR (savedkey)->contents[0], Qmenu_bar)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
348 savedkey = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
349 if (!NILP (savedkey)) |
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 descrip = Fkey_description (savedkey); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
352 descrip = concat2 (make_string (" (", 3), descrip); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
353 descrip = concat2 (descrip, make_string (")", 1)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
354 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
355 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
356 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
357 /* Cache the data we just got in a sublist of the menu binding. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
358 if (NILP (cachelist)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
359 XCONS (item1)->cdr = Fcons (Fcons (savedkey, descrip), def); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
360 else if (changed) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
361 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
362 XCONS (cachelist)->car = savedkey; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
363 XCONS (cachelist)->cdr = descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
364 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
365 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
366 *descrip_ptr = descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
367 return def; |
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 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
370 /* This is used as the handler when calling internal_condition_case_1. */ |
118 | 371 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
372 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
373 menu_item_enabled_p_1 (arg) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
374 Lisp_Object arg; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
375 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
376 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
377 } |
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 /* Return non-nil if the command DEF is enabled when used as a menu item. |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
380 This is based on looking for a menu-enable property. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
381 If NOTREAL is set, don't bother really computing this. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
382 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
383 static Lisp_Object |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
384 menu_item_enabled_p (def, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
385 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
386 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
387 Lisp_Object enabled, tem; |
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 enabled = Qt; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
390 if (notreal) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
391 return enabled; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
392 if (XTYPE (def) == Lisp_Symbol) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
393 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
394 /* No property, or nil, means enable. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
395 Otherwise, enable if value is not nil. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
396 tem = Fget (def, Qmenu_enable); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
397 if (!NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
398 /* (condition-case nil (eval tem) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
399 (error nil)) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
400 enabled = internal_condition_case_1 (Feval, tem, Qerror, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
401 menu_item_enabled_p_1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
402 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
403 return enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
404 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
405 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
406 /* 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
|
407 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
|
408 If NOTREAL is nonzero, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
409 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
|
410 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
411 static void |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
412 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
|
413 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
|
414 int nmaps; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
415 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
|
416 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
417 int mapno; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
418 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
419 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
|
420 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
421 /* 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
|
422 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
|
423 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
|
424 for (mapno = 0; mapno < nmaps; mapno++) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
425 single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
426 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
427 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
|
428 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
429 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
430 /* 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
|
431 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
|
432 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
|
433 or point to local variables of the previous function. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
434 If NOTREAL is nonzero, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
435 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
|
436 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
437 static void |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
438 single_keymap_panes (keymap, pane_name, prefix, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
439 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
|
440 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
|
441 Lisp_Object prefix; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
442 int notreal; |
118 | 443 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
444 Lisp_Object pending_maps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
445 Lisp_Object tail, item, item1, item_string, table; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
446 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
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 pending_maps = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
449 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
450 push_menu_pane (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
|
451 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
452 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
453 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
454 /* Look at each key binding, and if it has a menu string, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
455 make a menu item from it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
456 item = XCONS (tail)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
457 if (XTYPE (item) == Lisp_Cons) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
458 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
459 item1 = XCONS (item)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
460 if (XTYPE (item1) == Lisp_Cons) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
461 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
462 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
463 if (XTYPE (item_string) == Lisp_String) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
464 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
465 /* This is the real definition--the function to run. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
466 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
467 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
468 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
469 Lisp_Object descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
470 Lisp_Object tem, enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
471 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
472 def = menu_item_equiv_key (item_string, item1, &descrip); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
473 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
474 /* GCPRO because we will call eval. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
475 Protecting KEYMAP preserves everything we use; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
476 aside from that, must protect whatever might be |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
477 a string. Since there's no GCPRO5, we refetch |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
478 item_string instead of protecting it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
479 GCPRO4 (keymap, pending_maps, def, descrip); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
480 enabled = menu_item_enabled_p (def, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
481 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
482 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
483 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
484 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
485 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
486 tem = Fkeymapp (def); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
487 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
488 pending_maps = Fcons (Fcons (def, Fcons (item_string, XCONS (item)->car)), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
489 pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
490 else |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
491 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
492 Lisp_Object submap; |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
493 GCPRO4 (keymap, pending_maps, descrip, item_string); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
494 submap = get_keymap_1 (def, 0, 1); |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
495 UNGCPRO; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
496 #ifndef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
497 /* Indicate visually that this is a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
498 if (!NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
499 item_string = concat2 (item_string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
500 build_string (" >")); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
501 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
502 push_menu_item (item_string, enabled, XCONS (item)->car, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
503 descrip); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
504 #ifdef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
505 /* Display a submenu using the toolkit. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
506 if (! NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
507 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
508 push_submenu_start (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
509 single_keymap_panes (submap, Qnil, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
510 XCONS (item)->car, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
511 push_submenu_end (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
512 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
513 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
514 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
515 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
516 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
517 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
518 else if (XTYPE (item) == Lisp_Vector) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
519 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
520 /* 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
|
521 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
|
522 int c; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
523 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
|
524 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
525 Lisp_Object character; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
526 XFASTINT (character) = c; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
527 item1 = XVECTOR (item)->contents[c]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
528 if (XTYPE (item1) == Lisp_Cons) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
529 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
530 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
531 if (XTYPE (item_string) == Lisp_String) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
532 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
533 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
534 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
535 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
536 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
537 Lisp_Object descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
538 Lisp_Object tem, enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
539 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
540 def = menu_item_equiv_key (item_string, item1, &descrip); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
541 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
542 /* GCPRO because we will call eval. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
543 Protecting KEYMAP preserves everything we use; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
544 aside from that, must protect whatever might be |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
545 a string. Since there's no GCPRO5, we refetch |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
546 item_string instead of protecting it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
547 GCPRO4 (keymap, pending_maps, def, descrip); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
548 enabled = menu_item_enabled_p (def, notreal); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
549 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
550 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
551 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
552 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
553 tem = Fkeymapp (def); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
554 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
555 pending_maps = Fcons (Fcons (def, Fcons (item_string, character)), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
556 pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
557 else |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
558 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
559 Lisp_Object submap; |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
560 GCPRO4 (keymap, pending_maps, descrip, item_string); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
561 submap = get_keymap_1 (def, 0, 1); |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
562 UNGCPRO; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
563 #ifndef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
564 if (!NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
565 item_string = concat2 (item_string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
566 build_string (" >")); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
567 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
568 push_menu_item (item_string, enabled, character, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
569 descrip); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
570 #ifdef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
571 if (! NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
572 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
573 push_submenu_start (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
574 single_keymap_panes (submap, Qnil, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
575 character, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
576 push_submenu_end (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
577 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
578 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
579 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
580 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
581 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
582 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
583 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
584 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
585 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
586 /* 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
|
587 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
|
588 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
589 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
|
590 elt = Fcar (pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
591 eltcdr = XCONS (elt)->cdr; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
592 string = XCONS (eltcdr)->car; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
593 /* 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
|
594 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
|
595 single_keymap_panes (Fcar (elt), string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
596 XCONS (eltcdr)->cdr, notreal); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
597 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
|
598 } |
118 | 599 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
600 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
601 /* Push all the panes and items of a menu decsribed by the |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
602 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
|
603 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
|
604 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
605 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
606 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
|
607 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
|
608 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
609 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
|
610 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
611 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
|
612 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
613 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
|
614 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
615 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 } |
118 | 624 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
625 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
|
626 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
627 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
628 /* 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
|
629 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
630 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
631 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
|
632 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
|
633 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
634 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
|
635 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
636 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
|
637 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
638 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
|
639 if (STRINGP (item)) |
6406
6c9903c97bf4
(list_of_items): Arg to push_menu_item was missing.
Richard M. Stallman <rms@gnu.org>
parents:
6395
diff
changeset
|
640 push_menu_item (item, Qnil, Qnil, Qnil); |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
641 else if (NILP (item)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
642 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
|
643 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
644 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
645 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
|
646 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
|
647 CHECK_STRING (item1, 1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
648 push_menu_item (item1, Qt, Fcdr (item), Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
649 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
650 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
651 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
652 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
653 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, |
118 | 654 "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
|
655 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
|
656 or a list ((XOFFSET YOFFSET) WINDOW)\n\ |
7175
5fa65268508b
(Fx_popup_menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7129
diff
changeset
|
657 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
|
658 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\ |
118 | 659 This controls the position of the center of the first line\n\ |
660 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
|
661 If POSITION is t, it means to use the current mouse position.\n\ |
118 | 662 \n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
663 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
|
664 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
|
665 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
|
666 \(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
|
667 the keymap as a top-level element.\n\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 is a list of events.\n\n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 \n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
680 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
|
681 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
|
682 (position, menu) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
683 Lisp_Object position, menu; |
118 | 684 { |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
685 int number_of_panes, panes; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
686 Lisp_Object keymap, tem; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
687 int xpos, ypos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
688 Lisp_Object title; |
118 | 689 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
|
690 Lisp_Object selection; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
691 int i, j; |
770 | 692 FRAME_PTR f; |
118 | 693 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
|
694 int keymaps = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
695 int menubarp = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
696 struct gcpro gcpro1; |
118 | 697 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
698 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
|
699 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
700 check_x (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
701 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
702 /* Decode the first argument: find the window and the coordinates. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
703 if (EQ (position, Qt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
704 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
705 /* Use the mouse's current position. */ |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
706 FRAME_PTR new_f = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
707 Lisp_Object bar_window; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
708 int part; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
709 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
|
710 |
7334
fcea4173315d
(Fx_popup_menu): Restore accidentally-deleted call to mouse_position_hook.
Karl Heuer <kwzh@gnu.org>
parents:
7208
diff
changeset
|
711 if (mouse_position_hook) |
fcea4173315d
(Fx_popup_menu): Restore accidentally-deleted call to mouse_position_hook.
Karl Heuer <kwzh@gnu.org>
parents:
7208
diff
changeset
|
712 (*mouse_position_hook) (&new_f, &bar_window, &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
|
713 if (new_f != 0) |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
714 XSET (window, Lisp_Frame, new_f); |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
715 else |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
716 { |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
717 window = selected_window; |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
718 XFASTINT (x) = 0; |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
719 XFASTINT (y) = 0; |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
720 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
721 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
722 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
723 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
724 tem = Fcar (position); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
725 if (XTYPE (tem) == Lisp_Cons) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
726 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
727 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
|
728 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
|
729 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
|
730 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
731 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
732 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
733 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
|
734 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
|
735 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
|
736 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
|
737 y = Fcdr (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
738 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
739 /* Determine whether this menu is handling a menu bar click. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
740 tem = Fcar (Fcdr (Fcar (Fcdr (position)))); |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
741 if (CONSP (tem) && EQ (Fcar (tem), Qmenu_bar)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
742 menubarp = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
743 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
744 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
745 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
746 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
|
747 CHECK_NUMBER (y, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
748 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
749 /* 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
|
750 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
751 if (XTYPE (window) == Lisp_Frame) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
752 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
753 f = XFRAME (window); |
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 xpos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
756 ypos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
757 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
758 else if (XTYPE (window) == Lisp_Window) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
759 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
760 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
|
761 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
|
762 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
763 xpos = (FONT_WIDTH (f->display.x->font) * XWINDOW (window)->left); |
6764
52b64d326287
(Fx_popup_menu): Use line_height field.
Richard M. Stallman <rms@gnu.org>
parents:
6746
diff
changeset
|
764 ypos = (f->display.x->line_height * 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
|
765 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
766 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
767 /* ??? 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
|
768 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
|
769 CHECK_WINDOW (window, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
770 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
771 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
|
772 ypos += XINT (y); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
773 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
774 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
775 title = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
776 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
|
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 /* 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
|
779 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
780 keymap = Fkeymapp (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
781 tem = Qnil; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
782 if (XTYPE (menu) == Lisp_Cons) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
783 tem = Fkeymapp (Fcar (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
784 if (!NILP (keymap)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
785 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
786 /* 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
|
787 Lisp_Object prompt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
788 keymap = get_keymap (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
789 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
790 /* 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
|
791 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
|
792 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
793 /* 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
|
794 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
|
795 prompt = map_prompt (keymap); |
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 /* 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
|
798 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
|
799 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
|
800 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
801 keymaps = 1; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
802 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
803 else if (!NILP (tem)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
804 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
805 /* 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
|
806 int nmaps = XFASTINT (Flength (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
807 Lisp_Object *maps |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
808 = (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
|
809 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
|
810 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
811 title = Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
812 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
813 /* 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
|
814 supplies the menu title. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
815 for (tem = menu, i = 0; XTYPE (tem) == Lisp_Cons; tem = Fcdr (tem)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
816 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
817 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
|
818 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
819 maps[i++] = keymap = get_keymap (Fcar (tem)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
820 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
821 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
|
822 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
|
823 title = prompt; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
824 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
825 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
826 /* 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
|
827 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
|
828 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
829 /* 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
|
830 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
|
831 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
|
832 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
833 keymaps = 1; |
1082
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 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
836 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
837 /* 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
|
838 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
|
839 CHECK_STRING (title, 1); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
840 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
841 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
|
842 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
843 keymaps = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
844 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
845 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
846 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
|
847 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
848 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
|
849 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
850 return Qnil; |
118 | 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 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
853 /* 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
|
854 BLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
855 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
856 selection = xmenu_show (f, xpos, ypos, menubarp, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
857 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
|
858 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
859 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
860 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
|
861 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
862 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
863 |
118 | 864 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
|
865 return selection; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
866 } |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
867 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
868 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
|
869 "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
|
870 POSITION specifies which frame to use.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
871 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
|
872 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
|
873 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
|
874 \n\ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 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
|
881 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
|
882 \(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
|
883 (position, contents) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
884 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
|
885 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
886 FRAME_PTR f; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
887 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
|
888 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
889 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
|
890 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
891 /* Decode the first argument: find the window or frame to use. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
892 if (EQ (position, Qt)) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
893 { |
6653
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
894 #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
|
895 /* Use the mouse's current position. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
896 FRAME_PTR new_f = 0; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
897 Lisp_Object bar_window; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
898 int part; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
899 unsigned long time; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
900 Lisp_Object x, y; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
901 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
902 (*mouse_position_hook) (&new_f, &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
|
903 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
904 if (new_f != 0) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
905 XSET (window, Lisp_Frame, new_f); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
906 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
907 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
|
908 #endif |
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
909 /* Decode the first argument: find the window and the coordinates. */ |
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
910 if (EQ (position, Qt)) |
6656
19bcf36f315e
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6653
diff
changeset
|
911 window = selected_window; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
912 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
913 else if (CONSP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
914 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
915 Lisp_Object tem; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
916 tem = Fcar (position); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
917 if (XTYPE (tem) == Lisp_Cons) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
918 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
|
919 else |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
920 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
921 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
922 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
|
923 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
924 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
925 else if (WINDOWP (position) || FRAMEP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
926 window = position; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
927 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
928 /* 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
|
929 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
930 if (XTYPE (window) == Lisp_Frame) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
931 f = XFRAME (window); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
932 else if (XTYPE (window) == Lisp_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
|
933 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
934 CHECK_LIVE_WINDOW (window, 0); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
935 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
|
936 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
937 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
938 /* ??? 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
|
939 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
|
940 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
|
941 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
942 #ifndef USE_X_TOOLKIT |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
943 /* Display a menu with these alternatives |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
944 in the middle of frame F. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
945 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
946 Lisp_Object x, y, frame, newpos; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
947 XSET (frame, Lisp_Frame, f); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
948 XSET (x, Lisp_Int, x_pixel_width (f) / 2); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
949 XSET (y, Lisp_Int, x_pixel_height (f) / 2); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
950 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
|
951 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
952 return Fx_popup_menu (newpos, |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
953 Fcons (Fcar (contents), Fcons (contents, Qnil))); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
954 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
955 #else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
956 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
957 Lisp_Object title; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
958 char *error_name; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
959 Lisp_Object selection; |
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 /* 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
|
962 title = Fcar (contents); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
963 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
|
964 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
965 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
|
966 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
967 /* Display them in a dialog box. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
968 BLOCK_INPUT; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
969 selection = xdialog_show (f, 0, 0, title, &error_name); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
970 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
|
971 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
972 discard_menu_items (); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
973 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
974 if (error_name) error (error_name); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
975 return selection; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
976 } |
6325
d6817c9c0413
Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents:
6324
diff
changeset
|
977 #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
|
978 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
979 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
980 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
981 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
982 static void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
983 dispatch_dummy_expose (w, x, y) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
984 Widget w; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
985 int x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
986 int y; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
987 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
988 XExposeEvent dummy; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
989 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
990 dummy.type = Expose; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
991 dummy.window = XtWindow (w); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
992 dummy.count = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
993 dummy.serial = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
994 dummy.send_event = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
995 dummy.display = XtDisplay (w); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
996 dummy.x = x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
997 dummy.y = y; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
998 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
999 XtDispatchEvent ((XEvent *) &dummy); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1000 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1001 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1002 static int |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1003 event_is_in_menu_item (mw, event, name, string_w) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1004 XlwMenuWidget mw; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1005 struct input_event *event; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1006 char *name; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1007 int *string_w; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1008 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1009 *string_w += (string_width (mw, name) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1010 + 2 * (mw->menu.horizontal_spacing |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1011 + mw->menu.shadow_thickness)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1012 return XINT (event->x) < *string_w; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1013 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1014 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1015 |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1016 /* Return the menu bar key which corresponds to event EVENT in frame F. */ |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1017 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1018 Lisp_Object |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1019 map_event_to_object (event, f) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1020 struct input_event *event; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1021 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1022 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1023 int i,j, string_w; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1024 window_state* ws; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1025 XlwMenuWidget mw = (XlwMenuWidget) f->display.x->menubar_widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1026 widget_value *val; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1027 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1028 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1029 string_w = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1030 /* Find the window */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1031 for (val = mw->menu.old_stack [0]->contents; val; val = val->next) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1032 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1033 ws = &mw->menu.windows [0]; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1034 if (ws && event_is_in_menu_item (mw, event, val->name, &string_w)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1035 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1036 Lisp_Object items; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1037 int i; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1038 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1039 items = FRAME_MENU_BAR_ITEMS (f); |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1040 |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1041 for (i = 0; i < XVECTOR (items)->size; i += 3) |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1042 { |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1043 Lisp_Object pos, string, item; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1044 item = XVECTOR (items)->contents[i]; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1045 string = XVECTOR (items)->contents[i + 1]; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1046 pos = XVECTOR (items)->contents[i + 2]; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1047 if (NILP (string)) |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1048 break; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1049 |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1050 if (!strcmp (val->name, XSTRING (string)->data)) |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1051 return item; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1052 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1053 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1054 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1055 return Qnil; |
118 | 1056 } |
1057 | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1058 static Lisp_Object *menu_item_selection; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1059 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1060 static void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1061 popup_selection_callback (widget, id, client_data) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1062 Widget widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1063 LWLIB_ID id; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1064 XtPointer client_data; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1065 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1066 menu_item_selection = (Lisp_Object *) client_data; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1067 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1068 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1069 static void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1070 popup_down_callback (widget, id, client_data) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1071 Widget widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1072 LWLIB_ID id; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1073 XtPointer client_data; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1074 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1075 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1076 lw_destroy_all_widgets (id); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1077 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1078 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1079 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1080 static void |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1081 dialog_selection_callback (widget, id, client_data) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1082 Widget widget; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1083 LWLIB_ID id; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1084 XtPointer client_data; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1085 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1086 if ((int)client_data != -1) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1087 menu_item_selection = (Lisp_Object *) client_data; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1088 BLOCK_INPUT; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1089 lw_destroy_all_widgets (id); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1090 UNBLOCK_INPUT; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1091 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1092 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1093 /* This recursively calls free_widget_value() on the tree of widgets. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1094 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
|
1095 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
|
1096 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
|
1097 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1098 void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1099 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
|
1100 widget_value *wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1101 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1102 if (! wv) return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1103 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1104 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
|
1105 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1106 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
|
1107 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1108 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
|
1109 wv->contents = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1110 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1111 if (wv->next) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1112 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1113 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
|
1114 wv->next = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1115 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1116 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1117 free_widget_value (wv); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1118 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1119 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1120 |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1121 extern void EmacsFrameSetCharSize (); |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1122 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1123 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
|
1124 update_frame_menubar (f) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1125 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1126 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1127 struct x_display *x = f->display.x; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1128 int columns, rows; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1129 int menubar_changed; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1130 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1131 menubar_changed = (x->menubar_widget |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1132 && !XtIsManaged (x->menubar_widget)); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1133 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1134 if (! (menubar_changed)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1135 return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1136 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1137 BLOCK_INPUT; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1138 /* 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
|
1139 resize itself. So force it. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1140 columns = f->width; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1141 rows = f->height; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1142 |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1143 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1144 XawPanedSetRefigureMode (x->column_widget, 0); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1145 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1146 /* 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
|
1147 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
|
1148 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
|
1149 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1150 XtUnmanageChild (x->edit_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1151 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1152 /* 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
|
1153 should be there. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1154 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1155 if (menubar_changed) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1156 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1157 XtManageChild (x->menubar_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1158 XtMapWidget (x->menubar_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1159 XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, 0); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1160 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1161 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1162 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1163 /* Re-manage the text-area widget */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1164 XtManageChild (x->edit_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1165 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1166 /* and now thrash the sizes */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1167 XawPanedSetRefigureMode (x->column_widget, 1); |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1168 |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1169 /* 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
|
1170 EmacsFrameSetCharSize (x->edit_widget, columns, rows); |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1171 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1172 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1173 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1174 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1175 void |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1176 set_frame_menubar (f, first_time) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1177 FRAME_PTR f; |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1178 int first_time; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1179 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1180 Widget menubar_widget = f->display.x->menubar_widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1181 int id = (int) f; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1182 Lisp_Object tail, items; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1183 widget_value *wv, *save_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
|
1184 int i; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1185 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1186 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1187 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1188 wv = malloc_widget_value (); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1189 wv->name = "menubar"; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1190 wv->value = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1191 wv->enabled = 1; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1192 save_wv = first_wv = wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1193 |
6481
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1194 if (NILP (items = FRAME_MENU_BAR_ITEMS (f))) |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1195 items = FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1196 |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1197 for (i = 0; i < XVECTOR (items)->size; i += 3) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1198 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1199 Lisp_Object string; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1200 |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1201 string = XVECTOR (items)->contents[i + 1]; |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1202 if (NILP (string)) |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1203 break; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1204 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1205 wv = malloc_widget_value (); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1206 if (prev_wv) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1207 prev_wv->next = wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1208 else |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1209 save_wv->contents = wv; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1210 wv->name = (char *) XSTRING (string)->data; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1211 wv->value = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1212 wv->enabled = 1; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1213 prev_wv = wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1214 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1215 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1216 if (menubar_widget) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1217 lw_modify_all_widgets (id, first_wv, False); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1218 else |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1219 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1220 menubar_widget = lw_create_widget ("menubar", "menubar", |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1221 id, first_wv, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1222 f->display.x->column_widget, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1223 0, 0, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1224 0, 0); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1225 f->display.x->menubar_widget = menubar_widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1226 XtVaSetValues (menubar_widget, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1227 XtNshowGrip, 0, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1228 XtNresizeToPreferred, 1, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1229 XtNallowResize, 1, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1230 0); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1231 } |
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 free_menubar_widget_value_tree (first_wv); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1234 |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1235 /* Don't update the menubar the first time it is created via x_window. */ |
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1236 if (!first_time) |
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1237 update_frame_menubar (f); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1238 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1239 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1240 } |
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
|
1241 |
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
|
1242 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
|
1243 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
|
1244 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
|
1245 { |
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
|
1246 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
|
1247 int id; |
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
|
1248 |
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
|
1249 menubar_widget = f->display.x->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
|
1250 id = (int) 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
|
1251 |
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
|
1252 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
|
1253 { |
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
|
1254 BLOCK_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
|
1255 lw_destroy_all_widgets (id); |
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
|
1256 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
|
1257 } |
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
|
1258 } |
6481
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1259 /* Called from Fx_create_frame to create the inital menubar of a frame |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1260 before it is mapped, so that the window is mapped with the menubar already |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1261 there instead of us tacking it on later and thrashing the window after it |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1262 is visible. */ |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1263 void |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1264 initialize_frame_menubar (f) |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1265 FRAME_PTR f; |
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1266 { |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1267 set_frame_menubar (f, 1); |
6481
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1268 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1269 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1270 /* Horizontal bounds of the current menu bar item. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1271 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1272 static int this_menu_bar_item_beg; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1273 static int this_menu_bar_item_end; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1274 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1275 /* Horizontal position of the end of the last menu bar item. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1276 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1277 static int last_menu_bar_item_end; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1278 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1279 /* Nonzero if position X, Y is in the menu bar and in some menu bar item |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1280 but not in the current menu bar item. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1281 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1282 static int |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1283 other_menu_bar_item_p (f, x, y) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1284 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
|
1285 int x, y; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1286 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1287 return (y >= 0 |
7554
9e9b7a0eebc6
(other_menu_bar_item_p): Return 0 if no menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
7552
diff
changeset
|
1288 && f->display.x->menubar_widget != 0 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1289 && y < f->display.x->menubar_widget->core.height |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1290 && x >= 0 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1291 && x < last_menu_bar_item_end |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1292 && (x >= this_menu_bar_item_end |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1293 || x < this_menu_bar_item_beg)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1294 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1295 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1296 /* Unread a button-press event in the menu bar of frame F |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1297 at x position XPOS relative to the inside of the frame. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1298 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1299 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1300 unread_menu_bar_button (f, xpos) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1301 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
|
1302 int xpos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1303 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1304 XEvent event; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1305 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1306 event.type = ButtonPress; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1307 event.xbutton.display = x_current_display; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1308 event.xbutton.serial = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1309 event.xbutton.send_event = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1310 event.xbutton.time = CurrentTime; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1311 event.xbutton.button = Button1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1312 event.xbutton.window = XtWindow (f->display.x->menubar_widget); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1313 event.xbutton.x = xpos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1314 XPutBackEvent (XDISPLAY &event); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1315 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1316 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1317 /* If the mouse has moved to another menu bar item, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1318 return 1 and unread a button press event for that item. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1319 Otherwise return 0. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1320 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1321 static int |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1322 check_mouse_other_menu_bar (f) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1323 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
|
1324 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1325 FRAME_PTR new_f; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1326 Lisp_Object bar_window; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1327 int part; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1328 Lisp_Object x, y; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1329 unsigned long time; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1330 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1331 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1332 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1333 if (f == new_f && other_menu_bar_item_p (f, x, y)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1334 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1335 unread_menu_bar_button (f, x); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1336 return 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1337 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1338 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1339 return 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1340 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1341 #endif /* USE_X_TOOLKIT */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1342 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1343 /* 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
|
1344 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
|
1345 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
|
1346 Both assume input is blocked by the caller. */ |
118 | 1347 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1348 /* 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
|
1349 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
|
1350 relative to the inside upper left corner of the frame F. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1351 MENUBARP is 1 if the click that asked for this menu came from the menu bar. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1352 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
|
1353 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
|
1354 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
|
1355 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
|
1356 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
|
1357 (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
|
1358 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1359 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1360 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1361 extern unsigned int x_mouse_grabbed; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1362 extern Lisp_Object Vmouse_depressed; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1363 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1364 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1365 xmenu_show (f, x, y, menubarp, keymaps, title, error) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1366 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1367 int x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1368 int y; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1369 int menubarp; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1370 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1371 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
|
1372 char **error; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1373 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1374 int i; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1375 int menu_id; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1376 Widget menu; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1377 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1378 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1379 /* This is the menu bar item (if any) that led to this menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1380 widget_value *menubar_item = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1381 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1382 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
|
1383 widget_value **submenu_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1384 = (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
|
1385 Lisp_Object *subprefix_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1386 = (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
|
1387 int 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
|
1388 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1389 /* Define a queue to save up for later unreading |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1390 all X events that don't pertain to the menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1391 struct event_queue |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1392 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1393 XEvent event; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1394 struct event_queue *next; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1395 }; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1396 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1397 struct event_queue *queue = NULL; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1398 struct event_queue *queue_tmp; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1399 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1400 Position root_x, root_y; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1401 |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1402 int first_pane; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1403 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1404 *error = NULL; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1405 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1406 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1407 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1408 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1409 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1410 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1411 this_menu_bar_item_beg = -1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1412 this_menu_bar_item_end = -1; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1413 last_menu_bar_item_end = -1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1414 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1415 /* Figure out which menu bar item, if any, this 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
|
1416 if (menubarp) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1417 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1418 int xbeg; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1419 int xend = 0; |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1420 widget_value *mb_item = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1421 |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1422 for (mb_item = menubar->menu.old_stack[0]->contents; |
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1423 mb_item; |
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1424 mb_item = mb_item->next) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1425 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1426 xbeg = xend; |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1427 xend += (string_width (menubar, mb_item->name) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1428 + 2 * (menubar->menu.horizontal_spacing |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1429 + menubar->menu.shadow_thickness)); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1430 if (x >= xbeg && x < xend) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1431 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1432 x = xbeg + 4; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1433 y = 0; |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
1434 menubar_item = mb_item; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1435 /* Arrange to show a different menu if we move in the menu bar |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1436 to a different item. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1437 this_menu_bar_item_beg = xbeg; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1438 this_menu_bar_item_end = xend; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1439 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1440 } |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1441 last_menu_bar_item_end = xend; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1442 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1443 if (menubar_item == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1444 menubarp = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1445 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1446 /* Offset the coordinates to root-relative. */ |
7552
371ae57ac9a8
(xmenu_show): Don't look in menubar for core.height if no menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
7521
diff
changeset
|
1447 if (f->display.x->menubar_widget != 0) |
371ae57ac9a8
(xmenu_show): Don't look in menubar for core.height if no menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
7521
diff
changeset
|
1448 y += f->display.x->menubar_widget->core.height; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1449 XtTranslateCoords (f->display.x->widget, |
7552
371ae57ac9a8
(xmenu_show): Don't look in menubar for core.height if no menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
7521
diff
changeset
|
1450 x, y, &root_x, &root_y); |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1451 x = root_x; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1452 y = root_y; |
5896
b20145eafe0c
(xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5881
diff
changeset
|
1453 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1454 /* 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
|
1455 representing the 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
|
1456 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1457 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
|
1458 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
|
1459 wv->enabled = 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1460 first_wv = wv; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1461 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
|
1462 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1463 /* 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
|
1464 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1465 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
|
1466 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1467 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
|
1468 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1469 submenu_stack[submenu_depth++] = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1470 save_wv = prev_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1471 prev_wv = 0; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1472 first_pane = 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1473 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1474 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1475 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
|
1476 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1477 prev_wv = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1478 save_wv = submenu_stack[--submenu_depth]; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1479 first_pane = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1480 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1481 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1482 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
|
1483 && submenu_depth != 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1484 i += MENU_ITEMS_PANE_LENGTH; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1485 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1486 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1487 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
|
1488 i += 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1489 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
|
1490 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1491 /* 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
|
1492 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
|
1493 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
|
1494 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
|
1495 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
|
1496 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
|
1497 ? "" : (char *) XSTRING (pane_name)->data); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1498 /* 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
|
1499 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
|
1500 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
|
1501 pane_string = ""; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1502 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1503 /* 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
|
1504 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
|
1505 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
|
1506 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
|
1507 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1508 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1509 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
|
1510 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
|
1511 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1512 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
|
1513 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
|
1514 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
|
1515 wv->name++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1516 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
|
1517 wv->enabled = 1; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1518 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1519 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
|
1520 } |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1521 else if (first_pane) |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1522 { |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1523 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1524 prev_wv = 0; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1525 } |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1526 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
|
1527 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
|
1528 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1529 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1530 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1531 /* Create a new item within current pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1532 Lisp_Object item_name, enable, descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1533 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
|
1534 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
|
1535 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1536 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1537 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1538 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1539 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
|
1540 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
|
1541 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1542 save_wv->contents = wv; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1543 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
|
1544 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1545 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
|
1546 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
|
1547 wv->call_data = (void *) &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
|
1548 wv->enabled = !NILP (enable); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1549 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
|
1550 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1551 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
|
1552 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1553 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1554 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1555 /* Actually create the menu. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1556 menu_id = ++popup_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
|
1557 menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv, |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1558 f->display.x->widget, 1, 0, |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1559 popup_selection_callback, popup_down_callback); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1560 /* 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
|
1561 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
|
1562 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1563 /* 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
|
1564 menu_item_selection = 0; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1565 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1566 /* If the mouse moves out of the menu before we show the menu, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1567 don't show it at all. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1568 if (check_mouse_other_menu_bar (f)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1569 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1570 lw_destroy_all_widgets (menu_id); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1571 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1572 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1573 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1574 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1575 /* Highlight the menu bar item (if any) that led to this menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1576 if (menubarp) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1577 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1578 menubar_item->call_data = (XtPointer) 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1579 dispatch_dummy_expose (f->display.x->menubar_widget, x, y); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1580 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1581 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1582 /* Display the menu. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1583 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1584 XButtonPressedEvent dummy; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1585 XlwMenuWidget mw; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1586 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1587 mw = (XlwMenuWidget) ((CompositeWidget)menu)->composite.children[0]; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1588 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1589 dummy.type = ButtonPress; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1590 dummy.serial = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1591 dummy.send_event = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1592 dummy.display = XtDisplay (menu); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1593 dummy.window = XtWindow (XtParent (menu)); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1594 dummy.time = CurrentTime; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1595 dummy.button = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1596 dummy.x_root = x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1597 dummy.y_root = y; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1598 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1599 /* We activate directly the lucid implementation. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1600 pop_up_menu (mw, &dummy); |
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 |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1603 /* No need to check a second time since this is done in the XEvent loop. |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1604 This slows done the execution. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1605 #if 0 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1606 /* Check again whether the mouse has moved to another menu bar item. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1607 if (check_mouse_other_menu_bar (f)) |
5865
8dc616f310e8
(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5809
diff
changeset
|
1608 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1609 /* The mouse moved into a different menu bar item. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1610 We should bring up that item's menu instead. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1611 First pop down this menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1612 XtUngrabPointer ((Widget) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1613 ((XlwMenuWidget) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1614 ((CompositeWidget)menu)->composite.children[0]), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1615 CurrentTime); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1616 lw_destroy_all_widgets (menu_id); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1617 goto pop_down; |
5865
8dc616f310e8
(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5809
diff
changeset
|
1618 } |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1619 #endif |
5865
8dc616f310e8
(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5809
diff
changeset
|
1620 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1621 /* Process events that apply to the menu. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1622 while (1) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1623 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1624 XEvent event; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1625 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1626 XtAppNextEvent (Xt_app_con, &event); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1627 if (event.type == ButtonRelease) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1628 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1629 XtDispatchEvent (&event); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1630 if (! menubarp) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1631 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1632 /* Do the work of construct_mouse_click since it can't |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1633 be called. Initially, the popup menu has been called |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1634 from a ButtonPress in the edit_widget. Then the mouse |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1635 has been set to grabbed. Reset it now. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1636 x_mouse_grabbed &= ~(1 << event.xbutton.button); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1637 if (!x_mouse_grabbed) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1638 Vmouse_depressed = Qnil; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1639 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1640 break; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1641 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1642 else if (event.type == Expose) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1643 process_expose_from_menu (event); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1644 else if (event.type == MotionNotify) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1645 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1646 int event_x = (event.xmotion.x_root |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1647 - (f->display.x->widget->core.x |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1648 + f->display.x->widget->core.border_width)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1649 int event_y = (event.xmotion.y_root |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1650 - (f->display.x->widget->core.y |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1651 + f->display.x->widget->core.border_width)); |
5865
8dc616f310e8
(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5809
diff
changeset
|
1652 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1653 if (other_menu_bar_item_p (f, event_x, event_y)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1654 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1655 /* The mouse moved into a different menu bar item. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1656 We should bring up that item's menu instead. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1657 First pop down this menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1658 XtUngrabPointer ((Widget) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1659 ((XlwMenuWidget) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1660 ((CompositeWidget)menu)->composite.children[0]), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1661 event.xbutton.time); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1662 lw_destroy_all_widgets (menu_id); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1663 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1664 /* Put back an event that will bring up the other item's menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1665 unread_menu_bar_button (f, event_x); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1666 /* Don't let us select anything in this case. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1667 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
|
1668 break; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1669 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1670 } |
5865
8dc616f310e8
(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5809
diff
changeset
|
1671 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1672 XtDispatchEvent (&event); |
6198
d941186e8fb9
[USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents:
6172
diff
changeset
|
1673 if (XtWindowToWidget(XDISPLAY event.xany.window) != menu) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1674 { |
6198
d941186e8fb9
[USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents:
6172
diff
changeset
|
1675 queue_tmp |
d941186e8fb9
[USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents:
6172
diff
changeset
|
1676 = (struct event_queue *) malloc (sizeof (struct event_queue)); |
6115
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1677 |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1678 if (queue_tmp != NULL) |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1679 { |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1680 queue_tmp->event = event; |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1681 queue_tmp->next = queue; |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1682 queue = queue_tmp; |
e3d6c30a3906
(xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6058
diff
changeset
|
1683 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1684 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1685 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1686 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1687 pop_down: |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1688 /* Unhighlight the menu bar item (if any) that led to this menu. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1689 if (menubarp) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1690 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1691 menubar_item->call_data = (XtPointer) 0; |
5775
07a36e38e514
(xmenu_show) [USE_X_TOOLKIT]: Remove the #if 0 directives and reverse one to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5673
diff
changeset
|
1692 dispatch_dummy_expose (f->display.x->menubar_widget, x, y); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1693 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1694 |
6625
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
1695 /* 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
|
1696 that it is unnecessary--that the menu has already disappeared. |
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
1697 I observer that is not so. -- rms. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1698 /* Make sure the menu disappears. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1699 lw_destroy_all_widgets (menu_id); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1700 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1701 /* Unread any events that we got but did not handle. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1702 while (queue != NULL) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1703 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1704 queue_tmp = queue; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1705 XPutBackEvent (XDISPLAY &queue_tmp->event); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1706 queue = queue_tmp->next; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1707 free ((char *)queue_tmp); |
7129
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1708 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1709 interrupt_input_pending = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1710 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1711 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1712 /* 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
|
1713 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
|
1714 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
|
1715 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1716 Lisp_Object prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1717 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1718 prefix = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1719 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1720 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
|
1721 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1722 Lisp_Object entry; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1723 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1724 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
|
1725 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1726 subprefix_stack[submenu_depth++] = prefix; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1727 prefix = entry; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1728 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1729 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1730 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
|
1731 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1732 prefix = subprefix_stack[--submenu_depth]; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1733 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1734 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1735 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
|
1736 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1737 prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1738 = 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
|
1739 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
|
1740 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1741 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1742 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1743 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1744 = 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
|
1745 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
|
1746 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1747 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
|
1748 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1749 int j; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1750 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1751 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
|
1752 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
|
1753 entry = Fcons (prefix, entry); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1754 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
|
1755 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
|
1756 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
|
1757 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1758 return entry; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1759 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1760 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
|
1761 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1762 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1763 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1764 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1765 return Qnil; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1766 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1767 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1768 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
|
1769 "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
|
1770 "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
|
1771 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1772 static Lisp_Object |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1773 xdialog_show (f, menubarp, 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
|
1774 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
|
1775 int menubarp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1776 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
|
1777 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
|
1778 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
|
1779 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1780 int i, nb_buttons=0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1781 int dialog_id; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1782 Widget menu; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1783 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1784 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
|
1785 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1786 /* This is the menu bar item (if any) that led to this menu. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1787 widget_value *menubar_item = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1788 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1789 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1790 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1791 /* Define a queue to save up for later unreading |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1792 all X events that don't pertain to 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
|
1793 struct event_queue |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1794 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1795 XEvent event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1796 struct event_queue *next; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1797 }; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1798 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1799 struct event_queue *queue = NULL; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1800 struct event_queue *queue_tmp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1801 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1802 /* Number of elements seen so far, before boundary. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1803 int left_count = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1804 /* 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
|
1805 int boundary_seen = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1806 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1807 *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
|
1808 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1809 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
|
1810 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1811 *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
|
1812 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
|
1813 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1814 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1815 /* 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
|
1816 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
|
1817 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1818 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
|
1819 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
|
1820 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
|
1821 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
|
1822 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
|
1823 ? "" : (char *) XSTRING (pane_name)->data); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1824 prev_wv = malloc_widget_value (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1825 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
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1832 /* 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
|
1833 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
|
1834 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
|
1835 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1836 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1837 /* 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
|
1838 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
|
1839 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
|
1840 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
|
1841 descrip |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1842 = 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
|
1843 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1844 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
|
1845 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1846 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
|
1847 *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
|
1848 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
|
1849 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1850 if (EQ (item_name, Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1851 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1852 /* This is the boundary between left-side elts |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1853 and right-side elts. Stop incrementing right_count. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1854 boundary_seen = 1; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1855 i++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1856 continue; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1857 } |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1858 if (nb_buttons >= 10) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1859 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1860 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
|
1861 *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
|
1862 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
|
1863 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1864 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1865 wv = malloc_widget_value (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1866 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
|
1867 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
|
1868 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1869 wv->key = (char *) XSTRING (descrip)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1870 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
|
1871 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
|
1872 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
|
1873 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
|
1874 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1875 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1876 left_count++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1877 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1878 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
|
1879 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
|
1880 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1881 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1882 /* If the boundary was not specified, |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1883 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
|
1884 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1885 left_count = nb_buttons - nb_buttons / 2; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1886 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1887 wv = malloc_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
|
1888 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
|
1889 |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1890 /* 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
|
1891 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
|
1892 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
|
1893 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
|
1894 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
|
1895 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
|
1896 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
|
1897 dialog_name[3] = 'R'; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1898 /* Number of buttons to put on the right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1899 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
|
1900 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
|
1901 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
|
1902 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
|
1903 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1904 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1905 /* Actually create the dialog. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1906 dialog_id = ++popup_id_tick; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1907 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, 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
|
1908 f->display.x->widget, 1, 0, |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1909 dialog_selection_callback, 0); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1910 #if 0 /* This causes crashes, and seems to be redundant -- rms. */ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1911 lw_modify_all_widgets (dialog_id, first_wv, True); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1912 #endif |
7770
41dda174ca7c
(xdialog_show): Fix problem with message in dialog box.
Karl Heuer <kwzh@gnu.org>
parents:
7679
diff
changeset
|
1913 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
|
1914 /* 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
|
1915 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
|
1916 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1917 /* 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
|
1918 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
|
1919 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1920 /* 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
|
1921 lw_pop_up_all_widgets (dialog_id); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1922 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1923 /* Process events that apply to 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
|
1924 while (1) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1925 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1926 XEvent event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1927 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1928 XtAppNextEvent (Xt_app_con, &event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1929 if (event.type == ButtonRelease) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1930 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1931 XtDispatchEvent (&event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1932 break; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1933 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1934 else if (event.type == Expose) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1935 process_expose_from_menu (event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1936 XtDispatchEvent (&event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1937 if (XtWindowToWidget(XDISPLAY event.xany.window) != menu) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1938 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1939 queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue)); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1940 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1941 if (queue_tmp != NULL) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1942 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1943 queue_tmp->event = event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1944 queue_tmp->next = queue; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1945 queue = queue_tmp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1946 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1947 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1948 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1949 pop_down: |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1950 |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
1951 /* 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
|
1952 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
|
1953 results, and it is a pain to ask which are actually held now |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
1954 or track this in the loop above. */ |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
1955 x_mouse_grabbed = 0; |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
1956 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1957 /* Unread any events that we got but did not handle. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1958 while (queue != NULL) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1959 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1960 queue_tmp = queue; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1961 XPutBackEvent (XDISPLAY &queue_tmp->event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1962 queue = queue_tmp->next; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1963 free ((char *)queue_tmp); |
7129
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1964 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1965 interrupt_input_pending = 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
|
1966 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1967 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1968 /* 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
|
1969 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
|
1970 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
|
1971 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1972 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
|
1973 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1974 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
|
1975 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
|
1976 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
|
1977 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1978 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
|
1979 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1980 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
|
1981 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1982 prefix |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1983 = 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
|
1984 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
|
1985 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1986 else |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1987 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1988 entry |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1989 = 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
|
1990 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
|
1991 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1992 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
|
1993 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1994 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
|
1995 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
|
1996 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
|
1997 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1998 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
|
1999 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2000 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
|
2001 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2002 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2003 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2004 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2005 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
|
2006 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2007 #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
|
2008 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2009 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2010 xmenu_show (f, x, y, menubarp, keymaps, title, error) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2011 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
|
2012 int x, y; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2013 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2014 int menubarp; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2015 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
|
2016 char **error; |
118 | 2017 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2018 Window root; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2019 XMenu *menu; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2020 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
|
2021 Lisp_Object entry, pane_prefix; |
118 | 2022 char *datap; |
2023 int ulx, uly, width, height; | |
2024 int dispwidth, dispheight; | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2025 int i, j; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2026 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
|
2027 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
|
2028 unsigned int dummy_uint; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2029 |
3747
6506b2fd475a
(xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
3501
diff
changeset
|
2030 *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
|
2031 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
|
2032 return Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2033 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2034 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2035 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2036 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2037 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2038 } |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2039 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2040 /* Figure out which root window F is on. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2041 XGetGeometry (x_current_display, FRAME_X_WINDOW (f), &root, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2042 &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
|
2043 &dummy_uint, &dummy_uint); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2044 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2045 /* Make the menu on that window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2046 menu = XMenuCreate (XDISPLAY root, "emacs"); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2047 if (menu == NULL) |
118 | 2048 { |
2049 *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
|
2050 return Qnil; |
118 | 2051 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2052 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2053 /* 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
|
2054 #ifdef HAVE_X11 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2055 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2056 Window child; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2057 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
|
2058 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2059 /* 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
|
2060 the inner window, with respect to the outer window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2061 if (f->display.x->parent_desc != ROOT_WINDOW) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2062 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2063 BLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2064 XTranslateCoordinates (x_current_display, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2065 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2066 /* From-window, to-window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2067 f->display.x->window_desc, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2068 f->display.x->parent_desc, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2069 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2070 /* 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
|
2071 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
|
2072 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2073 /* 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
|
2074 &child); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2075 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2076 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
|
2077 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
|
2078 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2079 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2080 #endif /* HAVE_X11 */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2081 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2082 /* Adjust coordinates to be root-window-relative. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2083 x += f->display.x->left_pos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2084 y += f->display.x->top_pos; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2085 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2086 /* 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
|
2087 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2088 while (i < menu_items_used) |
118 | 2089 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2090 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
118 | 2091 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2092 /* 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
|
2093 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
|
2094 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
|
2095 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2096 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
|
2097 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
|
2098 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
|
2099 ? "" : (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
|
2100 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
|
2101 pane_string++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2102 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2103 lpane = XMenuAddPane (XDISPLAY menu, pane_string, TRUE); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2104 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
|
2105 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2106 XMenuDestroy (XDISPLAY menu); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2107 *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
|
2108 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2109 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2110 i += MENU_ITEMS_PANE_LENGTH; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2111 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2112 /* 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
|
2113 maxwidth = 0; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2114 j = i; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2115 while (j < menu_items_used) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2116 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2117 Lisp_Object item; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2118 item = XVECTOR (menu_items)->contents[j]; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2119 if (EQ (item, Qt)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2120 break; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2121 if (NILP (item)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2122 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2123 j++; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2124 continue; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2125 } |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2126 width = XSTRING (item)->size; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2127 if (width > maxwidth) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2128 maxwidth = width; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2129 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2130 j += MENU_ITEMS_ITEM_LENGTH; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2131 } |
118 | 2132 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2133 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2134 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2135 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
|
2136 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
|
2137 else |
118 | 2138 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2139 /* Create a new item within current pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2140 Lisp_Object item_name, enable, descrip; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2141 unsigned char *item_data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2142 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2143 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
|
2144 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
|
2145 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2146 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2147 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2148 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2149 int gap = maxwidth - XSTRING (item_name)->size; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2150 #ifdef C_ALLOCA |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2151 Lisp_Object spacer; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2152 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
|
2153 item_name = concat2 (item_name, spacer); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2154 item_name = concat2 (item_name, descrip); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2155 item_data = XSTRING (item_name)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2156 #else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2157 /* 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
|
2158 to reduce gc needs. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2159 item_data |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2160 = (unsigned char *) alloca (maxwidth |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2161 + XSTRING (descrip)->size + 1); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2162 bcopy (XSTRING (item_name)->data, item_data, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2163 XSTRING (item_name)->size); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2164 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
|
2165 item_data[j] = ' '; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2166 bcopy (XSTRING (descrip)->data, item_data + j, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2167 XSTRING (descrip)->size); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2168 item_data[j + XSTRING (descrip)->size] = 0; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2169 #endif |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2170 } |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2171 else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2172 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
|
2173 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2174 if (XMenuAddSelection (XDISPLAY menu, lpane, 0, item_data, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2175 !NILP (enable)) |
118 | 2176 == XM_FAILURE) |
2177 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2178 XMenuDestroy (XDISPLAY menu); |
118 | 2179 *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
|
2180 return Qnil; |
118 | 2181 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2182 i += MENU_ITEMS_ITEM_LENGTH; |
118 | 2183 } |
2184 } | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2185 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2186 /* All set and ready to fly. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2187 XMenuRecompute (XDISPLAY menu); |
118 | 2188 dispwidth = DisplayWidth (x_current_display, XDefaultScreen (x_current_display)); |
2189 dispheight = DisplayHeight (x_current_display, XDefaultScreen (x_current_display)); | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2190 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
|
2191 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
|
2192 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
|
2193 y = max (y, 1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2194 XMenuLocate (XDISPLAY menu, 0, 0, x, y, |
118 | 2195 &ulx, &uly, &width, &height); |
2196 if (ulx+width > dispwidth) | |
2197 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2198 x -= (ulx + width) - dispwidth; |
118 | 2199 ulx = dispwidth - width; |
2200 } | |
2201 if (uly+height > dispheight) | |
2202 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2203 y -= (uly + height) - dispheight; |
118 | 2204 uly = dispheight - height; |
2205 } | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2206 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
|
2207 if (uly < 0) y -= uly; |
6526
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2208 |
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2209 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
|
2210 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
|
2211 pane = selidx = 0; |
118 | 2212 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2213 status = XMenuActivate (XDISPLAY menu, &pane, &selidx, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2214 x, y, ButtonReleaseMask, &datap); |
118 | 2215 switch (status) |
2216 { | |
2217 case XM_SUCCESS: | |
2218 #ifdef XDEBUG | |
2219 fprintf (stderr, "pane= %d line = %d\n", panes, selidx); | |
2220 #endif | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2221 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2222 /* 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
|
2223 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2224 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
|
2225 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2226 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
|
2227 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2228 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
|
2229 pane_prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2230 = 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
|
2231 pane--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2232 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
|
2233 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2234 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2235 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2236 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
|
2237 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2238 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
|
2239 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2240 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2241 = 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
|
2242 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
|
2243 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2244 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
|
2245 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
|
2246 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
|
2247 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2248 break; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2249 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2250 selidx--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2251 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2252 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
|
2253 } |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
2254 } |
118 | 2255 break; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2256 |
118 | 2257 case XM_FAILURE: |
2258 *error = "Can't activate menu"; | |
2259 case XM_IA_SELECT: | |
2260 case XM_NO_SELECT: | |
2261 entry = Qnil; | |
2262 break; | |
2263 } | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2264 XMenuDestroy (XDISPLAY menu); |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2265 |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2266 /* 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
|
2267 (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
|
2268 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
|
2269 results, and it is a pain to ask which are actually held now. */ |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2270 x_mouse_grabbed = 0; |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2271 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2272 return entry; |
118 | 2273 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2274 #endif /* 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
|
2275 |
118 | 2276 syms_of_xmenu () |
2277 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2278 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
|
2279 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
|
2280 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2281 popup_id_tick = (1<<16); |
118 | 2282 defsubr (&Sx_popup_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
|
2283 defsubr (&Sx_popup_dialog); |
118 | 2284 } |