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