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