Mercurial > emacs
annotate lwlib/lwlib-Xlw.c @ 5836:6d7ceb4493e3
(desktop-bug-report): Command deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 07 Feb 1994 21:04:46 +0000 |
parents | 4870efc489ea |
children | ddd8c555b2fc |
rev | line source |
---|---|
5626 | 1 /* The lwlib interface to "xlwmenu" menus. |
2 Copyright (C) 1992 Lucid, Inc. | |
3 | |
4 This file is part of the Lucid Widget Library. | |
5 | |
6 The Lucid Widget Library is free software; you can redistribute it and/or | |
7 modify it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 The Lucid Widget Library is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 #include "lwlib-Xlw.h" | |
21 #include <X11/StringDefs.h> | |
22 #include <X11/IntrinsicP.h> | |
23 #include <X11/ObjectP.h> | |
24 #include <X11/CompositeP.h> | |
25 #include <X11/Shell.h> | |
26 #include "xlwmenu.h" | |
27 | |
28 /* Menu callbacks */ | |
29 static void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
30 pre_hook (w, client_data, call_data) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
31 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
32 XtPointer client_data; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
33 XtPointer call_data; |
5626 | 34 { |
35 widget_instance* instance = (widget_instance*)client_data; | |
36 widget_value* val; | |
37 | |
38 if (w->core.being_destroyed) | |
39 return; | |
40 | |
41 val = lw_get_widget_value_for_widget (instance, w); | |
42 if (instance->info->pre_activate_cb) | |
43 instance->info->pre_activate_cb (w, instance->info->id, | |
44 val ? val->call_data : NULL); | |
45 } | |
46 | |
47 static void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
48 pick_hook (w, client_data, call_data) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
49 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
50 XtPointer client_data; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
51 XtPointer call_data; |
5626 | 52 { |
53 widget_instance* instance = (widget_instance*)client_data; | |
54 widget_value* contents_val = (widget_value*)call_data; | |
55 widget_value* widget_val; | |
56 XtPointer widget_arg; | |
57 | |
58 if (w->core.being_destroyed) | |
59 return; | |
60 | |
61 if (instance->info->selection_cb && contents_val && contents_val->enabled | |
62 && !contents_val->contents) | |
63 instance->info->selection_cb (w, instance->info->id, | |
64 contents_val->call_data); | |
65 | |
66 widget_val = lw_get_widget_value_for_widget (instance, w); | |
67 widget_arg = widget_val ? widget_val->call_data : NULL; | |
68 if (instance->info->post_activate_cb) | |
69 instance->info->post_activate_cb (w, instance->info->id, widget_arg); | |
70 | |
71 } | |
72 | |
73 /* creation functions */ | |
74 static Widget | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
75 xlw_create_menubar (instance) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
76 widget_instance* instance; |
5626 | 77 { |
78 Widget widget = | |
79 XtVaCreateWidget (instance->info->name, xlwMenuWidgetClass, | |
80 instance->parent, | |
81 XtNmenu, instance->info->val, | |
82 0); | |
83 XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); | |
84 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | |
85 return widget; | |
86 } | |
87 | |
88 static Widget | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
89 xlw_create_popup_menu (instance) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
90 widget_instance* instance; |
5626 | 91 { |
92 Widget popup_shell = | |
93 XtCreatePopupShell (instance->info->name, overrideShellWidgetClass, | |
94 instance->parent, NULL, 0); | |
95 | |
96 Widget widget = | |
97 XtVaCreateManagedWidget ("popup", xlwMenuWidgetClass, | |
98 popup_shell, | |
99 XtNmenu, instance->info->val, | |
100 XtNhorizontal, False, | |
101 0); | |
102 | |
103 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | |
104 | |
105 return popup_shell; | |
106 } | |
107 | |
108 widget_creation_entry | |
109 xlw_creation_table [] = | |
110 { | |
111 {"menubar", xlw_create_menubar}, | |
112 {"popup", xlw_create_popup_menu}, | |
113 {NULL, NULL} | |
114 }; | |
115 | |
116 Boolean | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
117 lw_lucid_widget_p (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
118 Widget widget; |
5626 | 119 { |
120 WidgetClass the_class = XtClass (widget); | |
121 if (the_class == xlwMenuWidgetClass) | |
122 return True; | |
123 if (the_class == overrideShellWidgetClass) | |
124 return | |
125 XtClass (((CompositeWidget)widget)->composite.children [0]) | |
126 == xlwMenuWidgetClass; | |
127 return False; | |
128 } | |
129 | |
130 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
131 xlw_update_one_widget (instance, widget, val, deep_p) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
132 widget_instance* instance; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
133 Widget widget; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
134 widget_value* val; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
135 Boolean deep_p; |
5626 | 136 { |
137 XlwMenuWidget mw; | |
138 | |
139 if (XtIsShell (widget)) | |
140 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | |
141 else | |
142 mw = (XlwMenuWidget)widget; | |
143 XtVaSetValues (widget, XtNmenu, val, 0); | |
144 } | |
145 | |
146 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
147 xlw_update_one_value (instance, widget, val) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
148 widget_instance* instance; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
149 Widget widget; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
150 widget_value* val; |
5626 | 151 { |
152 return; | |
153 } | |
154 | |
155 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
156 xlw_pop_instance (instance, up) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
157 widget_instance* instance; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
158 Boolean up; |
5626 | 159 { |
160 } | |
161 | |
162 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
163 xlw_popup_menu (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
164 Widget widget; |
5626 | 165 { |
166 XButtonPressedEvent dummy; | |
167 XlwMenuWidget mw; | |
168 | |
169 if (!XtIsShell (widget)) | |
170 return; | |
171 | |
172 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | |
173 | |
174 dummy.type = ButtonPress; | |
175 dummy.serial = 0; | |
176 dummy.send_event = 0; | |
177 dummy.display = XtDisplay (widget); | |
178 dummy.window = XtWindow (XtParent (widget)); | |
179 dummy.time = CurrentTime; | |
180 dummy.button = 0; | |
181 XQueryPointer (dummy.display, dummy.window, &dummy.root, | |
182 &dummy.subwindow, &dummy.x_root, &dummy.y_root, | |
183 &dummy.x, &dummy.y, &dummy.state); | |
184 | |
185 pop_up_menu (mw, &dummy); | |
186 } | |
187 | |
188 /* Destruction of instances */ | |
189 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
190 xlw_destroy_instance (instance) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
191 widget_instance* instance; |
5626 | 192 { |
193 if (instance->widget) | |
194 XtDestroyWidget (instance->widget); | |
195 } | |
196 |