annotate src/macmenu.c @ 95144:c9d1dab54646

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 20 May 2008 16:33:58 +0000
parents 8971ddf55736
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1 /* Menu support for GNU Emacs on Mac OS.
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
3 2008 Free Software Foundation, Inc.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5 This file is part of GNU Emacs.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
10 (at your option) any later version.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
11
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
15 GNU General Public License for more details.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
16
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94145
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
19
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
20 /* Contributed by Andrew Choi (akochoi@mac.com). */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
21
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
22 #include <config.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
23
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
24 #include <stdio.h>
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
25
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
26 #include "lisp.h"
83619
5da6a46ddbd6 * s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 77625
diff changeset
27 #include "frame.h"
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
28 #include "termhooks.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
29 #include "keyboard.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
30 #include "keymap.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
31 #include "window.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
32 #include "blockinput.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
33 #include "buffer.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
34 #include "charset.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
35 #include "coding.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
36
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
37 /* This may include sys/types.h, and that somehow loses
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
38 if this is not done before the other system files. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
39 #include "macterm.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
40
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
41 /* Load sys/types.h if not already loaded.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
42 In some systems loading it twice is suicidal. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
43 #ifndef makedev
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
44 #include <sys/types.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
45 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
46
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
47 #include "dispextern.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
48
75199
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
49 #if TARGET_API_MAC_CARBON
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
50 #define HAVE_DIALOGS 1
75199
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
51 #endif
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
52
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
53 #undef HAVE_MULTILINGUAL_MENU
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
54
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
55 /******************************************************************/
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
56
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
57 /* Assumed by other routines to zero area returned. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
58 #define malloc_widget_value() (void *)memset (xmalloc (sizeof (widget_value)),\
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
59 0, (sizeof (widget_value)))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
60 #define free_widget_value(wv) xfree (wv)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
61
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
62 /******************************************************************/
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
63
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
64 #ifndef TRUE
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
65 #define TRUE 1
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
66 #define FALSE 0
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
67 #endif /* no TRUE */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
68
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
69 Lisp_Object Qdebug_on_next_call;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
70
72773
15d914de92fd * src/macmenu.c (Vmenu_updating_frame, syms_of_xmenu):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70382
diff changeset
71 extern Lisp_Object Vmenu_updating_frame;
15d914de92fd * src/macmenu.c (Vmenu_updating_frame, syms_of_xmenu):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70382
diff changeset
72
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
73 extern Lisp_Object Qmenu_bar, Qmac_apple_event;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
74
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
75 extern Lisp_Object QCtoggle, QCradio;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
76
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
77 extern Lisp_Object Voverriding_local_map;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
78 extern Lisp_Object Voverriding_local_map_menu_flag;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
79
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
80 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
81
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
82 extern Lisp_Object Qmenu_bar_update_hook;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
83
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
84 void set_frame_menubar P_ ((FRAME_PTR, int, int));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
85
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
86 #if TARGET_API_MAC_CARBON
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
87 #define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
88 #else
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
89 #define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
90 #endif
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
91
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
92 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
93 Lisp_Object, Lisp_Object, Lisp_Object,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
94 Lisp_Object, Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
95 #ifdef HAVE_DIALOGS
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
96 static Lisp_Object mac_dialog_show P_ ((FRAME_PTR, int, Lisp_Object,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
97 Lisp_Object, char **));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
98 #endif
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
99 static Lisp_Object mac_menu_show P_ ((struct frame *, int, int, int, int,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
100 Lisp_Object, char **));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
101 static void keymap_panes P_ ((Lisp_Object *, int, int));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
102 static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
103 int, int));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
104 static void list_of_panes P_ ((Lisp_Object));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
105 static void list_of_items P_ ((Lisp_Object));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
106
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
107
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
108 /* This holds a Lisp vector that holds the results of decoding
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
109 the keymaps or alist-of-alists that specify a menu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
110
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
111 It describes the panes and items within the panes.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
112
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
113 Each pane is described by 3 elements in the vector:
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
114 t, the pane name, the pane's prefix key.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
115 Then follow the pane's items, with 5 elements per item:
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
116 the item string, the enable flag, the item's value,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
117 the definition, and the equivalent keyboard key's description string.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
118
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
119 In some cases, multiple levels of menus may be described.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
120 A single vector slot containing nil indicates the start of a submenu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
121 A single vector slot containing lambda indicates the end of a submenu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
122 The submenu follows a menu item which is the way to reach the submenu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
123
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
124 A single vector slot containing quote indicates that the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
125 following items should appear on the right of a dialog box.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
126
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
127 Using a Lisp vector to hold this information while we decode it
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
128 takes care of protecting all the data from GC. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
129
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
130 #define MENU_ITEMS_PANE_NAME 1
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
131 #define MENU_ITEMS_PANE_PREFIX 2
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
132 #define MENU_ITEMS_PANE_LENGTH 3
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
133
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
134 enum menu_item_idx
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
135 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
136 MENU_ITEMS_ITEM_NAME = 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
137 MENU_ITEMS_ITEM_ENABLE,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
138 MENU_ITEMS_ITEM_VALUE,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
139 MENU_ITEMS_ITEM_EQUIV_KEY,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
140 MENU_ITEMS_ITEM_DEFINITION,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
141 MENU_ITEMS_ITEM_TYPE,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
142 MENU_ITEMS_ITEM_SELECTED,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
143 MENU_ITEMS_ITEM_HELP,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
144 MENU_ITEMS_ITEM_LENGTH
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
145 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
146
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
147 static Lisp_Object menu_items;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
148
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
149 /* Number of slots currently allocated in menu_items. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
150 static int menu_items_allocated;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
151
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
152 /* This is the index in menu_items of the first empty slot. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
153 static int menu_items_used;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
154
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
155 /* The number of panes currently recorded in menu_items,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
156 excluding those within submenus. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
157 static int menu_items_n_panes;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
158
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
159 /* Current depth within submenus. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
160 static int menu_items_submenu_depth;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
161
76534
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
162 /* Nonzero means a menu is currently active. */
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
163 int popup_activated_flag;
76534
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
164
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
165 /* This is set nonzero after the user activates the menu bar, and set
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
166 to zero again after the menu bars are redisplayed by prepare_menu_bar.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
167 While it is nonzero, all calls to set_frame_menubar go deep.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
168
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
169 I don't understand why this is needed, but it does seem to be
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
170 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
171
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
172 int pending_menu_activation;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
173
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
174 /* Initialize the menu_items structure if we haven't already done so.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
175 Also mark it as currently empty. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
176
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
177 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
178 init_menu_items ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
179 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
180 if (NILP (menu_items))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
181 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
182 menu_items_allocated = 60;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
183 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
184 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
185
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
186 menu_items_used = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
187 menu_items_n_panes = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
188 menu_items_submenu_depth = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
189 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
190
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
191 /* Call at the end of generating the data in menu_items. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
192
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
193 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
194 finish_menu_items ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
195 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
196 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
197
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
198 /* Call when finished using the data for the current menu
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
199 in menu_items. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
200
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
201 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
202 discard_menu_items ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
203 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
204 /* Free the structure if it is especially large.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
205 Otherwise, hold on to it, to save time. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
206 if (menu_items_allocated > 200)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
207 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
208 menu_items = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
209 menu_items_allocated = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
210 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
211 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
212
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
213 /* This undoes save_menu_items, and it is called by the specpdl unwind
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
214 mechanism. */
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
215
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
216 static Lisp_Object
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
217 restore_menu_items (saved)
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
218 Lisp_Object saved;
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
219 {
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
220 menu_items = XCAR (saved);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
221 menu_items_allocated = (VECTORP (menu_items) ? ASIZE (menu_items) : 0);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
222 saved = XCDR (saved);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
223 menu_items_used = XINT (XCAR (saved));
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
224 saved = XCDR (saved);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
225 menu_items_n_panes = XINT (XCAR (saved));
73992
531d6c96fc70 (menu_quit_handler, install_menu_quit_handler):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73787
diff changeset
226 saved = XCDR (saved);
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
227 menu_items_submenu_depth = XINT (XCAR (saved));
70382
eb5777232ca5 (restore_menu_items, cleanup_popup_menu): Return a value.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70148
diff changeset
228 return Qnil;
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
229 }
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
230
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
231 /* Push the whole state of menu_items processing onto the specpdl.
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
232 It will be restored when the specpdl is unwound. */
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
233
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
234 static void
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
235 save_menu_items ()
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
236 {
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
237 Lisp_Object saved = list4 (menu_items,
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
238 make_number (menu_items_used),
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
239 make_number (menu_items_n_panes),
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
240 make_number (menu_items_submenu_depth));
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
241 record_unwind_protect (restore_menu_items, saved);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
242 menu_items = Qnil;
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
243 }
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
244
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
245 /* Make the menu_items vector twice as large. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
246
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
247 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
248 grow_menu_items ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
249 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
250 menu_items_allocated *= 2;
85246
ef39b2bc8f1e (grow_menu_items): Use larger_vector.
Eli Zaretskii <eliz@gnu.org>
parents: 83652
diff changeset
251 menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
252 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
253
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
254 /* Begin a submenu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
255
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
256 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
257 push_submenu_start ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
258 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
259 if (menu_items_used + 1 > menu_items_allocated)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
260 grow_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
261
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
262 XVECTOR (menu_items)->contents[menu_items_used++] = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
263 menu_items_submenu_depth++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
264 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
265
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
266 /* End a submenu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
267
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
268 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
269 push_submenu_end ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
270 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
271 if (menu_items_used + 1 > menu_items_allocated)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
272 grow_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
273
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
274 XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
275 menu_items_submenu_depth--;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
276 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
277
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
278 /* Indicate boundary between left and right. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
279
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
280 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
281 push_left_right_boundary ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
282 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
283 if (menu_items_used + 1 > menu_items_allocated)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
284 grow_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
285
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
286 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
287 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
288
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
289 /* Start a new menu pane in menu_items.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
290 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
291
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
292 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
293 push_menu_pane (name, prefix_vec)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
294 Lisp_Object name, prefix_vec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
295 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
296 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
297 grow_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
298
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
299 if (menu_items_submenu_depth == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
300 menu_items_n_panes++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
301 XVECTOR (menu_items)->contents[menu_items_used++] = Qt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
302 XVECTOR (menu_items)->contents[menu_items_used++] = name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
303 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
304 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
305
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
306 /* Push one menu item into the current pane. NAME is the string to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
307 display. ENABLE if non-nil means this item can be selected. KEY
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
308 is the key generated by choosing this item, or nil if this item
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
309 doesn't really have a definition. DEF is the definition of this
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
310 item. EQUIV is the textual description of the keyboard equivalent
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
311 for this item (or nil if none). TYPE is the type of this menu
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
312 item, one of nil, `toggle' or `radio'. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
313
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
314 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
315 push_menu_item (name, enable, key, def, equiv, type, selected, help)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
316 Lisp_Object name, enable, key, def, equiv, type, selected, help;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
317 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
318 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
319 grow_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
320
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
321 XVECTOR (menu_items)->contents[menu_items_used++] = name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
322 XVECTOR (menu_items)->contents[menu_items_used++] = enable;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
323 XVECTOR (menu_items)->contents[menu_items_used++] = key;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
324 XVECTOR (menu_items)->contents[menu_items_used++] = equiv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
325 XVECTOR (menu_items)->contents[menu_items_used++] = def;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
326 XVECTOR (menu_items)->contents[menu_items_used++] = type;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
327 XVECTOR (menu_items)->contents[menu_items_used++] = selected;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
328 XVECTOR (menu_items)->contents[menu_items_used++] = help;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
329 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
330
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
331 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
332 and generate menu panes for them in menu_items.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
333 If NOTREAL is nonzero,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
334 don't bother really computing whether an item is enabled. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
335
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
336 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
337 keymap_panes (keymaps, nmaps, notreal)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
338 Lisp_Object *keymaps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
339 int nmaps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
340 int notreal;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
341 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
342 int mapno;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
343
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
344 init_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
345
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
346 /* Loop over the given keymaps, making a pane for each map.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
347 But don't make a pane that is empty--ignore that map instead.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
348 P is the number of panes we have made so far. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
349 for (mapno = 0; mapno < nmaps; mapno++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
350 single_keymap_panes (keymaps[mapno],
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
351 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
352
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
353 finish_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
354 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
355
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
356 /* Args passed between single_keymap_panes and single_menu_item. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
357 struct skp
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
358 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
359 Lisp_Object pending_maps;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
360 int maxdepth, notreal;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
361 };
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
362
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
363 static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
364 void *));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
365
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
366 /* This is a recursive subroutine of keymap_panes.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
367 It handles one keymap, KEYMAP.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
368 The other arguments are passed along
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
369 or point to local variables of the previous function.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
370 If NOTREAL is nonzero, only check for equivalent key bindings, don't
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
371 evaluate expressions in menu items and don't make any menu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
372
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
373 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
374
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
375 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
376 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
377 Lisp_Object keymap;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
378 Lisp_Object pane_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
379 Lisp_Object prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
380 int notreal;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
381 int maxdepth;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
382 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
383 struct skp skp;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
384 struct gcpro gcpro1;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
385
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
386 skp.pending_maps = Qnil;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
387 skp.maxdepth = maxdepth;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
388 skp.notreal = notreal;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
389
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
390 if (maxdepth <= 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
391 return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
392
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
393 push_menu_pane (pane_name, prefix);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
394
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
395 GCPRO1 (skp.pending_maps);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
396 map_keymap (keymap, single_menu_item, Qnil, &skp, 1);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
397 UNGCPRO;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
398
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
399 /* Process now any submenus which want to be panes at this level. */
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
400 while (CONSP (skp.pending_maps))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
401 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
402 Lisp_Object elt, eltcdr, string;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
403 elt = XCAR (skp.pending_maps);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
404 eltcdr = XCDR (elt);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
405 string = XCAR (eltcdr);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
406 /* We no longer discard the @ from the beginning of the string here.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
407 Instead, we do this in mac_menu_show. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
408 single_keymap_panes (Fcar (elt), string,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
409 XCDR (eltcdr), notreal, maxdepth - 1);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
410 skp.pending_maps = XCDR (skp.pending_maps);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
411 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
412 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
413
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
414 /* This is a subroutine of single_keymap_panes that handles one
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
415 keymap entry.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
416 KEY is a key in a keymap and ITEM is its binding.
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
417 SKP->PENDING_MAPS_PTR is a list of keymaps waiting to be made into
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
418 separate panes.
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
419 If SKP->NOTREAL is nonzero, only check for equivalent key bindings, don't
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
420 evaluate expressions in menu items and don't make any menu.
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
421 If we encounter submenus deeper than SKP->MAXDEPTH levels, ignore them. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
422
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
423 static void
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
424 single_menu_item (key, item, dummy, skp_v)
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
425 Lisp_Object key, item, dummy;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
426 void *skp_v;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
427 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
428 Lisp_Object map, item_string, enabled;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
429 struct gcpro gcpro1, gcpro2;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
430 int res;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
431 struct skp *skp = skp_v;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
432
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
433 /* Parse the menu item and leave the result in item_properties. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
434 GCPRO2 (key, item);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
435 res = parse_menu_item (item, skp->notreal, 0);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
436 UNGCPRO;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
437 if (!res)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
438 return; /* Not a menu item. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
439
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
440 map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
441
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
442 if (skp->notreal)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
443 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
444 /* We don't want to make a menu, just traverse the keymaps to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
445 precompute equivalent key bindings. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
446 if (!NILP (map))
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
447 single_keymap_panes (map, Qnil, key, 1, skp->maxdepth - 1);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
448 return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
449 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
450
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
451 enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
452 item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
453
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
454 if (!NILP (map) && SREF (item_string, 0) == '@')
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
455 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
456 if (!NILP (enabled))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
457 /* An enabled separate pane. Remember this to handle it later. */
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
458 skp->pending_maps = Fcons (Fcons (map, Fcons (item_string, key)),
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
459 skp->pending_maps);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
460 return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
461 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
462
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
463 push_menu_item (item_string, enabled, key,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
464 XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF],
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
465 XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ],
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
466 XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE],
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
467 XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED],
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
468 XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
469
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
470 /* Display a submenu using the toolkit. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
471 if (! (NILP (map) || NILP (enabled)))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
472 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
473 push_submenu_start ();
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
474 single_keymap_panes (map, Qnil, key, 0, skp->maxdepth - 1);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
475 push_submenu_end ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
476 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
477 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
478
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
479 /* Push all the panes and items of a menu described by the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
480 alist-of-alists MENU.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
481 This handles old-fashioned calls to x-popup-menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
482
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
483 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
484 list_of_panes (menu)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
485 Lisp_Object menu;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
486 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
487 Lisp_Object tail;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
488
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
489 init_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
490
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
491 for (tail = menu; CONSP (tail); tail = XCDR (tail))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
492 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
493 Lisp_Object elt, pane_name, pane_data;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
494 elt = XCAR (tail);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
495 pane_name = Fcar (elt);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
496 CHECK_STRING (pane_name);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
497 push_menu_pane (ENCODE_MENU_STRING (pane_name), Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
498 pane_data = Fcdr (elt);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
499 CHECK_CONS (pane_data);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
500 list_of_items (pane_data);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
501 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
502
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
503 finish_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
504 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
505
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
506 /* Push the items in a single pane defined by the alist PANE. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
507
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
508 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
509 list_of_items (pane)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
510 Lisp_Object pane;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
511 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
512 Lisp_Object tail, item, item1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
513
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
514 for (tail = pane; CONSP (tail); tail = XCDR (tail))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
515 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
516 item = XCAR (tail);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
517 if (STRINGP (item))
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
518 push_menu_item (ENCODE_MENU_STRING (item), Qnil, Qnil, Qt,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
519 Qnil, Qnil, Qnil, Qnil);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
520 else if (CONSP (item))
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
521 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
522 item1 = XCAR (item);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
523 CHECK_STRING (item1);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
524 push_menu_item (ENCODE_MENU_STRING (item1), Qt, XCDR (item),
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
525 Qt, Qnil, Qnil, Qnil, Qnil);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
526 }
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
527 else
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
528 push_left_right_boundary ();
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
529
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
530 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
531 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
532
62988
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
533 static Lisp_Object
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
534 cleanup_popup_menu (arg)
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
535 Lisp_Object arg;
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
536 {
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
537 discard_menu_items ();
70382
eb5777232ca5 (restore_menu_items, cleanup_popup_menu): Return a value.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70148
diff changeset
538 return Qnil;
62988
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
539 }
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
540
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
541 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
542 doc: /* Pop up a deck-of-cards menu and return user's selection.
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
543 POSITION is a position specification. This is either a mouse button event
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
544 or a list ((XOFFSET YOFFSET) WINDOW)
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
545 where XOFFSET and YOFFSET are positions in pixels from the top left
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
546 corner of WINDOW. (WINDOW may be a window or a frame object.)
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
547 This controls the position of the top left of the menu as a whole.
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
548 If POSITION is t, it means to use the current mouse position.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
549
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
550 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
551 The menu items come from key bindings that have a menu string as well as
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
552 a definition; actually, the "definition" in such a key binding looks like
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
553 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
554 the keymap as a top-level element.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
555
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
556 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
557 Otherwise, REAL-DEFINITION should be a valid key binding definition.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
558
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
559 You can also use a list of keymaps as MENU.
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
560 Then each keymap makes a separate pane.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
561
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
562 When MENU is a keymap or a list of keymaps, the return value is the
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
563 list of events corresponding to the user's choice. Note that
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
564 `x-popup-menu' does not actually execute the command bound to that
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
565 sequence of events.
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
566
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
567 Alternatively, you can specify a menu of multiple panes
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
568 with a list of the form (TITLE PANE1 PANE2...),
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
569 where each pane is a list of form (TITLE ITEM1 ITEM2...).
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
570 Each ITEM is normally a cons cell (STRING . VALUE);
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
571 but a string can appear as an item--that makes a nonselectable line
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
572 in the menu.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
573 With this form of menu, the return value is VALUE from the chosen item.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
574
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
575 If POSITION is nil, don't display the menu at all, just precalculate the
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
576 cached information about equivalent key sequences.
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
577
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
578 If the user gets rid of the menu without making a valid choice, for
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
579 instance by clicking the mouse away from a valid choice or by typing
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
580 keyboard input, then this normally results in a quit and
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
581 `x-popup-menu' does not return. But if POSITION is a mouse button
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
582 event (indicating that the user invoked the menu with the mouse) then
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
583 no quit occurs and `x-popup-menu' returns nil. */)
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
584 (position, menu)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
585 Lisp_Object position, menu;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
586 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
587 Lisp_Object keymap, tem;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
588 int xpos = 0, ypos = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
589 Lisp_Object title;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
590 char *error_name = NULL;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
591 Lisp_Object selection;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
592 FRAME_PTR f = NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
593 Lisp_Object x, y, window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
594 int keymaps = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
595 int for_click = 0;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
596 int specpdl_count = SPECPDL_INDEX ();
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
597 struct gcpro gcpro1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
598
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
599 #ifdef HAVE_MENUS
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
600 if (! NILP (position))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
601 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
602 check_mac ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
603
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
604 /* Decode the first argument: find the window and the coordinates. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
605 if (EQ (position, Qt)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
606 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
607 || EQ (XCAR (position), Qtool_bar)
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
608 || EQ (XCAR (position), Qmac_apple_event))))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
609 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
610 /* Use the mouse's current position. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
611 FRAME_PTR new_f = SELECTED_FRAME ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
612 Lisp_Object bar_window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
613 enum scroll_bar_part part;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
614 unsigned long time;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
615
83619
5da6a46ddbd6 * s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 77625
diff changeset
616 if (FRAME_TERMINAL (new_f)->mouse_position_hook)
5da6a46ddbd6 * s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 77625
diff changeset
617 (*FRAME_TERMINAL (new_f)->mouse_position_hook) (&new_f, 1, &bar_window,
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
618 &part, &x, &y, &time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
619 if (new_f != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
620 XSETFRAME (window, new_f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
621 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
622 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
623 window = selected_window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
624 XSETFASTINT (x, 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
625 XSETFASTINT (y, 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
626 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
627 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
628 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
629 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
630 tem = Fcar (position);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
631 if (CONSP (tem))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
632 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
633 window = Fcar (Fcdr (position));
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
634 x = XCAR (tem);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
635 y = Fcar (XCDR (tem));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
636 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
637 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
638 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
639 for_click = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
640 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
641 window = Fcar (tem); /* POSN_WINDOW (tem) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
642 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
643 x = Fcar (tem);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
644 y = Fcdr (tem);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
645 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
646 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
647
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
648 CHECK_NUMBER (x);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
649 CHECK_NUMBER (y);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
650
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
651 /* Decode where to put the menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
652
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
653 if (FRAMEP (window))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
654 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
655 f = XFRAME (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
656 xpos = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
657 ypos = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
658 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
659 else if (WINDOWP (window))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
660 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
661 CHECK_LIVE_WINDOW (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
662 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
663
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
664 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
665 ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
666 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
667 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
668 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
669 but I don't want to make one now. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
670 CHECK_WINDOW (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
671
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
672 xpos += XINT (x);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
673 ypos += XINT (y);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
674
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
675 XSETFRAME (Vmenu_updating_frame, f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
676 }
67704
06f3a72bffb2 (Fx_popup_menu): Add `else' to set Vmenu_updating_frame to nil
Juri Linkov <juri@jurta.org>
parents: 64770
diff changeset
677 else
06f3a72bffb2 (Fx_popup_menu): Add `else' to set Vmenu_updating_frame to nil
Juri Linkov <juri@jurta.org>
parents: 64770
diff changeset
678 Vmenu_updating_frame = Qnil;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
679 #endif /* HAVE_MENUS */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
680
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
681 title = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
682 GCPRO1 (title);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
683
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
684 /* Decode the menu items from what was specified. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
685
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
686 keymap = get_keymap (menu, 0, 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
687 if (CONSP (keymap))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
688 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
689 /* We were given a keymap. Extract menu info from the keymap. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
690 Lisp_Object prompt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
691
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
692 /* Extract the detailed info to make one pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
693 keymap_panes (&menu, 1, NILP (position));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
694
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
695 /* Search for a string appearing directly as an element of the keymap.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
696 That string is the title of the menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
697 prompt = Fkeymap_prompt (keymap);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
698 if (NILP (title) && !NILP (prompt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
699 title = prompt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
700
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
701 /* Make that be the pane title of the first pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
702 if (!NILP (prompt) && menu_items_n_panes >= 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
703 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
704
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
705 keymaps = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
706 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
707 else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
708 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
709 /* We were given a list of keymaps. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
710 int nmaps = XFASTINT (Flength (menu));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
711 Lisp_Object *maps
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
712 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
713 int i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
714
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
715 title = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
716
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
717 /* The first keymap that has a prompt string
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
718 supplies the menu title. */
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
719 for (tem = menu, i = 0; CONSP (tem); tem = XCDR (tem))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
720 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
721 Lisp_Object prompt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
722
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
723 maps[i++] = keymap = get_keymap (XCAR (tem), 1, 0);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
724
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
725 prompt = Fkeymap_prompt (keymap);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
726 if (NILP (title) && !NILP (prompt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
727 title = prompt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
728 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
729
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
730 /* Extract the detailed info to make one pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
731 keymap_panes (maps, nmaps, NILP (position));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
732
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
733 /* Make the title be the pane title of the first pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
734 if (!NILP (title) && menu_items_n_panes >= 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
735 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
736
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
737 keymaps = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
738 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
739 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
740 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
741 /* We were given an old-fashioned menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
742 title = Fcar (menu);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
743 CHECK_STRING (title);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
744
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
745 list_of_panes (Fcdr (menu));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
746
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
747 keymaps = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
748 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
749
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
750 if (NILP (position))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
751 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
752 discard_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
753 UNGCPRO;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
754 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
755 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
756
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
757 #ifdef HAVE_MENUS
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
758 /* Display them in a menu. */
62988
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
759 record_unwind_protect (cleanup_popup_menu, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
760 BLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
761
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
762 selection = mac_menu_show (f, xpos, ypos, for_click,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
763 keymaps, title, &error_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
764 UNBLOCK_INPUT;
62988
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
765 unbind_to (specpdl_count, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
766
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
767 UNGCPRO;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
768 #endif /* HAVE_MENUS */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
769
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
770 if (error_name) error (error_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
771 return selection;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
772 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
773
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
774 #ifdef HAVE_MENUS
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
775
62670
5ba03d610746 (Fx_popup_dialog): Allow 3rd optional argument.
Nick Roberts <nickrob@snap.net.nz>
parents: 62669
diff changeset
776 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
777 doc: /* Pop up a dialog box and return user's selection.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
778 POSITION specifies which frame to use.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
779 This is normally a mouse button event or a window or frame.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
780 If POSITION is t, it means to use the frame the mouse is on.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
781 The dialog box appears in the middle of the specified frame.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
782
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
783 CONTENTS specifies the alternatives to display in the dialog box.
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
784 It is a list of the form (DIALOG ITEM1 ITEM2...).
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
785 Each ITEM is a cons cell (STRING . VALUE).
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
786 The return value is VALUE from the chosen item.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
787
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
788 An ITEM may also be just a string--that makes a nonselectable item.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
789 An ITEM may also be nil--that means to put all preceding items
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
790 on the left of the dialog box and all following items on the right.
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
791 \(By default, approximately half appear on each side.)
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
792
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
793 If HEADER is non-nil, the frame title for the box is "Information",
64606
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
794 otherwise it is "Question".
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
795
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
796 If the user gets rid of the dialog box without making a valid choice,
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
797 for instance using the window manager, then this produces a quit and
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
798 `x-popup-dialog' does not return. */)
ceb2de3f0f69 (Fx_popup_menu, Fx_popup_menu): Doc fixes.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
799 (position, contents, header)
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
800 Lisp_Object position, contents, header;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
801 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
802 FRAME_PTR f = NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
803 Lisp_Object window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
804
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
805 check_mac ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
806
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
807 /* Decode the first argument: find the window or frame to use. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
808 if (EQ (position, Qt)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
809 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
810 || EQ (XCAR (position), Qtool_bar)
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
811 || EQ (XCAR (position), Qmac_apple_event))))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
812 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
813 #if 0 /* Using the frame the mouse is on may not be right. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
814 /* Use the mouse's current position. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
815 FRAME_PTR new_f = SELECTED_FRAME ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
816 Lisp_Object bar_window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
817 enum scroll_bar_part part;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
818 unsigned long time;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
819 Lisp_Object x, y;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
820
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
821 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
822
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
823 if (new_f != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
824 XSETFRAME (window, new_f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
825 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
826 window = selected_window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
827 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
828 window = selected_window;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
829 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
830 else if (CONSP (position))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
831 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
832 Lisp_Object tem;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
833 tem = Fcar (position);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
834 if (CONSP (tem))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
835 window = Fcar (Fcdr (position));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
836 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
837 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
838 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
839 window = Fcar (tem); /* POSN_WINDOW (tem) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
840 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
841 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
842 else if (WINDOWP (position) || FRAMEP (position))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
843 window = position;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
844 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
845 window = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
846
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
847 /* Decode where to put the menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
848
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
849 if (FRAMEP (window))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
850 f = XFRAME (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
851 else if (WINDOWP (window))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
852 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
853 CHECK_LIVE_WINDOW (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
854 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
855 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
856 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
857 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
858 but I don't want to make one now. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
859 CHECK_WINDOW (window);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
860
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
861 #ifndef HAVE_DIALOGS
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
862 /* Display a menu with these alternatives
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
863 in the middle of frame F. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
864 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
865 Lisp_Object x, y, frame, newpos;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
866 XSETFRAME (frame, f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
867 XSETINT (x, x_pixel_width (f) / 2);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
868 XSETINT (y, x_pixel_height (f) / 2);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
869 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
870
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
871 return Fx_popup_menu (newpos,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
872 Fcons (Fcar (contents), Fcons (contents, Qnil)));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
873 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
874 #else /* HAVE_DIALOGS */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
875 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
876 Lisp_Object title;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
877 char *error_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
878 Lisp_Object selection;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
879 int specpdl_count = SPECPDL_INDEX ();
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
880
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
881 /* Decode the dialog items from what was specified. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
882 title = Fcar (contents);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
883 CHECK_STRING (title);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
884
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
885 list_of_panes (Fcons (contents, Qnil));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
886
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
887 /* Display them in a dialog box. */
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
888 record_unwind_protect (cleanup_popup_menu, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
889 BLOCK_INPUT;
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
890 selection = mac_dialog_show (f, 0, title, header, &error_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
891 UNBLOCK_INPUT;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
892 unbind_to (specpdl_count, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
893
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
894 if (error_name) error (error_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
895 return selection;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
896 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
897 #endif /* HAVE_DIALOGS */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
898 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
899
72984
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
900 /* Find the menu selection and store it in the keyboard buffer.
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
901 F is the frame the menu is on.
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
902 MENU_BAR_ITEMS_USED is the length of VECTOR.
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
903 VECTOR is an array of menu events for the whole menu. */
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
904
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
905 void
72984
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
906 find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data)
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
907 FRAME_PTR f;
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
908 int menu_bar_items_used;
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
909 Lisp_Object vector;
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
910 void *client_data;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
911 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
912 Lisp_Object prefix, entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
913 Lisp_Object *subprefix_stack;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
914 int submenu_depth = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
915 int i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
916
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
917 entry = Qnil;
72984
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
918 subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
919 prefix = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
920 i = 0;
72984
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
921
93e945b1789c (enum mac_menu_kind, min_menu_id): New enumerator and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72773
diff changeset
922 while (i < menu_bar_items_used)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
923 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
924 if (EQ (XVECTOR (vector)->contents[i], Qnil))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
925 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
926 subprefix_stack[submenu_depth++] = prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
927 prefix = entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
928 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
929 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
930 else if (EQ (XVECTOR (vector)->contents[i], Qlambda))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
931 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
932 prefix = subprefix_stack[--submenu_depth];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
933 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
934 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
935 else if (EQ (XVECTOR (vector)->contents[i], Qt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
936 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
937 prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
938 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
939 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
940 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
941 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
942 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
943 /* The EMACS_INT cast avoids a warning. There's no problem
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
944 as long as pointers have enough bits to hold small integers. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
945 if ((int) (EMACS_INT) client_data == i)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
946 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
947 int j;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
948 struct input_event buf;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
949 Lisp_Object frame;
51573
861a49cd70cf (menubar_selection_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51206
diff changeset
950 EVENT_INIT (buf);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
951
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
952 XSETFRAME (frame, f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
953 buf.kind = MENU_BAR_EVENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
954 buf.frame_or_window = frame;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
955 buf.arg = frame;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
956 kbd_buffer_store_event (&buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
957
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
958 for (j = 0; j < submenu_depth; j++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
959 if (!NILP (subprefix_stack[j]))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
960 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
961 buf.kind = MENU_BAR_EVENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
962 buf.frame_or_window = frame;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
963 buf.arg = subprefix_stack[j];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
964 kbd_buffer_store_event (&buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
965 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
966
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
967 if (!NILP (prefix))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
968 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
969 buf.kind = MENU_BAR_EVENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
970 buf.frame_or_window = frame;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
971 buf.arg = prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
972 kbd_buffer_store_event (&buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
973 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
974
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
975 buf.kind = MENU_BAR_EVENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
976 buf.frame_or_window = frame;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
977 buf.arg = entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
978 kbd_buffer_store_event (&buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
979
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
980 return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
981 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
982 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
983 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
984 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
985 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
986
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
987 /* Allocate a widget_value, blocking input. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
988
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
989 widget_value *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
990 xmalloc_widget_value ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
991 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
992 widget_value *value;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
993
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
994 BLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
995 value = malloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
996 UNBLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
997
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
998 return value;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
999 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1001 /* This recursively calls free_widget_value on the tree of widgets.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1002 It must free all data that was malloc'ed for these widget_values.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1003 In Emacs, many slots are pointers into the data of Lisp_Strings, and
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1004 must be left alone. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1005
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1006 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1007 free_menubar_widget_value_tree (wv)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1008 widget_value *wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1009 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1010 if (! wv) return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1011
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1012 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1013
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1014 if (wv->contents && (wv->contents != (widget_value*)1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1015 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1016 free_menubar_widget_value_tree (wv->contents);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1017 wv->contents = (widget_value *) 0xDEADBEEF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1018 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1019 if (wv->next)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1020 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1021 free_menubar_widget_value_tree (wv->next);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1022 wv->next = (widget_value *) 0xDEADBEEF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1023 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1024 BLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1025 free_widget_value (wv);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1026 UNBLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1027 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1028
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1029 /* Set up data in menu_items for a menu bar item
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1030 whose event type is ITEM_KEY (with string ITEM_NAME)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1031 and whose contents come from the list of keymaps MAPS. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1032
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1033 static int
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1034 parse_single_submenu (item_key, item_name, maps)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1035 Lisp_Object item_key, item_name, maps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1036 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1037 Lisp_Object length;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1038 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1039 Lisp_Object *mapvec;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1040 int i;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1041 int top_level_items = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1042
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1043 length = Flength (maps);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1044 len = XINT (length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1045
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1046 /* Convert the list MAPS into a vector MAPVEC. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1047 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1048 for (i = 0; i < len; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1049 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1050 mapvec[i] = Fcar (maps);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1051 maps = Fcdr (maps);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1052 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1053
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1054 /* Loop over the given keymaps, making a pane for each map.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1055 But don't make a pane that is empty--ignore that map instead. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1056 for (i = 0; i < len; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1057 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1058 if (!KEYMAPP (mapvec[i]))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1059 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1060 /* Here we have a command at top level in the menu bar
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1061 as opposed to a submenu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1062 top_level_items = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1063 push_menu_pane (Qnil, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1064 push_menu_item (item_name, Qt, item_key, mapvec[i],
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1065 Qnil, Qnil, Qnil, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1066 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1067 else
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1068 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1069 Lisp_Object prompt;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1070 prompt = Fkeymap_prompt (mapvec[i]);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1071 single_keymap_panes (mapvec[i],
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1072 !NILP (prompt) ? prompt : item_name,
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1073 item_key, 0, 10);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1074 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1075 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1076
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1077 return top_level_items;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1078 }
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1079
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1080 /* Create a tree of widget_value objects
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1081 representing the panes and items
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1082 in menu_items starting at index START, up to index END. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1083
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1084 static widget_value *
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1085 digest_single_submenu (start, end, top_level_items)
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1086 int start, end, top_level_items;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1087 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1088 widget_value *wv, *prev_wv, *save_wv, *first_wv;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1089 int i;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1090 int submenu_depth = 0;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1091 widget_value **submenu_stack;
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1092 int panes_seen = 0;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1093
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1094 submenu_stack
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1095 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1096 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1097 wv->name = "menu";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1098 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1099 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1100 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1101 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1102 first_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1103 save_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1104 prev_wv = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1105
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1106 /* Loop over all panes and items made by the preceding call
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1107 to parse_single_submenu and construct a tree of widget_value objects.
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1108 Ignore the panes and items used by previous calls to
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1109 digest_single_submenu, even though those are also in menu_items. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1110 i = start;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1111 while (i < end)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1112 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1113 if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1114 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1115 submenu_stack[submenu_depth++] = save_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1116 save_wv = prev_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1117 prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1118 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1119 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1120 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1121 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1122 prev_wv = save_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1123 save_wv = submenu_stack[--submenu_depth];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1124 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1125 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1126 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1127 && submenu_depth != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1128 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1129 /* Ignore a nil in the item list.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1130 It's meaningful only for dialog boxes. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1131 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1132 i += 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1133 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1134 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1135 /* Create a new pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1136 Lisp_Object pane_name, prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1137 char *pane_string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1138
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1139 panes_seen++;
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1140
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1141 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1142 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1143
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1144 #ifndef HAVE_MULTILINGUAL_MENU
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1145 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1146 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1147 pane_name = ENCODE_MENU_STRING (pane_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1148 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1149 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1150 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1151 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
1152 ? "" : (char *) SDATA (pane_name));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1153 /* If there is just one top-level pane, put all its items directly
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1154 under the top-level menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1155 if (menu_items_n_panes == 1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1156 pane_string = "";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1157
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1158 /* If the pane has a meaningful name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1159 make the pane a top-level menu item
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1160 with its items as a submenu beneath it. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1161 if (strcmp (pane_string, ""))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1162 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1163 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1164 if (save_wv)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1165 save_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1166 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1167 first_wv->contents = wv;
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1168 wv->lname = pane_name;
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1169 /* Set value to 1 so update_submenu_strings can handle '@' */
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1170 wv->value = (char *)1;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1171 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1172 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1173 wv->help = Qnil;
69098
53d05914b117 (digest_single_submenu): Apply 2006-02-19 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69001
diff changeset
1174 save_wv = wv;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1175 }
69098
53d05914b117 (digest_single_submenu): Apply 2006-02-19 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69001
diff changeset
1176 else
53d05914b117 (digest_single_submenu): Apply 2006-02-19 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69001
diff changeset
1177 save_wv = first_wv;
53d05914b117 (digest_single_submenu): Apply 2006-02-19 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69001
diff changeset
1178
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1179 prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1180 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1181 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1182 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1183 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1184 /* Create a new item within current pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1185 Lisp_Object item_name, enable, descrip, def, type, selected;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1186 Lisp_Object help;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1187
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1188 /* All items should be contained in panes. */
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1189 if (panes_seen == 0)
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1190 abort ();
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1191
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1192 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1193 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1194 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1195 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1196 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1197 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1198 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1199
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1200 #ifndef HAVE_MULTILINGUAL_MENU
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1201 if (STRING_MULTIBYTE (item_name))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1202 {
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
1203 item_name = ENCODE_MENU_STRING (item_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1204 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1205 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1206
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1207 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1208 {
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
1209 descrip = ENCODE_MENU_STRING (descrip);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1210 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1211 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1212 #endif /* not HAVE_MULTILINGUAL_MENU */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1213
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1214 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1215 if (prev_wv)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1216 prev_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1217 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1218 save_wv->contents = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1219
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1220 wv->lname = item_name;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1221 if (!NILP (descrip))
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1222 wv->lkey = descrip;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1223 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1224 /* The EMACS_INT cast avoids a warning. There's no problem
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1225 as long as pointers have enough bits to hold small integers. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1226 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1227 wv->enabled = !NILP (enable);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1228
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1229 if (NILP (type))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1230 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1231 else if (EQ (type, QCradio))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1232 wv->button_type = BUTTON_TYPE_RADIO;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1233 else if (EQ (type, QCtoggle))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1234 wv->button_type = BUTTON_TYPE_TOGGLE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1235 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1236 abort ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1237
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1238 wv->selected = !NILP (selected);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1239 if (! STRINGP (help))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1240 help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1241
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1242 wv->help = help;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1243
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1244 prev_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1245
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1246 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1247 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1248 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1249
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1250 /* If we have just one "menu item"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1251 that was originally a button, return it by itself. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1252 if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1253 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1254 wv = first_wv->contents;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1255 free_widget_value (first_wv);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1256 return wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1257 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1258
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1259 return first_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1260 }
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1261
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1262 /* Walk through the widget_value tree starting at FIRST_WV and update
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1263 the char * pointers from the corresponding lisp values.
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1264 We do this after building the whole tree, since GC may happen while the
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1265 tree is constructed, and small strings are relocated. So we must wait
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1266 until no GC can happen before storing pointers into lisp values. */
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1267 static void
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1268 update_submenu_strings (first_wv)
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1269 widget_value *first_wv;
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1270 {
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1271 widget_value *wv;
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1272
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1273 for (wv = first_wv; wv; wv = wv->next)
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1274 {
57357
05fe2d3ca439 macfns.c (mac_get_window_bounds): Add extern.
Steven Tamm <steventamm@mac.com>
parents: 56889
diff changeset
1275 if (STRINGP (wv->lname))
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1276 {
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1277 wv->name = SDATA (wv->lname);
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1278
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1279 /* Ignore the @ that means "separate pane".
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1280 This is a kludge, but this isn't worth more time. */
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1281 if (wv->value == (char *)1)
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1282 {
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1283 if (wv->name[0] == '@')
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1284 wv->name++;
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1285 wv->value = 0;
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1286 }
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1287 }
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1288
57357
05fe2d3ca439 macfns.c (mac_get_window_bounds): Add extern.
Steven Tamm <steventamm@mac.com>
parents: 56889
diff changeset
1289 if (STRINGP (wv->lkey))
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1290 wv->key = SDATA (wv->lkey);
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1291
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1292 if (wv->contents)
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1293 update_submenu_strings (wv->contents);
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1294 }
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1295 }
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1296
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1297
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1298 /* Set the contents of the menubar widgets of frame F.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1299 The argument FIRST_TIME is currently ignored;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1300 it is set the first time this is called, from initialize_frame_menubar. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1301
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1302 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1303 set_frame_menubar (f, first_time, deep_p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1304 FRAME_PTR f;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1305 int first_time;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1306 int deep_p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1307 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1308 int menubar_widget = f->output_data.mac->menubar_widget;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1309 Lisp_Object items;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1310 widget_value *wv, *first_wv, *prev_wv = 0;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1311 int i, last_i = 0;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1312 int *submenu_start, *submenu_end;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1313 int *submenu_top_level_items, *submenu_n_panes;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1314
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1315 XSETFRAME (Vmenu_updating_frame, f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1316
80390
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
1317 /* This seems to be unnecessary for Carbon. */
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
1318 #if 0
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1319 if (! menubar_widget)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1320 deep_p = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1321 else if (pending_menu_activation && !deep_p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1322 deep_p = 1;
80390
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
1323 #endif
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1324
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1325 if (deep_p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1326 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1327 /* Make a widget-value tree representing the entire menu trees. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1328
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1329 struct buffer *prev = current_buffer;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1330 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45848
diff changeset
1331 int specpdl_count = SPECPDL_INDEX ();
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1332 int previous_menu_items_used = f->menu_bar_items_used;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1333 Lisp_Object *previous_items
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1334 = (Lisp_Object *) alloca (previous_menu_items_used
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1335 * sizeof (Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1336
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1337 /* If we are making a new widget, its contents are empty,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1338 do always reinitialize them. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1339 if (! menubar_widget)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1340 previous_menu_items_used = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1341
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1342 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1343 specbind (Qinhibit_quit, Qt);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1344 /* Don't let the debugger step into this code
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1345 because it is not reentrant. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1346 specbind (Qdebug_on_next_call, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1347
63147
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 63099
diff changeset
1348 record_unwind_save_match_data ();
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1349 if (NILP (Voverriding_local_map_menu_flag))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1350 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1351 specbind (Qoverriding_terminal_local_map, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1352 specbind (Qoverriding_local_map, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1353 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1354
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1355 set_buffer_internal_1 (XBUFFER (buffer));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1356
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1357 /* Run the Lucid hook. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1358 safe_run_hooks (Qactivate_menubar_hook);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1359
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1360 /* If it has changed current-menubar from previous value,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1361 really recompute the menubar from the value. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1362 if (! NILP (Vlucid_menu_bar_dirty_flag))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1363 call0 (Qrecompute_lucid_menubar);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1364 safe_run_hooks (Qmenu_bar_update_hook);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1365 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1366
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1367 items = FRAME_MENU_BAR_ITEMS (f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1368
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1369 /* Save the frame's previous menu bar contents data. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1370 if (previous_menu_items_used)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1371 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1372 previous_menu_items_used * sizeof (Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1373
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1374 /* Fill in menu_items with the current menu bar contents.
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1375 This can evaluate Lisp code. */
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1376 save_menu_items ();
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1377
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1378 menu_items = f->menu_bar_vector;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1379 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1380 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1381 submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1382 submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int));
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1383 submenu_top_level_items
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1384 = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1385 init_menu_items ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1386 for (i = 0; i < XVECTOR (items)->size; i += 4)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1387 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1388 Lisp_Object key, string, maps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1389
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1390 last_i = i;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1391
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1392 key = XVECTOR (items)->contents[i];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1393 string = XVECTOR (items)->contents[i + 1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1394 maps = XVECTOR (items)->contents[i + 2];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1395 if (NILP (string))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1396 break;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1397
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1398 submenu_start[i] = menu_items_used;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1399
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1400 menu_items_n_panes = 0;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1401 submenu_top_level_items[i]
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1402 = parse_single_submenu (key, string, maps);
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1403 submenu_n_panes[i] = menu_items_n_panes;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1404
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1405 submenu_end[i] = menu_items_used;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1406 }
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1407
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1408 finish_menu_items ();
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1409
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1410 /* Convert menu_items into widget_value trees
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1411 to display the menu. This cannot evaluate Lisp code. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1412
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1413 wv = xmalloc_widget_value ();
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1414 wv->name = "menubar";
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1415 wv->value = 0;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1416 wv->enabled = 1;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1417 wv->button_type = BUTTON_TYPE_NONE;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1418 wv->help = Qnil;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1419 first_wv = wv;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1420
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1421 for (i = 0; i < last_i; i += 4)
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1422 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1423 menu_items_n_panes = submenu_n_panes[i];
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1424 wv = digest_single_submenu (submenu_start[i], submenu_end[i],
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1425 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1426 if (prev_wv)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1427 prev_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1428 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1429 first_wv->contents = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1430 /* Don't set wv->name here; GC during the loop might relocate it. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1431 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1432 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1433 prev_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1434 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1435
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1436 set_buffer_internal_1 (prev);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1437
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1438 /* If there has been no change in the Lisp-level contents
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1439 of the menu bar, skip redisplaying it. Just exit. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1440
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1441 /* Compare the new menu items with the ones computed last time. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1442 for (i = 0; i < previous_menu_items_used; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1443 if (menu_items_used == i
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1444 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1445 break;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1446 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1447 {
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1448 /* The menu items have not changed. Don't bother updating
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1449 the menus in any form, since it would be a no-op. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1450 free_menubar_widget_value_tree (first_wv);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1451 discard_menu_items ();
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1452 unbind_to (specpdl_count, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1453 return;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1454 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1455
70148
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1456 /* The menu items are different, so store them in the frame. */
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1457 f->menu_bar_vector = menu_items;
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1458 f->menu_bar_items_used = menu_items_used;
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1459
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1460 /* This calls restore_menu_items to restore menu_items, etc.,
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1461 as they were outside. */
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1462 unbind_to (specpdl_count, Qnil);
a2348b30cc21 (restore_menu_items, save_menu_items): New functions from xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69962
diff changeset
1463
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1464 /* Now GC cannot happen during the lifetime of the widget_value,
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1465 so it's safe to store data from a Lisp_String. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1466 wv = first_wv->contents;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1467 for (i = 0; i < XVECTOR (items)->size; i += 4)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1468 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1469 Lisp_Object string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1470 string = XVECTOR (items)->contents[i + 1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1471 if (NILP (string))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1472 break;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1473 wv->name = (char *) SDATA (string);
56849
49d188f9179f * macmenu.c (_widget_value): Added lname and lkey.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56842
diff changeset
1474 update_submenu_strings (wv->contents);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1475 wv = wv->next;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1476 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1477
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1478 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1479 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1480 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1481 /* Make a widget-value tree containing
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1482 just the top level menu bar strings. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1483
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1484 wv = xmalloc_widget_value ();
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1485 wv->name = "menubar";
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1486 wv->value = 0;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1487 wv->enabled = 1;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1488 wv->button_type = BUTTON_TYPE_NONE;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1489 wv->help = Qnil;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1490 first_wv = wv;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1491
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1492 items = FRAME_MENU_BAR_ITEMS (f);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1493 for (i = 0; i < XVECTOR (items)->size; i += 4)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1494 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1495 Lisp_Object string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1496
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1497 string = XVECTOR (items)->contents[i + 1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1498 if (NILP (string))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1499 break;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1500
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1501 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
1502 wv->name = (char *) SDATA (string);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1503 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1504 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1505 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1506 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1507 /* This prevents lwlib from assuming this
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1508 menu item is really supposed to be empty. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1509 /* The EMACS_INT cast avoids a warning.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1510 This value just has to be different from small integers. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1511 wv->call_data = (void *) (EMACS_INT) (-1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1512
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1513 if (prev_wv)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1514 prev_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1515 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1516 first_wv->contents = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1517 prev_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1518 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1519
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1520 /* Forget what we thought we knew about what is in the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1521 detailed contents of the menu bar menus.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1522 Changing the top level always destroys the contents. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1523 f->menu_bar_items_used = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1524 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1525
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1526 /* Create or update the menu bar widget. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1527
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1528 BLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1529
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1530 /* Non-null value to indicate menubar has already been "created". */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1531 f->output_data.mac->menubar_widget = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1532
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1533 mac_fill_menubar (first_wv->contents, deep_p);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1534
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1535 free_menubar_widget_value_tree (first_wv);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1536
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1537 UNBLOCK_INPUT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1538 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1539
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1540 /* Get rid of the menu bar of frame F, and free its storage.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1541 This is used when deleting a frame, and when turning off the menu bar. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1542
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1543 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1544 free_frame_menubar (f)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1545 FRAME_PTR f;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1546 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1547 f->output_data.mac->menubar_widget = 0;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1548 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1549
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1550
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1551 /* The item selected in the popup menu. */
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1552 int menu_item_selection;
63099
a817e29f8ce0 * macmenu.c (menu_quit_handler, install_menu_quit_handler): New
Jan Djärv <jan.h.d@swipnet.se>
parents: 62988
diff changeset
1553
a817e29f8ce0 * macmenu.c (menu_quit_handler, install_menu_quit_handler): New
Jan Djärv <jan.h.d@swipnet.se>
parents: 62988
diff changeset
1554 /* Mac_menu_show actually displays a menu using the panes and items in
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1555 menu_items and returns the value selected from it; we assume input
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1556 is blocked by the caller. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1557
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1558 /* F is the frame the menu is for.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1559 X and Y are the frame-relative specified position,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1560 relative to the inside upper left corner of the frame F.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1561 FOR_CLICK is nonzero if this menu was invoked for a mouse click.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1562 KEYMAPS is 1 if this menu was specified with keymaps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1563 in that case, we return a list containing the chosen item's value
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1564 and perhaps also the pane's prefix.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1565 TITLE is the specified menu title.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1566 ERROR is a place to store an error message string in case of failure.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1567 (We return nil on failure, but the value doesn't actually matter.) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1568
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1569 static Lisp_Object
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1570 mac_menu_show (f, x, y, for_click, keymaps, title, error)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1571 FRAME_PTR f;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1572 int x;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1573 int y;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1574 int for_click;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1575 int keymaps;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1576 Lisp_Object title;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1577 char **error;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1578 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1579 int i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1580 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1581 widget_value **submenu_stack
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1582 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1583 Lisp_Object *subprefix_stack
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1584 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1585 int submenu_depth = 0;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1586
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1587 int first_pane;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1588
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1589 *error = NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1590
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1591 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1592 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1593 *error = "Empty menu";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1594 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1595 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1596
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1597 /* Create a tree of widget_value objects
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1598 representing the panes and their items. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1599 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1600 wv->name = "menu";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1601 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1602 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1603 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1604 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1605 first_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1606 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1607
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1608 /* Loop over all panes and items, filling in the tree. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1609 i = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1610 while (i < menu_items_used)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1611 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1612 if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1613 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1614 submenu_stack[submenu_depth++] = save_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1615 save_wv = prev_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1616 prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1617 first_pane = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1618 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1619 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1620 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1621 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1622 prev_wv = save_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1623 save_wv = submenu_stack[--submenu_depth];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1624 first_pane = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1625 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1626 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1627 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1628 && submenu_depth != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1629 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1630 /* Ignore a nil in the item list.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1631 It's meaningful only for dialog boxes. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1632 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1633 i += 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1634 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1635 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1636 /* Create a new pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1637 Lisp_Object pane_name, prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1638 char *pane_string;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1639
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1640 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1641 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1642
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1643 #ifndef HAVE_MULTILINGUAL_MENU
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1644 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1645 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1646 pane_name = ENCODE_MENU_STRING (pane_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1647 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1648 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1649 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1650 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
1651 ? "" : (char *) SDATA (pane_name));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1652 /* If there is just one top-level pane, put all its items directly
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1653 under the top-level menu. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1654 if (menu_items_n_panes == 1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1655 pane_string = "";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1656
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1657 /* If the pane has a meaningful name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1658 make the pane a top-level menu item
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1659 with its items as a submenu beneath it. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1660 if (!keymaps && strcmp (pane_string, ""))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1661 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1662 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1663 if (save_wv)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1664 save_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1665 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1666 first_wv->contents = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1667 wv->name = pane_string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1668 if (keymaps && !NILP (prefix))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1669 wv->name++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1670 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1671 wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1672 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1673 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1674 save_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1675 prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1676 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1677 else if (first_pane)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1678 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1679 save_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1680 prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1681 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1682 first_pane = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1683 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1684 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1685 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1686 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1687 /* Create a new item within current pane. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1688 Lisp_Object item_name, enable, descrip, def, type, selected, help;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1689 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1690 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1691 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1692 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1693 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1694 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1695 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1696
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1697 #ifndef HAVE_MULTILINGUAL_MENU
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1698 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1699 {
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
1700 item_name = ENCODE_MENU_STRING (item_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1701 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1702 }
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1703
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1704 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1705 {
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
1706 descrip = ENCODE_MENU_STRING (descrip);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1707 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1708 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1709 #endif /* not HAVE_MULTILINGUAL_MENU */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1710
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1711 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1712 if (prev_wv)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1713 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1714 else
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1715 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
1716 wv->name = (char *) SDATA (item_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1717 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
1718 wv->key = (char *) SDATA (descrip);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1719 wv->value = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1720 /* Use the contents index as call_data, since we are
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1721 restricted to 16-bits. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1722 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1723 wv->enabled = !NILP (enable);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1724
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1725 if (NILP (type))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1726 wv->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1727 else if (EQ (type, QCtoggle))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1728 wv->button_type = BUTTON_TYPE_TOGGLE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1729 else if (EQ (type, QCradio))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1730 wv->button_type = BUTTON_TYPE_RADIO;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1731 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1732 abort ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1733
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1734 wv->selected = !NILP (selected);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1735
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1736 if (! STRINGP (help))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1737 help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1738
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1739 wv->help = help;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1740
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1741 prev_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1742
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1743 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1744 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1745 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1746
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1747 /* Deal with the title, if it is non-nil. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1748 if (!NILP (title))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1749 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1750 widget_value *wv_title = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1751 widget_value *wv_sep = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1752
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1753 /* Maybe replace this separator with a bitmap or owner-draw item
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1754 so that it looks better. Having two separators looks odd. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1755 wv_sep->name = "--";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1756 wv_sep->next = first_wv->contents;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1757 wv_sep->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1758
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1759 #ifndef HAVE_MULTILINGUAL_MENU
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1760 if (STRING_MULTIBYTE (title))
56799
d2348e1fa995 macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
Steven Tamm <steventamm@mac.com>
parents: 55851
diff changeset
1761 title = ENCODE_MENU_STRING (title);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1762 #endif
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1763
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1764 wv_title->name = (char *) SDATA (title);
63099
a817e29f8ce0 * macmenu.c (menu_quit_handler, install_menu_quit_handler): New
Jan Djärv <jan.h.d@swipnet.se>
parents: 62988
diff changeset
1765 wv_title->enabled = FALSE;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1766 wv_title->title = TRUE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1767 wv_title->button_type = BUTTON_TYPE_NONE;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1768 wv_title->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1769 wv_title->next = wv_sep;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1770 first_wv->contents = wv_title;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1771 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1772
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1773 /* No selection has been chosen yet. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1774 menu_item_selection = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1775
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1776 /* Actually create and show the menu until popped down. */
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1777 create_and_show_popup_menu (f, first_wv, x, y, for_click);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1778
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1779 /* Free the widget_value objects we used to specify the contents. */
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1780 free_menubar_widget_value_tree (first_wv);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1781
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1782 /* Find the selected item, and its pane, to return
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1783 the proper value. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1784 if (menu_item_selection != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1785 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1786 Lisp_Object prefix, entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1787
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1788 prefix = entry = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1789 i = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1790 while (i < menu_items_used)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1791 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1792 if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1793 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1794 subprefix_stack[submenu_depth++] = prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1795 prefix = entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1796 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1797 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1798 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1799 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1800 prefix = subprefix_stack[--submenu_depth];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1801 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1802 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1803 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1804 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1805 prefix
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1806 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1807 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1808 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1809 /* Ignore a nil in the item list.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1810 It's meaningful only for dialog boxes. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1811 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1812 i += 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1813 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1814 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1815 entry
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1816 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
76090
9e1d5ee9152e (mac_menu_show): Call unbind_to early. Use variable
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1817 if (menu_item_selection == i)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1818 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1819 if (keymaps != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1820 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1821 int j;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1822
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1823 entry = Fcons (entry, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1824 if (!NILP (prefix))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1825 entry = Fcons (prefix, entry);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1826 for (j = submenu_depth - 1; j >= 0; j--)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1827 if (!NILP (subprefix_stack[j]))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1828 entry = Fcons (subprefix_stack[j], entry);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1829 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1830 return entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1831 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1832 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1833 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1834 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1835 }
62988
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
1836 else if (!for_click)
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
1837 /* Make "Cancel" equivalent to C-g. */
3ca414a25103 * macmenu.c (cleanup_popup_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 62670
diff changeset
1838 Fsignal (Qquit, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1839
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1840 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1841 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1842
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1843
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1844 #ifdef HAVE_DIALOGS
75199
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
1845 /* Construct native Mac OS dialog based on widget_value tree. */
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
1846
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1847 static char * button_names [] = {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1848 "button1", "button2", "button3", "button4", "button5",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1849 "button6", "button7", "button8", "button9", "button10" };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1850
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1851 static Lisp_Object
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1852 mac_dialog_show (f, keymaps, title, header, error_name)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1853 FRAME_PTR f;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1854 int keymaps;
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1855 Lisp_Object title, header;
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1856 char **error_name;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1857 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1858 int i, nb_buttons=0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1859 char dialog_name[6];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1860
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1861 widget_value *wv, *first_wv = 0, *prev_wv = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1862
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1863 /* Number of elements seen so far, before boundary. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1864 int left_count = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1865 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1866 int boundary_seen = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1867
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1868 *error_name = NULL;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1869
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1870 if (menu_items_n_panes > 1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1871 {
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1872 *error_name = "Multiple panes in dialog box";
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1873 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1874 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1875
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1876 /* Create a tree of widget_value objects
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1877 representing the text label and buttons. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1878 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1879 Lisp_Object pane_name, prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1880 char *pane_string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1881 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1882 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1883 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1884 ? "" : (char *) SDATA (pane_name));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1885 prev_wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1886 prev_wv->value = pane_string;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1887 if (keymaps && !NILP (prefix))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1888 prev_wv->name++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1889 prev_wv->enabled = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1890 prev_wv->name = "message";
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1891 prev_wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1892 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1893
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1894 /* Loop over all panes and items, filling in the tree. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1895 i = MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1896 while (i < menu_items_used)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1897 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1898
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1899 /* Create a new item within current pane. */
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1900 Lisp_Object item_name, enable, descrip;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1901 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1902 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1903 descrip
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1904 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48937
diff changeset
1905
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1906 if (NILP (item_name))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1907 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1908 free_menubar_widget_value_tree (first_wv);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1909 *error_name = "Submenu in dialog items";
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1910 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1911 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1912 if (EQ (item_name, Qquote))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1913 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1914 /* This is the boundary between left-side elts
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1915 and right-side elts. Stop incrementing right_count. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1916 boundary_seen = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1917 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1918 continue;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1919 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1920 if (nb_buttons >= 9)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1921 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1922 free_menubar_widget_value_tree (first_wv);
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1923 *error_name = "Too many dialog items";
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1924 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1925 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1926
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1927 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1928 prev_wv->next = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1929 wv->name = (char *) button_names[nb_buttons];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1930 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
1931 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
1932 wv->value = (char *) SDATA (item_name);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1933 wv->call_data = (void *) i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1934 /* menu item is identified by its index in menu_items table */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1935 wv->enabled = !NILP (enable);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1936 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1937 prev_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1938
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1939 if (! boundary_seen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1940 left_count++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1941
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1942 nb_buttons++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1943 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1944 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1945
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1946 /* If the boundary was not specified,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1947 by default put half on the left and half on the right. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1948 if (! boundary_seen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1949 left_count = nb_buttons - nb_buttons / 2;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1950
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1951 wv = xmalloc_widget_value ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1952 wv->name = dialog_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1953 wv->help = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1954
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1955 /* Frame title: 'Q' = Question, 'I' = Information.
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1956 Can also have 'E' = Error if, one day, we want
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1957 a popup for errors. */
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1958 if (NILP(header))
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1959 dialog_name[0] = 'Q';
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1960 else
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1961 dialog_name[0] = 'I';
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1962
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1963 /* Dialog boxes use a really stupid name encoding
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1964 which specifies how many buttons to use
62669
befffaf3d1cf (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 62282
diff changeset
1965 and how many buttons are on the right. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1966 dialog_name[1] = '0' + nb_buttons;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1967 dialog_name[2] = 'B';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1968 dialog_name[3] = 'R';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1969 /* Number of buttons to put on the right. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1970 dialog_name[4] = '0' + nb_buttons - left_count;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1971 dialog_name[5] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1972 wv->contents = first_wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1973 first_wv = wv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1974 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1975
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1976 /* No selection has been chosen yet. */
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1977 menu_item_selection = 0;
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1978
77625
8e8447aa415f (mac_dialog_show): Apply 2007-04-27 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76534
diff changeset
1979 /* Force a redisplay before showing the dialog. If a frame is created
8e8447aa415f (mac_dialog_show): Apply 2007-04-27 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76534
diff changeset
1980 just before showing the dialog, its contents may not have been fully
8e8447aa415f (mac_dialog_show): Apply 2007-04-27 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76534
diff changeset
1981 drawn. */
8e8447aa415f (mac_dialog_show): Apply 2007-04-27 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76534
diff changeset
1982 Fredisplay (Qt);
8e8447aa415f (mac_dialog_show): Apply 2007-04-27 change for xmenu.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76534
diff changeset
1983
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1984 /* Actually create the dialog. */
75199
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
1985 #if TARGET_API_MAC_CARBON
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
1986 create_and_show_dialog (f, first_wv);
75199
6f528fee9d6d (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75155
diff changeset
1987 #else
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1988 menu_item_selection = mac_dialog (first_wv);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1989 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1990
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1991 /* Free the widget_value objects we used to specify the contents. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1992 free_menubar_widget_value_tree (first_wv);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1993
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1994 /* Find the selected item, and its pane, to return
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
1995 the proper value. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1996 if (menu_item_selection != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1997 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1998 Lisp_Object prefix;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1999
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2000 prefix = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2001 i = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2002 while (i < menu_items_used)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2003 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2004 Lisp_Object entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2005
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2006 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2007 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2008 prefix
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2009 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2010 i += MENU_ITEMS_PANE_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2011 }
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2012 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2013 {
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2014 /* This is the boundary between left-side elts and
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2015 right-side elts. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2016 ++i;
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2017 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2018 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2019 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2020 entry
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2021 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2022 if (menu_item_selection == i)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2023 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2024 if (keymaps != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2025 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2026 entry = Fcons (entry, Qnil);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2027 if (!NILP (prefix))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2028 entry = Fcons (prefix, entry);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2029 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2030 return entry;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2031 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2032 i += MENU_ITEMS_ITEM_LENGTH;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2033 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2034 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2035 }
67715
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2036 else
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2037 /* Make "Cancel" equivalent to C-g. */
69a961190da1 (Qmac_apple_event): Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67704
diff changeset
2038 Fsignal (Qquit, Qnil);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2039
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2040 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2041 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2042 #endif /* HAVE_DIALOGS */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2043
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2044
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2045 /* Is this item a separator? */
80453
07666d9ede23 [!TARGET_API_MAC_CARBON]: Move includes to mactoolbox.c.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80390
diff changeset
2046 int
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2047 name_is_separator (name)
73573
4d143b423b75 (install_menu_quit_handler): Make variable `typesList'
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72984
diff changeset
2048 const char *name;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2049 {
73573
4d143b423b75 (install_menu_quit_handler): Make variable `typesList'
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72984
diff changeset
2050 const char *start = name;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2051
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2052 /* Check if name string consists of only dashes ('-'). */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2053 while (*name == '-') name++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2054 /* Separators can also be of the form "--:TripleSuperMegaEtched"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2055 or "--deep-shadow". We don't implement them yet, se we just treat
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2056 them like normal separators. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2057 return (*name == '\0' || start + 2 == name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2058 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2059 #endif /* HAVE_MENUS */
73787
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2060
76534
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2061 /* Detect if a menu is currently active. */
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2062
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2063 int
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2064 popup_activated ()
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2065 {
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2066 return popup_activated_flag;
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2067 }
388ed021f559 (popup_activated_flag): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 76090
diff changeset
2068
73787
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2069 /* The following is used by delayed window autoselection. */
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2070
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2071 DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2072 doc: /* Return t if a menu or popup dialog is active. */)
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2073 ()
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2074 {
80390
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
2075 #if TARGET_API_MAC_CARBON
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
2076 return (popup_activated ()) ? Qt : Qnil;
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
2077 #else
73787
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2078 /* Always return Qnil since menu selection functions do not return
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2079 until a selection has been made or cancelled. */
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2080 return Qnil;
80390
59863894d837 Replace MenuHandle and GetMenuHandle with MenuRef and
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
2081 #endif
73787
497b9d9c1774 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73694
diff changeset
2082 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2083
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2084 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2085 syms_of_macmenu ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2086 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2087 staticpro (&menu_items);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2088 menu_items = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2089
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2090 Qdebug_on_next_call = intern ("debug-on-next-call");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2091 staticpro (&Qdebug_on_next_call);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2092
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2093 defsubr (&Sx_popup_menu);
73694
124599cd087e (Fmenu_or_popup_active_p): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 73573
diff changeset
2094 defsubr (&Smenu_or_popup_active_p);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2095 #ifdef HAVE_MENUS
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2096 defsubr (&Sx_popup_dialog);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2097 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2098 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2099
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2100 /* arch-tag: 40b2c6c7-b8a9-4a49-b930-1b2707184cce
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
2101 (do not change this comment) */