/* * Free any GC associated with the given id. */ GC freeCgs(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId) { CgsCache *me; int j; if ((me = myCache(xw, cgsWin, cgsId)) != 0) { for (j = 0; j < DEPTH; ++j) { if (LIST(j).gc != 0) { TRACE(("freeCgs(%s, %s) gc %p(%d)\n", traceVTwin(xw, cgsWin), traceCgsEnum(cgsId), (void *) LIST(j).gc, j)); clrCgsFonts(xw, cgsWin, LIST(j).font); #if OPT_BOX_CHARS if (cgsId == gcDots) { XmuReleaseStippledPixmap(XtScreen((Widget) xw), LIST(j).tile); } #endif XFreeGC(TScreenOf(xw)->display, LIST(j).gc); memset(&LIST(j), 0, sizeof(LIST(j))); } LINK(0); } } return 0; }
static void XawLabelDestroy(Widget w) { LabelWidget lw = (LabelWidget)w; if (lw->label.label != lw->core.name) XtFree(lw->label.label); XtReleaseGC(w, lw->label.normal_GC); XtReleaseGC(w, lw->label.gray_GC); XmuReleaseStippledPixmap(XtScreen(w), lw->label.stipple); }
static void XawListDestroy(Widget w) { ListWidget lw = (ListWidget)w; XGCValues values; XGetGCValues(XtDisplay(w), lw->list.graygc, GCTile, &values); XmuReleaseStippledPixmap(XtScreen(w), values.tile); XtReleaseGC(w, lw->list.graygc); XtReleaseGC(w, lw->list.revgc); XtReleaseGC(w, lw->list.normgc); }
/*ARGSUSED*/ static Boolean XawListSetValues(Widget current, Widget request, Widget cnew, ArgList args, Cardinal *num_args) { ListWidget cl = (ListWidget)current; ListWidget rl = (ListWidget)request; ListWidget nl = (ListWidget)cnew; Bool redraw = False; XFontSetExtents *ext = XExtentsOfFontSet(nl->list.fontset); /* If the request height/width is different, lock it. Unless its 0. If neither new nor 0, leave it as it was. Not in R5 */ if (XtWidth(nl) != XtWidth(cl)) nl->list.freedoms |= WidthLock; if (XtWidth(nl) == 0) nl->list.freedoms &= ~WidthLock; if (XtHeight(nl) != XtHeight(cl)) nl->list.freedoms |= HeightLock; if (XtHeight(nl) == 0) nl->list.freedoms &= ~HeightLock; if (nl->list.longest != cl->list.longest) nl->list.freedoms |= LongestLock; if (nl->list.longest == 0) nl->list.freedoms &= ~LongestLock; if (cl->list.foreground != nl->list.foreground || cl->core.background_pixel != nl->core.background_pixel || cl->list.font != nl->list.font) { XGCValues values; XGetGCValues(XtDisplay(current), cl->list.graygc, GCTile, &values); XmuReleaseStippledPixmap(XtScreen(current), values.tile); XtReleaseGC(current, cl->list.graygc); XtReleaseGC(current, cl->list.revgc); XtReleaseGC(current, cl->list.normgc); GetGCs(cnew); redraw = True; } if (cl->list.font != nl->list.font && cl->simple.international == False) nl->list.row_height = nl->list.font->max_bounds.ascent + nl->list.font->max_bounds.descent + nl->list.row_space; else if (cl->list.fontset != nl->list.fontset && cl->simple.international == True) nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space; /* ...If the above two font(set) change checkers above both failed, check if row_space was altered. If one of the above passed, row_height will already have been re-calculated */ else if (cl->list.row_space != nl->list.row_space) { if (cl->simple.international == True) nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space; else nl->list.row_height = nl->list.font->max_bounds.ascent + nl->list.font->max_bounds.descent + nl->list.row_space; } if (XtWidth(cl) != XtWidth(nl) || XtHeight(cl) != XtHeight(nl) || cl->list.internal_width != nl->list.internal_width || cl->list.internal_height != nl->list.internal_height || cl->list.column_space != nl->list.column_space || cl->list.row_space != nl->list.row_space || cl->list.default_cols != nl->list.default_cols || (cl->list.force_cols != nl->list.force_cols && rl->list.force_cols != nl->list.ncols) || cl->list.vertical_cols != nl->list.vertical_cols || cl->list.longest != nl->list.longest || cl->list.nitems != nl->list.nitems || cl->list.font != nl->list.font /* Equiv. fontsets might have different values, but the same fonts, so the next comparison is sloppy but not dangerous */ || cl->list.fontset != nl->list.fontset || cl->list.list != nl->list.list) { CalculatedValues(cnew); Layout(cnew, WidthFree(nl), HeightFree(nl), &nl->core.width, &nl->core.height); redraw = True; } if (cl->list.list != nl->list.list || cl->list.nitems != nl->list.nitems) nl->list.is_highlighted = nl->list.highlight = NO_HIGHLIGHT; if (cl->core.sensitive != nl->core.sensitive || cl->core.ancestor_sensitive != nl->core.ancestor_sensitive) { nl->list.highlight = NO_HIGHLIGHT; redraw = True; } return (redraw); }
static Boolean XawLabelSetValues(Widget current, Widget request, Widget cnew, ArgList args, Cardinal *num_args) { LabelWidget curlw = (LabelWidget)current; LabelWidget reqlw = (LabelWidget)request; LabelWidget newlw = (LabelWidget)cnew; unsigned int i; Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS]; for (i = 0; i < NUM_CHECKS; i++) checks[i] = False; for (i = 0; i < *num_args; i++) { if (streq(XtNbitmap, args[i].name)) checks[PIXMAP] = True; else if (streq(XtNwidth, args[i].name)) checks[WIDTH] = True; else if (streq(XtNheight, args[i].name)) checks[HEIGHT] = True; } if (newlw->label.label == NULL) newlw->label.label = newlw->core.name; /* * resize on bitmap change */ if (curlw->label.left_bitmap != newlw->label.left_bitmap) was_resized = True; if (curlw->label.encoding != newlw->label.encoding) was_resized = True; if (curlw->simple.international && curlw->label.fontset != newlw->label.fontset) was_resized = True; if (curlw->label.label != newlw->label.label) { if (curlw->label.label != curlw->core.name) XtFree((char *)curlw->label.label); if (newlw->label.label != newlw->core.name) newlw->label.label = XtNewString(newlw->label.label); was_resized = True; } if (was_resized || (curlw->label.font != newlw->label.font) || curlw->label.justify != newlw->label.justify || checks[PIXMAP]) { SetTextWidthAndHeight(newlw); was_resized = True; } /* recalculate the window size if something has changed */ if (newlw->label.resize && was_resized) { if (XtHeight(curlw) == XtHeight(reqlw) && !checks[HEIGHT]) XtHeight(newlw) = newlw->label.label_height + (newlw->label.internal_height << 1); set_bitmap_info(newlw); if (XtWidth(curlw) == XtWidth(reqlw) && !checks[WIDTH]) XtWidth(newlw) = newlw->label.label_width + LEFT_OFFSET(newlw) + (newlw->label.internal_width << 1); } if (curlw->label.foreground != newlw->label.foreground || curlw->core.background_pixel != newlw->core.background_pixel || curlw->label.font->fid != newlw->label.font->fid) { /* The Fontset is not in the GC - don't make a new GC if FS changes! */ XtReleaseGC(cnew, curlw->label.normal_GC); XtReleaseGC(cnew, curlw->label.gray_GC); XmuReleaseStippledPixmap(XtScreen(current), curlw->label.stipple); GetNormalGC(newlw); GetGrayGC(newlw); redisplay = True; } if (curlw->label.label_x != newlw->label.label_x || curlw->label.label_y != newlw->label.label_y) redisplay = True; if (curlw->label.internal_width != newlw->label.internal_width || curlw->label.internal_height != newlw->label.internal_height || was_resized) { /* Resize() will be called if geometry changes succeed */ Position dx, dy; _Reposition(newlw, XtWidth(curlw), XtHeight(curlw), &dx, &dy); } return (was_resized || redisplay || XtIsSensitive(current) != XtIsSensitive(cnew)); }