| File: | DisplayList.c |
| Location: | line 1912, column 21 |
| Description: | Null pointer passed as an argument to a 'nonnull' parameter |
| 1 | /* | ||
| 2 | * Copyright (c) 1998 by The XFree86 Project, Inc. | ||
| 3 | * | ||
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | * copy of this software and associated documentation files (the "Software"), | ||
| 6 | * to deal in the Software without restriction, including without limitation | ||
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | * Software is furnished to do so, subject to the following conditions: | ||
| 10 | * | ||
| 11 | * The above copyright notice and this permission notice shall be included in | ||
| 12 | * all copies or substantial portions of the Software. | ||
| 13 | * | ||
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 17 | * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 20 | * SOFTWARE. | ||
| 21 | * | ||
| 22 | * Except as contained in this notice, the name of the XFree86 Project shall | ||
| 23 | * not be used in advertising or otherwise to promote the sale, use or other | ||
| 24 | * dealings in this Software without prior written authorization from the | ||
| 25 | * XFree86 Project. | ||
| 26 | * | ||
| 27 | * Author: Paulo César Pereira de Andrade | ||
| 28 | */ | ||
| 29 | |||
| 30 | #ifdef HAVE_CONFIG_H1 | ||
| 31 | #include <config.h> | ||
| 32 | #endif | ||
| 33 | #include <ctype.h> | ||
| 34 | #include <string.h> | ||
| 35 | #include <stdio.h> | ||
| 36 | #include <stdlib.h> | ||
| 37 | #include <X11/IntrinsicP.h> | ||
| 38 | #include <X11/StringDefs.h> | ||
| 39 | #include <X11/CoreP.h> | ||
| 40 | #include <X11/Xfuncs.h> | ||
| 41 | #include <X11/Xmu/CharSet.h> | ||
| 42 | #include "Private.h" | ||
| 43 | |||
| 44 | #ifdef __UNIXOS2__ | ||
| 45 | static char dummy; | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #ifndef OLDXAW | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Types | ||
| 52 | */ | ||
| 53 | typedef struct _XawDLProc XawDLProc; | ||
| 54 | typedef struct _XawDLData XawDLData; | ||
| 55 | typedef struct _XawDLInfo XawDLInfo; | ||
| 56 | |||
| 57 | struct _XawDLProc { | ||
| 58 | XrmQuark qname; | ||
| 59 | String *params; | ||
| 60 | Cardinal num_params; | ||
| 61 | XawDisplayListProc proc; | ||
| 62 | XtPointer args; | ||
| 63 | XawDLData *data; | ||
| 64 | }; | ||
| 65 | |||
| 66 | struct _XawDLData { | ||
| 67 | XawDLClass *dlclass; | ||
| 68 | XtPointer data; | ||
| 69 | }; | ||
| 70 | |||
| 71 | struct _XawDLInfo { | ||
| 72 | String name; | ||
| 73 | XrmQuark qname; | ||
| 74 | XawDisplayListProc proc; | ||
| 75 | }; | ||
| 76 | |||
| 77 | struct _XawDL { | ||
| 78 | XawDLProc **procs; | ||
| 79 | Cardinal num_procs; | ||
| 80 | XawDLData **data; | ||
| 81 | Cardinal num_data; | ||
| 82 | Screen *screen; | ||
| 83 | Colormap colormap; | ||
| 84 | int depth; | ||
| 85 | XrmQuark qrep; /* for cache lookup */ | ||
| 86 | }; | ||
| 87 | |||
| 88 | struct _XawDLClass { | ||
| 89 | String name; | ||
| 90 | XawDLInfo **infos; | ||
| 91 | Cardinal num_infos; | ||
| 92 | XawDLArgsInitProc args_init; | ||
| 93 | XawDLArgsDestructor args_destructor; | ||
| 94 | XawDLDataInitProc data_init; | ||
| 95 | XawDLDataDestructor data_destructor; | ||
| 96 | }; | ||
| 97 | |||
| 98 | /* | ||
| 99 | * Private Methods | ||
| 100 | */ | ||
| 101 | static XawDLClass *_XawFindDLClass(String); | ||
| 102 | static int qcmp_dlist_class(_Xconstconst void*, _Xconstconst void*); | ||
| 103 | static int bcmp_dlist_class(_Xconstconst void*, _Xconstconst void*); | ||
| 104 | static XawDLInfo *_XawFindDLInfo(XawDLClass*, String); | ||
| 105 | static int qcmp_dlist_info(_Xconstconst void*, _Xconstconst void*); | ||
| 106 | static int bcmp_dlist_info(_Xconstconst void*, _Xconstconst void*); | ||
| 107 | static void *_Xaw_Xlib_ArgsInitProc(String, String*, Cardinal*, | ||
| 108 | Screen*, Colormap, int); | ||
| 109 | static void _Xaw_Xlib_ArgsDestructor(Display*, String, XtPointer, | ||
| 110 | String*, Cardinal*); | ||
| 111 | static void *_Xaw_Xlib_DataInitProc(String, Screen*, Colormap, int); | ||
| 112 | static void _Xaw_Xlib_DataDestructor(Display*, String, XtPointer); | ||
| 113 | |||
| 114 | /* | ||
| 115 | * Initialization | ||
| 116 | */ | ||
| 117 | static XawDLClass **classes; | ||
| 118 | static Cardinal num_classes; | ||
| 119 | static String xlib = "xlib"; | ||
| 120 | |||
| 121 | /* | ||
| 122 | * Implementation | ||
| 123 | */ | ||
| 124 | void | ||
| 125 | XawRunDisplayList(Widget w, _XawDisplayList *list, | ||
| 126 | XEvent *event, Region region) | ||
| 127 | { | ||
| 128 | XawDLProc *proc; | ||
| 129 | Cardinal i; | ||
| 130 | |||
| 131 | if (!XtIsRealized(w)(XtWindowOfObject(w) != 0L)) | ||
| 132 | return; | ||
| 133 | |||
| 134 | for (i = 0; i < list->num_procs; i++) | ||
| 135 | { | ||
| 136 | proc = list->procs[i]; | ||
| 137 | proc->proc(w, proc->args, proc->data->data, event, region); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | #define DLERR-2 -2 | ||
| 142 | #define DLEOF-1 -1 | ||
| 143 | #define DLEND1 1 | ||
| 144 | #define DLNAME2 2 | ||
| 145 | #define DLARG3 3 | ||
| 146 | static char * | ||
| 147 | read_token(char *src, char *dst, Cardinal size, int *status) | ||
| 148 | { | ||
| 149 | int ch; | ||
| 150 | Boolint esc, quote; | ||
| 151 | Cardinal i; | ||
| 152 | |||
| 153 | i = 0; | ||
| 154 | esc = quote = False0; | ||
| 155 | |||
| 156 | /*CONSTCOND*/ | ||
| 157 | while (1) | ||
| 158 | { | ||
| 159 | ch = *src; | ||
| 160 | if (ch != '\n' && isspace(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)) | ||
| 161 | ++src; | ||
| 162 | else | ||
| 163 | break; | ||
| 164 | } | ||
| 165 | |||
| 166 | for (; i < size - 1; src++) | ||
| 167 | { | ||
| 168 | ch = *src; | ||
| 169 | if (ch == '"') | ||
| 170 | { | ||
| 171 | if (quote) | ||
| 172 | { | ||
| 173 | quote = False0; | ||
| 174 | continue; | ||
| 175 | } | ||
| 176 | quote = True1; | ||
| 177 | continue; | ||
| 178 | } | ||
| 179 | if (ch == '\\') | ||
| 180 | { | ||
| 181 | if (esc) | ||
| 182 | { | ||
| 183 | dst[i++] = ch; | ||
| 184 | esc = False0; | ||
| 185 | continue; | ||
| 186 | } | ||
| 187 | esc = True1; | ||
| 188 | continue; | ||
| 189 | } | ||
| 190 | if (ch == '\0') | ||
| 191 | { | ||
| 192 | *status = DLEOF-1; | ||
| 193 | dst[i] = '\0'; | ||
| 194 | return (src); | ||
| 195 | } | ||
| 196 | else if (!esc) | ||
| 197 | { | ||
| 198 | if (!quote) | ||
| 199 | { | ||
| 200 | if (ch == ',') | ||
| 201 | { | ||
| 202 | *status = DLARG3; | ||
| 203 | dst[i] = '\0'; | ||
| 204 | return (++src); | ||
| 205 | } | ||
| 206 | else if (ch == ' ' || ch == '\t') | ||
| 207 | { | ||
| 208 | *status = DLNAME2; | ||
| 209 | dst[i] = '\0'; | ||
| 210 | return (++src); | ||
| 211 | } | ||
| 212 | else if (ch == ';' || ch == '\n') | ||
| 213 | { | ||
| 214 | *status = DLEND1; | ||
| 215 | dst[i] = '\0'; | ||
| 216 | return (++src); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | } | ||
| 220 | else | ||
| 221 | esc = False0; | ||
| 222 | dst[i++] = ch; | ||
| 223 | } | ||
| 224 | |||
| 225 | *status = DLERR-2; | ||
| 226 | dst[i] = '\0'; | ||
| 227 | |||
| 228 | return (src); | ||
| 229 | } | ||
| 230 | |||
| 231 | _XawDisplayList *XawCreateDisplayList(String string, Screen *screen, | ||
| 232 | Colormap colormap, int depth) | ||
| 233 | { | ||
| 234 | _XawDisplayList *dlist; | ||
| 235 | XawDLClass *lc, *xlibc; | ||
| 236 | XawDLData *data; | ||
| 237 | XawDLInfo *info; | ||
| 238 | XawDLProc *proc; | ||
| 239 | char cname[64], fname[64], aname[1024]; | ||
| 240 | Cardinal i; | ||
| 241 | char *cp, *fp, *lp; | ||
| 242 | int status; | ||
| 243 | |||
| 244 | xlibc = XawGetDisplayListClass(xlib); | ||
| 245 | if (!xlibc) | ||
| 246 | { | ||
| 247 | XawDisplayListInitialize(); | ||
| 248 | xlibc = XawGetDisplayListClass(xlib); | ||
| 249 | } | ||
| 250 | |||
| 251 | dlist = (_XawDisplayList *)XtMalloc(sizeof(_XawDisplayList)); | ||
| 252 | dlist->procs = NULL((void*)0); | ||
| 253 | dlist->num_procs = 0; | ||
| 254 | dlist->data = NULL((void*)0); | ||
| 255 | dlist->num_data = 0; | ||
| 256 | dlist->screen = screen; | ||
| 257 | dlist->colormap = colormap; | ||
| 258 | dlist->depth = depth; | ||
| 259 | dlist->qrep = NULLQUARK((XrmQuark) 0); | ||
| 260 | if (!string || !string[0]) | ||
| 261 | return (dlist); | ||
| 262 | |||
| 263 | cp = string; | ||
| 264 | |||
| 265 | status = 0; | ||
| 266 | while (status != DLEOF-1) | ||
| 267 | { | ||
| 268 | lp = cp; | ||
| 269 | cp = read_token(cp, fname, sizeof(fname), &status); | ||
| 270 | |||
| 271 | if (status != DLNAME2 && status != DLEND1 && status != DLEOF-1) | ||
| 272 | { | ||
| 273 | char msg[256]; | ||
| 274 | |||
| 275 | snprintf(msg, sizeof(msg), | ||
| 276 | "Error parsing displayList at \"%s\"", lp); | ||
| 277 | XtAppWarning(XtDisplayToApplicationContext(DisplayOfScreen(screen)((screen)->display)), | ||
| 278 | msg); | ||
| 279 | XawDestroyDisplayList(dlist); | ||
| 280 | return (NULL((void*)0)); | ||
| 281 | } | ||
| 282 | fp = fname; | ||
| 283 | /*CONSTCOND*/ | ||
| 284 | while (1) | ||
| 285 | { | ||
| 286 | fp = strchr(fp, ':'); | ||
| 287 | if (!fp || (fp == cp || fp[-1] != '\\')) | ||
| 288 | break; | ||
| 289 | ++fp; | ||
| 290 | } | ||
| 291 | if (fp) | ||
| 292 | { | ||
| 293 | snprintf(cname, fp - fname + 1, fname); | ||
| 294 | memmove(fname, fp + 1, strlen(fp)); | ||
| 295 | lc = cname[0] ? XawGetDisplayListClass(cname) : xlibc; | ||
| 296 | if (!lc) | ||
| 297 | { | ||
| 298 | char msg[256]; | ||
| 299 | |||
| 300 | snprintf(msg, sizeof(msg), | ||
| 301 | "Cannot find displayList class \"%s\"", cname); | ||
| 302 | XtAppWarning(XtDisplayToApplicationContext | ||
| 303 | (DisplayOfScreen(screen)((screen)->display)), msg); | ||
| 304 | XawDestroyDisplayList(dlist); | ||
| 305 | return (NULL((void*)0)); | ||
| 306 | } | ||
| 307 | } | ||
| 308 | else | ||
| 309 | lc = xlibc; | ||
| 310 | |||
| 311 | if (status == DLEOF-1 && !fname[0]) | ||
| 312 | break; | ||
| 313 | |||
| 314 | if ((info = _XawFindDLInfo(lc, fname)) == NULL((void*)0)) | ||
| 315 | { | ||
| 316 | char msg[256]; | ||
| 317 | |||
| 318 | snprintf(msg, sizeof(msg), | ||
| 319 | "Cannot find displayList procedure \"%s\"", fname); | ||
| 320 | XtAppWarning(XtDisplayToApplicationContext(DisplayOfScreen(screen)((screen)->display)), | ||
| 321 | msg); | ||
| 322 | XawDestroyDisplayList(dlist); | ||
| 323 | return (NULL((void*)0)); | ||
| 324 | } | ||
| 325 | |||
| 326 | proc = (XawDLProc *)XtMalloc(sizeof(XawDLProc)); | ||
| 327 | proc->qname = info->qname; | ||
| 328 | proc->params = NULL((void*)0); | ||
| 329 | proc->num_params = 0; | ||
| 330 | proc->proc = info->proc; | ||
| 331 | proc->args = NULL((void*)0); | ||
| 332 | proc->data = NULL((void*)0); | ||
| 333 | |||
| 334 | if (!dlist->procs) | ||
| 335 | { | ||
| 336 | dlist->num_procs = 1; | ||
| 337 | dlist->procs = (XawDLProc**)XtMalloc(sizeof(XawDLProc*)); | ||
| 338 | } | ||
| 339 | else | ||
| 340 | { | ||
| 341 | ++dlist->num_procs; | ||
| 342 | dlist->procs = (XawDLProc**) | ||
| 343 | XtRealloc((char *)dlist->procs, sizeof(XawDLProc*) * | ||
| 344 | dlist->num_procs); | ||
| 345 | } | ||
| 346 | dlist->procs[dlist->num_procs - 1] = proc; | ||
| 347 | |||
| 348 | while (status != DLEND1 && status != DLEOF-1) | ||
| 349 | { | ||
| 350 | lp = cp; | ||
| 351 | cp = read_token(cp, aname, sizeof(aname), &status); | ||
| 352 | |||
| 353 | if (status != DLARG3 && status != DLEND1 && status != DLEOF-1) | ||
| 354 | { | ||
| 355 | char msg[256]; | ||
| 356 | |||
| 357 | snprintf(msg, sizeof(msg), | ||
| 358 | "Error parsing displayList at \"%s\"", lp); | ||
| 359 | XtAppWarning(XtDisplayToApplicationContext | ||
| 360 | (DisplayOfScreen(screen)((screen)->display)), msg); | ||
| 361 | XawDestroyDisplayList(dlist); | ||
| 362 | return (NULL((void*)0)); | ||
| 363 | } | ||
| 364 | |||
| 365 | if (!proc->num_params) | ||
| 366 | { | ||
| 367 | proc->num_params = 1; | ||
| 368 | proc->params = (String *)XtMalloc(sizeof(String)); | ||
| 369 | } | ||
| 370 | else | ||
| 371 | { | ||
| 372 | ++proc->num_params; | ||
| 373 | proc->params = (String *)XtRealloc((char *)proc->params, | ||
| 374 | sizeof(String) * | ||
| 375 | proc->num_params); | ||
| 376 | } | ||
| 377 | proc->params[proc->num_params - 1] = XtNewString(aname)((aname) != ((void*)0) ? (strcpy(XtMalloc((unsigned)strlen(aname ) + 1), aname)) : ((void*)0)); | ||
| 378 | } | ||
| 379 | |||
| 380 | /* verify if data is already created for lc */ | ||
| 381 | data = NULL((void*)0); | ||
| 382 | for (i = 0; i < dlist->num_data; i++) | ||
| 383 | if (dlist->data[i]->dlclass == lc) | ||
| 384 | { | ||
| 385 | data = dlist->data[i]; | ||
| 386 | break; | ||
| 387 | } | ||
| 388 | |||
| 389 | if (!data) | ||
| 390 | { | ||
| 391 | data = (XawDLData *)XtMalloc(sizeof(XawDLData)); | ||
| 392 | data->dlclass = lc; | ||
| 393 | if (lc->data_init) | ||
| 394 | data->data = lc->data_init(lc->name, screen, colormap, depth); | ||
| 395 | else | ||
| 396 | data->data = NULL((void*)0); | ||
| 397 | |||
| 398 | if (!dlist->data) | ||
| 399 | { | ||
| 400 | dlist->num_data = 1; | ||
| 401 | dlist->data = (XawDLData **)XtMalloc(sizeof(XawDLData*)); | ||
| 402 | } | ||
| 403 | else | ||
| 404 | { | ||
| 405 | ++dlist->num_data; | ||
| 406 | dlist->data = (XawDLData **) | ||
| 407 | XtRealloc((char *)dlist->data, sizeof(XawDLData*) * | ||
| 408 | dlist->num_data); | ||
| 409 | } | ||
| 410 | dlist->data[dlist->num_data - 1] = data; | ||
| 411 | } | ||
| 412 | |||
| 413 | if (lc->args_init) | ||
| 414 | { | ||
| 415 | proc->args = lc->args_init(fname, proc->params, &proc->num_params, | ||
| 416 | screen, colormap, depth); | ||
| 417 | if (proc->args == XAWDL_CONVERT_ERROR(XtPointer)-1) | ||
| 418 | { | ||
| 419 | char msg[256]; | ||
| 420 | |||
| 421 | proc->args = NULL((void*)0); | ||
| 422 | snprintf(msg, sizeof(msg), | ||
| 423 | "Cannot convert arguments to displayList function \"%s\"", | ||
| 424 | fname); | ||
| 425 | XtAppWarning(XtDisplayToApplicationContext | ||
| 426 | (DisplayOfScreen(screen)((screen)->display)), msg); | ||
| 427 | XawDestroyDisplayList(dlist); | ||
| 428 | return (NULL((void*)0)); | ||
| 429 | } | ||
| 430 | } | ||
| 431 | else | ||
| 432 | proc->args = NULL((void*)0); | ||
| 433 | |||
| 434 | proc->data = data; | ||
| 435 | } | ||
| 436 | |||
| 437 | dlist->qrep = XrmStringToQuark(string); | ||
| 438 | return (dlist); | ||
| 439 | } | ||
| 440 | |||
| 441 | String | ||
| 442 | XawDisplayListString(_XawDisplayList *dlist) | ||
| 443 | { | ||
| 444 | if (!dlist || dlist->qrep == NULLQUARK((XrmQuark) 0)) | ||
| 445 | return (""); | ||
| 446 | return (XrmQuarkToString(dlist->qrep)); | ||
| 447 | } | ||
| 448 | |||
| 449 | void | ||
| 450 | XawDestroyDisplayList(_XawDisplayList *dlist) | ||
| 451 | { | ||
| 452 | Cardinal i, j; | ||
| 453 | XawDLProc *proc; | ||
| 454 | XawDLData *data; | ||
| 455 | |||
| 456 | if (!dlist) | ||
| 457 | return; | ||
| 458 | |||
| 459 | for (i = 0; i < dlist->num_procs; i++) | ||
| 460 | { | ||
| 461 | proc = dlist->procs[i]; | ||
| 462 | data = proc->data; | ||
| 463 | |||
| 464 | if (data) | ||
| 465 | { | ||
| 466 | if (data->dlclass->args_destructor) | ||
| 467 | data->dlclass->args_destructor(DisplayOfScreen(dlist->screen)((dlist->screen)->display), | ||
| 468 | XrmQuarkToString(proc->qname), | ||
| 469 | proc->args, | ||
| 470 | proc->params, &proc->num_params); | ||
| 471 | if (data->data) | ||
| 472 | { | ||
| 473 | if (data->dlclass->data_destructor) | ||
| 474 | { | ||
| 475 | data->dlclass | ||
| 476 | ->data_destructor(DisplayOfScreen(dlist->screen)((dlist->screen)->display), | ||
| 477 | data->dlclass->name, data->data); | ||
| 478 | data->data = NULL((void*)0); | ||
| 479 | } | ||
| 480 | } | ||
| 481 | } | ||
| 482 | |||
| 483 | for (j = 0; j < proc->num_params; j++) | ||
| 484 | XtFree(proc->params[j]); | ||
| 485 | if (proc->num_params) | ||
| 486 | XtFree((char *)proc->params); | ||
| 487 | XtFree((char *)proc); | ||
| 488 | } | ||
| 489 | |||
| 490 | if (dlist->num_procs) | ||
| 491 | XtFree((char *)dlist->procs); | ||
| 492 | |||
| 493 | XtFree((char *)dlist); | ||
| 494 | } | ||
| 495 | |||
| 496 | /********************************************************************** | ||
| 497 | * If you want to implement your own class of procedures, look at | ||
| 498 | * the code bellow. | ||
| 499 | **********************************************************************/ | ||
| 500 | /* Start of Implementation of class "xlib" */ | ||
| 501 | typedef struct _XawXlibData { | ||
| 502 | GC gc; | ||
| 503 | unsigned long mask; | ||
| 504 | XGCValues values; | ||
| 505 | int shape; | ||
| 506 | int mode; | ||
| 507 | char *dashes; | ||
| 508 | /* these fields can be used for optimization, to | ||
| 509 | * avoid unnecessary coordinates recalculation. | ||
| 510 | */ | ||
| 511 | Position x, y; | ||
| 512 | Dimension width, height; | ||
| 513 | } XawXlibData; | ||
| 514 | |||
| 515 | typedef struct _XawDLPosition { | ||
| 516 | Position pos; | ||
| 517 | short denom; | ||
| 518 | Boolean high; | ||
| 519 | } XawDLPosition; | ||
| 520 | |||
| 521 | typedef struct _XawDLPositionPtr { | ||
| 522 | XawDLPosition *pos; | ||
| 523 | Cardinal num_pos; | ||
| 524 | } XawDLPositionPtr; | ||
| 525 | |||
| 526 | typedef struct _XawDLArcArgs { | ||
| 527 | XawDLPosition pos[4]; | ||
| 528 | int angle1; | ||
| 529 | int angle2; | ||
| 530 | } XawDLArcArgs; | ||
| 531 | |||
| 532 | typedef struct _XawDLStringArgs { | ||
| 533 | XawDLPosition pos[2]; | ||
| 534 | char *string; | ||
| 535 | int length; | ||
| 536 | } XawDLStringArgs; | ||
| 537 | |||
| 538 | typedef struct _XawDLCopyArgs { | ||
| 539 | XawPixmap *pixmap; | ||
| 540 | XawDLPosition pos[6]; | ||
| 541 | int plane; | ||
| 542 | } XawDLCopyArgs; | ||
| 543 | |||
| 544 | typedef struct _XawDLImageArgs { | ||
| 545 | XawPixmap *pixmap; | ||
| 546 | XawDLPosition pos[4]; | ||
| 547 | int depth; | ||
| 548 | } XawDLImageArgs; | ||
| 549 | |||
| 550 | #define X_ARG(x)(Position)(((x).denom != 0) ? ((float)(((RectObj)w)->rectangle .width) * ((float)(x).pos / (float)(x).denom)) : ((x).high ? ( ((RectObj)w)->rectangle.width) - (x).pos : (x).pos)) (Position)(((x).denom != 0) ? \ | ||
| 551 | ((float)XtWidth(w)(((RectObj)w)->rectangle.width) * ((float)(x).pos / (float)(x).denom)) : \ | ||
| 552 | ((x).high ? XtWidth(w)(((RectObj)w)->rectangle.width) - (x).pos : (x).pos)) | ||
| 553 | #define Y_ARG(x)(Position)(((x).denom != 0) ? ((float)(((RectObj)w)->rectangle .height) * ((float)(x).pos / (float)(x).denom)): ((x).high ? ( ((RectObj)w)->rectangle.height) - (x).pos : (x).pos)) (Position)(((x).denom != 0) ? \ | ||
| 554 | ((float)XtHeight(w)(((RectObj)w)->rectangle.height) * ((float)(x).pos / (float)(x).denom)): \ | ||
| 555 | ((x).high ? XtHeight(w)(((RectObj)w)->rectangle.height) - (x).pos : (x).pos)) | ||
| 556 | #define DRECT0 0 | ||
| 557 | #define FRECT1 1 | ||
| 558 | #define LINE2 2 | ||
| 559 | #define GCFG3 3 | ||
| 560 | #define GCBG4 4 | ||
| 561 | #define FPOLY5 5 | ||
| 562 | #define DARC6 6 | ||
| 563 | #define FARC7 7 | ||
| 564 | #define DLINES8 8 | ||
| 565 | #define MASK9 9 | ||
| 566 | #define UMASK10 10 | ||
| 567 | #define LWIDTH11 11 | ||
| 568 | #define POINT12 12 | ||
| 569 | #define POINTS13 13 | ||
| 570 | #define SEGMENTS14 14 | ||
| 571 | #define ARCMODE15 15 | ||
| 572 | #define COORDMODE16 16 | ||
| 573 | #define SHAPEMODE17 17 | ||
| 574 | #define LINESTYLE18 18 | ||
| 575 | #define CAPSTYLE19 19 | ||
| 576 | #define JOINSTYLE20 20 | ||
| 577 | #define FILLSTYLE21 21 | ||
| 578 | #define FILLRULE22 22 | ||
| 579 | #define TILE23 23 | ||
| 580 | #define STIPPLE24 24 | ||
| 581 | #define TSORIGIN25 25 | ||
| 582 | #define FUNCTION26 26 | ||
| 583 | #define PLANEMASK27 27 | ||
| 584 | #define DSTRING28 28 | ||
| 585 | #define PSTRING29 29 | ||
| 586 | #define FONT30 30 | ||
| 587 | #define DASHES31 31 | ||
| 588 | #define SUBWMODE32 32 | ||
| 589 | #define EXPOSURES33 33 | ||
| 590 | #define CLIPORIGIN34 34 | ||
| 591 | #define CLIPMASK35 35 | ||
| 592 | #define CLIPRECTS36 36 | ||
| 593 | #define COPYAREA37 37 | ||
| 594 | #define COPYPLANE38 38 | ||
| 595 | #define IMAGE39 39 | ||
| 596 | |||
| 597 | static void | ||
| 598 | Dl1Point(Widget w, XtPointer args, XtPointer data, int id) | ||
| 599 | { | ||
| 600 | XawDLPosition *pos = (XawDLPosition *)args; | ||
| 601 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 602 | Display *display; | ||
| 603 | Window window; | ||
| 604 | Position x, y; | ||
| 605 | |||
| 606 | x = X_ARG(pos[0])(Position)(((pos[0]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[0]).pos / (float)(pos[0]).denom )) : ((pos[0]).high ? (((RectObj)w)->rectangle.width) - (pos [0]).pos : (pos[0]).pos)); | ||
| 607 | y = Y_ARG(pos[1])(Position)(((pos[1]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[1]).pos / (float)(pos[1]).denom )): ((pos[1]).high ? (((RectObj)w)->rectangle.height) - (pos [1]).pos : (pos[1]).pos)); | ||
| 608 | |||
| 609 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 610 | { | ||
| 611 | Position xpad, ypad; | ||
| 612 | |||
| 613 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 614 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 615 | x += xpad; | ||
| 616 | y += ypad; | ||
| 617 | display = XtDisplayOfObject(w); | ||
| 618 | window = XtWindowOfObject(w); | ||
| 619 | } | ||
| 620 | else | ||
| 621 | { | ||
| 622 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 623 | window = XtWindow(w)((w)->core.window); | ||
| 624 | } | ||
| 625 | |||
| 626 | if (id == POINT12) | ||
| 627 | XDrawPoint(display, window, xdata->gc, x, y); | ||
| 628 | else if (id == TSORIGIN25) | ||
| 629 | { | ||
| 630 | xdata->values.ts_x_origin = x; | ||
| 631 | xdata->values.ts_y_origin = y; | ||
| 632 | xdata->mask |= GCTileStipXOrigin(1L<<12) | GCTileStipYOrigin(1L<<13); | ||
| 633 | XSetTSOrigin(display, xdata->gc, x, y); | ||
| 634 | } | ||
| 635 | else if (id == CLIPORIGIN34) | ||
| 636 | { | ||
| 637 | xdata->values.clip_x_origin = x; | ||
| 638 | xdata->values.clip_y_origin = y; | ||
| 639 | xdata->mask |= GCClipXOrigin(1L<<17) | GCClipYOrigin(1L<<18); | ||
| 640 | XSetClipOrigin(display, xdata->gc, x, y); | ||
| 641 | } | ||
| 642 | } | ||
| 643 | |||
| 644 | static void | ||
| 645 | Dl2Points(Widget w, XtPointer args, XtPointer data, int id) | ||
| 646 | { | ||
| 647 | XawDLPosition *pos = (XawDLPosition *)args; | ||
| 648 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 649 | Display *display; | ||
| 650 | Window window; | ||
| 651 | Position x1, y1, x2, y2; | ||
| 652 | |||
| 653 | x1 = X_ARG(pos[0])(Position)(((pos[0]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[0]).pos / (float)(pos[0]).denom )) : ((pos[0]).high ? (((RectObj)w)->rectangle.width) - (pos [0]).pos : (pos[0]).pos)); | ||
| 654 | y1 = Y_ARG(pos[1])(Position)(((pos[1]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[1]).pos / (float)(pos[1]).denom )): ((pos[1]).high ? (((RectObj)w)->rectangle.height) - (pos [1]).pos : (pos[1]).pos)); | ||
| 655 | x2 = X_ARG(pos[2])(Position)(((pos[2]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[2]).pos / (float)(pos[2]).denom )) : ((pos[2]).high ? (((RectObj)w)->rectangle.width) - (pos [2]).pos : (pos[2]).pos)); | ||
| 656 | y2 = Y_ARG(pos[3])(Position)(((pos[3]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[3]).pos / (float)(pos[3]).denom )): ((pos[3]).high ? (((RectObj)w)->rectangle.height) - (pos [3]).pos : (pos[3]).pos)); | ||
| 657 | |||
| 658 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 659 | { | ||
| 660 | Position xpad, ypad; | ||
| 661 | |||
| 662 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 663 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 664 | x1 += xpad; y1 += ypad; | ||
| 665 | x2 += xpad; y2 += ypad; | ||
| 666 | display = XtDisplayOfObject(w); | ||
| 667 | window = XtWindowOfObject(w); | ||
| 668 | } | ||
| 669 | else | ||
| 670 | { | ||
| 671 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 672 | window = XtWindow(w)((w)->core.window); | ||
| 673 | } | ||
| 674 | |||
| 675 | if (id == DRECT0) | ||
| 676 | XDrawRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1); | ||
| 677 | else if (id == FRECT1) | ||
| 678 | XFillRectangle(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1); | ||
| 679 | else if (id == LINE2) | ||
| 680 | XDrawLine(display, window, xdata->gc, x1, y1, x2, y2); | ||
| 681 | } | ||
| 682 | |||
| 683 | /* ARGSUSED */ | ||
| 684 | static void | ||
| 685 | DlLine(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) | ||
| 686 | { | ||
| 687 | Dl2Points(w, args, data, LINE2); | ||
| 688 | } | ||
| 689 | |||
| 690 | /* ARGSUSED */ | ||
| 691 | static void | ||
| 692 | DlDrawRectangle(Widget w, XtPointer args, XtPointer data, | ||
| 693 | XEvent *event, Region region) | ||
| 694 | { | ||
| 695 | Dl2Points(w, args, data, DRECT0); | ||
| 696 | } | ||
| 697 | |||
| 698 | /* ARGSUSED */ | ||
| 699 | static void | ||
| 700 | DlFillRectangle(Widget w, XtPointer args, XtPointer data, | ||
| 701 | XEvent *event, Region region) | ||
| 702 | { | ||
| 703 | Dl2Points(w, args, data, FRECT1); | ||
| 704 | } | ||
| 705 | |||
| 706 | static void | ||
| 707 | DlXPoints(Widget w, XtPointer args, XtPointer data, int id) | ||
| 708 | { | ||
| 709 | XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args; | ||
| 710 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 711 | XawDLPosition *pos; | ||
| 712 | XPoint points_buf[16]; | ||
| 713 | XPoint *points; | ||
| 714 | Display *display; | ||
| 715 | Window window; | ||
| 716 | Cardinal num_points, i, j; | ||
| 717 | |||
| 718 | num_points = pos_ptr->num_pos>>1; | ||
| 719 | points = (XPoint *)XawStackAlloc(sizeof(XPoint) * num_points, points_buf)((sizeof(XPoint) * num_points) <= sizeof(points_buf) ? (XtPointer )(points_buf) : XtMalloc((unsigned)(sizeof(XPoint) * num_points ))); | ||
| 720 | |||
| 721 | for (i = j = 0; i < num_points; i++, j = i << 1) | ||
| 722 | { | ||
| 723 | pos = &pos_ptr->pos[j]; | ||
| 724 | points[i].x = X_ARG(pos[0])(Position)(((pos[0]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[0]).pos / (float)(pos[0]).denom )) : ((pos[0]).high ? (((RectObj)w)->rectangle.width) - (pos [0]).pos : (pos[0]).pos)); | ||
| 725 | points[i].y = Y_ARG(pos[1])(Position)(((pos[1]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[1]).pos / (float)(pos[1]).denom )): ((pos[1]).high ? (((RectObj)w)->rectangle.height) - (pos [1]).pos : (pos[1]).pos)); | ||
| 726 | } | ||
| 727 | |||
| 728 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 729 | { | ||
| 730 | Position xpad, ypad; | ||
| 731 | |||
| 732 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 733 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 734 | if (xdata->mode != CoordModePrevious1) | ||
| 735 | { | ||
| 736 | for (i = 0; i < num_points; i++) | ||
| 737 | { | ||
| 738 | points[i].x += xpad; | ||
| 739 | points[i].y += ypad; | ||
| 740 | } | ||
| 741 | } | ||
| 742 | else | ||
| 743 | { | ||
| 744 | points[0].x += xpad; | ||
| 745 | points[0].y += ypad; | ||
| 746 | } | ||
| 747 | display = XtDisplayOfObject(w); | ||
| 748 | window = XtWindowOfObject(w); | ||
| 749 | } | ||
| 750 | else | ||
| 751 | { | ||
| 752 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 753 | window = XtWindow(w)((w)->core.window); | ||
| 754 | } | ||
| 755 | |||
| 756 | if (id == FPOLY5) | ||
| 757 | XFillPolygon(display, window, xdata->gc, points, num_points, | ||
| 758 | xdata->shape, xdata->mode); | ||
| 759 | else if (id == DLINES8) | ||
| 760 | XDrawLines(display, window, xdata->gc, points, num_points, xdata->mode); | ||
| 761 | else if (id == POINTS13) | ||
| 762 | XDrawPoints(display, window, xdata->gc, points, num_points, xdata->mode); | ||
| 763 | |||
| 764 | XawStackFree(points, points_buf)do { if ((points) != (XtPointer)(points_buf)) XtFree((char *) points); } while (0); | ||
| 765 | } | ||
| 766 | |||
| 767 | /* ARGSUSED */ | ||
| 768 | static void | ||
| 769 | DlFillPolygon(Widget w, XtPointer args, XtPointer data, | ||
| 770 | XEvent *event, Region region) | ||
| 771 | { | ||
| 772 | DlXPoints(w, args, data, FPOLY5); | ||
| 773 | } | ||
| 774 | |||
| 775 | /* ARGSUSED */ | ||
| 776 | static void | ||
| 777 | DlDrawLines(Widget w, XtPointer args, XtPointer data, | ||
| 778 | XEvent *event, Region region) | ||
| 779 | { | ||
| 780 | DlXPoints(w, args, data, DLINES8); | ||
| 781 | } | ||
| 782 | |||
| 783 | /* ARGSUSED */ | ||
| 784 | static void | ||
| 785 | DlDrawPoints(Widget w, XtPointer args, XtPointer data, | ||
| 786 | XEvent *event, Region region) | ||
| 787 | { | ||
| 788 | DlXPoints(w, args, data, POINTS13); | ||
| 789 | } | ||
| 790 | |||
| 791 | /* ARGSUSED */ | ||
| 792 | static void | ||
| 793 | DlForeground(Widget w, XtPointer args, XtPointer data, | ||
| 794 | XEvent *event, Region region) | ||
| 795 | { | ||
| 796 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 797 | Pixel foreground = (Pixel)args; | ||
| 798 | |||
| 799 | if (xdata->values.foreground != foreground) | ||
| 800 | { | ||
| 801 | xdata->mask |= GCForeground(1L<<2); | ||
| 802 | xdata->values.foreground = foreground; | ||
| 803 | XSetForeground(XtDisplayOfObject(w), xdata->gc, foreground); | ||
| 804 | } | ||
| 805 | } | ||
| 806 | |||
| 807 | /* ARGSUSED */ | ||
| 808 | static void | ||
| 809 | DlBackground(Widget w, XtPointer args, XtPointer data, | ||
| 810 | XEvent *event, Region region) | ||
| 811 | { | ||
| 812 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 813 | Pixel background = (Pixel)args; | ||
| 814 | |||
| 815 | if (xdata->values.background != background) | ||
| 816 | { | ||
| 817 | xdata->mask |= GCBackground(1L<<3); | ||
| 818 | xdata->values.background = background; | ||
| 819 | XSetBackground(XtDisplayOfObject(w), xdata->gc, background); | ||
| 820 | } | ||
| 821 | } | ||
| 822 | |||
| 823 | static void | ||
| 824 | DlArc(Widget w, XtPointer args, XtPointer data, Boolint fill) | ||
| 825 | { | ||
| 826 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 827 | XawDLArcArgs *arc = (XawDLArcArgs *)args; | ||
| 828 | Position x1, y1, x2, y2; | ||
| 829 | Display *display; | ||
| 830 | Window window; | ||
| 831 | |||
| 832 | x1 = X_ARG(arc->pos[0])(Position)(((arc->pos[0]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(arc->pos[0]).pos / (float )(arc->pos[0]).denom)) : ((arc->pos[0]).high ? (((RectObj )w)->rectangle.width) - (arc->pos[0]).pos : (arc->pos [0]).pos)); | ||
| 833 | y1 = Y_ARG(arc->pos[1])(Position)(((arc->pos[1]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(arc->pos[1]).pos / (float )(arc->pos[1]).denom)): ((arc->pos[1]).high ? (((RectObj )w)->rectangle.height) - (arc->pos[1]).pos : (arc->pos [1]).pos)); | ||
| 834 | x2 = X_ARG(arc->pos[2])(Position)(((arc->pos[2]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(arc->pos[2]).pos / (float )(arc->pos[2]).denom)) : ((arc->pos[2]).high ? (((RectObj )w)->rectangle.width) - (arc->pos[2]).pos : (arc->pos [2]).pos)); | ||
| 835 | y2 = Y_ARG(arc->pos[3])(Position)(((arc->pos[3]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(arc->pos[3]).pos / (float )(arc->pos[3]).denom)): ((arc->pos[3]).high ? (((RectObj )w)->rectangle.height) - (arc->pos[3]).pos : (arc->pos [3]).pos)); | ||
| 836 | |||
| 837 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 838 | { | ||
| 839 | Position xpad, ypad; | ||
| 840 | |||
| 841 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 842 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 843 | x1 += xpad; | ||
| 844 | y1 += ypad; | ||
| 845 | x2 += xpad; | ||
| 846 | y2 += ypad; | ||
| 847 | display = XtDisplayOfObject(w); | ||
| 848 | window = XtWindowOfObject(w); | ||
| 849 | } | ||
| 850 | else | ||
| 851 | { | ||
| 852 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 853 | window = XtWindow(w)((w)->core.window); | ||
| 854 | } | ||
| 855 | |||
| 856 | if (fill) | ||
| 857 | XFillArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1, | ||
| 858 | arc->angle1, arc->angle2); | ||
| 859 | else | ||
| 860 | XDrawArc(display, window, xdata->gc, x1, y1, x2 - x1, y2 - y1, | ||
| 861 | arc->angle1, arc->angle2); | ||
| 862 | } | ||
| 863 | |||
| 864 | /* ARGSUSED */ | ||
| 865 | static void | ||
| 866 | DlDrawArc(Widget w, XtPointer args, XtPointer data, | ||
| 867 | XEvent *event, Region region) | ||
| 868 | { | ||
| 869 | DlArc(w, args, data, False0); | ||
| 870 | } | ||
| 871 | |||
| 872 | /* ARGSUSED */ | ||
| 873 | static void | ||
| 874 | DlFillArc(Widget w, XtPointer args, XtPointer data, | ||
| 875 | XEvent *event, Region region) | ||
| 876 | { | ||
| 877 | DlArc(w, args, data, True1); | ||
| 878 | } | ||
| 879 | |||
| 880 | /*ARGSUSED*/ | ||
| 881 | static void | ||
| 882 | DlMask(Widget w, XtPointer args, XtPointer data, | ||
| 883 | XEvent *event, Region region) | ||
| 884 | { | ||
| 885 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 886 | Display *display = XtDisplayOfObject(w); | ||
| 887 | |||
| 888 | if (region) | ||
| 889 | XSetRegion(display, xdata->gc, region); | ||
| 890 | else if (event) | ||
| 891 | { | ||
| 892 | XRectangle rect; | ||
| 893 | |||
| 894 | rect.x = event->xexpose.x; | ||
| 895 | rect.y = event->xexpose.y; | ||
| 896 | rect.width = event->xexpose.width; | ||
| 897 | rect.height = event->xexpose.height; | ||
| 898 | XSetClipRectangles(display, xdata->gc, 0, 0, &rect, 1, Unsorted0); | ||
| 899 | } | ||
| 900 | } | ||
| 901 | |||
| 902 | /* ARGSUSED */ | ||
| 903 | static void | ||
| 904 | DlUmask(Widget w, XtPointer args, XtPointer data, | ||
| 905 | XEvent *event, Region region) | ||
| 906 | { | ||
| 907 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 908 | |||
| 909 | XSetClipMask(XtDisplayOfObject(w), xdata->gc, None0L); | ||
| 910 | } | ||
| 911 | |||
| 912 | /* ARGSUSED */ | ||
| 913 | static void | ||
| 914 | DlLineWidth(Widget w, XtPointer args, XtPointer data, | ||
| 915 | XEvent *event, Region region) | ||
| 916 | { | ||
| 917 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 918 | unsigned line_width = (unsigned long)args; | ||
| 919 | |||
| 920 | if (xdata->values.line_width != line_width) | ||
| 921 | { | ||
| 922 | xdata->mask |= GCLineWidth(1L<<4); | ||
| 923 | xdata->values.line_width = line_width; | ||
| 924 | XChangeGC(XtDisplayOfObject(w), xdata->gc, GCLineWidth(1L<<4), &xdata->values); | ||
| 925 | } | ||
| 926 | } | ||
| 927 | |||
| 928 | /* ARGSUSED */ | ||
| 929 | static void | ||
| 930 | DlDrawPoint(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) | ||
| 931 | { | ||
| 932 | Dl1Point(w, args, data, POINT12); | ||
| 933 | } | ||
| 934 | |||
| 935 | /* ARGSUSED */ | ||
| 936 | static void | ||
| 937 | DlDrawSegments(Widget w, XtPointer args, XtPointer data, | ||
| 938 | XEvent *event, Region region) | ||
| 939 | { | ||
| 940 | XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args; | ||
| 941 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 942 | XawDLPosition *pos; | ||
| 943 | XSegment *segments; | ||
| 944 | XSegment segments_buf[8]; | ||
| 945 | Display *display; | ||
| 946 | Window window; | ||
| 947 | Cardinal num_segments, i, j; | ||
| 948 | |||
| 949 | num_segments = pos_ptr->num_pos>>2; | ||
| 950 | segments = (XSegment *)XawStackAlloc(sizeof(XSegment) * num_segments, segments_buf)((sizeof(XSegment) * num_segments) <= sizeof(segments_buf) ? (XtPointer)(segments_buf) : XtMalloc((unsigned)(sizeof(XSegment ) * num_segments))); | ||
| 951 | |||
| 952 | for (i = j = 0; i < num_segments; i++, j = i << 2) | ||
| 953 | { | ||
| 954 | pos = &pos_ptr->pos[j]; | ||
| 955 | segments[i].x1 = X_ARG(pos[0])(Position)(((pos[0]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[0]).pos / (float)(pos[0]).denom )) : ((pos[0]).high ? (((RectObj)w)->rectangle.width) - (pos [0]).pos : (pos[0]).pos)); | ||
| 956 | segments[i].y1 = Y_ARG(pos[1])(Position)(((pos[1]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[1]).pos / (float)(pos[1]).denom )): ((pos[1]).high ? (((RectObj)w)->rectangle.height) - (pos [1]).pos : (pos[1]).pos)); | ||
| 957 | segments[i].x2 = X_ARG(pos[2])(Position)(((pos[2]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[2]).pos / (float)(pos[2]).denom )) : ((pos[2]).high ? (((RectObj)w)->rectangle.width) - (pos [2]).pos : (pos[2]).pos)); | ||
| 958 | segments[i].y2 = Y_ARG(pos[3])(Position)(((pos[3]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[3]).pos / (float)(pos[3]).denom )): ((pos[3]).high ? (((RectObj)w)->rectangle.height) - (pos [3]).pos : (pos[3]).pos)); | ||
| 959 | } | ||
| 960 | |||
| 961 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 962 | { | ||
| 963 | Position xpad, ypad; | ||
| 964 | |||
| 965 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 966 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 967 | for (i = 0; i < num_segments; i++) | ||
| 968 | { | ||
| 969 | segments[i].x1 += xpad; | ||
| 970 | segments[i].y1 += ypad; | ||
| 971 | segments[i].x2 += xpad; | ||
| 972 | segments[i].y2 += ypad; | ||
| 973 | } | ||
| 974 | display = XtDisplayOfObject(w); | ||
| 975 | window = XtWindowOfObject(w); | ||
| 976 | } | ||
| 977 | else | ||
| 978 | { | ||
| 979 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 980 | window = XtWindow(w)((w)->core.window); | ||
| 981 | } | ||
| 982 | |||
| 983 | XDrawSegments(display, window, xdata->gc, segments, num_segments); | ||
| 984 | |||
| 985 | XawStackFree(segments, segments_buf)do { if ((segments) != (XtPointer)(segments_buf)) XtFree((char *)segments); } while (0); | ||
| 986 | } | ||
| 987 | |||
| 988 | /* ARGSUSED */ | ||
| 989 | static void | ||
| 990 | DlArcMode(Widget w, XtPointer args, XtPointer data, | ||
| 991 | XEvent *event, Region region) | ||
| 992 | { | ||
| 993 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 994 | int arc_mode = (long)args; | ||
| 995 | |||
| 996 | if (xdata->values.arc_mode != arc_mode) | ||
| 997 | { | ||
| 998 | xdata->mask |= GCArcMode(1L<<22); | ||
| 999 | xdata->values.arc_mode = arc_mode; | ||
| 1000 | XSetArcMode(XtDisplayOfObject(w), xdata->gc, arc_mode); | ||
| 1001 | } | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | /* ARGSUSED */ | ||
| 1005 | static void | ||
| 1006 | DlCoordMode(Widget w, XtPointer args, XtPointer data, | ||
| 1007 | XEvent *event, Region region) | ||
| 1008 | { | ||
| 1009 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1010 | int mode = (long)args; | ||
| 1011 | |||
| 1012 | xdata->mode = mode; | ||
| 1013 | } | ||
| 1014 | |||
| 1015 | /* ARGSUSED */ | ||
| 1016 | static void | ||
| 1017 | DlShapeMode(Widget w, XtPointer args, XtPointer data, | ||
| 1018 | XEvent *event, Region region) | ||
| 1019 | { | ||
| 1020 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1021 | int shape = (long)args; | ||
| 1022 | |||
| 1023 | xdata->shape = shape; | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | /* ARGSUSED */ | ||
| 1027 | static void | ||
| 1028 | DlLineStyle(Widget w, XtPointer args, XtPointer data, | ||
| 1029 | XEvent *event, Region region) | ||
| 1030 | { | ||
| 1031 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1032 | int line_style = (long)args; | ||
| 1033 | |||
| 1034 | if (xdata->values.line_style != line_style) | ||
| 1035 | { | ||
| 1036 | xdata->mask |= GCLineStyle(1L<<5); | ||
| 1037 | xdata->values.line_style = line_style; | ||
| 1038 | XChangeGC(XtDisplayOfObject(w), xdata->gc, GCLineStyle(1L<<5), &xdata->values); | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | /* ARGSUSED */ | ||
| 1043 | static void | ||
| 1044 | DlCapStyle(Widget w, XtPointer args, XtPointer data, | ||
| 1045 | XEvent *event, Region region) | ||
| 1046 | { | ||
| 1047 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1048 | int cap_style = (long)args; | ||
| 1049 | |||
| 1050 | if (xdata->values.cap_style != cap_style) | ||
| 1051 | { | ||
| 1052 | xdata->mask |= GCCapStyle(1L<<6); | ||
| 1053 | xdata->values.cap_style = cap_style; | ||
| 1054 | XChangeGC(XtDisplayOfObject(w), xdata->gc, GCCapStyle(1L<<6), &xdata->values); | ||
| 1055 | } | ||
| 1056 | } | ||
| 1057 | |||
| 1058 | /* ARGSUSED */ | ||
| 1059 | static void | ||
| 1060 | DlJoinStyle(Widget w, XtPointer args, XtPointer data, | ||
| 1061 | XEvent *event, Region region) | ||
| 1062 | { | ||
| 1063 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1064 | int join_style = (long)args; | ||
| 1065 | |||
| 1066 | if (xdata->values.join_style != join_style) | ||
| 1067 | { | ||
| 1068 | xdata->mask |= GCJoinStyle(1L<<7); | ||
| 1069 | xdata->values.join_style = join_style; | ||
| 1070 | XChangeGC(XtDisplayOfObject(w), xdata->gc, GCJoinStyle(1L<<7), &xdata->values); | ||
| 1071 | } | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | /* ARGSUSED */ | ||
| 1075 | static void | ||
| 1076 | DlFillStyle(Widget w, XtPointer args, XtPointer data, | ||
| 1077 | XEvent *event, Region region) | ||
| 1078 | { | ||
| 1079 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1080 | int fill_style = (long)args; | ||
| 1081 | |||
| 1082 | if (xdata->values.fill_style != fill_style) | ||
| 1083 | { | ||
| 1084 | xdata->mask |= GCFillStyle(1L<<8); | ||
| 1085 | xdata->values.fill_style = fill_style; | ||
| 1086 | XSetFillStyle(XtDisplayOfObject(w), xdata->gc, fill_style); | ||
| 1087 | } | ||
| 1088 | } | ||
| 1089 | |||
| 1090 | /* ARGSUSED */ | ||
| 1091 | static void | ||
| 1092 | DlFillRule(Widget w, XtPointer args, XtPointer data, | ||
| 1093 | XEvent *event, Region region) | ||
| 1094 | { | ||
| 1095 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1096 | int fill_rule = (long)args; | ||
| 1097 | |||
| 1098 | if (xdata->values.fill_rule != fill_rule) | ||
| 1099 | { | ||
| 1100 | xdata->mask |= GCFillRule(1L<<9); | ||
| 1101 | xdata->values.fill_rule = fill_rule; | ||
| 1102 | XSetFillRule(XtDisplayOfObject(w), xdata->gc, fill_rule); | ||
| 1103 | } | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | /* ARGSUSED */ | ||
| 1107 | static void | ||
| 1108 | DlTile(Widget w, XtPointer args, XtPointer data, | ||
| 1109 | XEvent *event, Region region) | ||
| 1110 | { | ||
| 1111 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1112 | XawPixmap *pixmap = (XawPixmap *)args; | ||
| 1113 | |||
| 1114 | if (pixmap && xdata->values.tile != pixmap->pixmap) | ||
| 1115 | { | ||
| 1116 | xdata->mask |= GCTile(1L<<10); | ||
| 1117 | xdata->values.tile = pixmap->pixmap; | ||
| 1118 | XSetTile(XtDisplayOfObject(w), xdata->gc, xdata->values.tile); | ||
| 1119 | } | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | /* ARGSUSED */ | ||
| 1123 | static void | ||
| 1124 | DlStipple(Widget w, XtPointer args, XtPointer data, | ||
| 1125 | XEvent *event, Region region) | ||
| 1126 | { | ||
| 1127 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1128 | XawPixmap *pixmap = (XawPixmap *)args; | ||
| 1129 | |||
| 1130 | if (pixmap && xdata->values.stipple != pixmap->pixmap) | ||
| 1131 | { | ||
| 1132 | xdata->mask |= GCStipple(1L<<11); | ||
| 1133 | xdata->values.stipple = pixmap->pixmap; | ||
| 1134 | XSetStipple(XtDisplayOfObject(w), xdata->gc, xdata->values.stipple); | ||
| 1135 | } | ||
| 1136 | } | ||
| 1137 | |||
| 1138 | /* ARGSUSED */ | ||
| 1139 | static void | ||
| 1140 | DlTSOrigin(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) | ||
| 1141 | { | ||
| 1142 | Dl1Point(w, args, data, TSORIGIN25); | ||
| 1143 | } | ||
| 1144 | |||
| 1145 | /* ARGSUSED */ | ||
| 1146 | static void | ||
| 1147 | DlFunction(Widget w, XtPointer args, XtPointer data, | ||
| 1148 | XEvent *event, Region region) | ||
| 1149 | { | ||
| 1150 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1151 | int function = (long)args; | ||
| 1152 | |||
| 1153 | if (function != xdata->values.function) | ||
| 1154 | { | ||
| 1155 | xdata->mask |= GCFunction(1L<<0); | ||
| 1156 | xdata->values.function = function; | ||
| 1157 | XSetFunction(XtDisplayOfObject(w), xdata->gc, function); | ||
| 1158 | } | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | /* ARGSUSED */ | ||
| 1162 | static void | ||
| 1163 | DlPlaneMask(Widget w, XtPointer args, XtPointer data, | ||
| 1164 | XEvent *event, Region region) | ||
| 1165 | { | ||
| 1166 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1167 | unsigned long plane_mask = (unsigned long)args; | ||
| 1168 | |||
| 1169 | if (xdata->values.plane_mask != plane_mask) | ||
| 1170 | { | ||
| 1171 | xdata->mask |= GCPlaneMask(1L<<1); | ||
| 1172 | xdata->values.plane_mask = plane_mask; | ||
| 1173 | XSetPlaneMask(XtDisplayOfObject(w), xdata->gc, plane_mask); | ||
| 1174 | } | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | static void | ||
| 1178 | DlString(Widget w, XtPointer args, XtPointer data, Boolint image) | ||
| 1179 | { | ||
| 1180 | XawDLStringArgs *string = (XawDLStringArgs *)args; | ||
| 1181 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1182 | Display *display; | ||
| 1183 | Window window; | ||
| 1184 | Position x, y; | ||
| 1185 | |||
| 1186 | x = X_ARG(string->pos[0])(Position)(((string->pos[0]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(string->pos[0]).pos / ( float)(string->pos[0]).denom)) : ((string->pos[0]).high ? (((RectObj)w)->rectangle.width) - (string->pos[0]).pos : (string->pos[0]).pos)); | ||
| 1187 | y = Y_ARG(string->pos[1])(Position)(((string->pos[1]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(string->pos[1]).pos / (float)(string->pos[1]).denom)): ((string->pos[1]).high ? (((RectObj)w)->rectangle.height) - (string->pos[1]). pos : (string->pos[1]).pos)); | ||
| 1188 | |||
| 1189 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 1190 | { | ||
| 1191 | Position xpad, ypad; | ||
| 1192 | |||
| 1193 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1194 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1195 | x += xpad; | ||
| 1196 | y += ypad; | ||
| 1197 | display = XtDisplayOfObject(w); | ||
| 1198 | window = XtWindowOfObject(w); | ||
| 1199 | } | ||
| 1200 | else | ||
| 1201 | { | ||
| 1202 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 1203 | window = XtWindow(w)((w)->core.window); | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | if (image) | ||
| 1207 | XDrawImageString(display, window, xdata->gc, x, y, string->string, string->length); | ||
| 1208 | else | ||
| 1209 | XDrawString(display, window, xdata->gc, x, y, string->string, string->length); | ||
| 1210 | } | ||
| 1211 | |||
| 1212 | /* ARGSUSED */ | ||
| 1213 | static void | ||
| 1214 | DlDrawString(Widget w, XtPointer args, XtPointer data, | ||
| 1215 | XEvent *event, Region region) | ||
| 1216 | { | ||
| 1217 | DlString(w, args, data, False0); | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | /* ARGSUSED */ | ||
| 1221 | static void | ||
| 1222 | DlPaintString(Widget w, XtPointer args, XtPointer data, | ||
| 1223 | XEvent *event, Region region) | ||
| 1224 | { | ||
| 1225 | DlString(w, args, data, True1); | ||
| 1226 | } | ||
| 1227 | |||
| 1228 | /* ARGSUSED */ | ||
| 1229 | static void | ||
| 1230 | DlFont(Widget w, XtPointer args, XtPointer data, | ||
| 1231 | XEvent *event, Region region) | ||
| 1232 | { | ||
| 1233 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1234 | Font font = (Font)args; | ||
| 1235 | |||
| 1236 | if (xdata->values.font != font) | ||
| 1237 | { | ||
| 1238 | xdata->mask |= GCFont(1L<<14); | ||
| 1239 | xdata->values.font = font; | ||
| 1240 | XSetFont(XtDisplayOfObject(w), xdata->gc, font); | ||
| 1241 | } | ||
| 1242 | } | ||
| 1243 | |||
| 1244 | /* ARGSUSED */ | ||
| 1245 | static void | ||
| 1246 | DlDashes(Widget w, XtPointer args, XtPointer data, | ||
| 1247 | XEvent *event, Region region) | ||
| 1248 | { | ||
| 1249 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1250 | char *dashes = args; | ||
| 1251 | |||
| 1252 | if (xdata->dashes != dashes) | ||
| 1253 | { | ||
| 1254 | xdata->mask |= GCDashOffset(1L<<20) | GCDashList(1L<<21); | ||
| 1255 | xdata->dashes = dashes; | ||
| 1256 | XSetDashes(XtDisplayOfObject(w), xdata->gc, 0, dashes + 1, *dashes); | ||
| 1257 | } | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | /* ARGSUSED */ | ||
| 1261 | static void | ||
| 1262 | DlSubwindowMode(Widget w, XtPointer args, XtPointer data, | ||
| 1263 | XEvent *event, Region region) | ||
| 1264 | { | ||
| 1265 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1266 | int subwindow_mode = (long)args; | ||
| 1267 | |||
| 1268 | if (xdata->values.subwindow_mode != subwindow_mode) | ||
| 1269 | { | ||
| 1270 | xdata->mask |= GCSubwindowMode(1L<<15); | ||
| 1271 | xdata->values.subwindow_mode = subwindow_mode; | ||
| 1272 | XSetSubwindowMode(XtDisplayOfObject(w), xdata->gc, subwindow_mode); | ||
| 1273 | } | ||
| 1274 | } | ||
| 1275 | |||
| 1276 | /* ARGSUSED */ | ||
| 1277 | static void | ||
| 1278 | DlExposures(Widget w, XtPointer args, XtPointer data, | ||
| 1279 | XEvent *event, Region region) | ||
| 1280 | { | ||
| 1281 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1282 | Boolint graphics_exposures = (Boolint)(long)args; | ||
| 1283 | |||
| 1284 | if (xdata->values.graphics_exposures != graphics_exposures) | ||
| 1285 | { | ||
| 1286 | xdata->mask |= GCGraphicsExposures(1L<<16); | ||
| 1287 | xdata->values.graphics_exposures = graphics_exposures; | ||
| 1288 | XSetGraphicsExposures(XtDisplayOfObject(w), xdata->gc, graphics_exposures); | ||
| 1289 | } | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | /* ARGSUSED */ | ||
| 1293 | static void | ||
| 1294 | DlClipOrigin(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) | ||
| 1295 | { | ||
| 1296 | Dl1Point(w, args, data, CLIPORIGIN34); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | /* ARGSUSED */ | ||
| 1300 | static void | ||
| 1301 | DlClipMask(Widget w, XtPointer args, XtPointer data, | ||
| 1302 | XEvent *event, Region region) | ||
| 1303 | { | ||
| 1304 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1305 | XawPixmap *pixmap = (XawPixmap *)args; | ||
| 1306 | Pixmap clip_mask; | ||
| 1307 | |||
| 1308 | if (pixmap) | ||
| 1309 | clip_mask = pixmap->mask ? pixmap->mask : pixmap->pixmap; | ||
| 1310 | else | ||
| 1311 | clip_mask = None0L; | ||
| 1312 | |||
| 1313 | if (xdata->values.clip_mask != clip_mask) | ||
| 1314 | { | ||
| 1315 | xdata->mask |= GCClipMask(1L<<19); | ||
| 1316 | XSetClipMask(XtDisplayOfObject(w), xdata->gc, clip_mask); | ||
| 1317 | } | ||
| 1318 | } | ||
| 1319 | |||
| 1320 | /* ARGSUSED */ | ||
| 1321 | static void | ||
| 1322 | DlClipRectangles(Widget w, XtPointer args, XtPointer data, | ||
| 1323 | XEvent *event, Region region) | ||
| 1324 | { | ||
| 1325 | XawDLPositionPtr *pos_ptr = (XawDLPositionPtr *)args; | ||
| 1326 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1327 | XawDLPosition *pos; | ||
| 1328 | XRectangle *rects; | ||
| 1329 | XRectangle rects_buf[8]; | ||
| 1330 | Position x1, y1, x2, y2; | ||
| 1331 | Cardinal num_rects, i, j; | ||
| 1332 | |||
| 1333 | num_rects = pos_ptr->num_pos>>2; | ||
| 1334 | rects = (XRectangle *)XawStackAlloc(sizeof(XRectangle) * num_rects, rects_buf)((sizeof(XRectangle) * num_rects) <= sizeof(rects_buf) ? ( XtPointer)(rects_buf) : XtMalloc((unsigned)(sizeof(XRectangle ) * num_rects))); | ||
| 1335 | |||
| 1336 | for (i = j = 0; i < num_rects; i++, j = i << 2) | ||
| 1337 | { | ||
| 1338 | pos = &pos_ptr->pos[j]; | ||
| 1339 | x1 = X_ARG(pos[0])(Position)(((pos[0]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[0]).pos / (float)(pos[0]).denom )) : ((pos[0]).high ? (((RectObj)w)->rectangle.width) - (pos [0]).pos : (pos[0]).pos)); | ||
| 1340 | y1 = Y_ARG(pos[1])(Position)(((pos[1]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[1]).pos / (float)(pos[1]).denom )): ((pos[1]).high ? (((RectObj)w)->rectangle.height) - (pos [1]).pos : (pos[1]).pos)); | ||
| 1341 | x2 = X_ARG(pos[2])(Position)(((pos[2]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.width) * ((float)(pos[2]).pos / (float)(pos[2]).denom )) : ((pos[2]).high ? (((RectObj)w)->rectangle.width) - (pos [2]).pos : (pos[2]).pos)); | ||
| 1342 | y2 = Y_ARG(pos[3])(Position)(((pos[3]).denom != 0) ? ((float)(((RectObj)w)-> rectangle.height) * ((float)(pos[3]).pos / (float)(pos[3]).denom )): ((pos[3]).high ? (((RectObj)w)->rectangle.height) - (pos [3]).pos : (pos[3]).pos)); | ||
| 1343 | rects[i].x = XawMin(x1, x2)((x1) < (x2) ? (x1) : (x2)); | ||
| 1344 | rects[i].y = XawMin(y1, y2)((y1) < (y2) ? (y1) : (y2)); | ||
| 1345 | rects[i].width = XawMax(x1, x2)((x1) > (x2) ? (x1) : (x2)) - rects[i].x; | ||
| 1346 | rects[i].height = XawMax(y1, y2)((y1) > (y2) ? (y1) : (y2)) - rects[i].y; | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 1350 | { | ||
| 1351 | Position xpad, ypad; | ||
| 1352 | |||
| 1353 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1354 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1355 | for (i = 0; i < num_rects; i++) | ||
| 1356 | { | ||
| 1357 | rects[i].x += xpad; | ||
| 1358 | rects[i].y += ypad; | ||
| 1359 | } | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | XSetClipRectangles(XtDisplayOfObject(w), xdata->gc, 0, 0, rects, num_rects, Unsorted0); | ||
| 1363 | |||
| 1364 | XawStackFree(rects, rects_buf)do { if ((rects) != (XtPointer)(rects_buf)) XtFree((char *)rects ); } while (0); | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | static void | ||
| 1368 | DlCopy(Widget w, XtPointer args, XtPointer data, Boolint plane) | ||
| 1369 | { | ||
| 1370 | XawDLCopyArgs *copy = (XawDLCopyArgs *)args; | ||
| 1371 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1372 | int src_x, src_y, dst_x, dst_y, width, height, tmp1, tmp2; | ||
| 1373 | |||
| 1374 | tmp1 = X_ARG(copy->pos[0])(Position)(((copy->pos[0]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(copy->pos[0]).pos / (float )(copy->pos[0]).denom)) : ((copy->pos[0]).high ? (((RectObj )w)->rectangle.width) - (copy->pos[0]).pos : (copy-> pos[0]).pos)); | ||
| 1375 | tmp2 = X_ARG(copy->pos[2])(Position)(((copy->pos[2]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(copy->pos[2]).pos / (float )(copy->pos[2]).denom)) : ((copy->pos[2]).high ? (((RectObj )w)->rectangle.width) - (copy->pos[2]).pos : (copy-> pos[2]).pos)); | ||
| 1376 | dst_x = XawMin(tmp1, tmp2)((tmp1) < (tmp2) ? (tmp1) : (tmp2)); | ||
| 1377 | width = XawMax(tmp1, tmp2)((tmp1) > (tmp2) ? (tmp1) : (tmp2)) - dst_x; | ||
| 1378 | |||
| 1379 | tmp1 = Y_ARG(copy->pos[1])(Position)(((copy->pos[1]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(copy->pos[1]).pos / ( float)(copy->pos[1]).denom)): ((copy->pos[1]).high ? (( (RectObj)w)->rectangle.height) - (copy->pos[1]).pos : ( copy->pos[1]).pos)); | ||
| 1380 | tmp2 = Y_ARG(copy->pos[3])(Position)(((copy->pos[3]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(copy->pos[3]).pos / ( float)(copy->pos[3]).denom)): ((copy->pos[3]).high ? (( (RectObj)w)->rectangle.height) - (copy->pos[3]).pos : ( copy->pos[3]).pos)); | ||
| 1381 | dst_y = XawMin(tmp1, tmp2)((tmp1) < (tmp2) ? (tmp1) : (tmp2)); | ||
| 1382 | height = XawMax(tmp1, tmp2)((tmp1) > (tmp2) ? (tmp1) : (tmp2)) - dst_y; | ||
| 1383 | |||
| 1384 | src_x = X_ARG(copy->pos[4])(Position)(((copy->pos[4]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(copy->pos[4]).pos / (float )(copy->pos[4]).denom)) : ((copy->pos[4]).high ? (((RectObj )w)->rectangle.width) - (copy->pos[4]).pos : (copy-> pos[4]).pos)); | ||
| 1385 | src_y = Y_ARG(copy->pos[5])(Position)(((copy->pos[5]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(copy->pos[5]).pos / ( float)(copy->pos[5]).denom)): ((copy->pos[5]).high ? (( (RectObj)w)->rectangle.height) - (copy->pos[5]).pos : ( copy->pos[5]).pos)); | ||
| 1386 | |||
| 1387 | if (width <= 0) | ||
| 1388 | { | ||
| 1389 | if (copy->pixmap) | ||
| 1390 | width = copy->pixmap->width; | ||
| 1391 | else | ||
| 1392 | { | ||
| 1393 | if ((width = XtWidth(w)(((RectObj)w)->rectangle.width) - src_x) < 0) | ||
| 1394 | width = 0; | ||
| 1395 | } | ||
| 1396 | } | ||
| 1397 | if (height <= 0) | ||
| 1398 | { | ||
| 1399 | if (copy->pixmap) | ||
| 1400 | height = copy->pixmap->height; | ||
| 1401 | else | ||
| 1402 | { | ||
| 1403 | if ((height = XtHeight(w)(((RectObj)w)->rectangle.height) - src_y) < 0) | ||
| 1404 | height = 0; | ||
| 1405 | } | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 1409 | { | ||
| 1410 | Position xpad, ypad; | ||
| 1411 | |||
| 1412 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1413 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1414 | src_x += xpad; | ||
| 1415 | src_y += ypad; | ||
| 1416 | dst_x += xpad; | ||
| 1417 | dst_y += ypad; | ||
| 1418 | } | ||
| 1419 | |||
| 1420 | if (plane) | ||
| 1421 | XCopyPlane(XtDisplayOfObject(w), XtWindowOfObject(w), | ||
| 1422 | copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w), | ||
| 1423 | xdata->gc, src_x, src_y, width, height, dst_x, dst_y, | ||
| 1424 | copy->plane ? copy->plane : 1); | ||
| 1425 | else | ||
| 1426 | XCopyArea(XtDisplayOfObject(w), | ||
| 1427 | copy->pixmap ? copy->pixmap->pixmap : XtWindowOfObject(w), | ||
| 1428 | XtWindowOfObject(w), xdata->gc, src_x, src_y, width, height, dst_x, dst_y); | ||
| 1429 | } | ||
| 1430 | |||
| 1431 | /* ARGSUSED */ | ||
| 1432 | static void | ||
| 1433 | DlCopyArea(Widget w, XtPointer args, XtPointer data, | ||
| 1434 | XEvent *event, Region region) | ||
| 1435 | { | ||
| 1436 | DlCopy(w, args, data, False0); | ||
| 1437 | } | ||
| 1438 | |||
| 1439 | /* ARGSUSED */ | ||
| 1440 | static void | ||
| 1441 | DlCopyPlane(Widget w, XtPointer args, XtPointer data, | ||
| 1442 | XEvent *event, Region region) | ||
| 1443 | { | ||
| 1444 | DlCopy(w, args, data, True1); | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | /*ARGSUSED*/ | ||
| 1448 | /* Note: | ||
| 1449 | * This function is destructive if you set the ts_x_origin, ts_y_origin, | ||
| 1450 | * and/or clip-mask. It is meant to be the only function used in a display | ||
| 1451 | * list. If you need to use other functions (and those values), be sure to | ||
| 1452 | * set them after calling this function. | ||
| 1453 | */ | ||
| 1454 | static void | ||
| 1455 | DlImage(Widget w, XtPointer args, XtPointer data, XEvent *event, Region region) | ||
| 1456 | { | ||
| 1457 | XawDLImageArgs *image = (XawDLImageArgs *)args; | ||
| 1458 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 1459 | int x, y, xs, ys, xe, ye, width, height; | ||
| 1460 | Display *display; | ||
| 1461 | Window window; | ||
| 1462 | |||
| 1463 | width = image->pixmap->width; | ||
| 1464 | height = image->pixmap->height; | ||
| 1465 | xs = X_ARG(image->pos[0])(Position)(((image->pos[0]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(image->pos[0]).pos / ( float)(image->pos[0]).denom)) : ((image->pos[0]).high ? (((RectObj)w)->rectangle.width) - (image->pos[0]).pos : (image->pos[0]).pos)); | ||
| 1466 | ys = Y_ARG(image->pos[1])(Position)(((image->pos[1]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(image->pos[1]).pos / ( float)(image->pos[1]).denom)): ((image->pos[1]).high ? ( ((RectObj)w)->rectangle.height) - (image->pos[1]).pos : (image->pos[1]).pos)); | ||
| 1467 | xe = X_ARG(image->pos[2])(Position)(((image->pos[2]).denom != 0) ? ((float)(((RectObj )w)->rectangle.width) * ((float)(image->pos[2]).pos / ( float)(image->pos[2]).denom)) : ((image->pos[2]).high ? (((RectObj)w)->rectangle.width) - (image->pos[2]).pos : (image->pos[2]).pos)); | ||
| 1468 | ye = Y_ARG(image->pos[3])(Position)(((image->pos[3]).denom != 0) ? ((float)(((RectObj )w)->rectangle.height) * ((float)(image->pos[3]).pos / ( float)(image->pos[3]).denom)): ((image->pos[3]).high ? ( ((RectObj)w)->rectangle.height) - (image->pos[3]).pos : (image->pos[3]).pos)); | ||
| 1469 | |||
| 1470 | if (xe <= 0) | ||
| 1471 | xe = xs + width; | ||
| 1472 | if (ye <= 0) | ||
| 1473 | ye = ys + height; | ||
| 1474 | |||
| 1475 | if (!XtIsWidget(w)(((Object)(w))->object.widget_class->core_class.class_inited & 0x04)) | ||
| 1476 | { | ||
| 1477 | Position xpad, ypad; | ||
| 1478 | |||
| 1479 | xpad = XtX(w)(((RectObj)w)->rectangle.x) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1480 | ypad = XtY(w)(((RectObj)w)->rectangle.y) + XtBorderWidth(w)(((RectObj)w)->rectangle.border_width); | ||
| 1481 | xe += xpad; | ||
| 1482 | ye += ypad; | ||
| 1483 | xe += xpad; | ||
| 1484 | ye += ypad; | ||
| 1485 | display = XtDisplayOfObject(w); | ||
| 1486 | window = XtWindowOfObject(w); | ||
| 1487 | } | ||
| 1488 | else | ||
| 1489 | { | ||
| 1490 | display = XtDisplay(w)(((w)->core.screen)->display); | ||
| 1491 | window = XtWindow(w)((w)->core.window); | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | for (y = ys; y < ye; y += height) | ||
| 1495 | for (x = xs; x < xe; x += width) | ||
| 1496 | { | ||
| 1497 | XSetClipOrigin(display, xdata->gc, x, y); | ||
| 1498 | if (image->pixmap->mask) | ||
| 1499 | XSetClipMask(display, xdata->gc, image->pixmap->mask); | ||
| 1500 | if (image->depth == 1) | ||
| 1501 | XCopyPlane(display, image->pixmap->pixmap, window, xdata->gc, | ||
| 1502 | 0, 0, XawMin(width, xe - x)((width) < (xe - x) ? (width) : (xe - x)), XawMin(height, ye - y)((height) < (ye - y) ? (height) : (ye - y)), | ||
| 1503 | x, y, 1L); | ||
| 1504 | else | ||
| 1505 | XCopyArea(display, image->pixmap->pixmap, window, xdata->gc, 0, 0, | ||
| 1506 | XawMin(width, xe - x)((width) < (xe - x) ? (width) : (xe - x)), XawMin(height, ye - y)((height) < (ye - y) ? (height) : (ye - y)), x, y); | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | XSetClipMask(display, xdata->gc, None0L); | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | typedef struct _Dl_init Dl_init; | ||
| 1513 | struct _Dl_init { | ||
| 1514 | String name; | ||
| 1515 | XawDisplayListProc proc; | ||
| 1516 | Cardinal id; | ||
| 1517 | }; | ||
| 1518 | |||
| 1519 | static Dl_init dl_init[] = | ||
| 1520 | { | ||
| 1521 | {"arc-mode", DlArcMode, ARCMODE15}, | ||
| 1522 | {"background", DlBackground, GCBG4}, | ||
| 1523 | {"bg", DlBackground, GCBG4}, | ||
| 1524 | {"cap-style", DlCapStyle, CAPSTYLE19}, | ||
| 1525 | {"clip-mask", DlClipMask, CLIPMASK35}, | ||
| 1526 | {"clip-origin", DlClipOrigin, CLIPORIGIN34}, | ||
| 1527 | {"clip-rectangles", DlClipRectangles, CLIPRECTS36}, | ||
| 1528 | {"clip-rects", DlClipRectangles, CLIPRECTS36}, | ||
| 1529 | {"coord-mode", DlCoordMode, COORDMODE16}, | ||
| 1530 | {"copy-area", DlCopyArea, COPYAREA37}, | ||
| 1531 | {"copy-plane", DlCopyPlane, COPYPLANE38}, | ||
| 1532 | {"dashes", DlDashes, DASHES31}, | ||
| 1533 | {"draw-arc", DlDrawArc, DARC6}, | ||
| 1534 | {"draw-line", DlLine, LINE2}, | ||
| 1535 | {"draw-lines", DlDrawLines, DLINES8}, | ||
| 1536 | {"draw-point", DlDrawPoint, POINT12}, | ||
| 1537 | {"draw-points", DlDrawPoints, POINTS13}, | ||
| 1538 | {"draw-rect", DlDrawRectangle, DRECT0}, | ||
| 1539 | {"draw-rectangle", DlDrawRectangle, DRECT0}, | ||
| 1540 | {"draw-segments", DlDrawSegments, SEGMENTS14}, | ||
| 1541 | {"draw-string", DlDrawString, DSTRING28}, | ||
| 1542 | {"exposures", DlExposures, EXPOSURES33}, | ||
| 1543 | {"fg", DlForeground, GCFG3}, | ||
| 1544 | {"fill-arc", DlFillArc, FARC7}, | ||
| 1545 | {"fill-poly", DlFillPolygon, FPOLY5}, | ||
| 1546 | {"fill-polygon", DlFillPolygon, FPOLY5}, | ||
| 1547 | {"fill-rect", DlFillRectangle, FRECT1}, | ||
| 1548 | {"fill-rectangle", DlFillRectangle, FRECT1}, | ||
| 1549 | {"fill-rule", DlFillRule, FILLRULE22}, | ||
| 1550 | {"fill-style", DlFillStyle, FILLSTYLE21}, | ||
| 1551 | {"font", DlFont, FONT30}, | ||
| 1552 | {"foreground", DlForeground, GCFG3}, | ||
| 1553 | {"function", DlFunction, FUNCTION26}, | ||
| 1554 | {"image", DlImage, IMAGE39}, | ||
| 1555 | {"join-style", DlJoinStyle, JOINSTYLE20}, | ||
| 1556 | {"line", DlLine, LINE2}, | ||
| 1557 | {"line-style", DlLineStyle, LINESTYLE18}, | ||
| 1558 | {"line-width", DlLineWidth, LWIDTH11}, | ||
| 1559 | {"lines", DlDrawLines, DLINES8}, | ||
| 1560 | {"mask", DlMask, MASK9}, | ||
| 1561 | {"paint-string", DlPaintString, PSTRING29}, | ||
| 1562 | {"plane-mask", DlPlaneMask, PLANEMASK27}, | ||
| 1563 | {"point", DlDrawPoint, POINT12}, | ||
| 1564 | {"points", DlDrawPoints, POINTS13}, | ||
| 1565 | {"segments", DlDrawSegments, SEGMENTS14}, | ||
| 1566 | {"shape-mode", DlShapeMode, SHAPEMODE17}, | ||
| 1567 | {"stipple", DlStipple, STIPPLE24}, | ||
| 1568 | {"subwindow-mode", DlSubwindowMode, SUBWMODE32}, | ||
| 1569 | {"tile", DlTile, TILE23}, | ||
| 1570 | {"ts-origin", DlTSOrigin, TSORIGIN25}, | ||
| 1571 | {"umask", DlUmask, UMASK10}, | ||
| 1572 | }; | ||
| 1573 | |||
| 1574 | void | ||
| 1575 | XawDisplayListInitialize(void) | ||
| 1576 | { | ||
| 1577 | static Boolint first_time = True1; | ||
| 1578 | XawDLClass *lc; | ||
| 1579 | Cardinal i; | ||
| 1580 | |||
| 1581 | if (first_time == False0) | ||
| 1582 | return; | ||
| 1583 | |||
| 1584 | first_time = False0; | ||
| 1585 | |||
| 1586 | lc = XawCreateDisplayListClass(xlib, | ||
| 1587 | _Xaw_Xlib_ArgsInitProc, | ||
| 1588 | _Xaw_Xlib_ArgsDestructor, | ||
| 1589 | _Xaw_Xlib_DataInitProc, | ||
| 1590 | _Xaw_Xlib_DataDestructor); | ||
| 1591 | for (i = 0; i < sizeof(dl_init) / sizeof(dl_init[0]); i++) | ||
| 1592 | (void)XawDeclareDisplayListProc(lc, dl_init[i].name, dl_init[i].proc); | ||
| 1593 | } | ||
| 1594 | |||
| 1595 | static int | ||
| 1596 | bcmp_cvt_proc(register _Xconstconst void *string, | ||
| 1597 | register _Xconstconst void *dlinfo) | ||
| 1598 | { | ||
| 1599 | return (strcmp((String)string, ((Dl_init*)dlinfo)->name)); | ||
| 1600 | } | ||
| 1601 | |||
| 1602 | static long | ||
| 1603 | read_int(char *cp, char **cpp) | ||
| 1604 | { | ||
| 1605 | long value = 0, sign = 1; | ||
| 1606 | |||
| 1607 | if (*cp == '-') | ||
| 1608 | { | ||
| 1609 | sign = -1; | ||
| 1610 | ++cp; | ||
| 1611 | } | ||
| 1612 | else if (*cp == '+') | ||
| 1613 | ++cp; | ||
| 1614 | value = 0; | ||
| 1615 | while (*cp >= '0' && *cp <= '9') | ||
| 1616 | { | ||
| 1617 | value = value * 10 + *cp - '0'; | ||
| 1618 | ++cp; | ||
| 1619 | } | ||
| 1620 | if (cpp) | ||
| 1621 | *cpp = cp; | ||
| 1622 | return (value * sign); | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | static void | ||
| 1626 | read_position(char *arg, XawDLPosition *pos) | ||
| 1627 | { | ||
| 1628 | int ch; | ||
| 1629 | char *str = arg; | ||
| 1630 | |||
| 1631 | ch = *str; | ||
| 1632 | if (ch == '-' || ch == '+') | ||
| 1633 | { | ||
| 1634 | ++str; | ||
| 1635 | if (ch == '-') | ||
| 1636 | pos->high = True1; | ||
| 1637 | pos->pos = read_int(str, NULL((void*)0)); | ||
| 1638 | } | ||
| 1639 | else if (isdigit(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit)) | ||
| 1640 | { | ||
| 1641 | pos->pos = read_int(str, &str); | ||
| 1642 | ch = *str++; | ||
| 1643 | if (ch == '/') | ||
| 1644 | pos->denom = read_int(str, NULL((void*)0)); | ||
| 1645 | } | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | /* ARGSUSED */ | ||
| 1649 | static void * | ||
| 1650 | _Xaw_Xlib_ArgsInitProc(String proc_name, String *params, Cardinal *num_params, | ||
| 1651 | Screen *screen, Colormap colormap, int depth) | ||
| 1652 | { | ||
| 1653 | Cardinal id, i; | ||
| 1654 | Dl_init *init; | ||
| 1655 | void *retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 1656 | |||
| 1657 | init = (Dl_init *)bsearch(proc_name, dl_init, | ||
| 1658 | sizeof(dl_init) / sizeof(dl_init[0]), | ||
| 1659 | sizeof(dl_init[0]), | ||
| 1660 | bcmp_cvt_proc); | ||
| 1661 | |||
| 1662 | id = init->id; | ||
| 1663 | |||
| 1664 | switch (id) | ||
| |||
| 1665 | { | ||
| 1666 | case LINE2: | ||
| 1667 | case DRECT0: | ||
| 1668 | case FRECT1: | ||
| 1669 | if (*num_params == 4) | ||
| 1670 | { | ||
| 1671 | XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 4); | ||
| 1672 | |||
| 1673 | for (i = 0; i < 4; i++) | ||
| 1674 | read_position(params[i], &pos[i]); | ||
| 1675 | retval = (void *)pos; | ||
| 1676 | } | ||
| 1677 | break; | ||
| 1678 | case POINT12: | ||
| 1679 | case TSORIGIN25: | ||
| 1680 | case CLIPORIGIN34: | ||
| 1681 | if (*num_params == 2) | ||
| 1682 | { | ||
| 1683 | XawDLPosition *pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * 2); | ||
| 1684 | |||
| 1685 | read_position(params[0], &pos[0]); | ||
| 1686 | read_position(params[1], &pos[1]); | ||
| 1687 | retval = (void *)pos; | ||
| 1688 | } | ||
| 1689 | break; | ||
| 1690 | case DLINES8: | ||
| 1691 | case FPOLY5: | ||
| 1692 | case POINTS13: | ||
| 1693 | if (*num_params >= 4 && !(*num_params & 1)) | ||
| 1694 | { | ||
| 1695 | XawDLPositionPtr *pos = XtNew(XawDLPositionPtr)((XawDLPositionPtr *) XtMalloc((unsigned) sizeof(XawDLPositionPtr ))); | ||
| 1696 | |||
| 1697 | pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * | ||
| 1698 | *num_params); | ||
| 1699 | pos->num_pos = *num_params; | ||
| 1700 | for (i = 0; i < *num_params; i++) | ||
| 1701 | read_position(params[i], &pos->pos[i]); | ||
| 1702 | retval = (void *)pos; | ||
| 1703 | } | ||
| 1704 | break; | ||
| 1705 | case SEGMENTS14: | ||
| 1706 | case CLIPRECTS36: | ||
| 1707 | if (*num_params >= 4 && !(*num_params % 4)) | ||
| 1708 | { | ||
| 1709 | XawDLPositionPtr *pos = XtNew(XawDLPositionPtr)((XawDLPositionPtr *) XtMalloc((unsigned) sizeof(XawDLPositionPtr ))); | ||
| 1710 | |||
| 1711 | pos->pos = (XawDLPosition *)XtCalloc(1, sizeof(XawDLPosition) * | ||
| 1712 | *num_params); | ||
| 1713 | pos->num_pos = *num_params; | ||
| 1714 | for (i = 0; i < *num_params; i++) | ||
| 1715 | read_position(params[i], &pos->pos[i]); | ||
| 1716 | retval = (void *)pos; | ||
| 1717 | } | ||
| 1718 | break; | ||
| 1719 | case DARC6: | ||
| 1720 | case FARC7: | ||
| 1721 | if (*num_params >= 4 && *num_params <= 6) | ||
| 1722 | { | ||
| 1723 | XawDLArcArgs *args = (XawDLArcArgs *)XtCalloc(1, sizeof(XawDLArcArgs)); | ||
| 1724 | |||
| 1725 | args->angle1 = 0; | ||
| 1726 | args->angle2 = 360; | ||
| 1727 | for (i = 0; i < 4; i++) | ||
| 1728 | read_position(params[i], &args->pos[i]); | ||
| 1729 | if (*num_params > 4) | ||
| 1730 | args->angle1 = read_int(params[4], NULL((void*)0)); | ||
| 1731 | if (*num_params > 5) | ||
| 1732 | args->angle2 = read_int(params[5], NULL((void*)0)); | ||
| 1733 | args->angle1 *= 64; | ||
| 1734 | args->angle2 *= 64; | ||
| 1735 | retval = (void *)args; | ||
| 1736 | } | ||
| 1737 | break; | ||
| 1738 | case GCFG3: | ||
| 1739 | case GCBG4: | ||
| 1740 | { | ||
| 1741 | XColor xcolor; | ||
| 1742 | |||
| 1743 | if (*num_params == 1 && | ||
| 1744 | XAllocNamedColor(DisplayOfScreen(screen)((screen)->display), colormap, | ||
| 1745 | params[0], &xcolor, &xcolor)) | ||
| 1746 | retval = (void *)xcolor.pixel; | ||
| 1747 | } break; | ||
| 1748 | case MASK9: | ||
| 1749 | case UMASK10: | ||
| 1750 | if (*num_params == 0) | ||
| 1751 | retval = NULL((void*)0); | ||
| 1752 | break; | ||
| 1753 | case LWIDTH11: | ||
| 1754 | if (*num_params == 1) | ||
| 1755 | retval = (void *)read_int(params[0], NULL((void*)0)); | ||
| 1756 | break; | ||
| 1757 | case ARCMODE15: | ||
| 1758 | if (*num_params == 1) | ||
| 1759 | { | ||
| 1760 | if (XmuCompareISOLatin1(params[0], "pieslice") == 0) | ||
| 1761 | retval = (void *)ArcPieSlice1; | ||
| 1762 | else if (XmuCompareISOLatin1(params[0], "chord") == 0) | ||
| 1763 | retval = (void *)ArcChord0; | ||
| 1764 | } | ||
| 1765 | break; | ||
| 1766 | case COORDMODE16: | ||
| 1767 | if (*num_params == 1) | ||
| 1768 | { | ||
| 1769 | if (XmuCompareISOLatin1(params[0], "origin") == 0) | ||
| 1770 | retval = (void *)CoordModeOrigin0; | ||
| 1771 | else if (XmuCompareISOLatin1(params[0], "previous") == 0) | ||
| 1772 | retval = (void *)CoordModePrevious1; | ||
| 1773 | } | ||
| 1774 | break; | ||
| 1775 | case SHAPEMODE17: | ||
| 1776 | if (*num_params == 1) | ||
| 1777 | { | ||
| 1778 | if (XmuCompareISOLatin1(params[0], "complex") == 0) | ||
| 1779 | retval = (void *)Complex0; | ||
| 1780 | else if (XmuCompareISOLatin1(params[0], "convex") == 0) | ||
| 1781 | retval = (void *)Convex2; | ||
| 1782 | else if (XmuCompareISOLatin1(params[0], "nonconvex") == 0) | ||
| 1783 | retval = (void *)Nonconvex1; | ||
| 1784 | } | ||
| 1785 | break; | ||
| 1786 | case LINESTYLE18: | ||
| 1787 | if (*num_params == 1) | ||
| 1788 | { | ||
| 1789 | if (XmuCompareISOLatin1(params[0], "solid") == 0) | ||
| 1790 | retval = (void *)LineSolid0; | ||
| 1791 | else if (XmuCompareISOLatin1(params[0], "onoffdash") == 0) | ||
| 1792 | retval = (void *)LineOnOffDash1; | ||
| 1793 | else if (XmuCompareISOLatin1(params[0], "doubledash") == 0) | ||
| 1794 | retval = (void *)LineDoubleDash2; | ||
| 1795 | } | ||
| 1796 | break; | ||
| 1797 | case CAPSTYLE19: | ||
| 1798 | if (*num_params == 1) | ||
| 1799 | { | ||
| 1800 | if (XmuCompareISOLatin1(params[0], "notlast") == 0) | ||
| 1801 | retval = (void *)CapNotLast0; | ||
| 1802 | else if (XmuCompareISOLatin1(params[0], "butt") == 0) | ||
| 1803 | retval = (void *)CapButt1; | ||
| 1804 | else if (XmuCompareISOLatin1(params[0], "round") == 0) | ||
| 1805 | retval = (void *)CapRound2; | ||
| 1806 | else if (XmuCompareISOLatin1(params[0], "projecting") == 0) | ||
| 1807 | retval = (void *)CapProjecting3; | ||
| 1808 | } | ||
| 1809 | break; | ||
| 1810 | case JOINSTYLE20: | ||
| 1811 | if (*num_params == 1) | ||
| 1812 | { | ||
| 1813 | if (XmuCompareISOLatin1(params[0], "miter") == 0) | ||
| 1814 | retval = (void *)JoinMiter0; | ||
| 1815 | else if (XmuCompareISOLatin1(params[0], "round") == 0) | ||
| 1816 | retval = (void *)JoinRound1; | ||
| 1817 | else if (XmuCompareISOLatin1(params[0], "bevel") == 0) | ||
| 1818 | retval = (void *)JoinBevel2; | ||
| 1819 | } | ||
| 1820 | break; | ||
| 1821 | case FILLSTYLE21: | ||
| 1822 | if (*num_params == 1) | ||
| 1823 | { | ||
| 1824 | if (*num_params && XmuCompareISOLatin1(params[0], "solid") == 0) | ||
| 1825 | retval = (void *)FillSolid0; | ||
| 1826 | else if (*num_params && XmuCompareISOLatin1(params[0], "tiled") == 0) | ||
| 1827 | retval = (void *)FillTiled1; | ||
| 1828 | else if (*num_params && XmuCompareISOLatin1(params[0], "stippled") == 0) | ||
| 1829 | retval = (void *)FillStippled2; | ||
| 1830 | else if (*num_params && XmuCompareISOLatin1(params[0], "opaquestippled") == 0) | ||
| 1831 | retval = (void *)FillOpaqueStippled3; | ||
| 1832 | } | ||
| 1833 | break; | ||
| 1834 | case FILLRULE22: | ||
| 1835 | if (*num_params == 1) | ||
| 1836 | { | ||
| 1837 | if (XmuCompareISOLatin1(params[0], "evenodd") == 0) | ||
| 1838 | retval = (void *)EvenOddRule0; | ||
| 1839 | else if (XmuCompareISOLatin1(params[0], "winding") == 0) | ||
| 1840 | retval = (void *)WindingRule1; | ||
| 1841 | } | ||
| 1842 | break; | ||
| 1843 | case TILE23: | ||
| 1844 | if (*num_params == 1) | ||
| 1845 | retval = (void *)XawLoadPixmap(params[0], screen, colormap, depth); | ||
| 1846 | if (retval == NULL((void*)0)) | ||
| 1847 | { | ||
| 1848 | XtDisplayStringConversionWarning(DisplayOfScreen(screen)((screen)->display), (String)params[0], | ||
| 1849 | XtRPixmap((char*)&XtStrings[1760])); | ||
| 1850 | retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 1851 | } | ||
| 1852 | break; | ||
| 1853 | case STIPPLE24: | ||
| 1854 | if (*num_params == 1) | ||
| 1855 | retval = (void *)XawLoadPixmap(params[0], screen, colormap, 1); | ||
| 1856 | if (retval == NULL((void*)0)) | ||
| 1857 | { | ||
| 1858 | XtDisplayStringConversionWarning(DisplayOfScreen(screen)((screen)->display), (String)params[0], | ||
| 1859 | XtRBitmap((char*)&XtStrings[1549])); | ||
| 1860 | retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 1861 | } | ||
| 1862 | break; | ||
| 1863 | case FUNCTION26: | ||
| 1864 | if (*num_params == 1) | ||
| 1865 | { | ||
| 1866 | if (XmuCompareISOLatin1(params[0], "set") == 0) | ||
| 1867 | retval = (void *)GXset0xf; | ||
| 1868 | else if (XmuCompareISOLatin1(params[0], "clear") == 0) | ||
| 1869 | retval = (void *)GXclear0x0; | ||
| 1870 | else if (XmuCompareISOLatin1(params[0], "and") == 0) | ||
| 1871 | retval = (void *)GXand0x1; | ||
| 1872 | else if (XmuCompareISOLatin1(params[0], "andreverse") == 0) | ||
| 1873 | retval = (void *)GXandReverse0x2; | ||
| 1874 | else if (XmuCompareISOLatin1(params[0], "copy") == 0) | ||
| 1875 | retval = (void *)GXcopy0x3; | ||
| 1876 | else if (XmuCompareISOLatin1(params[0], "andinverted") == 0) | ||
| 1877 | retval = (void *)GXandInverted0x4; | ||
| 1878 | else if (XmuCompareISOLatin1(params[0], "noop") == 0) | ||
| 1879 | retval = (void *)GXnoop0x5; | ||
| 1880 | else if (XmuCompareISOLatin1(params[0], "xor") == 0) | ||
| 1881 | retval = (void *)GXxor0x6; | ||
| 1882 | else if (XmuCompareISOLatin1(params[0], "or") == 0) | ||
| 1883 | retval = (void *)GXor0x7; | ||
| 1884 | else if (XmuCompareISOLatin1(params[0], "nor") == 0) | ||
| 1885 | retval = (void *)GXnor0x8; | ||
| 1886 | else if (XmuCompareISOLatin1(params[0], "equiv") == 0) | ||
| 1887 | retval = (void *)GXequiv0x9; | ||
| 1888 | else if (XmuCompareISOLatin1(params[0], "invert") == 0) | ||
| 1889 | retval = (void *)GXinvert0xa; | ||
| 1890 | else if (XmuCompareISOLatin1(params[0], "orreverse") == 0) | ||
| 1891 | retval = (void *)GXorReverse0xb; | ||
| 1892 | else if (XmuCompareISOLatin1(params[0], "copyinverted") == 0) | ||
| 1893 | retval = (void *)GXcopyInverted0xc; | ||
| 1894 | else if (XmuCompareISOLatin1(params[0], "nand") == 0) | ||
| 1895 | retval = (void *)GXnand0xe; | ||
| 1896 | } | ||
| 1897 | break; | ||
| 1898 | case PLANEMASK27: | ||
| 1899 | if (*num_params == 1) | ||
| 1900 | retval = (void *)read_int(params[0], NULL((void*)0)); | ||
| 1901 | break; | ||
| 1902 | case DSTRING28: | ||
| 1903 | case PSTRING29: | ||
| 1904 | if (*num_params == 3) | ||
| |||
| 1905 | { | ||
| 1906 | XawDLStringArgs *string = (XawDLStringArgs *) | ||
| 1907 | XtCalloc(1, sizeof(XawDLStringArgs)); | ||
| 1908 | |||
| 1909 | read_position(params[0], &string->pos[0]); | ||
| 1910 | read_position(params[1], &string->pos[1]); | ||
| 1911 | string->string = XtNewString(params[2])((params[2]) != ((void*)0) ? (strcpy(XtMalloc((unsigned)strlen (params[2]) + 1), params[2])) : ((void*)0)); | ||
| 1912 | string->length = strlen(string->string); | ||
| |||
| 1913 | retval = string; | ||
| 1914 | } | ||
| 1915 | break; | ||
| 1916 | case FONT30: | ||
| 1917 | if (*num_params == 1) | ||
| 1918 | retval = (void *)XLoadFont(DisplayOfScreen(screen)((screen)->display), params[0]); | ||
| 1919 | break; | ||
| 1920 | case DASHES31: | ||
| 1921 | if (*num_params && *num_params < 127) | ||
| 1922 | { | ||
| 1923 | char *dashes; | ||
| 1924 | |||
| 1925 | dashes = XtMalloc(*num_params + 1); | ||
| 1926 | |||
| 1927 | for (i = 0; i < *num_params; i++) | ||
| 1928 | dashes[i + 1] = read_int(params[i], NULL((void*)0)); | ||
| 1929 | *dashes = *num_params; | ||
| 1930 | retval = dashes; | ||
| 1931 | } | ||
| 1932 | break; | ||
| 1933 | case SUBWMODE32: | ||
| 1934 | if (*num_params == 1) | ||
| 1935 | { | ||
| 1936 | if (XmuCompareISOLatin1(params[0], "clipbychildren") == 0) | ||
| 1937 | retval = (void *)ClipByChildren0; | ||
| 1938 | else if (XmuCompareISOLatin1(params[0], "includeinferiors") == 0) | ||
| 1939 | retval = (void *)IncludeInferiors1; | ||
| 1940 | } | ||
| 1941 | break; | ||
| 1942 | case EXPOSURES33: | ||
| 1943 | if (*num_params == 1) | ||
| 1944 | { | ||
| 1945 | if (isdigit(params[0][0])((*__ctype_b_loc ())[(int) ((params[0][0]))] & (unsigned short int) _ISdigit) || params[0][0] == '+' || params[0][0] == '-') | ||
| 1946 | retval = (void *)read_int(params[0], NULL((void*)0)); | ||
| 1947 | else if (XmuCompareISOLatin1(params[0], "true") == 0 || | ||
| 1948 | XmuCompareISOLatin1(params[0], "on") == 0) | ||
| 1949 | retval = (void *)True1; | ||
| 1950 | else if (XmuCompareISOLatin1(params[0], "false") == 0 || | ||
| 1951 | XmuCompareISOLatin1(params[0], "off") == 0) | ||
| 1952 | retval = (void *)False0; | ||
| 1953 | } | ||
| 1954 | break; | ||
| 1955 | case CLIPMASK35: | ||
| 1956 | if (*num_params == 1) | ||
| 1957 | retval = (void *)XawLoadPixmap(params[0], screen, colormap, 1); | ||
| 1958 | if (retval == NULL((void*)0)) | ||
| 1959 | { | ||
| 1960 | retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 1961 | XtDisplayStringConversionWarning(DisplayOfScreen(screen)((screen)->display), (String)params[0], | ||
| 1962 | XtRPixmap((char*)&XtStrings[1760])); | ||
| 1963 | } | ||
| 1964 | break; | ||
| 1965 | case COPYAREA37: | ||
| 1966 | case COPYPLANE38: | ||
| 1967 | if (*num_params > 2 && *num_params <= 7 + (id == COPYPLANE38)) | ||
| 1968 | { | ||
| 1969 | XawDLCopyArgs *args = (XawDLCopyArgs *) | ||
| 1970 | XtCalloc(1, sizeof(XawDLCopyArgs)); | ||
| 1971 | |||
| 1972 | retval = args; | ||
| 1973 | if (params[0][0] == '\0' || strcmp(params[0], ".") == 0) | ||
| 1974 | args->pixmap = NULL((void*)0); | ||
| 1975 | else | ||
| 1976 | { | ||
| 1977 | args->pixmap = XawLoadPixmap(params[0], screen, colormap, id == COPYPLANE38 ? 1 : depth); | ||
| 1978 | if (args->pixmap == NULL((void*)0)) | ||
| 1979 | { | ||
| 1980 | XtDisplayStringConversionWarning(DisplayOfScreen(screen)((screen)->display), (String)params[0], | ||
| 1981 | XtRBitmap((char*)&XtStrings[1549])); | ||
| 1982 | retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 1983 | XtFree((char *)args); | ||
| 1984 | } | ||
| 1985 | } | ||
| 1986 | if (retval != XAWDL_CONVERT_ERROR(XtPointer)-1) | ||
| 1987 | { | ||
| 1988 | for (i = 1; i < *num_params && i < 7; i++) | ||
| 1989 | read_position(params[i], &args->pos[i - 1]); | ||
| 1990 | if (*num_params > 7) | ||
| 1991 | args->plane = read_int(params[7], NULL((void*)0)); | ||
| 1992 | } | ||
| 1993 | } | ||
| 1994 | break; | ||
| 1995 | case IMAGE39: | ||
| 1996 | if (*num_params > 2 && *num_params <= 7) | ||
| 1997 | { | ||
| 1998 | XawDLImageArgs *args = (XawDLImageArgs *) | ||
| 1999 | XtCalloc(1, sizeof(XawDLImageArgs)); | ||
| 2000 | |||
| 2001 | retval = args; | ||
| 2002 | args->pixmap = XawLoadPixmap(params[0], screen, colormap, depth); | ||
| 2003 | if (args->pixmap == NULL((void*)0)) | ||
| 2004 | { | ||
| 2005 | XtDisplayStringConversionWarning(DisplayOfScreen(screen)((screen)->display), | ||
| 2006 | (String)params[0], XtRPixmap((char*)&XtStrings[1760])); | ||
| 2007 | retval = XAWDL_CONVERT_ERROR(XtPointer)-1; | ||
| 2008 | XtFree((char *)args); | ||
| 2009 | } | ||
| 2010 | else | ||
| 2011 | { | ||
| 2012 | args->depth = depth; | ||
| 2013 | for (i = 1; i < *num_params && i < 5; i++) | ||
| 2014 | read_position(params[i], &args->pos[i - 1]); | ||
| 2015 | } | ||
| 2016 | } | ||
| 2017 | break; | ||
| 2018 | } | ||
| 2019 | |||
| 2020 | return (retval); | ||
| 2021 | } | ||
| 2022 | |||
| 2023 | /* ARGSUSED */ | ||
| 2024 | static void * | ||
| 2025 | _Xaw_Xlib_DataInitProc(String class_name, | ||
| 2026 | Screen *screen, Colormap colormap, int depth) | ||
| 2027 | { | ||
| 2028 | XawXlibData *data; | ||
| 2029 | Window tmp_win; | ||
| 2030 | |||
| 2031 | data = (XawXlibData *)XtMalloc(sizeof(XawXlibData)); | ||
| 2032 | |||
| 2033 | tmp_win = XCreateWindow(DisplayOfScreen(screen)((screen)->display), | ||
| 2034 | RootWindowOfScreen(screen)((screen)->root), | ||
| 2035 | 0, 0, 1, 1, 1, depth, | ||
| 2036 | InputOutput1, (Visual *)CopyFromParent0L, 0, NULL((void*)0)); | ||
| 2037 | data->mask = 0; | ||
| 2038 | data->gc = XCreateGC(DisplayOfScreen(screen)((screen)->display), tmp_win, 0, &data->values); | ||
| 2039 | XDestroyWindow(DisplayOfScreen(screen)((screen)->display), tmp_win); | ||
| 2040 | data->shape = Complex0; | ||
| 2041 | data->mode = CoordModeOrigin0; | ||
| 2042 | data->dashes = NULL((void*)0); | ||
| 2043 | |||
| 2044 | return ((void *)data); | ||
| 2045 | } | ||
| 2046 | |||
| 2047 | /* ARGSUSED */ | ||
| 2048 | static void | ||
| 2049 | _Xaw_Xlib_ArgsDestructor(Display *display, String proc_name, XtPointer args, | ||
| 2050 | String *params, Cardinal *num_params) | ||
| 2051 | { | ||
| 2052 | Cardinal id; | ||
| 2053 | Dl_init *init; | ||
| 2054 | |||
| 2055 | init = (Dl_init *)bsearch(proc_name, dl_init, | ||
| 2056 | sizeof(dl_init) / sizeof(dl_init[0]), | ||
| 2057 | sizeof(dl_init[0]), | ||
| 2058 | bcmp_cvt_proc); | ||
| 2059 | |||
| 2060 | id = init->id; | ||
| 2061 | |||
| 2062 | switch (id) | ||
| 2063 | { | ||
| 2064 | case LINE2: | ||
| 2065 | case DRECT0: | ||
| 2066 | case FRECT1: | ||
| 2067 | case DARC6: | ||
| 2068 | case FARC7: | ||
| 2069 | case POINT12: | ||
| 2070 | case TSORIGIN25: | ||
| 2071 | case DASHES31: | ||
| 2072 | case CLIPORIGIN34: | ||
| 2073 | case COPYAREA37: | ||
| 2074 | case COPYPLANE38: | ||
| 2075 | case IMAGE39: | ||
| 2076 | XtFree(args); | ||
| 2077 | break; | ||
| 2078 | case DSTRING28: | ||
| 2079 | case PSTRING29: | ||
| 2080 | { | ||
| 2081 | XawDLStringArgs *string = (XawDLStringArgs *)args; | ||
| 2082 | XtFree(string->string); | ||
| 2083 | XtFree(args); | ||
| 2084 | } break; | ||
| 2085 | case DLINES8: | ||
| 2086 | case FPOLY5: | ||
| 2087 | case POINTS13: | ||
| 2088 | case SEGMENTS14: | ||
| 2089 | case CLIPRECTS36: | ||
| 2090 | { | ||
| 2091 | XawDLPositionPtr *ptr = (XawDLPositionPtr *)args; | ||
| 2092 | |||
| 2093 | XtFree((char *)ptr->pos); | ||
| 2094 | XtFree(args); | ||
| 2095 | } break; | ||
| 2096 | } | ||
| 2097 | } | ||
| 2098 | |||
| 2099 | /* ARGSUSED */ | ||
| 2100 | static void | ||
| 2101 | _Xaw_Xlib_DataDestructor(Display *display, String class_name, XtPointer data) | ||
| 2102 | { | ||
| 2103 | if (data) | ||
| 2104 | { | ||
| 2105 | XawXlibData *xdata = (XawXlibData *)data; | ||
| 2106 | |||
| 2107 | XFreeGC(display, xdata->gc); | ||
| 2108 | if (xdata->dashes) | ||
| 2109 | XtFree(xdata->dashes); | ||
| 2110 | XtFree((char *)data); | ||
| 2111 | } | ||
| 2112 | } | ||
| 2113 | |||
| 2114 | /* Start of DLInfo Management Functions */ | ||
| 2115 | static int | ||
| 2116 | qcmp_dlist_info(register _Xconstconst void *left, register _Xconstconst void *right) | ||
| 2117 | { | ||
| 2118 | return (strcmp((*(XawDLInfo **)left)->name, (*(XawDLInfo **)right)->name)); | ||
| 2119 | } | ||
| 2120 | |||
| 2121 | Boolint XawDeclareDisplayListProc(XawDLClass *lc, String name, | ||
| 2122 | XawDisplayListProc proc) | ||
| 2123 | { | ||
| 2124 | XawDLInfo *info; | ||
| 2125 | |||
| 2126 | if (!lc || !proc || !name || name[0] == '\0') | ||
| 2127 | return (False0); | ||
| 2128 | |||
| 2129 | if ((info = _XawFindDLInfo(lc, name)) != NULL((void*)0)) | ||
| 2130 | /* Since the data structures to the displayList classes are(should be) | ||
| 2131 | * opaque, it is not a good idea to allow overriding a displayList | ||
| 2132 | * procedure; it's better to choose another name or class name! | ||
| 2133 | */ | ||
| 2134 | return (False0); | ||
| 2135 | |||
| 2136 | info = (XawDLInfo *)XtMalloc(sizeof(XawDLInfo)); | ||
| 2137 | info->name = XtNewString(name)((name) != ((void*)0) ? (strcpy(XtMalloc((unsigned)strlen(name ) + 1), name)) : ((void*)0)); | ||
| 2138 | info->qname = XrmStringToQuark(info->name); | ||
| 2139 | info->proc = proc; | ||
| 2140 | |||
| 2141 | if (!lc->num_infos) | ||
| 2142 | { | ||
| 2143 | lc->num_infos = 1; | ||
| 2144 | lc->infos = (XawDLInfo **)XtMalloc(sizeof(XawDLInfo*)); | ||
| 2145 | } | ||
| 2146 | else | ||
| 2147 | { | ||
| 2148 | ++lc->num_infos; | ||
| 2149 | lc->infos = (XawDLInfo **) | ||
| 2150 | XtRealloc((char *)lc->infos, sizeof(XawDLInfo*) * lc->num_infos); | ||
| 2151 | } | ||
| 2152 | lc->infos[lc->num_infos - 1] = info; | ||
| 2153 | |||
| 2154 | if (lc->num_infos > 1) | ||
| 2155 | qsort(lc->infos, lc->num_infos, sizeof(XawDLInfo*), qcmp_dlist_info); | ||
| 2156 | |||
| 2157 | return (True1); | ||
| 2158 | } | ||
| 2159 | |||
| 2160 | static int | ||
| 2161 | bcmp_dlist_info(register _Xconstconst void *string, | ||
| 2162 | register _Xconstconst void *dlinfo) | ||
| 2163 | { | ||
| 2164 | return (strcmp((String)string, (*(XawDLClass **)dlinfo)->name)); | ||
| 2165 | } | ||
| 2166 | |||
| 2167 | static XawDLInfo * | ||
| 2168 | _XawFindDLInfo(XawDLClass *lc, String name) | ||
| 2169 | { | ||
| 2170 | XawDLInfo **info; | ||
| 2171 | |||
| 2172 | if (!lc->infos) | ||
| 2173 | return (NULL((void*)0)); | ||
| 2174 | |||
| 2175 | info = (XawDLInfo **)bsearch(name, lc->infos, lc->num_infos, | ||
| 2176 | sizeof(XawDLInfo*), bcmp_dlist_info); | ||
| 2177 | |||
| 2178 | return (info ? *info : NULL((void*)0)); | ||
| 2179 | } | ||
| 2180 | |||
| 2181 | /* Start of DLClass Management Functions */ | ||
| 2182 | XawDLClass * | ||
| 2183 | XawGetDisplayListClass(String name) | ||
| 2184 | { | ||
| 2185 | return (_XawFindDLClass(name)); | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | static int | ||
| 2189 | qcmp_dlist_class(register _Xconstconst void *left, register _Xconstconst void *right) | ||
| 2190 | { | ||
| 2191 | return (strcmp((*(XawDLClass **)left)->name, (*(XawDLClass **)right)->name)); | ||
| 2192 | } | ||
| 2193 | |||
| 2194 | XawDLClass * | ||
| 2195 | XawCreateDisplayListClass(String name, | ||
| 2196 | XawDLArgsInitProc args_init, | ||
| 2197 | XawDLArgsDestructor args_destructor, | ||
| 2198 | XawDLDataInitProc data_init, | ||
| 2199 | XawDLDataDestructor data_destructor) | ||
| 2200 | { | ||
| 2201 | XawDLClass *lc; | ||
| 2202 | |||
| 2203 | if (!name || name[0] == '\0') | ||
| 2204 | return (NULL((void*)0)); | ||
| 2205 | |||
| 2206 | lc = (XawDLClass *)XtMalloc(sizeof(XawDLClass)); | ||
| 2207 | lc->name = XtNewString(name)((name) != ((void*)0) ? (strcpy(XtMalloc((unsigned)strlen(name ) + 1), name)) : ((void*)0)); | ||
| 2208 | lc->infos = NULL((void*)0); | ||
| 2209 | lc->num_infos = 0; | ||
| 2210 | lc->args_init = args_init; | ||
| 2211 | lc->args_destructor = args_destructor; | ||
| 2212 | lc->data_init = data_init; | ||
| 2213 | lc->data_destructor = data_destructor; | ||
| 2214 | |||
| 2215 | if (!classes) | ||
| 2216 | { | ||
| 2217 | num_classes = 1; | ||
| 2218 | classes = (XawDLClass **)XtMalloc(sizeof(XawDLClass)); | ||
| 2219 | } | ||
| 2220 | else | ||
| 2221 | { | ||
| 2222 | ++num_classes; | ||
| 2223 | classes = (XawDLClass **)XtRealloc((char *)classes, | ||
| 2224 | sizeof(XawDLClass) * num_classes); | ||
| 2225 | } | ||
| 2226 | classes[num_classes - 1] = lc; | ||
| 2227 | |||
| 2228 | if (num_classes > 1) | ||
| 2229 | qsort(&classes[0], num_classes, sizeof(XawDLClass*), qcmp_dlist_class); | ||
| 2230 | |||
| 2231 | return (lc); | ||
| 2232 | } | ||
| 2233 | |||
| 2234 | static int | ||
| 2235 | bcmp_dlist_class(register _Xconstconst void *string, | ||
| 2236 | register _Xconstconst void *dlist) | ||
| 2237 | { | ||
| 2238 | return (strcmp((String)string, (*(XawDLClass **)dlist)->name)); | ||
| 2239 | } | ||
| 2240 | |||
| 2241 | static XawDLClass * | ||
| 2242 | _XawFindDLClass(String name) | ||
| 2243 | { | ||
| 2244 | XawDLClass **lc; | ||
| 2245 | |||
| 2246 | if (!classes) | ||
| 2247 | return (NULL((void*)0)); | ||
| 2248 | |||
| 2249 | lc = (XawDLClass **)bsearch(name, &classes[0], num_classes, | ||
| 2250 | sizeof(XawDLClass*), bcmp_dlist_class); | ||
| 2251 | |||
| 2252 | return (lc ? *lc : NULL((void*)0)); | ||
| 2253 | } | ||
| 2254 | |||
| 2255 | #endif /* OLDXAW */ |