| 497 | } |
| 498 | |
| 499 | Boolean |
| 500 | nhCvtStringToPixel( |
| 501 | Display *dpy, |
| 502 | XrmValuePtr args, Cardinal *num_args, |
| 503 | XrmValuePtr fromVal, XrmValuePtr toVal, |
| 504 | XtPointer *closure_ret) |
| 505 | { |
| 506 | String str = (String) fromVal->addr; |
| 507 | XColor screenColor; |
| 508 | XColor exactColor; |
| 509 | Screen *screen; |
| 510 | XtAppContext app = XtDisplayToApplicationContext(dpy); |
| 511 | Colormap colormap; |
| 512 | Status status; |
| 513 | String params[1]; |
| 514 | Cardinal num_params = 1; |
| 515 | |
| 516 | if (*num_args != 2) { |
| 517 | XtAppWarningMsg(app, "wrongParameters", |
| 518 | "cvtStringToPixel", "XtToolkitError", |
| 519 | "String to pixel conversion needs screen and colormap arguments", |
| 520 | (String *) 0, (Cardinal *) 0); |
| 521 | return False; |
| 522 | } |
| 523 | |
| 524 | screen = *((Screen **) args[0].addr); |
| 525 | colormap = *((Colormap *) args[1].addr); |
| 526 | |
| 527 | /* If Xt colors, use the Xt routine and hope for the best */ |
| 528 | #if (XtSpecificationRelease >= 5) |
| 529 | if ((strcmpi(str, XtDefaultBackground) == 0) |
| 530 | || (strcmpi(str, XtDefaultForeground) == 0)) { |
| 531 | return XtCvtStringToPixel(dpy, args, num_args, fromVal, toVal, |
| 532 | closure_ret); |
| 533 | } |
| 534 | #else |
| 535 | if (strcmpi(str, XtDefaultBackground) == 0) { |
| 536 | *closure_ret = (char *) False; |
| 537 | done(Pixel, WhitePixelOfScreen(screen)); |
| 538 | } |
| 539 | if (strcmpi(str, XtDefaultForeground) == 0) { |
| 540 | *closure_ret = (char *) False; |
| 541 | done(Pixel, BlackPixelOfScreen(screen)); |
| 542 | } |
| 543 | #endif |
| 544 | |
| 545 | status = XAllocNamedColor(DisplayOfScreen(screen), colormap, (char *) str, |
| 546 | &screenColor, &exactColor); |
| 547 | if (status == 0) { |
| 548 | String msg, type; |
| 549 | |
| 550 | /* some versions of XAllocNamedColor don't allow #xxyyzz names */ |
| 551 | if (str[0] == '#' && XParseColor(DisplayOfScreen(screen), colormap, |
| 552 | str, &exactColor) |
| 553 | && XAllocColor(DisplayOfScreen(screen), colormap, &exactColor)) { |
| 554 | *closure_ret = (char *) True; |
| 555 | done(Pixel, exactColor.pixel); |
| 556 | } |
nothing calls this directly
no test coverage detected