annotate lwlib/lwlib-Xaw.c @ 4:b82b59fe008d r19-15b3

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