Lines Matching defs:lw
264 static void SetTextWidthAndHeight(UCSLabelWidget lw)
266 XFontStruct *fs = lw->label.font;
270 if (lw->label.pixmap != None) {
274 if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
276 lw->label.label_height = height;
277 lw->label.label_width = width;
278 lw->label.label_len = depth;
282 if ( lw->simple.international == True ) {
284 XFontSet fset = lw->label.fontset;
287 lw->label.label_height = ext->max_ink_extent.height;
288 if (lw->label.label == NULL) {
289 lw->label.label_len = 0;
290 lw->label.label_width = 0;
292 else if ((nl = index(lw->label.label, '\n')) != NULL) {
294 lw->label.label_len = MULTI_LINE_LABEL;
295 lw->label.label_width = 0;
296 for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
299 if (width > (int)lw->label.label_width)
300 lw->label.label_width = width;
303 lw->label.label_height +=
309 if (width > (int) lw->label.label_width)
310 lw->label.label_width = width;
313 lw->label.label_len = strlen(lw->label.label);
314 lw->label.label_width =
315 XmbTextEscapement(fset, lw->label.label, (int) lw->label.label_len);
320 lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
321 if (lw->label.label == NULL) {
322 lw->label.label_len = 0;
323 lw->label.label_width = 0;
325 else if ((nl = index(lw->label.label, '\n')) != NULL) {
327 lw->label.label_len = MULTI_LINE_LABEL;
328 lw->label.label_width = 0;
329 for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
332 if (lw->label.encoding == XawTextEncodingChar2b)
334 else if (lw->label.encoding == XawTextEncodingUCS)
338 if (width > (int)lw->label.label_width)
339 lw->label.label_width = width;
342 lw->label.label_height +=
348 if (lw->label.encoding == XawTextEncodingChar2b)
350 else if (lw->label.encoding == XawTextEncodingUCS)
354 if (width > (int) lw->label.label_width)
355 lw->label.label_width = width;
358 lw->label.label_len = strlen(lw->label.label);
359 if (lw->label.encoding == XawTextEncodingChar2b)
360 lw->label.label_width =
361 XTextWidth16(fs, (XChar2b *)lw->label.label,
362 (int) lw->label.label_len/2);
363 else if (lw->label.encoding == XawTextEncodingUCS)
364 lw->label.label_width = XTextWidthUCS(fs, lw->label.label,
365 lw->label.label_len);
367 lw->label.label_width =
368 XTextWidth(fs, lw->label.label, (int) lw->label.label_len);
374 static void GetnormalGC(UCSLabelWidget lw)
378 values.foreground = lw->label.foreground;
379 values.background = lw->core.background_pixel;
380 values.font = lw->label.font->fid;
383 if ( lw->simple.international == True )
385 lw->label.normal_GC = XtAllocateGC(
386 (Widget)lw, 0,
390 lw->label.normal_GC = XtGetGC(
391 (Widget)lw,
396 static void GetgrayGC(UCSLabelWidget lw)
400 values.foreground = lw->label.foreground;
401 values.background = lw->core.background_pixel;
402 values.font = lw->label.font->fid;
404 values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
405 lw->label.foreground,
406 lw->core.background_pixel,
407 lw->core.depth);
410 lw->label.stipple = values.tile;
411 if ( lw->simple.international == True )
413 lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
419 lw->label.gray_GC = XtGetGC((Widget)lw,
426 static void compute_bitmap_offsets(UCSLabelWidget lw)
432 if (lw->label.lbm_height != 0) {
433 lw->label.lbm_y = (lw->core.height -
434 (lw->label.internal_height * 2 +
435 lw->label.lbm_height)) / 2;
437 lw->label.lbm_y = 0;
442 static void set_bitmap_info(UCSLabelWidget lw)
448 if (!(lw->label.left_bitmap &&
449 XGetGeometry (XtDisplay(lw), lw->label.left_bitmap, &root, &x, &y,
450 &lw->label.lbm_width, &lw->label.lbm_height,
452 lw->label.lbm_width = lw->label.lbm_height = 0;
454 compute_bitmap_offsets (lw);
463 UCSLabelWidget lw = (UCSLabelWidget) new;
465 if (lw->label.label == NULL)
466 lw->label.label = XtNewString(lw->core.name);
468 lw->label.label = XtNewString(lw->label.label);
471 GetnormalGC(lw);
472 GetgrayGC(lw);
474 SetTextWidthAndHeight(lw);
476 if (lw->core.height == 0)
477 lw->core.height = lw->label.label_height +
478 2 * lw->label.internal_height;
480 set_bitmap_info (lw); /* need core.height */
482 if (lw->core.width == 0) /* need label.lbm_width */
483 lw->core.width = (lw->label.label_width +
484 2 * lw->label.internal_width +
485 LEFT_OFFSET(lw));
487 lw->label.label_x = lw->label.label_y = 0;
488 (*XtClass(new)->core_class.resize) ((Widget)lw);
610 static void _Reposition(UCSLabelWidget lw, Dimension width, Dimension height,
614 Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
616 switch (lw->label.justify) {
624 (lw->label.label_width + lw->label.internal_width);
629 newPos = (int)(width - lw->label.label_width) / 2;
634 *dx = newPos - lw->label.label_x;
635 lw->label.label_x = newPos;
636 *dy = (newPos = (int)(height - lw->label.label_height) / 2)
637 - lw->label.label_y;
638 lw->label.label_y = newPos;
644 UCSLabelWidget lw = (UCSLabelWidget)w;
647 _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
648 compute_bitmap_offsets (lw);
759 UCSLabelWidget lw = (UCSLabelWidget)w;
761 if ( lw->label.label != lw->core.name )
762 XtFree( (char *) lw->label.label );
763 XtReleaseGC( w, lw->label.normal_GC );
764 XtReleaseGC( w, lw->label.gray_GC);
765 XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );
772 UCSLabelWidget lw = (UCSLabelWidget)w;
775 preferred->width = (lw->label.label_width +
776 2 * lw->label.internal_width +
777 LEFT_OFFSET(lw));
778 preferred->height = lw->label.label_height +
779 2 * lw->label.internal_height;