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