home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xaw / SmeBSB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-15  |  18.4 KB  |  628 lines

  1. /* $XConsortium: SmeBSB.c,v 1.16 91/03/15 15:59:41 gildea Exp $ */
  2.  
  3. /*
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. /*
  25.  * SmeBSB.c - Source code file for BSB Menu Entry object.
  26.  *
  27.  * Date:    September 26, 1989
  28.  *
  29.  * By:      Chris D. Peterson
  30.  *          MIT X Consortium 
  31.  *          kit@expo.lcs.mit.edu
  32.  */
  33.  
  34. #include <X11/IntrinsicP.h>
  35. #include <X11/StringDefs.h>
  36. #include <X11/Xos.h>
  37.  
  38. #include <X11/Xmu/Drawing.h>
  39.  
  40. #include <X11/Xaw/XawInit.h>
  41. #include <X11/Xaw/SimpleMenu.h>
  42. #include <X11/Xaw/SmeBSBP.h>
  43. #include <X11/Xaw/Cardinals.h>
  44.  
  45. #include <stdio.h>
  46.  
  47. #define ONE_HUNDRED 100
  48.  
  49. #define offset(field) XtOffsetOf(SmeBSBRec, sme_bsb.field)
  50.  
  51. static XtResource resources[] = {
  52.   {XtNlabel,  XtCLabel, XtRString, sizeof(String),
  53.      offset(label), XtRString, NULL},
  54.   {XtNvertSpace,  XtCVertSpace, XtRInt, sizeof(int),
  55.      offset(vert_space), XtRImmediate, (XtPointer) 25},
  56.   {XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
  57.      offset(left_bitmap), XtRImmediate, (XtPointer)None},
  58.   {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
  59.      offset(justify), XtRImmediate, (XtPointer) XtJustifyLeft},
  60.   {XtNrightBitmap, XtCRightBitmap, XtRBitmap, sizeof(Pixmap),
  61.      offset(right_bitmap), XtRImmediate, (XtPointer)None},
  62.   {XtNleftMargin,  XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
  63.      offset(left_margin), XtRImmediate, (XtPointer) 4},
  64.   {XtNrightMargin,  XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
  65.      offset(right_margin), XtRImmediate, (XtPointer) 4},
  66.   {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
  67.      offset(foreground), XtRString, XtDefaultForeground},
  68.   {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
  69.      offset(font), XtRString, XtDefaultFont},
  70. };   
  71. #undef offset
  72.  
  73. /*
  74.  * Semi Public function definitions. 
  75.  */
  76.  
  77. static void Redisplay(), Destroy(), Initialize(), FlipColors();
  78. static void ClassInitialize();
  79. static Boolean SetValues();
  80. static XtGeometryResult QueryGeometry();
  81.  
  82. /* 
  83.  * Private Function Definitions.
  84.  */
  85.  
  86. static void GetDefaultSize(), DrawBitmaps(), GetBitmapInfo();
  87. static void CreateGCs(), DestroyGCs();
  88.     
  89. #define superclass (&smeClassRec)
  90. SmeBSBClassRec smeBSBClassRec = {
  91.   {
  92.     /* superclass         */    (WidgetClass) superclass,
  93.     /* class_name         */    "SmeBSB",
  94.     /* size               */    sizeof(SmeBSBRec),
  95.     /* class_initializer  */    ClassInitialize,
  96.     /* class_part_initialize*/    NULL,
  97.     /* Class init'ed      */    FALSE,
  98.     /* initialize         */    Initialize,
  99.     /* initialize_hook    */    NULL,
  100.     /* realize            */    NULL,
  101.     /* actions            */    NULL,
  102.     /* num_actions        */    ZERO,
  103.     /* resources          */    resources,
  104.     /* resource_count     */    XtNumber(resources),
  105.     /* xrm_class          */    NULLQUARK,
  106.     /* compress_motion    */    FALSE, 
  107.     /* compress_exposure  */    FALSE,
  108.     /* compress_enterleave*/     FALSE,
  109.     /* visible_interest   */    FALSE,
  110.     /* destroy            */    Destroy,
  111.     /* resize             */    NULL,
  112.     /* expose             */    Redisplay,
  113.     /* set_values         */    SetValues,
  114.     /* set_values_hook    */    NULL,
  115.     /* set_values_almost  */    XtInheritSetValuesAlmost,  
  116.     /* get_values_hook    */    NULL,            
  117.     /* accept_focus       */    NULL,
  118.     /* intrinsics version */    XtVersion,
  119.     /* callback offsets   */    NULL,
  120.     /* tm_table          */    NULL,
  121.     /* query_geometry      */    QueryGeometry,
  122.     /* display_accelerator*/    NULL,
  123.     /* extension      */    NULL
  124.   },{
  125.     /* Menu Entry Fields */
  126.       
  127.     /* highlight */             FlipColors,
  128.     /* unhighlight */           FlipColors,
  129.     /* notify */        XtInheritNotify,        
  130.     /* extension      */    NULL
  131.   }, {
  132.     /* BSB Menu entry Fields */  
  133.  
  134.     /* extension      */    NULL
  135.   }
  136. };
  137.  
  138. WidgetClass smeBSBObjectClass = (WidgetClass) &smeBSBClassRec;
  139.  
  140. /************************************************************
  141.  *
  142.  * Semi-Public Functions.
  143.  *
  144.  ************************************************************/
  145.  
  146. /*    Function Name: ClassInitialize
  147.  *    Description: Initializes the SmeBSBObject. 
  148.  *    Arguments: none.
  149.  *    Returns: none.
  150.  */
  151.  
  152. static void 
  153. ClassInitialize()
  154. {
  155.     XawInitializeWidgetSet();
  156.     XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0 );
  157. }
  158.  
  159. /*      Function Name: Initialize
  160.  *      Description: Initializes the simple menu widget
  161.  *      Arguments: request - the widget requested by the argument list.
  162.  *                 new     - the new widget with both resource and non
  163.  *                           resource values.
  164.  *      Returns: none.
  165.  */
  166.  
  167. /* ARGSUSED */
  168. static void
  169. Initialize(request, new)
  170. Widget request, new;
  171. {
  172.     SmeBSBObject entry = (SmeBSBObject) new;
  173.  
  174.     if (entry->sme_bsb.label == NULL) 
  175.     entry->sme_bsb.label = XtName(new);
  176.     else
  177.     entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
  178.  
  179.     GetDefaultSize(new, &(entry->rectangle.width), &(entry->rectangle.height));
  180.     CreateGCs(new);
  181.  
  182.     entry->sme_bsb.left_bitmap_width = entry->sme_bsb.left_bitmap_height = 0;
  183.     entry->sme_bsb.right_bitmap_width = entry->sme_bsb.right_bitmap_height = 0;
  184.  
  185.     GetBitmapInfo(new, TRUE);    /* Left Bitmap Info */
  186.     GetBitmapInfo(new, FALSE);    /* Right Bitmap Info */
  187. }
  188.  
  189. /*      Function Name: Destroy
  190.  *      Description: Called at destroy time, cleans up.
  191.  *      Arguments: w - the simple menu widget.
  192.  *      Returns: none.
  193.  */
  194.  
  195. static void
  196. Destroy(w)
  197. Widget w;
  198. {
  199.     SmeBSBObject entry = (SmeBSBObject) w;
  200.  
  201.     DestroyGCs(w);
  202.     if (entry->sme_bsb.label != XtName(w))
  203.     XtFree(entry->sme_bsb.label);
  204. }
  205.  
  206. /*      Function Name: Redisplay
  207.  *      Description: Redisplays the contents of the widget.
  208.  *      Arguments: w - the simple menu widget.
  209.  *                 event - the X event that caused this redisplay.
  210.  *                 region - the region the needs to be repainted. 
  211.  *      Returns: none.
  212.  */
  213.  
  214. /* ARGSUSED */
  215. static void
  216. Redisplay(w, event, region)
  217. Widget w;
  218. XEvent * event;
  219. Region region;
  220. {
  221.     GC gc;
  222.     SmeBSBObject entry = (SmeBSBObject) w;
  223.     int    font_ascent, font_descent, y_loc;
  224.  
  225.     entry->sme_bsb.set_values_area_cleared = FALSE;    
  226.     font_ascent = entry->sme_bsb.font->max_bounds.ascent;
  227.     font_descent = entry->sme_bsb.font->max_bounds.descent;
  228.  
  229.     y_loc = entry->rectangle.y;
  230.     
  231.     if (XtIsSensitive(w) && XtIsSensitive( XtParent(w) ) ) {
  232.     if ( w == XawSimpleMenuGetActiveEntry(XtParent(w)) ) {
  233.         XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), 
  234.                entry->sme_bsb.norm_gc, 0, y_loc,
  235.                (unsigned int) entry->rectangle.width,
  236.                (unsigned int) entry->rectangle.height);
  237.         gc = entry->sme_bsb.rev_gc;
  238.     }
  239.     else
  240.         gc = entry->sme_bsb.norm_gc;
  241.     }
  242.     else
  243.     gc = entry->sme_bsb.norm_gray_gc;
  244.     
  245.     if (entry->sme_bsb.label != NULL) {
  246.     int x_loc = entry->sme_bsb.left_margin;
  247.     int len = strlen(entry->sme_bsb.label);
  248.     char * label = entry->sme_bsb.label;
  249.  
  250.     switch(entry->sme_bsb.justify) {
  251.         int width, t_width;
  252.  
  253.     case XtJustifyCenter:
  254.         t_width = XTextWidth(entry->sme_bsb.font, label, len);
  255.         width = entry->rectangle.width - (entry->sme_bsb.left_margin +
  256.                           entry->sme_bsb.right_margin);
  257.         x_loc += (width - t_width)/2;
  258.         break;
  259.     case XtJustifyRight:
  260.         t_width = XTextWidth(entry->sme_bsb.font, label, len);
  261.         x_loc = entry->rectangle.width - (entry->sme_bsb.right_margin +
  262.                           t_width);
  263.         break;
  264.     case XtJustifyLeft:
  265.     default:
  266.         break;
  267.     }
  268.  
  269.     y_loc += ((int)entry->rectangle.height - 
  270.           (font_ascent + font_descent)) / 2 + font_ascent;
  271.     
  272.     XDrawString(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
  273.             x_loc, y_loc, label, len);
  274.     }
  275.  
  276.     DrawBitmaps(w, gc);
  277. }
  278.  
  279.  
  280. /*      Function Name: SetValues
  281.  *      Description: Relayout the menu when one of the resources is changed.
  282.  *      Arguments: current - current state of the widget.
  283.  *                 request - what was requested.
  284.  *                 new - what the widget will become.
  285.  *      Returns: none
  286.  */
  287.  
  288. /* ARGSUSED */
  289. static Boolean
  290. SetValues(current, request, new)
  291. Widget current, request, new;
  292. {
  293.     SmeBSBObject entry = (SmeBSBObject) new;
  294.     SmeBSBObject old_entry = (SmeBSBObject) current;
  295.     Boolean ret_val = FALSE;
  296.  
  297.     if (old_entry->sme_bsb.label != entry->sme_bsb.label) {
  298.         if (old_entry->sme_bsb.label != XtName( new ) )
  299.         XtFree( (char *) old_entry->sme_bsb.label );
  300.  
  301.     if (entry->sme_bsb.label != XtName(new) ) 
  302.         entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
  303.  
  304.     ret_val = True;
  305.     }
  306.  
  307.     if (entry->rectangle.sensitive != old_entry->rectangle.sensitive )
  308.     ret_val = TRUE;
  309.  
  310.     if (entry->sme_bsb.left_bitmap != old_entry->sme_bsb.left_bitmap) {
  311.     GetBitmapInfo(new, TRUE);
  312.     ret_val = TRUE;
  313.     }
  314.  
  315.     if (entry->sme_bsb.right_bitmap != old_entry->sme_bsb.right_bitmap) {
  316.     GetBitmapInfo(new, FALSE);
  317.     ret_val = TRUE;
  318.     }
  319.  
  320.     if ( (old_entry->sme_bsb.font != entry->sme_bsb.font) ||
  321.      (old_entry->sme_bsb.foreground != entry->sme_bsb.foreground) ) {
  322.     DestroyGCs(current);
  323.     CreateGCs(new);
  324.     ret_val = TRUE;
  325.     }
  326.  
  327.     if (ret_val) {
  328.     GetDefaultSize(new, 
  329.                &(entry->rectangle.width), &(entry->rectangle.height));
  330.     entry->sme_bsb.set_values_area_cleared = TRUE;
  331.     }
  332.     return(ret_val);
  333. }
  334.  
  335. /*    Function Name: QueryGeometry.
  336.  *    Description: Returns the preferred geometry for this widget.
  337.  *    Arguments: w - the menu entry object.
  338.  *                 itended, return_val - the intended and return geometry info.
  339.  *    Returns: A Geometry Result.
  340.  *
  341.  * See the Intrinsics manual for details on what this function is for.
  342.  * 
  343.  * I just return the height and width of the label plus the margins.
  344.  */
  345.  
  346. static XtGeometryResult
  347. QueryGeometry(w, intended, return_val) 
  348. Widget w;
  349. XtWidgetGeometry *intended, *return_val;
  350. {
  351.     SmeBSBObject entry = (SmeBSBObject) w;
  352.     Dimension width, height;
  353.     XtGeometryResult ret_val = XtGeometryYes;
  354.     XtGeometryMask mode = intended->request_mode;
  355.  
  356.     GetDefaultSize(w, &width, &height );    
  357.  
  358.     if ( ((mode & CWWidth) && (intended->width != width)) ||
  359.      !(mode & CWWidth) ) {
  360.     return_val->request_mode |= CWWidth;
  361.     return_val->width = width;
  362.     ret_val = XtGeometryAlmost;
  363.     }
  364.  
  365.     if ( ((mode & CWHeight) && (intended->height != height)) ||
  366.      !(mode & CWHeight) ) {
  367.     return_val->request_mode |= CWHeight;
  368.     return_val->height = height;
  369.     ret_val = XtGeometryAlmost;
  370.     }
  371.  
  372.     if (ret_val == XtGeometryAlmost) {
  373.     mode = return_val->request_mode;
  374.     
  375.     if ( ((mode & CWWidth) && (width == entry->rectangle.width)) &&
  376.          ((mode & CWHeight) && (height == entry->rectangle.height)) )
  377.         return(XtGeometryNo);
  378.     }
  379.  
  380.     return(ret_val);
  381. }
  382.     
  383. /*      Function Name: FlipColors
  384.  *      Description: Invert the colors of the current entry.
  385.  *      Arguments: w - the bsb menu entry widget.
  386.  *      Returns: none.
  387.  */
  388.  
  389. static void 
  390. FlipColors(w)
  391. Widget w;
  392. {
  393.     SmeBSBObject entry = (SmeBSBObject) w;
  394.  
  395.     if (entry->sme_bsb.set_values_area_cleared) return;
  396.  
  397.     XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
  398.            entry->sme_bsb.invert_gc, 0, (int) entry->rectangle.y,
  399.            (unsigned int) entry->rectangle.width, 
  400.            (unsigned int) entry->rectangle.height);
  401. }
  402.  
  403. /************************************************************
  404.  *
  405.  * Private Functions.
  406.  *
  407.  ************************************************************/
  408.  
  409. /*    Function Name: GetDefaultSize
  410.  *    Description: Calculates the Default (preferred) size of
  411.  *                   this menu entry.
  412.  *    Arguments: w - the menu entry widget.
  413.  *                 width, height - default sizes (RETURNED).
  414.  *    Returns: none.
  415.  */
  416.  
  417. static void
  418. GetDefaultSize(w, width, height) 
  419. Widget w;
  420. Dimension * width, * height;
  421. {
  422.     SmeBSBObject entry = (SmeBSBObject) w;
  423.  
  424.     if (entry->sme_bsb.label == NULL) 
  425.     *width = 0;
  426.     else
  427.     *width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label,
  428.                 strlen(entry->sme_bsb.label));
  429.  
  430.     *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
  431.     
  432.     *height = (entry->sme_bsb.font->max_bounds.ascent +
  433.            entry->sme_bsb.font->max_bounds.descent);
  434.  
  435.     *height = ((int)*height * ( ONE_HUNDRED + 
  436.                     entry->sme_bsb.vert_space )) / ONE_HUNDRED;
  437. }
  438.  
  439. /*      Function Name: DrawBitmaps
  440.  *      Description: Draws left and right bitmaps.
  441.  *      Arguments: w - the simple menu widget.
  442.  *                 gc - graphics context to use for drawing.
  443.  *      Returns: none
  444.  */
  445.  
  446. static void
  447. DrawBitmaps(w, gc)
  448. Widget w;
  449. GC gc;
  450. {
  451.     int x_loc, y_loc;
  452.     SmeBSBObject entry = (SmeBSBObject) w;
  453.     
  454.     if ( (entry->sme_bsb.left_bitmap == None) && 
  455.      (entry->sme_bsb.right_bitmap == None) ) return;
  456.  
  457. /*
  458.  * Draw Left Bitmap.
  459.  */
  460.  
  461.   if (entry->sme_bsb.left_bitmap != None) {
  462.     x_loc = (int)(entry->sme_bsb.left_margin -
  463.               entry->sme_bsb.left_bitmap_width) / 2;
  464.  
  465.     y_loc = entry->rectangle.y + (int)(entry->rectangle.height -
  466.                        entry->sme_bsb.left_bitmap_height) / 2;
  467.  
  468.     XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap,
  469.            XtWindowOfObject(w), gc, 0, 0, 
  470.            entry->sme_bsb.left_bitmap_width,
  471.            entry->sme_bsb.left_bitmap_height, x_loc, y_loc, 1);
  472.   }
  473.  
  474. /*
  475.  * Draw Right Bitmap.
  476.  */
  477.  
  478.  
  479.   if (entry->sme_bsb.right_bitmap != None) {
  480.     x_loc = entry->rectangle.width -
  481.           (int)(entry->sme_bsb.right_margin +
  482.             entry->sme_bsb.right_bitmap_width) / 2;
  483.  
  484.     y_loc = entry->rectangle.y + (int)(entry->rectangle.height -
  485.                        entry->sme_bsb.right_bitmap_height) / 2;
  486.  
  487.     XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap,
  488.            XtWindowOfObject(w), gc, 0, 0, 
  489.            entry->sme_bsb.right_bitmap_width,
  490.            entry->sme_bsb.right_bitmap_height, x_loc, y_loc, 1);
  491.   }
  492. }
  493.  
  494. /*      Function Name: GetBitmapInfo
  495.  *      Description: Gets the bitmap information from either of the bitmaps.
  496.  *      Arguments: w - the bsb menu entry widget.
  497.  *                 is_left - TRUE if we are testing left bitmap,
  498.  *                           FALSE if we are testing the right bitmap.
  499.  *      Returns: none
  500.  */
  501.  
  502. static void
  503. GetBitmapInfo(w, is_left)
  504. Widget w;
  505. Boolean is_left;
  506. {
  507.     SmeBSBObject entry = (SmeBSBObject) w;    
  508.     unsigned int depth, bw;
  509.     Window root;
  510.     int x, y;
  511.     unsigned int width, height;
  512.     char buf[BUFSIZ];
  513.     
  514.     if (is_left) {
  515.     if (entry->sme_bsb.left_bitmap != None) {
  516.         if (!XGetGeometry(XtDisplayOfObject(w), 
  517.                   entry->sme_bsb.left_bitmap, &root, 
  518.                   &x, &y, &width, &height, &bw, &depth)) {
  519.         sprintf(buf, "SmeBSB Object: %s %s \"%s\".", "Could not",
  520.             "get Left Bitmap geometry information for menu entry ",
  521.             XtName(w));
  522.         XtAppError(XtWidgetToApplicationContext(w), buf);
  523.         }
  524.         if (depth != 1) {
  525.         sprintf(buf, "SmeBSB Object: %s \"%s\"%s.", 
  526.             "Left Bitmap of entry ", 
  527.             XtName(w), " is not one bit deep.");
  528.         XtAppError(XtWidgetToApplicationContext(w), buf);
  529.         }
  530.         entry->sme_bsb.left_bitmap_width = (Dimension) width; 
  531.         entry->sme_bsb.left_bitmap_height = (Dimension) height;
  532.     }
  533.     }
  534.     else if (entry->sme_bsb.right_bitmap != None) {
  535.     if (!XGetGeometry(XtDisplayOfObject(w),
  536.               entry->sme_bsb.right_bitmap, &root,
  537.               &x, &y, &width, &height, &bw, &depth)) {
  538.         sprintf(buf, "SmeBSB Object: %s %s \"%s\".", "Could not",
  539.             "get Right Bitmap geometry information for menu entry ",
  540.             XtName(w));
  541.         XtAppError(XtWidgetToApplicationContext(w), buf);
  542.     }
  543.     if (depth != 1) {
  544.         sprintf(buf, "SmeBSB Object: %s \"%s\"%s.", 
  545.             "Right Bitmap of entry ", XtName(w),
  546.             " is not one bit deep.");
  547.         XtAppError(XtWidgetToApplicationContext(w), buf);
  548.     }
  549.     entry->sme_bsb.right_bitmap_width = (Dimension) width; 
  550.     entry->sme_bsb.right_bitmap_height = (Dimension) height;
  551.     }
  552. }      
  553.  
  554. /*      Function Name: CreateGCs
  555.  *      Description: Creates all gc's for the simple menu widget.
  556.  *      Arguments: w - the simple menu widget.
  557.  *      Returns: none.
  558.  */
  559.  
  560. static void
  561. CreateGCs(w)
  562. Widget w;
  563. {
  564.     SmeBSBObject entry = (SmeBSBObject) w;    
  565.     XGCValues values;
  566.     XtGCMask mask;
  567.     
  568.     values.foreground = XtParent(w)->core.background_pixel;
  569.     values.background = entry->sme_bsb.foreground;
  570.     values.font = entry->sme_bsb.font->fid;
  571.     values.graphics_exposures = FALSE;
  572.     mask        = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
  573.     entry->sme_bsb.rev_gc = XtGetGC(w, mask, &values);
  574.     
  575.     values.foreground = entry->sme_bsb.foreground;
  576.     values.background = XtParent(w)->core.background_pixel;
  577.     entry->sme_bsb.norm_gc = XtGetGC(w, mask, &values);
  578.     
  579.     values.fill_style = FillTiled;
  580.     values.tile   = XmuCreateStippledPixmap(XtScreenOfObject(w), 
  581.                         entry->sme_bsb.foreground,
  582.                         XtParent(w)->core.background_pixel,
  583.                         XtParent(w)->core.depth);
  584.     values.graphics_exposures = FALSE;
  585.     mask |= GCTile | GCFillStyle;
  586.     entry->sme_bsb.norm_gray_gc = XtGetGC(w, mask, &values);
  587.     
  588.     values.foreground ^= values.background;
  589.     values.background = 0;
  590.     values.function = GXxor;
  591.     mask = GCForeground | GCBackground | GCGraphicsExposures | GCFunction;
  592.     entry->sme_bsb.invert_gc = XtGetGC(w, mask, &values);
  593. }
  594.  
  595. /*      Function Name: DestroyGCs
  596.  *      Description: Removes all gc's for the simple menu widget.
  597.  *      Arguments: w - the simple menu widget.
  598.  *      Returns: none.
  599.  */
  600.  
  601. static void
  602. DestroyGCs(w)
  603. Widget w;
  604. {
  605.     SmeBSBObject entry = (SmeBSBObject) w;    
  606.  
  607.     XtReleaseGC(w, entry->sme_bsb.norm_gc);
  608.     XtReleaseGC(w, entry->sme_bsb.norm_gray_gc);
  609.     XtReleaseGC(w, entry->sme_bsb.rev_gc);
  610.     XtReleaseGC(w, entry->sme_bsb.invert_gc);
  611. }
  612.  
  613. #ifdef apollo
  614.  
  615. /*
  616.  * The apollo compiler that we have optomizes out my code for
  617.  * FlipColors() since it is static. and no one executes it in this
  618.  * file.  I am setting the function pointer into the class structure so
  619.  * that it can be called by my parent who will tell me to when to
  620.  * highlight and unhighlight.
  621.  */
  622.  
  623. void _XawSmeBSBApolloHack ()
  624. {
  625.     FlipColors();
  626. }
  627. #endif /* apollo */
  628.