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