home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / master12.zip / mastering / scalecolors.c < prev    next >
C/C++ Source or Header  |  1992-08-25  |  19KB  |  554 lines

  1. /*  Xm headers  */
  2. #include <Xm/DialogS.h>
  3. #include <Xm/Form.h>
  4. #include <Xm/Frame.h>
  5. #include <Xm/LabelG.h>
  6. #include <Xm/PushBG.h>
  7. #include <Xm/CascadeB.h>
  8. #include <Xm/MessageB.h>
  9. #include <Xm/RowColumn.h>
  10. #include <Xm/MainW.h>
  11. #include <Xm/Scale.h>
  12.  
  13. /* global defines */
  14. #define CMPSTR(str)      XmStringCreateLtoR (str, XmFONTLIST_DEFAULT_TAG)
  15.  
  16. /* geometry */
  17. #define HORIZONTAL_SPACING         8
  18. #define VERTICAL_SPACING           8
  19. #define TOP_OFFSET                 (Dimension) 30
  20. #define SCALE_HIGHLIGHT_THICKNESS  (Dimension) 2
  21. #define SCALE_WIDTH                400
  22. #define SCALE_HEIGHT               25
  23.  
  24. #define RED     1
  25. #define GREEN   2
  26. #define BLUE    3
  27.  
  28. #define BUFFERSZ       1000
  29.  
  30. Widget  appshell;
  31. Widget  frame; 
  32. Widget  form; 
  33. Widget  redLabel; 
  34. Widget  greenLabel; 
  35. Widget  blueLabel; 
  36. Widget  redScale; 
  37. Widget  greenScale; 
  38. Widget  blueScale; 
  39.  
  40. XColor  bg_color;   /* color structure for the background color */
  41. XColor  fg_color;   /* color structure for the foreground color */
  42. XColor  ts_color;   /* color structure for the top shadow color */
  43. XColor  bs_color;   /* color structure for the bottom shadow color */ 
  44. XColor  sc_color;   /* color structure for the select color (arm) color */ 
  45.  
  46. XmColorProc calcRGB;
  47.  
  48. Display *display;
  49.  
  50. Colormap colormap;
  51.  
  52. /* Forward Declarations */
  53. static Widget CreateHelp();
  54. static void HelpCB();
  55. static void QuitCB();
  56. static void CreateColorEditor();
  57. static void changRGB_CB();
  58. static void SetScales();
  59. static void GenerateColors();
  60.  
  61. Pixel GetPixel();
  62.  
  63. char *tmpbuf = "#78a0d5";
  64. /****************************************/
  65. /* main                                 */
  66. /****************************************/
  67. void main(argc, argv)
  68.     int argc;
  69.     char **argv;
  70. {
  71.    register int n;
  72.    Arg args[4];
  73.    Widget main_window, menu_bar, menu_pane, cascade;
  74.    Widget button;
  75.    Boolean status;
  76.    unsigned long plane_mask;
  77.    unsigned long *color_cells;
  78.    XtAppContext app_context;
  79.  
  80.  /* Initialize the toolkit and open the display */
  81.    appshell = XtAppInitialize(&app_context, "Scalecolors", NULL, 0, &argc,
  82.                               argv, NULL, args, 0);
  83.  
  84.  /* Get the display */
  85.    display = XtDisplay(appshell);
  86.  
  87.  /* Get the default colormap for this display */
  88.    colormap = XDefaultColormap(display, XDefaultScreen(display));
  89.  
  90.  /* Allocate 4 color cells for use with this program: background, 
  91.     foreground, top shadow, and bottom shadow.  The select color 
  92.     won't be used so we don't need to allocate for it */
  93.    color_cells = (unsigned long *)XtMalloc (4 * sizeof (unsigned long));
  94.    status = XAllocColorCells (display, colormap,
  95.                                      0, &plane_mask, 0, color_cells, 4);
  96.  
  97.    if(status == False)
  98.    {
  99.       printf(" couldn't allocate enough color cells\n");
  100.       exit(1);
  101.    }
  102.    else
  103.    {
  104.  /* Assign the allocated color cells to the correct structure */
  105.       n = 0;
  106.       bg_color.pixel = color_cells[n++];
  107.       bg_color.flags = DoRed | DoGreen | DoBlue;
  108.       fg_color.pixel = color_cells[n++];
  109.       fg_color.flags = DoRed | DoGreen | DoBlue;
  110.       bs_color.pixel = color_cells[n++];
  111.       bs_color.flags = DoRed | DoGreen | DoBlue;
  112.       ts_color.pixel = color_cells[n];
  113.       ts_color.flags = DoRed | DoGreen | DoBlue;
  114.    }
  115.  
  116.  /* Get the RGB value (XColor) of the background */
  117.    XParseColor(display, colormap, tmpbuf, &bg_color);
  118.  
  119.  /* Create main window. */
  120.    main_window = XmCreateMainWindow (appshell, "main1", args, 0);
  121.    XtManageChild (main_window);
  122.  
  123.  /* Create menu bar in main window. */
  124.    menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, 0); 
  125.    XtManageChild (menu_bar);
  126.  
  127.  /* Create "File" pulldown menu. */
  128.    menu_pane = XmCreatePulldownMenu (menu_bar, "menu_pane", args, 0);
  129.  
  130.    button = XmCreatePushButtonGadget (menu_pane, "Exit", args, 0);
  131.    XtManageChild (button);
  132.    XtAddCallback (button, XmNactivateCallback, QuitCB, NULL);
  133.   
  134.    n = 0;
  135.    XtSetArg (args[n], XmNsubMenuId, menu_pane); n++;
  136.    cascade = XmCreateCascadeButton (menu_bar, "File", args, n);
  137.    XtManageChild (cascade);
  138.  
  139.  /* Create "Help" button. */
  140.    cascade = XmCreateCascadeButton (menu_bar, "Help", args, 0);
  141.    XtManageChild (cascade);
  142.    XtAddCallback (cascade, XmNactivateCallback, HelpCB, NULL);
  143.  
  144.    n = 0;
  145.    XtSetArg (args[n], XmNmenuHelpWidget, cascade); n++;
  146.    XtSetValues (menu_bar, args, n);
  147.  
  148.  /*
  149.   * Create a frame widget
  150.   */
  151.    n = 0;
  152.    XtSetArg(args[n], XmNmarginWidth, 15); n++;
  153.    XtSetArg(args[n], XmNmarginHeight, 15); n++;
  154.    frame = XmCreateFrame (main_window, "frame", args, n);
  155.    XtManageChild(frame);
  156.  
  157.  /*  Set main window areas  */
  158.    XmMainWindowSetAreas (main_window, menu_bar, NULL, NULL, NULL, frame);
  159.  
  160.  /* Go generate the foreground, top shadow, and bottom shadow colors
  161.     based on the background color which was set by XParseColor above */
  162.    GenerateColors();
  163.  
  164.  /* Create the sliders with labels using the generated colors */
  165.    CreateColorEditor();
  166.  
  167.    XtRealizeWidget (appshell);
  168.  
  169.    XtAppMainLoop (app_context);
  170. }
  171.  
  172.  
  173. /*-------------------------------------------------------------
  174. **  HelpCB      - callback for help button
  175. */
  176. static
  177. void HelpCB (w, client_data, call_data) 
  178. Widget      w;            /*  widget id               */
  179. XtPointer   client_data;  /*  data from application   */
  180. XtPointer   call_data;    /*  data from widget class  */
  181. {
  182.    Widget   message_box;  /*  message box             */
  183.  
  184.  /*  Create help window. */
  185.    message_box = CreateHelp (w);
  186.  
  187.  /*  Display help window. */
  188.    XtManageChild (message_box);
  189. }
  190.  
  191.  
  192. /*-------------------------------------------------------------
  193. **  CreateHelp    - create help window
  194. */
  195. static
  196. Widget CreateHelp (parent) 
  197. Widget    parent;    /*  parent widget  */
  198. {
  199.    Widget        button;
  200.    Widget        message_box;       /*  Message Dialog  */
  201.    Arg           args[4];           /*  arg list        */
  202.    register int  n;                 /*  arg count       */
  203.  
  204.    static char   message[BUFFERSZ];  /*  help text      */
  205.    XmString      title_string = NULL;
  206.    XmString      message_string = NULL;
  207.    XmString      button_string = NULL;
  208.  
  209.  
  210.  /*  Generate message to display. */
  211.  
  212.    sprintf (message, "\
  213. This program uses three scale widgets to balance colors. The three scales\n\
  214. are used to adjust the primary colors: red, blue, and green.  As the\n\
  215. scales are adjusted, the background color changes accordingly.  To\n\
  216. terminate the program, press the 'File' button and then the 'Exit'\n\
  217. button.\0");
  218.  
  219.  
  220.  /* Create the compound strings */
  221.    message_string = CMPSTR (message);
  222.    button_string = CMPSTR ("Close");
  223.    title_string = CMPSTR ("scalecolors help");
  224.  
  225.  /*  Create message box dialog. */
  226.    n = 0;
  227.    XtSetArg (args[n], XmNdialogTitle, title_string);  n++;
  228.    XtSetArg (args[n], XmNokLabelString, button_string);  n++;
  229.    XtSetArg (args[n], XmNmessageString, message_string);  n++;
  230.    message_box = XmCreateMessageDialog (parent, "helpbox", args, n);
  231.  
  232.    button = XmMessageBoxGetChild (message_box, XmDIALOG_CANCEL_BUTTON);
  233.    XtUnmanageChild (button);
  234.    button = XmMessageBoxGetChild (message_box, XmDIALOG_HELP_BUTTON);
  235.    XtUnmanageChild (button);
  236.  
  237.  /*  Free strings and return message box. */
  238.    if (title_string) XmStringFree (title_string);
  239.    if (message_string) XmStringFree (message_string);
  240.    if (button_string) XmStringFree (button_string);
  241.    return (message_box);
  242. }
  243.  
  244.  
  245. /*-------------------------------------------------------------
  246. **  QuitCB      - callback for quit button
  247. */
  248. static
  249. void QuitCB (w, client_data, call_data) 
  250. Widget     w;            /*  widget id               */
  251. XtPointer  client_data;  /*  data from application   */
  252. XtPointer  call_data;    /*  data from widget class  */
  253. {
  254.  /*  Terminate the application. */
  255.    exit (0);
  256. }
  257.  
  258.  
  259. /*--------------------------------------------------------------
  260.  * CreateColorEditor  -  Create the form and scale widgets
  261.  */
  262. static void 
  263. CreateColorEditor()
  264. {
  265.    register int     n;
  266.    Arg              args[15];
  267.    XmString         string;               /* temp Xm string */
  268.    WidgetList       children;
  269.  
  270.  /* Create form widget */
  271.    n=0;
  272.    XtSetArg(args[n], XmNhorizontalSpacing, HORIZONTAL_SPACING); n++;
  273.    XtSetArg(args[n], XmNverticalSpacing, VERTICAL_SPACING); n++;
  274.    XtSetArg(args[n], XmNbackground, bg_color.pixel);  n++;
  275.    XtSetArg(args[n], XmNforeground, fg_color.pixel);  n++;
  276.    XtSetArg(args[n], XmNtopShadowColor, ts_color.pixel);  n++;
  277.    XtSetArg(args[n], XmNbottomShadowColor, bs_color.pixel);  n++;
  278.    form = XmCreateForm(frame,"form", args, n);
  279.                       
  280.    XtManageChild (form);
  281.  
  282.  /*
  283.   * Create RGB label gadgets for R, G, B, labels
  284.   */
  285.    string =  CMPSTR("R");
  286.    n = 0;
  287.    XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  288.    XtSetArg(args[n], XmNlabelString, string); n++;
  289.    XtSetArg(args[n], XmNmarginHeight, 0); n++;
  290.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_FORM); n++;
  291.    XtSetArg(args[n], XmNtopOffset, TOP_OFFSET); n++;
  292.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  293.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_FORM); n++;
  294.    XtSetArg(args[n], XmNrightAttachment,   XmATTACH_NONE); n++;
  295.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  296.    redLabel = XmCreateLabelGadget(form, "redLabel", args, n);
  297.    XtManageChild(redLabel);
  298.    XmStringFree(string);
  299.  
  300.    string =  CMPSTR("G");
  301.    n = 0;
  302.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_WIDGET); n++;
  303.    XtSetArg(args[n], XmNtopWidget, redLabel); n++;
  304.    XtSetArg(args[n], XmNtopOffset, TOP_OFFSET); n++;
  305.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  306.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_FORM); n++;
  307.    XtSetArg(args[n], XmNrightAttachment,  XmATTACH_NONE); n++;
  308.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  309.    XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  310.    XtSetArg(args[n], XmNlabelString, string); n++;
  311.    XtSetArg(args[n], XmNmarginHeight, 0); n++;
  312.    greenLabel = XmCreateLabelGadget(form, "greenLabel", args, n);
  313.    XtManageChild(greenLabel);
  314.    XmStringFree(string);
  315.  
  316.    string =  CMPSTR("B");
  317.    n = 0;
  318.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  319.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_WIDGET); n++;
  320.    XtSetArg(args[n], XmNtopWidget, greenLabel); n++;
  321.    XtSetArg(args[n], XmNtopOffset, TOP_OFFSET); n++;
  322.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  323.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_FORM); n++;
  324.    XtSetArg(args[n], XmNrightAttachment,  XmATTACH_NONE); n++;
  325.    XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  326.    XtSetArg(args[n], XmNlabelString, string); n++;
  327.    XtSetArg(args[n], XmNmarginHeight, 0); n++;
  328.    blueLabel = XmCreateLabelGadget(form, "blueLabel", args, n);
  329.    XtManageChild(blueLabel);
  330.    XmStringFree(string);
  331.  
  332.  /*
  333.   * Create the three scale widgets, one each for red, green, and blue
  334.   */
  335.    n = 0;
  336.    XtSetArg(args[n], XmNbackground, bg_color.pixel);  n++;
  337.    XtSetArg(args[n], XmNforeground, fg_color.pixel);  n++;
  338.    XtSetArg(args[n], XmNtopShadowColor, ts_color.pixel);  n++;
  339.    XtSetArg(args[n], XmNbottomShadowColor, bs_color.pixel);  n++;
  340.    XtSetArg(args[n], XmNshowValue, True);  n++;
  341.    XtSetArg(args[n], XmNorientation, XmHORIZONTAL);  n++;
  342.    XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT);  n++;
  343.    XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS);  n++; 
  344.    XtSetArg(args[n], XmNmaximum, 0xff);  n++;
  345.    XtSetArg(args[n], XmNminimum, 0x0);  n++;
  346.    XtSetArg(args[n], XmNincrement, 1); n++;
  347.    XtSetArg(args[n], XmNscaleWidth, SCALE_WIDTH); n++; 
  348.    XtSetArg(args[n], XmNscaleHeight, SCALE_HEIGHT); n++; 
  349.    redScale = XmCreateScale(form, "redScale", args, n);
  350.    XtManageChild(redScale);
  351.    XtAddCallback(redScale, XmNvalueChangedCallback, changRGB_CB,
  352.                                                       (XtPointer) RED);
  353.    XtAddCallback(redScale, XmNdragCallback, changRGB_CB, (XtPointer) RED );
  354.  
  355.    greenScale = XmCreateScale(form, "greenScale", args, n);
  356.    XtManageChild(greenScale);
  357.    XtAddCallback(greenScale, XmNvalueChangedCallback, changRGB_CB,
  358.                                                       (XtPointer) GREEN );
  359.    XtAddCallback(greenScale, XmNdragCallback, changRGB_CB, (XtPointer) GREEN );
  360.  
  361.    blueScale = XmCreateScale(form, "blueScale", args, n);
  362.    XtManageChild(blueScale);
  363.    XtAddCallback(blueScale, XmNvalueChangedCallback, changRGB_CB,
  364.                                                       (XtPointer) BLUE );
  365.    XtAddCallback(blueScale, XmNdragCallback, changRGB_CB, (XtPointer) BLUE);
  366.  
  367.  /* Add to Red Scale */
  368.    n=0;
  369.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  370.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_FORM); n++;
  371.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  372.    XtSetArg(args[n], XmNbottomWidget, redLabel); n++;
  373.    XtSetArg(args[n], XmNbottomOffset,  0); n++;
  374.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_WIDGET); n++;
  375.    XtSetArg(args[n], XmNleftWidget, redLabel); n++;
  376.    XtSetArg(args[n], XmNleftOffset,  HORIZONTAL_SPACING); n++;
  377.    XtSetArg(args[n], XmNrightAttachment,  XmATTACH_FORM); n++;
  378.    XtSetValues (redScale, args, n);
  379.  
  380.  /* Add to Green Scale */
  381.    n=0;
  382.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  383.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_NONE); n++;
  384.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  385.    XtSetArg(args[n], XmNbottomWidget, greenLabel); n++;
  386.    XtSetArg(args[n], XmNbottomOffset,  0); n++;
  387.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_WIDGET); n++;
  388.    XtSetArg(args[n], XmNleftWidget, redLabel); n++;
  389.    XtSetArg(args[n], XmNleftOffset,  HORIZONTAL_SPACING); n++;
  390.    XtSetArg(args[n], XmNrightAttachment,  XmATTACH_FORM); n++;
  391.    XtSetValues (greenScale, args, n);
  392.  
  393.  /* Add to Blue Scale */
  394.    n=0;
  395.    XtSetArg(args[n], XmNhorizontalSpacing,    30); n++;
  396.    XtSetArg(args[n], XmNtopAttachment,    XmATTACH_NONE); n++;
  397.    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  398.    XtSetArg(args[n], XmNbottomWidget, blueLabel); n++;
  399.    XtSetArg(args[n], XmNbottomOffset,  0); n++;
  400.    XtSetArg(args[n], XmNleftAttachment,   XmATTACH_WIDGET); n++;
  401.    XtSetArg(args[n], XmNleftWidget, redLabel); n++;
  402.    XtSetArg(args[n], XmNleftOffset,  HORIZONTAL_SPACING); n++;
  403.    XtSetArg(args[n], XmNrightAttachment,  XmATTACH_FORM); n++;
  404.    XtSetValues (blueScale, args, n);
  405.  
  406.  /* Set the scales to the bg component of the selected color */
  407.    SetScales(&bg_color);
  408.  
  409.  /* Set the trough colors of the RGB scales -
  410.     get the composite children of the scales - 
  411.     child[1] is the scroll bar */
  412.    n=0;
  413.    XtSetArg(args[n], XmNchildren, &children); n++;
  414.    XtGetValues(redScale, args, n);
  415.    n=0;
  416.    XtSetArg(args[n], XmNtroughColor, GetPixel(form,"red"));  n++;
  417.    XtSetValues (children[1], args, n);
  418.  
  419.    n=0;
  420.    XtSetArg(args[n], XmNchildren, &children); n++;
  421.    XtGetValues(greenScale, args, n);
  422.    n=0;
  423.    XtSetArg(args[n], XmNtroughColor, GetPixel(form,"green"));  n++; 
  424.    XtSetValues (children[1], args, n);
  425.  
  426.    n=0;
  427.    XtSetArg(args[n], XmNchildren, &children); n++;
  428.    XtGetValues(blueScale, args, n);
  429.    n=0;
  430.    XtSetArg(args[n], XmNtroughColor, GetPixel(form,"blue"));  n++; 
  431.    XtSetValues (children[1], args, n);
  432.  
  433. }
  434.  
  435. /************************************************************************
  436.  *   GenerateColors()
  437.  *           Generates new RGB values for foreground, top shadow, 
  438.  *           bottom shadow, and select color based on the background.
  439.  *           Select color is not used in our program but the Motif color
  440.  *           generation routine expects it and calculates it.
  441.  *           The Colors generated are stored in the red, green, and blue
  442.  *           fields of the XColor structure passed in.
  443.  *           The generated colors are then used to update the color cells
  444.  *           of the ColorSet being edited.
  445.  ************************************************************************/
  446. static void 
  447. GenerateColors()
  448. {
  449.    XColor colors[4];
  450.    int j=0;
  451.  
  452.  /* Get the color calculation procedure */   
  453.    if (calcRGB == NULL) 
  454.        calcRGB = XmGetColorCalculation();
  455.  
  456.  /* Given the background color, calculate the foreground, select color,
  457.      top shadow, and bottom shadow colors */
  458.    (*calcRGB)(&bg_color, &fg_color, &sc_color, &ts_color, &bs_color);
  459.    
  460.  /* Put those calculated colors in an array */
  461.    colors[j++] =  bg_color;
  462.    colors[j++] =  fg_color; 
  463.    colors[j++] =  ts_color;
  464.    colors[j++] =  bs_color;
  465.  
  466.  /* Go change the colors dynamically */
  467.    XStoreColors(display, colormap, colors, j);
  468. }
  469.  
  470. /************************************************************************
  471.  *   changeRGB_CB()
  472.  *           Called when one of the RGB scales is moved
  473.  ************************************************************************/
  474. static void 
  475. changRGB_CB( w, client_data, call_data )
  476. Widget    w;
  477. XtPointer client_data;
  478. XtPointer call_data;
  479. {
  480.    int reason_code;
  481.    int value;
  482.    int color;
  483.  
  484.    reason_code = ((XmAnyCallbackStruct *)call_data)->reason;
  485.    if ( reason_code == XmCR_VALUE_CHANGED || reason_code == XmCR_DRAG )
  486.    {
  487.       color = (int) client_data;
  488.       value = ((XmScaleCallbackStruct *)call_data)->value;
  489.  
  490.       /*
  491.        * Shift value -- to make up for scale max of only 0xff
  492.        */
  493.       value <<= 8;
  494.       switch (color)
  495.       {
  496.         case RED:
  497.            bg_color.red = value;
  498.            break;
  499.         case GREEN:
  500.            bg_color.green = value;
  501.            break;
  502.         case BLUE:
  503.            bg_color.blue = value;
  504.            break;
  505.         default:
  506.            return;
  507.       }
  508.  
  509.       SetScales(&bg_color);
  510.       GenerateColors();
  511.    }
  512. }
  513.  
  514.  
  515. /************************************************************************
  516.  *   SetScales()
  517.  *           passed an XColor, updates all scales.
  518.  ************************************************************************/
  519. static void 
  520. SetScales( rgb )
  521. XColor *rgb;
  522. {
  523.    XmScaleSetValue(redScale,rgb->red >> 8);
  524.    XmScaleSetValue(greenScale,rgb->green >> 8);
  525.    XmScaleSetValue(blueScale,rgb->blue >> 8);
  526. }
  527.  
  528.  
  529. /************************************************************************
  530.  *   GetPixel()
  531.  *         passed in a color string, calls XtConvert which is an X 
  532.  *         toolkit converter which converts a string into a pixel value.
  533.  ************************************************************************/
  534. Pixel 
  535. GetPixel( widget, color_string )
  536. Widget widget;
  537. char *color_string;
  538. {
  539.    XrmValue from, to;
  540.  
  541.  /* Determine the size of the string passed in */
  542.    from.size = strlen(color_string) + 1;
  543.    if (from.size < sizeof(String))
  544.        from.size = sizeof(String);
  545.    from.addr = color_string;
  546.  
  547.  /* Go convert the string into a pixel (i.e. color cell) */
  548.    XtConvert(widget, XmRString, &from, XmRPixel, &to);
  549.  
  550.  /* Return that pixel */
  551.    return ((Pixel) *((Pixel *) to.addr));
  552. }
  553.  
  554.