diff options
author | culler <culler> | 2020-11-10 13:59:25 (GMT) |
---|---|---|
committer | culler <culler> | 2020-11-10 13:59:25 (GMT) |
commit | d94200fdcf927707b43670e7751208ea902b382e (patch) | |
tree | c8f724ce055955eef67c4b799866138c5389715d /generic/tkOldTest.c | |
parent | a49d6e52a72b1f086503ae32cb28b0da62e5fa99 (diff) | |
parent | 6133a711414cfb8fcc3a8b52ecf25b59a09e5800 (diff) | |
download | tk-d94200fdcf927707b43670e7751208ea902b382e.zip tk-d94200fdcf927707b43670e7751208ea902b382e.tar.gz tk-d94200fdcf927707b43670e7751208ea902b382e.tar.bz2 |
Merge main
Diffstat (limited to 'generic/tkOldTest.c')
-rw-r--r-- | generic/tkOldTest.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c index d9e8053..22522d8 100644 --- a/generic/tkOldTest.c +++ b/generic/tkOldTest.c @@ -24,18 +24,19 @@ #endif #include "tkInt.h" +#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) /* - * The following data structure represents the master for a test image: + * The following data structure represents the model for a test image: */ -typedef struct TImageMaster { - Tk_ImageMaster master; /* Tk's token for image master. */ +typedef struct TImageModel { + Tk_ImageModel model; /* Tk's token for image model. */ Tcl_Interp *interp; /* Interpreter for application. */ int width, height; /* Dimensions of image. */ char *imageName; /* Name of image (malloc-ed). */ char *varName; /* Name of variable in which to log events for * image (malloc-ed). */ -} TImageMaster; +} TImageModel; /* * The following data structure represents a particular use of a particular @@ -43,7 +44,7 @@ typedef struct TImageMaster { */ typedef struct TImageInstance { - TImageMaster *masterPtr; /* Pointer to master for image. */ + TImageModel *modelPtr; /* Pointer to model for image. */ XColor *fg; /* Foreground color for drawing in image. */ GC gc; /* Graphics context for drawing in image. */ } TImageInstance; @@ -54,7 +55,7 @@ typedef struct TImageInstance { static int ImageCreate(Tcl_Interp *interp, char *name, int argc, char **argv, - Tk_ImageType *typePtr, Tk_ImageMaster master, + Tk_ImageType *typePtr, Tk_ImageModel model, ClientData *clientDataPtr); static ClientData ImageGet(Tk_Window tkwin, ClientData clientData); static void ImageDisplay(ClientData clientData, @@ -84,7 +85,7 @@ static Tk_ImageType imageType = { static int ImageObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); - +#endif /* *---------------------------------------------------------------------- @@ -113,7 +114,9 @@ TkOldTestInit( if (!initialized) { initialized = 1; +#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) Tk_CreateImageType(&imageType); +#endif } return TCL_OK; } @@ -133,7 +136,7 @@ TkOldTestInit( * *---------------------------------------------------------------------- */ - +#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) static int ImageCreate( Tcl_Interp *interp, /* Interpreter for application containing @@ -143,12 +146,12 @@ ImageCreate( char **argv, /* Argument strings for options (doesn't * include image name or type). */ Tk_ImageType *typePtr, /* Pointer to our type record (not used). */ - Tk_ImageMaster master, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - TImageMaster *timPtr; + TImageModel *timPtr; const char *varName; int i; (void)typePtr; @@ -168,8 +171,8 @@ ImageCreate( varName = argv[i+1]; } - timPtr = (TImageMaster *)ckalloc(sizeof(TImageMaster)); - timPtr->master = master; + timPtr = (TImageModel *)ckalloc(sizeof(TImageModel)); + timPtr->model = model; timPtr->interp = interp; timPtr->width = 30; timPtr->height = 15; @@ -179,7 +182,7 @@ ImageCreate( strcpy(timPtr->varName, varName); Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL); *clientDataPtr = timPtr; - Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15); + Tk_ImageChanged(model, 0, 0, 30, 15, 30, 15); return TCL_OK; } @@ -207,7 +210,7 @@ ImageObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; int x, y, width, height; if (objc < 2) { @@ -228,7 +231,7 @@ ImageObjCmd( || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) { return TCL_ERROR; } - Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width, + Tk_ImageChanged(timPtr->model, x, y, width, height, timPtr->width, timPtr->height); } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), @@ -260,9 +263,9 @@ static ClientData ImageGet( Tk_Window tkwin, /* Token for window in which image will be * used. */ - ClientData clientData) /* Pointer to TImageMaster for image. */ + ClientData clientData) /* Pointer to TImageModel for image. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; TImageInstance *instPtr; char buffer[100]; XGCValues gcValues; @@ -272,7 +275,7 @@ ImageGet( TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance)); - instPtr->masterPtr = timPtr; + instPtr->modelPtr = timPtr; instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues); @@ -313,15 +316,15 @@ ImageDisplay( char buffer[200 + TCL_INTEGER_SPACE * 6]; sprintf(buffer, "%s display %d %d %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height, + instPtr->modelPtr->imageName, imageX, imageY, width, height, drawableX, drawableY); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - if (width > (instPtr->masterPtr->width - imageX)) { - width = instPtr->masterPtr->width - imageX; + if (width > (instPtr->modelPtr->width - imageX)) { + width = instPtr->modelPtr->width - imageX; } - if (height > (instPtr->masterPtr->height - imageY)) { - height = instPtr->masterPtr->height - imageY; + if (height > (instPtr->modelPtr->height - imageY)) { + height = instPtr->modelPtr->height - imageY; } XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY, (unsigned) (width-1), (unsigned) (height-1)); @@ -357,8 +360,8 @@ ImageFree( TImageInstance *instPtr = (TImageInstance *)clientData; char buffer[200]; - sprintf(buffer, "%s free", instPtr->masterPtr->imageName); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + sprintf(buffer, "%s free", instPtr->modelPtr->imageName); + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); @@ -384,11 +387,11 @@ ImageFree( static void ImageDelete( - ClientData clientData) /* Pointer to TImageMaster for image. When + ClientData clientData) /* Pointer to TImageModel for image. When * this function is called, no more instances * exist. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; char buffer[100]; sprintf(buffer, "%s delete", timPtr->imageName); @@ -400,6 +403,7 @@ ImageDelete( ckfree(timPtr->varName); ckfree(timPtr); } +#endif /* * Local Variables: |