home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xaw / Label.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-24  |  17.6 KB  |  632 lines

  1. /* $XConsortium: Label.c,v 1.92 91/07/24 16:56:28 converse Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  5. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its 
  10. documentation for any purpose and without fee is hereby granted, 
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in 
  13. supporting documentation, and that the names of Digital or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.  
  16.  
  17. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27. /*
  28.  * Label.c - Label widget
  29.  *
  30.  */
  31.  
  32. #include <X11/IntrinsicP.h>
  33. #include <X11/StringDefs.h>
  34. #include <X11/Xos.h>
  35. #include <X11/Xaw/XawInit.h>
  36. #include <X11/Xaw/LabelP.h>
  37. #include <X11/Xmu/Converters.h>
  38. #include <X11/Xmu/Drawing.h>
  39. #include <stdio.h>
  40. #include <ctype.h>
  41.  
  42. #define streq(a,b) (strcmp( (a), (b) ) == 0)
  43.  
  44. #define MULTI_LINE_LABEL 32767
  45.  
  46. #ifdef CRAY
  47. #define WORD64
  48. #endif
  49.  
  50. /****************************************************************
  51.  *
  52.  * Full class record constant
  53.  *
  54.  ****************************************************************/
  55.  
  56. /* Private Data */
  57.  
  58. #define offset(field) XtOffsetOf(LabelRec, field)
  59. static XtResource resources[] = {
  60.     {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
  61.     offset(label.foreground), XtRString, XtDefaultForeground},
  62.     {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
  63.     offset(label.font),XtRString, XtDefaultFont},
  64.     {XtNlabel,  XtCLabel, XtRString, sizeof(String),
  65.     offset(label.label), XtRString, NULL},
  66.     {XtNencoding, XtCEncoding, XtRUnsignedChar, sizeof(unsigned char),
  67.     offset(label.encoding), XtRImmediate, (XtPointer)XawTextEncoding8bit},
  68.     {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
  69.     offset(label.justify), XtRImmediate, (XtPointer)XtJustifyCenter},
  70.     {XtNinternalWidth, XtCWidth, XtRDimension,  sizeof(Dimension),
  71.     offset(label.internal_width), XtRImmediate, (XtPointer)4},
  72.     {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
  73.     offset(label.internal_height), XtRImmediate, (XtPointer)2},
  74.     {XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
  75.        offset(label.left_bitmap), XtRImmediate, (XtPointer) None},
  76.     {XtNbitmap, XtCPixmap, XtRBitmap, sizeof(Pixmap),
  77.     offset(label.pixmap), XtRImmediate, (XtPointer)None},
  78.     {XtNresize, XtCResize, XtRBoolean, sizeof(Boolean),
  79.     offset(label.resize), XtRImmediate, (XtPointer)True},
  80. };
  81. #undef offset
  82.  
  83. static void Initialize();
  84. static void Resize();
  85. static void Redisplay();
  86. static Boolean SetValues();
  87. static void ClassInitialize();
  88. static void Destroy();
  89. static XtGeometryResult QueryGeometry();
  90.  
  91. LabelClassRec labelClassRec = {
  92.   {
  93. /* core_class fields */    
  94. #define superclass        (&simpleClassRec)
  95.     /* superclass          */    (WidgetClass) superclass,
  96.     /* class_name          */    "Label",
  97.     /* widget_size          */    sizeof(LabelRec),
  98.     /* class_initialize       */    ClassInitialize,
  99.     /* class_part_initialize    */    NULL,
  100.     /* class_inited           */    FALSE,
  101.     /* initialize          */    Initialize,
  102.     /* initialize_hook        */    NULL,
  103.     /* realize              */    XtInheritRealize,
  104.     /* actions              */    NULL,
  105.     /* num_actions          */    0,
  106.     /* resources          */    resources,
  107.     /* num_resources          */    XtNumber(resources),
  108.     /* xrm_class          */    NULLQUARK,
  109.     /* compress_motion          */    TRUE,
  110.     /* compress_exposure      */    TRUE,
  111.     /* compress_enterleave    */    TRUE,
  112.     /* visible_interest          */    FALSE,
  113.     /* destroy              */    Destroy,
  114.     /* resize              */    Resize,
  115.     /* expose              */    Redisplay,
  116.     /* set_values          */    SetValues,
  117.     /* set_values_hook        */    NULL,
  118.     /* set_values_almost    */    XtInheritSetValuesAlmost,
  119.     /* get_values_hook        */    NULL,
  120.     /* accept_focus         */    NULL,
  121.     /* version            */    XtVersion,
  122.     /* callback_private       */    NULL,
  123.     /* tm_table               */    NULL,
  124.     /* query_geometry        */    QueryGeometry,
  125.     /* display_accelerator    */    XtInheritDisplayAccelerator,
  126.     /* extension        */    NULL
  127.   },
  128. /* Simple class fields initialization */
  129.   {
  130.     /* change_sensitive        */    XtInheritChangeSensitive
  131.   }
  132. };
  133. WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
  134. /****************************************************************
  135.  *
  136.  * Private Procedures
  137.  *
  138.  ****************************************************************/
  139.  
  140. static void ClassInitialize()
  141. {
  142.     XawInitializeWidgetSet();
  143.     XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0 );
  144. }
  145.  
  146. #ifndef WORD64
  147.  
  148. #define TXT16 XChar2b
  149.  
  150. #else
  151.  
  152. #define TXT16 char
  153.  
  154. static XChar2b *buf2b;
  155. static int buf2blen = 0;
  156.  
  157. _XawLabelWidth16(fs, str, n)
  158.     XFontStruct *fs;
  159.     char *str;
  160.     int    n;
  161. {
  162.     int i;
  163.     XChar2b *ptr;
  164.  
  165.     if (n > buf2blen) {
  166.     buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
  167.     buf2blen = n;
  168.     }
  169.     for (ptr = buf2b, i = n; --i >= 0; ptr++) {
  170.     ptr->byte1 = *str++;
  171.     ptr->byte2 = *str++;
  172.     }
  173.     return XTextWidth16(fs, buf2b, n);
  174. }
  175.  
  176. _XawLabelDraw16(dpy, d, gc, x, y, str, n)
  177.     Display *dpy;
  178.     Drawable d;
  179.     GC gc;
  180.     int x, y;
  181.     char *str;
  182.     int n;
  183. {
  184.     int i;
  185.     XChar2b *ptr;
  186.  
  187.     if (n > buf2blen) {
  188.     buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
  189.     buf2blen = n;
  190.     }
  191.     for (ptr = buf2b, i = n; --i >= 0; ptr++) {
  192.     ptr->byte1 = *str++;
  193.     ptr->byte2 = *str++;
  194.     }
  195.     XDrawString16(dpy, d, gc, x, y, buf2b, n);
  196. }
  197.  
  198. #define XTextWidth16 _XawLabelWidth16
  199. #define XDrawString16 _XawLabelDraw16
  200.  
  201. #endif /* WORD64 */
  202.  
  203. /*
  204.  * Calculate width and height of displayed text in pixels
  205.  */
  206.  
  207. static void SetTextWidthAndHeight(lw)
  208.     LabelWidget lw;
  209. {
  210.     register XFontStruct    *fs = lw->label.font;
  211.     char *nl;
  212.  
  213.     if (lw->label.pixmap != None) {
  214.     Window root;
  215.     int x, y;
  216.     unsigned int width, height, bw, depth;
  217.     if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
  218.              &width, &height, &bw, &depth)) {
  219.         lw->label.label_height = height;
  220.         lw->label.label_width = width;
  221.         lw->label.label_len = depth;
  222.         return;
  223.     }
  224.     }
  225.  
  226.     lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
  227.     if (lw->label.label == NULL) {
  228.     lw->label.label_len = 0;
  229.     lw->label.label_width = 0;
  230.     }
  231.     else if ((nl = index(lw->label.label, '\n')) != NULL) {
  232.     char *label;
  233.     lw->label.label_len = MULTI_LINE_LABEL;
  234.     lw->label.label_width = 0;
  235.     for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
  236.         int width;
  237.  
  238.         if (lw->label.encoding)
  239.         width = XTextWidth16(fs, (TXT16*)label, (int)(nl - label)/2);
  240.         else
  241.         width = XTextWidth(fs, label, (int)(nl - label));
  242.         if (width > (int)lw->label.label_width)
  243.         lw->label.label_width = width;
  244.         label = nl + 1;
  245.         if (*label)
  246.         lw->label.label_height +=
  247.             fs->max_bounds.ascent + fs->max_bounds.descent;
  248.     }
  249.     if (*label) {
  250.         int width = XTextWidth(fs, label, strlen(label));
  251.  
  252.         if (lw->label.encoding)
  253.         width = XTextWidth16(fs, (TXT16*)label, (int)strlen(label)/2);
  254.         else
  255.         width = XTextWidth(fs, label, strlen(label));
  256.         if (width > (int) lw->label.label_width)
  257.         lw->label.label_width = width;
  258.     }
  259.     } else {
  260.     lw->label.label_len = strlen(lw->label.label);
  261.     if (lw->label.encoding)
  262.         lw->label.label_width =
  263.         XTextWidth16(fs, (TXT16*)lw->label.label,
  264.                  (int) lw->label.label_len/2);
  265.     else
  266.         lw->label.label_width =
  267.         XTextWidth(fs, lw->label.label, (int) lw->label.label_len);
  268.     }
  269. }
  270.  
  271. static void GetnormalGC(lw)
  272.     LabelWidget lw;
  273. {
  274.     XGCValues    values;
  275.  
  276.     values.foreground    = lw->label.foreground;
  277.     values.background    = lw->core.background_pixel;
  278.     values.font        = lw->label.font->fid;
  279.     values.graphics_exposures = False;
  280.  
  281.     lw->label.normal_GC = XtGetGC(
  282.     (Widget)lw,
  283.     (unsigned) GCForeground | GCBackground | GCFont | GCGraphicsExposures,
  284.     &values);
  285. }
  286.  
  287. static void GetgrayGC(lw)
  288.     LabelWidget lw;
  289. {
  290.     XGCValues    values;
  291.  
  292.     values.foreground = lw->label.foreground;
  293.     values.background = lw->core.background_pixel;
  294.     values.font          = lw->label.font->fid;
  295.     values.fill_style = FillTiled;
  296.     values.tile       = XmuCreateStippledPixmap(XtScreen((Widget)lw),
  297.                         lw->label.foreground, 
  298.                         lw->core.background_pixel,
  299.                         lw->core.depth);
  300.     values.graphics_exposures = False;
  301.  
  302.     lw->label.stipple = values.tile;
  303.     lw->label.gray_GC = XtGetGC((Widget)lw, 
  304.                 (unsigned) GCForeground | GCBackground |
  305.                        GCFont | GCTile | GCFillStyle |
  306.                        GCGraphicsExposures,
  307.                 &values);
  308. }
  309.  
  310. static void compute_bitmap_offsets (lw)
  311.     LabelWidget lw;
  312. {
  313.     /*
  314.      * label will be displayed at (internal_width, internal_height + lbm_y)
  315.      */
  316.     if (lw->label.lbm_height != 0) {
  317.     lw->label.lbm_y = (((int) lw->core.height) -
  318.                ((int) lw->label.internal_height * 2) -
  319.                ((int) lw->label.lbm_height)) / 2;
  320.     } else {
  321.     lw->label.lbm_y = 0;
  322.     }
  323. }
  324.  
  325.  
  326. static void set_bitmap_info (lw)
  327.     LabelWidget lw;
  328. {
  329.     Window root;
  330.     int x, y;
  331.     unsigned int bw, depth;
  332.  
  333.     if (!(lw->label.left_bitmap &&
  334.       XGetGeometry (XtDisplay(lw), lw->label.left_bitmap, &root, &x, &y,
  335.             &lw->label.lbm_width, &lw->label.lbm_height,
  336.             &bw, &depth))) {
  337.     lw->label.lbm_width = lw->label.lbm_height = 0;
  338.     }
  339.     compute_bitmap_offsets (lw);
  340. }
  341.  
  342.  
  343.  
  344. /* ARGSUSED */
  345. static void Initialize(request, new)
  346.  Widget request, new;
  347. {
  348.     LabelWidget lw = (LabelWidget) new;
  349.  
  350.     if (lw->label.label == NULL) 
  351.         lw->label.label = XtNewString(lw->core.name);
  352.     else {
  353.         lw->label.label = XtNewString(lw->label.label);
  354.     }
  355.  
  356.     GetnormalGC(lw);
  357.     GetgrayGC(lw);
  358.  
  359.     SetTextWidthAndHeight(lw);
  360.  
  361.     if (lw->core.height == 0)
  362.         lw->core.height = lw->label.label_height + 2*lw->label.internal_height;
  363.  
  364.     set_bitmap_info (lw);        /* need core.height */
  365.  
  366.     if (lw->core.width == 0)        /* need label.lbm_width */
  367.         lw->core.width = (lw->label.label_width + 2 * lw->label.internal_width
  368.               + LEFT_OFFSET(lw));
  369.  
  370.     lw->label.label_x = lw->label.label_y = 0;
  371.     (*XtClass(new)->core_class.resize) ((Widget)lw);
  372.  
  373. } /* Initialize */
  374.  
  375. /*
  376.  * Repaint the widget window
  377.  */
  378.  
  379. /* ARGSUSED */
  380. static void Redisplay(w, event, region)
  381.     Widget w;
  382.     XEvent *event;
  383.     Region region;
  384. {
  385.    LabelWidget lw = (LabelWidget) w;
  386.    GC gc;
  387.  
  388.    if (region != NULL) {
  389.        int x = lw->label.label_x;
  390.        unsigned int width = lw->label.label_width;
  391.        if (lw->label.lbm_width) {
  392.        if (lw->label.label_x > (x = lw->label.internal_width))
  393.            width += lw->label.label_x - x;
  394.        }
  395.        if (XRectInRegion(region, x, lw->label.label_y,
  396.              width, lw->label.label_height) == RectangleOut)
  397.        return;
  398.    }
  399.  
  400.    gc = XtIsSensitive((Widget)lw) ? lw->label.normal_GC : lw->label.gray_GC;
  401. #ifdef notdef
  402.    if (region != NULL) XSetRegion(XtDisplay(w), gc, region);
  403. #endif /*notdef*/
  404.    if (lw->label.pixmap == None) {
  405.        int len = lw->label.label_len;
  406.        char *label = lw->label.label;
  407.        Position y = lw->label.label_y + lw->label.font->max_bounds.ascent;
  408.  
  409.        /* display left bitmap */
  410.        if (lw->label.left_bitmap && lw->label.lbm_width != 0) {
  411.        XCopyPlane (XtDisplay(w), lw->label.left_bitmap, XtWindow(w), gc,
  412.                0, 0, lw->label.lbm_width, lw->label.lbm_height,
  413.                (int) lw->label.internal_width, 
  414.                (int) lw->label.internal_height + lw->label.lbm_y, 
  415.                (unsigned long) 1L);
  416.        }
  417.  
  418.        if (len == MULTI_LINE_LABEL) {
  419.        char *nl;
  420.        while ((nl = index(label, '\n')) != NULL) {
  421.            if (lw->label.encoding)
  422.            XDrawString16(XtDisplay(w), XtWindow(w), gc,
  423.                  lw->label.label_x, y,
  424.                  (TXT16*)label, (int)(nl - label)/2);
  425.            else
  426.            XDrawString(XtDisplay(w), XtWindow(w), gc,
  427.                    lw->label.label_x, y, label, (int)(nl - label));
  428.            y += lw->label.font->max_bounds.ascent + lw->label.font->max_bounds.descent;
  429.            label = nl + 1;
  430.        }
  431.        len = strlen(label);
  432.        }
  433.        if (len) {
  434.        if (lw->label.encoding)
  435.            XDrawString16(XtDisplay(w), XtWindow(w), gc,
  436.                  lw->label.label_x, y, (TXT16*)label, len/2);
  437.        else
  438.            XDrawString(XtDisplay(w), XtWindow(w), gc,
  439.                lw->label.label_x, y, label, len);
  440.        }
  441.    } else if (lw->label.label_len == 1) { /* depth */
  442.        XCopyPlane(XtDisplay(w), lw->label.pixmap, XtWindow(w), gc,
  443.           0, 0, lw->label.label_width, lw->label.label_height,
  444.           lw->label.label_x, lw->label.label_y, 1L);
  445.    } else {
  446.        XCopyArea(XtDisplay(w), lw->label.pixmap, XtWindow(w), gc,
  447.          0, 0, lw->label.label_width, lw->label.label_height,
  448.          lw->label.label_x, lw->label.label_y);
  449.    }
  450. #ifdef notdef
  451.    if (region != NULL) XSetClipMask(XtDisplay(w), gc, (Pixmap)None);
  452. #endif /* notdef */
  453. }
  454.  
  455. static void _Reposition(lw, width, height, dx, dy)
  456.     register LabelWidget lw;
  457.     Dimension width, height;
  458.     Position *dx, *dy;
  459. {
  460.     Position newPos;
  461.     Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
  462.  
  463.     switch (lw->label.justify) {
  464.  
  465.     case XtJustifyLeft   :
  466.         newPos = leftedge;
  467.         break;
  468.  
  469.     case XtJustifyRight  :
  470.         newPos = width -
  471.         (lw->label.label_width + lw->label.internal_width);
  472.         break;
  473.  
  474.     case XtJustifyCenter :
  475.     default:
  476.         newPos = (int)(width - lw->label.label_width) / 2;
  477.         break;
  478.     }
  479.     if (newPos < (Position)leftedge)
  480.     newPos = leftedge;
  481.     *dx = newPos - lw->label.label_x;
  482.     lw->label.label_x = newPos;
  483.     *dy = (newPos = (int)(height - lw->label.label_height) / 2)
  484.       - lw->label.label_y;
  485.     lw->label.label_y = newPos;
  486.     return;
  487. }
  488.  
  489. static void Resize(w)
  490.     Widget w;
  491. {
  492.     LabelWidget lw = (LabelWidget)w;
  493.     Position dx, dy;
  494.     _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
  495.     compute_bitmap_offsets (lw);
  496. }
  497.  
  498. /*
  499.  * Set specified arguments into widget
  500.  */
  501.  
  502. #define PIXMAP 0
  503. #define WIDTH 1
  504. #define HEIGHT 2
  505. #define NUM_CHECKS 3
  506.  
  507. static Boolean SetValues(current, request, new, args, num_args)
  508.     Widget current, request, new;
  509.     ArgList args;
  510.     Cardinal *num_args;
  511. {
  512.     LabelWidget curlw = (LabelWidget) current;
  513.     LabelWidget reqlw = (LabelWidget) request;
  514.     LabelWidget newlw = (LabelWidget) new;
  515.     int i;
  516.     Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];
  517.  
  518.     for (i = 0; i < NUM_CHECKS; i++)
  519.     checks[i] = FALSE;
  520.  
  521.     for (i = 0; i < *num_args; i++) {
  522.     if (streq(XtNbitmap, args[i].name))
  523.         checks[PIXMAP] = TRUE;
  524.     if (streq(XtNwidth, args[i].name))
  525.         checks[WIDTH] = TRUE;
  526.     if (streq(XtNheight, args[i].name))
  527.         checks[HEIGHT] = TRUE;
  528.     }
  529.  
  530.     if (newlw->label.label == NULL) {
  531.     newlw->label.label = newlw->core.name;
  532.     }
  533.  
  534.     /*
  535.      * resize on bitmap change
  536.      */
  537.     if (curlw->label.left_bitmap != newlw->label.left_bitmap) {
  538.     was_resized = True;
  539.     }
  540.  
  541.     if (curlw->label.encoding != newlw->label.encoding)
  542.     was_resized = True;
  543.  
  544.     if (curlw->label.label != newlw->label.label) {
  545.         if (curlw->label.label != curlw->core.name)
  546.         XtFree( (char *)curlw->label.label );
  547.  
  548.     if (newlw->label.label != newlw->core.name) {
  549.         newlw->label.label = XtNewString( newlw->label.label );
  550.     }
  551.     was_resized = True;
  552.     }
  553.  
  554.     if (was_resized || (curlw->label.font != newlw->label.font) ||
  555.     (curlw->label.justify != newlw->label.justify) || checks[PIXMAP]) {
  556.  
  557.     SetTextWidthAndHeight(newlw);
  558.     was_resized = True;
  559.     }
  560.  
  561.     /* recalculate the window size if something has changed. */
  562.     if (newlw->label.resize && was_resized) {
  563.     if ((curlw->core.height == reqlw->core.height) && !checks[HEIGHT])
  564.         newlw->core.height = (newlw->label.label_height + 
  565.                   2 * newlw->label.internal_height);
  566.  
  567.     set_bitmap_info (newlw);
  568.  
  569.     if ((curlw->core.width == reqlw->core.width) && !checks[WIDTH])
  570.         newlw->core.width = (newlw->label.label_width +
  571.                  LEFT_OFFSET(newlw) +
  572.                  2 * newlw->label.internal_width);
  573.     }
  574.  
  575.     if (curlw->label.foreground != newlw->label.foreground
  576.     || curlw->core.background_pixel != newlw->core.background_pixel
  577.     || curlw->label.font->fid != newlw->label.font->fid) {
  578.  
  579.     XtReleaseGC(new, curlw->label.normal_GC);
  580.     XtReleaseGC(new, curlw->label.gray_GC);
  581.     XmuReleaseStippledPixmap( XtScreen(current), curlw->label.stipple );
  582.     GetnormalGC(newlw);
  583.     GetgrayGC(newlw);
  584.     redisplay = True;
  585.     }
  586.  
  587.     if ((curlw->label.internal_width != newlw->label.internal_width)
  588.         || (curlw->label.internal_height != newlw->label.internal_height)
  589.     || was_resized) {
  590.     /* Resize() will be called if geometry changes succeed */
  591.     Position dx, dy;
  592.     _Reposition(newlw, curlw->core.width, curlw->core.height, &dx, &dy);
  593.     }
  594.  
  595.     return was_resized || redisplay ||
  596.        XtIsSensitive(current) != XtIsSensitive(new);
  597. }
  598.  
  599. static void Destroy(w)
  600.     Widget w;
  601. {
  602.     LabelWidget lw = (LabelWidget)w;
  603.  
  604.     XtFree( lw->label.label );
  605.     XtReleaseGC( w, lw->label.normal_GC );
  606.     XtReleaseGC( w, lw->label.gray_GC);
  607.     XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );
  608. }
  609.  
  610.  
  611. static XtGeometryResult QueryGeometry(w, intended, preferred)
  612.     Widget w;
  613.     XtWidgetGeometry *intended, *preferred;
  614. {
  615.     register LabelWidget lw = (LabelWidget)w;
  616.  
  617.     preferred->request_mode = CWWidth | CWHeight;
  618.     preferred->width = (lw->label.label_width + 2 * lw->label.internal_width +
  619.             LEFT_OFFSET(lw));
  620.     preferred->height = lw->label.label_height + 2*lw->label.internal_height;
  621.     if (  ((intended->request_mode & (CWWidth | CWHeight))
  622.            == (CWWidth | CWHeight)) &&
  623.       intended->width == preferred->width &&
  624.       intended->height == preferred->height)
  625.     return XtGeometryYes;
  626.     else if (preferred->width == w->core.width &&
  627.          preferred->height == w->core.height)
  628.     return XtGeometryNo;
  629.     else
  630.     return XtGeometryAlmost;
  631. }
  632.