annotate lwlib/lwlib-Xaw.c @ 105:e59cf502fb45

Added tag r20-1b4 for changeset cf808b4c4290
author cvs
date Mon, 13 Aug 2007 09:16:54 +0200
parents 6a378aca36af
children 6b37e6ddd302
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* The lwlib interface to Athena widgets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of the Lucid Widget Library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 The Lucid Widget Library is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 modify it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 The Lucid Widget Library is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #include "lwlib-Xaw.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <X11/IntrinsicP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <X11/CoreP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <X11/Shell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <X11/Xaw/Scrollbar.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <X11/Xaw/Dialog.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include <X11/Xaw/Form.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include <X11/Xaw/Command.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include <X11/Xaw/Label.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include <X11/Xatom.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 static void xaw_generic_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 lw_xaw_widget_p (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 return (0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 || XtIsSubclass (widget, scrollbarWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 || XtIsSubclass (widget, dialogWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 xaw_update_scrollbar (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 if (val->scrollbar_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 scrollbar_values *data = val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 float widget_shown, widget_topOfThumb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 float new_shown, new_topOfThumb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 * First size and position the scrollbar widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 XtVaSetValues (widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 XtNx, data->scrollbar_x,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 XtNy, data->scrollbar_y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 XtNwidth, data->scrollbar_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 XtNheight, data->scrollbar_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 * Now the size the scrollbar's slider.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 XtVaGetValues (widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 XtNtopOfThumb, &widget_topOfThumb,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 XtNshown, &widget_shown,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 new_shown = (double) data->slider_size /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 new_topOfThumb = (double) (data->slider_position - data->minimum) /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 if (new_shown > 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 new_shown = 1.0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 if (new_shown < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 new_shown = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 if (new_topOfThumb > 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 new_topOfThumb = 1.0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 if (new_topOfThumb < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 new_topOfThumb = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 XawScrollbarSetThumb (widget, new_topOfThumb, new_shown);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #endif /* SCROLLBARS_ATHENA */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 xaw_update_one_widget (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 widget_value *val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 if (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 else if (XtIsSubclass (widget, scrollbarWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 xaw_update_scrollbar (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 else if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 XtVaSetValues (widget, XtNlabel, val->contents->value, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 else if (XtIsSubclass (widget, commandWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Dimension bw = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 XtVaGetValues (widget, XtNborderWidth, &bw, 0);
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
131
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
132 #ifndef LWLIB_DIALOGS_ATHENA3D
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 if (bw == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 /* Don't let buttons end up with 0 borderwidth, that's ugly...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Yeah, all this should really be done through app-defaults files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 or fallback resources, but that's a whole different can of worms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 that I don't feel like opening right now. Making Athena widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 not look like shit is just entirely too much work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 XtVaSetValues (widget, XtNborderWidth, 1, 0);
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
141 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 XtVaSetValues (widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 XtNlabel, val->value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 XtNsensitive, val->enabled,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 /* Force centered button text. Se above. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 XtNjustify, XtJustifyCenter,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 XtRemoveAllCallbacks (widget, XtNcallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 xaw_update_one_value (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 /* This function is not used by the scrollbars and those are the only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 Athena widget implemented at the moment so do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 xaw_destroy_instance (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 if (XtIsSubclass (instance->widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 /* Need to destroy the Shell too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 XtDestroyWidget (XtParent (instance->widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 XtDestroyWidget (instance->widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 xaw_popup_menu (Widget widget, XEvent *event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 /* An Athena menubar has not been implemented. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 xaw_pop_instance (widget_instance *instance, Boolean up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Widget widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 if (up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 /* For dialogs, we need to call XtPopup on the parent instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 of calling XtManageChild on the widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 Also we need to hack the shell's WM_PROTOCOLS to get it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 understand what the close box is supposed to do!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 Display *dpy = XtDisplay (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 Widget shell = XtParent (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 Atom props [2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 int i = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 XChangeProperty (dpy, XtWindow (shell),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 XInternAtom (dpy, "WM_PROTOCOLS", False),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 XA_ATOM, 32, PropModeAppend,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (unsigned char *) props, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 /* Center the widget in its parent. Why isn't this kind of crap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 done automatically? I thought toolkits were supposed to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 life easier?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 unsigned int x, y, w, h;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 Widget topmost = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 w = shell->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 h = shell->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 while (topmost->core.parent && XtIsRealized (topmost->core.parent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 topmost = topmost->core.parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 if (topmost->core.width < w) x = topmost->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 else x = topmost->core.x + ((topmost->core.width - w) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 if (topmost->core.height < h) y = topmost->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 else y = topmost->core.y + ((topmost->core.height - h) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 XtMoveWidget (shell, x, y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 /* Finally, pop it up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 XtPopup (shell, XtGrabNonexclusive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 #endif /* DIALOGS_ATHENA */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 XtManageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 XtUnmanageChild (XtParent (widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 XtUnmanageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 /* Dialog boxes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 static char overrideTrans[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 static XtActionProc wm_delete_window (Widget shell, XtPointer closure,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 XtPointer call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 static XtActionsRec xaw_actions [] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 {"lwlib_delete_dialog", (XtActionProc) wm_delete_window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 static Boolean actions_initted = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 make_dialog (CONST char* name, Widget parent, Boolean pop_up_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 CONST char* shell_title, CONST char* icon_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 Boolean text_input_slot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Boolean radio_box, Boolean list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 int left_buttons, int right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 Arg av [20];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 int ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 int i, bc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 char button_name [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Widget shell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Widget dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Widget button;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 XtTranslations override;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 if (! pop_up_p) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 if (text_input_slot) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 if (radio_box) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 if (list) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 if (! actions_initted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 XtAppContext app = XtWidgetToApplicationContext (parent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 XtAppAddActions (app, xaw_actions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 actions_initted = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 override = XtParseTranslationTable (overrideTrans);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
290 XtSetArg (av[ac], XtNtitle, shell_title); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 XtSetArg (av[ac], XtNallowShellResize, True); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
292 XtSetArg (av[ac], XtNtransientFor, parent); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 parent, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 XtOverrideTranslations (shell, override);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 bc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 button = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 for (i = 0; i < left_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
305 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
306 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
307 XtSetArg (av [ac], XtNright, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
308 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
310 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 if (right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 /* Create a separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 I want the separator to take up the slack between the buttons on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 the right and the buttons on the left (that is I want the buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 after the separator to be packed against the right edge of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 window) but I can't seem to make it do it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
325 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 /* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
327 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
328 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
329 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 XtSetArg (av [ac], XtNlabel, ""); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 XtSetArg (av [ac], XtNresizable, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 XtSetArg (av [ac], XtNsensitive, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 button = XtCreateManagedWidget ("separator",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 /* labelWidgetClass, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 /* This has to be Command to fake out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 the Dialog widget... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 for (i = 0; i < right_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
347 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
348 XtSetArg (av [ac], XtNleft, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
349 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
350 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
352 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 return dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 xaw_create_dialog (widget_instance* instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 char *name = instance->info->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 Widget parent = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 Boolean pop_up_p = instance->pop_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 CONST char *shell_name = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 CONST char *icon_name = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Boolean text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 Boolean radio_box = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Boolean list = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 int total_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 int left_buttons = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 int right_buttons = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 switch (name [0]) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 case 'E': case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 icon_name = "dbox-error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 shell_name = "Error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 case 'I': case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 icon_name = "dbox-info";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 shell_name = "Information";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 case 'L': case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 list = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 case 'P': case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 text_input_slot = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 case 'Q': case 'q':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 shell_name = "Question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 total_buttons = name [1] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 if (name [3] == 'T' || name [3] == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 radio_box = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 else if (name [3])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 right_buttons = name [4] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 left_buttons = total_buttons - right_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 widget = make_dialog (name, parent, pop_up_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 shell_name, icon_name, text_input_slot, radio_box,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 list, left_buttons, right_buttons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 return widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 #endif /* DIALOGS_ATHENA */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Widget instance_widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 XtPointer user_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 lw_internal_update_other_instances (widget, closure, call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 if (! instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 if (widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 instance_widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 if (!instance_widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 user_data = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 XtVaGetValues (widget, XtNuserData, &user_data, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 /* Damn! Athena doesn't give us a way to hang our own data on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 buttons, so we have to go find it... I guess this assumes that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 all instances of a button have the same call data. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 widget_value *val = instance->info->val->contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 char *name = XtName (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 while (val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 if (val->name && !strcmp (val->name, name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 val = val->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 if (! val) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 user_data = val->call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 if (instance->info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 instance->info->selection_cb (widget, id, user_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 #ifdef DIALOGS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 static XtActionProc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 wm_delete_window (Widget shell, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 Widget *kids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 if (! XtIsSubclass (shell, shellWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 XtVaGetValues (shell, XtNchildren, &kids, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (!kids || !*kids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 widget = kids [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 if (! XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 id = lw_get_widget_id (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 if (! id) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 widget_info *info = lw_get_widget_info (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 if (! info) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 if (info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 info->selection_cb (widget, id, (XtPointer) -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 #endif /* DIALOGS_ATHENA */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 /* Scrollbars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 if (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 event_data.slider_value = (int) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if ((int) call_data > 0)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
524 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
525 event_data.action = SCROLLBAR_LINE_DOWN;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 else
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
527 /* event_data.action = SCROLLBAR_PAGE_UP;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
528 event_data.action = SCROLLBAR_LINE_UP;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 scrollbar_values *val =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (scrollbar_values *) instance->info->val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 float percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 if (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 percent = * (float *) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 event_data.slider_value =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 event_data.action = SCROLLBAR_DRAG;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 xaw_create_scrollbar (widget_instance *instance, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
563 Arg av[10];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 int ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
565
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
566 static XtCallbackRec jumpCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
567 { {xaw_scrollbar_jump, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
568
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
569 static XtCallbackRec scrollCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
570 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
571
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
572 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 /* #### This is tacked onto the with and height and completely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 screws our geometry management. We should probably make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 top-level aware of this so that people could have a border but so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 few people use the Athena scrollbar now that it really isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 worth the effort, at least not at the moment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
580 XtSetArg (av [ac], XtNorientation,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
581 vertical ? XtorientVertical : XtorientHorizontal); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
582 XtSetArg (av [ac], "jumpProc", jumpCallbacks); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
583 XtSetArg (av [ac], "scrollProc", scrollCallbacks); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
585 return XtCreateWidget (instance->info->name, scrollbarWidgetClass,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
586 instance->parent, av, ac);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 xaw_create_vertical_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 return xaw_create_scrollbar (instance, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 xaw_create_horizontal_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 return xaw_create_scrollbar (instance, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 #endif /* SCROLLBARS_ATHENA */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 widget_creation_entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 xaw_creation_table [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 #ifdef SCROLLBARS_ATHENA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 {"vertical-scrollbar", xaw_create_vertical_scrollbar},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 {NULL, NULL}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 };