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