static int OpenGLConfigure(Tcl_Interp *interp, OpenGLClientData *OpenGLPtr, int argc, CONST84 char** argv, int flags) { int height, width; if (Tk_ConfigureWidget(interp, OpenGLPtr->tkwin, configSpecs, argc, argv, (char *) OpenGLPtr, flags) != TCL_OK) { return TCL_ERROR; } if (sscanf(OpenGLPtr->geometry, "%dx%d", &width, &height) != 2) { Tcl_AppendResult(interp, "bad geometry \"", OpenGLPtr->geometry, "\": expected widthxheight", (char *) NULL); return TCL_ERROR; } Tk_GeometryRequest(OpenGLPtr->tkwin, width, height); Tk_DefineCursor(OpenGLPtr->tkwin, OpenGLPtr->cursor); return TCL_OK; }
int ConfigureSimGraph(Tcl_Interp *interp, SimGraph *graph, int argc, char **argv, int flags) { if (Tk_ConfigureWidget(interp, graph->tkwin, GraphConfigSpecs, argc, argv, (char *) graph, flags) != TCL_OK) { return TCL_ERROR; } Tk_SetBackgroundFromBorder(graph->tkwin, graph->border); EventuallyRedrawGraph(graph); return TCL_OK; }
static int PaxWidgetConfigure(Tcl_Interp * interp, PaxWidget * paxwidget, int argc, char**argv, int flags) { if (Tk_ConfigureWidget(interp, paxwidget->tkwin, configSpecs, argc, argv, (char*) paxwidget, flags) != TCL_OK) return TCL_ERROR; if ((configSpecs[CFGIDX_OBJECT].specFlags & TK_CONFIG_OPTION_SPECIFIED) != 0) { PyObject * tkwin = TkWin_FromTkWindow(paxwidget->interp, paxwidget->tkwin); if (!tkwin) { print_failure_message("Cannot initialize tkwin object"); return TCL_ERROR; } paxWidget_CallMethodArgs(paxwidget->obj, InitTkWinObjectIdx, Py_BuildValue("(O)", tkwin)); Py_DECREF(tkwin); } if (paxwidget->width > 0 || paxwidget->height > 0) { Tk_GeometryRequest(paxwidget->tkwin, paxwidget->width, paxwidget->height); } if (!paxwidget->background_inited || (configSpecs[CFGIDX_BACKGROUND].specFlags & TK_CONFIG_OPTION_SPECIFIED) != 0) { PyObject * border = PaxBorder_FromTkBorder(paxwidget->background, paxwidget->tkwin, 1); if (!border) { print_failure_message("Cannot initialize tkborder objects"); return TCL_ERROR; } paxWidget_CallMethodArgs(paxwidget->obj, InitTkBorderIdx, Py_BuildValue("(O)", border)); Py_DECREF(border); paxwidget->background_inited = 1; Tk_SetBackgroundFromBorder(paxwidget->tkwin, paxwidget->background); } return TCL_OK; }
static int imfsample_configure(Tcl_Interp *interp, Imfsample *imfsample, int argc, char **argv, int flags) { /* Interpret the configuration arguments according to the specs. */ if (Tk_ConfigureWidget(interp, imfsample->tkwin, config_specs, argc, argv, (char *) imfsample, flags) != TCL_OK) return TCL_ERROR; /* Set the background for the window and create a graphics context for use during redisplay. */ Tk_SetWindowBackground(imfsample->tkwin, Tk_3DBorderColor(imfsample->fg_border)->pixel); Tk_SetWindowBackground(imfsample->tkwin, Tk_3DBorderColor(imfsample->bg_border)->pixel); Tk_SetWindowBackground(imfsample->tkwin, Tk_3DBorderColor(imfsample->cu_border)->pixel); if ((imfsample->copygc == None) && 1/*imfsample->double_buffer*/) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; imfsample->copygc = XCreateGC(imfsample->display, DefaultRootWindow(imfsample->display), GCFunction|GCGraphicsExposures, &gcValues); } if (imfsample->gc == None) { imfsample->gc = XCreateGC(imfsample->display, DefaultRootWindow(imfsample->display), None, NULL); } /* Register the desired geometry for the window, then arrange for the window to be redisplayed. */ Tk_GeometryRequest(imfsample->tkwin, imfsample->width, imfsample->height); Tk_SetInternalBorder(imfsample->tkwin, imfsample->border_width); /* Make sure the resized widget is redrawn. */ imfsample->redraw = TRUE; if (!imfsample->update_pending) { Tcl_DoWhenIdle(imfsample_display, (ClientData) imfsample); imfsample->update_pending = 1; } return TCL_OK; }
static int ConfigureBLine(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int argc, CONST84 char** argv, int flags) { register BLineItem *linePtr = (BLineItem *) itemPtr; Tk_Window tkwin; tkwin = Tk_CanvasTkwin(canvas); if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv, (char *) linePtr, flags) != TCL_OK) { return TCL_ERROR; } /* * Recompute bounding box for line. */ ComputeBLineBbox(canvas, linePtr); return TCL_OK; }
static int ConfigureRectOval( Tcl_Interp *interp, /* Used for error reporting. */ Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Rectangle item to reconfigure. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; XGCValues gcValues; GC newGC; unsigned long mask; Tk_Window tkwin; Tk_TSOffset *tsoffset; XColor *color; Pixmap stipple; Tk_State state; tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (const char **)objv, (char *) rectOvalPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } state = itemPtr->state; /* * A few of the options require additional processing, such as graphics * contexts. */ if (rectOvalPtr->outline.activeWidth > rectOvalPtr->outline.width || rectOvalPtr->outline.activeDash.number != 0 || rectOvalPtr->outline.activeColor != NULL || rectOvalPtr->outline.activeStipple != None || rectOvalPtr->activeFillColor != NULL || rectOvalPtr->activeFillStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; } tsoffset = &rectOvalPtr->outline.tsoffset; flags = tsoffset->flags; if (flags & TK_OFFSET_LEFT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[0] + 0.5); } else if (flags & TK_OFFSET_CENTER) { tsoffset->xoffset = (int) ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); } else if (flags & TK_OFFSET_RIGHT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } if (flags & TK_OFFSET_TOP) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[1] + 0.5); } else if (flags & TK_OFFSET_MIDDLE) { tsoffset->yoffset = (int) ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); } else if (flags & TK_OFFSET_BOTTOM) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } /* * Configure the outline graphics context. If mask is non-zero, the gc has * changed and must be reallocated, provided that the new settings specify * a valid outline (non-zero width and non-NULL color) */ mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(rectOvalPtr->outline)); if (mask && \ rectOvalPtr->outline.width != 0 && \ rectOvalPtr->outline.color != NULL) { gcValues.cap_style = CapProjecting; mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { newGC = None; } if (rectOvalPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); } rectOvalPtr->outline.gc = newGC; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } if (state == TK_STATE_HIDDEN) { ComputeRectOvalBbox(canvas, rectOvalPtr); return TCL_OK; } color = rectOvalPtr->fillColor; stipple = rectOvalPtr->fillStipple; if (Canvas(canvas)->currentItemPtr == itemPtr) { if (rectOvalPtr->activeFillColor!=NULL) { color = rectOvalPtr->activeFillColor; } if (rectOvalPtr->activeFillStipple!=None) { stipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->disabledFillColor!=NULL) { color = rectOvalPtr->disabledFillColor; } if (rectOvalPtr->disabledFillStipple!=None) { stipple = rectOvalPtr->disabledFillStipple; } } if (color == NULL) { newGC = None; } else { gcValues.foreground = color->pixel; if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask = GCForeground|GCStipple|GCFillStyle; } else { mask = GCForeground; } #ifdef MAC_OSX_TK /* * Mac OS X CG drawing needs access to the outline linewidth even for * fills (as linewidth controls antialiasing). */ gcValues.line_width = rectOvalPtr->outline.gc != None ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } if (rectOvalPtr->fillGC != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC); } rectOvalPtr->fillGC = newGC; tsoffset = &rectOvalPtr->tsoffset; flags = tsoffset->flags; if (flags & TK_OFFSET_LEFT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[0] + 0.5); } else if (flags & TK_OFFSET_CENTER) { tsoffset->xoffset = (int) ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); } else if (flags & TK_OFFSET_RIGHT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } if (flags & TK_OFFSET_TOP) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[1] + 0.5); } else if (flags & TK_OFFSET_MIDDLE) { tsoffset->yoffset = (int) ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); } else if (flags & TK_OFFSET_BOTTOM) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[3] + 0.5); } ComputeRectOvalBbox(canvas, rectOvalPtr); return TCL_OK; }
static int ConfigureBitmap( Tcl_Interp *interp, /* Used for error reporting. */ Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Bitmap item to reconfigure. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; XGCValues gcValues; GC newGC; Tk_Window tkwin; unsigned long mask; XColor *fgColor; XColor *bgColor; Pixmap bitmap; Tk_State state; tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (const char **) objv, (char *) bmapPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } /* * A few of the options require additional processing, such as those that * determine the graphics context. */ state = itemPtr->state; if (bmapPtr->activeFgColor!=NULL || bmapPtr->activeBgColor!=NULL || bmapPtr->activeBitmap!=None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } if (state == TK_STATE_HIDDEN) { ComputeBitmapBbox(canvas, bmapPtr); return TCL_OK; } fgColor = bmapPtr->fgColor; bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; if (Canvas(canvas)->currentItemPtr == itemPtr) { if (bmapPtr->activeFgColor!=NULL) { fgColor = bmapPtr->activeFgColor; } if (bmapPtr->activeBgColor!=NULL) { bgColor = bmapPtr->activeBgColor; } if (bmapPtr->activeBitmap!=None) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { if (bmapPtr->disabledFgColor!=NULL) { fgColor = bmapPtr->disabledFgColor; } if (bmapPtr->disabledBgColor!=NULL) { bgColor = bmapPtr->disabledBgColor; } if (bmapPtr->disabledBitmap!=None) { bitmap = bmapPtr->disabledBitmap; } } if (bitmap == None) { newGC = None; } else { gcValues.foreground = fgColor->pixel; mask = GCForeground; if (bgColor != NULL) { gcValues.background = bgColor->pixel; mask |= GCBackground; } else { gcValues.clip_mask = bitmap; mask |= GCClipMask; } newGC = Tk_GetGC(tkwin, mask, &gcValues); } if (bmapPtr->gc != None) { Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc); } bmapPtr->gc = newGC; ComputeBitmapBbox(canvas, bmapPtr); return TCL_OK; }
static int ConfigureImage( Tcl_Interp *interp, /* Used for error reporting. */ Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Image item to reconfigure. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { ImageItem *imgPtr = (ImageItem *) itemPtr; Tk_Window tkwin; Tk_Image image; tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (const char **) objv, (char *) imgPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } /* * Create the image. Save the old image around and don't free it until * after the new one is allocated. This keeps the reference count from * going to zero so the image doesn't have to be recreated if it hasn't * changed. */ if (imgPtr->activeImageString != NULL) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; } if (imgPtr->imageString != NULL) { image = Tk_GetImage(interp, tkwin, imgPtr->imageString, ImageChangedProc, imgPtr); if (image == NULL) { return TCL_ERROR; } } else { image = NULL; } if (imgPtr->image != NULL) { Tk_FreeImage(imgPtr->image); } imgPtr->image = image; if (imgPtr->activeImageString != NULL) { image = Tk_GetImage(interp, tkwin, imgPtr->activeImageString, ImageChangedProc, imgPtr); if (image == NULL) { return TCL_ERROR; } } else { image = NULL; } if (imgPtr->activeImage != NULL) { Tk_FreeImage(imgPtr->activeImage); } imgPtr->activeImage = image; if (imgPtr->disabledImageString != NULL) { image = Tk_GetImage(interp, tkwin, imgPtr->disabledImageString, ImageChangedProc, imgPtr); if (image == NULL) { return TCL_ERROR; } } else { image = NULL; } if (imgPtr->disabledImage != NULL) { Tk_FreeImage(imgPtr->disabledImage); } imgPtr->disabledImage = image; ComputeImageBbox(canvas, imgPtr); return TCL_OK; }
static int ConfigureWinItem( Tcl_Interp *interp, /* Used for error reporting. */ Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Window item to reconfigure. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; Tk_Window oldWindow; Tk_Window canvasTkwin; oldWindow = winItemPtr->tkwin; canvasTkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, canvasTkwin, configSpecs, objc, (const char **) objv, (char *) winItemPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } /* * A few of the options require additional processing. */ if (oldWindow != winItemPtr->tkwin) { if (oldWindow != NULL) { Tk_DeleteEventHandler(oldWindow, StructureNotifyMask, WinItemStructureProc, winItemPtr); Tk_ManageGeometry(oldWindow, NULL, NULL); Tk_UnmaintainGeometry(oldWindow, canvasTkwin); Tk_UnmapWindow(oldWindow); } if (winItemPtr->tkwin != NULL) { Tk_Window ancestor, parent; /* * Make sure that the canvas is either the parent of the window * associated with the item or a descendant of that parent. Also, * don't allow a top-of-hierarchy window to be managed inside a * canvas. */ parent = Tk_Parent(winItemPtr->tkwin); for (ancestor = canvasTkwin ;; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) ancestor)->flags & TK_TOP_HIERARCHY) { goto badWindow; } } if (((Tk_FakeWin *) winItemPtr->tkwin)->flags & TK_TOP_HIERARCHY){ goto badWindow; } if (winItemPtr->tkwin == canvasTkwin) { goto badWindow; } Tk_CreateEventHandler(winItemPtr->tkwin, StructureNotifyMask, WinItemStructureProc, winItemPtr); Tk_ManageGeometry(winItemPtr->tkwin, &canvasGeomType, winItemPtr); } } if ((winItemPtr->tkwin != NULL) && (itemPtr->state == TK_STATE_HIDDEN)) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } } ComputeWindowBbox(canvas, winItemPtr); return TCL_OK; badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s in a window item of this canvas", Tk_PathName(winItemPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); winItemPtr->tkwin = NULL; return TCL_ERROR; }
static int ConfigureText( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Rectangle item to reconfigure. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { TextItem *textPtr = (TextItem *) itemPtr; XGCValues gcValues; GC newGC, newSelGC; unsigned long mask; Tk_Window tkwin; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; XColor *selBgColorPtr; XColor *color; Pixmap stipple; Tk_State state; tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (const char **) objv, (char *) textPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } /* * A few of the options require additional processing, such as graphics * contexts. */ state = itemPtr->state; if (textPtr->activeColor != NULL || textPtr->activeStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } color = textPtr->color; stipple = textPtr->stipple; if (Canvas(canvas)->currentItemPtr == itemPtr) { if (textPtr->activeColor != NULL) { color = textPtr->activeColor; } if (textPtr->activeStipple != None) { stipple = textPtr->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (textPtr->disabledColor != NULL) { color = textPtr->disabledColor; } if (textPtr->disabledStipple != None) { stipple = textPtr->disabledStipple; } } newGC = newSelGC = NULL; if (textPtr->tkfont != NULL) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; if (color != NULL) { gcValues.foreground = color->pixel; mask |= GCForeground; if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } newGC = Tk_GetGC(tkwin, mask, &gcValues); } mask &= ~(GCTile|GCFillStyle|GCStipple); if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } if (textInfoPtr->selFgColorPtr != NULL) { gcValues.foreground = textInfoPtr->selFgColorPtr->pixel; } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } if (textPtr->gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; if (textPtr->selTextGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC); } textPtr->selTextGC = newSelGC; selBgColorPtr = Tk_3DBorderColor(textInfoPtr->selBorder); if (Tk_3DBorderColor(textInfoPtr->insertBorder)->pixel == selBgColorPtr->pixel) { if (selBgColorPtr->pixel == BlackPixelOfScreen(Tk_Screen(tkwin))) { gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin)); } else { gcValues.foreground = BlackPixelOfScreen(Tk_Screen(tkwin)); } newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); } else { newGC = NULL; } if (textPtr->cursorOffGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); } textPtr->cursorOffGC = newGC; /* * If the text was changed, move the selection and insertion indices to * keep them inside the item. */ textPtr->numBytes = strlen(textPtr->text); textPtr->numChars = Tcl_NumUtfChars(textPtr->text, textPtr->numBytes); if (textInfoPtr->selItemPtr == itemPtr) { if (textInfoPtr->selectFirst >= textPtr->numChars) { textInfoPtr->selItemPtr = NULL; } else { if (textInfoPtr->selectLast >= textPtr->numChars) { textInfoPtr->selectLast = textPtr->numChars - 1; } if ((textInfoPtr->anchorItemPtr == itemPtr) && (textInfoPtr->selectAnchor >= textPtr->numChars)) { textInfoPtr->selectAnchor = textPtr->numChars - 1; } } } if (textPtr->insertPos >= textPtr->numChars) { textPtr->insertPos = textPtr->numChars; } /* * Restrict so that 0.0 <= angle < 360.0, and then recompute the cached * sine and cosine of the angle. Note that fmod() can produce negative * results, and we try to avoid negative zero as well. */ textPtr->angle = fmod(textPtr->angle, 360.0); if (textPtr->angle < 0.0) { textPtr->angle += 360.0; } if (textPtr->angle == 0.0) { textPtr->angle = 0.0; } textPtr->sine = sin(textPtr->angle * PI/180.0); textPtr->cosine = cos(textPtr->angle * PI/180.0); ComputeTextBbox(canvas, textPtr); return TCL_OK; }
static int ImgBmapConfigureMaster( BitmapMaster *masterPtr, /* Pointer to data structure describing * overall bitmap image to (reconfigure). */ int objc, /* Number of entries in objv. */ Tcl_Obj *const objv[], /* Pairs of configuration options for image. */ int flags) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ { BitmapInstance *instancePtr; int maskWidth, maskHeight, dummy1, dummy2; const char **argv = (const char **) ckalloc((objc+1) * sizeof(char *)); for (dummy1 = 0; dummy1 < objc; dummy1++) { argv[dummy1]=Tcl_GetString(objv[dummy1]); } argv[objc] = NULL; if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp), configSpecs, objc, argv, (char *) masterPtr, flags) != TCL_OK) { ckfree((char *) argv); return TCL_ERROR; } ckfree((char *) argv); /* * Parse the bitmap and/or mask to create binary data. Make sure that the * bitmap and mask have the same dimensions. */ if (masterPtr->data != NULL) { ckfree(masterPtr->data); masterPtr->data = NULL; } if ((masterPtr->fileString != NULL) || (masterPtr->dataString != NULL)) { masterPtr->data = TkGetBitmapData(masterPtr->interp, masterPtr->dataString, masterPtr->fileString, &masterPtr->width, &masterPtr->height, &dummy1, &dummy2); if (masterPtr->data == NULL) { return TCL_ERROR; } } if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); masterPtr->maskData = NULL; } if ((masterPtr->maskFileString != NULL) || (masterPtr->maskDataString != NULL)) { if (masterPtr->data == NULL) { Tcl_SetResult(masterPtr->interp, "can't have mask without bitmap", TCL_STATIC); return TCL_ERROR; } masterPtr->maskData = TkGetBitmapData(masterPtr->interp, masterPtr->maskDataString, masterPtr->maskFileString, &maskWidth, &maskHeight, &dummy1, &dummy2); if (masterPtr->maskData == NULL) { return TCL_ERROR; } if ((maskWidth != masterPtr->width) || (maskHeight != masterPtr->height)) { ckfree(masterPtr->maskData); masterPtr->maskData = NULL; Tcl_SetResult(masterPtr->interp, "bitmap and mask have different sizes", TCL_STATIC); return TCL_ERROR; } } /* * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { ImgBmapConfigureInstance(instancePtr); } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width, masterPtr->height, masterPtr->width, masterPtr->height); return TCL_OK; }