Import Tk 8.6.11
This commit is contained in:
227
generic/tkTest.c
227
generic/tkTest.c
@@ -31,9 +31,9 @@
|
||||
#if defined(MAC_OSX_TK)
|
||||
#include "tkMacOSXInt.h"
|
||||
#include "tkScrollbar.h"
|
||||
#define LOG_DISPLAY TkTestLogDisplay()
|
||||
#define LOG_DISPLAY(drawable) TkTestLogDisplay(drawable)
|
||||
#else
|
||||
#define LOG_DISPLAY 1
|
||||
#define LOG_DISPLAY(drawable) 1
|
||||
#endif
|
||||
|
||||
#ifdef __UNIX__
|
||||
@@ -50,17 +50,17 @@
|
||||
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||
EXTERN int Tktest_Init(Tcl_Interp *interp);
|
||||
/*
|
||||
* 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
|
||||
@@ -68,9 +68,11 @@ 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. */
|
||||
Bool displayFailed; /* macOS display attempted out of drawRect. */
|
||||
char buffer[200 + TCL_INTEGER_SPACE * 6]; /* message to log on display. */
|
||||
} TImageInstance;
|
||||
|
||||
/*
|
||||
@@ -79,7 +81,7 @@ typedef struct TImageInstance {
|
||||
|
||||
static int ImageCreate(Tcl_Interp *interp,
|
||||
const char *name, int argc, Tcl_Obj *const objv[],
|
||||
const Tk_ImageType *typePtr, Tk_ImageMaster master,
|
||||
const Tk_ImageType *typePtr, Tk_ImageModel model,
|
||||
ClientData *clientDataPtr);
|
||||
static ClientData ImageGet(Tk_Window tkwin, ClientData clientData);
|
||||
static void ImageDisplay(ClientData clientData,
|
||||
@@ -242,7 +244,7 @@ Tktest_Init(
|
||||
*/
|
||||
|
||||
if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL);
|
||||
@@ -322,10 +324,9 @@ Tktest_Init(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestbitmapObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
TCL_UNUSED(void *), /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
@@ -357,10 +358,9 @@ TestbitmapObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestborderObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
TCL_UNUSED(ClientData), /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
@@ -392,10 +392,9 @@ TestborderObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestcolorObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
TCL_UNUSED(void *), /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
@@ -426,10 +425,9 @@ TestcolorObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestcursorObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
TCL_UNUSED(void *), /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
@@ -455,19 +453,18 @@ TestcursorObjCmd(
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* All the intepreters created by previous calls to "testnewapp" get
|
||||
* All the interpreters created by previous calls to "testnewapp" get
|
||||
* deleted.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestdeleteappsObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument strings. */
|
||||
TCL_UNUSED(void *), /* Main window for application. */
|
||||
TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */
|
||||
TCL_UNUSED(int), /* Number of arguments. */
|
||||
TCL_UNUSED(Tcl_Obj *const *)) /* Argument strings. */
|
||||
{
|
||||
NewApp *nextPtr;
|
||||
|
||||
@@ -498,7 +495,6 @@ TestdeleteappsObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestobjconfigObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -637,7 +633,6 @@ TestobjconfigObjCmd(
|
||||
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
Tk_OptionTable optionTable;
|
||||
Tk_Window tkwin;
|
||||
|
||||
optionTable = Tk_CreateOptionTable(interp, typesSpecs);
|
||||
tables[index] = optionTable;
|
||||
@@ -648,7 +643,7 @@ TestobjconfigObjCmd(
|
||||
}
|
||||
Tk_SetClass(tkwin, "Test");
|
||||
|
||||
recordPtr = ckalloc(sizeof(TypesRecord));
|
||||
recordPtr = (TypesRecord *)ckalloc(sizeof(TypesRecord));
|
||||
recordPtr->header.interp = interp;
|
||||
recordPtr->header.optionTable = optionTable;
|
||||
recordPtr->header.tkwin = tkwin;
|
||||
@@ -693,7 +688,6 @@ TestobjconfigObjCmd(
|
||||
|
||||
case CHAIN1: {
|
||||
ExtensionWidgetRecord *recordPtr;
|
||||
Tk_Window tkwin;
|
||||
Tk_OptionTable optionTable;
|
||||
|
||||
tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
|
||||
@@ -705,7 +699,7 @@ TestobjconfigObjCmd(
|
||||
optionTable = Tk_CreateOptionTable(interp, baseSpecs);
|
||||
tables[index] = optionTable;
|
||||
|
||||
recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
|
||||
recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
|
||||
recordPtr->header.interp = interp;
|
||||
recordPtr->header.optionTable = optionTable;
|
||||
recordPtr->header.tkwin = tkwin;
|
||||
@@ -746,7 +740,6 @@ TestobjconfigObjCmd(
|
||||
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0,
|
||||
(ClientData) baseSpecs, 0}
|
||||
};
|
||||
Tk_Window tkwin;
|
||||
Tk_OptionTable optionTable;
|
||||
|
||||
tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
|
||||
@@ -758,7 +751,7 @@ TestobjconfigObjCmd(
|
||||
optionTable = Tk_CreateOptionTable(interp, extensionSpecs);
|
||||
tables[index] = optionTable;
|
||||
|
||||
recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
|
||||
recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
|
||||
recordPtr->header.interp = interp;
|
||||
recordPtr->header.optionTable = optionTable;
|
||||
recordPtr->header.tkwin = tkwin;
|
||||
@@ -915,7 +908,6 @@ TestobjconfigObjCmd(
|
||||
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
Tk_OptionTable optionTable;
|
||||
Tk_Window tkwin;
|
||||
|
||||
optionTable = Tk_CreateOptionTable(interp, internalSpecs);
|
||||
tables[index] = optionTable;
|
||||
@@ -1060,17 +1052,17 @@ TestobjconfigObjCmd(
|
||||
}
|
||||
|
||||
case TWO_WINDOWS: {
|
||||
typedef struct SlaveRecord {
|
||||
typedef struct ContentRecord {
|
||||
TrivialCommandHeader header;
|
||||
Tcl_Obj *windowPtr;
|
||||
} SlaveRecord;
|
||||
SlaveRecord *recordPtr;
|
||||
static const Tk_OptionSpec slaveSpecs[] = {
|
||||
} ContentRecord;
|
||||
ContentRecord *recordPtr;
|
||||
static const Tk_OptionSpec contentSpecs[] = {
|
||||
{TK_OPTION_WINDOW, "-window", "window", "Window", ".bar",
|
||||
Tk_Offset(SlaveRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
|
||||
Tk_Offset(ContentRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
|
||||
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
Tk_Window tkwin = Tk_CreateWindowFromPath(interp,
|
||||
tkwin = Tk_CreateWindowFromPath(interp,
|
||||
(Tk_Window) clientData, Tcl_GetString(objv[2]), NULL);
|
||||
|
||||
if (tkwin == NULL) {
|
||||
@@ -1078,10 +1070,10 @@ TestobjconfigObjCmd(
|
||||
}
|
||||
Tk_SetClass(tkwin, "Test");
|
||||
|
||||
recordPtr = ckalloc(sizeof(SlaveRecord));
|
||||
recordPtr = (ContentRecord *)ckalloc(sizeof(ContentRecord));
|
||||
recordPtr->header.interp = interp;
|
||||
recordPtr->header.optionTable = Tk_CreateOptionTable(interp,
|
||||
slaveSpecs);
|
||||
contentSpecs);
|
||||
tables[index] = recordPtr->header.optionTable;
|
||||
recordPtr->header.tkwin = tkwin;
|
||||
recordPtr->windowPtr = NULL;
|
||||
@@ -1131,7 +1123,6 @@ TestobjconfigObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TrivialConfigObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1243,7 +1234,7 @@ static void
|
||||
TrivialCmdDeletedProc(
|
||||
ClientData clientData) /* Pointer to widget record for widget. */
|
||||
{
|
||||
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
|
||||
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
|
||||
Tk_Window tkwin = headerPtr->tkwin;
|
||||
|
||||
if (tkwin != NULL) {
|
||||
@@ -1255,8 +1246,8 @@ TrivialCmdDeletedProc(
|
||||
* here.
|
||||
*/
|
||||
|
||||
Tk_FreeConfigOptions((char *) clientData,
|
||||
headerPtr->optionTable, (Tk_Window) NULL);
|
||||
Tk_FreeConfigOptions((char *)clientData,
|
||||
headerPtr->optionTable, NULL);
|
||||
Tcl_EventuallyFree(clientData, TCL_DYNAMIC);
|
||||
}
|
||||
}
|
||||
@@ -1282,11 +1273,11 @@ TrivialEventProc(
|
||||
ClientData clientData, /* Information about window. */
|
||||
XEvent *eventPtr) /* Information about event. */
|
||||
{
|
||||
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
|
||||
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
|
||||
|
||||
if (eventPtr->type == DestroyNotify) {
|
||||
if (headerPtr->tkwin != NULL) {
|
||||
Tk_FreeConfigOptions((char *) clientData,
|
||||
Tk_FreeConfigOptions((char *)clientData,
|
||||
headerPtr->optionTable, headerPtr->tkwin);
|
||||
headerPtr->optionTable = NULL;
|
||||
headerPtr->tkwin = NULL;
|
||||
@@ -1314,7 +1305,6 @@ TrivialEventProc(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestfontObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1328,7 +1318,7 @@ TestfontObjCmd(
|
||||
Tk_Window tkwin;
|
||||
Tk_Font tkfont;
|
||||
|
||||
tkwin = (Tk_Window) clientData;
|
||||
tkwin = (Tk_Window)clientData;
|
||||
|
||||
if (objc < 3) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "option fontName");
|
||||
@@ -1374,7 +1364,6 @@ TestfontObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
ImageCreate(
|
||||
Tcl_Interp *interp, /* Interpreter for application containing
|
||||
@@ -1383,13 +1372,13 @@ ImageCreate(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[], /* Argument strings for options (doesn't
|
||||
* include image name or type). */
|
||||
const Tk_ImageType *typePtr, /* Pointer to our type record (not used). */
|
||||
Tk_ImageMaster master, /* Token for image, to be used by us in later
|
||||
TCL_UNUSED(const Tk_ImageType *), /* Pointer to our type record (not used). */
|
||||
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;
|
||||
|
||||
@@ -1408,18 +1397,18 @@ ImageCreate(
|
||||
varName = Tcl_GetString(objv[i+1]);
|
||||
}
|
||||
|
||||
timPtr = ckalloc(sizeof(TImageMaster));
|
||||
timPtr->master = master;
|
||||
timPtr = (TImageModel *)ckalloc(sizeof(TImageModel));
|
||||
timPtr->model = model;
|
||||
timPtr->interp = interp;
|
||||
timPtr->width = 30;
|
||||
timPtr->height = 15;
|
||||
timPtr->imageName = ckalloc(strlen(name) + 1);
|
||||
timPtr->imageName = (char *)ckalloc(strlen(name) + 1);
|
||||
strcpy(timPtr->imageName, name);
|
||||
timPtr->varName = ckalloc(strlen(varName) + 1);
|
||||
timPtr->varName = (char *)ckalloc(strlen(varName) + 1);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1440,7 +1429,6 @@ ImageCreate(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
ImageObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1448,7 +1436,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) {
|
||||
@@ -1469,7 +1457,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]),
|
||||
@@ -1501,9 +1489,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;
|
||||
@@ -1512,11 +1500,12 @@ ImageGet(
|
||||
Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer,
|
||||
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
|
||||
|
||||
instPtr = ckalloc(sizeof(TImageInstance));
|
||||
instPtr->masterPtr = timPtr;
|
||||
instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance));
|
||||
instPtr->modelPtr = timPtr;
|
||||
instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
|
||||
gcValues.foreground = instPtr->fg->pixel;
|
||||
instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues);
|
||||
instPtr->displayFailed = False;
|
||||
return instPtr;
|
||||
}
|
||||
|
||||
@@ -1550,48 +1539,57 @@ ImageDisplay(
|
||||
/* Coordinates in drawable corresponding to
|
||||
* imageX and imageY. */
|
||||
{
|
||||
TImageInstance *instPtr = (TImageInstance *) clientData;
|
||||
char buffer[200 + TCL_INTEGER_SPACE * 6];
|
||||
TImageInstance *instPtr = (TImageInstance *)clientData;
|
||||
|
||||
/*
|
||||
* The purpose of the test image type is to track the calls to an image
|
||||
* display proc and record the parameters passed in each call. On macOS
|
||||
* a display proc must be run inside of the drawRect method of an NSView
|
||||
* in order for the graphics operations to have any effect. To deal with
|
||||
* display proc and record the parameters passed in each call. On macOS a
|
||||
* display proc must be run inside of the drawRect method of an NSView in
|
||||
* order for the graphics operations to have any effect. To deal with
|
||||
* this, whenever a display proc is called outside of any drawRect method
|
||||
* it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES].
|
||||
* This will trigger a later call to the view's drawRect method which will
|
||||
* run the display proc a second time.
|
||||
* it schedules a redraw of the NSView.
|
||||
*
|
||||
* This complicates testing, since it can result in more calls to the display
|
||||
* proc than are expected by the test. It can also result in an inconsistent
|
||||
* number of calls unless the test waits until the call to drawRect actually
|
||||
* occurs before validating its results.
|
||||
*
|
||||
* In an attempt to work around this, this display proc only logs those
|
||||
* calls which occur within a drawRect method. This means that tests must
|
||||
* be written so as to ensure that the drawRect method is run before
|
||||
* results are validated. In practice it usually suffices to run update
|
||||
* idletasks (to run the display proc the first time) followed by update
|
||||
* (to run the display proc in drawRect).
|
||||
*
|
||||
* This also has the consequence that the image changed command will log
|
||||
* different results on Aqua than on other systems, because when the image
|
||||
* is redisplayed in the drawRect method the entire image will be drawn,
|
||||
* not just the changed portion. Tests must account for this.
|
||||
* In an attempt to work around this, each image instance maintains it own
|
||||
* copy of the log message which gets written on the first call to the
|
||||
* display proc. This usually means that the message created on macOS is
|
||||
* the same as that created on other platforms. However it is possible
|
||||
* for the messages to differ for other reasons, namely differences in
|
||||
* how damage regions are computed.
|
||||
*/
|
||||
|
||||
if (LOG_DISPLAY) {
|
||||
sprintf(buffer, "%s display %d %d %d %d",
|
||||
instPtr->masterPtr->imageName, imageX, imageY, width, height);
|
||||
Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName,
|
||||
NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
|
||||
if (LOG_DISPLAY(drawable)) {
|
||||
if (instPtr->displayFailed == False) {
|
||||
|
||||
/*
|
||||
* Drawing is possible on the first call to DisplayImage.
|
||||
* Log the message.
|
||||
*/
|
||||
|
||||
sprintf(instPtr->buffer, "%s display %d %d %d %d",
|
||||
instPtr->modelPtr->imageName, imageX, imageY, width, height);
|
||||
}
|
||||
Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName,
|
||||
NULL, instPtr->buffer,
|
||||
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
|
||||
instPtr->displayFailed = False;
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Drawing is not possible on the first call to DisplayImage.
|
||||
* Save the message, but do not log it until the actual display.
|
||||
*/
|
||||
|
||||
if (instPtr->displayFailed == False) {
|
||||
sprintf(instPtr->buffer, "%s display %d %d %d %d",
|
||||
instPtr->modelPtr->imageName, imageX, imageY, width, height);
|
||||
}
|
||||
instPtr->displayFailed = True;
|
||||
}
|
||||
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,
|
||||
@@ -1625,11 +1623,11 @@ ImageFree(
|
||||
ClientData clientData, /* Pointer to TImageInstance for instance. */
|
||||
Display *display) /* Display where image was to be drawn. */
|
||||
{
|
||||
TImageInstance *instPtr = (TImageInstance *) clientData;
|
||||
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);
|
||||
@@ -1655,11 +1653,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);
|
||||
@@ -1690,7 +1688,6 @@ ImageDelete(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestmakeexistObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1698,7 +1695,7 @@ TestmakeexistObjCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument strings. */
|
||||
{
|
||||
Tk_Window mainWin = (Tk_Window) clientData;
|
||||
Tk_Window mainWin = (Tk_Window)clientData;
|
||||
int i;
|
||||
Tk_Window tkwin;
|
||||
|
||||
@@ -1731,7 +1728,6 @@ TestmakeexistObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
|
||||
static int
|
||||
TestmenubarObjCmd(
|
||||
@@ -1741,7 +1737,7 @@ TestmenubarObjCmd(
|
||||
Tcl_Obj *const objv[]) /* Argument strings. */
|
||||
{
|
||||
#ifdef __UNIX__
|
||||
Tk_Window mainWin = (Tk_Window) clientData;
|
||||
Tk_Window mainWin = (Tk_Window)clientData;
|
||||
Tk_Window tkwin, menubar;
|
||||
|
||||
if (objc < 2) {
|
||||
@@ -1801,7 +1797,7 @@ TestmenubarObjCmd(
|
||||
#if defined(_WIN32)
|
||||
static int
|
||||
TestmetricsObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
TCL_UNUSED(void *), /* Main window for application. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument strings. */
|
||||
@@ -1846,7 +1842,6 @@ TestmetricsObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestpropObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1854,7 +1849,7 @@ TestpropObjCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument strings. */
|
||||
{
|
||||
Tk_Window mainWin = (Tk_Window) clientData;
|
||||
Tk_Window mainWin = (Tk_Window)clientData;
|
||||
int result, actualFormat;
|
||||
unsigned long bytesAfter, length, value;
|
||||
Atom actualType, propName;
|
||||
@@ -1925,7 +1920,6 @@ TestpropObjCmd(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
TestwrapperObjCmd(
|
||||
ClientData clientData, /* Main window for application. */
|
||||
@@ -1941,7 +1935,7 @@ TestwrapperObjCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
tkwin = (Tk_Window) clientData;
|
||||
tkwin = (Tk_Window)clientData;
|
||||
winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin);
|
||||
if (winPtr == NULL) {
|
||||
return TCL_ERROR;
|
||||
@@ -1978,17 +1972,16 @@ TestwrapperObjCmd(
|
||||
* CustomOptionSet Sets option value to new setting.
|
||||
* CustomOptionGet Creates a new Tcl_Obj.
|
||||
* CustomOptionRestore Resets option value to original value.
|
||||
* CustomOptionFree Free storage for internal rep of
|
||||
* option.
|
||||
* CustomOptionFree Free storage for internal rep of option.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
CustomOptionSet(
|
||||
ClientData clientData,
|
||||
TCL_UNUSED(void *),
|
||||
Tcl_Interp *interp,
|
||||
Tk_Window tkwin,
|
||||
TCL_UNUSED(Tk_Window),
|
||||
Tcl_Obj **value,
|
||||
char *recordPtr,
|
||||
int internalOffset,
|
||||
@@ -2033,7 +2026,7 @@ CustomOptionSet(
|
||||
if (internalPtr != NULL) {
|
||||
if (*value != NULL) {
|
||||
string = Tcl_GetString(*value);
|
||||
newStr = ckalloc((*value)->length + 1);
|
||||
newStr = (char *)ckalloc((*value)->length + 1);
|
||||
strcpy(newStr, string);
|
||||
} else {
|
||||
newStr = NULL;
|
||||
@@ -2047,8 +2040,8 @@ CustomOptionSet(
|
||||
|
||||
static Tcl_Obj *
|
||||
CustomOptionGet(
|
||||
ClientData clientData,
|
||||
Tk_Window tkwin,
|
||||
TCL_UNUSED(void *),
|
||||
TCL_UNUSED(Tk_Window),
|
||||
char *recordPtr,
|
||||
int internalOffset)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user