static void DeleteRectOval( Tk_Canvas canvas, /* Info about overall widget. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; Tk_DeleteOutline(display, &(rectOvalPtr->outline)); if (rectOvalPtr->fillColor != NULL) { Tk_FreeColor(rectOvalPtr->fillColor); } if (rectOvalPtr->activeFillColor != NULL) { Tk_FreeColor(rectOvalPtr->activeFillColor); } if (rectOvalPtr->disabledFillColor != NULL) { Tk_FreeColor(rectOvalPtr->disabledFillColor); } if (rectOvalPtr->fillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->fillStipple); } if (rectOvalPtr->activeFillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->activeFillStipple); } if (rectOvalPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->disabledFillStipple); } if (rectOvalPtr->fillGC != None) { Tk_FreeGC(display, rectOvalPtr->fillGC); } }
void Tk_Free3DBorder( Tk_3DBorder border) /* Token for border to be released. */ { TkBorder *borderPtr = (TkBorder *) border; Display *display = DisplayOfScreen(borderPtr->screen); TkBorder *prevPtr; borderPtr->resourceRefCount--; if (borderPtr->resourceRefCount > 0) { return; } prevPtr = (TkBorder *) Tcl_GetHashValue(borderPtr->hashPtr); TkpFreeBorder(borderPtr); if (borderPtr->bgColorPtr != NULL) { Tk_FreeColor(borderPtr->bgColorPtr); } if (borderPtr->darkColorPtr != NULL) { Tk_FreeColor(borderPtr->darkColorPtr); } if (borderPtr->lightColorPtr != NULL) { Tk_FreeColor(borderPtr->lightColorPtr); } if (borderPtr->shadow != None) { Tk_FreeBitmap(display, borderPtr->shadow); } if (borderPtr->bgGC != None) { Tk_FreeGC(display, borderPtr->bgGC); } if (borderPtr->darkGC != None) { Tk_FreeGC(display, borderPtr->darkGC); } if (borderPtr->lightGC != None) { Tk_FreeGC(display, borderPtr->lightGC); } if (prevPtr == borderPtr) { if (borderPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(borderPtr->hashPtr); } else { Tcl_SetHashValue(borderPtr->hashPtr, borderPtr->nextPtr); } } else { while (prevPtr->nextPtr != borderPtr) { prevPtr = prevPtr->nextPtr; } prevPtr->nextPtr = borderPtr->nextPtr; } if (borderPtr->objRefCount == 0) { ckfree((char *) borderPtr); } }
static void ImgBmapFree( ClientData clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display) /* Display containing window that used image. */ { BitmapInstance *instancePtr = clientData; BitmapInstance *prevPtr; instancePtr->refCount--; if (instancePtr->refCount > 0) { return; } /* * There are no more uses of the image within this widget. Free the * instance structure. */ if (instancePtr->fg != NULL) { Tk_FreeColor(instancePtr->fg); } if (instancePtr->bg != NULL) { Tk_FreeColor(instancePtr->bg); } if (instancePtr->bitmap != None) { Tk_FreePixmap(display, instancePtr->bitmap); } if (instancePtr->mask != None) { Tk_FreePixmap(display, instancePtr->mask); } if (instancePtr->gc != None) { Tk_FreeGC(display, instancePtr->gc); } if (instancePtr->masterPtr->instancePtr == instancePtr) { instancePtr->masterPtr->instancePtr = instancePtr->nextPtr; } else { for (prevPtr = instancePtr->masterPtr->instancePtr; prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body */ } prevPtr->nextPtr = instancePtr->nextPtr; } ckfree((char *) instancePtr); }
void Tk_FreeColorFromObj( Tk_Window tkwin, /* The window this color lives in. Needed for * the screen and colormap values. */ Tcl_Obj *objPtr) /* The Tcl_Obj * to be freed. */ { Tk_FreeColor(Tk_GetColorFromObj(tkwin, objPtr)); FreeColorObjProc(objPtr); }
/* ARGSUSED */ void Tk_FreeOptions( Tk_ConfigSpec *specs, /* Describes legal options. */ char *widgRec, /* Record whose fields contain current values * for options. */ Display *display, /* X display; needed for freeing some * resources. */ int needFlags) /* Used to specify additional flags that must * be present in config specs for them to be * considered. */ { register Tk_ConfigSpec *specPtr; char *ptr; for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) { if ((specPtr->specFlags & needFlags) != needFlags) { continue; } ptr = widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_STRING: if (*((char **) ptr) != NULL) { ckfree(*((char **) ptr)); *((char **) ptr) = NULL; } break; case TK_CONFIG_COLOR: if (*((XColor **) ptr) != NULL) { Tk_FreeColor(*((XColor **) ptr)); *((XColor **) ptr) = NULL; } break; case TK_CONFIG_FONT: Tk_FreeFont(*((Tk_Font *) ptr)); *((Tk_Font *) ptr) = NULL; break; case TK_CONFIG_BITMAP: if (*((Pixmap *) ptr) != None) { Tk_FreeBitmap(display, *((Pixmap *) ptr)); *((Pixmap *) ptr) = None; } break; case TK_CONFIG_BORDER: if (*((Tk_3DBorder *) ptr) != NULL) { Tk_Free3DBorder(*((Tk_3DBorder *) ptr)); *((Tk_3DBorder *) ptr) = NULL; } break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: if (*((Tk_Cursor *) ptr) != None) { Tk_FreeCursor(display, *((Tk_Cursor *) ptr)); *((Tk_Cursor *) ptr) = None; } } } }
static void DeleteText( Tk_Canvas canvas, /* Info about overall canvas widget. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { TextItem *textPtr = (TextItem *) itemPtr; if (textPtr->color != NULL) { Tk_FreeColor(textPtr->color); } if (textPtr->activeColor != NULL) { Tk_FreeColor(textPtr->activeColor); } if (textPtr->disabledColor != NULL) { Tk_FreeColor(textPtr->disabledColor); } Tk_FreeFont(textPtr->tkfont); if (textPtr->stipple != None) { Tk_FreeBitmap(display, textPtr->stipple); } if (textPtr->activeStipple != None) { Tk_FreeBitmap(display, textPtr->activeStipple); } if (textPtr->disabledStipple != None) { Tk_FreeBitmap(display, textPtr->disabledStipple); } if (textPtr->text != NULL) { ckfree(textPtr->text); } Tk_FreeTextLayout(textPtr->textLayout); if (textPtr->gc != NULL) { Tk_FreeGC(display, textPtr->gc); } if (textPtr->selTextGC != NULL) { Tk_FreeGC(display, textPtr->selTextGC); } if (textPtr->cursorOffGC != NULL) { Tk_FreeGC(display, textPtr->cursorOffGC); } }
static void ImageFree( ClientData clientData, /* Pointer to TImageInstance for instance. */ Display *display) /* Display where image was to be drawn. */ { TImageInstance *instPtr = clientData; char buffer[200]; sprintf(buffer, "%s free", instPtr->masterPtr->imageName); Tcl_SetVar(instPtr->masterPtr->interp, instPtr->masterPtr->varName, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); ckfree((char *) instPtr); }
callGraphConsts::~callGraphConsts() { Tk_FreeFont(rootItemFontStruct); Tk_FreeFont(rootItemItalicFontStruct); Tk_FreeFont(listboxItemFontStruct); Tk_FreeFont(listboxItemItalicFontStruct); Tk_FreeColor(textColor); Tk_FreeGC(display, rootItemTextGC); Tk_FreeGC(display, listboxItemGC); Tk_Free3DBorder(rootItemTk3DBordersByStyle[0]); Tk_Free3DBorder(rootItemTk3DBordersByStyle[1]); // Note that we intentionally don't free up anything in // listboxItemTk3DBordersByStyle, since it was always just a shadow copy // of the contents of rootItemTk3DBordersByStyle }
static void DeleteBitmap( Tk_Canvas canvas, /* Info about overall canvas widget. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; if (bmapPtr->bitmap != None) { Tk_FreeBitmap(display, bmapPtr->bitmap); } if (bmapPtr->activeBitmap != None) { Tk_FreeBitmap(display, bmapPtr->activeBitmap); } if (bmapPtr->disabledBitmap != None) { Tk_FreeBitmap(display, bmapPtr->disabledBitmap); } if (bmapPtr->fgColor != NULL) { Tk_FreeColor(bmapPtr->fgColor); } if (bmapPtr->activeFgColor != NULL) { Tk_FreeColor(bmapPtr->activeFgColor); } if (bmapPtr->disabledFgColor != NULL) { Tk_FreeColor(bmapPtr->disabledFgColor); } if (bmapPtr->bgColor != NULL) { Tk_FreeColor(bmapPtr->bgColor); } if (bmapPtr->activeBgColor != NULL) { Tk_FreeColor(bmapPtr->activeBgColor); } if (bmapPtr->disabledBgColor != NULL) { Tk_FreeColor(bmapPtr->disabledBgColor); } if (bmapPtr->gc != NULL) { Tk_FreeGC(display, bmapPtr->gc); } }
static int DoConfig( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Window tkwin, /* Window containing widget (needed to set up * X resources). */ Tk_ConfigSpec *specPtr, /* Specifier to apply. */ Tk_Uid value, /* Value to use to fill in widgRec. */ int valueIsUid, /* Non-zero means value is a Tk_Uid; zero * means it's an ordinary string. */ char *widgRec) /* Record whose fields are to be modified. * Values must be properly initialized. */ { char *ptr; Tk_Uid uid; int nullValue; nullValue = 0; if ((*value == 0) && (specPtr->specFlags & TK_CONFIG_NULL_OK)) { nullValue = 1; } do { ptr = widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_BOOLEAN: if (Tcl_GetBoolean(interp, value, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_INT: if (Tcl_GetInt(interp, value, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_DOUBLE: if (Tcl_GetDouble(interp, value, (double *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_STRING: { char *oldStr, *newStr; if (nullValue) { newStr = NULL; } else { newStr = (char *) ckalloc((unsigned) (strlen(value) + 1)); strcpy(newStr, value); } oldStr = *((char **) ptr); if (oldStr != NULL) { ckfree(oldStr); } *((char **) ptr) = newStr; break; } case TK_CONFIG_UID: if (nullValue) { *((Tk_Uid *) ptr) = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); *((Tk_Uid *) ptr) = uid; } break; case TK_CONFIG_COLOR: { XColor *newPtr, *oldPtr; if (nullValue) { newPtr = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newPtr = Tk_GetColor(interp, tkwin, uid); if (newPtr == NULL) { return TCL_ERROR; } } oldPtr = *((XColor **) ptr); if (oldPtr != NULL) { Tk_FreeColor(oldPtr); } *((XColor **) ptr) = newPtr; break; } case TK_CONFIG_FONT: { Tk_Font newFont; if (nullValue) { newFont = NULL; } else { newFont = Tk_GetFont(interp, tkwin, value); if (newFont == NULL) { return TCL_ERROR; } } Tk_FreeFont(*((Tk_Font *) ptr)); *((Tk_Font *) ptr) = newFont; break; } case TK_CONFIG_BITMAP: { Pixmap newBmp, oldBmp; if (nullValue) { newBmp = None; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBmp = Tk_GetBitmap(interp, tkwin, uid); if (newBmp == None) { return TCL_ERROR; } } oldBmp = *((Pixmap *) ptr); if (oldBmp != None) { Tk_FreeBitmap(Tk_Display(tkwin), oldBmp); } *((Pixmap *) ptr) = newBmp; break; } case TK_CONFIG_BORDER: { Tk_3DBorder newBorder, oldBorder; if (nullValue) { newBorder = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBorder = Tk_Get3DBorder(interp, tkwin, uid); if (newBorder == NULL) { return TCL_ERROR; } } oldBorder = *((Tk_3DBorder *) ptr); if (oldBorder != NULL) { Tk_Free3DBorder(oldBorder); } *((Tk_3DBorder *) ptr) = newBorder; break; } case TK_CONFIG_RELIEF: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: { Tk_Cursor newCursor, oldCursor; if (nullValue) { newCursor = None; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); if (newCursor == None) { return TCL_ERROR; } } oldCursor = *((Tk_Cursor *) ptr); if (oldCursor != None) { Tk_FreeCursor(Tk_Display(tkwin), oldCursor); } *((Tk_Cursor *) ptr) = newCursor; if (specPtr->type == TK_CONFIG_ACTIVE_CURSOR) { Tk_DefineCursor(tkwin, newCursor); } break; } case TK_CONFIG_JUSTIFY: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); if (Tk_GetJustify(interp, uid, (Tk_Justify *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_ANCHOR: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); if (Tk_GetAnchor(interp, uid, (Tk_Anchor *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_CAP_STYLE: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); if (Tk_GetCapStyle(interp, uid, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_JOIN_STYLE: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); if (Tk_GetJoinStyle(interp, uid, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_PIXELS: if (Tk_GetPixels(interp, tkwin, value, (int *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_MM: if (Tk_GetScreenMM(interp, tkwin, value, (double*)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_WINDOW: { Tk_Window tkwin2; if (nullValue) { tkwin2 = NULL; } else { tkwin2 = Tk_NameToWindow(interp, value, tkwin); if (tkwin2 == NULL) { return TCL_ERROR; } } *((Tk_Window *) ptr) = tkwin2; break; } case TK_CONFIG_CUSTOM: if ((*specPtr->customPtr->parseProc)( specPtr->customPtr->clientData, interp, tkwin, value, widgRec, specPtr->offset) != TCL_OK) { return TCL_ERROR; } break; default: { char buf[64 + TCL_INTEGER_SPACE]; sprintf(buf, "bad config table: unknown type %d", specPtr->type); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } specPtr++; } while ((specPtr->argvName == NULL) && (specPtr->type != TK_CONFIG_END)); return TCL_OK; }
static void ImgBmapConfigureInstance( BitmapInstance *instancePtr)/* Instance to reconfigure. */ { BitmapMaster *masterPtr = instancePtr->masterPtr; XColor *colorPtr; XGCValues gcValues; GC gc; unsigned int mask; Pixmap oldBitmap, oldMask; /* * For each of the options in masterPtr, translate the string form into an * internal form appropriate for instancePtr. */ if (*masterPtr->bgUid != 0) { colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin, masterPtr->bgUid); if (colorPtr == NULL) { goto error; } } else { colorPtr = NULL; } if (instancePtr->bg != NULL) { Tk_FreeColor(instancePtr->bg); } instancePtr->bg = colorPtr; colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin, masterPtr->fgUid); if (colorPtr == NULL) { goto error; } if (instancePtr->fg != NULL) { Tk_FreeColor(instancePtr->fg); } instancePtr->fg = colorPtr; /* * Careful: We have to allocate new Pixmaps before deleting the old ones. * Otherwise, The XID allocator will always return the same XID for the * new Pixmaps as was used for the old Pixmaps. And that will prevent the * data and/or mask from changing in the GC below. */ oldBitmap = instancePtr->bitmap; instancePtr->bitmap = None; oldMask = instancePtr->mask; instancePtr->mask = None; if (masterPtr->data != NULL) { instancePtr->bitmap = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), masterPtr->data, (unsigned) masterPtr->width, (unsigned) masterPtr->height); } if (masterPtr->maskData != NULL) { instancePtr->mask = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), masterPtr->maskData, (unsigned) masterPtr->width, (unsigned) masterPtr->height); } if (oldMask != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } if (oldBitmap != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap); } if (masterPtr->data != NULL) { gcValues.foreground = instancePtr->fg->pixel; gcValues.graphics_exposures = False; mask = GCForeground|GCGraphicsExposures; if (instancePtr->bg != NULL) { gcValues.background = instancePtr->bg->pixel; mask |= GCBackground; if (instancePtr->mask != None) { gcValues.clip_mask = instancePtr->mask; mask |= GCClipMask; } } else { gcValues.clip_mask = instancePtr->bitmap; mask |= GCClipMask; } gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues); } else { gc = None; } if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = gc; return; error: /* * An error occurred: clear the graphics context in the instance to make * it clear that this instance cannot be displayed. Then report the error. */ if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = None; Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf( "\n (while configuring image \"%s\")", Tk_NameOfImage( masterPtr->tkMaster))); Tcl_BackgroundError(masterPtr->interp); }