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