Lines Matching defs:lw

157 static void SetTextWidthAndHeight(lw)
158 LabelWidget lw;
160 register XFontStruct *fs = lw->label.font;
163 if (lw->label.pixmap != None) {
167 if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
169 lw->label.label_height = height;
170 lw->label.label_width = width;
171 lw->label.label_len = depth;
176 lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
177 if (lw->label.label == NULL) {
178 lw->label.label_len = 0;
179 lw->label.label_width = 0;
181 else if ((nl = index(lw->label.label, '\n')) != NULL) {
183 lw->label.label_len = MULTI_LINE_LABEL;
184 lw->label.label_width = 0;
185 for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
187 if (width > lw->label.label_width) lw->label.label_width = width;
190 lw->label.label_height +=
195 if (width > lw->label.label_width) lw->label.label_width = width;
198 lw->label.label_len = strlen(lw->label.label);
199 lw->label.label_width =
200 XTextWidth(fs, lw->label.label, (int) lw->label.label_len);
204 static void GetnormalGC(lw)
205 LabelWidget lw;
209 values.foreground = lw->label.foreground;
210 values.background = lw->core.background_pixel;
211 values.font = lw->label.font->fid;
213 lw->label.normal_GC = XtGetGC(
214 (Widget)lw,
219 static void GetgrayGC(lw)
220 LabelWidget lw;
224 values.foreground = lw->label.foreground;
225 values.background = lw->core.background_pixel;
226 values.font = lw->label.font->fid;
228 values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
229 lw->label.foreground,
230 lw->core.background_pixel,
231 lw->core.depth);
233 lw->label.stipple = values.tile;
234 lw->label.gray_GC = XtGetGC((Widget)lw,
244 LabelWidget lw = (LabelWidget) new;
246 if (lw->label.label == NULL)
247 lw->label.label = XtNewString(lw->core.name);
249 lw->label.label = XtNewString(lw->label.label);
252 GetnormalGC(lw);
253 GetgrayGC(lw);
255 SetTextWidthAndHeight(lw);
257 if (lw->core.width == 0)
258 lw->core.width = lw->label.label_width + 2 * lw->label.internal_width;
259 if (lw->core.height == 0)
260 lw->core.height = lw->label.label_height + 2*lw->label.internal_height;
262 lw->label.label_x = lw->label.label_y = 0;
263 (*XtClass(new)->core_class.resize) ((Widget)lw);
277 LabelWidget lw = (LabelWidget) w;
281 XRectInRegion(region, lw->label.label_x, lw->label.label_y,
282 lw->label.label_width, lw->label.label_height)
286 gc = XtIsSensitive((Widget)lw) ? lw->label.normal_GC : lw->label.gray_GC;
290 if (lw->label.pixmap == None) {
291 int len = lw->label.label_len;
292 char *label = lw->label.label;
293 Position y = lw->label.label_y + lw->label.font->max_bounds.ascent;
298 XtDisplay(w), XtWindow(w), gc, lw->label.label_x,
300 y += lw->label.font->max_bounds.ascent + lw->label.font->max_bounds.descent;
307 XtDisplay(w), XtWindow(w), gc, lw->label.label_x,
309 } else if (lw->label.label_len == 1) { /* depth */
311 XtDisplay(w), lw->label.pixmap, XtWindow(w), gc,
312 0, 0, lw->label.label_width, lw->label.label_height,
313 lw->label.label_x, lw->label.label_y, 1L);
316 XtDisplay(w), lw->label.pixmap, XtWindow(w), gc,
317 0, 0, lw->label.label_width, lw->label.label_height,
318 lw->label.label_x, lw->label.label_y);
325 static void _Reposition(lw, width, height, dx, dy)
326 register LabelWidget lw;
331 switch (lw->label.justify) {
334 newPos = lw->label.internal_width;
339 (lw->label.label_width + lw->label.internal_width);
343 newPos = (width - lw->label.label_width) / 2;
346 if (newPos < (Position)lw->label.internal_width)
347 newPos = lw->label.internal_width;
348 *dx = newPos - lw->label.label_x;
349 lw->label.label_x = newPos;
350 *dy = (newPos = (height - lw->label.label_height) / 2) - lw->label.label_y;
351 lw->label.label_y = newPos;
358 LabelWidget lw = (LabelWidget)w;
360 _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
453 LabelWidget lw = (LabelWidget)w;
455 XtFree( lw->label.label );
456 XtReleaseGC( w, lw->label.normal_GC );
457 XtReleaseGC( w, lw->label.gray_GC);
458 XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );
466 register LabelWidget lw = (LabelWidget)w;
469 preferred->width = lw->label.label_width + 2 * lw->label.internal_width;
470 preferred->height = lw->label.label_height + 2*lw->label.internal_height;