summaryrefslogtreecommitdiffstats
path: root/generic/tkImage.c
diff options
context:
space:
mode:
authorericm <ericm>2000-05-15 18:21:46 (GMT)
committerericm <ericm>2000-05-15 18:21:46 (GMT)
commit698e6260491555c0e947686a83d1fbab938f9102 (patch)
tree13ac478424a609a08eb922b050439a74404458c2 /generic/tkImage.c
parent5a419fa18771e4048b825850f2c7a861d1103e97 (diff)
downloadtk-698e6260491555c0e947686a83d1fbab938f9102.zip
tk-698e6260491555c0e947686a83d1fbab938f9102.tar.gz
tk-698e6260491555c0e947686a83d1fbab938f9102.tar.bz2
* doc/image.n: Added documentation for [image inuse] command.
* tests/image.test: Added tests for [image inuse] command. * generic/tkImage.c (Tk_ImageObjCmd): Added [image inuse] command, which provides a means for programmers to determine if a given image is in use by any widgets. [RFE: 3327].
Diffstat (limited to 'generic/tkImage.c')
-rw-r--r--generic/tkImage.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/generic/tkImage.c b/generic/tkImage.c
index 0c763a1..31ac3bb 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkImage.c,v 1.6 2000/04/25 01:03:06 hobbs Exp $
+ * RCS: @(#) $Id: tkImage.c,v 1.7 2000/05/15 18:21:47 ericm Exp $
*/
#include "tkInt.h"
@@ -157,11 +157,11 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
Tcl_Obj *CONST objv[]; /* Argument strings. */
{
static char *imageOptions[] = {
- "create", "delete", "height", "names", "type", "types", "width",
- (char *) NULL
+ "create", "delete", "height", "inuse", "names", "type", "types",
+ "width", (char *) NULL
};
enum options {
- IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_NAMES,
+ IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES,
IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH
};
TkWindow *winPtr = (TkWindow *) clientData;
@@ -344,18 +344,46 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
Tcl_SetIntObj(Tcl_GetObjResult(interp), masterPtr->height);
break;
}
+
+ case IMAGE_INUSE: {
+ int count = 0;
+ char *arg;
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "name");
+ return TCL_ERROR;
+ }
+ arg = Tcl_GetString(objv[2]);
+ hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
+ if (hPtr == NULL) {
+ Tcl_AppendResult(interp, "image \"", arg,
+ "\" doesn't exist", (char *) NULL);
+ return TCL_ERROR;
+ }
+ masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->typePtr != NULL) {
+ for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
+ imagePtr = imagePtr->nextPtr) {
+ count = 1;
+ break;
+ }
+ }
+ Tcl_SetBooleanObj(Tcl_GetObjResult(interp), count);
+ break;
+ }
+
case IMAGE_NAMES: {
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
}
- for (hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
+ for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_AppendElement(interp, Tcl_GetHashKey(
&winPtr->mainPtr->imageTable, hPtr));
}
break;
}
+
case IMAGE_TYPE: {
char *arg;
if (objc != 3) {