Lines Matching refs:lw

248 static void SetTextWidthAndHeight(lw)
249 LabelWidget lw;
251 XFontStruct *fs = lw->label.font;
255 if (lw->label.pixmap != None) {
259 if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
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;
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')) {
284 if (width > (int)lw->label.label_width)
285 lw->label.label_width = width;
288 lw->label.label_height +=
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)
321 if (width > (int)lw->label.label_width)
322 lw->label.label_width = width;
325 lw->label.label_height +=
331 if (lw->label.encoding)
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)
353 LabelWidget lw;
357 values.foreground = lw->label.foreground;
358 values.background = lw->core.background_pixel;
359 values.font = lw->label.font->fid;
362 if ( lw->simple.international == True )
364 lw->label.normal_GC = XtAllocateGC(
365 (Widget)lw, 0,
369 lw->label.normal_GC = XtGetGC(
370 (Widget)lw,
375 static void GetgrayGC(lw)
376 LabelWidget lw;
380 values.foreground = lw->label.foreground;
381 values.background = lw->core.background_pixel;
382 values.font = lw->label.font->fid;
384 values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
385 lw->label.foreground,
386 lw->core.background_pixel,
387 lw->core.depth);
390 lw->label.stipple = values.tile;
391 if ( lw->simple.international == True )
393 lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
399 lw->label.gray_GC = XtGetGC((Widget)lw,
406 static void compute_bitmap_offsets (lw)
407 LabelWidget lw;
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;
418 lw->label.lbm_y = 0;
423 static void set_bitmap_info (lw)
424 LabelWidget lw;
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);
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);
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);
593 static void _Reposition(lw, width, height, dx, dy)
594 LabelWidget lw;
599 Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
601 switch (lw->label.justify) {
609 (lw->label.label_width + lw->label.internal_width);
614 newPos = (int)(width - lw->label.label_width) / 2;
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;
630 LabelWidget lw = (LabelWidget)w;
633 _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
634 compute_bitmap_offsets (lw);
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 );
761 LabelWidget lw = (LabelWidget)w;
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;