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