annotate src/w32menu.c @ 80759:c3bd08b7c78d

(Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not grabbed after menu is finished.
author Jason Rumney <jasonr@gnu.org>
date Tue, 26 Aug 2008 14:23:25 +0000
parents fc2bcd2a8aad
children ab6494b53df0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16884
36babc489b0c Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents: 16860
diff changeset
1 /* Menu support for GNU Emacs on the Microsoft W32 API.
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 73788
diff changeset
2 Copyright (C) 1986, 1988, 1993, 1994, 1996, 1998, 1999, 2001, 2002,
79759
fc2bcd2a8aad Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78260
diff changeset
3 2003, 2004, 2005, 2006, 2007, 2008
fc2bcd2a8aad Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78260
diff changeset
4 Free Software Foundation, Inc.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6 This file is part of GNU Emacs.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
8 GNU Emacs is free software; you can redistribute it and/or modify
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
78260
922696f363b0 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 78022
diff changeset
10 the Free Software Foundation; either version 3, or (at your option)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
11 any later version.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
17
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
19 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63147
diff changeset
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63147
diff changeset
21 Boston, MA 02110-1301, USA. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
22
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
23 #include <config.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
24 #include <signal.h>
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
25
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
26 #include <stdio.h>
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
27 #include <mbstring.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
28 #include "lisp.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
29 #include "termhooks.h"
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
30 #include "keyboard.h"
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
31 #include "keymap.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
32 #include "frame.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
33 #include "window.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
34 #include "blockinput.h"
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
35 #include "buffer.h"
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
36 #include "charset.h"
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
37 #include "coding.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
38
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
39 /* This may include sys/types.h, and that somehow loses
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
40 if this is not done before the other system files. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
41 #include "w32term.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
42
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
43 /* Load sys/types.h if not already loaded.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
44 In some systems loading it twice is suicidal. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
45 #ifndef makedev
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
46 #include <sys/types.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
47 #endif
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
48
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
49 #include "dispextern.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
50
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
51 #undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
52
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
53 /******************************************************************/
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
54 /* Definitions copied from lwlib.h */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
55
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
56 typedef void * XtPointer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
57 typedef char Boolean;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
58
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
59 enum button_type
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
60 {
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
61 BUTTON_TYPE_NONE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
62 BUTTON_TYPE_TOGGLE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
63 BUTTON_TYPE_RADIO
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
64 };
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
65
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
66 /* This structure is based on the one in ../lwlib/lwlib.h, modified
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
67 for Windows. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
68 typedef struct _widget_value
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
69 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
70 /* name of widget */
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
71 Lisp_Object lname;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
72 char* name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
73 /* value (meaning depend on widget type) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
74 char* value;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
75 /* keyboard equivalent. no implications for XtTranslations */
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
76 Lisp_Object lkey;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
77 char* key;
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
78 /* Help string or nil if none.
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
79 GC finds this string through the frame's menu_bar_vector
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
80 or through menu_items. */
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
81 Lisp_Object help;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
82 /* true if enabled */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
83 Boolean enabled;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
84 /* true if selected */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
85 Boolean selected;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
86 /* The type of a button. */
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
87 enum button_type button_type;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
88 /* true if menu title */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
89 Boolean title;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
90 #if 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
91 /* true if was edited (maintained by get_value) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
92 Boolean edited;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
93 /* true if has changed (maintained by lw library) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
94 change_type change;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
95 /* true if this widget itself has changed,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
96 but not counting the other widgets found in the `next' field. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
97 change_type this_one_change;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
98 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
99 /* Contents of the sub-widgets, also selected slot for checkbox */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
100 struct _widget_value* contents;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
101 /* data passed to callback */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
102 XtPointer call_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
103 /* next one in the list */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
104 struct _widget_value* next;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
105 #if 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
106 /* slot for the toolkit dependent part. Always initialize to NULL. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
107 void* toolkit_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
108 /* tell us if we should free the toolkit data slot when freeing the
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
109 widget_value itself. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
110 Boolean free_toolkit_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
111
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
112 /* we resource the widget_value structures; this points to the next
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
113 one on the free list if this one has been deallocated.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
114 */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
115 struct _widget_value *free_list;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
116 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
117 } widget_value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
118
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
119 /* Local memory management */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
120 #define local_heap (GetProcessHeap ())
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
121 #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
122 #define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
123
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
124 #define malloc_widget_value() ((widget_value *) local_alloc (sizeof (widget_value)))
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
125 #define free_widget_value(wv) (local_free ((wv)))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
126
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
127 /******************************************************************/
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
128
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
129 #ifndef TRUE
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
130 #define TRUE 1
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
131 #define FALSE 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
132 #endif /* no TRUE */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
133
76074
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
134 HMENU current_popup_menu;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
135
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
136 void syms_of_w32menu ();
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
137 void globals_of_w32menu ();
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
138
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
139 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
140 IN HMENU,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
141 IN UINT,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
142 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
143 IN OUT LPMENUITEMINFOA);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
144 typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
145 IN HMENU,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
146 IN UINT,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
147 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
148 IN LPCMENUITEMINFOA);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
149
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
150 GetMenuItemInfoA_Proc get_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
151 SetMenuItemInfoA_Proc set_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
152 AppendMenuW_Proc unicode_append_menu = NULL;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
153
72773
15d914de92fd * src/macmenu.c (Vmenu_updating_frame, syms_of_xmenu):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72260
diff changeset
154 Lisp_Object Qdebug_on_next_call;
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
155
72773
15d914de92fd * src/macmenu.c (Vmenu_updating_frame, syms_of_xmenu):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72260
diff changeset
156 extern Lisp_Object Vmenu_updating_frame;
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
157
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
158 extern Lisp_Object Qmenu_bar;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
159
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
160 extern Lisp_Object QCtoggle, QCradio;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
161
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
162 extern Lisp_Object Voverriding_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
163 extern Lisp_Object Voverriding_local_map_menu_flag;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
164
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
165 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
166
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
167 extern Lisp_Object Qmenu_bar_update_hook;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
168
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
169 void set_frame_menubar ();
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
170
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
171 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
172 Lisp_Object, Lisp_Object, Lisp_Object,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
173 Lisp_Object, Lisp_Object));
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
174 #ifdef HAVE_DIALOGS
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
175 static Lisp_Object w32_dialog_show ();
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
176 #endif
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
177 static Lisp_Object w32_menu_show ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
178
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
179 static void keymap_panes ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
180 static void single_keymap_panes ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
181 static void single_menu_item ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
182 static void list_of_panes ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
183 static void list_of_items ();
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
184 void w32_free_menu_strings (HWND);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
185
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
186 /* This holds a Lisp vector that holds the results of decoding
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
187 the keymaps or alist-of-alists that specify a menu.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
188
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
189 It describes the panes and items within the panes.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
190
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
191 Each pane is described by 3 elements in the vector:
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
192 t, the pane name, the pane's prefix key.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
193 Then follow the pane's items, with 5 elements per item:
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
194 the item string, the enable flag, the item's value,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
195 the definition, and the equivalent keyboard key's description string.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
196
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
197 In some cases, multiple levels of menus may be described.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
198 A single vector slot containing nil indicates the start of a submenu.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
199 A single vector slot containing lambda indicates the end of a submenu.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
200 The submenu follows a menu item which is the way to reach the submenu.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
201
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
202 A single vector slot containing quote indicates that the
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
203 following items should appear on the right of a dialog box.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
204
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
205 Using a Lisp vector to hold this information while we decode it
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
206 takes care of protecting all the data from GC. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
207
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
208 #define MENU_ITEMS_PANE_NAME 1
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
209 #define MENU_ITEMS_PANE_PREFIX 2
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
210 #define MENU_ITEMS_PANE_LENGTH 3
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
211
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
212 enum menu_item_idx
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
213 {
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
214 MENU_ITEMS_ITEM_NAME = 0,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
215 MENU_ITEMS_ITEM_ENABLE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
216 MENU_ITEMS_ITEM_VALUE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
217 MENU_ITEMS_ITEM_EQUIV_KEY,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
218 MENU_ITEMS_ITEM_DEFINITION,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
219 MENU_ITEMS_ITEM_TYPE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
220 MENU_ITEMS_ITEM_SELECTED,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
221 MENU_ITEMS_ITEM_HELP,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
222 MENU_ITEMS_ITEM_LENGTH
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
223 };
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
224
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
225 static Lisp_Object menu_items;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
226
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
227 /* Number of slots currently allocated in menu_items. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
228 static int menu_items_allocated;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
229
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
230 /* This is the index in menu_items of the first empty slot. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
231 static int menu_items_used;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
232
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
233 /* The number of panes currently recorded in menu_items,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
234 excluding those within submenus. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
235 static int menu_items_n_panes;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
236
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
237 /* Current depth within submenus. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
238 static int menu_items_submenu_depth;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
239
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
240 static int next_menubar_widget_id;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
241
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
242 /* This is set nonzero after the user activates the menu bar, and set
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
243 to zero again after the menu bars are redisplayed by prepare_menu_bar.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
244 While it is nonzero, all calls to set_frame_menubar go deep.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
245
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
246 I don't understand why this is needed, but it does seem to be
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
247 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
248
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
249 int pending_menu_activation;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
250
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
251
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
252 /* Return the frame whose ->output_data.w32->menubar_widget equals
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
253 ID, or 0 if none. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
254
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
255 static struct frame *
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
256 menubar_id_to_frame (id)
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
257 HMENU id;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
258 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
259 Lisp_Object tail, frame;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
260 FRAME_PTR f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
261
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
262 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
263 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
264 frame = XCAR (tail);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
265 if (!GC_FRAMEP (frame))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
266 continue;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
267 f = XFRAME (frame);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
268 if (!FRAME_WINDOW_P (f))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
269 continue;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
270 if (f->output_data.w32->menubar_widget == id)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
271 return f;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
272 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
273 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
274 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
275
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
276 /* Initialize the menu_items structure if we haven't already done so.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
277 Also mark it as currently empty. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
278
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
279 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
280 init_menu_items ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
281 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
282 if (NILP (menu_items))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
283 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
284 menu_items_allocated = 60;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
285 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
286 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
287
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
288 menu_items_used = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
289 menu_items_n_panes = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
290 menu_items_submenu_depth = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
291 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
292
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
293 /* Call at the end of generating the data in menu_items.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
294 This fills in the number of items in the last pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
295
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
296 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
297 finish_menu_items ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
298 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
299 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
300
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
301 /* Call when finished using the data for the current menu
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
302 in menu_items. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
303
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
304 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
305 discard_menu_items ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
306 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
307 /* Free the structure if it is especially large.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
308 Otherwise, hold on to it, to save time. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
309 if (menu_items_allocated > 200)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
310 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
311 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
312 menu_items_allocated = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
313 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
314 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
315
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
316 /* Make the menu_items vector twice as large. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
317
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
318 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
319 grow_menu_items ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
320 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
321 Lisp_Object old;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
322 int old_size = menu_items_allocated;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
323 old = menu_items;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
324
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
325 menu_items_allocated *= 2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
326 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
327 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
328 old_size * sizeof (Lisp_Object));
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
329 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
330
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
331 /* Begin a submenu. */
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
332
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
333 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
334 push_submenu_start ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
335 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
336 if (menu_items_used + 1 > menu_items_allocated)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
337 grow_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
338
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
339 ASET (menu_items, menu_items_used++, Qnil);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
340 menu_items_submenu_depth++;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
341 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
342
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
343 /* End a submenu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
344
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
345 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
346 push_submenu_end ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
347 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
348 if (menu_items_used + 1 > menu_items_allocated)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
349 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
350
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
351 ASET (menu_items, menu_items_used++, Qlambda);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
352 menu_items_submenu_depth--;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
353 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
354
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
355 /* Indicate boundary between left and right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
356
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
357 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
358 push_left_right_boundary ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
359 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
360 if (menu_items_used + 1 > menu_items_allocated)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
361 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
362
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
363 ASET (menu_items, menu_items_used++, Qquote);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
364 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
365
41251
e6612d08452f (w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 41108
diff changeset
366 /* Start a new menu pane in menu_items.
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
367 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
368
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
369 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
370 push_menu_pane (name, prefix_vec)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
371 Lisp_Object name, prefix_vec;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
372 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
373 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
374 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
375
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
376 if (menu_items_submenu_depth == 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
377 menu_items_n_panes++;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
378 ASET (menu_items, menu_items_used++, Qt);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
379 ASET (menu_items, menu_items_used++, name);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
380 ASET (menu_items, menu_items_used++, prefix_vec);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
381 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
382
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
383 /* Push one menu item into the current pane. NAME is the string to
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
384 display. ENABLE if non-nil means this item can be selected. KEY
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
385 is the key generated by choosing this item, or nil if this item
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
386 doesn't really have a definition. DEF is the definition of this
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
387 item. EQUIV is the textual description of the keyboard equivalent
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
388 for this item (or nil if none). TYPE is the type of this menu
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
389 item, one of nil, `toggle' or `radio'. */
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
390
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
391 static void
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
392 push_menu_item (name, enable, key, def, equiv, type, selected, help)
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
393 Lisp_Object name, enable, key, def, equiv, type, selected, help;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
394 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
395 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
396 grow_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
397
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
398 ASET (menu_items, menu_items_used++, name);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
399 ASET (menu_items, menu_items_used++, enable);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
400 ASET (menu_items, menu_items_used++, key);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
401 ASET (menu_items, menu_items_used++, equiv);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
402 ASET (menu_items, menu_items_used++, def);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
403 ASET (menu_items, menu_items_used++, type);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
404 ASET (menu_items, menu_items_used++, selected);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
405 ASET (menu_items, menu_items_used++, help);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
406 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
407
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
408 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
409 and generate menu panes for them in menu_items.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
410 If NOTREAL is nonzero,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
411 don't bother really computing whether an item is enabled. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
412
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
413 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
414 keymap_panes (keymaps, nmaps, notreal)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
415 Lisp_Object *keymaps;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
416 int nmaps;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
417 int notreal;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
418 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
419 int mapno;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
420
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
421 init_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
422
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
423 /* Loop over the given keymaps, making a pane for each map.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
424 But don't make a pane that is empty--ignore that map instead.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
425 P is the number of panes we have made so far. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
426 for (mapno = 0; mapno < nmaps; mapno++)
30989
2152817050ff (keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents: 30238
diff changeset
427 single_keymap_panes (keymaps[mapno],
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
428 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
429
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
430 finish_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
431 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
432
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
433 /* This is a recursive subroutine of keymap_panes.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
434 It handles one keymap, KEYMAP.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
435 The other arguments are passed along
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
436 or point to local variables of the previous function.
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
437 If NOTREAL is nonzero, only check for equivalent key bindings, don't
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
438 evaluate expressions in menu items and don't make any menu.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
439
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
440 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
441
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
442 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
443 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
444 Lisp_Object keymap;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
445 Lisp_Object pane_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
446 Lisp_Object prefix;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
447 int notreal;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
448 int maxdepth;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
449 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
450 Lisp_Object pending_maps = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
451 Lisp_Object tail, item;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
452 struct gcpro gcpro1, gcpro2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
453
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
454 if (maxdepth <= 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
455 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
456
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
457 push_menu_pane (pane_name, prefix);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
458
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
459 for (tail = keymap; CONSP (tail); tail = XCDR (tail))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
460 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
461 GCPRO2 (keymap, pending_maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
462 /* Look at each key binding, and if it is a menu item add it
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
463 to this menu. */
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
464 item = XCAR (tail);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
465 if (CONSP (item))
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
466 single_menu_item (XCAR (item), XCDR (item),
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
467 &pending_maps, notreal, maxdepth);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
468 else if (VECTORP (item))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
469 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
470 /* Loop over the char values represented in the vector. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
471 int len = ASIZE (item);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
472 int c;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
473 for (c = 0; c < len; c++)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
474 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
475 Lisp_Object character;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
476 XSETFASTINT (character, c);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
477 single_menu_item (character, AREF (item, c),
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
478 &pending_maps, notreal, maxdepth);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
479 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
480 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
481 UNGCPRO;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
482 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
483
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
484 /* Process now any submenus which want to be panes at this level. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
485 while (!NILP (pending_maps))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
486 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
487 Lisp_Object elt, eltcdr, string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
488 elt = Fcar (pending_maps);
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
489 eltcdr = XCDR (elt);
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
490 string = XCAR (eltcdr);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
491 /* We no longer discard the @ from the beginning of the string here.
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
492 Instead, we do this in w32_menu_show. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
493 single_keymap_panes (Fcar (elt), string,
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
494 XCDR (eltcdr), notreal, maxdepth - 1);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
495 pending_maps = Fcdr (pending_maps);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
496 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
497 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
498
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
499 /* This is a subroutine of single_keymap_panes that handles one
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
500 keymap entry.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
501 KEY is a key in a keymap and ITEM is its binding.
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
502 PENDING_MAPS_PTR points to a list of keymaps waiting to be made into
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
503 separate panes.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
504 If NOTREAL is nonzero, only check for equivalent key bindings, don't
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
505 evaluate expressions in menu items and don't make any menu.
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
506 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
507
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
508 static void
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
509 single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
510 Lisp_Object key, item;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
511 Lisp_Object *pending_maps_ptr;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
512 int maxdepth, notreal;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
513 {
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
514 Lisp_Object map, item_string, enabled;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
515 struct gcpro gcpro1, gcpro2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
516 int res;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
517
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
518 /* Parse the menu item and leave the result in item_properties. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
519 GCPRO2 (key, item);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
520 res = parse_menu_item (item, notreal, 0);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
521 UNGCPRO;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
522 if (!res)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
523 return; /* Not a menu item. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
524
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
525 map = AREF (item_properties, ITEM_PROPERTY_MAP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
526
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
527 if (notreal)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
528 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
529 /* We don't want to make a menu, just traverse the keymaps to
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
530 precompute equivalent key bindings. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
531 if (!NILP (map))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
532 single_keymap_panes (map, Qnil, key, 1, maxdepth - 1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
533 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
534 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
535
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
536 enabled = AREF (item_properties, ITEM_PROPERTY_ENABLE);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
537 item_string = AREF (item_properties, ITEM_PROPERTY_NAME);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
538
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
539 if (!NILP (map) && SREF (item_string, 0) == '@')
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
540 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
541 if (!NILP (enabled))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
542 /* An enabled separate pane. Remember this to handle it later. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
543 *pending_maps_ptr = Fcons (Fcons (map, Fcons (item_string, key)),
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
544 *pending_maps_ptr);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
545 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
546 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
547
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
548 push_menu_item (item_string, enabled, key,
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
549 AREF (item_properties, ITEM_PROPERTY_DEF),
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
550 AREF (item_properties, ITEM_PROPERTY_KEYEQ),
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
551 AREF (item_properties, ITEM_PROPERTY_TYPE),
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
552 AREF (item_properties, ITEM_PROPERTY_SELECTED),
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
553 AREF (item_properties, ITEM_PROPERTY_HELP));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
554
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
555 /* Display a submenu using the toolkit. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
556 if (! (NILP (map) || NILP (enabled)))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
557 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
558 push_submenu_start ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
559 single_keymap_panes (map, Qnil, key, 0, maxdepth - 1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
560 push_submenu_end ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
561 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
562 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
563
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13434
diff changeset
564 /* Push all the panes and items of a menu described by the
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
565 alist-of-alists MENU.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
566 This handles old-fashioned calls to x-popup-menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
567
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
568 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
569 list_of_panes (menu)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
570 Lisp_Object menu;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
571 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
572 Lisp_Object tail;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
573
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
574 init_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
575
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
576 for (tail = menu; !NILP (tail); tail = Fcdr (tail))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
577 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
578 Lisp_Object elt, pane_name, pane_data;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
579 elt = Fcar (tail);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
580 pane_name = Fcar (elt);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
581 CHECK_STRING (pane_name);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
582 push_menu_pane (pane_name, Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
583 pane_data = Fcdr (elt);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
584 CHECK_CONS (pane_data);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
585 list_of_items (pane_data);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
586 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
587
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
588 finish_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
589 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
590
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
591 /* Push the items in a single pane defined by the alist PANE. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
592
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
593 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
594 list_of_items (pane)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
595 Lisp_Object pane;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
596 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
597 Lisp_Object tail, item, item1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
598
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
599 for (tail = pane; !NILP (tail); tail = Fcdr (tail))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
600 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
601 item = Fcar (tail);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
602 if (STRINGP (item))
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
603 push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
604 else if (NILP (item))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
605 push_left_right_boundary ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
606 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
607 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
608 CHECK_CONS (item);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
609 item1 = Fcar (item);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
610 CHECK_STRING (item1);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
611 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
612 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
613 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
614 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
615
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
616 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
617 doc: /* Pop up a deck-of-cards menu and return user's selection.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
618 POSITION is a position specification. This is either a mouse button
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
619 event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
620 are positions in pixels from the top left corner of WINDOW's frame
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
621 \(WINDOW may be a frame object instead of a window). This controls the
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
622 position of the center of the first line in the first pane of the
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
623 menu, not the top left of the menu as a whole. If POSITION is t, it
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
624 means to use the current mouse position.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
625
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
626 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
627 The menu items come from key bindings that have a menu string as well as
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
628 a definition; actually, the \"definition\" in such a key binding looks like
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
629 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
630 the keymap as a top-level element.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
631
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
632 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
633 Otherwise, REAL-DEFINITION should be a valid key binding definition.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
634
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
635 You can also use a list of keymaps as MENU. Then each keymap makes a
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
636 separate pane. When MENU is a keymap or a list of keymaps, the return
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
637 value is a list of events.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
638
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
639 Alternatively, you can specify a menu of multiple panes with a list of
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
640 the form (TITLE PANE1 PANE2...), where each pane is a list of
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
641 form (TITLE ITEM1 ITEM2...).
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
642 Each ITEM is normally a cons cell (STRING . VALUE); but a string can
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
643 appear as an item--that makes a nonselectable line in the menu.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
644 With this form of menu, the return value is VALUE from the chosen item.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
645
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
646 If POSITION is nil, don't display the menu at all, just precalculate the
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
647 cached information about equivalent key sequences. */)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
648 (position, menu)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
649 Lisp_Object position, menu;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
650 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
651 Lisp_Object keymap, tem;
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
652 int xpos = 0, ypos = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
653 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
654 char *error_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
655 Lisp_Object selection;
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
656 FRAME_PTR f = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
657 Lisp_Object x, y, window;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
658 int keymaps = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
659 int for_click = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
660 struct gcpro gcpro1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
661
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
662 #ifdef HAVE_MENUS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
663 if (! NILP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
664 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
665 check_w32 ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
666
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
667 /* Decode the first argument: find the window and the coordinates. */
16860
247f0b107588 (x-popup-menu): Pass in insist flag to mouse_position_hook.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16729
diff changeset
668 if (EQ (position, Qt)
32671
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
669 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
670 || EQ (XCAR (position), Qtool_bar))))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
671 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
672 /* Use the mouse's current position. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
673 FRAME_PTR new_f = SELECTED_FRAME ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
674 Lisp_Object bar_window;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
675 enum scroll_bar_part part;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
676 unsigned long time;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
677
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
678 if (mouse_position_hook)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
679 (*mouse_position_hook) (&new_f, 1, &bar_window,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
680 &part, &x, &y, &time);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
681 if (new_f != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
682 XSETFRAME (window, new_f);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
683 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
684 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
685 window = selected_window;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
686 XSETFASTINT (x, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
687 XSETFASTINT (y, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
688 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
689 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
690 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
691 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
692 tem = Fcar (position);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
693 if (CONSP (tem))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
694 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
695 window = Fcar (Fcdr (position));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
696 x = Fcar (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
697 y = Fcar (Fcdr (tem));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
698 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
699 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
700 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
701 for_click = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
702 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
703 window = Fcar (tem); /* POSN_WINDOW (tem) */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
704 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
705 x = Fcar (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
706 y = Fcdr (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
707 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
708 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
709
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
710 CHECK_NUMBER (x);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
711 CHECK_NUMBER (y);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
712
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
713 /* Decode where to put the menu. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
714
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
715 if (FRAMEP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
716 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
717 f = XFRAME (window);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
718 xpos = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
719 ypos = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
720 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
721 else if (WINDOWP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
722 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
723 CHECK_LIVE_WINDOW (window);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
724 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
725
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
726 xpos = WINDOW_LEFT_EDGE_X (XWINDOW (window));
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
727 ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
728 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
729 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
730 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
731 but I don't want to make one now. */
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
732 CHECK_WINDOW (window);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
733
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
734 xpos += XINT (x);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
735 ypos += XINT (y);
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
736
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
737 XSETFRAME (Vmenu_updating_frame, f);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
738 }
67704
06f3a72bffb2 (Fx_popup_menu): Add `else' to set Vmenu_updating_frame to nil
Juri Linkov <juri@jurta.org>
parents: 65301
diff changeset
739 else
06f3a72bffb2 (Fx_popup_menu): Add `else' to set Vmenu_updating_frame to nil
Juri Linkov <juri@jurta.org>
parents: 65301
diff changeset
740 Vmenu_updating_frame = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
741 #endif /* HAVE_MENUS */
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
742
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
743 title = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
744 GCPRO1 (title);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
745
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
746 /* Decode the menu items from what was specified. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
747
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
748 keymap = get_keymap (menu, 0, 0);
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
749 if (CONSP (keymap))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
750 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
751 /* We were given a keymap. Extract menu info from the keymap. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
752 Lisp_Object prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
753
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
754 /* Extract the detailed info to make one pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
755 keymap_panes (&menu, 1, NILP (position));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
756
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
757 /* Search for a string appearing directly as an element of the keymap.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
758 That string is the title of the menu. */
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
759 prompt = Fkeymap_prompt (keymap);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
760 if (NILP (title) && !NILP (prompt))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
761 title = prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
762
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
763 /* Make that be the pane title of the first pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
764 if (!NILP (prompt) && menu_items_n_panes >= 0)
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
765 ASET (menu_items, MENU_ITEMS_PANE_NAME, prompt);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
766
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
767 keymaps = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
768 }
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
769 else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
770 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
771 /* We were given a list of keymaps. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
772 int nmaps = XFASTINT (Flength (menu));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
773 Lisp_Object *maps
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
774 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
775 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
776
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
777 title = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
778
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
779 /* The first keymap that has a prompt string
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
780 supplies the menu title. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
781 for (tem = menu, i = 0; CONSP (tem); tem = Fcdr (tem))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
782 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
783 Lisp_Object prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
784
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
785 maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
786
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
787 prompt = Fkeymap_prompt (keymap);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
788 if (NILP (title) && !NILP (prompt))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
789 title = prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
790 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
791
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
792 /* Extract the detailed info to make one pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
793 keymap_panes (maps, nmaps, NILP (position));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
794
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
795 /* Make the title be the pane title of the first pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
796 if (!NILP (title) && menu_items_n_panes >= 0)
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
797 ASET (menu_items, MENU_ITEMS_PANE_NAME, title);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
798
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
799 keymaps = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
800 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
801 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
802 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
803 /* We were given an old-fashioned menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
804 title = Fcar (menu);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
805 CHECK_STRING (title);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
806
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
807 list_of_panes (Fcdr (menu));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
808
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
809 keymaps = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
810 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
811
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
812 if (NILP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
813 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
814 discard_menu_items ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
815 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
816 UNGCPRO;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
817 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
818 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
819
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
820 #ifdef HAVE_MENUS
69443
c5278c858018 (Fx_popup_menu): Call w32_free_menu_strings when
Jason Rumney <jasonr@gnu.org>
parents: 68651
diff changeset
821 /* If resources from a previous popup menu still exist, does nothing
c5278c858018 (Fx_popup_menu): Call w32_free_menu_strings when
Jason Rumney <jasonr@gnu.org>
parents: 68651
diff changeset
822 until the `menu_free_timer' has freed them (see w32fns.c). This
c5278c858018 (Fx_popup_menu): Call w32_free_menu_strings when
Jason Rumney <jasonr@gnu.org>
parents: 68651
diff changeset
823 can occur if you press ESC or click outside a menu without selecting
c5278c858018 (Fx_popup_menu): Call w32_free_menu_strings when
Jason Rumney <jasonr@gnu.org>
parents: 68651
diff changeset
824 a menu item.
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
825 */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
826 if (current_popup_menu)
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
827 {
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
828 discard_menu_items ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
829 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
830 UNGCPRO;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
831 return Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
832 }
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
833
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
834 /* Display them in a menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
835 BLOCK_INPUT;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
836
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
837 selection = w32_menu_show (f, xpos, ypos, for_click,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
838 keymaps, title, &error_name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
839 UNBLOCK_INPUT;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
840
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
841 discard_menu_items ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
842 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
69443
c5278c858018 (Fx_popup_menu): Call w32_free_menu_strings when
Jason Rumney <jasonr@gnu.org>
parents: 68651
diff changeset
843
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
844 #endif /* HAVE_MENUS */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
845
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
846 UNGCPRO;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
847
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
848 if (error_name) error (error_name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
849 return selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
850 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
851
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
852 #ifdef HAVE_MENUS
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
853
62670
5ba03d610746 (Fx_popup_dialog): Allow 3rd optional argument.
Nick Roberts <nickrob@snap.net.nz>
parents: 62668
diff changeset
854 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
855 doc: /* Pop up a dialog box and return user's selection.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
856 POSITION specifies which frame to use.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
857 This is normally a mouse button event or a window or frame.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
858 If POSITION is t, it means to use the frame the mouse is on.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
859 The dialog box appears in the middle of the specified frame.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
860
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
861 CONTENTS specifies the alternatives to display in the dialog box.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
862 It is a list of the form (TITLE ITEM1 ITEM2...).
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
863 Each ITEM is a cons cell (STRING . VALUE).
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
864 The return value is VALUE from the chosen item.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
865
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
866 An ITEM may also be just a string--that makes a nonselectable item.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
867 An ITEM may also be nil--that means to put all preceding items
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
868 on the left of the dialog box and all following items on the right.
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
869 \(By default, approximately half appear on each side.)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
870
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
871 If HEADER is non-nil, the frame title for the box is "Information",
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
872 otherwise it is "Question". */)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
873 (position, contents, header)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
874 Lisp_Object position, contents, header;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
875 {
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
876 FRAME_PTR f = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
877 Lisp_Object window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
878
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
879 check_w32 ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
880
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
881 /* Decode the first argument: find the window or frame to use. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
882 if (EQ (position, Qt)
32671
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
883 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
884 || EQ (XCAR (position), Qtool_bar))))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
885 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
886 #if 0 /* Using the frame the mouse is on may not be right. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
887 /* Use the mouse's current position. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
888 FRAME_PTR new_f = SELECTED_FRAME ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
889 Lisp_Object bar_window;
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
890 enum scroll_bar_part part;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
891 unsigned long time;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
892 Lisp_Object x, y;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
893
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
894 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
895
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
896 if (new_f != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
897 XSETFRAME (window, new_f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
898 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
899 window = selected_window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
900 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
901 window = selected_window;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
902 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
903 else if (CONSP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
904 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
905 Lisp_Object tem;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
906 tem = Fcar (position);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
907 if (CONSP (tem))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
908 window = Fcar (Fcdr (position));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
909 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
910 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
911 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
912 window = Fcar (tem); /* POSN_WINDOW (tem) */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
913 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
914 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
915 else if (WINDOWP (position) || FRAMEP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
916 window = position;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
917 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
918 window = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
919
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
920 /* Decode where to put the menu. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
921
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
922 if (FRAMEP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
923 f = XFRAME (window);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
924 else if (WINDOWP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
925 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
926 CHECK_LIVE_WINDOW (window);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
927 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
928 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
929 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
930 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
931 but I don't want to make one now. */
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
932 CHECK_WINDOW (window);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
933
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
934 #ifndef HAVE_DIALOGS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
935 /* Display a menu with these alternatives
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
936 in the middle of frame F. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
937 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
938 Lisp_Object x, y, frame, newpos;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
939 XSETFRAME (frame, f);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
940 XSETINT (x, x_pixel_width (f) / 2);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
941 XSETINT (y, x_pixel_height (f) / 2);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
942 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
943
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
944 return Fx_popup_menu (newpos,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
945 Fcons (Fcar (contents), Fcons (contents, Qnil)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
946 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
947 #else /* HAVE_DIALOGS */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
948 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
949 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
950 char *error_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
951 Lisp_Object selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
952
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
953 /* Decode the dialog items from what was specified. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
954 title = Fcar (contents);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
955 CHECK_STRING (title);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
956
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
957 list_of_panes (Fcons (contents, Qnil));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
958
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
959 /* Display them in a dialog box. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
960 BLOCK_INPUT;
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
961 selection = w32_dialog_show (f, 0, title, header, &error_name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
962 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
963
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
964 discard_menu_items ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
965 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
966
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
967 if (error_name) error (error_name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
968 return selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
969 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
970 #endif /* HAVE_DIALOGS */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
971 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
972
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
973 /* Activate the menu bar of frame F.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
974 This is called from keyboard.c when it gets the
45803
9484de301252 Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents: 43471
diff changeset
975 MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue.
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
976
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
977 To activate the menu bar, we signal to the input thread that it can
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
978 return from the WM_INITMENU message, allowing the normal Windows
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
979 processing of the menus.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
980
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
981 But first we recompute the menu bar contents (the whole tree).
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
982
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
983 This way we can safely execute Lisp code. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
984
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
985 void
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
986 x_activate_menubar (f)
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
987 FRAME_PTR f;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
988 {
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
989 set_frame_menubar (f, 0, 1);
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
990
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
991 /* Lock out further menubar changes while active. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
992 f->output_data.w32->menubar_active = 1;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
993
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
994 /* Signal input thread to return from WM_INITMENU. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
995 complete_deferred_msg (FRAME_W32_WINDOW (f), WM_INITMENU, 0);
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
996 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
997
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
998 /* This callback is called from the menu bar pulldown menu
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
999 when the user makes a selection.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1000 Figure out what the user chose
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1001 and put the appropriate events into the keyboard buffer. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1002
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1003 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1004 menubar_selection_callback (FRAME_PTR f, void * client_data)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1005 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1006 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1007 Lisp_Object vector;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1008 Lisp_Object *subprefix_stack;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1009 int submenu_depth = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1010 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1011
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1012 if (!f)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1013 return;
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1014 entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1015 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1016 vector = f->menu_bar_vector;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1017 prefix = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1018 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1019 while (i < f->menu_bar_items_used)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1020 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1021 if (EQ (AREF (vector, i), Qnil))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1022 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1023 subprefix_stack[submenu_depth++] = prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1024 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1025 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1026 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1027 else if (EQ (AREF (vector, i), Qlambda))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1028 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1029 prefix = subprefix_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1030 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1031 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1032 else if (EQ (AREF (vector, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1033 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1034 prefix = AREF (vector, i + MENU_ITEMS_PANE_PREFIX);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1035 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1036 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1037 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1038 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1039 entry = AREF (vector, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1040 /* The EMACS_INT cast avoids a warning. There's no problem
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1041 as long as pointers have enough bits to hold small integers. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1042 if ((int) (EMACS_INT) client_data == i)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1043 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1044 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1045 struct input_event buf;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1046 Lisp_Object frame;
51573
861a49cd70cf (menubar_selection_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51206
diff changeset
1047 EVENT_INIT (buf);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1048
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1049 XSETFRAME (frame, f);
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1050 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1051 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1052 buf.arg = frame;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1053 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1054
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1055 for (j = 0; j < submenu_depth; j++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1056 if (!NILP (subprefix_stack[j]))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1057 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1058 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1059 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1060 buf.arg = subprefix_stack[j];
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1061 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1062 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1063
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1064 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1065 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1066 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1067 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1068 buf.arg = prefix;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1069 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1070 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1071
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1072 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1073 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1074 buf.arg = entry;
76074
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
1075 /* Free memory used by owner-drawn and help-echo strings. */
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
1076 w32_free_menu_strings (FRAME_W32_WINDOW (f));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1077 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1078
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1079 f->output_data.w32->menubar_active = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1080 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1081 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1082 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1083 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1084 }
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1085 /* Free memory used by owner-drawn and help-echo strings. */
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1086 w32_free_menu_strings (FRAME_W32_WINDOW (f));
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1087 f->output_data.w32->menubar_active = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1088 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1089
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1090 /* Allocate a widget_value, blocking input. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1091
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1092 widget_value *
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1093 xmalloc_widget_value ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1094 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1095 widget_value *value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1096
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1097 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1098 value = malloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1099 UNBLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1100
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1101 return value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1102 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1103
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1104 /* This recursively calls free_widget_value on the tree of widgets.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1105 It must free all data that was malloc'ed for these widget_values.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1106 In Emacs, many slots are pointers into the data of Lisp_Strings, and
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1107 must be left alone. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1108
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1109 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1110 free_menubar_widget_value_tree (wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1111 widget_value *wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1112 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1113 if (! wv) return;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1114
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1115 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1116
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1117 if (wv->contents && (wv->contents != (widget_value*)1))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1118 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1119 free_menubar_widget_value_tree (wv->contents);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1120 wv->contents = (widget_value *) 0xDEADBEEF;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1121 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1122 if (wv->next)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1123 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1124 free_menubar_widget_value_tree (wv->next);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1125 wv->next = (widget_value *) 0xDEADBEEF;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1126 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1127 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1128 free_widget_value (wv);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1129 UNBLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1130 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1131
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1132 /* Set up data i menu_items for a menu bar item
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1133 whose event type is ITEM_KEY (with string ITEM_NAME)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1134 and whose contents come from the list of keymaps MAPS. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1135
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1136 static int
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1137 parse_single_submenu (item_key, item_name, maps)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1138 Lisp_Object item_key, item_name, maps;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1139 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1140 Lisp_Object length;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1141 int len;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1142 Lisp_Object *mapvec;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1143 int i;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1144 int top_level_items = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1145
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1146 length = Flength (maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1147 len = XINT (length);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1148
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1149 /* Convert the list MAPS into a vector MAPVEC. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1150 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1151 for (i = 0; i < len; i++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1152 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1153 mapvec[i] = Fcar (maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1154 maps = Fcdr (maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1155 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1156
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1157 /* Loop over the given keymaps, making a pane for each map.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1158 But don't make a pane that is empty--ignore that map instead. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1159 for (i = 0; i < len; i++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1160 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1161 if (SYMBOLP (mapvec[i])
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1162 || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i])))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1163 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1164 /* Here we have a command at top level in the menu bar
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1165 as opposed to a submenu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1166 top_level_items = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1167 push_menu_pane (Qnil, Qnil);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1168 push_menu_item (item_name, Qt, item_key, mapvec[i],
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1169 Qnil, Qnil, Qnil, Qnil);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1170 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1171 else
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1172 {
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1173 Lisp_Object prompt;
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1174 prompt = Fkeymap_prompt (mapvec[i]);
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1175 single_keymap_panes (mapvec[i],
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1176 !NILP (prompt) ? prompt : item_name,
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1177 item_key, 0, 10);
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1178 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1179 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1180
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1181 return top_level_items;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1182 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1183
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1184
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1185 /* Create a tree of widget_value objects
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1186 representing the panes and items
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1187 in menu_items starting at index START, up to index END. */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1188
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1189 static widget_value *
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1190 digest_single_submenu (start, end, top_level_items)
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1191 int start, end, top_level_items;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1192 {
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1193 widget_value *wv, *prev_wv, *save_wv, *first_wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1194 int i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1195 int submenu_depth = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1196 widget_value **submenu_stack;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1197
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1198 submenu_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1199 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1200 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1201 wv->name = "menu";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1202 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1203 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1204 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1205 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1206 first_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1207 save_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1208 prev_wv = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1209
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1210 /* Loop over all panes and items made by the preceding call
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1211 to parse_single_submenu and construct a tree of widget_value objects.
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1212 Ignore the panes and items used by previous calls to
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1213 digest_single_submenu, even though those are also in menu_items. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1214 i = start;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1215 while (i < end)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1216 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1217 if (EQ (AREF (menu_items, i), Qnil))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1218 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1219 submenu_stack[submenu_depth++] = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1220 save_wv = prev_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1221 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1222 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1223 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1224 else if (EQ (AREF (menu_items, i), Qlambda))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1225 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1226 prev_wv = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1227 save_wv = submenu_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1228 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1229 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1230 else if (EQ (AREF (menu_items, i), Qt)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1231 && submenu_depth != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1232 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1233 /* Ignore a nil in the item list.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1234 It's meaningful only for dialog boxes. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1235 else if (EQ (AREF (menu_items, i), Qquote))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1236 i += 1;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1237 else if (EQ (AREF (menu_items, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1238 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1239 /* Create a new pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1240 Lisp_Object pane_name, prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1241 char *pane_string;
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1242
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1243 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1244 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1245
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1246 if (STRINGP (pane_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1247 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1248 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1249 /* Encode as UTF-8 for now. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1250 pane_name = ENCODE_UTF_8 (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1251 else if (STRING_MULTIBYTE (pane_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1252 pane_name = ENCODE_SYSTEM (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1253
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1254 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1255 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1256
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1257 pane_string = (NILP (pane_name)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1258 ? "" : (char *) SDATA (pane_name));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1259 /* If there is just one top-level pane, put all its items directly
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1260 under the top-level menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1261 if (menu_items_n_panes == 1)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1262 pane_string = "";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1263
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1264 /* If the pane has a meaningful name,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1265 make the pane a top-level menu item
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1266 with its items as a submenu beneath it. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1267 if (strcmp (pane_string, ""))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1268 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1269 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1270 if (save_wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1271 save_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1272 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1273 first_wv->contents = wv;
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1274 wv->lname = pane_name;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1275 /* Set value to 1 so update_submenu_strings can handle '@' */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1276 wv->value = (char *) 1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1277 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1278 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1279 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1280 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1281 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1282 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1283 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1284 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1285 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1286 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1287 /* Create a new item within current pane. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1288 Lisp_Object item_name, enable, descrip, def, type, selected;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1289 Lisp_Object help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1290
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1291 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1292 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1293 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1294 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1295 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1296 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1297 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1298
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1299 if (STRINGP (item_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1300 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1301 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1302 item_name = ENCODE_UTF_8 (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1303 else if (STRING_MULTIBYTE (item_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1304 item_name = ENCODE_SYSTEM (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1305
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1306 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1307 }
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1308
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1309 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1310 {
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1311 descrip = ENCODE_SYSTEM (descrip);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1312 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1313 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1314
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1315 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1316 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1317 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1318 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1319 save_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1320
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1321 wv->lname = item_name;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1322 if (!NILP (descrip))
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1323 wv->lkey = descrip;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1324 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1325 /* The EMACS_INT cast avoids a warning. There's no problem
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1326 as long as pointers have enough bits to hold small integers. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1327 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1328 wv->enabled = !NILP (enable);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1329
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1330 if (NILP (type))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1331 wv->button_type = BUTTON_TYPE_NONE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1332 else if (EQ (type, QCradio))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1333 wv->button_type = BUTTON_TYPE_RADIO;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1334 else if (EQ (type, QCtoggle))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1335 wv->button_type = BUTTON_TYPE_TOGGLE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1336 else
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1337 abort ();
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1338
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1339 wv->selected = !NILP (selected);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1340 if (!STRINGP (help))
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1341 help = Qnil;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1342
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1343 wv->help = help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1344
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1345 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1346
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1347 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1348 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1349 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1350
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1351 /* If we have just one "menu item"
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1352 that was originally a button, return it by itself. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1353 if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1354 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1355 wv = first_wv->contents;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1356 free_widget_value (first_wv);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1357 return wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1358 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1359
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1360 return first_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1361 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1362
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1363
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1364 /* Walk through the widget_value tree starting at FIRST_WV and update
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1365 the char * pointers from the corresponding lisp values.
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1366 We do this after building the whole tree, since GC may happen while the
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1367 tree is constructed, and small strings are relocated. So we must wait
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1368 until no GC can happen before storing pointers into lisp values. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1369 static void
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1370 update_submenu_strings (first_wv)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1371 widget_value *first_wv;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1372 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1373 widget_value *wv;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1374
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1375 for (wv = first_wv; wv; wv = wv->next)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1376 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1377 if (wv->lname && ! NILP (wv->lname))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1378 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1379 wv->name = SDATA (wv->lname);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1380
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1381 /* Ignore the @ that means "separate pane".
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1382 This is a kludge, but this isn't worth more time. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1383 if (wv->value == (char *)1)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1384 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1385 if (wv->name[0] == '@')
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1386 wv->name++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1387 wv->value = 0;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1388 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1389 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1390
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1391 if (wv->lkey && ! NILP (wv->lkey))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1392 wv->key = SDATA (wv->lkey);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1393
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1394 if (wv->contents)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1395 update_submenu_strings (wv->contents);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1396 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1397 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1398
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1399
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1400 /* Set the contents of the menubar widgets of frame F.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1401 The argument FIRST_TIME is currently ignored;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1402 it is set the first time this is called, from initialize_frame_menubar. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1403
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1404 void
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1405 set_frame_menubar (f, first_time, deep_p)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1406 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1407 int first_time;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1408 int deep_p;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1409 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1410 HMENU menubar_widget = f->output_data.w32->menubar_widget;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1411 Lisp_Object items;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1412 widget_value *wv, *first_wv, *prev_wv = 0;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1413 int i, last_i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1414 int *submenu_start, *submenu_end;
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1415 int *submenu_top_level_items, *submenu_n_panes;
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
1416
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1417 /* We must not change the menubar when actually in use. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1418 if (f->output_data.w32->menubar_active)
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1419 return;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1420
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1421 XSETFRAME (Vmenu_updating_frame, f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1422
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1423 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1424 deep_p = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1425 else if (pending_menu_activation && !deep_p)
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1426 deep_p = 1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1427
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1428 if (deep_p)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1429 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1430 /* Make a widget-value tree representing the entire menu trees. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1431
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1432 struct buffer *prev = current_buffer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1433 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45803
diff changeset
1434 int specpdl_count = SPECPDL_INDEX ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1435 int previous_menu_items_used = f->menu_bar_items_used;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1436 Lisp_Object *previous_items
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1437 = (Lisp_Object *) alloca (previous_menu_items_used
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1438 * sizeof (Lisp_Object));
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1439
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1440 /* If we are making a new widget, its contents are empty,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1441 do always reinitialize them. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1442 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1443 previous_menu_items_used = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1444
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1445 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1446 specbind (Qinhibit_quit, Qt);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1447 /* Don't let the debugger step into this code
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1448 because it is not reentrant. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1449 specbind (Qdebug_on_next_call, Qnil);
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
1450
63147
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 62670
diff changeset
1451 record_unwind_save_match_data ();
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 62670
diff changeset
1452
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1453 if (NILP (Voverriding_local_map_menu_flag))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1454 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1455 specbind (Qoverriding_terminal_local_map, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1456 specbind (Qoverriding_local_map, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1457 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1458
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1459 set_buffer_internal_1 (XBUFFER (buffer));
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
1460
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1461 /* Run the Lucid hook. */
36313
77093a87f2de * w32menu.c (set_frame_menubar): Run activate-menu-bar-hook with
Jason Rumney <jasonr@gnu.org>
parents: 33971
diff changeset
1462 safe_run_hooks (Qactivate_menubar_hook);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1463 /* If it has changed current-menubar from previous value,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1464 really recompute the menubar from the value. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1465 if (! NILP (Vlucid_menu_bar_dirty_flag))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1466 call0 (Qrecompute_lucid_menubar);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1467 safe_run_hooks (Qmenu_bar_update_hook);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1468 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1469
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1470 items = FRAME_MENU_BAR_ITEMS (f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1471
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1472 /* Save the frame's previous menu bar contents data. */
39507
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1473 if (previous_menu_items_used)
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1474 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1475 previous_menu_items_used * sizeof (Lisp_Object));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1476
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1477 /* Fill in menu_items with the current menu bar contents.
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1478 This can evaluate Lisp code. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1479 menu_items = f->menu_bar_vector;
39507
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1480 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1481 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1482 submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1483 submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int));
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1484 submenu_top_level_items
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1485 = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1486 init_menu_items ();
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1487 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1488 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1489 Lisp_Object key, string, maps;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1490
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1491 last_i = i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1492
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1493 key = AREF (items, i);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1494 string = AREF (items, i + 1);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1495 maps = AREF (items, i + 2);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1496 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1497 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1498
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1499 submenu_start[i] = menu_items_used;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1500
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1501 menu_items_n_panes = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1502 submenu_top_level_items[i]
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1503 = parse_single_submenu (key, string, maps);
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1504 submenu_n_panes[i] = menu_items_n_panes;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1505
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1506 submenu_end[i] = menu_items_used;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1507 }
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1508
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1509 finish_menu_items ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1510
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1511 /* Convert menu_items into widget_value trees
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1512 to display the menu. This cannot evaluate Lisp code. */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1513
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1514 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1515 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1516 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1517 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1518 wv->button_type = BUTTON_TYPE_NONE;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1519 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1520 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1521
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1522 for (i = 0; i < last_i; i += 4)
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1523 {
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1524 menu_items_n_panes = submenu_n_panes[i];
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1525 wv = digest_single_submenu (submenu_start[i], submenu_end[i],
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1526 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1527 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1528 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1529 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1530 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1531 /* Don't set wv->name here; GC during the loop might relocate it. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1532 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1533 wv->button_type = BUTTON_TYPE_NONE;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1534 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1535 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1536
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1537 set_buffer_internal_1 (prev);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1538 unbind_to (specpdl_count, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1539
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1540 /* If there has been no change in the Lisp-level contents
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1541 of the menu bar, skip redisplaying it. Just exit. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1542
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1543 for (i = 0; i < previous_menu_items_used; i++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1544 if (menu_items_used == i
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1545 || (!EQ (previous_items[i], AREF (menu_items, i))))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1546 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1547 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1548 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1549 free_menubar_widget_value_tree (first_wv);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1550 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1551
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1552 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1553 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1554
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1555 /* Now GC cannot happen during the lifetime of the widget_value,
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1556 so it's safe to store data from a Lisp_String, as long as
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1557 local copies are made when the actual menu is created.
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1558 Windows takes care of this for normal string items, but
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1559 not for owner-drawn items or additional item-info. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1560 wv = first_wv->contents;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1561 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1562 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1563 Lisp_Object string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1564 string = AREF (items, i + 1);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1565 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1566 break;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1567 wv->name = (char *) SDATA (string);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1568 update_submenu_strings (wv->contents);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1569 wv = wv->next;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1570 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1571
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1572 f->menu_bar_vector = menu_items;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1573 f->menu_bar_items_used = menu_items_used;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1574 menu_items = Qnil;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1575 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1576 else
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1577 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1578 /* Make a widget-value tree containing
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1579 just the top level menu bar strings. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1580
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1581 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1582 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1583 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1584 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1585 wv->button_type = BUTTON_TYPE_NONE;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1586 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1587 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1588
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1589 items = FRAME_MENU_BAR_ITEMS (f);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1590 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1591 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1592 Lisp_Object string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1593
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1594 string = AREF (items, i + 1);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1595 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1596 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1597
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1598 wv = xmalloc_widget_value ();
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1599 wv->name = (char *) SDATA (string);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1600 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1601 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1602 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1603 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1604 /* This prevents lwlib from assuming this
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1605 menu item is really supposed to be empty. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1606 /* The EMACS_INT cast avoids a warning.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1607 This value just has to be different from small integers. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1608 wv->call_data = (void *) (EMACS_INT) (-1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1609
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1610 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1611 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1612 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1613 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1614 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1615 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1616
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1617 /* Forget what we thought we knew about what is in the
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1618 detailed contents of the menu bar menus.
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1619 Changing the top level always destroys the contents. */
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1620 f->menu_bar_items_used = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1621 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1622
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1623 /* Create or update the menu bar widget. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1624
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1625 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1626
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1627 if (menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1628 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1629 /* Empty current menubar, rather than creating a fresh one. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1630 while (DeleteMenu (menubar_widget, 0, MF_BYPOSITION))
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1631 ;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1632 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1633 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1634 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1635 menubar_widget = CreateMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1636 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1637 fill_in_menu (menubar_widget, first_wv->contents);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1638
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1639 free_menubar_widget_value_tree (first_wv);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1640
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1641 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1642 HMENU old_widget = f->output_data.w32->menubar_widget;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1643
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1644 f->output_data.w32->menubar_widget = menubar_widget;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1645 SetMenu (FRAME_W32_WINDOW (f), f->output_data.w32->menubar_widget);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1646 /* Causes flicker when menu bar is updated
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1647 DrawMenuBar (FRAME_W32_WINDOW (f)); */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1648
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1649 /* Force the window size to be recomputed so that the frame's text
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1650 area remains the same, if menubar has just been created. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1651 if (old_widget == NULL)
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1652 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1653 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1654
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1655 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1656 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1657
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1658 /* Called from Fx_create_frame to create the initial menubar of a frame
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1659 before it is mapped, so that the window is mapped with the menubar already
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1660 there instead of us tacking it on later and thrashing the window after it
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1661 is visible. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1662
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1663 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1664 initialize_frame_menubar (f)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1665 FRAME_PTR f;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1666 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1667 /* This function is called before the first chance to redisplay
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1668 the frame. It has to be, so the frame will have the right size. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1669 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1670 set_frame_menubar (f, 1, 1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1671 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1672
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1673 /* Get rid of the menu bar of frame F, and free its storage.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1674 This is used when deleting a frame, and when turning off the menu bar. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1675
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1676 void
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1677 free_frame_menubar (f)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1678 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1679 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1680 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1681
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1682 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1683 HMENU old = GetMenu (FRAME_W32_WINDOW (f));
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1684 SetMenu (FRAME_W32_WINDOW (f), NULL);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1685 f->output_data.w32->menubar_widget = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1686 DestroyMenu (old);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1687 }
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1688
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1689 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1690 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1691
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1692
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1693 /* w32_menu_show actually displays a menu using the panes and items in
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1694 menu_items and returns the value selected from it; we assume input
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1695 is blocked by the caller. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1696
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1697 /* F is the frame the menu is for.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1698 X and Y are the frame-relative specified position,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1699 relative to the inside upper left corner of the frame F.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1700 FOR_CLICK is nonzero if this menu was invoked for a mouse click.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1701 KEYMAPS is 1 if this menu was specified with keymaps;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1702 in that case, we return a list containing the chosen item's value
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1703 and perhaps also the pane's prefix.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1704 TITLE is the specified menu title.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1705 ERROR is a place to store an error message string in case of failure.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1706 (We return nil on failure, but the value doesn't actually matter.) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1707
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1708 static Lisp_Object
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1709 w32_menu_show (f, x, y, for_click, keymaps, title, error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1710 FRAME_PTR f;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1711 int x;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1712 int y;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1713 int for_click;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1714 int keymaps;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1715 Lisp_Object title;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1716 char **error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1717 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1718 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1719 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1720 HMENU menu;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1721 POINT pos;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1722 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1723 widget_value **submenu_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1724 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1725 Lisp_Object *subprefix_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1726 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1727 int submenu_depth = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1728 int first_pane;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1729
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1730 *error = NULL;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1731
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1732 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1733 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1734 *error = "Empty menu";
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1735 return Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1736 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1737
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1738 /* Create a tree of widget_value objects
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1739 representing the panes and their items. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1740 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1741 wv->name = "menu";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1742 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1743 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1744 wv->button_type = BUTTON_TYPE_NONE;
42613
a5eb47b53761 Fix typo in last checkin
Jason Rumney <jasonr@gnu.org>
parents: 42589
diff changeset
1745 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1746 first_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1747 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1748
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1749 /* Loop over all panes and items, filling in the tree. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1750 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1751 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1752 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1753 if (EQ (AREF (menu_items, i), Qnil))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1754 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1755 submenu_stack[submenu_depth++] = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1756 save_wv = prev_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1757 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1758 first_pane = 1;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1759 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1760 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1761 else if (EQ (AREF (menu_items, i), Qlambda))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1762 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1763 prev_wv = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1764 save_wv = submenu_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1765 first_pane = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1766 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1767 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1768 else if (EQ (AREF (menu_items, i), Qt)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1769 && submenu_depth != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1770 i += MENU_ITEMS_PANE_LENGTH;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1771 /* Ignore a nil in the item list.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1772 It's meaningful only for dialog boxes. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1773 else if (EQ (AREF (menu_items, i), Qquote))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1774 i += 1;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1775 else if (EQ (AREF (menu_items, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1776 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1777 /* Create a new pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1778 Lisp_Object pane_name, prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1779 char *pane_string;
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1780 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1781 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1782
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1783 if (STRINGP (pane_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1784 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1785 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1786 pane_name = ENCODE_UTF_8 (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1787 else if (STRING_MULTIBYTE (pane_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1788 pane_name = ENCODE_SYSTEM (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1789
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1790 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1791 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1792
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1793 pane_string = (NILP (pane_name)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1794 ? "" : (char *) SDATA (pane_name));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1795 /* If there is just one top-level pane, put all its items directly
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1796 under the top-level menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1797 if (menu_items_n_panes == 1)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1798 pane_string = "";
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1799
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1800 /* If the pane has a meaningful name,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1801 make the pane a top-level menu item
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1802 with its items as a submenu beneath it. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1803 if (!keymaps && strcmp (pane_string, ""))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1804 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1805 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1806 if (save_wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1807 save_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1808 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1809 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1810 wv->name = pane_string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1811 if (keymaps && !NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1812 wv->name++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1813 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1814 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1815 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1816 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1817 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1818 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1819 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1820 else if (first_pane)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1821 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1822 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1823 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1824 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1825 first_pane = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1826 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1827 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1828 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1829 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1830 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
1831 Lisp_Object item_name, enable, descrip, def, type, selected, help;
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
1832
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1833 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1834 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1835 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1836 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1837 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1838 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1839 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1840
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1841 if (STRINGP (item_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1842 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1843 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1844 item_name = ENCODE_UTF_8 (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1845 else if (STRING_MULTIBYTE (item_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1846 item_name = ENCODE_SYSTEM (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1847
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1848 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1849 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1850
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1851 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1852 {
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1853 descrip = ENCODE_SYSTEM (descrip);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1854 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1855 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1856
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1857 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1858 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1859 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1860 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1861 save_wv->contents = wv;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1862 wv->name = (char *) SDATA (item_name);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1863 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1864 wv->key = (char *) SDATA (descrip);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1865 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1866 /* Use the contents index as call_data, since we are
41251
e6612d08452f (w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 41108
diff changeset
1867 restricted to 16-bits. */
22737
41e01b5de7cc (w32_menu_show): Set widget call_data to 0 if definition is nil.
Andrew Innes <andrewi@gnu.org>
parents: 21741
diff changeset
1868 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1869 wv->enabled = !NILP (enable);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1870
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1871 if (NILP (type))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1872 wv->button_type = BUTTON_TYPE_NONE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1873 else if (EQ (type, QCtoggle))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1874 wv->button_type = BUTTON_TYPE_TOGGLE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1875 else if (EQ (type, QCradio))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1876 wv->button_type = BUTTON_TYPE_RADIO;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1877 else
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1878 abort ();
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1879
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1880 wv->selected = !NILP (selected);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1881 if (!STRINGP (help))
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1882 help = Qnil;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1883
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1884 wv->help = help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1885
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1886 prev_wv = wv;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1887
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1888 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1889 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1890 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1891
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1892 /* Deal with the title, if it is non-nil. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1893 if (!NILP (title))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1894 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1895 widget_value *wv_title = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1896 widget_value *wv_sep = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1897
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1898 /* Maybe replace this separator with a bitmap or owner-draw item
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1899 so that it looks better. Having two separators looks odd. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1900 wv_sep->name = "--";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1901 wv_sep->next = first_wv->contents;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1902 wv_sep->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1903
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1904 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1905 title = ENCODE_UTF_8 (title);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1906 else if (STRING_MULTIBYTE (title))
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
1907 title = ENCODE_SYSTEM (title);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1908
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1909 wv_title->name = (char *) SDATA (title);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1910 wv_title->enabled = TRUE;
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1911 wv_title->title = TRUE;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1912 wv_title->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1913 wv_title->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1914 wv_title->next = wv_sep;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1915 first_wv->contents = wv_title;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1916 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1917
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1918 /* Actually create the menu. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1919 current_popup_menu = menu = CreatePopupMenu ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1920 fill_in_menu (menu, first_wv->contents);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1921
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1922 /* Adjust coordinates to be root-window-relative. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1923 pos.x = x;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1924 pos.y = y;
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1925 ClientToScreen (FRAME_W32_WINDOW (f), &pos);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1926
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1927 /* No selection has been chosen yet. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1928 menu_item_selection = 0;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1929
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1930 /* Display the menu. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1931 menu_item_selection = SendMessage (FRAME_W32_WINDOW (f),
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1932 WM_EMACS_TRACKPOPUPMENU,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1933 (WPARAM)menu, (LPARAM)&pos);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1934
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1935 /* Clean up extraneous mouse events which might have been generated
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1936 during the call. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1937 discard_mouse_events ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
1938 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1939
30238
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
1940 /* Free the widget_value objects we used to specify the contents. */
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
1941 free_menubar_widget_value_tree (first_wv);
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
1942
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1943 DestroyMenu (menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1944
76080
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
1945 /* Free the owner-drawn and help-echo menu strings. */
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
1946 w32_free_menu_strings (FRAME_W32_WINDOW (f));
76086
da9b24e47b34 (w32_menu_show): Mark the frame's menu as inactive when popup menu
Jason Rumney <jasonr@gnu.org>
parents: 76080
diff changeset
1947 f->output_data.w32->menubar_active = 0;
76080
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
1948
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1949 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1950 the proper value. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1951 if (menu_item_selection != 0)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1952 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1953 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1954
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1955 prefix = entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1956 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1957 while (i < menu_items_used)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1958 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1959 if (EQ (AREF (menu_items, i), Qnil))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1960 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1961 subprefix_stack[submenu_depth++] = prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1962 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1963 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1964 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1965 else if (EQ (AREF (menu_items, i), Qlambda))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1966 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1967 prefix = subprefix_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1968 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1969 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1970 else if (EQ (AREF (menu_items, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1971 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1972 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1973 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1974 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1975 /* Ignore a nil in the item list.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1976 It's meaningful only for dialog boxes. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1977 else if (EQ (AREF (menu_items, i), Qquote))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1978 i += 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1979 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1980 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1981 entry = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1982 if (menu_item_selection == i)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1983 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1984 if (keymaps != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1985 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1986 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1987
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1988 entry = Fcons (entry, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1989 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1990 entry = Fcons (prefix, entry);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1991 for (j = submenu_depth - 1; j >= 0; j--)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1992 if (!NILP (subprefix_stack[j]))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1993 entry = Fcons (subprefix_stack[j], entry);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1994 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1995 return entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1996 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1997 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1998 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1999 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2000 }
72260
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2001 else if (!for_click)
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2002 /* Make "Cancel" equivalent to C-g. */
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2003 Fsignal (Qquit, Qnil);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2004
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2005 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2006 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2007
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2008
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2009 #ifdef HAVE_DIALOGS
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2010 static char * button_names [] = {
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2011 "button1", "button2", "button3", "button4", "button5",
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2012 "button6", "button7", "button8", "button9", "button10" };
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2013
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2014 static Lisp_Object
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2015 w32_dialog_show (f, keymaps, title, header, error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2016 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2017 int keymaps;
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2018 Lisp_Object title, header;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2019 char **error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2020 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2021 int i, nb_buttons=0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2022 char dialog_name[6];
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2023 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2024
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2025 widget_value *wv, *first_wv = 0, *prev_wv = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2026
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2027 /* Number of elements seen so far, before boundary. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2028 int left_count = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2029 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2030 int boundary_seen = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2031
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2032 *error = NULL;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2033
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2034 if (menu_items_n_panes > 1)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2035 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2036 *error = "Multiple panes in dialog box";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2037 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2038 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2039
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2040 /* Create a tree of widget_value objects
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2041 representing the text label and buttons. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2042 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2043 Lisp_Object pane_name, prefix;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2044 char *pane_string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2045 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2046 prefix = AREF (menu_items, MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2047 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2048 ? "" : (char *) SDATA (pane_name));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2049 prev_wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2050 prev_wv->value = pane_string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2051 if (keymaps && !NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2052 prev_wv->name++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2053 prev_wv->enabled = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2054 prev_wv->name = "message";
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2055 prev_wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2056 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2057
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2058 /* Loop over all panes and items, filling in the tree. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2059 i = MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2060 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2061 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2062
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2063 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
2064 Lisp_Object item_name, enable, descrip, help;
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
2065
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2066 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2067 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2068 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2069 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2070
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2071 if (NILP (item_name))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2072 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2073 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2074 *error = "Submenu in dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2075 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2076 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2077 if (EQ (item_name, Qquote))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2078 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2079 /* This is the boundary between left-side elts
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2080 and right-side elts. Stop incrementing right_count. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2081 boundary_seen = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2082 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2083 continue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2084 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2085 if (nb_buttons >= 9)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2086 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2087 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2088 *error = "Too many dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2089 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2090 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2091
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2092 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2093 prev_wv->next = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2094 wv->name = (char *) button_names[nb_buttons];
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2095 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2096 wv->key = (char *) SDATA (descrip);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2097 wv->value = (char *) SDATA (item_name);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2098 wv->call_data = (void *) &AREF (menu_items, i);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2099 wv->enabled = !NILP (enable);
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2100 wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2101 prev_wv = wv;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2102
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2103 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2104 left_count++;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2105
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2106 nb_buttons++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2107 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2108 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2109
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2110 /* If the boundary was not specified,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2111 by default put half on the left and half on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2112 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2113 left_count = nb_buttons - nb_buttons / 2;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2114
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2115 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2116 wv->name = dialog_name;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2117 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2118
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2119 /* Frame title: 'Q' = Question, 'I' = Information.
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2120 Can also have 'E' = Error if, one day, we want
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2121 a popup for errors. */
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2122 if (NILP(header))
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2123 dialog_name[0] = 'Q';
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2124 else
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2125 dialog_name[0] = 'I';
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2126
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2127 /* Dialog boxes use a really stupid name encoding
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2128 which specifies how many buttons to use
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
2129 and how many buttons are on the right. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2130 dialog_name[1] = '0' + nb_buttons;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2131 dialog_name[2] = 'B';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2132 dialog_name[3] = 'R';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2133 /* Number of buttons to put on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2134 dialog_name[4] = '0' + nb_buttons - left_count;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2135 dialog_name[5] = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2136 wv->contents = first_wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2137 first_wv = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2138 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2139
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2140 /* Actually create the dialog. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2141 dialog_id = widget_id_tick++;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2142 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
2143 f->output_data.w32->widget, 1, 0,
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2144 dialog_selection_callback, 0);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
2145 lw_modify_all_widgets (dialog_id, first_wv->contents, TRUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2146
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2147 /* Free the widget_value objects we used to specify the contents. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2148 free_menubar_widget_value_tree (first_wv);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2149
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2150 /* No selection has been chosen yet. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2151 menu_item_selection = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2152
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2153 /* Display the menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2154 lw_pop_up_all_widgets (dialog_id);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2155
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2156 /* Process events that apply to the menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2157 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2158
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2159 lw_destroy_all_widgets (dialog_id);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2160
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2161 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2162 the proper value. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2163 if (menu_item_selection != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2164 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2165 Lisp_Object prefix;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2166
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2167 prefix = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2168 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2169 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2170 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2171 Lisp_Object entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2172
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2173 if (EQ (AREF (menu_items, i), Qt))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2174 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2175 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2176 i += MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2177 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2178 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2179 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2180 entry = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2181 if (menu_item_selection == i)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2182 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2183 if (keymaps != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2184 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2185 entry = Fcons (entry, Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2186 if (!NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2187 entry = Fcons (prefix, entry);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2188 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2189 return entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2190 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2191 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2192 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2193 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2194 }
72260
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2195 else
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2196 /* Make "Cancel" equivalent to C-g. */
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
2197 Fsignal (Qquit, Qnil);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2198
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2199 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2200 }
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2201 #endif /* HAVE_DIALOGS */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2202
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2203
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2204 /* Is this item a separator? */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2205 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2206 name_is_separator (name)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2207 char *name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2208 {
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2209 char *start = name;
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2210
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2211 /* Check if name string consists of only dashes ('-'). */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2212 while (*name == '-') name++;
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2213 /* Separators can also be of the form "--:TripleSuperMegaEtched"
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2214 or "--deep-shadow". We don't implement them yet, se we just treat
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2215 them like normal separators. */
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2216 return (*name == '\0' || start + 2 == name);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2217 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2218
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2219
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2220 /* Indicate boundary between left and right. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2221 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2222 add_left_right_boundary (HMENU menu)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2223 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2224 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2225 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2226
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2227 /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2228 static void
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2229 utf8to16 (unsigned char * src, int len, WCHAR * dest)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2230 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2231 while (len > 0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2232 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2233 int utf16;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2234 if (*src < 0x80)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2235 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2236 *dest = (WCHAR) *src;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2237 dest++; src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2238 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2239 /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2240 else if (*src < 0xC0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2241 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2242 src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2243 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2244 /* 2 char UTF-8 sequence. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2245 else if (*src < 0xE0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2246 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2247 *dest = (WCHAR) (((*src & 0x1f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2248 | (*(src + 1) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2249 src += 2; len -= 2; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2250 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2251 else if (*src < 0xF0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2252 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2253 *dest = (WCHAR) (((*src & 0x0f) << 12)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2254 | ((*(src + 1) & 0x3f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2255 | (*(src + 2) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2256 src += 3; len -= 3; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2257 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2258 else /* Not encodable. Insert Unicode Substitution char. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2259 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2260 *dest = (WCHAR) 0xfffd;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2261 src++; len--; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2262 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2263 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2264 *dest = 0;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2265 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2266
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2267 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2268 add_menu_item (HMENU menu, widget_value *wv, HMENU item)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2269 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2270 UINT fuFlags;
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2271 char *out_string, *p, *q;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2272 int return_value;
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2273 size_t nlen, orig_len;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2274
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2275 if (name_is_separator (wv->name))
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2276 {
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2277 fuFlags = MF_SEPARATOR;
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2278 out_string = NULL;
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2279 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2280 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2281 {
22750
b38cb406ed80 (add_menu_item): Draw menu items like titles if call_data is 0.
Andrew Innes <andrewi@gnu.org>
parents: 22737
diff changeset
2282 if (wv->enabled)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2283 fuFlags = MF_STRING;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2284 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2285 fuFlags = MF_STRING | MF_GRAYED;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2286
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2287 if (wv->key != NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2288 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2289 out_string = alloca (strlen (wv->name) + strlen (wv->key) + 2);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2290 strcpy (out_string, wv->name);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2291 strcat (out_string, "\t");
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2292 strcat (out_string, wv->key);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2293 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2294 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2295 out_string = wv->name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2296
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2297 /* Quote any special characters within the menu item's text and
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2298 key binding. */
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2299 nlen = orig_len = strlen (out_string);
78022
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2300 if (unicode_append_menu)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2301 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2302 /* With UTF-8, & cannot be part of a multibyte character. */
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2303 for (p = out_string; *p; p++)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2304 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2305 if (*p == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2306 nlen++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2307 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2308 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2309 else
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2310 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2311 /* If encoded with the system codepage, use multibyte string
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2312 functions in case of multibyte characters that contain '&'. */
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2313 for (p = out_string; *p; p = _mbsinc (p))
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2314 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2315 if (_mbsnextc (p) == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2316 nlen++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2317 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2318 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2319
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2320 if (nlen > orig_len)
78022
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2321 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2322 p = out_string;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2323 out_string = alloca (nlen + 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2324 q = out_string;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2325 while (*p)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2326 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2327 if (unicode_append_menu)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2328 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2329 if (*p == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2330 *q++ = *p;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2331 *q++ = *p++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2332 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2333 else
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2334 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2335 if (_mbsnextc (p) == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2336 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2337 _mbsncpy (q, p, 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2338 q = _mbsinc (q);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2339 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2340 _mbsncpy (q, p, 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2341 p = _mbsinc (p);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2342 q = _mbsinc (q);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2343 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2344 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2345 *q = '\0';
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
2346 }
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
2347
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2348 if (item != NULL)
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2349 fuFlags = MF_POPUP;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2350 else if (wv->title || wv->call_data == 0)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2351 {
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2352 /* Only use MF_OWNERDRAW if GetMenuItemInfo is usable, since
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2353 we can't deallocate the memory otherwise. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2354 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2355 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2356 out_string = (char *) local_alloc (strlen (wv->name) + 1);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2357 strcpy (out_string, wv->name);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2358 #ifdef MENU_DEBUG
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2359 DebPrint ("Menu: allocing %ld for owner-draw", out_string);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2360 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2361 fuFlags = MF_OWNERDRAW | MF_DISABLED;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2362 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2363 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2364 fuFlags = MF_DISABLED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2365 }
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2366
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2367 /* Draw radio buttons and tickboxes. */
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2368 else if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
41108
ef7a153a2c68 (add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
2369 wv->button_type == BUTTON_TYPE_RADIO))
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2370 fuFlags |= MF_CHECKED;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2371 else
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2372 fuFlags |= MF_UNCHECKED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2373 }
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2374
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2375 if (unicode_append_menu && out_string)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2376 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2377 /* Convert out_string from UTF-8 to UTF-16-LE. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2378 int utf8_len = strlen (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2379 WCHAR * utf16_string;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2380 if (fuFlags & MF_OWNERDRAW)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2381 utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2382 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2383 utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2384
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2385 utf8to16 (out_string, utf8_len, utf16_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2386 return_value = unicode_append_menu (menu, fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2387 item != NULL ? (UINT) item
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2388 : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2389 utf16_string);
65301
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2390 if (!return_value)
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2391 {
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2392 /* On W9x/ME, unicode menus are not supported, though AppendMenuW
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2393 apparently does exist at least in some cases and appears to be
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2394 stubbed out to do nothing. out_string is UTF-8, but since
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2395 our standard menus are in English and this is only going to
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2396 happen the first time a menu is used, the encoding is
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2397 of minor importance compared with menus not working at all. */
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2398 return_value =
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2399 AppendMenu (menu, fuFlags,
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2400 item != NULL ? (UINT) item: (UINT) wv->call_data,
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2401 out_string);
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2402 /* Don't use unicode menus in future. */
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2403 unicode_append_menu = NULL;
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2404 }
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2405
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
2406 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW))
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2407 local_free (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2408 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2409 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2410 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2411 return_value =
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2412 AppendMenu (menu,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2413 fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2414 item != NULL ? (UINT) item : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2415 out_string );
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2416 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2417
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2418 /* This must be done after the menu item is created. */
41108
ef7a153a2c68 (add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
2419 if (!wv->title && wv->call_data != 0)
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2420 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2421 if (set_menu_item_info)
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2422 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2423 MENUITEMINFO info;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2424 bzero (&info, sizeof (info));
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2425 info.cbSize = sizeof (info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2426 info.fMask = MIIM_DATA;
32671
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
2427
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2428 /* Set help string for menu item. Leave it as a Lisp_Object
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2429 until it is ready to be displayed, since GC can happen while
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2430 menus are active. */
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2431 if (!NILP (wv->help))
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2432 #ifdef USE_LISP_UNION_TYPE
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2433 info.dwItemData = (DWORD) (wv->help).i;
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2434 #else
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2435 info.dwItemData = (DWORD) (wv->help);
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2436 #endif
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2437 if (wv->button_type == BUTTON_TYPE_RADIO)
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2438 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2439 /* CheckMenuRadioItem allows us to differentiate TOGGLE and
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2440 RADIO items, but is not available on NT 3.51 and earlier. */
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2441 info.fMask |= MIIM_TYPE | MIIM_STATE;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2442 info.fType = MFT_RADIOCHECK | MFT_STRING;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2443 info.dwTypeData = out_string;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2444 info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2445 }
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2446
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2447 set_menu_item_info (menu,
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2448 item != NULL ? (UINT) item : (UINT) wv->call_data,
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2449 FALSE, &info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2450 }
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2451 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2452 return return_value;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2453 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2454
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2455 /* Construct native Windows menu(bar) based on widget_value tree. */
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
2456 int
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2457 fill_in_menu (HMENU menu, widget_value *wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2458 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2459 int items_added = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2460
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2461 for ( ; wv != NULL; wv = wv->next)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2462 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2463 if (wv->contents)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2464 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2465 HMENU sub_menu = CreatePopupMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2466
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2467 if (sub_menu == NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2468 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2469
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2470 if (!fill_in_menu (sub_menu, wv->contents) ||
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2471 !add_menu_item (menu, wv, sub_menu))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2472 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2473 DestroyMenu (sub_menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2474 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2475 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2476 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2477 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2478 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2479 if (!add_menu_item (menu, wv, NULL))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2480 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2481 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2482 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2483 return 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2484 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2485
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2486 /* Display help string for currently pointed to menu item. Not
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2487 supported on NT 3.51 and earlier, as GetMenuItemInfo is not
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2488 available. */
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2489 void
41646
258fa72efab7 (w32_menu_display_help): Actually add the new argument
Andrew Innes <andrewi@gnu.org>
parents: 41637
diff changeset
2490 w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2491 {
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2492 if (get_menu_item_info)
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2493 {
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2494 struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2495 Lisp_Object frame, help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2496
64632
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
2497 /* No help echo on owner-draw menu items, or when the keyboard is used
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
2498 to navigate the menus, since tooltips are distracting if they pop
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
2499 up elsewhere. */
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
2500 if (flags & MF_OWNERDRAW || flags & MF_POPUP
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
2501 || !(flags & MF_MOUSESELECT))
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2502 help = Qnil;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2503 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2504 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2505 MENUITEMINFO info;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2506
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2507 bzero (&info, sizeof (info));
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2508 info.cbSize = sizeof (info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2509 info.fMask = MIIM_DATA;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2510 get_menu_item_info (menu, item, FALSE, &info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2511
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2512 #ifdef USE_LISP_UNION_TYPE
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2513 help = info.dwItemData ? (Lisp_Object) ((EMACS_INT) info.dwItemData)
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2514 : Qnil;
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2515 #else
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2516 help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2517 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2518 }
30989
2152817050ff (keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents: 30238
diff changeset
2519
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2520 /* Store the help echo in the keyboard buffer as the X toolkit
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2521 version does, rather than directly showing it. This seems to
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2522 solve the GC problems that were present when we based the
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2523 Windows code on the non-toolkit version. */
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2524 if (f)
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2525 {
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2526 XSETFRAME (frame, f);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2527 kbd_buffer_store_help_event (frame, help);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2528 }
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2529 else
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2530 /* X version has a loop through frames here, which doesn't
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2531 appear to do anything, unless it has some side effect. */
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2532 show_help_echo (help, Qnil, Qnil, Qnil, 1);
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2533 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2534 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2535
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2536 /* Free memory used by owner-drawn strings. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2537 static void
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2538 w32_free_submenu_strings (menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2539 HMENU menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2540 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2541 int i, num = GetMenuItemCount (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2542 for (i = 0; i < num; i++)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2543 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2544 MENUITEMINFO info;
41930
d5fc57bcb0f2 (w32_free_submenu_strings): Clear menu item struct
Jason Rumney <jasonr@gnu.org>
parents: 41908
diff changeset
2545 bzero (&info, sizeof (info));
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2546 info.cbSize = sizeof (info);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2547 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2548
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2549 get_menu_item_info (menu, i, TRUE, &info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2550
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2551 /* Owner-drawn names are held in dwItemData. */
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2552 if ((info.fType & MF_OWNERDRAW) && info.dwItemData)
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2553 {
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2554 #ifdef MENU_DEBUG
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2555 DebPrint ("Menu: freeing %ld for owner-draw", info.dwItemData);
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2556 #endif
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2557 local_free (info.dwItemData);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2558 }
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2559
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2560 /* Recurse down submenus. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2561 if (info.hSubMenu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2562 w32_free_submenu_strings (info.hSubMenu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2563 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2564 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2565
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2566 void
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2567 w32_free_menu_strings (hwnd)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2568 HWND hwnd;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2569 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2570 HMENU menu = current_popup_menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2571
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2572 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2573 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2574 /* If there is no popup menu active, free the strings from the frame's
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2575 menubar. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2576 if (!menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2577 menu = GetMenu (hwnd);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2578
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2579 if (menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2580 w32_free_submenu_strings (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2581 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2582
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2583 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2584 }
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2585
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2586 #endif /* HAVE_MENUS */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2587
73788
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2588 /* The following is used by delayed window autoselection. */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2589
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2590 DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2591 doc: /* Return t if a menu or popup dialog is active on selected frame. */)
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2592 ()
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2593 {
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2594 #ifdef HAVE_MENUS
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2595 FRAME_PTR f;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2596 f = SELECTED_FRAME ();
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2597 return (f->output_data.w32->menubar_active > 0) ? Qt : Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2598 #else
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2599 return Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2600 #endif /* HAVE_MENUS */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2601 }
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
2602
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
2603 void syms_of_w32menu ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2604 {
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2605 globals_of_w32menu ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2606 staticpro (&menu_items);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2607 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2608
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2609 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2610
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2611 Qdebug_on_next_call = intern ("debug-on-next-call");
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2612 staticpro (&Qdebug_on_next_call);
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2613
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2614 defsubr (&Sx_popup_menu);
73695
3901ff3eaf2c (Fmenu_or_popup_active_p): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 72773
diff changeset
2615 defsubr (&Smenu_or_popup_active_p);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2616 #ifdef HAVE_MENUS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2617 defsubr (&Sx_popup_dialog);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2618 #endif
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2619 }
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2620
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2621 /*
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2622 globals_of_w32menu is used to initialize those global variables that
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2623 must always be initialized on startup even when the global variable
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2624 initialized is non zero (see the function main in emacs.c).
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2625 globals_of_w32menu is called from syms_of_w32menu when the global
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2626 variable initialized is 0 and directly from main when initialized
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2627 is non zero.
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2628 */
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2629 void globals_of_w32menu ()
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2630 {
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2631 /* See if Get/SetMenuItemInfo functions are available. */
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2632 HMODULE user32 = GetModuleHandle ("user32.dll");
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2633 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2634 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2635 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
2636 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2637
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2638 /* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2639 (do not change this comment) */