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