/*
* tkTest.c --
*
* This file contains C command procedures for a bunch of additional
* Tcl commands that are used for testing out Tcl's C interfaces.
* These commands are not normally included in Tcl applications;
* they're only used for testing.
*
* Copyright (c) 1993-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkTest.c 1.35 96/10/03 11:22:26
*/
#include "tkInt.h"
#ifdef WIN_TCL
#include "tkWinInt.h"
#endif
/*
* The table below describes events and is used by the "testevent"
* command.
*/
typedef struct {
* ButtonPress. */
} EventInfo;
{"Motion", MotionNotify},
{"Button", ButtonPress},
{"ButtonPress", ButtonPress},
{"ButtonRelease", ButtonRelease},
{"Colormap", ColormapNotify},
{"Enter", EnterNotify},
{"Leave", LeaveNotify},
{"Expose", Expose},
{"FocusIn", FocusIn},
{"FocusOut", FocusOut},
{"Keymap", KeymapNotify},
{"Key", KeyPress},
{"KeyPress", KeyPress},
{"KeyRelease", KeyRelease},
{"Property", PropertyNotify},
{"ResizeRequest", ResizeRequest},
{"Circulate", CirculateNotify},
{"Configure", ConfigureNotify},
{"Destroy", DestroyNotify},
{"Gravity", GravityNotify},
{"Map", MapNotify},
{"Reparent", ReparentNotify},
{"Unmap", UnmapNotify},
{"Visibility", VisibilityNotify},
{"CirculateRequest",CirculateRequest},
{"ConfigureRequest",ConfigureRequest},
{"MapRequest", MapRequest},
{(char *) NULL, 0}
};
/*
* The defines and table below are used to classify events into
* various groups. The reason for this is that logically identical
* fields (e.g. "state") appear at different places in different
* types of events. The classification masks can be used to figure
* out quickly where to extract information from events.
*/
/* Not used */ 0,
/* Not used */ 0,
/* KeyPress */ KEY_BUTTON_MOTION,
/* KeyRelease */ KEY_BUTTON_MOTION,
/* ButtonPress */ KEY_BUTTON_MOTION,
/* ButtonRelease */ KEY_BUTTON_MOTION,
/* MotionNotify */ KEY_BUTTON_MOTION,
/* EnterNotify */ CROSSING,
/* LeaveNotify */ CROSSING,
/* FocusIn */ FOCUS,
/* FocusOut */ FOCUS,
/* KeymapNotify */ 0,
/* Expose */ EXPOSE,
/* GraphicsExpose */ EXPOSE,
/* NoExpose */ 0,
/* VisibilityNotify */ VISIBILITY,
/* CreateNotify */ CREATE,
/* DestroyNotify */ 0,
/* UnmapNotify */ 0,
/* MapNotify */ MAP,
/* MapRequest */ 0,
/* ReparentNotify */ REPARENT,
/* ConfigureNotify */ CONFIG,
/* ConfigureRequest */ CONFIG_REQ,
/* GravityNotify */ 0,
/* ResizeRequest */ RESIZE_REQ,
/* CirculateNotify */ 0,
/* CirculateRequest */ 0,
/* PropertyNotify */ PROP,
/* SelectionClear */ SEL_CLEAR,
/* SelectionRequest */ SEL_REQ,
/* SelectionNotify */ SEL_NOTIFY,
/* ColormapNotify */ COLORMAP,
/* ClientMessage */ 0,
/* MappingNotify */ MAPPING
};
/*
* The following data structure represents the master for a test
* image:
*/
typedef struct TImageMaster {
* events for image (malloc-ed). */
} TImageMaster;
/*
* The following data structure represents a particular use of a
* particular test image.
*/
typedef struct TImageInstance {
/*
* The type record for test images:
*/
int drawableY));
"test", /* name */
ImageCreate, /* createProc */
ImageGet, /* getProc */
ImageDisplay, /* displayProc */
ImageFree, /* freeProc */
ImageDelete, /* deleteProc */
};
/*
* One of the following structures describes each of the interpreters
* created by the "testnewapp" command. This information is used by
* the "testdeleteinterps" command to destroy all of those interpreters.
*/
typedef struct NewApp {
} NewApp;
/* First in list of all new interpreters. */
/*
* Declaration for the square widget's class command procedure:
*/
/*
* Forward declarations for procedures defined later in this file:
*/
#ifdef WIN_TCL
#endif
/*
*----------------------------------------------------------------------
*
* Tktest_Init --
*
* This procedure performs intialization for the Tk test
* suite exensions.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Creates several test commands.
*
*----------------------------------------------------------------------
*/
int
{
static int initialized = 0;
/*
* Create additional commands for testing Tk.
*/
return TCL_ERROR;
}
#ifdef WIN_TCL
#endif
/*
* Create test image type.
*/
if (!initialized) {
initialized = 1;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TestclipboardCmd --
*
* This procedure implements the testclipboard command. It provides
* a way to determine the actual contents of the Windows clipboard.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#ifdef WIN_TCL
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
char *data;
if (OpenClipboard(NULL)) {
}
}
return TCL_OK;
}
#endif
/*
*----------------------------------------------------------------------
*
* TestdeleteappsCmd --
*
* This procedure implements the "testdeleteapps" command. It cleans
* up all the interpreters left behind by the "testnewapp" command.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* All the intepreters created by previous calls to "testnewapp"
* get deleted.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TesteventCmd --
*
* This procedure implements the "testevent" command. It allows
* events to be generated on the fly, for testing event-handling.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Creates and handles events.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
" window type ?field value field value ...?\"",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
/*
* Get the type of the event.
*/
"\"", (char *) NULL);
return TCL_ERROR;
}
break;
}
}
/*
* Fill in fields that are common to all events.
*/
/*
* Process the remaining arguments to fill in additional fields
* of the event.
*/
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
}
} else {
(char *) NULL);
return TCL_ERROR;
}
} else {
}
} else if (flags & CONFIG_REQ) {
} else {
(char *) NULL);
return TCL_ERROR;
}
}
return TCL_ERROR;
}
return TCL_ERROR;
}
} else if (flags & RESIZE_REQ) {
}
return TCL_ERROR;
}
"\"", (char *) NULL);
return TCL_ERROR;
}
if (number == 0) {
"\"", (char *) NULL);
return TCL_ERROR;
}
number = NotifyGrab;
} else {
(char *) NULL);
return TCL_ERROR;
}
}
return TCL_ERROR;
}
}
} else {
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION) {
return TCL_ERROR;
}
return TCL_ERROR;
}
} else if (flags & VISIBILITY) {
} else {
(char *) NULL);
return TCL_ERROR;
}
}
return TCL_ERROR;
}
return TCL_ERROR;
}
} else if (flags & SEL_NOTIFY) {
}
return TCL_ERROR;
}
return TCL_ERROR;
}
} else if (flags & RESIZE_REQ) {
}
return TCL_ERROR;
}
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION) {
}
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION) {
}
} else {
(char *) NULL);
return TCL_ERROR;
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TestmakeexistCmd --
*
* This procedure implements the "testmakeexist" command. It calls
* Tk_MakeWindowExist on each of its arguments to force the windows
* to be created.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Forces windows to be created.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int i;
for (i = 1; i < argc; i++) {
return TCL_ERROR;
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* ImageCreate --
*
* This procedure is called by the Tk image code to create "test"
* images.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* The data structure for a new image is allocated.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
* image. */
char *name; /* Name to use for image. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings for options (doesn't
* include image name or type). */
* later callbacks. */
* it will be returned in later callbacks. */
{
char *varName;
int i;
varName = "log";
for (i = 0; i < argc; i += 2) {
"\"", (char *) NULL);
return TCL_ERROR;
}
if ((i+1) == argc) {
"\" option", (char *) NULL);
return TCL_ERROR;
}
}
(Tcl_CmdDeleteProc *) NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* ImageCmd --
*
* This procedure implements the commands corresponding to individual
* images.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Forces windows to be created.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
if (argc < 2) {
return TCL_ERROR;
}
if (argc != 8) {
argv[0], " changed x y width height imageWidth imageHeight",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
} else {
"\": must be changed", (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* ImageGet --
*
* This procedure is called by Tk to set things up for using a
* test image in a particular widget.
*
* Results:
* The return value is a token for the image instance, which is
* used in future callbacks to ImageDisplay and ImageFree.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static ClientData
* be used. */
{
return (ClientData) instPtr;
}
/*
*----------------------------------------------------------------------
*
* ImageDisplay --
*
* This procedure is invoked to redisplay part or all of an
* image in a given drawable.
*
* Results:
* None.
*
* Side effects:
* The image gets partially redrawn, as an "X" that shows the
* exact redraw area.
*
*----------------------------------------------------------------------
*/
static void
* origin of image. */
* imageX and imageY. */
{
}
}
}
/*
*----------------------------------------------------------------------
*
* ImageFree --
*
* This procedure is called when an instance of an image is
* no longer used.
*
* Results:
* None.
*
* Side effects:
* Information related to the instance is freed.
*
*----------------------------------------------------------------------
*/
static void
{
}
/*
*----------------------------------------------------------------------
*
* ImageDelete --
*
* This procedure is called to clean up a test image when
* an application goes away.
*
* Results:
* None.
*
* Side effects:
* Information about the image is deleted.
*
*----------------------------------------------------------------------
*/
static void
* this procedure is called, no more
* instances exist. */
{
}
/*
*----------------------------------------------------------------------
*
* TestsendCmd --
*
* This procedure implements the "testsend" command. It provides
* a set of functions for testing the "send" command and support
* procedure in tkSend.c.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Depends on option; see below.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
if (argc < 2) {
" option ?arg ...?\"", (char *) NULL);
return TCL_ERROR;
}
#ifndef WIN_TCL
(unsigned char *) "This is bogus information", 6);
unsigned long bytesAfter;
Window w;
" prop window name ?value ?\"", (char *) NULL);
return TCL_ERROR;
}
} else {
}
if (argc == 4) {
&bytesAfter, (unsigned char **) &property);
if (*p == 0) {
*p = '\n';
}
}
}
}
} else {
if (argv[4][0] == 0) {
} else {
for (p = argv[4]; *p != 0; p++) {
if (*p == '\n') {
*p = 0;
}
}
}
}
} else {
"\": must be bogus, prop, or serial", (char *) NULL);
return TCL_ERROR;
}
#endif
return TCL_OK;
}