annotate mac/src/macmenu.c @ 35074:c8a8a9fac723

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