annotate src/w32menu.c @ 56897:1fa5ffcb2ac8

(_widget_value): Added lname and lkey. (digest_single_submenu): Set lname and lkey in widget_value instead of name and key. (update_submenu_strings): New function. (set_frame_menubar): Remove call to inhibit_garbage_collection, call update_submenu_strings. (globals_of_w32menu): Check for Unicode API. (digest_single_submenu, w32_menu_show): Encode menu strings as UTF-8 if Unicode API is available. (utf8to16): New function. (add_menu_item): Use it when calling Unicode API.
author Jason Rumney <jasonr@gnu.org>
date Thu, 02 Sep 2004 23:22:58 +0000
parents 6817f9469688
children 357d9738b63e 3219f94257bc
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.
51573
861a49cd70cf (menubar_selection_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51206
diff changeset
2 Copyright (C) 1986,88,93,94,96,98,1999,2003 Free Software Foundation, Inc.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4 This file is part of GNU Emacs.
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 GNU Emacs is free software; you can redistribute it and/or modify
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 any later version.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
10
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
19 Boston, MA 02111-1307, USA. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
20
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
21 #include <config.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
22 #include <signal.h>
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
23
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
24 #include <stdio.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
25 #include "lisp.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
26 #include "termhooks.h"
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
27 #include "keyboard.h"
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
28 #include "keymap.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
29 #include "frame.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
30 #include "window.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
31 #include "blockinput.h"
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
32 #include "buffer.h"
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
33 #include "charset.h"
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
34 #include "coding.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
35
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
36 /* This may include sys/types.h, and that somehow loses
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
37 if this is not done before the other system files. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
38 #include "w32term.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
39
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
40 /* Load sys/types.h if not already loaded.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
41 In some systems loading it twice is suicidal. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
42 #ifndef makedev
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
43 #include <sys/types.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
44 #endif
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
45
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
46 #include "dispextern.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
47
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
48 #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
49
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
50 /******************************************************************/
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
51 /* 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
52
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
53 typedef void * XtPointer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
54 typedef char Boolean;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
55
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
56 enum button_type
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
57 {
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
58 BUTTON_TYPE_NONE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
59 BUTTON_TYPE_TOGGLE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
60 BUTTON_TYPE_RADIO
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
61 };
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
62
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
63 /* 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
64 for Windows. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
65 typedef struct _widget_value
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
66 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
67 /* name of widget */
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
68 Lisp_Object lname;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
69 char* name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
70 /* 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
71 char* value;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
72 /* keyboard equivalent. no implications for XtTranslations */
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
73 Lisp_Object lkey;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
74 char* key;
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
75 /* 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
76 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
77 or through menu_items. */
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
78 Lisp_Object help;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
79 /* true if enabled */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
80 Boolean enabled;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
81 /* true if selected */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
82 Boolean selected;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
83 /* The type of a button. */
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
84 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
85 /* true if menu title */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
86 Boolean title;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
87 #if 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
88 /* 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
89 Boolean edited;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
90 /* 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
91 change_type change;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
92 /* 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
93 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
94 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
95 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
96 /* 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
97 struct _widget_value* contents;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
98 /* data passed to callback */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
99 XtPointer call_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
100 /* 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
101 struct _widget_value* next;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
102 #if 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
103 /* 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
104 void* toolkit_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
105 /* 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
106 widget_value itself. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
107 Boolean free_toolkit_data;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
108
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
109 /* 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
110 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
111 */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
112 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
113 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
114 } widget_value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
115
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
116 /* Local memory management */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
117 #define local_heap (GetProcessHeap ())
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
118 #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
119 #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
120
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
121 #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
122 #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
123
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
124 /******************************************************************/
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
125
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
126 #ifndef TRUE
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
127 #define TRUE 1
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
128 #define FALSE 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
129 #endif /* no TRUE */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
130
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
131 static HMENU current_popup_menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
132
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
133 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
134 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
135
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 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
137 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
138 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
139 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
140 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
141 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
142 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
143 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
144 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
145 IN LPCMENUITEMINFOA);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
146 typedef BOOL (WINAPI * AppendMenuW_Proc) (
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
147 IN HMENU,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
148 IN UINT,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
149 IN UINT_PTR,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
150 IN LPCWSTR);
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
151
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
152 GetMenuItemInfoA_Proc get_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
153 SetMenuItemInfoA_Proc set_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
154 AppendMenuW_Proc unicode_append_menu = NULL;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
155
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
156 Lisp_Object Vmenu_updating_frame;
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
157
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
158 Lisp_Object Qdebug_on_next_call;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
159
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
160 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
161
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
162 extern Lisp_Object QCtoggle, QCradio;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
163
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
164 extern Lisp_Object Voverriding_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
165 extern Lisp_Object Voverriding_local_map_menu_flag;
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 Qoverriding_local_map, Qoverriding_terminal_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
168
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
169 extern Lisp_Object Qmenu_bar_update_hook;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
170
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
171 void set_frame_menubar ();
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
172
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
173 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
174 Lisp_Object, Lisp_Object, Lisp_Object,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
175 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
176 #ifdef HAVE_DIALOGS
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
177 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
178 #endif
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
179 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
180
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
181 static void keymap_panes ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
182 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
183 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
184 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
185 static void list_of_items ();
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
186 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
187
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
188 /* 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
189 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
190
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
191 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
192
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
193 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
194 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
195 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
196 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
197 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
198
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
199 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
200 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
201 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
202 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
203
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
204 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
205 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
206
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
207 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
208 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
209
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_NAME 1
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
211 #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
212 #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
213
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
214 enum menu_item_idx
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
215 {
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
216 MENU_ITEMS_ITEM_NAME = 0,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
217 MENU_ITEMS_ITEM_ENABLE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
218 MENU_ITEMS_ITEM_VALUE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
219 MENU_ITEMS_ITEM_EQUIV_KEY,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
220 MENU_ITEMS_ITEM_DEFINITION,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
221 MENU_ITEMS_ITEM_TYPE,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
222 MENU_ITEMS_ITEM_SELECTED,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
223 MENU_ITEMS_ITEM_HELP,
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
224 MENU_ITEMS_ITEM_LENGTH
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
225 };
21741
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 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
228
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
229 /* 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
230 static int menu_items_allocated;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
231
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
232 /* 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
233 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
234
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
235 /* 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
236 excluding those within submenus. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
237 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
238
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
239 /* Current depth within submenus. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
240 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
241
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
242 /* Flag which when set indicates a dialog or menu has been posted by
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
243 Xt on behalf of one of the widget sets. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
244 static int popup_activated_flag;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
245
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
246 static int next_menubar_widget_id;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
247
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
248 /* 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
249 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
250 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
251
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
252 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
253 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
254
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
255 int pending_menu_activation;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
256
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
257
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
258 /* 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
259 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
260
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
261 static struct frame *
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
262 menubar_id_to_frame (id)
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
263 HMENU id;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
264 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
265 Lisp_Object tail, frame;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
266 FRAME_PTR f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
267
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
268 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
269 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
270 frame = XCAR (tail);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
271 if (!GC_FRAMEP (frame))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
272 continue;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
273 f = XFRAME (frame);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
274 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
275 continue;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
276 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
277 return f;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
278 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
279 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
280 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
281
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
282 /* Initialize the menu_items structure if we haven't already done so.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
283 Also mark it as currently empty. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
284
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
285 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
286 init_menu_items ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
287 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
288 if (NILP (menu_items))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
289 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
290 menu_items_allocated = 60;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
291 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
292 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
293
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
294 menu_items_used = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
295 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
296 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
297 }
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 /* 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
300 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
301
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
302 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
303 finish_menu_items ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
304 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
305 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
306
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
307 /* 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
308 in menu_items. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
309
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
310 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
311 discard_menu_items ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
312 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
313 /* 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
314 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
315 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
316 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
317 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
318 menu_items_allocated = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
319 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
320 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
321
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
322 /* Make the menu_items vector twice as large. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
323
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
324 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
325 grow_menu_items ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
326 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
327 Lisp_Object old;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
328 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
329 old = menu_items;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
330
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
331 menu_items_allocated *= 2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
332 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
333 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
334 old_size * sizeof (Lisp_Object));
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
335 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
336
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
337 /* Begin a submenu. */
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
338
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
339 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
340 push_submenu_start ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
341 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
342 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
343 grow_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
344
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
345 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
346 menu_items_submenu_depth++;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
347 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
348
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
349 /* End a submenu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
350
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
351 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
352 push_submenu_end ()
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
353 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
354 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
355 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
356
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
357 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
358 menu_items_submenu_depth--;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
359 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
360
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
361 /* Indicate boundary between left and right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
362
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
363 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
364 push_left_right_boundary ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
365 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
366 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
367 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
368
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
369 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
370 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
371
41251
e6612d08452f (w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 41108
diff changeset
372 /* 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
373 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
374
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
375 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
376 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
377 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
378 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
379 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
380 grow_menu_items ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
381
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
382 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
383 menu_items_n_panes++;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
384 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
385 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
386 ASET (menu_items, menu_items_used++, prefix_vec);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
387 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
388
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
389 /* 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
390 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
391 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
392 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
393 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
394 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
395 item, one of nil, `toggle' or `radio'. */
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
396
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
397 static void
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
398 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
399 Lisp_Object name, enable, key, def, equiv, type, selected, help;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
400 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
401 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
402 grow_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
403
46815
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++, name);
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++, enable);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
406 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
407 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
408 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
409 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
410 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
411 ASET (menu_items, menu_items_used++, help);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
412 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
413
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
414 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
415 and generate menu panes for them in menu_items.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
416 If NOTREAL is nonzero,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
417 don't bother really computing whether an item is enabled. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
418
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
419 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
420 keymap_panes (keymaps, nmaps, notreal)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
421 Lisp_Object *keymaps;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
422 int nmaps;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
423 int notreal;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
424 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
425 int mapno;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
426
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
427 init_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
428
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
429 /* 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
430 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
431 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
432 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
433 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
434 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
435
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
436 finish_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
437 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
438
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
439 /* This is a recursive subroutine of keymap_panes.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
440 It handles one keymap, KEYMAP.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
441 The other arguments are passed along
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
442 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
443 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
444 evaluate expressions in menu items and don't make any menu.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
445
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
446 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
447
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
448 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
449 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
450 Lisp_Object keymap;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
451 Lisp_Object pane_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
452 Lisp_Object prefix;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
453 int notreal;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
454 int maxdepth;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
455 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
456 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
457 Lisp_Object tail, item;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
458 struct gcpro gcpro1, gcpro2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
459
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
460 if (maxdepth <= 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
461 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
462
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
463 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
464
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
465 for (tail = keymap; CONSP (tail); tail = XCDR (tail))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
466 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
467 GCPRO2 (keymap, pending_maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
468 /* 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
469 to this menu. */
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
470 item = XCAR (tail);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
471 if (CONSP (item))
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
472 single_menu_item (XCAR (item), XCDR (item),
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
473 &pending_maps, notreal, maxdepth);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
474 else if (VECTORP (item))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
475 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
476 /* 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
477 int len = ASIZE (item);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
478 int c;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
479 for (c = 0; c < len; c++)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
480 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
481 Lisp_Object character;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
482 XSETFASTINT (character, c);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
483 single_menu_item (character, AREF (item, c),
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
484 &pending_maps, notreal, maxdepth);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
485 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
486 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
487 UNGCPRO;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
488 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
489
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
490 /* Process now any submenus which want to be panes at this level. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
491 while (!NILP (pending_maps))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
492 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
493 Lisp_Object elt, eltcdr, string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
494 elt = Fcar (pending_maps);
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
495 eltcdr = XCDR (elt);
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
496 string = XCAR (eltcdr);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
497 /* 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
498 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
499 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
500 XCDR (eltcdr), notreal, maxdepth - 1);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
501 pending_maps = Fcdr (pending_maps);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
502 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
503 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
504
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
505 /* 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
506 keymap entry.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
507 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
508 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
509 separate panes.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
510 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
511 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
512 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
513
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
514 static void
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
515 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
516 Lisp_Object key, item;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
517 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
518 int maxdepth, notreal;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
519 {
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
520 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
521 struct gcpro gcpro1, gcpro2;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
522 int res;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
523
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
524 /* 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
525 GCPRO2 (key, item);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
526 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
527 UNGCPRO;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
528 if (!res)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
529 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
530
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
531 map = AREF (item_properties, ITEM_PROPERTY_MAP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
532
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
533 if (notreal)
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 /* 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
536 precompute equivalent key bindings. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
537 if (!NILP (map))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
538 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
539 return;
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
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
542 enabled = AREF (item_properties, ITEM_PROPERTY_ENABLE);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
543 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
544
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
545 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
546 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
547 if (!NILP (enabled))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
548 /* 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
549 *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
550 *pending_maps_ptr);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
551 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
552 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
553
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
554 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
555 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
556 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
557 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
558 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
559 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
560
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
561 /* 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
562 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
563 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
564 push_submenu_start ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
565 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
566 push_submenu_end ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
567 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
568 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
569
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13434
diff changeset
570 /* 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
571 alist-of-alists MENU.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
572 This handles old-fashioned calls to x-popup-menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
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 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
575 list_of_panes (menu)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
576 Lisp_Object menu;
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 tail;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
579
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
580 init_menu_items ();
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
581
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
582 for (tail = menu; !NILP (tail); tail = Fcdr (tail))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
583 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
584 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
585 elt = Fcar (tail);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
586 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
587 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
588 push_menu_pane (pane_name, Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
589 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
590 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
591 list_of_items (pane_data);
13434
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
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
594 finish_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
595 }
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 /* Push the items in a single pane defined by the alist PANE. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
598
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
599 static void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
600 list_of_items (pane)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
601 Lisp_Object pane;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
602 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
603 Lisp_Object tail, item, item1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
604
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
605 for (tail = pane; !NILP (tail); tail = Fcdr (tail))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
606 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
607 item = Fcar (tail);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
608 if (STRINGP (item))
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
609 push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
610 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
611 push_left_right_boundary ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
612 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
613 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
614 CHECK_CONS (item);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
615 item1 = Fcar (item);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
616 CHECK_STRING (item1);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
617 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
618 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
619 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
620 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
621
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
622 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
623 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
624 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
625 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
626 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
627 \(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
628 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
629 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
630 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
631
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
632 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
633 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
634 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
635 \(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
636 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
637
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
638 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
639 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
640
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
641 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
642 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
643 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
644
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
645 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
646 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
647 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
648 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
649 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
650 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
651
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
652 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
653 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
654 (position, menu)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
655 Lisp_Object position, menu;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
656 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
657 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
658 int xpos = 0, ypos = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
659 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
660 char *error_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
661 Lisp_Object selection;
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
662 FRAME_PTR f = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
663 Lisp_Object x, y, window;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
664 int keymaps = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
665 int for_click = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
666 struct gcpro gcpro1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
667
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
668 #ifdef HAVE_MENUS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
669 if (! NILP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
670 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
671 check_w32 ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
672
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
673 /* 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
674 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
675 || (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
676 || EQ (XCAR (position), Qtool_bar))))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
677 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
678 /* 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
679 FRAME_PTR new_f = SELECTED_FRAME ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
680 Lisp_Object bar_window;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
681 enum scroll_bar_part part;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
682 unsigned long time;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
683
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
684 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
685 (*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
686 &part, &x, &y, &time);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
687 if (new_f != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
688 XSETFRAME (window, new_f);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
689 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
690 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
691 window = selected_window;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
692 XSETFASTINT (x, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
693 XSETFASTINT (y, 0);
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 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
696 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
697 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
698 tem = Fcar (position);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
699 if (CONSP (tem))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
700 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
701 window = Fcar (Fcdr (position));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
702 x = Fcar (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
703 y = Fcar (Fcdr (tem));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
704 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
705 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
706 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
707 for_click = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
708 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
709 window = Fcar (tem); /* POSN_WINDOW (tem) */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
710 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
711 x = Fcar (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
712 y = Fcdr (tem);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
713 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
714 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
715
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
716 CHECK_NUMBER (x);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
717 CHECK_NUMBER (y);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
718
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
719 /* 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
720
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
721 if (FRAMEP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
722 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
723 f = XFRAME (window);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
724 xpos = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
725 ypos = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
726 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
727 else if (WINDOWP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
728 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
729 CHECK_LIVE_WINDOW (window);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
730 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
731
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
732 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
733 ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
734 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
735 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
736 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
737 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
738 CHECK_WINDOW (window);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
739
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
740 xpos += XINT (x);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
741 ypos += XINT (y);
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
742
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
743 XSETFRAME (Vmenu_updating_frame, f);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
744 }
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
745 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
746 #endif /* HAVE_MENUS */
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
747
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
748 title = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
749 GCPRO1 (title);
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 /* 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
752
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
753 keymap = get_keymap (menu, 0, 0);
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
754 if (CONSP (keymap))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
755 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
756 /* 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
757 Lisp_Object prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
758
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
759 /* 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
760 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
761
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
762 /* 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
763 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
764 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
765 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
766 title = prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
767
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
768 /* 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
769 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
770 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
771
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
772 keymaps = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
773 }
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
774 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
775 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
776 /* 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
777 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
778 Lisp_Object *maps
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
779 = (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
780 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
781
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
782 title = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
783
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
784 /* 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
785 supplies the menu title. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
786 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
787 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
788 Lisp_Object prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
789
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
790 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
791
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
792 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
793 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
794 title = prompt;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
795 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
796
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
797 /* 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
798 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
799
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
800 /* 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
801 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
802 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
803
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
804 keymaps = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
805 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
806 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
807 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
808 /* 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
809 title = Fcar (menu);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
810 CHECK_STRING (title);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
811
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
812 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
813
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
814 keymaps = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
815 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
816
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
817 if (NILP (position))
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 discard_menu_items ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
820 UNGCPRO;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
821 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
822 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
823
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
824 #ifdef HAVE_MENUS
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
825 /* If resources from a previous popup menu exist yet, does nothing
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
826 until the `menu_free_timer' has freed them (see w32fns.c).
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 if (current_popup_menu)
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
829 {
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
830 discard_menu_items ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
831 UNGCPRO;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
832 return Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
833 }
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
834
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
835 /* Display them in a menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
836 BLOCK_INPUT;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
837
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
838 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
839 keymaps, title, &error_name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
840 UNBLOCK_INPUT;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
841
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
842 discard_menu_items ();
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
843 #endif /* HAVE_MENUS */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
844
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
845 UNGCPRO;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
846
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
847 if (error_name) error (error_name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
848 return selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
849 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
850
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
851 #ifdef HAVE_MENUS
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
852
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
853 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
854 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
855 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
856 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
857 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
858 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
859
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
860 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
861 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
862 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
863 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
864
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
865 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
866 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
867 on the left of the dialog box and all following items on the right.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
868 \(By default, approximately half appear on each side.) */)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
869 (position, contents)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
870 Lisp_Object position, contents;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
871 {
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
872 FRAME_PTR f = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
873 Lisp_Object window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
874
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
875 check_w32 ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
876
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
877 /* 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
878 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
879 || (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
880 || EQ (XCAR (position), Qtool_bar))))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
881 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
882 #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
883 /* 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
884 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
885 Lisp_Object bar_window;
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
886 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
887 unsigned long time;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
888 Lisp_Object x, y;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
889
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
890 (*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
891
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
892 if (new_f != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
893 XSETFRAME (window, new_f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
894 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
895 window = selected_window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
896 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
897 window = selected_window;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
898 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
899 else if (CONSP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
900 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
901 Lisp_Object tem;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
902 tem = Fcar (position);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
903 if (CONSP (tem))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
904 window = Fcar (Fcdr (position));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
905 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
906 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
907 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
908 window = Fcar (tem); /* POSN_WINDOW (tem) */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
909 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
910 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
911 else if (WINDOWP (position) || FRAMEP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
912 window = position;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
913 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
914 window = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
915
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
916 /* 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
917
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
918 if (FRAMEP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
919 f = XFRAME (window);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
920 else if (WINDOWP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
921 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
922 CHECK_LIVE_WINDOW (window);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
923 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
924 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
925 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
926 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
927 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
928 CHECK_WINDOW (window);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
929
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
930 #ifndef HAVE_DIALOGS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
931 /* Display a menu with these alternatives
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
932 in the middle of frame F. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
933 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
934 Lisp_Object x, y, frame, newpos;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
935 XSETFRAME (frame, f);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
936 XSETINT (x, x_pixel_width (f) / 2);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
937 XSETINT (y, x_pixel_height (f) / 2);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
938 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
939
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
940 return Fx_popup_menu (newpos,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
941 Fcons (Fcar (contents), Fcons (contents, Qnil)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
942 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
943 #else /* HAVE_DIALOGS */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
944 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
945 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
946 char *error_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
947 Lisp_Object selection;
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 /* Decode the dialog items from what was specified. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
950 title = Fcar (contents);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
951 CHECK_STRING (title);
13434
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 list_of_panes (Fcons (contents, Qnil));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
954
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
955 /* Display them in a dialog box. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
956 BLOCK_INPUT;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
957 selection = w32_dialog_show (f, 0, title, &error_name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
958 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
959
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
960 discard_menu_items ();
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
961
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
962 if (error_name) error (error_name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
963 return selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
964 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
965 #endif /* HAVE_DIALOGS */
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
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
968 /* Activate the menu bar of frame F.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
969 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
970 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
971
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
972 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
973 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
974 processing of the menus.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
975
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
976 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
977
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
978 This way we can safely execute Lisp code. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
979
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
980 void
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
981 x_activate_menubar (f)
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
982 FRAME_PTR f;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
983 {
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
984 set_frame_menubar (f, 0, 1);
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
985
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
986 /* Lock out further menubar changes while active. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
987 f->output_data.w32->menubar_active = 1;
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 /* Signal input thread to return from WM_INITMENU. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
990 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
991 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
992
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
993 /* 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
994 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
995 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
996 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
997
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
998 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
999 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
1000 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1001 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1002 Lisp_Object vector;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1003 Lisp_Object *subprefix_stack;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1004 int submenu_depth = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1005 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1006
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1007 if (!f)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1008 return;
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1009 entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1010 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
1011 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
1012 prefix = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1013 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1014 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
1015 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1016 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
1017 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1018 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
1019 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1020 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1021 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1022 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
1023 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1024 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
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), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1028 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1029 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
1030 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
1031 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1032 else
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 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
1035 /* 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
1036 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
1037 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
1038 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1039 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1040 struct input_event buf;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1041 Lisp_Object frame;
51573
861a49cd70cf (menubar_selection_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51206
diff changeset
1042 EVENT_INIT (buf);
21741
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 XSETFRAME (frame, f);
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1045 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1046 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1047 buf.arg = frame;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1048 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
1049
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1050 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
1051 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
1052 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1053 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1054 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1055 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
1056 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
1057 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1058
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1059 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1060 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1061 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1062 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1063 buf.arg = prefix;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1064 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
1065 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1066
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1067 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1068 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
1069 buf.arg = entry;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1070 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
1071
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1072 /* 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
1073 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
1074 f->output_data.w32->menu_command_in_progress = 0;
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1075 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
1076 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1077 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1078 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
1079 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1080 }
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1081 /* 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
1082 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
1083 f->output_data.w32->menu_command_in_progress = 0;
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
1084 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
1085 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1086
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1087 /* 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
1088
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1089 widget_value *
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1090 xmalloc_widget_value ()
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 *value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1093
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1094 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1095 value = malloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1096 UNBLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1097
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1098 return value;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1099 }
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 /* 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
1102 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
1103 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
1104 must be left alone. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1105
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1106 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1107 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
1108 widget_value *wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1109 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1110 if (! wv) return;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1111
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1112 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
1113
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1114 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
1115 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1116 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
1117 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
1118 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1119 if (wv->next)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1120 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1121 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
1122 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
1123 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1124 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1125 free_widget_value (wv);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1126 UNBLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1127 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1128
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1129 /* 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
1130 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
1131 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
1132
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1133 static int
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1134 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
1135 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
1136 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1137 Lisp_Object length;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1138 int len;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1139 Lisp_Object *mapvec;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1140 int i;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1141 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
1142
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1143 length = Flength (maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1144 len = XINT (length);
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 /* 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
1147 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
1148 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
1149 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1150 mapvec[i] = Fcar (maps);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1151 maps = Fcdr (maps);
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
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1154 /* 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
1155 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
1156 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
1157 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1158 if (SYMBOLP (mapvec[i])
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1159 || (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
1160 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1161 /* 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
1162 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
1163 top_level_items = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1164 push_menu_pane (Qnil, Qnil);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1165 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
1166 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
1167 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1168 else
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1169 {
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1170 Lisp_Object prompt;
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1171 prompt = Fkeymap_prompt (mapvec[i]);
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1172 single_keymap_panes (mapvec[i],
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1173 !NILP (prompt) ? prompt : item_name,
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1174 item_key, 0, 10);
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1175 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1176 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1177
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1178 return top_level_items;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1179 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1180
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1181
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1182 /* 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
1183 representing the panes and items
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1184 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
1185
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1186 static widget_value *
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1187 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
1188 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
1189 {
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1190 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
1191 int i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1192 int submenu_depth = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1193 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
1194
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1195 submenu_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1196 = (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
1197 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1198 wv->name = "menu";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1199 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1200 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1201 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1202 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1203 first_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1204 save_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1205 prev_wv = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1206
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1207 /* 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
1208 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
1209 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
1210 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
1211 i = start;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1212 while (i < end)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1213 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1214 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
1215 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1216 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
1217 save_wv = prev_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1218 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1219 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1220 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1221 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
1222 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1223 prev_wv = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1224 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
1225 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1226 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1227 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
1228 && submenu_depth != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1229 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
1230 /* 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
1231 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
1232 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
1233 i += 1;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1234 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
1235 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1236 /* Create a new pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1237 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
1238 char *pane_string;
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1239
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1240 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
1241 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
1242
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1243 if (STRINGP (pane_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1244 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1245 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1246 /* Encode as UTF-8 for now. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1247 pane_name = ENCODE_UTF_8 (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1248 else if (STRING_MULTIBYTE (pane_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1249 pane_name = ENCODE_SYSTEM (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1250
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1251 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
1252 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1253
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1254 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
1255 ? "" : (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
1256 /* 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
1257 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
1258 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
1259 pane_string = "";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1260
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1261 /* 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
1262 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
1263 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
1264 if (strcmp (pane_string, ""))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1265 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1266 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1267 if (save_wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1268 save_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1269 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1270 first_wv->contents = wv;
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1271 wv->lname = pane_name;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1272 /* 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
1273 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
1274 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1275 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
1276 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1277 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1278 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1279 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1280 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
1281 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1282 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1283 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1284 /* 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
1285 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
1286 Lisp_Object help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1287
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1288 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
1289 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
1290 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
1291 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
1292 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
1293 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
1294 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
1295
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1296 if (STRINGP (item_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1297 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1298 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1299 item_name = ENCODE_UTF_8 (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1300 else if (STRING_MULTIBYTE (item_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1301 item_name = ENCODE_SYSTEM (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1302
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1303 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
1304 }
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1305
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1306 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
1307 {
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1308 descrip = ENCODE_SYSTEM (descrip);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1309 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
1310 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1311
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1312 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1313 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1314 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1315 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1316 save_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1317
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1318 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
1319 if (!NILP (descrip))
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1320 wv->lkey = descrip;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1321 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1322 /* 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
1323 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
1324 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
1325 wv->enabled = !NILP (enable);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1326
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1327 if (NILP (type))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1328 wv->button_type = BUTTON_TYPE_NONE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1329 else if (EQ (type, QCradio))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1330 wv->button_type = BUTTON_TYPE_RADIO;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1331 else if (EQ (type, QCtoggle))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1332 wv->button_type = BUTTON_TYPE_TOGGLE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1333 else
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1334 abort ();
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1335
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1336 wv->selected = !NILP (selected);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1337 if (!STRINGP (help))
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1338 help = Qnil;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1339
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1340 wv->help = help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1341
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1342 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1343
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1344 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
1345 }
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
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1348 /* 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
1349 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
1350 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
1351 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1352 wv = first_wv->contents;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1353 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
1354 return wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1355 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1356
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1357 return first_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1358 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1359
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1360
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1361 /* 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
1362 the char * pointers from the corresponding lisp values.
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1363 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
1364 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
1365 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
1366 static void
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1367 update_submenu_strings (first_wv)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1368 widget_value *first_wv;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1369 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1370 widget_value *wv;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1371
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1372 for (wv = first_wv; wv; wv = wv->next)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1373 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1374 if (wv->lname && ! NILP (wv->lname))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1375 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1376 wv->name = SDATA (wv->lname);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1377
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1378 /* Ignore the @ that means "separate pane".
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1379 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
1380 if (wv->value == (char *)1)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1381 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1382 if (wv->name[0] == '@')
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1383 wv->name++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1384 wv->value = 0;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1385 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1386 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1387
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1388 if (wv->lkey && ! NILP (wv->lkey))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1389 wv->key = SDATA (wv->lkey);
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->contents)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1392 update_submenu_strings (wv->contents);
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 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1395
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1396
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1397 /* 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
1398 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
1399 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
1400
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1401 void
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1402 set_frame_menubar (f, first_time, deep_p)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1403 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1404 int first_time;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1405 int deep_p;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1406 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1407 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
1408 Lisp_Object items;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1409 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
1410 int i, last_i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1411 int *submenu_start, *submenu_end;
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1412 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
1413
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1414 /* 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
1415 if (f->output_data.w32->menubar_active)
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1416 return;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1417
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1418 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
1419
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1420 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1421 deep_p = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1422 else if (pending_menu_activation && !deep_p)
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1423 deep_p = 1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1424
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1425 if (deep_p)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1426 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1427 /* 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
1428
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1429 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
1430 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45803
diff changeset
1431 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
1432 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
1433 Lisp_Object *previous_items
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1434 = (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
1435 * sizeof (Lisp_Object));
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1436
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1437 /* 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
1438 do always reinitialize them. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1439 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1440 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
1441
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1442 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
1443 specbind (Qinhibit_quit, Qt);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1444 /* 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
1445 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
1446 specbind (Qdebug_on_next_call, Qnil);
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
1447
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1448 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1449 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
1450 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1451 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
1452 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
1453 }
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 set_buffer_internal_1 (XBUFFER (buffer));
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
1456
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1457 /* 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
1458 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
1459 /* 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
1460 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
1461 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
1462 call0 (Qrecompute_lucid_menubar);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1463 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
1464 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
1465
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1466 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
1467
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1468 /* 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
1469 if (previous_menu_items_used)
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1470 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
1471 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
1472
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1473 /* 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
1474 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
1475 menu_items = f->menu_bar_vector;
39507
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
1476 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
1477 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
1478 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
1479 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
1480 submenu_top_level_items
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1481 = (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
1482 init_menu_items ();
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1483 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
1484 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1485 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
1486
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1487 last_i = i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1488
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1489 key = AREF (items, i);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1490 string = AREF (items, i + 1);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1491 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
1492 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1493 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1494
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1495 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
1496
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1497 menu_items_n_panes = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1498 submenu_top_level_items[i]
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1499 = parse_single_submenu (key, string, maps);
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1500 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
1501
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1502 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
1503 }
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1504
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1505 finish_menu_items ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1506
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1507 /* 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
1508 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
1509
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1510 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1511 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1512 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1513 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1514 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
1515 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1516 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1517
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1518 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
1519 {
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
1520 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
1521 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
1522 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1523 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1524 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1525 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1526 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1527 /* 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
1528 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1529 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
1530 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1531 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1532
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1533 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
1534 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
1535
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1536 /* 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
1537 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
1538
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1539 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
1540 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
1541 || (!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
1542 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1543 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
1544 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1545 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
1546 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1547
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1548 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1549 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1550
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1551 /* 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
1552 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
1553 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
1554 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
1555 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
1556 wv = first_wv->contents;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1557 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
1558 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1559 Lisp_Object string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1560 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
1561 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1562 break;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1563 wv->name = (char *) SDATA (string);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1564 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
1565 wv = wv->next;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1566 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1567
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1568 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
1569 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
1570 menu_items = Qnil;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1571 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1572 else
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1573 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1574 /* 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
1575 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
1576
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1577 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1578 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1579 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1580 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1581 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
1582 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1583 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1584
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1585 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
1586 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
1587 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1588 Lisp_Object string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1589
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1590 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
1591 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1592 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1593
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1594 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
1595 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
1596 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1597 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1598 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
1599 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1600 /* 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
1601 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
1602 /* 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
1603 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
1604 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
1605
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1606 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1607 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1608 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1609 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1610 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1611 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1612
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1613 /* 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
1614 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
1615 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
1616 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
1617 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1618
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1619 /* 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
1620
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1621 BLOCK_INPUT;
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 if (menubar_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 /* 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
1626 while (DeleteMenu (menubar_widget, 0, MF_BYPOSITION))
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1627 ;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1628 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1629 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1630 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1631 menubar_widget = CreateMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1632 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1633 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
1634
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1635 free_menubar_widget_value_tree (first_wv);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1636
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1637 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1638 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
1639
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1640 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
1641 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
1642 /* Causes flicker when menu bar is updated
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1643 DrawMenuBar (FRAME_W32_WINDOW (f)); */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1644
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1645 /* 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
1646 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
1647 if (old_widget == NULL)
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1648 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
1649 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1650
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1651 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1652 }
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 /* 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
1655 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
1656 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
1657 is visible. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1658
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1659 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1660 initialize_frame_menubar (f)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1661 FRAME_PTR f;
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 /* 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
1664 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
1665 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
1666 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
1667 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1668
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1669 /* 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
1670 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
1671
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1672 void
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1673 free_frame_menubar (f)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1674 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1675 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1676 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1677
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1678 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1679 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
1680 SetMenu (FRAME_W32_WINDOW (f), NULL);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1681 f->output_data.w32->menubar_widget = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1682 DestroyMenu (old);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1683 }
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1684
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1685 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1686 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1687
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1688
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1689 /* 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
1690 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
1691 is blocked by the caller. */
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 /* 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
1694 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
1695 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
1696 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
1697 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
1698 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
1699 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
1700 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
1701 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
1702 (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
1703
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1704 static Lisp_Object
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1705 w32_menu_show (f, x, y, for_click, keymaps, title, error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1706 FRAME_PTR f;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1707 int x;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1708 int y;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1709 int for_click;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1710 int keymaps;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1711 Lisp_Object title;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1712 char **error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1713 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1714 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1715 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1716 HMENU menu;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1717 POINT pos;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1718 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
1719 widget_value **submenu_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1720 = (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
1721 Lisp_Object *subprefix_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1722 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1723 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
1724 int first_pane;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1725
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1726 *error = NULL;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1727
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1728 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1729 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1730 *error = "Empty menu";
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1731 return Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1732 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1733
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1734 /* 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
1735 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
1736 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1737 wv->name = "menu";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1738 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1739 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1740 wv->button_type = BUTTON_TYPE_NONE;
42613
a5eb47b53761 Fix typo in last checkin
Jason Rumney <jasonr@gnu.org>
parents: 42589
diff changeset
1741 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1742 first_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1743 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1744
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1745 /* Loop over all panes and items, filling in the tree. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1746 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1747 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1748 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1749 if (EQ (AREF (menu_items, i), Qnil))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1750 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1751 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
1752 save_wv = prev_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1753 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1754 first_pane = 1;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1755 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1756 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1757 else if (EQ (AREF (menu_items, i), Qlambda))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1758 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1759 prev_wv = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1760 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
1761 first_pane = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1762 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1763 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1764 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
1765 && submenu_depth != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1766 i += MENU_ITEMS_PANE_LENGTH;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1767 /* Ignore a nil in the item list.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1768 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
1769 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
1770 i += 1;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1771 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
1772 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1773 /* Create a new pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1774 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
1775 char *pane_string;
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1776 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
1777 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
1778
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1779 if (STRINGP (pane_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1780 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1781 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1782 pane_name = ENCODE_UTF_8 (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1783 else if (STRING_MULTIBYTE (pane_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1784 pane_name = ENCODE_SYSTEM (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1785
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1786 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
1787 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1788
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1789 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
1790 ? "" : (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
1791 /* 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
1792 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
1793 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
1794 pane_string = "";
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1795
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1796 /* 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
1797 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
1798 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
1799 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
1800 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1801 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1802 if (save_wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1803 save_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1804 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1805 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1806 wv->name = pane_string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1807 if (keymaps && !NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1808 wv->name++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1809 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1810 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1811 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
1812 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1813 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1814 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1815 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1816 else if (first_pane)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1817 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1818 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1819 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1820 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1821 first_pane = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1822 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
1823 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1824 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1825 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1826 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
1827 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
1828
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1829 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
1830 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
1831 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
1832 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
1833 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
1834 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
1835 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
1836
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1837 if (STRINGP (item_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1838 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1839 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1840 item_name = ENCODE_UTF_8 (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1841 else if (STRING_MULTIBYTE (item_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1842 item_name = ENCODE_SYSTEM (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1843
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1844 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
1845 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1846
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1847 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
1848 {
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
1849 descrip = ENCODE_SYSTEM (descrip);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1850 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
1851 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1852
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1853 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1854 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1855 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1856 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1857 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
1858 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
1859 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
1860 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
1861 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1862 /* 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
1863 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
1864 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
1865 wv->enabled = !NILP (enable);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1866
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1867 if (NILP (type))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1868 wv->button_type = BUTTON_TYPE_NONE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1869 else if (EQ (type, QCtoggle))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1870 wv->button_type = BUTTON_TYPE_TOGGLE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1871 else if (EQ (type, QCradio))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1872 wv->button_type = BUTTON_TYPE_RADIO;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1873 else
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1874 abort ();
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1875
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1876 wv->selected = !NILP (selected);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1877 if (!STRINGP (help))
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1878 help = Qnil;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1879
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1880 wv->help = help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1881
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1882 prev_wv = wv;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1883
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1884 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
1885 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1886 }
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 /* 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
1889 if (!NILP (title))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1890 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1891 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
1892 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
1893
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1894 /* 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
1895 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
1896 wv_sep->name = "--";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1897 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
1898 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
1899
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1900 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1901 title = ENCODE_UTF_8 (title);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1902 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
1903 title = ENCODE_SYSTEM (title);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1904
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1905 wv_title->name = (char *) SDATA (title);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1906 wv_title->enabled = TRUE;
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1907 wv_title->title = TRUE;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1908 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
1909 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
1910 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
1911 first_wv->contents = wv_title;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1912 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1913
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1914 /* Actually create the menu. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1915 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
1916 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
1917
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1918 /* Adjust coordinates to be root-window-relative. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1919 pos.x = x;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1920 pos.y = y;
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1921 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
1922
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1923 /* 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
1924 menu_item_selection = 0;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1925
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1926 /* Display the menu. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1927 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
1928 WM_EMACS_TRACKPOPUPMENU,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1929 (WPARAM)menu, (LPARAM)&pos);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1930
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1931 /* 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
1932 during the call. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1933 discard_mouse_events ();
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1934
30238
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
1935 /* 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
1936 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
1937
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1938 DestroyMenu (menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1939
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1940 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1941 the proper value. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1942 if (menu_item_selection != 0)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1943 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1944 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1945
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1946 prefix = entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1947 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1948 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
1949 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1950 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
1951 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1952 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
1953 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1954 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1955 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1956 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
1957 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1958 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
1959 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1960 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1961 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
1962 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1963 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
1964 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
1965 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1966 /* 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
1967 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
1968 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
1969 i += 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1970 else
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 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
1973 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
1974 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1975 if (keymaps != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1976 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1977 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1978
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1979 entry = Fcons (entry, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1980 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1981 entry = Fcons (prefix, entry);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1982 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
1983 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
1984 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
1985 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1986 return entry;
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 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
1989 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1990 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1991 }
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1992
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1993 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1994 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1995
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1996
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1997 #ifdef HAVE_DIALOGS
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1998 static char * button_names [] = {
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1999 "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
2000 "button6", "button7", "button8", "button9", "button10" };
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2001
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2002 static Lisp_Object
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2003 w32_dialog_show (f, keymaps, title, error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2004 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2005 int keymaps;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2006 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2007 char **error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2008 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2009 int i, nb_buttons=0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2010 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
2011 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2012
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2013 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
2014
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2015 /* Number of elements seen so far, before boundary. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2016 int left_count = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2017 /* 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
2018 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
2019
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2020 *error = NULL;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2021
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2022 if (menu_items_n_panes > 1)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2023 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2024 *error = "Multiple panes in dialog box";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2025 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2026 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2027
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2028 /* Create a tree of widget_value objects
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2029 representing the text label and buttons. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2030 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2031 Lisp_Object pane_name, prefix;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2032 char *pane_string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2033 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
2034 prefix = AREF (menu_items, MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2035 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2036 ? "" : (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
2037 prev_wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2038 prev_wv->value = pane_string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2039 if (keymaps && !NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2040 prev_wv->name++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2041 prev_wv->enabled = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2042 prev_wv->name = "message";
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2043 prev_wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2044 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2045
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2046 /* Loop over all panes and items, filling in the tree. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2047 i = MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2048 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2049 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2050
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2051 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
2052 Lisp_Object item_name, enable, descrip, help;
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
2053
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2054 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
2055 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
2056 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
2057 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2058
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2059 if (NILP (item_name))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2060 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2061 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2062 *error = "Submenu in dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2063 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2064 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2065 if (EQ (item_name, Qquote))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2066 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2067 /* This is the boundary between left-side elts
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2068 and right-side elts. Stop incrementing right_count. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2069 boundary_seen = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2070 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2071 continue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2072 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2073 if (nb_buttons >= 9)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2074 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2075 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2076 *error = "Too many dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2077 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2078 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2079
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2080 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2081 prev_wv->next = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2082 wv->name = (char *) button_names[nb_buttons];
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2083 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
2084 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
2085 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
2086 wv->call_data = (void *) &AREF (menu_items, i);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2087 wv->enabled = !NILP (enable);
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2088 wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2089 prev_wv = wv;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2090
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2091 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2092 left_count++;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2093
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2094 nb_buttons++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2095 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2096 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2097
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2098 /* If the boundary was not specified,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2099 by default put half on the left and half on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2100 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2101 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
2102
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2103 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2104 wv->name = dialog_name;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
2105 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2106
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2107 /* Dialog boxes use a really stupid name encoding
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2108 which specifies how many buttons to use
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2109 and how many buttons are on the right.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2110 The Q means something also. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2111 dialog_name[0] = 'Q';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2112 dialog_name[1] = '0' + nb_buttons;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2113 dialog_name[2] = 'B';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2114 dialog_name[3] = 'R';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2115 /* Number of buttons to put on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2116 dialog_name[4] = '0' + nb_buttons - left_count;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2117 dialog_name[5] = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2118 wv->contents = first_wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2119 first_wv = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2120 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2121
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2122 /* 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
2123 dialog_id = widget_id_tick++;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2124 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
2125 f->output_data.w32->widget, 1, 0,
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2126 dialog_selection_callback, 0);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
2127 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
2128
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2129 /* Free the widget_value objects we used to specify the contents. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2130 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
2131
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2132 /* No selection has been chosen yet. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2133 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
2134
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2135 /* Display the menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2136 lw_pop_up_all_widgets (dialog_id);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2137 popup_activated_flag = 1;
13434
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 /* 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
2140 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
2141
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2142 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
2143
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2144 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2145 the proper value. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2146 if (menu_item_selection != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2147 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2148 Lisp_Object prefix;
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 prefix = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2151 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2152 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2153 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2154 Lisp_Object entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2155
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2156 if (EQ (AREF (menu_items, i), Qt))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2157 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2158 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2159 i += MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2160 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2161 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2162 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2163 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
2164 if (menu_item_selection == i)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2165 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2166 if (keymaps != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2167 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2168 entry = Fcons (entry, Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2169 if (!NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2170 entry = Fcons (prefix, entry);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2171 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2172 return entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2173 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2174 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2175 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2176 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2177 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2178
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2179 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2180 }
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2181 #endif /* HAVE_DIALOGS */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2182
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2183
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2184 /* 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
2185 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2186 name_is_separator (name)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2187 char *name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2188 {
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2189 char *start = name;
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2190
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
2191 /* 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
2192 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
2193 /* 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
2194 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
2195 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
2196 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
2197 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2198
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2199
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2200 /* 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
2201 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2202 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
2203 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2204 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
2205 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2206
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2207 /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2208 static void
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2209 utf8to16 (unsigned char * src, int len, WCHAR * dest)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2210 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2211 while (len > 0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2212 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2213 int utf16;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2214 if (*src < 0x80)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2215 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2216 *dest = (WCHAR) *src;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2217 dest++; src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2218 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2219 /* 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
2220 else if (*src < 0xC0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2221 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2222 src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2223 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2224 /* 2 char UTF-8 sequence. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2225 else if (*src < 0xE0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2226 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2227 *dest = (WCHAR) (((*src & 0x1f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2228 | (*(src + 1) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2229 src += 2; len -= 2; 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 else if (*src < 0xF0)
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 *dest = (WCHAR) (((*src & 0x0f) << 12)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2234 | ((*(src + 1) & 0x3f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2235 | (*(src + 2) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2236 src += 3; len -= 3; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2237 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2238 else /* Not encodable. Insert Unicode Substitution char. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2239 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2240 *dest = (WCHAR) 0xfffd;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2241 src++; len--; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2242 }
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 *dest = 0;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2245 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2246
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2247 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2248 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
2249 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2250 UINT fuFlags;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2251 char *out_string;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2252 int return_value;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2253
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2254 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
2255 {
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2256 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
2257 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
2258 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
2259 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2260 {
22750
b38cb406ed80 (add_menu_item): Draw menu items like titles if call_data is 0.
Andrew Innes <andrewi@gnu.org>
parents: 22737
diff changeset
2261 if (wv->enabled)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2262 fuFlags = MF_STRING;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2263 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2264 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
2265
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2266 if (wv->key != NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2267 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2268 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
2269 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
2270 strcat (out_string, "\t");
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2271 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
2272 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2273 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2274 out_string = wv->name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2275
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2276 if (item != NULL)
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2277 fuFlags = MF_POPUP;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2278 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
2279 {
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2280 /* 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
2281 we can't deallocate the memory otherwise. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2282 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2283 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2284 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
2285 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
2286 #ifdef MENU_DEBUG
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2287 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
2288 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2289 fuFlags = MF_OWNERDRAW | MF_DISABLED;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2290 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2291 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2292 fuFlags = MF_DISABLED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2293 }
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2294
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2295 /* 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
2296 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
2297 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
2298 fuFlags |= MF_CHECKED;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2299 else
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2300 fuFlags |= MF_UNCHECKED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2301 }
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2302
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2303 if (unicode_append_menu && out_string)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2304 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2305 /* 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
2306 int utf8_len = strlen (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2307 WCHAR * utf16_string;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2308 if (fuFlags & MF_OWNERDRAW)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2309 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
2310 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2311 utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2312
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2313 utf8to16 (out_string, utf8_len, utf16_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2314 return_value = unicode_append_menu (menu, fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2315 item != NULL ? (UINT) item
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2316 : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2317 utf16_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2318 if (fuFlags & MF_OWNERDRAW)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2319 local_free (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2320 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2321 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2322 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2323 return_value =
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2324 AppendMenu (menu,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2325 fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2326 item != NULL ? (UINT) item : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2327 out_string );
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2328 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2329
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2330 /* 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
2331 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
2332 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2333 if (set_menu_item_info)
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2334 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2335 MENUITEMINFO info;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2336 bzero (&info, sizeof (info));
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2337 info.cbSize = sizeof (info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2338 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
2339
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2340 /* 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
2341 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
2342 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
2343 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
2344 #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
2345 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
2346 #else
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2347 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
2348 #endif
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2349 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
2350 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2351 /* 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
2352 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
2353 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
2354 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
2355 info.dwTypeData = out_string;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2356 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
2357 }
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
2358
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2359 set_menu_item_info (menu,
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2360 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
2361 FALSE, &info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2362 }
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
2363 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
2364 return return_value;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2365 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2366
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2367 /* 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
2368 int
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2369 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
2370 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2371 int items_added = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2372
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2373 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
2374 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2375 if (wv->contents)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2376 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2377 HMENU sub_menu = CreatePopupMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2378
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2379 if (sub_menu == NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2380 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2381
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2382 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
2383 !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
2384 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2385 DestroyMenu (sub_menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2386 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2387 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2388 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2389 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2390 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2391 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
2392 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2393 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2394 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2395 return 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2396 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2397
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2398 int
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2399 popup_activated ()
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2400 {
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2401 /* popup_activated_flag not actually used on W32 */
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2402 return 0;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2403 }
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
2404
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2405 /* 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
2406 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
2407 available. */
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2408 void
41646
258fa72efab7 (w32_menu_display_help): Actually add the new argument
Andrew Innes <andrewi@gnu.org>
parents: 41637
diff changeset
2409 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
2410 {
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2411 if (get_menu_item_info)
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2412 {
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2413 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
2414 Lisp_Object frame, help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2415
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
2416 /* No help echo on owner-draw menu items. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2417 if (flags & MF_OWNERDRAW || flags & MF_POPUP)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2418 help = Qnil;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2419 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2420 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2421 MENUITEMINFO info;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2422
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2423 bzero (&info, sizeof (info));
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2424 info.cbSize = sizeof (info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2425 info.fMask = MIIM_DATA;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2426 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
2427
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2428 #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
2429 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
2430 : Qnil;
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
2431 #else
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2432 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
2433 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2434 }
30989
2152817050ff (keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents: 30238
diff changeset
2435
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2436 /* 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
2437 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
2438 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
2439 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
2440 if (f)
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2441 {
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2442 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
2443 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
2444 }
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2445 else
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
2446 /* 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
2447 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
2448 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
2449 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2450 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2451
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2452 /* 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
2453 static void
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2454 w32_free_submenu_strings (menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2455 HMENU menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2456 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2457 int i, num = GetMenuItemCount (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2458 for (i = 0; i < num; i++)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2459 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2460 MENUITEMINFO info;
41930
d5fc57bcb0f2 (w32_free_submenu_strings): Clear menu item struct
Jason Rumney <jasonr@gnu.org>
parents: 41908
diff changeset
2461 bzero (&info, sizeof (info));
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2462 info.cbSize = sizeof (info);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2463 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
2464
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2465 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
2466
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2467 /* 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
2468 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
2469 {
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2470 #ifdef MENU_DEBUG
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2471 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
2472 #endif
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2473 local_free (info.dwItemData);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
2474 }
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2475
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2476 /* Recurse down submenus. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2477 if (info.hSubMenu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2478 w32_free_submenu_strings (info.hSubMenu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2479 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2480 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2481
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2482 void
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2483 w32_free_menu_strings (hwnd)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2484 HWND hwnd;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2485 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2486 HMENU menu = current_popup_menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2487
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2488 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2489 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2490 /* 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
2491 menubar. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2492 if (!menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2493 menu = GetMenu (hwnd);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2494
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2495 if (menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2496 w32_free_submenu_strings (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2497 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2498
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2499 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2500 }
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
2501
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2502 #endif /* HAVE_MENUS */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2503
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
2504 void syms_of_w32menu ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2505 {
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
2506 globals_of_w32menu ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2507 staticpro (&menu_items);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2508 menu_items = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2509
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2510 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
2511
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2512 Qdebug_on_next_call = intern ("debug-on-next-call");
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2513 staticpro (&Qdebug_on_next_call);
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
2514
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
2515 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
2516 doc: /* Frame for which we are updating a menu.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
2517 The enable predicate for a menu command should check this variable. */);
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
2518 Vmenu_updating_frame = Qnil;
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
2519
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2520 defsubr (&Sx_popup_menu);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
2521 #ifdef HAVE_MENUS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2522 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
2523 #endif
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2524 }
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
2525
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
2526 /*
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
2527 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
2528 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
2529 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
2530 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
2531 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
2532 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
2533 */
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
2534 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
2535 {
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
2536 /* 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
2537 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
2538 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
2539 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
2540 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
2541 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2542
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2543 /* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2544 (do not change this comment) */