Mercurial > hg > xemacs-beta
annotate lwlib/lwlib-Xaw.c @ 5757:6c2aa9851f5e r21-5-34 r21-5-latest-beta
XEmacs 21.5.34 "kale" is released.
| author | Stephen J. Turnbull <stephen@xemacs.org> |
|---|---|
| date | Mon, 24 Jun 2013 02:08:02 +0900 |
| parents | ade4c7e2c6cb |
| children |
| rev | line source |
|---|---|
| 428 | 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 | |
|
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
6 The Lucid Widget Library is free software: you can redistribute it |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
7 and/or modify it under the terms of the GNU General Public License as |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
8 published by the Free Software Foundation, either version 3 of the |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
9 License, or (at your option) any later version. |
| 428 | 10 |
|
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
11 The Lucid Widget Library is distributed in the hope that it will be |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
14 General Public License for more details. |
| 428 | 15 |
| 16 You should have received a copy of the GNU General Public License | |
|
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
17 along with the Lucid Widget Library. If not, see |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
18 <http://www.gnu.org/licenses/>. |
|
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
19 */ |
| 428 | 20 |
| 21 #include <config.h> | |
| 22 #include <stdio.h> | |
| 23 | |
| 24 #ifdef STDC_HEADERS | |
| 25 #include <stdlib.h> | |
| 26 #endif | |
| 27 | |
| 28 #include "lwlib-Xaw.h" | |
| 29 | |
| 30 #include <X11/StringDefs.h> | |
| 31 #include <X11/IntrinsicP.h> | |
| 32 #include <X11/CoreP.h> | |
| 33 #include <X11/Shell.h> | |
| 34 | |
| 35 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 442 | 36 #include ATHENA_Scrollbar_h_ |
| 428 | 37 #endif |
| 38 #ifdef LWLIB_DIALOGS_ATHENA | |
| 442 | 39 #include ATHENA_Dialog_h_ |
| 40 #include ATHENA_Form_h_ | |
| 41 #include ATHENA_Command_h_ | |
| 42 #include ATHENA_Label_h_ | |
| 428 | 43 #endif |
| 44 #ifdef LWLIB_WIDGETS_ATHENA | |
| 442 | 45 #include ATHENA_Toggle_h_ |
| 428 | 46 #include "xlwradio.h" |
| 47 #include "xlwcheckbox.h" | |
| 48 #include "xlwgauge.h" | |
| 442 | 49 #include ATHENA_AsciiText_h_ |
| 428 | 50 #endif |
| 51 #include <X11/Xatom.h> | |
| 52 | |
| 53 static void xaw_generic_callback (Widget, XtPointer, XtPointer); | |
| 54 | |
| 3094 | 55 extern int debug_xft; |
| 428 | 56 |
| 57 Boolean | |
| 58 lw_xaw_widget_p (Widget widget) | |
| 59 { | |
| 60 return (0 | |
| 61 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 62 || XtIsSubclass (widget, scrollbarWidgetClass) | |
| 63 #endif | |
| 64 #ifdef LWLIB_DIALOGS_ATHENA | |
| 65 || XtIsSubclass (widget, dialogWidgetClass) | |
| 66 #endif | |
| 67 #ifdef LWLIB_WIDGETS_ATHENA | |
| 68 || XtIsSubclass (widget, labelWidgetClass) | |
| 69 || XtIsSubclass (widget, toggleWidgetClass) | |
| 70 || XtIsSubclass (widget, gaugeWidgetClass) | |
| 442 | 71 #ifndef NEED_MOTIF |
| 72 || XtIsSubclass (widget, asciiTextWidgetClass) | |
| 428 | 73 #endif |
| 74 #endif | |
| 75 ); | |
| 76 } | |
| 77 | |
| 78 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 79 static void | |
| 80 xaw_update_scrollbar (widget_instance *instance, Widget widget, | |
| 81 widget_value *val) | |
| 82 { | |
| 83 if (val->scrollbar_data) | |
| 84 { | |
| 85 scrollbar_values *data = val->scrollbar_data; | |
| 86 float widget_shown, widget_topOfThumb; | |
| 87 float new_shown, new_topOfThumb; | |
| 88 Arg al [10]; | |
| 89 | |
| 90 /* First size and position the scrollbar widget. */ | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
91 Xt_SET_ARG (al [0], XtNx, data->scrollbar_x); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
92 Xt_SET_ARG (al [1], XtNy, data->scrollbar_y); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
93 Xt_SET_ARG (al [2], XtNwidth, data->scrollbar_width); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
94 Xt_SET_ARG (al [3], XtNheight, data->scrollbar_height); |
| 428 | 95 XtSetValues (widget, al, 4); |
| 96 | |
| 97 /* Now size the scrollbar's slider. */ | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
98 Xt_SET_ARG (al [0], XtNtopOfThumb, &widget_topOfThumb); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
99 Xt_SET_ARG (al [1], XtNshown, &widget_shown); |
| 428 | 100 XtGetValues (widget, al, 2); |
| 101 | |
| 102 new_shown = (double) data->slider_size / | |
| 103 (double) (data->maximum - data->minimum); | |
| 104 | |
| 105 new_topOfThumb = (double) (data->slider_position - data->minimum) / | |
| 106 (double) (data->maximum - data->minimum); | |
| 107 | |
| 108 if (new_shown > 1.0) | |
| 109 new_shown = 1.0; | |
| 110 else if (new_shown < 0) | |
| 111 new_shown = 0; | |
| 112 | |
| 113 if (new_topOfThumb > 1.0) | |
| 114 new_topOfThumb = 1.0; | |
| 115 else if (new_topOfThumb < 0) | |
| 116 new_topOfThumb = 0; | |
| 117 | |
| 118 if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb) | |
| 119 XawScrollbarSetThumb (widget, new_topOfThumb, new_shown); | |
| 120 } | |
| 121 } | |
| 122 #endif /* LWLIB_SCROLLBARS_ATHENA */ | |
| 123 | |
| 124 void | |
| 125 xaw_update_one_widget (widget_instance *instance, Widget widget, | |
| 2286 | 126 widget_value *val, Boolean UNUSED (deep_p)) |
| 428 | 127 { |
| 128 if (0) | |
| 129 ; | |
| 130 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 131 else if (XtIsSubclass (widget, scrollbarWidgetClass)) | |
| 132 { | |
| 133 xaw_update_scrollbar (instance, widget, val); | |
| 134 } | |
| 135 #endif | |
| 442 | 136 #ifdef LWLIB_WIDGETS_ATHENA |
| 137 #ifndef NEED_MOTIF | |
| 138 else if (XtIsSubclass (widget, asciiTextWidgetClass)) | |
| 139 { | |
| 140 } | |
| 141 #endif | |
| 142 #endif | |
| 428 | 143 #ifdef LWLIB_DIALOGS_ATHENA |
| 144 else if (XtIsSubclass (widget, dialogWidgetClass)) | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
145 Xt_SET_VALUE (widget, XtNlabel, val->contents->value); |
| 428 | 146 #endif /* LWLIB_DIALOGS_ATHENA */ |
| 147 #ifdef LWLIB_WIDGETS_ATHENA | |
| 438 | 148 else if (XtClass (widget) == labelWidgetClass) |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
149 Xt_SET_VALUE (widget, XtNlabel, val->value); |
| 428 | 150 #endif /* LWLIB_WIDGETS_ATHENA */ |
| 151 #if defined (LWLIB_DIALOGS_ATHENA) || defined (LWLIB_WIDGETS_ATHENA) | |
| 152 else if (XtIsSubclass (widget, commandWidgetClass)) | |
| 153 { | |
| 154 Arg al [3]; | |
| 155 | |
| 156 #ifndef LWLIB_DIALOGS_ATHENA3D | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
157 { |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
158 Dimension bw = 0; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
159 Xt_GET_VALUE (widget, XtNborderWidth, &bw); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
160 if (bw == 0) |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
161 /* Don't let buttons end up with 0 borderwidth, that's ugly... |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
162 Yeah, all this should really be done through app-defaults files |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
163 or fallback resources, but that's a whole different can of worms |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
164 that I don't feel like opening right now. Making Athena widgets |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
165 not look like shit is just entirely too much work. |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
166 */ |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
167 Xt_SET_VALUE (widget, XtNborderWidth, 1); |
| 428 | 168 } |
| 169 #endif /* ! LWLIB_DIALOGS_ATHENA3D */ | |
| 170 | |
| 442 | 171 lw_remove_accelerator_spec (val->value); |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
172 Xt_SET_ARG (al [0], XtNlabel, val->value); |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
173 Xt_SET_ARG (al [1], XtNsensitive, val->enabled); |
| 428 | 174 /* Force centered button text. See above. */ |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
175 Xt_SET_ARG (al [2], XtNjustify, XtJustifyCenter); |
| 428 | 176 XtSetValues (widget, al, 3); |
| 177 | |
| 178 XtRemoveAllCallbacks (widget, XtNcallback); | |
| 179 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance); | |
| 180 #ifdef LWLIB_WIDGETS_ATHENA | |
| 181 /* set the selected state */ | |
| 182 if (XtIsSubclass (widget, toggleWidgetClass)) | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
183 Xt_SET_VALUE (widget, XtNstate, val->selected); |
| 428 | 184 #endif /* LWLIB_WIDGETS_ATHENA */ |
| 185 } | |
| 186 #endif /* LWLIB_DIALOGS_ATHENA */ | |
| 442 | 187 /* Lastly update our global arg values. */ |
| 188 if (val->args && val->args->nargs) | |
| 189 XtSetValues (widget, val->args->args, val->args->nargs); | |
| 428 | 190 } |
| 191 | |
| 192 void | |
| 193 xaw_update_one_value (widget_instance *instance, Widget widget, | |
| 194 widget_value *val) | |
| 195 { | |
| 196 #ifdef LWLIB_WIDGETS_ATHENA | |
| 197 widget_value *old_wv; | |
| 198 | |
| 199 /* copy the call_data slot into the "return" widget_value */ | |
| 200 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next) | |
| 201 if (!strcmp (val->name, old_wv->name)) | |
| 202 { | |
| 203 val->call_data = old_wv->call_data; | |
| 204 break; | |
| 205 } | |
| 206 | |
| 207 if (XtIsSubclass (widget, toggleWidgetClass)) | |
| 208 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
209 Xt_GET_VALUE (widget, XtNstate, &val->selected); |
| 428 | 210 val->edited = True; |
| 211 } | |
| 212 #ifndef NEED_MOTIF | |
| 213 else if (XtIsSubclass (widget, asciiTextWidgetClass)) | |
| 214 { | |
| 442 | 215 String buf = 0; |
| 216 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
217 Xt_GET_VALUE (widget, XtNstring, &buf); |
| 428 | 218 if (val->value) |
| 442 | 219 { |
| 220 free (val->value); | |
| 221 val->value = 0; | |
| 222 } | |
| 223 /* I don't think this causes a leak. */ | |
| 224 if (buf) | |
| 225 val->value = strdup (buf); | |
| 428 | 226 val->edited = True; |
| 227 } | |
| 228 #endif | |
| 229 #endif /* LWLIB_WIDGETS_ATHENA */ | |
| 230 } | |
| 231 | |
| 232 void | |
| 233 xaw_destroy_instance (widget_instance *instance) | |
| 234 { | |
| 235 #ifdef LWLIB_DIALOGS_ATHENA | |
| 236 if (XtIsSubclass (instance->widget, dialogWidgetClass)) | |
| 237 /* Need to destroy the Shell too. */ | |
| 238 XtDestroyWidget (XtParent (instance->widget)); | |
| 239 else | |
| 240 #endif | |
| 241 XtDestroyWidget (instance->widget); | |
| 242 } | |
| 243 | |
| 244 void | |
| 2286 | 245 xaw_popup_menu (Widget UNUSED (widget), XEvent *UNUSED (event)) |
| 428 | 246 { |
| 247 /* An Athena menubar has not been implemented. */ | |
| 248 return; | |
| 249 } | |
| 250 | |
| 251 void | |
| 252 xaw_pop_instance (widget_instance *instance, Boolean up) | |
| 253 { | |
| 254 Widget widget = instance->widget; | |
| 255 | |
| 256 if (up) | |
| 257 { | |
| 258 #ifdef LWLIB_DIALOGS_ATHENA | |
| 259 if (XtIsSubclass (widget, dialogWidgetClass)) | |
| 260 { | |
| 261 /* For dialogs, we need to call XtPopup on the parent instead | |
| 262 of calling XtManageChild on the widget. | |
| 263 Also we need to hack the shell's WM_PROTOCOLS to get it to | |
| 264 understand what the close box is supposed to do!! | |
| 265 */ | |
| 266 Display *dpy = XtDisplay (widget); | |
| 267 Widget shell = XtParent (widget); | |
| 268 Atom props [2]; | |
| 269 int i = 0; | |
| 270 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False); | |
| 271 XChangeProperty (dpy, XtWindow (shell), | |
| 272 XInternAtom (dpy, "WM_PROTOCOLS", False), | |
| 273 XA_ATOM, 32, PropModeAppend, | |
| 274 (unsigned char *) props, i); | |
| 275 | |
| 276 /* Center the widget in its parent. Why isn't this kind of crap | |
| 277 done automatically? I thought toolkits were supposed to make | |
| 278 life easier? | |
| 279 */ | |
| 280 { | |
| 281 unsigned int x, y, w, h; | |
| 282 Widget topmost = instance->parent; | |
| 283 w = shell->core.width; | |
| 284 h = shell->core.height; | |
| 285 while (topmost->core.parent && | |
| 286 XtIsRealized (topmost->core.parent) && | |
| 287 /* HAVE_SESSION adds an unmapped parent widget that | |
| 288 we should ignore here. */ | |
| 289 topmost->core.parent->core.mapped_when_managed) | |
| 290 topmost = topmost->core.parent; | |
| 291 if (topmost->core.width < w) x = topmost->core.x; | |
| 292 else x = topmost->core.x + ((topmost->core.width - w) / 2); | |
| 293 if (topmost->core.height < h) y = topmost->core.y; | |
| 294 else y = topmost->core.y + ((topmost->core.height - h) / 2); | |
| 295 XtMoveWidget (shell, x, y); | |
| 296 } | |
| 297 | |
| 298 /* Finally, pop it up. */ | |
| 299 XtPopup (shell, XtGrabNonexclusive); | |
| 300 } | |
| 301 else | |
| 302 #endif /* LWLIB_DIALOGS_ATHENA */ | |
| 303 XtManageChild (widget); | |
| 304 } | |
| 305 else | |
| 306 { | |
| 307 #ifdef LWLIB_DIALOGS_ATHENA | |
| 308 if (XtIsSubclass (widget, dialogWidgetClass)) | |
| 309 XtUnmanageChild (XtParent (widget)); | |
| 310 else | |
| 311 #endif | |
| 312 XtUnmanageChild (widget); | |
| 313 } | |
| 314 } | |
| 315 | |
| 316 | |
| 317 #ifdef LWLIB_DIALOGS_ATHENA | |
| 318 /* Dialog boxes */ | |
| 319 | |
| 320 static char overrideTrans[] = | |
| 321 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()"; | |
| 322 static XtActionProc wm_delete_window (Widget shell, XtPointer closure, | |
| 323 XtPointer call_data); | |
| 324 static XtActionsRec xaw_actions [] = { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
325 { (String) "lwlib_delete_dialog", (XtActionProc) wm_delete_window} |
| 428 | 326 }; |
| 327 static Boolean actions_initted = False; | |
| 328 | |
| 329 static Widget | |
| 442 | 330 make_dialog (const char* name, Widget parent, Boolean pop_up_p, |
| 2286 | 331 const char* shell_title, const char* UNUSED (icon_name), |
| 428 | 332 Boolean text_input_slot, |
| 333 Boolean radio_box, Boolean list, | |
| 334 int left_buttons, int right_buttons) | |
| 335 { | |
| 336 Arg av [20]; | |
| 337 int ac = 0; | |
| 338 int i, bc; | |
| 339 char button_name [255]; | |
| 340 Widget shell; | |
| 341 Widget dialog; | |
| 342 Widget button; | |
| 343 XtTranslations override; | |
| 344 | |
| 345 if (! pop_up_p) abort (); /* not implemented */ | |
| 346 if (text_input_slot) abort (); /* not implemented */ | |
| 347 if (radio_box) abort (); /* not implemented */ | |
| 348 if (list) abort (); /* not implemented */ | |
| 349 | |
| 350 if (! actions_initted) | |
| 351 { | |
| 352 XtAppContext app = XtWidgetToApplicationContext (parent); | |
| 353 XtAppAddActions (app, xaw_actions, | |
| 354 sizeof (xaw_actions) / sizeof (xaw_actions[0])); | |
| 355 actions_initted = True; | |
| 356 } | |
| 357 | |
| 358 override = XtParseTranslationTable (overrideTrans); | |
| 359 | |
| 360 ac = 0; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
361 Xt_SET_ARG (av[ac], XtNtitle, shell_title); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
362 Xt_SET_ARG (av[ac], XtNallowShellResize, True); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
363 Xt_SET_ARG (av[ac], XtNtransientFor, parent); ac++; |
| 428 | 364 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass, |
| 365 parent, av, ac); | |
| 366 XtOverrideTranslations (shell, override); | |
| 367 | |
| 368 ac = 0; | |
| 369 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac); | |
| 370 | |
| 371 bc = 0; | |
| 372 button = 0; | |
| 373 for (i = 0; i < left_buttons; i++) | |
| 374 { | |
| 375 ac = 0; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
376 Xt_SET_ARG (av [ac], XtNfromHoriz, button); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
377 Xt_SET_ARG (av [ac], XtNleft, XtChainLeft); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
378 Xt_SET_ARG (av [ac], XtNright, XtChainLeft); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
379 Xt_SET_ARG (av [ac], XtNtop, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
380 Xt_SET_ARG (av [ac], XtNbottom, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
381 Xt_SET_ARG (av [ac], XtNresizable, True); ac++; |
| 428 | 382 sprintf (button_name, "button%d", ++bc); |
| 383 button = XtCreateManagedWidget (button_name, commandWidgetClass, | |
| 384 dialog, av, ac); | |
| 385 } | |
| 386 if (right_buttons) | |
| 387 { | |
| 388 /* Create a separator | |
| 389 | |
| 390 I want the separator to take up the slack between the buttons on | |
| 391 the right and the buttons on the left (that is I want the buttons | |
| 392 after the separator to be packed against the right edge of the | |
| 393 window) but I can't seem to make it do it. | |
| 394 */ | |
| 395 ac = 0; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
396 Xt_SET_ARG (av [ac], XtNfromHoriz, button); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
397 /* Xt_SET_ARG (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */ |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
398 Xt_SET_ARG (av [ac], XtNleft, XtChainLeft); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
399 Xt_SET_ARG (av [ac], XtNright, XtChainRight); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
400 Xt_SET_ARG (av [ac], XtNtop, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
401 Xt_SET_ARG (av [ac], XtNbottom, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
402 Xt_SET_ARG (av [ac], XtNlabel, ""); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
403 Xt_SET_ARG (av [ac], XtNwidth, 30); /* #### aaack!! */ ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
404 Xt_SET_ARG (av [ac], XtNborderWidth, 0); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
405 Xt_SET_ARG (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
406 Xt_SET_ARG (av [ac], XtNresizable, False); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
407 Xt_SET_ARG (av [ac], XtNsensitive, False); ac++; |
| 428 | 408 button = XtCreateManagedWidget ("separator", |
| 409 /* labelWidgetClass, */ | |
| 410 /* This has to be Command to fake out | |
| 411 the Dialog widget... */ | |
| 412 commandWidgetClass, | |
| 413 dialog, av, ac); | |
| 414 } | |
| 415 for (i = 0; i < right_buttons; i++) | |
| 416 { | |
| 417 ac = 0; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
418 Xt_SET_ARG (av [ac], XtNfromHoriz, button); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
419 Xt_SET_ARG (av [ac], XtNleft, XtChainRight); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
420 Xt_SET_ARG (av [ac], XtNright, XtChainRight); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
421 Xt_SET_ARG (av [ac], XtNtop, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
422 Xt_SET_ARG (av [ac], XtNbottom, XtChainBottom); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
423 Xt_SET_ARG (av [ac], XtNresizable, True); ac++; |
| 428 | 424 sprintf (button_name, "button%d", ++bc); |
| 425 button = XtCreateManagedWidget (button_name, commandWidgetClass, | |
| 426 dialog, av, ac); | |
| 427 } | |
| 428 | |
| 429 return dialog; | |
| 430 } | |
| 431 | |
| 432 Widget | |
| 433 xaw_create_dialog (widget_instance* instance) | |
| 434 { | |
| 435 char *name = instance->info->type; | |
| 436 Widget parent = instance->parent; | |
| 437 Widget widget; | |
| 438 Boolean pop_up_p = instance->pop_up_p; | |
| 442 | 439 const char *shell_name = 0; |
| 440 const char *icon_name = 0; | |
| 428 | 441 Boolean text_input_slot = False; |
| 442 Boolean radio_box = False; | |
| 443 Boolean list = False; | |
| 444 int total_buttons; | |
| 445 int left_buttons = 0; | |
| 446 int right_buttons = 1; | |
| 447 | |
| 448 switch (name [0]) { | |
| 449 case 'E': case 'e': | |
| 450 icon_name = "dbox-error"; | |
| 451 shell_name = "Error"; | |
| 452 break; | |
| 453 | |
| 454 case 'I': case 'i': | |
| 455 icon_name = "dbox-info"; | |
| 456 shell_name = "Information"; | |
| 457 break; | |
| 458 | |
| 459 case 'L': case 'l': | |
| 460 list = True; | |
| 461 icon_name = "dbox-question"; | |
| 462 shell_name = "Prompt"; | |
| 463 break; | |
| 464 | |
| 465 case 'P': case 'p': | |
| 466 text_input_slot = True; | |
| 467 icon_name = "dbox-question"; | |
| 468 shell_name = "Prompt"; | |
| 469 break; | |
| 470 | |
| 471 case 'Q': case 'q': | |
| 472 icon_name = "dbox-question"; | |
| 473 shell_name = "Question"; | |
| 474 break; | |
| 475 } | |
| 476 | |
| 477 total_buttons = name [1] - '0'; | |
| 478 | |
| 479 if (name [3] == 'T' || name [3] == 't') | |
| 480 { | |
| 481 text_input_slot = False; | |
| 482 radio_box = True; | |
| 483 } | |
| 484 else if (name [3]) | |
| 485 right_buttons = name [4] - '0'; | |
| 486 | |
| 487 left_buttons = total_buttons - right_buttons; | |
| 488 | |
| 489 widget = make_dialog (name, parent, pop_up_p, | |
| 490 shell_name, icon_name, text_input_slot, radio_box, | |
| 491 list, left_buttons, right_buttons); | |
| 492 | |
| 493 return widget; | |
| 494 } | |
| 495 #endif /* LWLIB_DIALOGS_ATHENA */ | |
| 496 | |
| 497 | |
| 498 static void | |
| 499 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
| 500 { | |
| 501 widget_instance *instance = (widget_instance *) closure; | |
| 502 Widget instance_widget; | |
| 503 LWLIB_ID id; | |
| 504 XtPointer user_data; | |
| 505 #ifdef LWLIB_WIDGETS_ATHENA | |
| 506 /* We want the selected status to change only when we decide it | |
| 507 should change. Yuck but correct. */ | |
| 508 if (XtIsSubclass (widget, toggleWidgetClass)) | |
| 509 { | |
| 510 Boolean check; | |
| 511 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
512 Xt_GET_VALUE (widget, XtNstate, &check); |
| 428 | 513 |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
514 Xt_SET_VALUE (widget, XtNstate, !check); |
| 428 | 515 } |
| 516 #endif /* LWLIB_WIDGETS_ATHENA */ | |
| 517 lw_internal_update_other_instances (widget, closure, call_data); | |
| 518 | |
| 519 if (! instance) | |
| 520 return; | |
| 521 if (widget->core.being_destroyed) | |
| 522 return; | |
| 523 | |
| 524 instance_widget = instance->widget; | |
| 525 if (!instance_widget) | |
| 526 return; | |
| 527 | |
| 528 id = instance->info->id; | |
| 529 | |
| 530 #if 0 | |
| 531 user_data = NULL; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
532 Xt_GET_VALUE (widget, XtNuserData, &user_data); |
| 428 | 533 #else |
| 534 /* Damn! Athena doesn't give us a way to hang our own data on the | |
| 535 buttons, so we have to go find it... I guess this assumes that | |
| 536 all instances of a button have the same call data. | |
| 537 | |
| 538 ... Which is a totally bogus assumption --andyp */ | |
| 539 { | |
| 540 widget_value *val = instance->info->val; | |
| 541 /* If the widget is a buffer/gutter widget then we already have | |
| 542 the one we are looking for, so don't try and descend the widget | |
| 543 tree. */ | |
| 544 if (val->contents) | |
| 545 { | |
| 546 char *name = XtName (widget); | |
| 547 val = val->contents; | |
| 548 while (val) | |
| 549 { | |
| 550 if (val->name && !strcmp (val->name, name)) | |
| 551 break; | |
| 552 val = val->next; | |
| 553 } | |
| 554 if (! val) abort (); | |
| 555 } | |
| 556 user_data = val->call_data; | |
| 557 } | |
| 558 #endif | |
| 559 | |
| 560 if (instance->info->selection_cb) | |
| 561 instance->info->selection_cb (widget, id, user_data); | |
| 562 } | |
| 563 | |
| 564 #ifdef LWLIB_DIALOGS_ATHENA | |
| 565 | |
| 566 static XtActionProc | |
| 2286 | 567 wm_delete_window (Widget shell, XtPointer UNUSED (closure), |
| 568 XtPointer UNUSED (call_data)) | |
| 428 | 569 { |
| 570 LWLIB_ID id; | |
| 571 Widget *kids = 0; | |
| 572 Widget widget; | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
573 |
| 428 | 574 if (! XtIsSubclass (shell, shellWidgetClass)) |
| 575 abort (); | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
576 Xt_GET_VALUE (shell, XtNchildren, &kids); |
| 3958 | 577 if (!kids || !*kids) abort (); |
| 578 | |
| 579 for (widget = *kids; | |
| 580 widget && ! XtIsSubclass (widget, dialogWidgetClass); | |
| 581 widget = *++kids) | |
| 582 ; | |
| 583 if (!widget) abort (); | |
| 584 | |
| 428 | 585 id = lw_get_widget_id (widget); |
| 586 if (! id) abort (); | |
| 587 | |
| 588 { | |
| 589 widget_info *info = lw_get_widget_info (id); | |
| 590 if (! info) abort (); | |
| 591 if (info->selection_cb) | |
| 592 info->selection_cb (widget, id, (XtPointer) -1); | |
| 593 } | |
| 594 | |
| 595 lw_destroy_all_widgets (id); | |
| 596 return NULL; | |
| 597 } | |
| 598 | |
| 599 #endif /* LWLIB_DIALOGS_ATHENA */ | |
| 600 | |
| 601 | |
| 602 /* Scrollbars */ | |
| 603 | |
| 604 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 605 static void | |
| 606 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_data) | |
| 607 { | |
| 608 widget_instance *instance = (widget_instance *) closure; | |
| 609 LWLIB_ID id; | |
| 610 scroll_event event_data; | |
| 611 | |
| 612 if (!instance || widget->core.being_destroyed) | |
| 613 return; | |
| 614 | |
| 615 id = instance->info->id; | |
| 616 event_data.slider_value = (int) call_data; | |
| 617 event_data.time = 0; | |
| 618 | |
| 619 if ((int) call_data > 0) | |
| 620 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/ | |
| 621 event_data.action = SCROLLBAR_LINE_DOWN; | |
| 622 else | |
| 623 /* event_data.action = SCROLLBAR_PAGE_UP;*/ | |
| 624 event_data.action = SCROLLBAR_LINE_UP; | |
| 625 | |
| 626 if (instance->info->pre_activate_cb) | |
| 627 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
| 628 } | |
| 629 | |
| 630 static void | |
| 631 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data) | |
| 632 { | |
| 633 widget_instance *instance = (widget_instance *) closure; | |
| 634 LWLIB_ID id; | |
| 635 scroll_event event_data; | |
| 636 scrollbar_values *val = | |
| 637 (scrollbar_values *) instance->info->val->scrollbar_data; | |
| 638 float percent; | |
| 639 | |
| 640 if (!instance || widget->core.being_destroyed) | |
| 641 return; | |
| 642 | |
| 643 id = instance->info->id; | |
| 644 | |
| 645 percent = * (float *) call_data; | |
| 646 event_data.slider_value = | |
| 647 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum; | |
| 648 | |
| 649 event_data.time = 0; | |
| 650 event_data.action = SCROLLBAR_DRAG; | |
| 651 | |
| 652 if (instance->info->pre_activate_cb) | |
| 653 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
| 654 } | |
| 655 | |
| 656 static Widget | |
| 657 xaw_create_scrollbar (widget_instance *instance, int vertical) | |
| 658 { | |
| 659 Arg av[10]; | |
| 660 int ac = 0; | |
| 661 | |
| 662 static XtCallbackRec jumpCallbacks[2] = | |
| 663 { {xaw_scrollbar_jump, NULL}, {NULL, NULL} }; | |
| 664 | |
| 665 static XtCallbackRec scrollCallbacks[2] = | |
| 666 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} }; | |
| 667 | |
| 668 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance; | |
| 669 | |
| 670 /* #### This is tacked onto the with and height and completely | |
| 671 screws our geometry management. We should probably make the | |
| 672 top-level aware of this so that people could have a border but so | |
| 673 few people use the Athena scrollbar now that it really isn't | |
| 674 worth the effort, at least not at the moment. */ | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
675 Xt_SET_ARG (av [ac], XtNborderWidth, 0); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
676 Xt_SET_ARG (av [ac], XtNorientation, |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
677 vertical ? XtorientVertical : XtorientHorizontal); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
678 Xt_SET_ARG (av [ac], "jumpProc", jumpCallbacks); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
679 Xt_SET_ARG (av [ac], "scrollProc", scrollCallbacks); ac++; |
| 428 | 680 |
| 681 return XtCreateWidget (instance->info->name, scrollbarWidgetClass, | |
| 682 instance->parent, av, ac); | |
| 683 } | |
| 684 | |
| 685 static Widget | |
| 686 xaw_create_vertical_scrollbar (widget_instance *instance) | |
| 687 { | |
| 688 return xaw_create_scrollbar (instance, 1); | |
| 689 } | |
| 690 | |
| 691 static Widget | |
| 692 xaw_create_horizontal_scrollbar (widget_instance *instance) | |
| 693 { | |
| 694 return xaw_create_scrollbar (instance, 0); | |
| 695 } | |
| 696 #endif /* LWLIB_SCROLLBARS_ATHENA */ | |
| 697 | |
| 698 #ifdef LWLIB_WIDGETS_ATHENA | |
| 699 /* glyph widgets */ | |
| 700 static Widget | |
| 701 xaw_create_button (widget_instance *instance) | |
| 702 { | |
| 703 Arg al[20]; | |
| 704 int ac = 0; | |
| 705 Widget button = 0; | |
| 706 widget_value* val = instance->info->val; | |
| 707 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
708 Xt_SET_ARG (al [ac], XtNsensitive, val->enabled); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
709 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
710 Xt_SET_ARG (al [ac], XtNjustify, XtJustifyCenter); ac++; |
| 428 | 711 /* The highlight doesn't appear to be dynamically set which makes it |
| 712 look ugly. I think this may be a LessTif bug but for now we just | |
| 713 get rid of it. */ | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
714 Xt_SET_ARG (al [ac], XtNhighlightThickness, (Dimension)0); ac++; |
| 428 | 715 |
| 716 /* add any args the user supplied for creation time */ | |
| 717 lw_add_value_args_to_args (val, al, &ac); | |
| 718 | |
| 719 if (!val->call_data) | |
| 3094 | 720 button = XtCreateWidget (val->name, labelWidgetClass, |
| 428 | 721 instance->parent, al, ac); |
| 722 | |
| 723 else | |
| 724 { | |
| 725 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE) | |
| 726 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
727 Xt_SET_ARG (al [ac], XtNstate, val->selected); ac++; |
| 3094 | 728 button = XtCreateWidget |
| 428 | 729 (val->name, |
| 730 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass, | |
| 731 instance->parent, al, ac); | |
| 732 } | |
| 733 else | |
| 734 { | |
| 3094 | 735 button = XtCreateWidget (val->name, commandWidgetClass, |
| 428 | 736 instance->parent, al, ac); |
| 737 } | |
| 738 XtRemoveAllCallbacks (button, XtNcallback); | |
| 739 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance); | |
| 740 } | |
| 741 | |
| 3094 | 742 /* #### this maybe can be folded into the XtCreateWidget calls above */ |
| 428 | 743 XtManageChild (button); |
| 744 | |
| 745 return button; | |
| 746 } | |
| 747 | |
| 748 static Widget | |
| 749 xaw_create_label_field (widget_instance *instance) | |
| 750 { | |
| 751 return xaw_create_label (instance->parent, instance->info->val); | |
| 752 } | |
| 753 | |
| 754 Widget | |
| 755 xaw_create_label (Widget parent, widget_value* val) | |
| 756 { | |
| 757 Arg al[20]; | |
| 758 int ac = 0; | |
| 759 Widget label = 0; | |
| 760 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
761 Xt_SET_ARG (al [ac], XtNsensitive, val->enabled); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
762 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
763 Xt_SET_ARG (al [ac], XtNjustify, XtJustifyCenter); ac++; |
| 428 | 764 |
| 765 /* add any args the user supplied for creation time */ | |
| 766 lw_add_value_args_to_args (val, al, &ac); | |
| 767 | |
| 768 label = XtCreateManagedWidget (val->name, labelWidgetClass, | |
| 769 parent, al, ac); | |
| 770 | |
| 3094 | 771 /* Do it again for arguments that have no effect until the widget is realized. |
| 772 #### Uh, but the widget isn't realized until later? Do we mean "created"? */ | |
| 428 | 773 ac = 0; |
| 774 lw_add_value_args_to_args (val, al, &ac); | |
| 442 | 775 if (ac > 20) |
| 776 abort (); /* #### need assert macro in lwlib */ | |
| 428 | 777 XtSetValues (label, al, ac); |
| 778 | |
| 779 return label; | |
| 780 } | |
| 781 | |
| 3094 | 782 static int debug_gauge = 0; |
| 783 | |
| 784 static void | |
| 785 lw_debug_print_xt_arglist (ArgList al, int ac) | |
| 786 { | |
| 787 int i; | |
| 788 for (i = 0; i < ac; i++) | |
| 789 fprintf (stderr, "Widget has arg %s with value %lu.\n", | |
| 790 al[i].name, (unsigned long) al[i].value); | |
| 791 } | |
| 792 | |
| 793 static void | |
| 794 lw_debug_print_class_resources (WidgetClass class_) | |
| 795 { | |
| 796 Cardinal i; | |
| 797 do { | |
| 798 Cardinal m, n = class_->core_class.num_resources; | |
| 799 XtResourceList rl; | |
| 800 fprintf (stderr, "Class is %s (%p/%p) with %d resources.\n", | |
| 801 class_->core_class.class_name, class_, &(class_->core_class), n); | |
| 802 fprintf (stderr, " Class's resources are at %p. Converting...\n", | |
| 803 class_->core_class.resources); | |
| 804 /* resources may be compiled to an internal format */ | |
| 805 XtGetResourceList (class_, &rl, &m); | |
| 806 for (i = 0; i < m; i++) | |
| 807 fprintf (stderr, | |
| 808 " Class has a %s resource of type %s initialized from %s.\n", | |
| 809 rl[i].resource_class, rl[i].resource_type, rl[i].default_type); | |
| 810 /* special cases for commonly problematic resources */ | |
| 811 for (i = 0; i < m; i++) | |
| 812 { | |
| 813 if (!strcmp (rl[i].resource_class, "Font")) | |
| 814 { | |
| 815 fprintf (stderr, " Class has a Font resource.\n"); | |
| 816 fprintf (stderr, " Font resource is %s.\n", | |
| 817 (char *) rl[i].default_addr); | |
| 818 } | |
| 819 if (!strcmp (rl[i].resource_class, "FontSet")) | |
| 820 { | |
| 821 fprintf (stderr, " Class has a FontSet resource.\n"); | |
| 822 fprintf (stderr, " FontSet resource is %s.\n", | |
| 823 (char *) rl[i].default_addr); | |
| 824 } | |
| 825 if (!strcmp (rl[i].resource_class, "International")) | |
| 826 { | |
| 827 fprintf (stderr, " Class has an International resource.\n"); | |
| 3374 | 828 fprintf (stderr, " International resource is %p.\n", |
| 829 rl[i].default_addr); | |
| 3094 | 830 } |
| 831 } | |
| 832 class_ = class_->core_class.superclass; | |
| 833 } while (class_ != NULL); | |
| 834 } | |
| 835 | |
| 428 | 836 static Widget |
| 837 xaw_create_progress (widget_instance *instance) | |
| 838 { | |
| 839 Arg al[20]; | |
| 840 int ac = 0; | |
| 841 Widget scale = 0; | |
| 842 widget_value* val = instance->info->val; | |
| 442 | 843 #if 0 /* This looks too awful, although more correct. */ |
| 428 | 844 if (!val->call_data) |
| 845 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
846 Xt_SET_ARG (al [ac], XtNsensitive, False); ac++; |
| 428 | 847 } |
| 848 else | |
| 849 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
850 Xt_SET_ARG (al [ac], XtNsensitive, val->enabled); ac++; |
| 428 | 851 } |
| 442 | 852 #else |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
853 Xt_SET_ARG (al [ac], XtNsensitive, True); ac++; |
| 442 | 854 #endif |
| 855 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
856 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
857 Xt_SET_ARG (al [ac], XtNorientation, XtorientHorizontal); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
858 Xt_SET_ARG (al [ac], XtNhighlightThickness, (Dimension)0); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
859 Xt_SET_ARG (al [ac], XtNntics, (Cardinal)10); ac++; |
| 428 | 860 |
| 861 /* add any args the user supplied for creation time */ | |
| 862 lw_add_value_args_to_args (val, al, &ac); | |
| 863 | |
| 3094 | 864 if (debug_gauge > 1) |
| 865 lw_debug_print_class_resources (gaugeWidgetClass); | |
| 866 if (debug_gauge > 0) | |
| 867 lw_debug_print_xt_arglist (al, ac); | |
| 868 | |
| 869 scale = XtCreateWidget (val->name, gaugeWidgetClass, | |
| 870 instance->parent, al, ac); | |
| 871 | |
| 428 | 872 /* add the callback */ |
| 873 if (val->call_data) | |
| 3094 | 874 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, |
| 875 (XtPointer) instance); | |
| 428 | 876 |
| 3094 | 877 /* #### this maybe can be folded into the XtCreateWidget call above */ |
| 428 | 878 XtManageChild (scale); |
| 879 | |
| 880 return scale; | |
| 881 } | |
| 882 | |
| 460 | 883 #if defined(LWLIB_WIDGETS_ATHENA) |
| 442 | 884 #define TEXT_BUFFER_SIZE 128 |
| 428 | 885 static Widget |
| 886 xaw_create_text_field (widget_instance *instance) | |
| 887 { | |
| 888 Arg al[20]; | |
| 889 int ac = 0; | |
| 890 Widget text = 0; | |
| 891 widget_value* val = instance->info->val; | |
| 892 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
893 Xt_SET_ARG (al [ac], XtNsensitive, val->enabled); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
894 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
895 Xt_SET_ARG (al [ac], XtNhighlightThickness, (Dimension)0); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
896 Xt_SET_ARG (al [ac], XtNtype, XawAsciiString); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
897 Xt_SET_ARG (al [ac], XtNeditType, XawtextEdit); ac++; |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
898 Xt_SET_ARG (al [ac], XtNuseStringInPlace, False); ac++; |
| 442 | 899 #if 0 |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
900 Xt_SET_ARG (al [ac], XtNlength, TEXT_BUFFER_SIZE); ac++; |
| 442 | 901 #endif |
| 902 if (val->value) | |
| 903 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
904 Xt_SET_ARG (al [ac], XtNstring, val->value); ac++; |
| 442 | 905 } |
| 428 | 906 |
| 907 /* add any args the user supplied for creation time */ | |
| 908 lw_add_value_args_to_args (val, al, &ac); | |
| 909 | |
| 3094 | 910 text = XtCreateWidget (val->name, asciiTextWidgetClass, |
| 428 | 911 instance->parent, al, ac); |
| 442 | 912 |
| 913 /* add the callback */ | |
| 914 if (val->call_data) | |
| 915 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance); | |
| 916 | |
| 428 | 917 XtManageChild (text); |
| 918 | |
| 919 return text; | |
| 920 } | |
| 921 #endif | |
| 442 | 922 |
| 428 | 923 #endif /* LWLIB_WIDGETS_ATHENA */ |
| 924 | |
| 450 | 925 const widget_creation_entry |
| 428 | 926 xaw_creation_table [] = |
| 927 { | |
| 928 #ifdef LWLIB_SCROLLBARS_ATHENA | |
| 929 {"vertical-scrollbar", xaw_create_vertical_scrollbar }, | |
| 930 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar }, | |
| 931 #endif | |
| 932 #ifdef LWLIB_WIDGETS_ATHENA | |
| 933 {"button", xaw_create_button }, | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
934 {"label", xaw_create_label_field }, |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
935 {"text-field", xaw_create_text_field }, |
| 428 | 936 {"progress", xaw_create_progress }, |
| 937 #endif | |
| 938 {NULL, NULL} | |
| 939 }; | |
| 940 |
