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.
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
49 ******************************************************************/
52 * Label.c - Label widget
56 #include <X11/IntrinsicP.h>
57 #include <X11/StringDefs.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>
66 /* needed for abs() */
70 #ifndef X_NOT_STDC_ENV
77 #define streq(a,b) (strcmp( (a), (b) ) == 0)
79 #define MULTI_LINE_LABEL 32767
85 /****************************************************************
87 * Full class record constant
89 ****************************************************************/
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
},
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
,
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
,
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
,
160 /* query_geometry */ QueryGeometry
,
161 /* display_accelerator */ XtInheritDisplayAccelerator
,
164 /* Simple class fields initialization */
166 /* change_sensitive */ XtInheritChangeSensitive
168 /* Label class fields initialization */
173 WidgetClass labelWidgetClass
= (WidgetClass
)&labelClassRec
;
174 /****************************************************************
178 ****************************************************************/
180 static void ClassInitialize()
182 XawInitializeWidgetSet();
183 XtAddConverter( XtRString
, XtRJustify
, XmuCvtStringToJustify
,
184 (XtConvertArgList
)NULL
, 0 );
189 #define TXT16 XChar2b
195 static XChar2b
*buf2b
;
196 static int buf2blen
= 0;
198 _XawLabelWidth16(fs
, str
, n
)
207 buf2b
= (XChar2b
*)XtRealloc((char *)buf2b
, n
* sizeof(XChar2b
));
210 for (ptr
= buf2b
, i
= n
; --i
>= 0; ptr
++) {
214 return XTextWidth16(fs
, buf2b
, n
);
217 _XawLabelDraw16(dpy
, d
, gc
, x
, y
, str
, n
)
229 buf2b
= (XChar2b
*)XtRealloc((char *)buf2b
, n
* sizeof(XChar2b
));
232 for (ptr
= buf2b
, i
= n
; --i
>= 0; ptr
++) {
236 XDrawString16(dpy
, d
, gc
, x
, y
, buf2b
, n
);
239 #define XTextWidth16 _XawLabelWidth16
240 #define XDrawString16 _XawLabelDraw16
245 * Calculate width and height of displayed text in pixels
248 static void SetTextWidthAndHeight(lw
)
251 XFontStruct
*fs
= lw
->label
.font
;
255 if (lw
->label
.pixmap
!= None
) {
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
;
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
) {
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
;
288 lw
->label
.label_height
+=
289 ext
->max_ink_extent
.height
;
292 int width
= XmbTextEscapement(fset
, label
, strlen(label
));
294 if (width
> (int) lw
->label
.label_width
)
295 lw
->label
.label_width
= width
;
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
);
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
) {
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')) {
317 if (lw
->label
.encoding
)
318 width
= XTextWidth16(fs
, (TXT16
*)label
, (int)(nl
- label
)/2);
320 width
= XTextWidth(fs
, label
, (int)(nl
- label
));
321 if (width
> (int)lw
->label
.label_width
)
322 lw
->label
.label_width
= width
;
325 lw
->label
.label_height
+=
326 fs
->max_bounds
.ascent
+ fs
->max_bounds
.descent
;
329 int width
= XTextWidth(fs
, label
, strlen(label
));
331 if (lw
->label
.encoding
)
332 width
= XTextWidth16(fs
, (TXT16
*)label
, (int)strlen(label
)/2);
334 width
= XTextWidth(fs
, label
, strlen(label
));
335 if (width
> (int) lw
->label
.label_width
)
336 lw
->label
.label_width
= width
;
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);
345 lw
->label
.label_width
=
346 XTextWidth(fs
, lw
->label
.label
, (int) lw
->label
.label_len
);
352 static void GetnormalGC(lw
)
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(
366 (unsigned) GCForeground
| GCBackground
| GCGraphicsExposures
,
367 &values
, GCFont
, 0 );
369 lw
->label
.normal_GC
= XtGetGC(
371 (unsigned) GCForeground
| GCBackground
| GCFont
| GCGraphicsExposures
,
375 static void GetgrayGC(lw
)
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
,
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
|
399 lw
->label
.gray_GC
= XtGetGC((Widget
)lw
,
400 (unsigned) GCForeground
| GCBackground
|
401 GCFont
| GCTile
| GCFillStyle
|
406 static void compute_bitmap_offsets (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;
423 static void set_bitmap_info (lw
)
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
,
434 lw
->label
.lbm_width
= lw
->label
.lbm_height
= 0;
436 compute_bitmap_offsets (lw
);
442 static void Initialize(request
, new, args
, num_args
)
447 LabelWidget lw
= (LabelWidget
) new;
449 if (lw
->label
.label
== NULL
)
450 lw
->label
.label
= XtNewString(lw
->core
.name
);
452 lw
->label
.label
= XtNewString(lw
->label
.label
);
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
+
471 lw
->label
.label_x
= lw
->label
.label_y
= 0;
472 (*XtClass(new)->core_class
.resize
) ((Widget
)lw
);
477 * Repaint the widget window
481 static void Redisplay(gw
, event
, region
)
486 extern WidgetClass commandWidgetClass
;
487 LabelWidget w
= (LabelWidget
) gw
;
488 LabelWidgetClass lwclass
= (LabelWidgetClass
) XtClass (gw
);
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
){
507 gc
= XtIsSensitive(gw
) ? w
->label
.normal_GC
: w
->label
.gray_GC
;
510 XSetRegion(XtDisplay(gw
), gc
, region
);
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
,
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
) {
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
;
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
) {
552 while ((nl
= index(label
, '\n')) != NULL
) {
553 if (w
->label
.encoding
)
554 XDrawString16(XtDisplay(gw
), XtWindow(gw
), gc
,
556 (TXT16
*)label
, (int)(nl
- label
)/2);
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
;
567 if (w
->label
.encoding
)
568 XDrawString16(XtDisplay(gw
), XtWindow(gw
), gc
,
569 w
->label
.label_x
, y
, (TXT16
*)label
, len
/2);
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);
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
);
589 XSetClipMask(XtDisplay(gw
), gc
, (Pixmap
)None
);
593 static void _Reposition(lw
, width
, height
, dx
, dy
)
595 Dimension width
, height
;
599 Position leftedge
= lw
->label
.internal_width
+ LEFT_OFFSET(lw
);
601 switch (lw
->label
.justify
) {
607 case XtJustifyRight
:
609 (lw
->label
.label_width
+ lw
->label
.internal_width
);
612 case XtJustifyCenter
:
614 newPos
= (int)(width
- lw
->label
.label_width
) / 2;
617 if (newPos
< (Position
)leftedge
)
619 *dx
= newPos
- lw
->label
.label_x
;
620 lw
->label
.label_x
= newPos
;
621 *dy
= (newPos
= (int)(height
- lw
->label
.label_height
) / 2)
623 lw
->label
.label_y
= newPos
;
627 static void Resize(w
)
630 LabelWidget lw
= (LabelWidget
)w
;
633 _Reposition(lw
, w
->core
.width
, w
->core
.height
, &dx
, &dy
);
634 compute_bitmap_offsets (lw
);
638 * Set specified arguments into widget
646 static Boolean
SetValues(current
, request
, new, args
, num_args
)
647 Widget current
, request
, new;
651 LabelWidget curlw
= (LabelWidget
) current
;
652 LabelWidget reqlw
= (LabelWidget
) request
;
653 LabelWidget newlw
= (LabelWidget
) new;
655 Boolean was_resized
= False
, redisplay
= False
, checks
[NUM_CHECKS
];
657 for (i
= 0; i
< NUM_CHECKS
; i
++)
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
) {
680 if (curlw
->label
.encoding
!= newlw
->label
.encoding
)
683 if ( (curlw
->label
.fontset
!= newlw
->label
.fontset
) &&
684 curlw
->simple
.international
){
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
);
697 if (was_resized
|| (curlw
->label
.font
!= newlw
->label
.font
) ||
698 (curlw
->label
.justify
!= newlw
->label
.justify
) || checks
[PIXMAP
]) {
700 SetTextWidthAndHeight(newlw
);
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
+
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
);
732 if ((curlw
->label
.internal_width
!= newlw
->label
.internal_width
)
733 || (curlw
->label
.internal_height
!= newlw
->label
.internal_height
)
735 /* Resize() will be called if geometry changes succeed */
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
)
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
)
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
+
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
)
778 return XtGeometryAlmost
;