gtk+3: fix dependencies for new gnome/accessibility/at-spi2-core
[oi-userland.git] / components / x11 / libXaw5 / src / Label.c
blob10698a32b8ec5d6bd06c745939a993f052cb9a62
1 /* $XConsortium: Label.c,v 1.97 94/04/17 20:12:12 kaleb Exp $ */
3 /***********************************************************
5 Copyright (c) 1987, 1988, 1994 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
31 All Rights Reserved
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of Digital not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 SOFTWARE.
49 ******************************************************************/
52 * Label.c - Label widget
56 #include <X11/IntrinsicP.h>
57 #include <X11/StringDefs.h>
58 #include <X11/Xos.h>
59 #include <X11/Xaw/XawInit.h>
60 #include <X11/Xaw/LabelP.h>
61 #include <X11/Xmu/Converters.h>
62 #include <X11/Xmu/Drawing.h>
63 #include <stdio.h>
64 #include <ctype.h>
66 /* needed for abs() */
67 #ifdef _LP64
68 #include <stdlib.h>
69 #else /* _LP64 */
70 #ifndef X_NOT_STDC_ENV
71 #include <stdlib.h>
72 #else
73 int abs();
74 #endif
75 #endif /* _LP64 */
77 #define streq(a,b) (strcmp( (a), (b) ) == 0)
79 #define MULTI_LINE_LABEL 32767
81 #ifdef CRAY
82 #define WORD64
83 #endif
85 /****************************************************************
87 * Full class record constant
89 ****************************************************************/
91 /* Private Data */
93 #define offset(field) XtOffsetOf(LabelRec, field)
94 static XtResource resources[] = {
95 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
96 offset(label.foreground), XtRString, XtDefaultForeground},
97 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
98 offset(label.font),XtRString, XtDefaultFont},
99 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet ),
100 offset(label.fontset),XtRString, XtDefaultFontSet},
101 {XtNlabel, XtCLabel, XtRString, sizeof(String),
102 offset(label.label), XtRString, NULL},
103 {XtNencoding, XtCEncoding, XtRUnsignedChar, sizeof(unsigned char),
104 offset(label.encoding), XtRImmediate, (XtPointer)XawTextEncoding8bit},
105 {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
106 offset(label.justify), XtRImmediate, (XtPointer)XtJustifyCenter},
107 {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
108 offset(label.internal_width), XtRImmediate, (XtPointer)4},
109 {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
110 offset(label.internal_height), XtRImmediate, (XtPointer)2},
111 {XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
112 offset(label.left_bitmap), XtRImmediate, (XtPointer) None},
113 {XtNbitmap, XtCPixmap, XtRBitmap, sizeof(Pixmap),
114 offset(label.pixmap), XtRImmediate, (XtPointer)None},
115 {XtNresize, XtCResize, XtRBoolean, sizeof(Boolean),
116 offset(label.resize), XtRImmediate, (XtPointer)True},
118 #undef offset
120 static void Initialize();
121 static void Resize();
122 static void Redisplay();
123 static Boolean SetValues();
124 static void ClassInitialize();
125 static void Destroy();
126 static XtGeometryResult QueryGeometry();
128 LabelClassRec labelClassRec = {
130 /* core_class fields */
131 /* superclass */ (WidgetClass) &simpleClassRec,
132 /* class_name */ "Label",
133 /* widget_size */ sizeof(LabelRec),
134 /* class_initialize */ ClassInitialize,
135 /* class_part_initialize */ NULL,
136 /* class_inited */ FALSE,
137 /* initialize */ Initialize,
138 /* initialize_hook */ NULL,
139 /* realize */ XtInheritRealize,
140 /* actions */ NULL,
141 /* num_actions */ 0,
142 /* resources */ resources,
143 /* num_resources */ XtNumber(resources),
144 /* xrm_class */ NULLQUARK,
145 /* compress_motion */ TRUE,
146 /* compress_exposure */ TRUE,
147 /* compress_enterleave */ TRUE,
148 /* visible_interest */ FALSE,
149 /* destroy */ Destroy,
150 /* resize */ Resize,
151 /* expose */ Redisplay,
152 /* set_values */ SetValues,
153 /* set_values_hook */ NULL,
154 /* set_values_almost */ XtInheritSetValuesAlmost,
155 /* get_values_hook */ NULL,
156 /* accept_focus */ NULL,
157 /* version */ XtVersion,
158 /* callback_private */ NULL,
159 /* tm_table */ NULL,
160 /* query_geometry */ QueryGeometry,
161 /* display_accelerator */ XtInheritDisplayAccelerator,
162 /* extension */ NULL
164 /* Simple class fields initialization */
166 /* change_sensitive */ XtInheritChangeSensitive
168 /* Label class fields initialization */
170 /* ignore */ 0
173 WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
174 /****************************************************************
176 * Private Procedures
178 ****************************************************************/
180 static void ClassInitialize()
182 XawInitializeWidgetSet();
183 XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify,
184 (XtConvertArgList)NULL, 0 );
187 #ifndef WORD64
189 #define TXT16 XChar2b
191 #else
193 #define TXT16 char
195 static XChar2b *buf2b;
196 static int buf2blen = 0;
198 _XawLabelWidth16(fs, str, n)
199 XFontStruct *fs;
200 char *str;
201 int n;
203 int i;
204 XChar2b *ptr;
206 if (n > buf2blen) {
207 buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
208 buf2blen = n;
210 for (ptr = buf2b, i = n; --i >= 0; ptr++) {
211 ptr->byte1 = *str++;
212 ptr->byte2 = *str++;
214 return XTextWidth16(fs, buf2b, n);
217 _XawLabelDraw16(dpy, d, gc, x, y, str, n)
218 Display *dpy;
219 Drawable d;
220 GC gc;
221 int x, y;
222 char *str;
223 int n;
225 int i;
226 XChar2b *ptr;
228 if (n > buf2blen) {
229 buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
230 buf2blen = n;
232 for (ptr = buf2b, i = n; --i >= 0; ptr++) {
233 ptr->byte1 = *str++;
234 ptr->byte2 = *str++;
236 XDrawString16(dpy, d, gc, x, y, buf2b, n);
239 #define XTextWidth16 _XawLabelWidth16
240 #define XDrawString16 _XawLabelDraw16
242 #endif /* WORD64 */
245 * Calculate width and height of displayed text in pixels
248 static void SetTextWidthAndHeight(lw)
249 LabelWidget lw;
251 XFontStruct *fs = lw->label.font;
253 char *nl;
255 if (lw->label.pixmap != None) {
256 Window root;
257 int x, y;
258 unsigned int width, height, bw, depth;
259 if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
260 &width, &height, &bw, &depth)) {
261 lw->label.label_height = height;
262 lw->label.label_width = width;
263 lw->label.label_len = depth;
264 return;
267 if ( lw->simple.international == True ) {
269 XFontSet fset = lw->label.fontset;
270 XFontSetExtents *ext = XExtentsOfFontSet(fset);
272 lw->label.label_height = ext->max_ink_extent.height;
273 if (lw->label.label == NULL) {
274 lw->label.label_len = 0;
275 lw->label.label_width = 0;
277 else if ((nl = index(lw->label.label, '\n')) != NULL) {
278 char *label;
279 lw->label.label_len = MULTI_LINE_LABEL;
280 lw->label.label_width = 0;
281 for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
282 int width = XmbTextEscapement(fset, label, (int)(nl - label));
284 if (width > (int)lw->label.label_width)
285 lw->label.label_width = width;
286 label = nl + 1;
287 if (*label)
288 lw->label.label_height +=
289 ext->max_ink_extent.height;
291 if (*label) {
292 int width = XmbTextEscapement(fset, label, strlen(label));
294 if (width > (int) lw->label.label_width)
295 lw->label.label_width = width;
297 } else {
298 lw->label.label_len = strlen(lw->label.label);
299 lw->label.label_width =
300 XmbTextEscapement(fset, lw->label.label, (int) lw->label.label_len);
303 } else {
305 lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
306 if (lw->label.label == NULL) {
307 lw->label.label_len = 0;
308 lw->label.label_width = 0;
310 else if ((nl = index(lw->label.label, '\n')) != NULL) {
311 char *label;
312 lw->label.label_len = MULTI_LINE_LABEL;
313 lw->label.label_width = 0;
314 for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
315 int width;
317 if (lw->label.encoding)
318 width = XTextWidth16(fs, (TXT16*)label, (int)(nl - label)/2);
319 else
320 width = XTextWidth(fs, label, (int)(nl - label));
321 if (width > (int)lw->label.label_width)
322 lw->label.label_width = width;
323 label = nl + 1;
324 if (*label)
325 lw->label.label_height +=
326 fs->max_bounds.ascent + fs->max_bounds.descent;
328 if (*label) {
329 int width = XTextWidth(fs, label, strlen(label));
331 if (lw->label.encoding)
332 width = XTextWidth16(fs, (TXT16*)label, (int)strlen(label)/2);
333 else
334 width = XTextWidth(fs, label, strlen(label));
335 if (width > (int) lw->label.label_width)
336 lw->label.label_width = width;
338 } else {
339 lw->label.label_len = strlen(lw->label.label);
340 if (lw->label.encoding)
341 lw->label.label_width =
342 XTextWidth16(fs, (TXT16*)lw->label.label,
343 (int) lw->label.label_len/2);
344 else
345 lw->label.label_width =
346 XTextWidth(fs, lw->label.label, (int) lw->label.label_len);
352 static void GetnormalGC(lw)
353 LabelWidget lw;
355 XGCValues values;
357 values.foreground = lw->label.foreground;
358 values.background = lw->core.background_pixel;
359 values.font = lw->label.font->fid;
360 values.graphics_exposures = False;
362 if ( lw->simple.international == True )
363 /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC. */
364 lw->label.normal_GC = XtAllocateGC(
365 (Widget)lw, 0,
366 (unsigned) GCForeground | GCBackground | GCGraphicsExposures,
367 &values, GCFont, 0 );
368 else
369 lw->label.normal_GC = XtGetGC(
370 (Widget)lw,
371 (unsigned) GCForeground | GCBackground | GCFont | GCGraphicsExposures,
372 &values);
375 static void GetgrayGC(lw)
376 LabelWidget lw;
378 XGCValues values;
380 values.foreground = lw->label.foreground;
381 values.background = lw->core.background_pixel;
382 values.font = lw->label.font->fid;
383 values.fill_style = FillTiled;
384 values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
385 lw->label.foreground,
386 lw->core.background_pixel,
387 lw->core.depth);
388 values.graphics_exposures = False;
390 lw->label.stipple = values.tile;
391 if ( lw->simple.international == True )
392 /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC. */
393 lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
394 (unsigned) GCForeground | GCBackground |
395 GCTile | GCFillStyle |
396 GCGraphicsExposures,
397 &values, GCFont, 0);
398 else
399 lw->label.gray_GC = XtGetGC((Widget)lw,
400 (unsigned) GCForeground | GCBackground |
401 GCFont | GCTile | GCFillStyle |
402 GCGraphicsExposures,
403 &values);
406 static void compute_bitmap_offsets (lw)
407 LabelWidget lw;
410 * bitmap will be eventually be displayed at
411 * (internal_width, internal_height + lbm_y)
413 if (lw->label.lbm_height != 0) {
414 lw->label.lbm_y = (lw->core.height -
415 (lw->label.internal_height * 2 +
416 lw->label.lbm_height)) / 2;
417 } else {
418 lw->label.lbm_y = 0;
423 static void set_bitmap_info (lw)
424 LabelWidget lw;
426 Window root;
427 int x, y;
428 unsigned int bw, depth;
430 if (!(lw->label.left_bitmap &&
431 XGetGeometry (XtDisplay(lw), lw->label.left_bitmap, &root, &x, &y,
432 &lw->label.lbm_width, &lw->label.lbm_height,
433 &bw, &depth))) {
434 lw->label.lbm_width = lw->label.lbm_height = 0;
436 compute_bitmap_offsets (lw);
441 /* ARGSUSED */
442 static void Initialize(request, new, args, num_args)
443 Widget request, new;
444 ArgList args;
445 Cardinal *num_args;
447 LabelWidget lw = (LabelWidget) new;
449 if (lw->label.label == NULL)
450 lw->label.label = XtNewString(lw->core.name);
451 else {
452 lw->label.label = XtNewString(lw->label.label);
455 GetnormalGC(lw);
456 GetgrayGC(lw);
458 SetTextWidthAndHeight(lw);
460 if (lw->core.height == 0)
461 lw->core.height = lw->label.label_height +
462 2 * lw->label.internal_height;
464 set_bitmap_info (lw); /* need core.height */
466 if (lw->core.width == 0) /* need label.lbm_width */
467 lw->core.width = (lw->label.label_width +
468 2 * lw->label.internal_width +
469 LEFT_OFFSET(lw));
471 lw->label.label_x = lw->label.label_y = 0;
472 (*XtClass(new)->core_class.resize) ((Widget)lw);
474 } /* Initialize */
477 * Repaint the widget window
480 /* ARGSUSED */
481 static void Redisplay(gw, event, region)
482 Widget gw;
483 XEvent *event;
484 Region region;
486 extern WidgetClass commandWidgetClass;
487 LabelWidget w = (LabelWidget) gw;
488 LabelWidgetClass lwclass = (LabelWidgetClass) XtClass (gw);
489 GC gc;
492 * now we'll see if we need to draw the rest of the label
494 if (region != NULL) {
495 int x = w->label.label_x;
496 unsigned int width = w->label.label_width;
497 if (w->label.lbm_width) {
498 if (w->label.label_x > (x = w->label.internal_width))
499 width += w->label.label_x - x;
501 if (XRectInRegion(region, x, w->label.label_y,
502 width, w->label.label_height) == RectangleOut){
503 return;
507 gc = XtIsSensitive(gw) ? w->label.normal_GC : w->label.gray_GC;
508 #ifdef notdef
509 if (region != NULL)
510 XSetRegion(XtDisplay(gw), gc, region);
511 #endif /*notdef*/
513 if (w->label.pixmap == None) {
514 int len = w->label.label_len;
515 char *label = w->label.label;
516 Position y = w->label.label_y + w->label.font->max_bounds.ascent;
517 Position ksy = w->label.label_y;
519 /* display left bitmap */
520 if (w->label.left_bitmap && w->label.lbm_width != 0) {
521 XCopyPlane (XtDisplay(gw), w->label.left_bitmap, XtWindow(gw), gc,
522 0, 0, w->label.lbm_width, w->label.lbm_height,
523 (int) w->label.internal_width,
524 (int) w->label.internal_height + w->label.lbm_y,
525 (unsigned long) 1L);
528 if ( w->simple.international == True ) {
530 XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset);
532 ksy += abs(ext->max_ink_extent.y);
534 if (len == MULTI_LINE_LABEL) {
535 char *nl;
536 while ((nl = index(label, '\n')) != NULL) {
537 XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
538 w->label.label_x, ksy, label, (int)(nl - label));
539 ksy += ext->max_ink_extent.height;
540 label = nl + 1;
542 len = strlen(label);
544 if (len)
545 XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
546 w->label.label_x, ksy, label, len);
548 } else { /*international false, so use R5 routine */
550 if (len == MULTI_LINE_LABEL) {
551 char *nl;
552 while ((nl = index(label, '\n')) != NULL) {
553 if (w->label.encoding)
554 XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
555 w->label.label_x, y,
556 (TXT16*)label, (int)(nl - label)/2);
557 else
558 XDrawString(XtDisplay(gw), XtWindow(gw), gc,
559 w->label.label_x, y, label, (int)(nl - label));
560 y += w->label.font->max_bounds.ascent +
561 w->label.font->max_bounds.descent;
562 label = nl + 1;
564 len = strlen(label);
566 if (len) {
567 if (w->label.encoding)
568 XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
569 w->label.label_x, y, (TXT16*)label, len/2);
570 else
571 XDrawString(XtDisplay(gw), XtWindow(gw), gc,
572 w->label.label_x, y, label, len);
575 } /*endif international*/
577 } else if (w->label.label_len == 1) { /* depth */
578 XCopyPlane(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
579 0, 0, w->label.label_width, w->label.label_height,
580 w->label.label_x, w->label.label_y, 1L);
581 } else {
582 XCopyArea(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
583 0, 0, w->label.label_width, w->label.label_height,
584 w->label.label_x, w->label.label_y);
587 #ifdef notdef
588 if (region != NULL)
589 XSetClipMask(XtDisplay(gw), gc, (Pixmap)None);
590 #endif /* notdef */
593 static void _Reposition(lw, width, height, dx, dy)
594 LabelWidget lw;
595 Dimension width, height;
596 Position *dx, *dy;
598 Position newPos;
599 Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
601 switch (lw->label.justify) {
603 case XtJustifyLeft :
604 newPos = leftedge;
605 break;
607 case XtJustifyRight :
608 newPos = width -
609 (lw->label.label_width + lw->label.internal_width);
610 break;
612 case XtJustifyCenter :
613 default:
614 newPos = (int)(width - lw->label.label_width) / 2;
615 break;
617 if (newPos < (Position)leftedge)
618 newPos = leftedge;
619 *dx = newPos - lw->label.label_x;
620 lw->label.label_x = newPos;
621 *dy = (newPos = (int)(height - lw->label.label_height) / 2)
622 - lw->label.label_y;
623 lw->label.label_y = newPos;
624 return;
627 static void Resize(w)
628 Widget w;
630 LabelWidget lw = (LabelWidget)w;
631 Position dx, dy;
633 _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
634 compute_bitmap_offsets (lw);
638 * Set specified arguments into widget
641 #define PIXMAP 0
642 #define WIDTH 1
643 #define HEIGHT 2
644 #define NUM_CHECKS 3
646 static Boolean SetValues(current, request, new, args, num_args)
647 Widget current, request, new;
648 ArgList args;
649 Cardinal *num_args;
651 LabelWidget curlw = (LabelWidget) current;
652 LabelWidget reqlw = (LabelWidget) request;
653 LabelWidget newlw = (LabelWidget) new;
654 int i;
655 Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];
657 for (i = 0; i < NUM_CHECKS; i++)
658 checks[i] = FALSE;
660 for (i = 0; i < *num_args; i++) {
661 if (streq(XtNbitmap, args[i].name))
662 checks[PIXMAP] = TRUE;
663 if (streq(XtNwidth, args[i].name))
664 checks[WIDTH] = TRUE;
665 if (streq(XtNheight, args[i].name))
666 checks[HEIGHT] = TRUE;
669 if (newlw->label.label == NULL) {
670 newlw->label.label = newlw->core.name;
674 * resize on bitmap change
676 if (curlw->label.left_bitmap != newlw->label.left_bitmap) {
677 was_resized = True;
680 if (curlw->label.encoding != newlw->label.encoding)
681 was_resized = True;
683 if ( (curlw->label.fontset != newlw->label.fontset) &&
684 curlw->simple.international ){
685 was_resized = True;
687 if (curlw->label.label != newlw->label.label) {
688 if (curlw->label.label != curlw->core.name)
689 XtFree( (char *)curlw->label.label );
691 if (newlw->label.label != newlw->core.name) {
692 newlw->label.label = XtNewString( newlw->label.label );
694 was_resized = True;
697 if (was_resized || (curlw->label.font != newlw->label.font) ||
698 (curlw->label.justify != newlw->label.justify) || checks[PIXMAP]) {
700 SetTextWidthAndHeight(newlw);
701 was_resized = True;
704 /* recalculate the window size if something has changed. */
705 if (newlw->label.resize && was_resized) {
706 if ((curlw->core.height == reqlw->core.height) && !checks[HEIGHT])
707 newlw->core.height = (newlw->label.label_height +
708 2 * newlw->label.internal_height);
710 set_bitmap_info (newlw);
712 if ((curlw->core.width == reqlw->core.width) && !checks[WIDTH])
713 newlw->core.width = (newlw->label.label_width +
714 LEFT_OFFSET(newlw) +
715 2 * newlw->label.internal_width);
718 if (curlw->label.foreground != newlw->label.foreground
719 || curlw->core.background_pixel != newlw->core.background_pixel
720 || curlw->label.font->fid != newlw->label.font->fid ) {
722 /* The Fontset is not in the GC - don't make a new GC if FS changes! */
724 XtReleaseGC(new, curlw->label.normal_GC);
725 XtReleaseGC(new, curlw->label.gray_GC);
726 XmuReleaseStippledPixmap( XtScreen(current), curlw->label.stipple );
727 GetnormalGC(newlw);
728 GetgrayGC(newlw);
729 redisplay = True;
732 if ((curlw->label.internal_width != newlw->label.internal_width)
733 || (curlw->label.internal_height != newlw->label.internal_height)
734 || was_resized) {
735 /* Resize() will be called if geometry changes succeed */
736 Position dx, dy;
737 _Reposition(newlw, curlw->core.width, curlw->core.height, &dx, &dy);
740 return was_resized || redisplay ||
741 XtIsSensitive(current) != XtIsSensitive(new);
744 static void Destroy(w)
745 Widget w;
747 LabelWidget lw = (LabelWidget)w;
749 if ( lw->label.label != lw->core.name )
750 XtFree( lw->label.label );
751 XtReleaseGC( w, lw->label.normal_GC );
752 XtReleaseGC( w, lw->label.gray_GC);
753 XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );
757 static XtGeometryResult QueryGeometry(w, intended, preferred)
758 Widget w;
759 XtWidgetGeometry *intended, *preferred;
761 LabelWidget lw = (LabelWidget)w;
763 preferred->request_mode = CWWidth | CWHeight;
764 preferred->width = (lw->label.label_width +
765 2 * lw->label.internal_width +
766 LEFT_OFFSET(lw));
767 preferred->height = lw->label.label_height +
768 2 * lw->label.internal_height;
769 if ( ((intended->request_mode & (CWWidth | CWHeight))
770 == (CWWidth | CWHeight)) &&
771 intended->width == preferred->width &&
772 intended->height == preferred->height)
773 return XtGeometryYes;
774 else if (preferred->width == w->core.width &&
775 preferred->height == w->core.height)
776 return XtGeometryNo;
777 else
778 return XtGeometryAlmost;