summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkArgv.c842
-rw-r--r--generic/tkButton.h648
-rw-r--r--generic/tkCanvas.h616
-rw-r--r--generic/tkColor.h170
-rw-r--r--generic/tkImgPPM.c1650
-rw-r--r--generic/tkMenubutton.h464
-rw-r--r--generic/tkSelect.h346
-rw-r--r--generic/tkUndo.h246
8 files changed, 2491 insertions, 2491 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index d0bfd77..a138221 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -1,421 +1,421 @@
-/*
- * tkArgv.c --
- *
- * This file contains a function that handles table-based argv-argc
- * parsing.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkArgv.c,v 1.6 2007/06/24 16:07:34 dkf Exp $
- */
-
-#include "tkPort.h"
-#include "tk.h"
-
-/*
- * Default table of argument descriptors. These are normally available in
- * every application.
- */
-
-static Tk_ArgvInfo defaultTable[] = {
- {"-help", TK_ARGV_HELP, NULL, NULL,
- "Print summary of command-line options and abort"},
- {NULL, TK_ARGV_END, NULL, NULL, NULL}
-};
-
-/*
- * Forward declarations for functions defined in this file:
- */
-
-static void PrintUsage(Tcl_Interp *interp, Tk_ArgvInfo *argTable,
- int flags);
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ParseArgv --
- *
- * Process an argv array according to a table of expected command-line
- * options. See the manual page for more details.
- *
- * Results:
- * The return value is a standard Tcl return value. If an error occurs
- * then an error message is left in the interp's result. Under normal
- * conditions, both *argcPtr and *argv are modified to return the
- * arguments that couldn't be processed here (they didn't match the
- * option table, or followed an TK_ARGV_REST argument).
- *
- * Side effects:
- * Variables may be modified, resources may be entered for tkwin, or
- * functions may be called. It all depends on the arguments and their
- * entries in argTable. See the user documentation for details.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_ParseArgv(
- Tcl_Interp *interp, /* Place to store error message. */
- Tk_Window tkwin, /* Window to use for setting Tk options. NULL
- * means ignore Tk option specs. */
- int *argcPtr, /* Number of arguments in argv. Modified to
- * hold # args left in argv at end. */
- CONST char **argv, /* Array of arguments. Modified to hold those
- * that couldn't be processed here. */
- Tk_ArgvInfo *argTable, /* Array of option descriptions */
- int flags) /* Or'ed combination of various flag bits,
- * such as TK_ARGV_NO_DEFAULTS. */
-{
- register Tk_ArgvInfo *infoPtr;
- /* Pointer to the current entry in the table
- * of argument descriptions. */
- Tk_ArgvInfo *matchPtr; /* Descriptor that matches current argument. */
- CONST char *curArg; /* Current argument */
- register char c; /* Second character of current arg (used for
- * quick check for matching; use 2nd char.
- * because first char. will almost always be
- * '-'). */
- int srcIndex; /* Location from which to read next argument
- * from argv. */
- int dstIndex; /* Index into argv to which next unused
- * argument should be copied (never greater
- * than srcIndex). */
- int argc; /* # arguments in argv still to process. */
- size_t length; /* Number of characters in current argument. */
- int i;
-
- if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) {
- srcIndex = dstIndex = 0;
- argc = *argcPtr;
- } else {
- srcIndex = dstIndex = 1;
- argc = *argcPtr-1;
- }
-
- while (argc > 0) {
- curArg = argv[srcIndex];
- srcIndex++;
- argc--;
- length = strlen(curArg);
- if (length > 0) {
- c = curArg[1];
- } else {
- c = 0;
- }
-
- /*
- * Loop throught the argument descriptors searching for one with the
- * matching key string. If found, leave a pointer to it in matchPtr.
- */
-
- matchPtr = NULL;
- for (i = 0; i < 2; i++) {
- if (i == 0) {
- infoPtr = argTable;
- } else {
- infoPtr = defaultTable;
- }
- for (; (infoPtr != NULL) && (infoPtr->type != TK_ARGV_END);
- infoPtr++) {
- if (infoPtr->key == NULL) {
- continue;
- }
- if ((infoPtr->key[1] != c)
- || (strncmp(infoPtr->key, curArg, length) != 0)) {
- continue;
- }
- if ((tkwin == NULL)
- && ((infoPtr->type == TK_ARGV_CONST_OPTION)
- || (infoPtr->type == TK_ARGV_OPTION_VALUE)
- || (infoPtr->type == TK_ARGV_OPTION_NAME_VALUE))) {
- continue;
- }
- if (infoPtr->key[length] == 0) {
- matchPtr = infoPtr;
- goto gotMatch;
- }
- if (flags & TK_ARGV_NO_ABBREV) {
- continue;
- }
- if (matchPtr != NULL) {
- Tcl_AppendResult(interp, "ambiguous option \"", curArg,
- "\"", NULL);
- return TCL_ERROR;
- }
- matchPtr = infoPtr;
- }
- }
- if (matchPtr == NULL) {
- /*
- * Unrecognized argument. Just copy it down, unless the caller
- * prefers an error to be registered.
- */
-
- if (flags & TK_ARGV_NO_LEFTOVERS) {
- Tcl_AppendResult(interp, "unrecognized argument \"",
- curArg, "\"", NULL);
- return TCL_ERROR;
- }
- argv[dstIndex] = curArg;
- dstIndex++;
- continue;
- }
-
- /*
- * Take the appropriate action based on the option type
- */
-
- gotMatch:
- infoPtr = matchPtr;
- switch (infoPtr->type) {
- case TK_ARGV_CONSTANT:
- *((int *) infoPtr->dst) = (int) infoPtr->src;
- break;
- case TK_ARGV_INT:
- if (argc == 0) {
- goto missingArg;
- } else {
- char *endPtr;
-
- *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_AppendResult(interp,"expected integer argument for \"",
- infoPtr->key, "\" but got \"", argv[srcIndex],
- "\"", NULL);
- return TCL_ERROR;
- }
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_STRING:
- if (argc == 0) {
- goto missingArg;
- }
- *((CONST char **)infoPtr->dst) = argv[srcIndex];
- srcIndex++;
- argc--;
- break;
- case TK_ARGV_UID:
- if (argc == 0) {
- goto missingArg;
- }
- *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]);
- srcIndex++;
- argc--;
- break;
- case TK_ARGV_REST:
- *((int *) infoPtr->dst) = dstIndex;
- goto argsDone;
- case TK_ARGV_FLOAT:
- if (argc == 0) {
- goto missingArg;
- } else {
- char *endPtr;
-
- *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_AppendResult(interp, "expected floating-point ",
- "argument for \"", infoPtr->key, "\" but got \"",
- argv[srcIndex], "\"", NULL);
- return TCL_ERROR;
- }
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_FUNC: {
- typedef int (ArgvFunc)(char *, char *, CONST char *);
- ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
-
- if ((*handlerProc)(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
- srcIndex++;
- argc--;
- }
- break;
- }
- case TK_ARGV_GENFUNC: {
- typedef int (ArgvGenFunc)(char *, Tcl_Interp *, char *, int,
- CONST char **);
- ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
-
- argc = (*handlerProc)(infoPtr->dst, interp, infoPtr->key,
- argc, argv+srcIndex);
- if (argc < 0) {
- return TCL_ERROR;
- }
- break;
- }
- case TK_ARGV_HELP:
- PrintUsage(interp, argTable, flags);
- return TCL_ERROR;
- case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
- TK_INTERACTIVE_PRIO);
- break;
- case TK_ARGV_OPTION_VALUE:
- if (argc < 1) {
- goto missingArg;
- }
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
- TK_INTERACTIVE_PRIO);
- srcIndex++;
- argc--;
- break;
- case TK_ARGV_OPTION_NAME_VALUE:
- if (argc < 2) {
- Tcl_AppendResult(interp, "\"", curArg,
- "\" option requires two following arguments", NULL);
- return TCL_ERROR;
- }
- Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
- TK_INTERACTIVE_PRIO);
- srcIndex += 2;
- argc -= 2;
- break;
- default: {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf, "bad argument type %d in Tk_ArgvInfo", infoPtr->type);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_ERROR;
- }
- }
- }
-
- /*
- * If we broke out of the loop because of an OPT_REST argument, copy the
- * remaining arguments down.
- */
-
- argsDone:
- while (argc) {
- argv[dstIndex] = argv[srcIndex];
- srcIndex++;
- dstIndex++;
- argc--;
- }
- argv[dstIndex] = NULL;
- *argcPtr = dstIndex;
- return TCL_OK;
-
- missingArg:
- Tcl_AppendResult(interp, "\"", curArg,
- "\" option requires an additional argument", NULL);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PrintUsage --
- *
- * Generate a help string describing command-line options.
- *
- * Results:
- * The interp's result will be modified to hold a help string describing
- * all the options in argTable, plus all those in the default table
- * unless TK_ARGV_NO_DEFAULTS is specified in flags.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-PrintUsage(
- Tcl_Interp *interp, /* Place information in this interp's result
- * area. */
- Tk_ArgvInfo *argTable, /* Array of command-specific argument
- * descriptions. */
- int flags) /* If the TK_ARGV_NO_DEFAULTS bit is set in
- * this word, then don't generate information
- * for default options. */
-{
- register Tk_ArgvInfo *infoPtr;
- int width, i, numSpaces;
-#define NUM_SPACES 20
- static char spaces[] = " ";
- char tmp[TCL_DOUBLE_SPACE];
-
- /*
- * First, compute the width of the widest option key, so that we can make
- * everything line up.
- */
-
- width = 4;
- for (i = 0; i < 2; i++) {
- for (infoPtr = i ? defaultTable : argTable;
- infoPtr->type != TK_ARGV_END; infoPtr++) {
- int length;
- if (infoPtr->key == NULL) {
- continue;
- }
- length = strlen(infoPtr->key);
- if (length > width) {
- width = length;
- }
- }
- }
-
- Tcl_AppendResult(interp, "Command-specific options:", NULL);
- for (i = 0; ; i++) {
- for (infoPtr = i ? defaultTable : argTable;
- infoPtr->type != TK_ARGV_END; infoPtr++) {
- if ((infoPtr->type == TK_ARGV_HELP) && (infoPtr->key == NULL)) {
- Tcl_AppendResult(interp, "\n", infoPtr->help, NULL);
- continue;
- }
- Tcl_AppendResult(interp, "\n ", infoPtr->key, ":", NULL);
- numSpaces = width + 1 - strlen(infoPtr->key);
- while (numSpaces > 0) {
- if (numSpaces >= NUM_SPACES) {
- Tcl_AppendResult(interp, spaces, NULL);
- } else {
- Tcl_AppendResult(interp, spaces+NUM_SPACES-numSpaces,NULL);
- }
- numSpaces -= NUM_SPACES;
- }
- Tcl_AppendResult(interp, infoPtr->help, NULL);
- switch (infoPtr->type) {
- case TK_ARGV_INT:
- sprintf(tmp, "%d", *((int *) infoPtr->dst));
- Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL);
- break;
- case TK_ARGV_FLOAT:
- sprintf(tmp, "%g", *((double *) infoPtr->dst));
- Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL);
- break;
- case TK_ARGV_STRING: {
- char *string = *((char **) infoPtr->dst);
-
- if (string != NULL) {
- Tcl_AppendResult(interp, "\n\t\tDefault value: \"", string,
- "\"", NULL);
- }
- break;
- }
- default:
- break;
- }
- }
-
- if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) {
- break;
- }
- Tcl_AppendResult(interp, "\nGeneric options for all commands:", NULL);
- }
-}
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
+/*
+ * tkArgv.c --
+ *
+ * This file contains a function that handles table-based argv-argc
+ * parsing.
+ *
+ * Copyright (c) 1990-1994 The Regents of the University of California.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkArgv.c,v 1.7 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#include "tkPort.h"
+#include "tk.h"
+
+/*
+ * Default table of argument descriptors. These are normally available in
+ * every application.
+ */
+
+static Tk_ArgvInfo defaultTable[] = {
+ {"-help", TK_ARGV_HELP, NULL, NULL,
+ "Print summary of command-line options and abort"},
+ {NULL, TK_ARGV_END, NULL, NULL, NULL}
+};
+
+/*
+ * Forward declarations for functions defined in this file:
+ */
+
+static void PrintUsage(Tcl_Interp *interp, Tk_ArgvInfo *argTable,
+ int flags);
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_ParseArgv --
+ *
+ * Process an argv array according to a table of expected command-line
+ * options. See the manual page for more details.
+ *
+ * Results:
+ * The return value is a standard Tcl return value. If an error occurs
+ * then an error message is left in the interp's result. Under normal
+ * conditions, both *argcPtr and *argv are modified to return the
+ * arguments that couldn't be processed here (they didn't match the
+ * option table, or followed an TK_ARGV_REST argument).
+ *
+ * Side effects:
+ * Variables may be modified, resources may be entered for tkwin, or
+ * functions may be called. It all depends on the arguments and their
+ * entries in argTable. See the user documentation for details.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+Tk_ParseArgv(
+ Tcl_Interp *interp, /* Place to store error message. */
+ Tk_Window tkwin, /* Window to use for setting Tk options. NULL
+ * means ignore Tk option specs. */
+ int *argcPtr, /* Number of arguments in argv. Modified to
+ * hold # args left in argv at end. */
+ CONST char **argv, /* Array of arguments. Modified to hold those
+ * that couldn't be processed here. */
+ Tk_ArgvInfo *argTable, /* Array of option descriptions */
+ int flags) /* Or'ed combination of various flag bits,
+ * such as TK_ARGV_NO_DEFAULTS. */
+{
+ register Tk_ArgvInfo *infoPtr;
+ /* Pointer to the current entry in the table
+ * of argument descriptions. */
+ Tk_ArgvInfo *matchPtr; /* Descriptor that matches current argument. */
+ CONST char *curArg; /* Current argument */
+ register char c; /* Second character of current arg (used for
+ * quick check for matching; use 2nd char.
+ * because first char. will almost always be
+ * '-'). */
+ int srcIndex; /* Location from which to read next argument
+ * from argv. */
+ int dstIndex; /* Index into argv to which next unused
+ * argument should be copied (never greater
+ * than srcIndex). */
+ int argc; /* # arguments in argv still to process. */
+ size_t length; /* Number of characters in current argument. */
+ int i;
+
+ if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) {
+ srcIndex = dstIndex = 0;
+ argc = *argcPtr;
+ } else {
+ srcIndex = dstIndex = 1;
+ argc = *argcPtr-1;
+ }
+
+ while (argc > 0) {
+ curArg = argv[srcIndex];
+ srcIndex++;
+ argc--;
+ length = strlen(curArg);
+ if (length > 0) {
+ c = curArg[1];
+ } else {
+ c = 0;
+ }
+
+ /*
+ * Loop throught the argument descriptors searching for one with the
+ * matching key string. If found, leave a pointer to it in matchPtr.
+ */
+
+ matchPtr = NULL;
+ for (i = 0; i < 2; i++) {
+ if (i == 0) {
+ infoPtr = argTable;
+ } else {
+ infoPtr = defaultTable;
+ }
+ for (; (infoPtr != NULL) && (infoPtr->type != TK_ARGV_END);
+ infoPtr++) {
+ if (infoPtr->key == NULL) {
+ continue;
+ }
+ if ((infoPtr->key[1] != c)
+ || (strncmp(infoPtr->key, curArg, length) != 0)) {
+ continue;
+ }
+ if ((tkwin == NULL)
+ && ((infoPtr->type == TK_ARGV_CONST_OPTION)
+ || (infoPtr->type == TK_ARGV_OPTION_VALUE)
+ || (infoPtr->type == TK_ARGV_OPTION_NAME_VALUE))) {
+ continue;
+ }
+ if (infoPtr->key[length] == 0) {
+ matchPtr = infoPtr;
+ goto gotMatch;
+ }
+ if (flags & TK_ARGV_NO_ABBREV) {
+ continue;
+ }
+ if (matchPtr != NULL) {
+ Tcl_AppendResult(interp, "ambiguous option \"", curArg,
+ "\"", NULL);
+ return TCL_ERROR;
+ }
+ matchPtr = infoPtr;
+ }
+ }
+ if (matchPtr == NULL) {
+ /*
+ * Unrecognized argument. Just copy it down, unless the caller
+ * prefers an error to be registered.
+ */
+
+ if (flags & TK_ARGV_NO_LEFTOVERS) {
+ Tcl_AppendResult(interp, "unrecognized argument \"",
+ curArg, "\"", NULL);
+ return TCL_ERROR;
+ }
+ argv[dstIndex] = curArg;
+ dstIndex++;
+ continue;
+ }
+
+ /*
+ * Take the appropriate action based on the option type
+ */
+
+ gotMatch:
+ infoPtr = matchPtr;
+ switch (infoPtr->type) {
+ case TK_ARGV_CONSTANT:
+ *((int *) infoPtr->dst) = (int) infoPtr->src;
+ break;
+ case TK_ARGV_INT:
+ if (argc == 0) {
+ goto missingArg;
+ } else {
+ char *endPtr;
+
+ *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0);
+ if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+ Tcl_AppendResult(interp,"expected integer argument for \"",
+ infoPtr->key, "\" but got \"", argv[srcIndex],
+ "\"", NULL);
+ return TCL_ERROR;
+ }
+ srcIndex++;
+ argc--;
+ }
+ break;
+ case TK_ARGV_STRING:
+ if (argc == 0) {
+ goto missingArg;
+ }
+ *((CONST char **)infoPtr->dst) = argv[srcIndex];
+ srcIndex++;
+ argc--;
+ break;
+ case TK_ARGV_UID:
+ if (argc == 0) {
+ goto missingArg;
+ }
+ *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]);
+ srcIndex++;
+ argc--;
+ break;
+ case TK_ARGV_REST:
+ *((int *) infoPtr->dst) = dstIndex;
+ goto argsDone;
+ case TK_ARGV_FLOAT:
+ if (argc == 0) {
+ goto missingArg;
+ } else {
+ char *endPtr;
+
+ *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr);
+ if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+ Tcl_AppendResult(interp, "expected floating-point ",
+ "argument for \"", infoPtr->key, "\" but got \"",
+ argv[srcIndex], "\"", NULL);
+ return TCL_ERROR;
+ }
+ srcIndex++;
+ argc--;
+ }
+ break;
+ case TK_ARGV_FUNC: {
+ typedef int (ArgvFunc)(char *, char *, CONST char *);
+ ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
+
+ if ((*handlerProc)(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
+ srcIndex++;
+ argc--;
+ }
+ break;
+ }
+ case TK_ARGV_GENFUNC: {
+ typedef int (ArgvGenFunc)(char *, Tcl_Interp *, char *, int,
+ CONST char **);
+ ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
+
+ argc = (*handlerProc)(infoPtr->dst, interp, infoPtr->key,
+ argc, argv+srcIndex);
+ if (argc < 0) {
+ return TCL_ERROR;
+ }
+ break;
+ }
+ case TK_ARGV_HELP:
+ PrintUsage(interp, argTable, flags);
+ return TCL_ERROR;
+ case TK_ARGV_CONST_OPTION:
+ Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
+ TK_INTERACTIVE_PRIO);
+ break;
+ case TK_ARGV_OPTION_VALUE:
+ if (argc < 1) {
+ goto missingArg;
+ }
+ Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
+ TK_INTERACTIVE_PRIO);
+ srcIndex++;
+ argc--;
+ break;
+ case TK_ARGV_OPTION_NAME_VALUE:
+ if (argc < 2) {
+ Tcl_AppendResult(interp, "\"", curArg,
+ "\" option requires two following arguments", NULL);
+ return TCL_ERROR;
+ }
+ Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
+ TK_INTERACTIVE_PRIO);
+ srcIndex += 2;
+ argc -= 2;
+ break;
+ default: {
+ char buf[64 + TCL_INTEGER_SPACE];
+
+ sprintf(buf, "bad argument type %d in Tk_ArgvInfo", infoPtr->type);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ return TCL_ERROR;
+ }
+ }
+ }
+
+ /*
+ * If we broke out of the loop because of an OPT_REST argument, copy the
+ * remaining arguments down.
+ */
+
+ argsDone:
+ while (argc) {
+ argv[dstIndex] = argv[srcIndex];
+ srcIndex++;
+ dstIndex++;
+ argc--;
+ }
+ argv[dstIndex] = NULL;
+ *argcPtr = dstIndex;
+ return TCL_OK;
+
+ missingArg:
+ Tcl_AppendResult(interp, "\"", curArg,
+ "\" option requires an additional argument", NULL);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * PrintUsage --
+ *
+ * Generate a help string describing command-line options.
+ *
+ * Results:
+ * The interp's result will be modified to hold a help string describing
+ * all the options in argTable, plus all those in the default table
+ * unless TK_ARGV_NO_DEFAULTS is specified in flags.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+PrintUsage(
+ Tcl_Interp *interp, /* Place information in this interp's result
+ * area. */
+ Tk_ArgvInfo *argTable, /* Array of command-specific argument
+ * descriptions. */
+ int flags) /* If the TK_ARGV_NO_DEFAULTS bit is set in
+ * this word, then don't generate information
+ * for default options. */
+{
+ register Tk_ArgvInfo *infoPtr;
+ int width, i, numSpaces;
+#define NUM_SPACES 20
+ static char spaces[] = " ";
+ char tmp[TCL_DOUBLE_SPACE];
+
+ /*
+ * First, compute the width of the widest option key, so that we can make
+ * everything line up.
+ */
+
+ width = 4;
+ for (i = 0; i < 2; i++) {
+ for (infoPtr = i ? defaultTable : argTable;
+ infoPtr->type != TK_ARGV_END; infoPtr++) {
+ int length;
+ if (infoPtr->key == NULL) {
+ continue;
+ }
+ length = strlen(infoPtr->key);
+ if (length > width) {
+ width = length;
+ }
+ }
+ }
+
+ Tcl_AppendResult(interp, "Command-specific options:", NULL);
+ for (i = 0; ; i++) {
+ for (infoPtr = i ? defaultTable : argTable;
+ infoPtr->type != TK_ARGV_END; infoPtr++) {
+ if ((infoPtr->type == TK_ARGV_HELP) && (infoPtr->key == NULL)) {
+ Tcl_AppendResult(interp, "\n", infoPtr->help, NULL);
+ continue;
+ }
+ Tcl_AppendResult(interp, "\n ", infoPtr->key, ":", NULL);
+ numSpaces = width + 1 - strlen(infoPtr->key);
+ while (numSpaces > 0) {
+ if (numSpaces >= NUM_SPACES) {
+ Tcl_AppendResult(interp, spaces, NULL);
+ } else {
+ Tcl_AppendResult(interp, spaces+NUM_SPACES-numSpaces,NULL);
+ }
+ numSpaces -= NUM_SPACES;
+ }
+ Tcl_AppendResult(interp, infoPtr->help, NULL);
+ switch (infoPtr->type) {
+ case TK_ARGV_INT:
+ sprintf(tmp, "%d", *((int *) infoPtr->dst));
+ Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL);
+ break;
+ case TK_ARGV_FLOAT:
+ sprintf(tmp, "%g", *((double *) infoPtr->dst));
+ Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL);
+ break;
+ case TK_ARGV_STRING: {
+ char *string = *((char **) infoPtr->dst);
+
+ if (string != NULL) {
+ Tcl_AppendResult(interp, "\n\t\tDefault value: \"", string,
+ "\"", NULL);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) {
+ break;
+ }
+ Tcl_AppendResult(interp, "\nGeneric options for all commands:", NULL);
+ }
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkButton.h b/generic/tkButton.h
index f753127..8df4df7 100644
--- a/generic/tkButton.h
+++ b/generic/tkButton.h
@@ -1,324 +1,324 @@
-/*
- * tkButton.h --
- *
- * Declarations of types and functions used to implement button-like
- * widgets.
- *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkButton.h,v 1.14 2007/06/24 16:07:34 dkf Exp $
- */
-
-#ifndef _TKBUTTON
-#define _TKBUTTON
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Legal values for the "compound" field of TkButton records.
- */
-
-enum compound {
- COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE,
- COMPOUND_RIGHT, COMPOUND_TOP
-};
-
-/*
- * Legal values for the "state" field of TkButton records.
- */
-
-enum state {
- STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
-};
-
-/*
- * Legal values for the "defaultState" field of TkButton records.
- */
-
-enum defaultState {
- DEFAULT_ACTIVE, DEFAULT_DISABLED, DEFAULT_NORMAL
-};
-
-/*
- * A data structure of the following type is kept for each widget managed by
- * this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the button. NULL means
- * that the window has been destroyed. */
- Display *display; /* Display containing widget. Needed to free
- * up resources after tkwin is gone. */
- Tcl_Interp *interp; /* Interpreter associated with button. */
- Tcl_Command widgetCmd; /* Token for button's widget command. */
- int type; /* Type of widget, such as TYPE_LABEL:
- * restricts operations that may be performed
- * on widget. See below for legal values. */
- Tk_OptionTable optionTable; /* Table that defines configuration options
- * available for this widget. */
-
- /*
- * Information about what's in the button.
- */
-
- Tcl_Obj *textPtr; /* Value of -text option: specifies text to
- * display in button. */
- int underline; /* Value of -underline option: specifies index
- * of character to underline. < 0 means don't
- * underline anything. */
- Tcl_Obj *textVarNamePtr; /* Value of -textvariable option: specifies
- * name of variable or NULL. If non-NULL,
- * button displays the contents of this
- * variable. */
- Pixmap bitmap; /* Value of -bitmap option. If not None,
- * specifies bitmap to display and text and
- * textVar are ignored. */
- Tcl_Obj *imagePtr; /* Value of -image option: specifies image to
- * display in window, or NULL if none. If
- * non-NULL, bitmap, text, and textVarName are
- * ignored.*/
- Tk_Image image; /* Derived from imagePtr by calling
- * Tk_GetImage, or NULL if imagePtr is
- * NULL. */
- Tcl_Obj *selectImagePtr; /* Value of -selectimage option: specifies
- * image to display in window when selected,
- * or NULL if none. Ignored if imagePtr is
- * NULL. */
- Tk_Image selectImage; /* Derived from selectImagePtr by calling
- * Tk_GetImage, or NULL if selectImagePtr is
- * NULL. */
- Tcl_Obj *tristateImagePtr; /* Value of -tristateimage option: specifies
- * image to display in window when selected,
- * or NULL if none. Ignored if imagePtr is
- * NULL. */
- Tk_Image tristateImage; /* Derived from tristateImagePtr by calling
- * Tk_GetImage, or NULL if tristateImagePtr is
- * NULL. */
-
- /*
- * Information used when displaying widget:
- */
-
- enum state state; /* Value of -state option: specifies state of
- * button for display purposes.*/
- Tk_3DBorder normalBorder; /* Value of -background option: specifies
- * color for background (and border) when
- * window isn't active. */
- Tk_3DBorder activeBorder; /* Value of -activebackground option: this is
- * the color used to draw 3-D border and
- * background when widget is active. */
- Tcl_Obj *borderWidthPtr; /* Value of -borderWidth option: specifies
- * width of border in pixels. */
- int borderWidth; /* Integer value corresponding to
- * borderWidthPtr. Always >= 0. */
- int relief; /* Value of -relief option: specifies 3-d
- * effect for border, such as
- * TK_RELIEF_RAISED. */
- int overRelief; /* Value of -overrelief option: specifies a
- * 3-d effect for the border, such as
- * TK_RELIEF_RAISED, to be used when the mouse
- * is over the button. */
- int offRelief; /* Value of -offrelief option: specifies a 3-d
- * effect for the border, such as
- * TK_RELIEF_RAISED, to be used when a
- * checkbutton or radiobutton without
- * indicator is off. */
- Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option:
- * specifies width in pixels of highlight to
- * draw around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- int highlightWidth; /* Integer value corresponding to
- * highlightWidthPtr. Always >= 0. */
- Tk_3DBorder highlightBorder;/* Value of -highlightbackground option:
- * specifies background with which to draw 3-D
- * default ring and focus highlight area when
- * highlight is off. */
- XColor *highlightColorPtr; /* Value of -highlightcolor option: specifies
- * color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must be
- * offset from outside edges to leave room for
- * borders. */
- Tk_Font tkfont; /* Value of -font option: specifies font to
- * use for display text. */
- XColor *normalFg; /* Value of -font option: specifies foreground
- * color in normal mode. */
- XColor *activeFg; /* Value of -activeforeground option:
- * foreground color in active mode. NULL means
- * use -foreground instead. */
- XColor *disabledFg; /* Value of -disabledforeground option:
- * foreground color when disabled. NULL means
- * use normalFg with a 50% stipple instead. */
- GC normalTextGC; /* GC for drawing text in normal mode. Also
- * used to copy from off-screen pixmap onto
- * screen. */
- GC activeTextGC; /* GC for drawing text in active mode (NULL
- * means use normalTextGC). */
- GC disabledGC; /* Used to produce disabled effect for text
- * and check/radio marks. */
- GC stippleGC; /* Used to produce disabled stipple effect for
- * images when disabled. */
- Pixmap gray; /* Pixmap for displaying disabled text if
- * disabledFg is NULL. */
- GC copyGC; /* Used for copying information from an
- * off-screen pixmap to the screen. */
- Tcl_Obj *widthPtr; /* Value of -width option. */
- int width; /* Integer value corresponding to widthPtr. */
- Tcl_Obj *heightPtr; /* Value of -height option. */
- int height; /* Integer value corresponding to heightPtr. */
- Tcl_Obj *wrapLengthPtr; /* Value of -wraplength option: specifies line
- * length (in pixels) at which to wrap onto
- * next line. <= 0 means don't wrap except at
- * newlines. */
- int wrapLength; /* Integer value corresponding to
- * wrapLengthPtr. */
- Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many
- * pixels of extra space to leave on left and
- * right of text. Ignored for bitmaps and
- * images. */
- int padX; /* Integer value corresponding to padXPtr. */
- Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many
- * pixels of extra space to leave above and
- * below text. Ignored for bitmaps and
- * images. */
- int padY; /* Integer value corresponding to padYPtr. */
- Tk_Anchor anchor; /* Value of -anchor option: specifies where
- * text/bitmap should be displayed inside
- * button region. */
- Tk_Justify justify; /* Value of -justify option: specifies how to
- * align lines of multi-line text. */
- int indicatorOn; /* Value of -indicatoron option: 1 means draw
- * indicator in checkbuttons and radiobuttons,
- * 0 means don't draw it. */
- Tk_3DBorder selectBorder; /* Value of -selectcolor option: specifies
- * color for drawing indicator background, or
- * perhaps widget background, when
- * selected. */
- int textWidth; /* Width needed to display text as requested,
- * in pixels. */
- int textHeight; /* Height needed to display text as requested,
- * in pixels. */
- Tk_TextLayout textLayout; /* Saved text layout information. */
- int indicatorSpace; /* Horizontal space (in pixels) allocated for
- * display of indicator. */
- int indicatorDiameter; /* Diameter of indicator, in pixels. */
- enum defaultState defaultState;
- /* Value of -default option, such as
- * DEFAULT_NORMAL: specifies state of default
- * ring for buttons (normal, active, or
- * disabled). NULL for other classes. */
-
- /*
- * For check and radio buttons, the fields below are used to manage the
- * variable indicating the button's state.
- */
-
- Tcl_Obj *selVarNamePtr; /* Value of -variable option: specifies name
- * of variable used to control selected state
- * of button. */
- Tcl_Obj *onValuePtr; /* Value of -offvalue option: specifies value
- * to store in variable when this button is
- * selected. */
- Tcl_Obj *offValuePtr; /* Value of -offvalue option: specifies value
- * to store in variable when this button isn't
- * selected. Used only by checkbuttons. */
- Tcl_Obj *tristateValuePtr; /* Value of -tristatevalue option: specifies
- * value to display Tristate or Multivalue
- * mode when variable matches this value.
- * Used by check- buttons. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Value of -cursor option: if not None,
- * specifies current cursor for window. */
- Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
- * C code, but used by keyboard traversal
- * scripts. */
- Tcl_Obj *commandPtr; /* Value of -command option: specifies script
- * to execute when button is invoked. If
- * widget is label or has no command, this is
- * NULL. */
- int compound; /* Value of -compound option; specifies
- * whether the button should show both an
- * image and text, and, if so, how. */
- int repeatDelay; /* Value of -repeatdelay option; specifies the
- * number of ms after which the button will
- * start to auto-repeat its command. */
- int repeatInterval; /* Value of -repeatinterval option; specifies
- * the number of ms between auto-repeat
- * invocataions of the button command. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkButton;
-
-/*
- * Possible "type" values for buttons. These are the kinds of widgets
- * supported by this file. The ordering of the type numbers is significant:
- * greater means more features and is used in the code.
- */
-
-#define TYPE_LABEL 0
-#define TYPE_BUTTON 1
-#define TYPE_CHECK_BUTTON 2
-#define TYPE_RADIO_BUTTON 3
-
-/*
- * Flag bits for buttons:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
- * already been queued to redraw this window.
- * SELECTED: Non-zero means this button is selected, so
- * special highlight should be drawn.
- * GOT_FOCUS: Non-zero means this button currently has the
- * input focus.
- * BUTTON_DELETED: Non-zero needs that this button has been
- * deleted, or is in the process of being deleted
- */
-
-#define REDRAW_PENDING (1 << 0)
-#define SELECTED (1 << 1)
-#define GOT_FOCUS (1 << 2)
-#define BUTTON_DELETED (1 << 3)
-#define TRISTATED (1 << 4)
-
-/*
- * Declaration of variables shared between the files in the button module.
- */
-
-MODULE_SCOPE Tk_ClassProcs tkpButtonProcs;
-
-/*
- * Declaration of functions used in the implementation of the button widget.
- */
-
-#ifndef TkpButtonSetDefaults
-MODULE_SCOPE void TkpButtonSetDefaults(Tk_OptionSpec *specPtr);
-#endif
-MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
-MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
-MODULE_SCOPE TkButton *TkpCreateButton(Tk_Window tkwin);
-#ifndef TkpDestroyButton
-MODULE_SCOPE void TkpDestroyButton(TkButton *butPtr);
-#endif
-#ifndef TkpDisplayButton
-MODULE_SCOPE void TkpDisplayButton(ClientData clientData);
-#endif
-MODULE_SCOPE int TkInvokeButton(TkButton *butPtr);
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKBUTTON */
+/*
+ * tkButton.h --
+ *
+ * Declarations of types and functions used to implement button-like
+ * widgets.
+ *
+ * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkButton.h,v 1.15 2007/06/25 19:09:44 dgp Exp $
+ */
+
+#ifndef _TKBUTTON
+#define _TKBUTTON
+
+#ifndef _TKINT
+#include "tkInt.h"
+#endif
+
+#ifdef BUILD_tk
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLEXPORT
+#endif
+
+/*
+ * Legal values for the "compound" field of TkButton records.
+ */
+
+enum compound {
+ COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE,
+ COMPOUND_RIGHT, COMPOUND_TOP
+};
+
+/*
+ * Legal values for the "state" field of TkButton records.
+ */
+
+enum state {
+ STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
+};
+
+/*
+ * Legal values for the "defaultState" field of TkButton records.
+ */
+
+enum defaultState {
+ DEFAULT_ACTIVE, DEFAULT_DISABLED, DEFAULT_NORMAL
+};
+
+/*
+ * A data structure of the following type is kept for each widget managed by
+ * this file:
+ */
+
+typedef struct {
+ Tk_Window tkwin; /* Window that embodies the button. NULL means
+ * that the window has been destroyed. */
+ Display *display; /* Display containing widget. Needed to free
+ * up resources after tkwin is gone. */
+ Tcl_Interp *interp; /* Interpreter associated with button. */
+ Tcl_Command widgetCmd; /* Token for button's widget command. */
+ int type; /* Type of widget, such as TYPE_LABEL:
+ * restricts operations that may be performed
+ * on widget. See below for legal values. */
+ Tk_OptionTable optionTable; /* Table that defines configuration options
+ * available for this widget. */
+
+ /*
+ * Information about what's in the button.
+ */
+
+ Tcl_Obj *textPtr; /* Value of -text option: specifies text to
+ * display in button. */
+ int underline; /* Value of -underline option: specifies index
+ * of character to underline. < 0 means don't
+ * underline anything. */
+ Tcl_Obj *textVarNamePtr; /* Value of -textvariable option: specifies
+ * name of variable or NULL. If non-NULL,
+ * button displays the contents of this
+ * variable. */
+ Pixmap bitmap; /* Value of -bitmap option. If not None,
+ * specifies bitmap to display and text and
+ * textVar are ignored. */
+ Tcl_Obj *imagePtr; /* Value of -image option: specifies image to
+ * display in window, or NULL if none. If
+ * non-NULL, bitmap, text, and textVarName are
+ * ignored.*/
+ Tk_Image image; /* Derived from imagePtr by calling
+ * Tk_GetImage, or NULL if imagePtr is
+ * NULL. */
+ Tcl_Obj *selectImagePtr; /* Value of -selectimage option: specifies
+ * image to display in window when selected,
+ * or NULL if none. Ignored if imagePtr is
+ * NULL. */
+ Tk_Image selectImage; /* Derived from selectImagePtr by calling
+ * Tk_GetImage, or NULL if selectImagePtr is
+ * NULL. */
+ Tcl_Obj *tristateImagePtr; /* Value of -tristateimage option: specifies
+ * image to display in window when selected,
+ * or NULL if none. Ignored if imagePtr is
+ * NULL. */
+ Tk_Image tristateImage; /* Derived from tristateImagePtr by calling
+ * Tk_GetImage, or NULL if tristateImagePtr is
+ * NULL. */
+
+ /*
+ * Information used when displaying widget:
+ */
+
+ enum state state; /* Value of -state option: specifies state of
+ * button for display purposes.*/
+ Tk_3DBorder normalBorder; /* Value of -background option: specifies
+ * color for background (and border) when
+ * window isn't active. */
+ Tk_3DBorder activeBorder; /* Value of -activebackground option: this is
+ * the color used to draw 3-D border and
+ * background when widget is active. */
+ Tcl_Obj *borderWidthPtr; /* Value of -borderWidth option: specifies
+ * width of border in pixels. */
+ int borderWidth; /* Integer value corresponding to
+ * borderWidthPtr. Always >= 0. */
+ int relief; /* Value of -relief option: specifies 3-d
+ * effect for border, such as
+ * TK_RELIEF_RAISED. */
+ int overRelief; /* Value of -overrelief option: specifies a
+ * 3-d effect for the border, such as
+ * TK_RELIEF_RAISED, to be used when the mouse
+ * is over the button. */
+ int offRelief; /* Value of -offrelief option: specifies a 3-d
+ * effect for the border, such as
+ * TK_RELIEF_RAISED, to be used when a
+ * checkbutton or radiobutton without
+ * indicator is off. */
+ Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option:
+ * specifies width in pixels of highlight to
+ * draw around widget when it has the focus.
+ * <= 0 means don't draw a highlight. */
+ int highlightWidth; /* Integer value corresponding to
+ * highlightWidthPtr. Always >= 0. */
+ Tk_3DBorder highlightBorder;/* Value of -highlightbackground option:
+ * specifies background with which to draw 3-D
+ * default ring and focus highlight area when
+ * highlight is off. */
+ XColor *highlightColorPtr; /* Value of -highlightcolor option: specifies
+ * color for drawing traversal highlight. */
+ int inset; /* Total width of all borders, including
+ * traversal highlight and 3-D border.
+ * Indicates how much interior stuff must be
+ * offset from outside edges to leave room for
+ * borders. */
+ Tk_Font tkfont; /* Value of -font option: specifies font to
+ * use for display text. */
+ XColor *normalFg; /* Value of -font option: specifies foreground
+ * color in normal mode. */
+ XColor *activeFg; /* Value of -activeforeground option:
+ * foreground color in active mode. NULL means
+ * use -foreground instead. */
+ XColor *disabledFg; /* Value of -disabledforeground option:
+ * foreground color when disabled. NULL means
+ * use normalFg with a 50% stipple instead. */
+ GC normalTextGC; /* GC for drawing text in normal mode. Also
+ * used to copy from off-screen pixmap onto
+ * screen. */
+ GC activeTextGC; /* GC for drawing text in active mode (NULL
+ * means use normalTextGC). */
+ GC disabledGC; /* Used to produce disabled effect for text
+ * and check/radio marks. */
+ GC stippleGC; /* Used to produce disabled stipple effect for
+ * images when disabled. */
+ Pixmap gray; /* Pixmap for displaying disabled text if
+ * disabledFg is NULL. */
+ GC copyGC; /* Used for copying information from an
+ * off-screen pixmap to the screen. */
+ Tcl_Obj *widthPtr; /* Value of -width option. */
+ int width; /* Integer value corresponding to widthPtr. */
+ Tcl_Obj *heightPtr; /* Value of -height option. */
+ int height; /* Integer value corresponding to heightPtr. */
+ Tcl_Obj *wrapLengthPtr; /* Value of -wraplength option: specifies line
+ * length (in pixels) at which to wrap onto
+ * next line. <= 0 means don't wrap except at
+ * newlines. */
+ int wrapLength; /* Integer value corresponding to
+ * wrapLengthPtr. */
+ Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many
+ * pixels of extra space to leave on left and
+ * right of text. Ignored for bitmaps and
+ * images. */
+ int padX; /* Integer value corresponding to padXPtr. */
+ Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many
+ * pixels of extra space to leave above and
+ * below text. Ignored for bitmaps and
+ * images. */
+ int padY; /* Integer value corresponding to padYPtr. */
+ Tk_Anchor anchor; /* Value of -anchor option: specifies where
+ * text/bitmap should be displayed inside
+ * button region. */
+ Tk_Justify justify; /* Value of -justify option: specifies how to
+ * align lines of multi-line text. */
+ int indicatorOn; /* Value of -indicatoron option: 1 means draw
+ * indicator in checkbuttons and radiobuttons,
+ * 0 means don't draw it. */
+ Tk_3DBorder selectBorder; /* Value of -selectcolor option: specifies
+ * color for drawing indicator background, or
+ * perhaps widget background, when
+ * selected. */
+ int textWidth; /* Width needed to display text as requested,
+ * in pixels. */
+ int textHeight; /* Height needed to display text as requested,
+ * in pixels. */
+ Tk_TextLayout textLayout; /* Saved text layout information. */
+ int indicatorSpace; /* Horizontal space (in pixels) allocated for
+ * display of indicator. */
+ int indicatorDiameter; /* Diameter of indicator, in pixels. */
+ enum defaultState defaultState;
+ /* Value of -default option, such as
+ * DEFAULT_NORMAL: specifies state of default
+ * ring for buttons (normal, active, or
+ * disabled). NULL for other classes. */
+
+ /*
+ * For check and radio buttons, the fields below are used to manage the
+ * variable indicating the button's state.
+ */
+
+ Tcl_Obj *selVarNamePtr; /* Value of -variable option: specifies name
+ * of variable used to control selected state
+ * of button. */
+ Tcl_Obj *onValuePtr; /* Value of -offvalue option: specifies value
+ * to store in variable when this button is
+ * selected. */
+ Tcl_Obj *offValuePtr; /* Value of -offvalue option: specifies value
+ * to store in variable when this button isn't
+ * selected. Used only by checkbuttons. */
+ Tcl_Obj *tristateValuePtr; /* Value of -tristatevalue option: specifies
+ * value to display Tristate or Multivalue
+ * mode when variable matches this value.
+ * Used by check- buttons. */
+
+ /*
+ * Miscellaneous information:
+ */
+
+ Tk_Cursor cursor; /* Value of -cursor option: if not None,
+ * specifies current cursor for window. */
+ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
+ * C code, but used by keyboard traversal
+ * scripts. */
+ Tcl_Obj *commandPtr; /* Value of -command option: specifies script
+ * to execute when button is invoked. If
+ * widget is label or has no command, this is
+ * NULL. */
+ int compound; /* Value of -compound option; specifies
+ * whether the button should show both an
+ * image and text, and, if so, how. */
+ int repeatDelay; /* Value of -repeatdelay option; specifies the
+ * number of ms after which the button will
+ * start to auto-repeat its command. */
+ int repeatInterval; /* Value of -repeatinterval option; specifies
+ * the number of ms between auto-repeat
+ * invocataions of the button command. */
+ int flags; /* Various flags; see below for
+ * definitions. */
+} TkButton;
+
+/*
+ * Possible "type" values for buttons. These are the kinds of widgets
+ * supported by this file. The ordering of the type numbers is significant:
+ * greater means more features and is used in the code.
+ */
+
+#define TYPE_LABEL 0
+#define TYPE_BUTTON 1
+#define TYPE_CHECK_BUTTON 2
+#define TYPE_RADIO_BUTTON 3
+
+/*
+ * Flag bits for buttons:
+ *
+ * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
+ * already been queued to redraw this window.
+ * SELECTED: Non-zero means this button is selected, so
+ * special highlight should be drawn.
+ * GOT_FOCUS: Non-zero means this button currently has the
+ * input focus.
+ * BUTTON_DELETED: Non-zero needs that this button has been
+ * deleted, or is in the process of being deleted
+ */
+
+#define REDRAW_PENDING (1 << 0)
+#define SELECTED (1 << 1)
+#define GOT_FOCUS (1 << 2)
+#define BUTTON_DELETED (1 << 3)
+#define TRISTATED (1 << 4)
+
+/*
+ * Declaration of variables shared between the files in the button module.
+ */
+
+MODULE_SCOPE Tk_ClassProcs tkpButtonProcs;
+
+/*
+ * Declaration of functions used in the implementation of the button widget.
+ */
+
+#ifndef TkpButtonSetDefaults
+MODULE_SCOPE void TkpButtonSetDefaults(Tk_OptionSpec *specPtr);
+#endif
+MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
+MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
+MODULE_SCOPE TkButton *TkpCreateButton(Tk_Window tkwin);
+#ifndef TkpDestroyButton
+MODULE_SCOPE void TkpDestroyButton(TkButton *butPtr);
+#endif
+#ifndef TkpDisplayButton
+MODULE_SCOPE void TkpDisplayButton(ClientData clientData);
+#endif
+MODULE_SCOPE int TkInvokeButton(TkButton *butPtr);
+
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+
+#endif /* _TKBUTTON */
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
index cdda4d4..d454317 100644
--- a/generic/tkCanvas.h
+++ b/generic/tkCanvas.h
@@ -1,308 +1,308 @@
-/*
- * tkCanvas.h --
- *
- * Declarations shared among all the files that implement canvas widgets.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkCanvas.h,v 1.11 2007/06/24 16:09:25 dkf Exp $
- */
-
-#ifndef _TKCANVAS
-#define _TKCANVAS
-
-#ifndef _TK
-#include "tk.h"
-#endif
-
-#ifndef USE_OLD_TAG_SEARCH
-typedef struct TagSearchExpr_s TagSearchExpr;
-
-struct TagSearchExpr_s {
- TagSearchExpr *next; /* For linked lists of expressions - used in
- * bindings. */
- Tk_Uid uid; /* The uid of the whole expression. */
- Tk_Uid *uids; /* Expresion compiled to an array of uids. */
- int allocated; /* Available space for array of uids. */
- int length; /* Length of expression. */
- int index; /* Current position in expression
- * evaluation. */
- int match; /* This expression matches event's item's
- * tags. */
-};
-#endif /* not USE_OLD_TAG_SEARCH */
-
-/*
- * The record below describes a canvas widget. It is made available to the
- * item functions so they can access certain shared fields such as the overall
- * displacement and scale factor for the canvas.
- */
-
-typedef struct TkCanvas {
- Tk_Window tkwin; /* Window that embodies the canvas. NULL means
- * that the window has been destroyed but the
- * data structures haven't yet been cleaned
- * up.*/
- Display *display; /* Display containing widget; needed, among
- * other things, to release resources after
- * tkwin has already gone away. */
- Tcl_Interp *interp; /* Interpreter associated with canvas. */
- Tcl_Command widgetCmd; /* Token for canvas's widget command. */
- Tk_Item *firstItemPtr; /* First in list of all items in canvas, or
- * NULL if canvas empty. */
- Tk_Item *lastItemPtr; /* Last in list of all items in canvas, or
- * NULL if canvas empty. */
-
- /*
- * Information used when displaying widget:
- */
-
- int borderWidth; /* Width of 3-D border around window. */
- Tk_3DBorder bgBorder; /* Used for canvas background. */
- int relief; /* Indicates whether window as a whole is
- * raised, sunken, or flat. */
- int highlightWidth; /* Width in pixels of highlight to draw around
- * widget when it has the focus. <= 0 means
- * don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight area
- * when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must be
- * offset from outside edges to leave room for
- * borders. */
- GC pixmapGC; /* Used to copy bits from a pixmap to the
- * screen and also to clear the pixmap. */
- int width, height; /* Dimensions to request for canvas window,
- * specified in pixels. */
- int redrawX1, redrawY1; /* Upper left corner of area to redraw, in
- * pixel coordinates. Border pixels are
- * included. Only valid if REDRAW_PENDING flag
- * is set. */
- int redrawX2, redrawY2; /* Lower right corner of area to redraw, in
- * integer canvas coordinates. Border pixels
- * will *not* be redrawn. */
- int confine; /* Non-zero means constrain view to keep as
- * much of canvas visible as possible. */
-
- /*
- * Information used to manage the selection and insertion cursor:
- */
-
- Tk_CanvasTextInfo textInfo; /* Contains lots of fields; see tk.h for
- * details. This structure is shared with the
- * code that implements individual items. */
- int insertOnTime; /* Number of milliseconds cursor should spend
- * in "on" state for each blink. */
- int insertOffTime; /* Number of milliseconds cursor should spend
- * in "off" state for each blink. */
- Tcl_TimerToken insertBlinkHandler;
- /* Timer handler used to blink cursor on and
- * off. */
-
- /*
- * Transformation applied to canvas as a whole: to compute screen
- * coordinates (X,Y) from canvas coordinates (x,y), do the following:
- *
- * X = x - xOrigin;
- * Y = y - yOrigin;
- */
-
- int xOrigin, yOrigin; /* Canvas coordinates corresponding to
- * upper-left corner of window, given in
- * canvas pixel units. */
- int drawableXOrigin, drawableYOrigin;
- /* During redisplay, these fields give the
- * canvas coordinates corresponding to the
- * upper-left corner of the drawable where
- * items are actually being drawn (typically a
- * pixmap smaller than the whole window). */
-
- /*
- * Information used for event bindings associated with items.
- */
-
- Tk_BindingTable bindingTable;
- /* Table of all bindings currently defined for
- * this canvas. NULL means that no bindings
- * exist, so the table hasn't been created.
- * Each "object" used for this table is either
- * a Tk_Uid for a tag or the address of an
- * item named by id. */
- Tk_Item *currentItemPtr; /* The item currently containing the mouse
- * pointer, or NULL if none. */
- Tk_Item *newCurrentPtr; /* The item that is about to become the
- * current one, or NULL. This field is used to
- * detect deletions of the new current item
- * pointer that occur during Leave processing
- * of the previous current item. */
- double closeEnough; /* The mouse is assumed to be inside an item
- * if it is this close to it. */
- XEvent pickEvent; /* The event upon which the current choice of
- * currentItem is based. Must be saved so that
- * if the currentItem is deleted, can pick
- * another. */
- int state; /* Last known modifier state. Used to defer
- * picking a new current object while buttons
- * are down. */
-
- /*
- * Information used for managing scrollbars:
- */
-
- char *xScrollCmd; /* Command prefix for communicating with
- * horizontal scrollbar. NULL means no
- * horizontal scrollbar. Malloc'ed. */
- char *yScrollCmd; /* Command prefix for communicating with
- * vertical scrollbar. NULL means no vertical
- * scrollbar. Malloc'ed. */
- int scrollX1, scrollY1, scrollX2, scrollY2;
- /* These four coordinates define the region
- * that is the 100% area for scrolling (i.e.
- * these numbers determine the size and
- * location of the sliders on scrollbars).
- * Units are pixels in canvas coords. */
- char *regionString; /* The option string from which scrollX1 etc.
- * are derived. Malloc'ed. */
- int xScrollIncrement; /* If >0, defines a grid for horizontal
- * scrolling. This is the size of the "unit",
- * and the left edge of the screen will always
- * lie on an even unit boundary. */
- int yScrollIncrement; /* If >0, defines a grid for horizontal
- * scrolling. This is the size of the "unit",
- * and the left edge of the screen will always
- * lie on an even unit boundary. */
-
- /*
- * Information used for scanning:
- */
-
- int scanX; /* X-position at which scan started (e.g.
- * button was pressed here). */
- int scanXOrigin; /* Value of xOrigin field when scan started. */
- int scanY; /* Y-position at which scan started (e.g.
- * button was pressed here). */
- int scanYOrigin; /* Value of yOrigin field when scan started. */
-
- /*
- * Information used to speed up searches by remembering the last item
- * created or found with an item id search.
- */
-
- Tk_Item *hotPtr; /* Pointer to "hot" item (one that's been
- * recently used. NULL means there's no hot
- * item. */
- Tk_Item *hotPrevPtr; /* Pointer to predecessor to hotPtr (NULL
- * means item is first in list). This is only
- * a hint and may not really be hotPtr's
- * predecessor. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in the
- * C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- double pixelsPerMM; /* Scale factor between MM and pixels; used
- * when converting coordinates. */
- int flags; /* Various flags; see below for
- * definitions. */
- int nextId; /* Number to use as id for next item created
- * in widget. */
- Tk_PostscriptInfo psInfo; /* Pointer to information used for generating
- * Postscript for the canvas. NULL means no
- * Postscript is currently being generated. */
- Tcl_HashTable idTable; /* Table of integer indices. */
-
- /*
- * Additional information, added by the 'dash'-patch
- */
-
- void *reserved1;
- Tk_State canvas_state; /* State of canvas. */
- void *reserved2;
- void *reserved3;
- Tk_TSOffset tsoffset;
-#ifndef USE_OLD_TAG_SEARCH
- TagSearchExpr *bindTagExprs;/* Linked list of tag expressions used in
- * bindings. */
-#endif
-} TkCanvas;
-
-/*
- * Flag bits for canvases:
- *
- * REDRAW_PENDING - 1 means a DoWhenIdle handler has already been
- * created to redraw some or all of the canvas.
- * REDRAW_BORDERS - 1 means that the borders need to be redrawn
- * during the next redisplay operation.
- * REPICK_NEEDED - 1 means DisplayCanvas should pick a new
- * current item before redrawing the canvas.
- * GOT_FOCUS - 1 means the focus is currently in this widget,
- * so should draw the insertion cursor and
- * traversal highlight.
- * CURSOR_ON - 1 means the insertion cursor is in the "on"
- * phase of its blink cycle. 0 means either we
- * don't have the focus or the cursor is in the
- * "off" phase of its cycle.
- * UPDATE_SCROLLBARS - 1 means the scrollbars should get updated as
- * part of the next display operation.
- * LEFT_GRABBED_ITEM - 1 means that the mouse left the current item
- * while a grab was in effect, so we didn't
- * change canvasPtr->currentItemPtr.
- * REPICK_IN_PROGRESS - 1 means PickCurrentItem is currently
- * executing. If it should be called recursively,
- * it should simply return immediately.
- * BBOX_NOT_EMPTY - 1 means that the bounding box of the area that
- * should be redrawn is not empty.
- */
-
-#define REDRAW_PENDING 1
-#define REDRAW_BORDERS 2
-#define REPICK_NEEDED 4
-#define GOT_FOCUS 8
-#define CURSOR_ON 0x10
-#define UPDATE_SCROLLBARS 0x20
-#define LEFT_GRABBED_ITEM 0x40
-#define REPICK_IN_PROGRESS 0x100
-#define BBOX_NOT_EMPTY 0x200
-
-/*
- * Flag bits for canvas items (redraw_flags):
- *
- * FORCE_REDRAW - 1 means that the new coordinates of some item
- * are not yet registered using
- * Tk_CanvasEventuallyRedraw(). It should still
- * be done by the general canvas code.
- */
-
-#define FORCE_REDRAW 8
-
-/*
- * Canvas-related functions that are shared among Tk modules but not exported
- * to the outside world:
- */
-
-MODULE_SCOPE int TkCanvPostscriptCmd(TkCanvas *canvasPtr,
- Tcl_Interp *interp, int argc, CONST char **argv);
-MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr,
- int numVertex, double *coordPtr, int closed,
- XPoint *outPtr);
-/*
- * Standard item types provided by Tk:
- */
-
-MODULE_SCOPE Tk_ItemType tkArcType, tkBitmapType, tkImageType, tkLineType;
-MODULE_SCOPE Tk_ItemType tkOvalType, tkPolygonType;
-MODULE_SCOPE Tk_ItemType tkRectangleType, tkTextType, tkWindowType;
-
-#endif /* _TKCANVAS */
+/*
+ * tkCanvas.h --
+ *
+ * Declarations shared among all the files that implement canvas widgets.
+ *
+ * Copyright (c) 1991-1994 The Regents of the University of California.
+ * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright (c) 1998 by Scriptics Corporation.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkCanvas.h,v 1.12 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#ifndef _TKCANVAS
+#define _TKCANVAS
+
+#ifndef _TK
+#include "tk.h"
+#endif
+
+#ifndef USE_OLD_TAG_SEARCH
+typedef struct TagSearchExpr_s TagSearchExpr;
+
+struct TagSearchExpr_s {
+ TagSearchExpr *next; /* For linked lists of expressions - used in
+ * bindings. */
+ Tk_Uid uid; /* The uid of the whole expression. */
+ Tk_Uid *uids; /* Expresion compiled to an array of uids. */
+ int allocated; /* Available space for array of uids. */
+ int length; /* Length of expression. */
+ int index; /* Current position in expression
+ * evaluation. */
+ int match; /* This expression matches event's item's
+ * tags. */
+};
+#endif /* not USE_OLD_TAG_SEARCH */
+
+/*
+ * The record below describes a canvas widget. It is made available to the
+ * item functions so they can access certain shared fields such as the overall
+ * displacement and scale factor for the canvas.
+ */
+
+typedef struct TkCanvas {
+ Tk_Window tkwin; /* Window that embodies the canvas. NULL means
+ * that the window has been destroyed but the
+ * data structures haven't yet been cleaned
+ * up.*/
+ Display *display; /* Display containing widget; needed, among
+ * other things, to release resources after
+ * tkwin has already gone away. */
+ Tcl_Interp *interp; /* Interpreter associated with canvas. */
+ Tcl_Command widgetCmd; /* Token for canvas's widget command. */
+ Tk_Item *firstItemPtr; /* First in list of all items in canvas, or
+ * NULL if canvas empty. */
+ Tk_Item *lastItemPtr; /* Last in list of all items in canvas, or
+ * NULL if canvas empty. */
+
+ /*
+ * Information used when displaying widget:
+ */
+
+ int borderWidth; /* Width of 3-D border around window. */
+ Tk_3DBorder bgBorder; /* Used for canvas background. */
+ int relief; /* Indicates whether window as a whole is
+ * raised, sunken, or flat. */
+ int highlightWidth; /* Width in pixels of highlight to draw around
+ * widget when it has the focus. <= 0 means
+ * don't draw a highlight. */
+ XColor *highlightBgColorPtr;
+ /* Color for drawing traversal highlight area
+ * when highlight is off. */
+ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
+ int inset; /* Total width of all borders, including
+ * traversal highlight and 3-D border.
+ * Indicates how much interior stuff must be
+ * offset from outside edges to leave room for
+ * borders. */
+ GC pixmapGC; /* Used to copy bits from a pixmap to the
+ * screen and also to clear the pixmap. */
+ int width, height; /* Dimensions to request for canvas window,
+ * specified in pixels. */
+ int redrawX1, redrawY1; /* Upper left corner of area to redraw, in
+ * pixel coordinates. Border pixels are
+ * included. Only valid if REDRAW_PENDING flag
+ * is set. */
+ int redrawX2, redrawY2; /* Lower right corner of area to redraw, in
+ * integer canvas coordinates. Border pixels
+ * will *not* be redrawn. */
+ int confine; /* Non-zero means constrain view to keep as
+ * much of canvas visible as possible. */
+
+ /*
+ * Information used to manage the selection and insertion cursor:
+ */
+
+ Tk_CanvasTextInfo textInfo; /* Contains lots of fields; see tk.h for
+ * details. This structure is shared with the
+ * code that implements individual items. */
+ int insertOnTime; /* Number of milliseconds cursor should spend
+ * in "on" state for each blink. */
+ int insertOffTime; /* Number of milliseconds cursor should spend
+ * in "off" state for each blink. */
+ Tcl_TimerToken insertBlinkHandler;
+ /* Timer handler used to blink cursor on and
+ * off. */
+
+ /*
+ * Transformation applied to canvas as a whole: to compute screen
+ * coordinates (X,Y) from canvas coordinates (x,y), do the following:
+ *
+ * X = x - xOrigin;
+ * Y = y - yOrigin;
+ */
+
+ int xOrigin, yOrigin; /* Canvas coordinates corresponding to
+ * upper-left corner of window, given in
+ * canvas pixel units. */
+ int drawableXOrigin, drawableYOrigin;
+ /* During redisplay, these fields give the
+ * canvas coordinates corresponding to the
+ * upper-left corner of the drawable where
+ * items are actually being drawn (typically a
+ * pixmap smaller than the whole window). */
+
+ /*
+ * Information used for event bindings associated with items.
+ */
+
+ Tk_BindingTable bindingTable;
+ /* Table of all bindings currently defined for
+ * this canvas. NULL means that no bindings
+ * exist, so the table hasn't been created.
+ * Each "object" used for this table is either
+ * a Tk_Uid for a tag or the address of an
+ * item named by id. */
+ Tk_Item *currentItemPtr; /* The item currently containing the mouse
+ * pointer, or NULL if none. */
+ Tk_Item *newCurrentPtr; /* The item that is about to become the
+ * current one, or NULL. This field is used to
+ * detect deletions of the new current item
+ * pointer that occur during Leave processing
+ * of the previous current item. */
+ double closeEnough; /* The mouse is assumed to be inside an item
+ * if it is this close to it. */
+ XEvent pickEvent; /* The event upon which the current choice of
+ * currentItem is based. Must be saved so that
+ * if the currentItem is deleted, can pick
+ * another. */
+ int state; /* Last known modifier state. Used to defer
+ * picking a new current object while buttons
+ * are down. */
+
+ /*
+ * Information used for managing scrollbars:
+ */
+
+ char *xScrollCmd; /* Command prefix for communicating with
+ * horizontal scrollbar. NULL means no
+ * horizontal scrollbar. Malloc'ed. */
+ char *yScrollCmd; /* Command prefix for communicating with
+ * vertical scrollbar. NULL means no vertical
+ * scrollbar. Malloc'ed. */
+ int scrollX1, scrollY1, scrollX2, scrollY2;
+ /* These four coordinates define the region
+ * that is the 100% area for scrolling (i.e.
+ * these numbers determine the size and
+ * location of the sliders on scrollbars).
+ * Units are pixels in canvas coords. */
+ char *regionString; /* The option string from which scrollX1 etc.
+ * are derived. Malloc'ed. */
+ int xScrollIncrement; /* If >0, defines a grid for horizontal
+ * scrolling. This is the size of the "unit",
+ * and the left edge of the screen will always
+ * lie on an even unit boundary. */
+ int yScrollIncrement; /* If >0, defines a grid for horizontal
+ * scrolling. This is the size of the "unit",
+ * and the left edge of the screen will always
+ * lie on an even unit boundary. */
+
+ /*
+ * Information used for scanning:
+ */
+
+ int scanX; /* X-position at which scan started (e.g.
+ * button was pressed here). */
+ int scanXOrigin; /* Value of xOrigin field when scan started. */
+ int scanY; /* Y-position at which scan started (e.g.
+ * button was pressed here). */
+ int scanYOrigin; /* Value of yOrigin field when scan started. */
+
+ /*
+ * Information used to speed up searches by remembering the last item
+ * created or found with an item id search.
+ */
+
+ Tk_Item *hotPtr; /* Pointer to "hot" item (one that's been
+ * recently used. NULL means there's no hot
+ * item. */
+ Tk_Item *hotPrevPtr; /* Pointer to predecessor to hotPtr (NULL
+ * means item is first in list). This is only
+ * a hint and may not really be hotPtr's
+ * predecessor. */
+
+ /*
+ * Miscellaneous information:
+ */
+
+ Tk_Cursor cursor; /* Current cursor for window, or None. */
+ char *takeFocus; /* Value of -takefocus option; not used in the
+ * C code, but used by keyboard traversal
+ * scripts. Malloc'ed, but may be NULL. */
+ double pixelsPerMM; /* Scale factor between MM and pixels; used
+ * when converting coordinates. */
+ int flags; /* Various flags; see below for
+ * definitions. */
+ int nextId; /* Number to use as id for next item created
+ * in widget. */
+ Tk_PostscriptInfo psInfo; /* Pointer to information used for generating
+ * Postscript for the canvas. NULL means no
+ * Postscript is currently being generated. */
+ Tcl_HashTable idTable; /* Table of integer indices. */
+
+ /*
+ * Additional information, added by the 'dash'-patch
+ */
+
+ void *reserved1;
+ Tk_State canvas_state; /* State of canvas. */
+ void *reserved2;
+ void *reserved3;
+ Tk_TSOffset tsoffset;
+#ifndef USE_OLD_TAG_SEARCH
+ TagSearchExpr *bindTagExprs;/* Linked list of tag expressions used in
+ * bindings. */
+#endif
+} TkCanvas;
+
+/*
+ * Flag bits for canvases:
+ *
+ * REDRAW_PENDING - 1 means a DoWhenIdle handler has already been
+ * created to redraw some or all of the canvas.
+ * REDRAW_BORDERS - 1 means that the borders need to be redrawn
+ * during the next redisplay operation.
+ * REPICK_NEEDED - 1 means DisplayCanvas should pick a new
+ * current item before redrawing the canvas.
+ * GOT_FOCUS - 1 means the focus is currently in this widget,
+ * so should draw the insertion cursor and
+ * traversal highlight.
+ * CURSOR_ON - 1 means the insertion cursor is in the "on"
+ * phase of its blink cycle. 0 means either we
+ * don't have the focus or the cursor is in the
+ * "off" phase of its cycle.
+ * UPDATE_SCROLLBARS - 1 means the scrollbars should get updated as
+ * part of the next display operation.
+ * LEFT_GRABBED_ITEM - 1 means that the mouse left the current item
+ * while a grab was in effect, so we didn't
+ * change canvasPtr->currentItemPtr.
+ * REPICK_IN_PROGRESS - 1 means PickCurrentItem is currently
+ * executing. If it should be called recursively,
+ * it should simply return immediately.
+ * BBOX_NOT_EMPTY - 1 means that the bounding box of the area that
+ * should be redrawn is not empty.
+ */
+
+#define REDRAW_PENDING 1
+#define REDRAW_BORDERS 2
+#define REPICK_NEEDED 4
+#define GOT_FOCUS 8
+#define CURSOR_ON 0x10
+#define UPDATE_SCROLLBARS 0x20
+#define LEFT_GRABBED_ITEM 0x40
+#define REPICK_IN_PROGRESS 0x100
+#define BBOX_NOT_EMPTY 0x200
+
+/*
+ * Flag bits for canvas items (redraw_flags):
+ *
+ * FORCE_REDRAW - 1 means that the new coordinates of some item
+ * are not yet registered using
+ * Tk_CanvasEventuallyRedraw(). It should still
+ * be done by the general canvas code.
+ */
+
+#define FORCE_REDRAW 8
+
+/*
+ * Canvas-related functions that are shared among Tk modules but not exported
+ * to the outside world:
+ */
+
+MODULE_SCOPE int TkCanvPostscriptCmd(TkCanvas *canvasPtr,
+ Tcl_Interp *interp, int argc, CONST char **argv);
+MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr,
+ int numVertex, double *coordPtr, int closed,
+ XPoint *outPtr);
+/*
+ * Standard item types provided by Tk:
+ */
+
+MODULE_SCOPE Tk_ItemType tkArcType, tkBitmapType, tkImageType, tkLineType;
+MODULE_SCOPE Tk_ItemType tkOvalType, tkPolygonType;
+MODULE_SCOPE Tk_ItemType tkRectangleType, tkTextType, tkWindowType;
+
+#endif /* _TKCANVAS */
diff --git a/generic/tkColor.h b/generic/tkColor.h
index e2d9aff..dc584c0 100644
--- a/generic/tkColor.h
+++ b/generic/tkColor.h
@@ -1,85 +1,85 @@
-/*
- * tkColor.h --
- *
- * Declarations of data types and functions used by the Tk color module.
- *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkColor.h,v 1.9 2007/06/24 16:07:34 dkf Exp $
- */
-
-#ifndef _TKCOLOR
-#define _TKCOLOR
-
-#include <tkInt.h>
-
-#ifdef BUILD_tk
-#undef TCL_STORAGE_CLASS
-#define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * One of the following data structures is used to keep track of each color
- * that is being used by the application; typically there is a colormap entry
- * allocated for each of these colors.
- */
-
-#define TK_COLOR_BY_NAME 1
-#define TK_COLOR_BY_VALUE 2
-
-#define COLOR_MAGIC ((unsigned int) 0x46140277)
-
-typedef struct TkColor {
- XColor color; /* Information about this color. */
- unsigned int magic; /* Used for quick integrity check on this
- * structure. Must always have the value
- * COLOR_MAGIC. */
- GC gc; /* Simple gc with this color as foreground
- * color and all other fields defaulted. May
- * be None. */
- Screen *screen; /* Screen where this color is valid. Used to
- * delete it, and to find its display. */
- Colormap colormap; /* Colormap from which this entry was
- * allocated. */
- Visual *visual; /* Visual associated with colormap. */
- int resourceRefCount; /* Number of active uses of this color (each
- * active use corresponds to a call to
- * Tk_AllocColorFromObj or Tk_GetColor). If
- * this count is 0, then this TkColor
- * structure is no longer valid and it isn't
- * present in a hash table: it is being kept
- * around only because there are objects
- * referring to it. The structure is freed
- * when resourceRefCount and objRefCount are
- * both 0. */
- int objRefCount; /* The number of Tcl objects that reference
- * this structure. */
- int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */
- Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this
- * structure. (for use in deleting entry). */
- struct TkColor *nextPtr; /* Points to the next TkColor structure with
- * the same color name. Colors with the same
- * name but different screens or colormaps are
- * chained together off a single entry in
- * nameTable. For colors in valueTable (those
- * allocated by Tk_GetColorByValue) this field
- * is always NULL. */
-} TkColor;
-
-/*
- * Common APIs exported from all platform-specific implementations.
- */
-
-#ifndef TkpFreeColor
-MODULE_SCOPE void TkpFreeColor(TkColor *tkColPtr);
-#endif
-MODULE_SCOPE TkColor * TkpGetColor(Tk_Window tkwin, Tk_Uid name);
-MODULE_SCOPE TkColor * TkpGetColorByValue(Tk_Window tkwin, XColor *colorPtr);
-
-#undef TCL_STORAGE_CLASS
-#define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKCOLOR */
+/*
+ * tkColor.h --
+ *
+ * Declarations of data types and functions used by the Tk color module.
+ *
+ * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkColor.h,v 1.10 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#ifndef _TKCOLOR
+#define _TKCOLOR
+
+#include <tkInt.h>
+
+#ifdef BUILD_tk
+#undef TCL_STORAGE_CLASS
+#define TCL_STORAGE_CLASS DLLEXPORT
+#endif
+
+/*
+ * One of the following data structures is used to keep track of each color
+ * that is being used by the application; typically there is a colormap entry
+ * allocated for each of these colors.
+ */
+
+#define TK_COLOR_BY_NAME 1
+#define TK_COLOR_BY_VALUE 2
+
+#define COLOR_MAGIC ((unsigned int) 0x46140277)
+
+typedef struct TkColor {
+ XColor color; /* Information about this color. */
+ unsigned int magic; /* Used for quick integrity check on this
+ * structure. Must always have the value
+ * COLOR_MAGIC. */
+ GC gc; /* Simple gc with this color as foreground
+ * color and all other fields defaulted. May
+ * be None. */
+ Screen *screen; /* Screen where this color is valid. Used to
+ * delete it, and to find its display. */
+ Colormap colormap; /* Colormap from which this entry was
+ * allocated. */
+ Visual *visual; /* Visual associated with colormap. */
+ int resourceRefCount; /* Number of active uses of this color (each
+ * active use corresponds to a call to
+ * Tk_AllocColorFromObj or Tk_GetColor). If
+ * this count is 0, then this TkColor
+ * structure is no longer valid and it isn't
+ * present in a hash table: it is being kept
+ * around only because there are objects
+ * referring to it. The structure is freed
+ * when resourceRefCount and objRefCount are
+ * both 0. */
+ int objRefCount; /* The number of Tcl objects that reference
+ * this structure. */
+ int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */
+ Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this
+ * structure. (for use in deleting entry). */
+ struct TkColor *nextPtr; /* Points to the next TkColor structure with
+ * the same color name. Colors with the same
+ * name but different screens or colormaps are
+ * chained together off a single entry in
+ * nameTable. For colors in valueTable (those
+ * allocated by Tk_GetColorByValue) this field
+ * is always NULL. */
+} TkColor;
+
+/*
+ * Common APIs exported from all platform-specific implementations.
+ */
+
+#ifndef TkpFreeColor
+MODULE_SCOPE void TkpFreeColor(TkColor *tkColPtr);
+#endif
+MODULE_SCOPE TkColor * TkpGetColor(Tk_Window tkwin, Tk_Uid name);
+MODULE_SCOPE TkColor * TkpGetColorByValue(Tk_Window tkwin, XColor *colorPtr);
+
+#undef TCL_STORAGE_CLASS
+#define TCL_STORAGE_CLASS DLLIMPORT
+
+#endif /* _TKCOLOR */
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index dc1c9e4..fe79ab1 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -1,825 +1,825 @@
-/*
- * tkImgPPM.c --
- *
- * A photo image file handler for PPM (Portable PixMap) files.
- *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * Author: Paul Mackerras (paulus@cs.anu.edu.au),
- * Department of Computer Science,
- * Australian National University.
- *
- * RCS: @(#) $Id: tkImgPPM.c,v 1.17 2007/06/24 16:20:41 dkf Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The maximum amount of memory to allocate for data read from the file. If we
- * need more than this, we do it in pieces.
- */
-
-#define MAX_MEMORY 10000 /* don't allocate > 10KB */
-
-/*
- * Define PGM and PPM, i.e. gray images and color images.
- */
-
-#define PGM 1
-#define PPM 2
-
-/*
- * The format record for the PPM file format:
- */
-
-static int FileMatchPPM(Tcl_Channel chan, CONST char *fileName,
- Tcl_Obj *format, int *widthPtr, int *heightPtr,
- Tcl_Interp *interp);
-static int FileReadPPM(Tcl_Interp *interp, Tcl_Channel chan,
- CONST char *fileName, Tcl_Obj *format,
- Tk_PhotoHandle imageHandle, int destX, int destY,
- int width, int height, int srcX, int srcY);
-static int FileWritePPM(Tcl_Interp *interp, CONST char *fileName,
- Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
-static int StringWritePPM(Tcl_Interp *interp, Tcl_Obj *format,
- Tk_PhotoImageBlock *blockPtr);
-static int StringMatchPPM(Tcl_Obj *dataObj, Tcl_Obj *format,
- int *widthPtr, int *heightPtr, Tcl_Interp *interp);
-static int StringReadPPM(Tcl_Interp *interp, Tcl_Obj *dataObj,
- Tcl_Obj *format, Tk_PhotoHandle imageHandle,
- int destX, int destY, int width, int height,
- int srcX, int srcY);
-
-Tk_PhotoImageFormat tkImgFmtPPM = {
- "ppm", /* name */
- FileMatchPPM, /* fileMatchProc */
- StringMatchPPM, /* stringMatchProc */
- FileReadPPM, /* fileReadProc */
- StringReadPPM, /* stringReadProc */
- FileWritePPM, /* fileWriteProc */
- StringWritePPM, /* stringWriteProc */
-};
-
-/*
- * Prototypes for local functions defined in this file:
- */
-
-static int ReadPPMFileHeader(Tcl_Channel chan, int *widthPtr,
- int *heightPtr, int *maxIntensityPtr);
-static int ReadPPMStringHeader(Tcl_Obj *dataObj, int *widthPtr,
- int *heightPtr, int *maxIntensityPtr,
- unsigned char **dataBufferPtr, int *dataSizePtr);
-
-/*
- *----------------------------------------------------------------------
- *
- * FileMatchPPM --
- *
- * This function is invoked by the photo image type to see if a file
- * contains image data in PPM format.
- *
- * Results:
- * The return value is >0 if the first characters in file "f" look like
- * PPM data, and 0 otherwise.
- *
- * Side effects:
- * The access position in f may change.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileMatchPPM(
- Tcl_Channel chan, /* The image file, open for reading. */
- CONST char *fileName, /* The name of the image file. */
- Tcl_Obj *format, /* User-specified format string, or NULL. */
- int *widthPtr, int *heightPtr,
- /* The dimensions of the image are returned
- * here if the file is a valid raw PPM
- * file. */
- Tcl_Interp *interp) /* unused */
-{
- int dummy;
-
- return ReadPPMFileHeader(chan, widthPtr, heightPtr, &dummy);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FileReadPPM --
- *
- * This function is called by the photo image type to read PPM format
- * data from a file and write it into a given photo image.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned then an error
- * message is left in the interp's result.
- *
- * Side effects:
- * The access position in file f is changed, and new data is added to the
- * image given by imageHandle.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileReadPPM(
- Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
- Tcl_Channel chan, /* The image file, open for reading. */
- CONST char *fileName, /* The name of the image file. */
- Tcl_Obj *format, /* User-specified format string, or NULL. */
- Tk_PhotoHandle imageHandle, /* The photo image to write into. */
- int destX, int destY, /* Coordinates of top-left pixel in photo
- * image to be written to. */
- int width, int height, /* Dimensions of block of photo image to be
- * written to. */
- int srcX, int srcY) /* Coordinates of top-left pixel to be used in
- * image being read. */
-{
- int fileWidth, fileHeight, maxIntensity;
- int nLines, nBytes, h, type, count;
- unsigned char *pixelPtr;
- Tk_PhotoImageBlock block;
-
- type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity);
- if (type == 0) {
- Tcl_AppendResult(interp, "couldn't read raw PPM header from file \"",
- fileName, "\"", NULL);
- return TCL_ERROR;
- }
- if ((fileWidth <= 0) || (fileHeight <= 0)) {
- Tcl_AppendResult(interp, "PPM image file \"", fileName,
- "\" has dimension(s) <= 0", NULL);
- return TCL_ERROR;
- }
- if ((maxIntensity <= 0) || (maxIntensity >= 256)) {
- char buffer[TCL_INTEGER_SPACE];
-
- sprintf(buffer, "%d", maxIntensity);
- Tcl_AppendResult(interp, "PPM image file \"", fileName,
- "\" has bad maximum intensity value ", buffer, NULL);
- return TCL_ERROR;
- }
-
- if ((srcX + width) > fileWidth) {
- width = fileWidth - srcX;
- }
- if ((srcY + height) > fileHeight) {
- height = fileHeight - srcY;
- }
- if ((width <= 0) || (height <= 0)
- || (srcX >= fileWidth) || (srcY >= fileHeight)) {
- return TCL_OK;
- }
-
- if (type == PGM) {
- block.pixelSize = 1;
- block.offset[0] = 0;
- block.offset[1] = 0;
- block.offset[2] = 0;
- } else {
- block.pixelSize = 3;
- block.offset[0] = 0;
- block.offset[1] = 1;
- block.offset[2] = 2;
- }
- block.offset[3] = 0;
- block.width = width;
- block.pitch = block.pixelSize * fileWidth;
-
- if (Tk_PhotoExpand(interp, imageHandle,
- destX + width, destY + height) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (srcY > 0) {
- Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR);
- }
-
- nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
- if (nLines > height) {
- nLines = height;
- }
- if (nLines <= 0) {
- nLines = 1;
- }
- nBytes = nLines * block.pitch;
- pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
- block.pixelPtr = pixelPtr + srcX * block.pixelSize;
-
- for (h = height; h > 0; h -= nLines) {
- if (nLines > h) {
- nLines = h;
- nBytes = nLines * block.pitch;
- }
- count = Tcl_Read(chan, (char *) pixelPtr, nBytes);
- if (count != nBytes) {
- Tcl_AppendResult(interp, "error reading PPM image file \"",
- fileName, "\": ",
- Tcl_Eof(chan) ? "not enough data" : Tcl_PosixError(interp),
- NULL);
- ckfree((char *) pixelPtr);
- return TCL_ERROR;
- }
- if (maxIntensity != 255) {
- unsigned char *p;
-
- for (p = pixelPtr; count > 0; count--, p++) {
- *p = (((int) *p) * 255)/maxIntensity;
- }
- }
- block.height = nLines;
- if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
- width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
- ckfree((char *) pixelPtr);
- return TCL_ERROR;
- }
- destY += nLines;
- }
-
- ckfree((char *) pixelPtr);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FileWritePPM --
- *
- * This function is invoked to write image data to a file in PPM format
- * (although we can read PGM files, we never write them).
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned then an error
- * message is left in the interp's result.
- *
- * Side effects:
- * Data is written to the file given by "fileName".
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileWritePPM(
- Tcl_Interp *interp,
- CONST char *fileName,
- Tcl_Obj *format,
- Tk_PhotoImageBlock *blockPtr)
-{
- Tcl_Channel chan;
- int w, h, greenOffset, blueOffset, nBytes;
- unsigned char *pixelPtr, *pixLinePtr;
- char header[16 + TCL_INTEGER_SPACE * 2];
-
- chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
- if (chan == NULL) {
- return TCL_ERROR;
- }
-
- if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
- != TCL_OK) {
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
- if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary")
- != TCL_OK) {
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
-
- sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
- Tcl_Write(chan, header, -1);
-
- pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-
- if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
- && (blockPtr->pitch == (blockPtr->width * 3))) {
- nBytes = blockPtr->height * blockPtr->pitch;
- if (Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
- goto writeerror;
- }
- } else {
- for (h = blockPtr->height; h > 0; h--) {
- pixelPtr = pixLinePtr;
- for (w = blockPtr->width; w > 0; w--) {
- if ( Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 ||
- Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1)==-1 ||
- Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) ==-1) {
- goto writeerror;
- }
- pixelPtr += blockPtr->pixelSize;
- }
- pixLinePtr += blockPtr->pitch;
- }
- }
-
- if (Tcl_Close(NULL, chan) == 0) {
- return TCL_OK;
- }
- chan = NULL;
-
- writeerror:
- Tcl_AppendResult(interp, "error writing \"", fileName, "\": ",
- Tcl_PosixError(interp), NULL);
- if (chan != NULL) {
- Tcl_Close(NULL, chan);
- }
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringWritePPM --
- *
- * This function is invoked to write image data to a string in PPM
- * format.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned then an error
- * message is left in the interp's result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringWritePPM(
- Tcl_Interp *interp,
- Tcl_Obj *format,
- Tk_PhotoImageBlock *blockPtr)
-{
- int w, h, size, greenOffset, blueOffset;
- unsigned char *pixLinePtr, *byteArray;
- char header[16 + TCL_INTEGER_SPACE * 2];
- Tcl_Obj *byteArrayObj;
-
- sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
-
- /*
- * Construct a byte array of the right size with the header and
- * get a pointer to the data part of it.
- */
-
- size = strlen(header);
- byteArrayObj = Tcl_NewByteArrayObj((unsigned char *)header, size);
- byteArray = Tcl_SetByteArrayLength(byteArrayObj,
- size + 3*blockPtr->width*blockPtr->height);
- byteArray += size;
-
- pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-
- /*
- * Check if we can do the data move in single action.
- */
-
- if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
- && (blockPtr->pitch == (blockPtr->width * 3))) {
- memcpy(byteArray, pixLinePtr,
- (unsigned)blockPtr->height * blockPtr->pitch);
- } else {
- for (h = blockPtr->height; h > 0; h--) {
- unsigned char *pixelPtr = pixLinePtr;
-
- for (w = blockPtr->width; w > 0; w--) {
- *byteArray++ = pixelPtr[0];
- *byteArray++ = pixelPtr[greenOffset];
- *byteArray++ = pixelPtr[blueOffset];
- pixelPtr += blockPtr->pixelSize;
- }
- pixLinePtr += blockPtr->pitch;
- }
- }
-
- /*
- * Return the object in the interpreter result.
- */
-
- Tcl_SetObjResult(interp, byteArrayObj);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringMatchPPM --
- *
- * This function is invoked by the photo image type to see if a string
- * contains image data in PPM format.
- *
- * Results:
- * The return value is >0 if the first characters in file "f" look like
- * PPM data, and 0 otherwise.
- *
- * Side effects:
- * The access position in f may change.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringMatchPPM(
- Tcl_Obj *dataObj, /* The image data. */
- Tcl_Obj *format, /* User-specified format string, or NULL. */
- int *widthPtr, int *heightPtr,
- /* The dimensions of the image are returned
- * here if the file is a valid raw PPM
- * file. */
- Tcl_Interp *interp) /* unused */
-{
- int dummy;
-
- return ReadPPMStringHeader(dataObj, widthPtr, heightPtr,
- &dummy, NULL, NULL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringReadPPM --
- *
- * This function is called by the photo image type to read PPM format
- * data from a string and write it into a given photo image.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned then an error
- * message is left in the interp's result.
- *
- * Side effects:
- * New data is added to the image given by imageHandle.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringReadPPM(
- Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
- Tcl_Obj *dataObj, /* The image data. */
- Tcl_Obj *format, /* User-specified format string, or NULL. */
- Tk_PhotoHandle imageHandle, /* The photo image to write into. */
- int destX, int destY, /* Coordinates of top-left pixel in photo
- * image to be written to. */
- int width, int height, /* Dimensions of block of photo image to be
- * written to. */
- int srcX, int srcY) /* Coordinates of top-left pixel to be used in
- * image being read. */
-{
- int fileWidth, fileHeight, maxIntensity;
- int nLines, nBytes, h, type, count, dataSize;
- unsigned char *pixelPtr, *dataBuffer;
- Tk_PhotoImageBlock block;
-
- type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight,
- &maxIntensity, &dataBuffer, &dataSize);
- if (type == 0) {
- Tcl_AppendResult(interp, "couldn't read raw PPM header from string",
- NULL);
- return TCL_ERROR;
- }
- if ((fileWidth <= 0) || (fileHeight <= 0)) {
- Tcl_AppendResult(interp, "PPM image data has dimension(s) <= 0",
- NULL);
- return TCL_ERROR;
- }
- if ((maxIntensity <= 0) || (maxIntensity >= 256)) {
- char buffer[TCL_INTEGER_SPACE];
-
- sprintf(buffer, "%d", maxIntensity);
- Tcl_AppendResult(interp,
- "PPM image data has bad maximum intensity value ", buffer,
- NULL);
- return TCL_ERROR;
- }
-
- if ((srcX + width) > fileWidth) {
- width = fileWidth - srcX;
- }
- if ((srcY + height) > fileHeight) {
- height = fileHeight - srcY;
- }
- if ((width <= 0) || (height <= 0)
- || (srcX >= fileWidth) || (srcY >= fileHeight)) {
- return TCL_OK;
- }
-
- if (type == PGM) {
- block.pixelSize = 1;
- block.offset[0] = 0;
- block.offset[1] = 0;
- block.offset[2] = 0;
- } else {
- block.pixelSize = 3;
- block.offset[0] = 0;
- block.offset[1] = 1;
- block.offset[2] = 2;
- }
- block.offset[3] = 0;
- block.width = width;
- block.pitch = block.pixelSize * fileWidth;
-
- if (srcY > 0) {
- dataBuffer += srcY * block.pitch;
- dataSize -= srcY * block.pitch;
- }
-
- if (maxIntensity == 255) {
- /*
- * We have all the data in memory, so write everything in one go.
- */
-
- if (block.pitch*height < dataSize) {
- Tcl_AppendResult(interp, "truncated PPM data", NULL);
- return TCL_ERROR;
- }
- block.pixelPtr = dataBuffer + srcX * block.pixelSize;
- block.height = height;
- return Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
- width, height, TK_PHOTO_COMPOSITE_SET);
- }
-
- if (Tk_PhotoExpand(interp, imageHandle,
- destX + width, destY + height) != TCL_OK) {
- return TCL_ERROR;
- }
-
- nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
- if (nLines > height) {
- nLines = height;
- }
- if (nLines <= 0) {
- nLines = 1;
- }
- nBytes = nLines * block.pitch;
- pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
- block.pixelPtr = pixelPtr + srcX * block.pixelSize;
-
- for (h = height; h > 0; h -= nLines) {
- unsigned char *p;
-
- if (nLines > h) {
- nLines = h;
- nBytes = nLines * block.pitch;
- }
- if (dataSize < nBytes) {
- ckfree((char *) pixelPtr);
- Tcl_AppendResult(interp, "truncated PPM data", NULL);
- return TCL_ERROR;
- }
- for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) {
- *p = (((int) *dataBuffer) * 255)/maxIntensity;
- }
- dataSize -= nBytes;
- block.height = nLines;
- if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
- width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
- ckfree((char *) pixelPtr);
- return TCL_ERROR;
- }
- destY += nLines;
- }
-
- ckfree((char *) pixelPtr);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadPPMFileHeader --
- *
- * This function reads the PPM header from the beginning of a PPM file
- * and returns information from the header.
- *
- * Results:
- * The return value is PGM if file "f" appears to start with a valid PGM
- * header, PPM if "f" appears to start with a valid PPM header, and 0
- * otherwise. If the header is valid, then *widthPtr and *heightPtr are
- * modified to hold the dimensions of the image and *maxIntensityPtr is
- * modified to hold the value of a "fully on" intensity value.
- *
- * Side effects:
- * The access position in f advances.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ReadPPMFileHeader(
- Tcl_Channel chan, /* Image file to read the header from. */
- int *widthPtr, int *heightPtr,
- /* The dimensions of the image are returned
- * here. */
- int *maxIntensityPtr) /* The maximum intensity value for the image
- * is stored here. */
-{
-#define BUFFER_SIZE 1000
- char buffer[BUFFER_SIZE], c;
- int i, numFields, type = 0;
-
- /*
- * Read 4 space-separated fields from the file, ignoring comments (any
- * line that starts with "#").
- */
-
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- i = 0;
- for (numFields = 0; numFields < 4; numFields++) {
- /*
- * Skip comments and white space.
- */
-
- while (1) {
- while (isspace(UCHAR(c))) {
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- }
- if (c != '#') {
- break;
- }
- do {
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- } while (c != '\n');
- }
-
- /*
- * Read a field (everything up to the next white space).
- */
-
- while (!isspace(UCHAR(c))) {
- if (i < (BUFFER_SIZE-2)) {
- buffer[i] = c;
- i++;
- }
- if (Tcl_Read(chan, &c, 1) != 1) {
- goto done;
- }
- }
- if (i < (BUFFER_SIZE-1)) {
- buffer[i] = ' ';
- i++;
- }
- }
-
- done:
- buffer[i] = 0;
-
- /*
- * Parse the fields, which are: id, width, height, maxIntensity.
- */
-
- if (strncmp(buffer, "P6 ", 3) == 0) {
- type = PPM;
- } else if (strncmp(buffer, "P5 ", 3) == 0) {
- type = PGM;
- } else {
- return 0;
- }
- if (sscanf(buffer+3, "%d %d %d", widthPtr, heightPtr, maxIntensityPtr)
- != 3) {
- return 0;
- }
- return type;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadPPMStringHeader --
- *
- * This function reads the PPM header from the beginning of a PPM-format
- * string and returns information from the header.
- *
- * Results:
- * The return value is PGM if the string appears to start with a valid
- * PGM header, PPM if the string appears to start with a valid PPM
- * header, and 0 otherwise. If the header is valid, then *widthPtr and
- * *heightPtr are modified to hold the dimensions of the image and
- * *maxIntensityPtr is modified to hold the value of a "fully on"
- * intensity value.
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ReadPPMStringHeader(
- Tcl_Obj *dataPtr, /* Object to read the header from. */
- int *widthPtr, int *heightPtr,
- /* The dimensions of the image are returned
- * here. */
- int *maxIntensityPtr, /* The maximum intensity value for the image
- * is stored here. */
- unsigned char **dataBufferPtr,
- int *dataSizePtr)
-{
-#define BUFFER_SIZE 1000
- char buffer[BUFFER_SIZE], c;
- int i, numFields, dataSize, type = 0;
- unsigned char *dataBuffer;
-
- dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);
-
- /*
- * Read 4 space-separated fields from the string, ignoring comments (any
- * line that starts with "#").
- */
-
- if (dataSize-- < 1) {
- return 0;
- }
- c = (char) (*dataBuffer++);
- i = 0;
- for (numFields = 0; numFields < 4; numFields++) {
- /*
- * Skip comments and white space.
- */
-
- while (1) {
- while (isspace(UCHAR(c))) {
- if (dataSize-- < 1) {
- return 0;
- }
- c = (char) (*dataBuffer++);
- }
- if (c != '#') {
- break;
- }
- do {
- if (dataSize-- < 1) {
- return 0;
- }
- c = (char) (*dataBuffer++);
- } while (c != '\n');
- }
-
- /*
- * Read a field (everything up to the next white space).
- */
-
- while (!isspace(UCHAR(c))) {
- if (i < (BUFFER_SIZE-2)) {
- buffer[i] = c;
- i++;
- }
- if (dataSize-- < 1) {
- goto done;
- }
- c = (char) (*dataBuffer++);
- }
- if (i < (BUFFER_SIZE-1)) {
- buffer[i] = ' ';
- i++;
- }
- }
-
- done:
- buffer[i] = 0;
-
- /*
- * Parse the fields, which are: id, width, height, maxIntensity.
- */
-
- if (strncmp(buffer, "P6 ", 3) == 0) {
- type = PPM;
- } else if (strncmp(buffer, "P5 ", 3) == 0) {
- type = PGM;
- } else {
- return 0;
- }
- if (sscanf(buffer+3, "%d %d %d", widthPtr, heightPtr, maxIntensityPtr)
- != 3) {
- return 0;
- }
- if (dataBufferPtr != NULL) {
- *dataBufferPtr = dataBuffer;
- *dataSizePtr = dataSize;
- }
- return type;
-}
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
+/*
+ * tkImgPPM.c --
+ *
+ * A photo image file handler for PPM (Portable PixMap) files.
+ *
+ * Copyright (c) 1994 The Australian National University.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * Author: Paul Mackerras (paulus@cs.anu.edu.au),
+ * Department of Computer Science,
+ * Australian National University.
+ *
+ * RCS: @(#) $Id: tkImgPPM.c,v 1.18 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#include "tkInt.h"
+#include "tkPort.h"
+
+/*
+ * The maximum amount of memory to allocate for data read from the file. If we
+ * need more than this, we do it in pieces.
+ */
+
+#define MAX_MEMORY 10000 /* don't allocate > 10KB */
+
+/*
+ * Define PGM and PPM, i.e. gray images and color images.
+ */
+
+#define PGM 1
+#define PPM 2
+
+/*
+ * The format record for the PPM file format:
+ */
+
+static int FileMatchPPM(Tcl_Channel chan, CONST char *fileName,
+ Tcl_Obj *format, int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp);
+static int FileReadPPM(Tcl_Interp *interp, Tcl_Channel chan,
+ CONST char *fileName, Tcl_Obj *format,
+ Tk_PhotoHandle imageHandle, int destX, int destY,
+ int width, int height, int srcX, int srcY);
+static int FileWritePPM(Tcl_Interp *interp, CONST char *fileName,
+ Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
+static int StringWritePPM(Tcl_Interp *interp, Tcl_Obj *format,
+ Tk_PhotoImageBlock *blockPtr);
+static int StringMatchPPM(Tcl_Obj *dataObj, Tcl_Obj *format,
+ int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+static int StringReadPPM(Tcl_Interp *interp, Tcl_Obj *dataObj,
+ Tcl_Obj *format, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY);
+
+Tk_PhotoImageFormat tkImgFmtPPM = {
+ "ppm", /* name */
+ FileMatchPPM, /* fileMatchProc */
+ StringMatchPPM, /* stringMatchProc */
+ FileReadPPM, /* fileReadProc */
+ StringReadPPM, /* stringReadProc */
+ FileWritePPM, /* fileWriteProc */
+ StringWritePPM, /* stringWriteProc */
+};
+
+/*
+ * Prototypes for local functions defined in this file:
+ */
+
+static int ReadPPMFileHeader(Tcl_Channel chan, int *widthPtr,
+ int *heightPtr, int *maxIntensityPtr);
+static int ReadPPMStringHeader(Tcl_Obj *dataObj, int *widthPtr,
+ int *heightPtr, int *maxIntensityPtr,
+ unsigned char **dataBufferPtr, int *dataSizePtr);
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileMatchPPM --
+ *
+ * This function is invoked by the photo image type to see if a file
+ * contains image data in PPM format.
+ *
+ * Results:
+ * The return value is >0 if the first characters in file "f" look like
+ * PPM data, and 0 otherwise.
+ *
+ * Side effects:
+ * The access position in f may change.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileMatchPPM(
+ Tcl_Channel chan, /* The image file, open for reading. */
+ CONST char *fileName, /* The name of the image file. */
+ Tcl_Obj *format, /* User-specified format string, or NULL. */
+ int *widthPtr, int *heightPtr,
+ /* The dimensions of the image are returned
+ * here if the file is a valid raw PPM
+ * file. */
+ Tcl_Interp *interp) /* unused */
+{
+ int dummy;
+
+ return ReadPPMFileHeader(chan, widthPtr, heightPtr, &dummy);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileReadPPM --
+ *
+ * This function is called by the photo image type to read PPM format
+ * data from a file and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * The access position in file f is changed, and new data is added to the
+ * image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileReadPPM(
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tcl_Channel chan, /* The image file, open for reading. */
+ CONST char *fileName, /* The name of the image file. */
+ Tcl_Obj *format, /* User-specified format string, or NULL. */
+ Tk_PhotoHandle imageHandle, /* The photo image to write into. */
+ int destX, int destY, /* Coordinates of top-left pixel in photo
+ * image to be written to. */
+ int width, int height, /* Dimensions of block of photo image to be
+ * written to. */
+ int srcX, int srcY) /* Coordinates of top-left pixel to be used in
+ * image being read. */
+{
+ int fileWidth, fileHeight, maxIntensity;
+ int nLines, nBytes, h, type, count;
+ unsigned char *pixelPtr;
+ Tk_PhotoImageBlock block;
+
+ type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity);
+ if (type == 0) {
+ Tcl_AppendResult(interp, "couldn't read raw PPM header from file \"",
+ fileName, "\"", NULL);
+ return TCL_ERROR;
+ }
+ if ((fileWidth <= 0) || (fileHeight <= 0)) {
+ Tcl_AppendResult(interp, "PPM image file \"", fileName,
+ "\" has dimension(s) <= 0", NULL);
+ return TCL_ERROR;
+ }
+ if ((maxIntensity <= 0) || (maxIntensity >= 256)) {
+ char buffer[TCL_INTEGER_SPACE];
+
+ sprintf(buffer, "%d", maxIntensity);
+ Tcl_AppendResult(interp, "PPM image file \"", fileName,
+ "\" has bad maximum intensity value ", buffer, NULL);
+ return TCL_ERROR;
+ }
+
+ if ((srcX + width) > fileWidth) {
+ width = fileWidth - srcX;
+ }
+ if ((srcY + height) > fileHeight) {
+ height = fileHeight - srcY;
+ }
+ if ((width <= 0) || (height <= 0)
+ || (srcX >= fileWidth) || (srcY >= fileHeight)) {
+ return TCL_OK;
+ }
+
+ if (type == PGM) {
+ block.pixelSize = 1;
+ block.offset[0] = 0;
+ block.offset[1] = 0;
+ block.offset[2] = 0;
+ } else {
+ block.pixelSize = 3;
+ block.offset[0] = 0;
+ block.offset[1] = 1;
+ block.offset[2] = 2;
+ }
+ block.offset[3] = 0;
+ block.width = width;
+ block.pitch = block.pixelSize * fileWidth;
+
+ if (Tk_PhotoExpand(interp, imageHandle,
+ destX + width, destY + height) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ if (srcY > 0) {
+ Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR);
+ }
+
+ nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
+ if (nLines > height) {
+ nLines = height;
+ }
+ if (nLines <= 0) {
+ nLines = 1;
+ }
+ nBytes = nLines * block.pitch;
+ pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
+ block.pixelPtr = pixelPtr + srcX * block.pixelSize;
+
+ for (h = height; h > 0; h -= nLines) {
+ if (nLines > h) {
+ nLines = h;
+ nBytes = nLines * block.pitch;
+ }
+ count = Tcl_Read(chan, (char *) pixelPtr, nBytes);
+ if (count != nBytes) {
+ Tcl_AppendResult(interp, "error reading PPM image file \"",
+ fileName, "\": ",
+ Tcl_Eof(chan) ? "not enough data" : Tcl_PosixError(interp),
+ NULL);
+ ckfree((char *) pixelPtr);
+ return TCL_ERROR;
+ }
+ if (maxIntensity != 255) {
+ unsigned char *p;
+
+ for (p = pixelPtr; count > 0; count--, p++) {
+ *p = (((int) *p) * 255)/maxIntensity;
+ }
+ }
+ block.height = nLines;
+ if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
+ width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ ckfree((char *) pixelPtr);
+ return TCL_ERROR;
+ }
+ destY += nLines;
+ }
+
+ ckfree((char *) pixelPtr);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileWritePPM --
+ *
+ * This function is invoked to write image data to a file in PPM format
+ * (although we can read PGM files, we never write them).
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * Data is written to the file given by "fileName".
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileWritePPM(
+ Tcl_Interp *interp,
+ CONST char *fileName,
+ Tcl_Obj *format,
+ Tk_PhotoImageBlock *blockPtr)
+{
+ Tcl_Channel chan;
+ int w, h, greenOffset, blueOffset, nBytes;
+ unsigned char *pixelPtr, *pixLinePtr;
+ char header[16 + TCL_INTEGER_SPACE * 2];
+
+ chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
+ if (chan == NULL) {
+ return TCL_ERROR;
+ }
+
+ if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
+ != TCL_OK) {
+ Tcl_Close(NULL, chan);
+ return TCL_ERROR;
+ }
+ if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary")
+ != TCL_OK) {
+ Tcl_Close(NULL, chan);
+ return TCL_ERROR;
+ }
+
+ sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
+ Tcl_Write(chan, header, -1);
+
+ pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
+ greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
+ blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
+
+ if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
+ && (blockPtr->pitch == (blockPtr->width * 3))) {
+ nBytes = blockPtr->height * blockPtr->pitch;
+ if (Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
+ goto writeerror;
+ }
+ } else {
+ for (h = blockPtr->height; h > 0; h--) {
+ pixelPtr = pixLinePtr;
+ for (w = blockPtr->width; w > 0; w--) {
+ if ( Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 ||
+ Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1)==-1 ||
+ Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) ==-1) {
+ goto writeerror;
+ }
+ pixelPtr += blockPtr->pixelSize;
+ }
+ pixLinePtr += blockPtr->pitch;
+ }
+ }
+
+ if (Tcl_Close(NULL, chan) == 0) {
+ return TCL_OK;
+ }
+ chan = NULL;
+
+ writeerror:
+ Tcl_AppendResult(interp, "error writing \"", fileName, "\": ",
+ Tcl_PosixError(interp), NULL);
+ if (chan != NULL) {
+ Tcl_Close(NULL, chan);
+ }
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringWritePPM --
+ *
+ * This function is invoked to write image data to a string in PPM
+ * format.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringWritePPM(
+ Tcl_Interp *interp,
+ Tcl_Obj *format,
+ Tk_PhotoImageBlock *blockPtr)
+{
+ int w, h, size, greenOffset, blueOffset;
+ unsigned char *pixLinePtr, *byteArray;
+ char header[16 + TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *byteArrayObj;
+
+ sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
+
+ /*
+ * Construct a byte array of the right size with the header and
+ * get a pointer to the data part of it.
+ */
+
+ size = strlen(header);
+ byteArrayObj = Tcl_NewByteArrayObj((unsigned char *)header, size);
+ byteArray = Tcl_SetByteArrayLength(byteArrayObj,
+ size + 3*blockPtr->width*blockPtr->height);
+ byteArray += size;
+
+ pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
+ greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
+ blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
+
+ /*
+ * Check if we can do the data move in single action.
+ */
+
+ if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
+ && (blockPtr->pitch == (blockPtr->width * 3))) {
+ memcpy(byteArray, pixLinePtr,
+ (unsigned)blockPtr->height * blockPtr->pitch);
+ } else {
+ for (h = blockPtr->height; h > 0; h--) {
+ unsigned char *pixelPtr = pixLinePtr;
+
+ for (w = blockPtr->width; w > 0; w--) {
+ *byteArray++ = pixelPtr[0];
+ *byteArray++ = pixelPtr[greenOffset];
+ *byteArray++ = pixelPtr[blueOffset];
+ pixelPtr += blockPtr->pixelSize;
+ }
+ pixLinePtr += blockPtr->pitch;
+ }
+ }
+
+ /*
+ * Return the object in the interpreter result.
+ */
+
+ Tcl_SetObjResult(interp, byteArrayObj);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringMatchPPM --
+ *
+ * This function is invoked by the photo image type to see if a string
+ * contains image data in PPM format.
+ *
+ * Results:
+ * The return value is >0 if the first characters in file "f" look like
+ * PPM data, and 0 otherwise.
+ *
+ * Side effects:
+ * The access position in f may change.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringMatchPPM(
+ Tcl_Obj *dataObj, /* The image data. */
+ Tcl_Obj *format, /* User-specified format string, or NULL. */
+ int *widthPtr, int *heightPtr,
+ /* The dimensions of the image are returned
+ * here if the file is a valid raw PPM
+ * file. */
+ Tcl_Interp *interp) /* unused */
+{
+ int dummy;
+
+ return ReadPPMStringHeader(dataObj, widthPtr, heightPtr,
+ &dummy, NULL, NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringReadPPM --
+ *
+ * This function is called by the photo image type to read PPM format
+ * data from a string and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * New data is added to the image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringReadPPM(
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tcl_Obj *dataObj, /* The image data. */
+ Tcl_Obj *format, /* User-specified format string, or NULL. */
+ Tk_PhotoHandle imageHandle, /* The photo image to write into. */
+ int destX, int destY, /* Coordinates of top-left pixel in photo
+ * image to be written to. */
+ int width, int height, /* Dimensions of block of photo image to be
+ * written to. */
+ int srcX, int srcY) /* Coordinates of top-left pixel to be used in
+ * image being read. */
+{
+ int fileWidth, fileHeight, maxIntensity;
+ int nLines, nBytes, h, type, count, dataSize;
+ unsigned char *pixelPtr, *dataBuffer;
+ Tk_PhotoImageBlock block;
+
+ type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight,
+ &maxIntensity, &dataBuffer, &dataSize);
+ if (type == 0) {
+ Tcl_AppendResult(interp, "couldn't read raw PPM header from string",
+ NULL);
+ return TCL_ERROR;
+ }
+ if ((fileWidth <= 0) || (fileHeight <= 0)) {
+ Tcl_AppendResult(interp, "PPM image data has dimension(s) <= 0",
+ NULL);
+ return TCL_ERROR;
+ }
+ if ((maxIntensity <= 0) || (maxIntensity >= 256)) {
+ char buffer[TCL_INTEGER_SPACE];
+
+ sprintf(buffer, "%d", maxIntensity);
+ Tcl_AppendResult(interp,
+ "PPM image data has bad maximum intensity value ", buffer,
+ NULL);
+ return TCL_ERROR;
+ }
+
+ if ((srcX + width) > fileWidth) {
+ width = fileWidth - srcX;
+ }
+ if ((srcY + height) > fileHeight) {
+ height = fileHeight - srcY;
+ }
+ if ((width <= 0) || (height <= 0)
+ || (srcX >= fileWidth) || (srcY >= fileHeight)) {
+ return TCL_OK;
+ }
+
+ if (type == PGM) {
+ block.pixelSize = 1;
+ block.offset[0] = 0;
+ block.offset[1] = 0;
+ block.offset[2] = 0;
+ } else {
+ block.pixelSize = 3;
+ block.offset[0] = 0;
+ block.offset[1] = 1;
+ block.offset[2] = 2;
+ }
+ block.offset[3] = 0;
+ block.width = width;
+ block.pitch = block.pixelSize * fileWidth;
+
+ if (srcY > 0) {
+ dataBuffer += srcY * block.pitch;
+ dataSize -= srcY * block.pitch;
+ }
+
+ if (maxIntensity == 255) {
+ /*
+ * We have all the data in memory, so write everything in one go.
+ */
+
+ if (block.pitch*height < dataSize) {
+ Tcl_AppendResult(interp, "truncated PPM data", NULL);
+ return TCL_ERROR;
+ }
+ block.pixelPtr = dataBuffer + srcX * block.pixelSize;
+ block.height = height;
+ return Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
+ width, height, TK_PHOTO_COMPOSITE_SET);
+ }
+
+ if (Tk_PhotoExpand(interp, imageHandle,
+ destX + width, destY + height) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
+ if (nLines > height) {
+ nLines = height;
+ }
+ if (nLines <= 0) {
+ nLines = 1;
+ }
+ nBytes = nLines * block.pitch;
+ pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
+ block.pixelPtr = pixelPtr + srcX * block.pixelSize;
+
+ for (h = height; h > 0; h -= nLines) {
+ unsigned char *p;
+
+ if (nLines > h) {
+ nLines = h;
+ nBytes = nLines * block.pitch;
+ }
+ if (dataSize < nBytes) {
+ ckfree((char *) pixelPtr);
+ Tcl_AppendResult(interp, "truncated PPM data", NULL);
+ return TCL_ERROR;
+ }
+ for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) {
+ *p = (((int) *dataBuffer) * 255)/maxIntensity;
+ }
+ dataSize -= nBytes;
+ block.height = nLines;
+ if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
+ width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ ckfree((char *) pixelPtr);
+ return TCL_ERROR;
+ }
+ destY += nLines;
+ }
+
+ ckfree((char *) pixelPtr);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ReadPPMFileHeader --
+ *
+ * This function reads the PPM header from the beginning of a PPM file
+ * and returns information from the header.
+ *
+ * Results:
+ * The return value is PGM if file "f" appears to start with a valid PGM
+ * header, PPM if "f" appears to start with a valid PPM header, and 0
+ * otherwise. If the header is valid, then *widthPtr and *heightPtr are
+ * modified to hold the dimensions of the image and *maxIntensityPtr is
+ * modified to hold the value of a "fully on" intensity value.
+ *
+ * Side effects:
+ * The access position in f advances.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadPPMFileHeader(
+ Tcl_Channel chan, /* Image file to read the header from. */
+ int *widthPtr, int *heightPtr,
+ /* The dimensions of the image are returned
+ * here. */
+ int *maxIntensityPtr) /* The maximum intensity value for the image
+ * is stored here. */
+{
+#define BUFFER_SIZE 1000
+ char buffer[BUFFER_SIZE], c;
+ int i, numFields, type = 0;
+
+ /*
+ * Read 4 space-separated fields from the file, ignoring comments (any
+ * line that starts with "#").
+ */
+
+ if (Tcl_Read(chan, &c, 1) != 1) {
+ return 0;
+ }
+ i = 0;
+ for (numFields = 0; numFields < 4; numFields++) {
+ /*
+ * Skip comments and white space.
+ */
+
+ while (1) {
+ while (isspace(UCHAR(c))) {
+ if (Tcl_Read(chan, &c, 1) != 1) {
+ return 0;
+ }
+ }
+ if (c != '#') {
+ break;
+ }
+ do {
+ if (Tcl_Read(chan, &c, 1) != 1) {
+ return 0;
+ }
+ } while (c != '\n');
+ }
+
+ /*
+ * Read a field (everything up to the next white space).
+ */
+
+ while (!isspace(UCHAR(c))) {
+ if (i < (BUFFER_SIZE-2)) {
+ buffer[i] = c;
+ i++;
+ }
+ if (Tcl_Read(chan, &c, 1) != 1) {
+ goto done;
+ }
+ }
+ if (i < (BUFFER_SIZE-1)) {
+ buffer[i] = ' ';
+ i++;
+ }
+ }
+
+ done:
+ buffer[i] = 0;
+
+ /*
+ * Parse the fields, which are: id, width, height, maxIntensity.
+ */
+
+ if (strncmp(buffer, "P6 ", 3) == 0) {
+ type = PPM;
+ } else if (strncmp(buffer, "P5 ", 3) == 0) {
+ type = PGM;
+ } else {
+ return 0;
+ }
+ if (sscanf(buffer+3, "%d %d %d", widthPtr, heightPtr, maxIntensityPtr)
+ != 3) {
+ return 0;
+ }
+ return type;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ReadPPMStringHeader --
+ *
+ * This function reads the PPM header from the beginning of a PPM-format
+ * string and returns information from the header.
+ *
+ * Results:
+ * The return value is PGM if the string appears to start with a valid
+ * PGM header, PPM if the string appears to start with a valid PPM
+ * header, and 0 otherwise. If the header is valid, then *widthPtr and
+ * *heightPtr are modified to hold the dimensions of the image and
+ * *maxIntensityPtr is modified to hold the value of a "fully on"
+ * intensity value.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadPPMStringHeader(
+ Tcl_Obj *dataPtr, /* Object to read the header from. */
+ int *widthPtr, int *heightPtr,
+ /* The dimensions of the image are returned
+ * here. */
+ int *maxIntensityPtr, /* The maximum intensity value for the image
+ * is stored here. */
+ unsigned char **dataBufferPtr,
+ int *dataSizePtr)
+{
+#define BUFFER_SIZE 1000
+ char buffer[BUFFER_SIZE], c;
+ int i, numFields, dataSize, type = 0;
+ unsigned char *dataBuffer;
+
+ dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);
+
+ /*
+ * Read 4 space-separated fields from the string, ignoring comments (any
+ * line that starts with "#").
+ */
+
+ if (dataSize-- < 1) {
+ return 0;
+ }
+ c = (char) (*dataBuffer++);
+ i = 0;
+ for (numFields = 0; numFields < 4; numFields++) {
+ /*
+ * Skip comments and white space.
+ */
+
+ while (1) {
+ while (isspace(UCHAR(c))) {
+ if (dataSize-- < 1) {
+ return 0;
+ }
+ c = (char) (*dataBuffer++);
+ }
+ if (c != '#') {
+ break;
+ }
+ do {
+ if (dataSize-- < 1) {
+ return 0;
+ }
+ c = (char) (*dataBuffer++);
+ } while (c != '\n');
+ }
+
+ /*
+ * Read a field (everything up to the next white space).
+ */
+
+ while (!isspace(UCHAR(c))) {
+ if (i < (BUFFER_SIZE-2)) {
+ buffer[i] = c;
+ i++;
+ }
+ if (dataSize-- < 1) {
+ goto done;
+ }
+ c = (char) (*dataBuffer++);
+ }
+ if (i < (BUFFER_SIZE-1)) {
+ buffer[i] = ' ';
+ i++;
+ }
+ }
+
+ done:
+ buffer[i] = 0;
+
+ /*
+ * Parse the fields, which are: id, width, height, maxIntensity.
+ */
+
+ if (strncmp(buffer, "P6 ", 3) == 0) {
+ type = PPM;
+ } else if (strncmp(buffer, "P5 ", 3) == 0) {
+ type = PGM;
+ } else {
+ return 0;
+ }
+ if (sscanf(buffer+3, "%d %d %d", widthPtr, heightPtr, maxIntensityPtr)
+ != 3) {
+ return 0;
+ }
+ if (dataBufferPtr != NULL) {
+ *dataBufferPtr = dataBuffer;
+ *dataSizePtr = dataSize;
+ }
+ return type;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
index 9c36003..242e6a0 100644
--- a/generic/tkMenubutton.h
+++ b/generic/tkMenubutton.h
@@ -1,232 +1,232 @@
-/*
- * tkMenubutton.h --
- *
- * Declarations of types and functions used to implement the menubutton
- * widget.
- *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkMenubutton.h,v 1.12 2007/06/24 16:07:35 dkf Exp $
- */
-
-#ifndef _TKMENUBUTTON
-#define _TKMENUBUTTON
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifndef _TKMENU
-#include "tkMenu.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Legal values for the "orient" field of TkMenubutton records.
- */
-
-enum direction {
- DIRECTION_ABOVE, DIRECTION_BELOW, DIRECTION_FLUSH,
- DIRECTION_LEFT, DIRECTION_RIGHT
-};
-
-/*
- * Legal values for the "state" field of TkMenubutton records.
- */
-
-enum state {
- STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
-};
-
-/*
- * A data structure of the following type is kept for each widget managed by
- * this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the widget. NULL means
- * that the window has been destroyed but the
- * data structures haven't yet been cleaned
- * up. */
- Display *display; /* Display containing widget. Needed, among
- * other things, so that resources can bee
- * freed up even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with menubutton. */
- Tcl_Command widgetCmd; /* Token for menubutton's widget command. */
- Tk_OptionTable optionTable; /* Table that defines configuration options
- * available for this widget. */
- char *menuName; /* Name of menu associated with widget.
- * Malloc-ed. */
-
- /*
- * Information about what's displayed in the menu button:
- */
-
- char *text; /* Text to display in button (malloc'ed) or
- * NULL. */
- int underline; /* Index of character to underline. */
- char *textVarName; /* Name of variable (malloc'ed) or NULL. If
- * non-NULL, button displays the contents of
- * this variable. */
- Pixmap bitmap; /* Bitmap to display or None. If not None then
- * text and textVar and underline are
- * ignored. */
- char *imageString; /* Name of image to display (malloc'ed), or
- * NULL. If non-NULL, bitmap, text, and
- * textVarName are ignored. */
- Tk_Image image; /* Image to display in window, or NULL if
- * none. */
-
- /*
- * Information used when displaying widget:
- */
-
- enum state state; /* State of button for display purposes:
- * normal, active, or disabled. */
- Tk_3DBorder normalBorder; /* Structure used to draw 3-D border and
- * background when window isn't active. NULL
- * means no such border exists. */
- Tk_3DBorder activeBorder; /* Structure used to draw 3-D border and
- * background when window is active. NULL
- * means no such border exists. */
- int borderWidth; /* Width of border. */
- int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw around
- * widget when it has the focus. <= 0 means
- * don't draw a highlight. */
- XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area
- * when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must be
- * offset from outside edges to leave room for
- * borders. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *normalFg; /* Foreground color in normal mode. */
- XColor *activeFg; /* Foreground color in active mode. NULL means
- * use normalFg instead. */
- XColor *disabledFg; /* Foreground color when disabled. NULL means
- * use normalFg with a 50% stipple instead. */
- GC normalTextGC; /* GC for drawing text in normal mode. */
- GC activeTextGC; /* GC for drawing text in active mode (NULL
- * means use normalTextGC). */
- Pixmap gray; /* Pixmap for displaying disabled text/icon if
- * disabledFg is NULL. */
- GC disabledGC; /* Used to produce disabled effect for
- * text. */
- GC stippleGC; /* Used to produce disabled stipple effect for
- * images when disabled. */
- int leftBearing; /* Distance from text origin to leftmost drawn
- * pixel (positive means to right). */
- int rightBearing; /* Amount text sticks right from its
- * origin. */
- char *widthString; /* Value of -width option. Malloc'ed. */
- char *heightString; /* Value of -height option. Malloc'ed. */
- int width, height; /* If > 0, these specify dimensions to request
- * for window, in characters for text and in
- * pixels for bitmaps. In this case the actual
- * size of the text string or bitmap is
- * ignored in computing desired window
- * size. */
- int wrapLength; /* Line length (in pixels) at which to wrap
- * onto next line. <= 0 means don't wrap
- * except at newlines. */
- int padX, padY; /* Extra space around text or bitmap (pixels
- * on each side). */
- Tk_Anchor anchor; /* Where text/bitmap should be displayed
- * inside window region. */
- Tk_Justify justify; /* Justification to use for multi-line
- * text. */
- int textWidth; /* Width needed to display text as requested,
- * in pixels. */
- int textHeight; /* Height needed to display text as requested,
- * in pixels. */
- Tk_TextLayout textLayout; /* Saved text layout information. */
- int indicatorOn; /* Non-zero means display indicator; 0 means
- * don't display. */
- int indicatorHeight; /* Height of indicator in pixels. This same
- * amount of extra space is also left on each
- * side of the indicator. 0 if no
- * indicator. */
- int indicatorWidth; /* Width of indicator in pixels, including
- * indicatorHeight in padding on each side. 0
- * if no indicator. */
-
- /*
- * Miscellaneous information:
- */
-
- int compound; /* Value of -compound option; specifies
- * whether the menubutton should show both an
- * image and text, and, if so, how. */
- enum direction direction; /* Direction for where to pop the menu. Valid
- * directions are "above", "below", "left",
- * "right", and "flush". "flush" means that
- * the upper left corner of the menubutton is
- * where the menu pops up. "above" and "below"
- * will attempt to pop the menu compleletly
- * above or below the menu respectively.
- * "left" and "right" will pop the menu left
- * or right, and the active item will be next
- * to the button. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in the
- * C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkMenuButton;
-
-/*
- * Flag bits for buttons:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
- * already been queued to redraw this window.
- * POSTED: Non-zero means that the menu associated with
- * this button has been posted (typically because
- * of an active button press).
- * GOT_FOCUS: Non-zero means this button currently has the
- * input focus.
- */
-
-#define REDRAW_PENDING 1
-#define POSTED 2
-#define GOT_FOCUS 4
-
-/*
- * The following constants define the dimensions of the cascade indicator,
- * which is displayed if the "-indicatoron" option is true. The units for
- * these options are 1/10 millimeters.
- */
-
-#define INDICATOR_WIDTH 40
-#define INDICATOR_HEIGHT 17
-
-/*
- * Declaration of variables shared between the files in the button module.
- */
-
-MODULE_SCOPE Tk_ClassProcs tkpMenubuttonClass;
-
-/*
- * Declaration of procedures used in the implementation of the button widget.
- */
-
-MODULE_SCOPE void TkpComputeMenuButtonGeometry(TkMenuButton *mbPtr);
-MODULE_SCOPE TkMenuButton *TkpCreateMenuButton(Tk_Window tkwin);
-MODULE_SCOPE void TkpDisplayMenuButton(ClientData clientData);
-MODULE_SCOPE void TkpDestroyMenuButton(TkMenuButton *mbPtr);
-MODULE_SCOPE void TkMenuButtonWorldChanged(ClientData instanceData);
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKMENUBUTTON */
+/*
+ * tkMenubutton.h --
+ *
+ * Declarations of types and functions used to implement the menubutton
+ * widget.
+ *
+ * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkMenubutton.h,v 1.13 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#ifndef _TKMENUBUTTON
+#define _TKMENUBUTTON
+
+#ifndef _TKINT
+#include "tkInt.h"
+#endif
+
+#ifndef _TKMENU
+#include "tkMenu.h"
+#endif
+
+#ifdef BUILD_tk
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLEXPORT
+#endif
+
+/*
+ * Legal values for the "orient" field of TkMenubutton records.
+ */
+
+enum direction {
+ DIRECTION_ABOVE, DIRECTION_BELOW, DIRECTION_FLUSH,
+ DIRECTION_LEFT, DIRECTION_RIGHT
+};
+
+/*
+ * Legal values for the "state" field of TkMenubutton records.
+ */
+
+enum state {
+ STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
+};
+
+/*
+ * A data structure of the following type is kept for each widget managed by
+ * this file:
+ */
+
+typedef struct {
+ Tk_Window tkwin; /* Window that embodies the widget. NULL means
+ * that the window has been destroyed but the
+ * data structures haven't yet been cleaned
+ * up. */
+ Display *display; /* Display containing widget. Needed, among
+ * other things, so that resources can bee
+ * freed up even after tkwin has gone away. */
+ Tcl_Interp *interp; /* Interpreter associated with menubutton. */
+ Tcl_Command widgetCmd; /* Token for menubutton's widget command. */
+ Tk_OptionTable optionTable; /* Table that defines configuration options
+ * available for this widget. */
+ char *menuName; /* Name of menu associated with widget.
+ * Malloc-ed. */
+
+ /*
+ * Information about what's displayed in the menu button:
+ */
+
+ char *text; /* Text to display in button (malloc'ed) or
+ * NULL. */
+ int underline; /* Index of character to underline. */
+ char *textVarName; /* Name of variable (malloc'ed) or NULL. If
+ * non-NULL, button displays the contents of
+ * this variable. */
+ Pixmap bitmap; /* Bitmap to display or None. If not None then
+ * text and textVar and underline are
+ * ignored. */
+ char *imageString; /* Name of image to display (malloc'ed), or
+ * NULL. If non-NULL, bitmap, text, and
+ * textVarName are ignored. */
+ Tk_Image image; /* Image to display in window, or NULL if
+ * none. */
+
+ /*
+ * Information used when displaying widget:
+ */
+
+ enum state state; /* State of button for display purposes:
+ * normal, active, or disabled. */
+ Tk_3DBorder normalBorder; /* Structure used to draw 3-D border and
+ * background when window isn't active. NULL
+ * means no such border exists. */
+ Tk_3DBorder activeBorder; /* Structure used to draw 3-D border and
+ * background when window is active. NULL
+ * means no such border exists. */
+ int borderWidth; /* Width of border. */
+ int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
+ int highlightWidth; /* Width in pixels of highlight to draw around
+ * widget when it has the focus. <= 0 means
+ * don't draw a highlight. */
+ XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area
+ * when highlight is off. */
+ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
+ int inset; /* Total width of all borders, including
+ * traversal highlight and 3-D border.
+ * Indicates how much interior stuff must be
+ * offset from outside edges to leave room for
+ * borders. */
+ Tk_Font tkfont; /* Information about text font, or NULL. */
+ XColor *normalFg; /* Foreground color in normal mode. */
+ XColor *activeFg; /* Foreground color in active mode. NULL means
+ * use normalFg instead. */
+ XColor *disabledFg; /* Foreground color when disabled. NULL means
+ * use normalFg with a 50% stipple instead. */
+ GC normalTextGC; /* GC for drawing text in normal mode. */
+ GC activeTextGC; /* GC for drawing text in active mode (NULL
+ * means use normalTextGC). */
+ Pixmap gray; /* Pixmap for displaying disabled text/icon if
+ * disabledFg is NULL. */
+ GC disabledGC; /* Used to produce disabled effect for
+ * text. */
+ GC stippleGC; /* Used to produce disabled stipple effect for
+ * images when disabled. */
+ int leftBearing; /* Distance from text origin to leftmost drawn
+ * pixel (positive means to right). */
+ int rightBearing; /* Amount text sticks right from its
+ * origin. */
+ char *widthString; /* Value of -width option. Malloc'ed. */
+ char *heightString; /* Value of -height option. Malloc'ed. */
+ int width, height; /* If > 0, these specify dimensions to request
+ * for window, in characters for text and in
+ * pixels for bitmaps. In this case the actual
+ * size of the text string or bitmap is
+ * ignored in computing desired window
+ * size. */
+ int wrapLength; /* Line length (in pixels) at which to wrap
+ * onto next line. <= 0 means don't wrap
+ * except at newlines. */
+ int padX, padY; /* Extra space around text or bitmap (pixels
+ * on each side). */
+ Tk_Anchor anchor; /* Where text/bitmap should be displayed
+ * inside window region. */
+ Tk_Justify justify; /* Justification to use for multi-line
+ * text. */
+ int textWidth; /* Width needed to display text as requested,
+ * in pixels. */
+ int textHeight; /* Height needed to display text as requested,
+ * in pixels. */
+ Tk_TextLayout textLayout; /* Saved text layout information. */
+ int indicatorOn; /* Non-zero means display indicator; 0 means
+ * don't display. */
+ int indicatorHeight; /* Height of indicator in pixels. This same
+ * amount of extra space is also left on each
+ * side of the indicator. 0 if no
+ * indicator. */
+ int indicatorWidth; /* Width of indicator in pixels, including
+ * indicatorHeight in padding on each side. 0
+ * if no indicator. */
+
+ /*
+ * Miscellaneous information:
+ */
+
+ int compound; /* Value of -compound option; specifies
+ * whether the menubutton should show both an
+ * image and text, and, if so, how. */
+ enum direction direction; /* Direction for where to pop the menu. Valid
+ * directions are "above", "below", "left",
+ * "right", and "flush". "flush" means that
+ * the upper left corner of the menubutton is
+ * where the menu pops up. "above" and "below"
+ * will attempt to pop the menu compleletly
+ * above or below the menu respectively.
+ * "left" and "right" will pop the menu left
+ * or right, and the active item will be next
+ * to the button. */
+ Tk_Cursor cursor; /* Current cursor for window, or None. */
+ char *takeFocus; /* Value of -takefocus option; not used in the
+ * C code, but used by keyboard traversal
+ * scripts. Malloc'ed, but may be NULL. */
+ int flags; /* Various flags; see below for
+ * definitions. */
+} TkMenuButton;
+
+/*
+ * Flag bits for buttons:
+ *
+ * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
+ * already been queued to redraw this window.
+ * POSTED: Non-zero means that the menu associated with
+ * this button has been posted (typically because
+ * of an active button press).
+ * GOT_FOCUS: Non-zero means this button currently has the
+ * input focus.
+ */
+
+#define REDRAW_PENDING 1
+#define POSTED 2
+#define GOT_FOCUS 4
+
+/*
+ * The following constants define the dimensions of the cascade indicator,
+ * which is displayed if the "-indicatoron" option is true. The units for
+ * these options are 1/10 millimeters.
+ */
+
+#define INDICATOR_WIDTH 40
+#define INDICATOR_HEIGHT 17
+
+/*
+ * Declaration of variables shared between the files in the button module.
+ */
+
+MODULE_SCOPE Tk_ClassProcs tkpMenubuttonClass;
+
+/*
+ * Declaration of procedures used in the implementation of the button widget.
+ */
+
+MODULE_SCOPE void TkpComputeMenuButtonGeometry(TkMenuButton *mbPtr);
+MODULE_SCOPE TkMenuButton *TkpCreateMenuButton(Tk_Window tkwin);
+MODULE_SCOPE void TkpDisplayMenuButton(ClientData clientData);
+MODULE_SCOPE void TkpDestroyMenuButton(TkMenuButton *mbPtr);
+MODULE_SCOPE void TkMenuButtonWorldChanged(ClientData instanceData);
+
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+
+#endif /* _TKMENUBUTTON */
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
index 5ce2fa5..f005290 100644
--- a/generic/tkSelect.h
+++ b/generic/tkSelect.h
@@ -1,173 +1,173 @@
-/*
- * tkSelect.h --
- *
- * Declarations of types shared among the files that implement selection
- * support.
- *
- * Copyright (c) 1995 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkSelect.h,v 1.7 2007/06/24 16:07:35 dkf Exp $
- */
-
-#ifndef _TKSELECT
-#define _TKSELECT
-
-/*
- * When a selection is owned by a window on a given display, one of the
- * following structures is present on a list of current selections in the
- * display structure. The structure is used to record the current owner of a
- * selection for use in later retrieval requests. There is a list of such
- * structures because a display can have multiple different selections active
- * at the same time.
- */
-
-typedef struct TkSelectionInfo {
- Atom selection; /* Selection name, e.g. XA_PRIMARY. */
- Tk_Window owner; /* Current owner of this selection. */
- int serial; /* Serial number of last XSelectionSetOwner
- * request made to server for this selection
- * (used to filter out redundant
- * SelectionClear events). */
- Time time; /* Timestamp used to acquire selection. */
- Tk_LostSelProc *clearProc; /* Procedure to call when owner loses
- * selection. */
- ClientData clearData; /* Info to pass to clearProc. */
- struct TkSelectionInfo *nextPtr;
- /* Next in list of current selections on this
- * display. NULL means end of list. */
-} TkSelectionInfo;
-
-/*
- * One of the following structures exists for each selection handler created
- * for a window by calling Tk_CreateSelHandler. The handlers are linked in a
- * list rooted in the TkWindow structure.
- */
-
-typedef struct TkSelHandler {
- Atom selection; /* Selection name, e.g. XA_PRIMARY. */
- Atom target; /* Target type for selection conversion, such
- * as TARGETS or STRING. */
- Atom format; /* Format in which selection info will be
- * returned, such as STRING or ATOM. */
- Tk_SelectionProc *proc; /* Procedure to generate selection in this
- * format. */
- ClientData clientData; /* Argument to pass to proc. */
- int size; /* Size of units returned by proc (8 for
- * STRING, 32 for almost anything else). */
- struct TkSelHandler *nextPtr;
- /* Next selection handler associated with same
- * window (NULL for end of list). */
-} TkSelHandler;
-
-/*
- * When the selection is being retrieved, one of the following structures is
- * present on a list of pending selection retrievals. The structure is used to
- * communicate between the background procedure that requests the selection
- * and the foreground event handler that processes the events in which the
- * selection is returned. There is a list of such structures so that there can
- * be multiple simultaneous selection retrievals (e.g. on different displays).
- */
-
-typedef struct TkSelRetrievalInfo {
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- TkWindow *winPtr; /* Window used as requestor for selection. */
- Atom selection; /* Selection being requested. */
- Atom property; /* Property where selection will appear. */
- Atom target; /* Desired form for selection. */
- int (*proc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp,
- char *portion)); /* Procedure to call to handle pieces of
- * selection. */
- ClientData clientData; /* Argument for proc. */
- int result; /* Initially -1. Set to a Tcl return value
- * once the selection has been retrieved. */
- Tcl_TimerToken timeout; /* Token for current timeout procedure. */
- int idleTime; /* Number of seconds that have gone by without
- * hearing anything from the selection
- * owner. */
- Tcl_EncodingState encState; /* Holds intermediate state during translations
- * of data that cross buffer boundaries. */
- int encFlags; /* Encoding translation state flags. */
- Tcl_DString buf; /* Buffer to hold translation data. */
- struct TkSelRetrievalInfo *nextPtr;
- /* Next in list of all pending selection
- * retrievals. NULL means end of list. */
-} TkSelRetrievalInfo;
-
-/*
- * The clipboard contains a list of buffers of various types and formats. All
- * of the buffers of a given type will be returned in sequence when the
- * CLIPBOARD selection is retrieved. All buffers of a given type on the same
- * clipboard must have the same format. The TkClipboardTarget structure is
- * used to record the information about a chain of buffers of the same type.
- */
-
-typedef struct TkClipboardBuffer {
- char *buffer; /* Null terminated data buffer. */
- long length; /* Length of string in buffer. */
- struct TkClipboardBuffer *nextPtr;
- /* Next in list of buffers. NULL means end of
- * list . */
-} TkClipboardBuffer;
-
-typedef struct TkClipboardTarget {
- Atom type; /* Type conversion supported. */
- Atom format; /* Representation used for data. */
- TkClipboardBuffer *firstBufferPtr;
- /* First in list of data buffers. */
- TkClipboardBuffer *lastBufferPtr;
- /* Last in list of clipboard buffers. Used to
- * speed up appends. */
- struct TkClipboardTarget *nextPtr;
- /* Next in list of targets on clipboard. NULL
- * means end of list. */
-} TkClipboardTarget;
-
-/*
- * It is possible for a Tk_SelectionProc to delete the handler that it
- * represents. If this happens, the code that is retrieving the selection
- * needs to know about it so it doesn't use the now-defunct handler structure.
- * One structure of the following form is created for each retrieval in
- * progress, so that the retriever can find out if its handler is deleted. All
- * of the pending retrievals (if there are more than one) are linked into a
- * list.
- */
-
-typedef struct TkSelInProgress {
- TkSelHandler *selPtr; /* Handler being executed. If this handler is
- * deleted, the field is set to NULL. */
- struct TkSelInProgress *nextPtr;
- /* Next higher nested search. */
-} TkSelInProgress;
-
-/*
- * Chunk size for retrieving selection. It's defined both in words and in
- * bytes; the word size is used to allocate buffer space that's guaranteed to
- * be word-aligned and that has an extra character for the terminating NULL.
- */
-
-#define TK_SEL_BYTES_AT_ONCE 4000
-#define TK_SEL_WORDS_AT_ONCE 1001
-
-/*
- * Declarations for procedures that are used by the selection-related files
- * but shouldn't be used anywhere else in Tk (or by Tk clients):
- */
-
-MODULE_SCOPE TkSelInProgress *TkSelGetInProgress(void);
-MODULE_SCOPE void TkSelSetInProgress(TkSelInProgress *pendingPtr);
-MODULE_SCOPE void TkSelClearSelection(Tk_Window tkwin, XEvent *eventPtr);
-MODULE_SCOPE int TkSelDefaultSelection(TkSelectionInfo *infoPtr,
- Atom target, char *buffer, int maxBytes,
- Atom *typePtr);
-MODULE_SCOPE int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin,
- Atom selection, Atom target, Tk_GetSelProc *proc,
- ClientData clientData);
-#ifndef TkSelUpdateClipboard
-MODULE_SCOPE void TkSelUpdateClipboard(TkWindow *winPtr,
- TkClipboardTarget *targetPtr);
-#endif
-
-#endif /* _TKSELECT */
+/*
+ * tkSelect.h --
+ *
+ * Declarations of types shared among the files that implement selection
+ * support.
+ *
+ * Copyright (c) 1995 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkSelect.h,v 1.8 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#ifndef _TKSELECT
+#define _TKSELECT
+
+/*
+ * When a selection is owned by a window on a given display, one of the
+ * following structures is present on a list of current selections in the
+ * display structure. The structure is used to record the current owner of a
+ * selection for use in later retrieval requests. There is a list of such
+ * structures because a display can have multiple different selections active
+ * at the same time.
+ */
+
+typedef struct TkSelectionInfo {
+ Atom selection; /* Selection name, e.g. XA_PRIMARY. */
+ Tk_Window owner; /* Current owner of this selection. */
+ int serial; /* Serial number of last XSelectionSetOwner
+ * request made to server for this selection
+ * (used to filter out redundant
+ * SelectionClear events). */
+ Time time; /* Timestamp used to acquire selection. */
+ Tk_LostSelProc *clearProc; /* Procedure to call when owner loses
+ * selection. */
+ ClientData clearData; /* Info to pass to clearProc. */
+ struct TkSelectionInfo *nextPtr;
+ /* Next in list of current selections on this
+ * display. NULL means end of list. */
+} TkSelectionInfo;
+
+/*
+ * One of the following structures exists for each selection handler created
+ * for a window by calling Tk_CreateSelHandler. The handlers are linked in a
+ * list rooted in the TkWindow structure.
+ */
+
+typedef struct TkSelHandler {
+ Atom selection; /* Selection name, e.g. XA_PRIMARY. */
+ Atom target; /* Target type for selection conversion, such
+ * as TARGETS or STRING. */
+ Atom format; /* Format in which selection info will be
+ * returned, such as STRING or ATOM. */
+ Tk_SelectionProc *proc; /* Procedure to generate selection in this
+ * format. */
+ ClientData clientData; /* Argument to pass to proc. */
+ int size; /* Size of units returned by proc (8 for
+ * STRING, 32 for almost anything else). */
+ struct TkSelHandler *nextPtr;
+ /* Next selection handler associated with same
+ * window (NULL for end of list). */
+} TkSelHandler;
+
+/*
+ * When the selection is being retrieved, one of the following structures is
+ * present on a list of pending selection retrievals. The structure is used to
+ * communicate between the background procedure that requests the selection
+ * and the foreground event handler that processes the events in which the
+ * selection is returned. There is a list of such structures so that there can
+ * be multiple simultaneous selection retrievals (e.g. on different displays).
+ */
+
+typedef struct TkSelRetrievalInfo {
+ Tcl_Interp *interp; /* Interpreter for error reporting. */
+ TkWindow *winPtr; /* Window used as requestor for selection. */
+ Atom selection; /* Selection being requested. */
+ Atom property; /* Property where selection will appear. */
+ Atom target; /* Desired form for selection. */
+ int (*proc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp,
+ char *portion)); /* Procedure to call to handle pieces of
+ * selection. */
+ ClientData clientData; /* Argument for proc. */
+ int result; /* Initially -1. Set to a Tcl return value
+ * once the selection has been retrieved. */
+ Tcl_TimerToken timeout; /* Token for current timeout procedure. */
+ int idleTime; /* Number of seconds that have gone by without
+ * hearing anything from the selection
+ * owner. */
+ Tcl_EncodingState encState; /* Holds intermediate state during translations
+ * of data that cross buffer boundaries. */
+ int encFlags; /* Encoding translation state flags. */
+ Tcl_DString buf; /* Buffer to hold translation data. */
+ struct TkSelRetrievalInfo *nextPtr;
+ /* Next in list of all pending selection
+ * retrievals. NULL means end of list. */
+} TkSelRetrievalInfo;
+
+/*
+ * The clipboard contains a list of buffers of various types and formats. All
+ * of the buffers of a given type will be returned in sequence when the
+ * CLIPBOARD selection is retrieved. All buffers of a given type on the same
+ * clipboard must have the same format. The TkClipboardTarget structure is
+ * used to record the information about a chain of buffers of the same type.
+ */
+
+typedef struct TkClipboardBuffer {
+ char *buffer; /* Null terminated data buffer. */
+ long length; /* Length of string in buffer. */
+ struct TkClipboardBuffer *nextPtr;
+ /* Next in list of buffers. NULL means end of
+ * list . */
+} TkClipboardBuffer;
+
+typedef struct TkClipboardTarget {
+ Atom type; /* Type conversion supported. */
+ Atom format; /* Representation used for data. */
+ TkClipboardBuffer *firstBufferPtr;
+ /* First in list of data buffers. */
+ TkClipboardBuffer *lastBufferPtr;
+ /* Last in list of clipboard buffers. Used to
+ * speed up appends. */
+ struct TkClipboardTarget *nextPtr;
+ /* Next in list of targets on clipboard. NULL
+ * means end of list. */
+} TkClipboardTarget;
+
+/*
+ * It is possible for a Tk_SelectionProc to delete the handler that it
+ * represents. If this happens, the code that is retrieving the selection
+ * needs to know about it so it doesn't use the now-defunct handler structure.
+ * One structure of the following form is created for each retrieval in
+ * progress, so that the retriever can find out if its handler is deleted. All
+ * of the pending retrievals (if there are more than one) are linked into a
+ * list.
+ */
+
+typedef struct TkSelInProgress {
+ TkSelHandler *selPtr; /* Handler being executed. If this handler is
+ * deleted, the field is set to NULL. */
+ struct TkSelInProgress *nextPtr;
+ /* Next higher nested search. */
+} TkSelInProgress;
+
+/*
+ * Chunk size for retrieving selection. It's defined both in words and in
+ * bytes; the word size is used to allocate buffer space that's guaranteed to
+ * be word-aligned and that has an extra character for the terminating NULL.
+ */
+
+#define TK_SEL_BYTES_AT_ONCE 4000
+#define TK_SEL_WORDS_AT_ONCE 1001
+
+/*
+ * Declarations for procedures that are used by the selection-related files
+ * but shouldn't be used anywhere else in Tk (or by Tk clients):
+ */
+
+MODULE_SCOPE TkSelInProgress *TkSelGetInProgress(void);
+MODULE_SCOPE void TkSelSetInProgress(TkSelInProgress *pendingPtr);
+MODULE_SCOPE void TkSelClearSelection(Tk_Window tkwin, XEvent *eventPtr);
+MODULE_SCOPE int TkSelDefaultSelection(TkSelectionInfo *infoPtr,
+ Atom target, char *buffer, int maxBytes,
+ Atom *typePtr);
+MODULE_SCOPE int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin,
+ Atom selection, Atom target, Tk_GetSelProc *proc,
+ ClientData clientData);
+#ifndef TkSelUpdateClipboard
+MODULE_SCOPE void TkSelUpdateClipboard(TkWindow *winPtr,
+ TkClipboardTarget *targetPtr);
+#endif
+
+#endif /* _TKSELECT */
diff --git a/generic/tkUndo.h b/generic/tkUndo.h
index c4c83a4..06f0d8b 100644
--- a/generic/tkUndo.h
+++ b/generic/tkUndo.h
@@ -1,123 +1,123 @@
-/*
- * tkUndo.h --
- *
- * Declarations shared among the files that implement an undo stack.
- *
- * Copyright (c) 2002 Ludwig Callewaert.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkUndo.h,v 1.6 2007/06/24 16:07:35 dkf Exp $
- */
-
-#ifndef _TKUNDO
-#define _TKUNDO
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Enum definining the types used in an undo stack.
- */
-
-typedef enum {
- TK_UNDO_SEPARATOR, /* Marker */
- TK_UNDO_ACTION /* Command */
-} TkUndoAtomType;
-
-/*
- * Callback proc type to carry out an undo or redo action via C code. (Actions
- * can also be defined by Tcl scripts).
- */
-
-typedef int (TkUndoProc)(Tcl_Interp *interp, ClientData clientData,
- Tcl_Obj *objPtr);
-
-/*
- * Struct defining a single action, one or more of which may be defined (and
- * stored in a linked list) separately for each undo and redo action of an
- * undo atom.
- */
-
-typedef struct TkUndoSubAtom {
- Tcl_Command command; /* Tcl token used to get the current Tcl
- * command name which will be used to execute
- * apply/revert scripts. If NULL then it is
- * assumed the apply/revert scripts already
- * contain everything. */
- TkUndoProc *funcPtr; /* Function pointer for callback to perform
- * undo/redo actions. */
- ClientData clientData; /* Data for 'funcPtr'. */
- Tcl_Obj *action; /* Command to apply the action that was
- * taken. */
- struct TkUndoSubAtom *next; /* Pointer to the next element in the linked
- * list. */
-} TkUndoSubAtom;
-
-/*
- * Struct representing a single undo+redo atom to be placed in the stack.
- */
-
-typedef struct TkUndoAtom {
- TkUndoAtomType type; /* The type that will trigger the required
- * action. */
- TkUndoSubAtom *apply; /* Linked list of 'apply' actions to perform
- * for this operation. */
- TkUndoSubAtom *revert; /* Linked list of 'revert' actions to perform
- * for this operation. */
- struct TkUndoAtom *next; /* Pointer to the next element in the
- * stack. */
-} TkUndoAtom;
-
-/*
- * Struct defining a single undo+redo stack.
- */
-
-typedef struct TkUndoRedoStack {
- TkUndoAtom *undoStack; /* The undo stack. */
- TkUndoAtom *redoStack; /* The redo stack. */
- Tcl_Interp *interp; /* The interpreter in which to execute the
- * revert and apply scripts. */
- int maxdepth;
- int depth;
-} TkUndoRedoStack;
-
-/*
- * Basic functions.
- */
-
-MODULE_SCOPE void TkUndoPushStack(TkUndoAtom **stack, TkUndoAtom *elem);
-MODULE_SCOPE TkUndoAtom *TkUndoPopStack(TkUndoAtom **stack);
-MODULE_SCOPE int TkUndoInsertSeparator(TkUndoAtom **stack);
-MODULE_SCOPE void TkUndoClearStack(TkUndoAtom **stack);
-
-/*
- * Functions for working on an undo/redo stack.
- */
-
-MODULE_SCOPE TkUndoRedoStack *TkUndoInitStack(Tcl_Interp *interp, int maxdepth);
-MODULE_SCOPE void TkUndoSetDepth(TkUndoRedoStack *stack, int maxdepth);
-MODULE_SCOPE void TkUndoClearStacks(TkUndoRedoStack *stack);
-MODULE_SCOPE void TkUndoFreeStack(TkUndoRedoStack *stack);
-MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack);
-MODULE_SCOPE TkUndoSubAtom *TkUndoMakeCmdSubAtom(Tcl_Command command,
- Tcl_Obj *actionScript, TkUndoSubAtom *subAtomList);
-MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr,
- ClientData clientData, Tcl_Obj *actionScript,
- TkUndoSubAtom *subAtomList);
-MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack,
- TkUndoSubAtom *apply, TkUndoSubAtom *revert);
-MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack);
-MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack);
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKUNDO */
+/*
+ * tkUndo.h --
+ *
+ * Declarations shared among the files that implement an undo stack.
+ *
+ * Copyright (c) 2002 Ludwig Callewaert.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tkUndo.h,v 1.7 2007/06/25 19:07:15 dgp Exp $
+ */
+
+#ifndef _TKUNDO
+#define _TKUNDO
+
+#ifndef _TKINT
+#include "tkInt.h"
+#endif
+
+#ifdef BUILD_tk
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLEXPORT
+#endif
+
+/*
+ * Enum definining the types used in an undo stack.
+ */
+
+typedef enum {
+ TK_UNDO_SEPARATOR, /* Marker */
+ TK_UNDO_ACTION /* Command */
+} TkUndoAtomType;
+
+/*
+ * Callback proc type to carry out an undo or redo action via C code. (Actions
+ * can also be defined by Tcl scripts).
+ */
+
+typedef int (TkUndoProc)(Tcl_Interp *interp, ClientData clientData,
+ Tcl_Obj *objPtr);
+
+/*
+ * Struct defining a single action, one or more of which may be defined (and
+ * stored in a linked list) separately for each undo and redo action of an
+ * undo atom.
+ */
+
+typedef struct TkUndoSubAtom {
+ Tcl_Command command; /* Tcl token used to get the current Tcl
+ * command name which will be used to execute
+ * apply/revert scripts. If NULL then it is
+ * assumed the apply/revert scripts already
+ * contain everything. */
+ TkUndoProc *funcPtr; /* Function pointer for callback to perform
+ * undo/redo actions. */
+ ClientData clientData; /* Data for 'funcPtr'. */
+ Tcl_Obj *action; /* Command to apply the action that was
+ * taken. */
+ struct TkUndoSubAtom *next; /* Pointer to the next element in the linked
+ * list. */
+} TkUndoSubAtom;
+
+/*
+ * Struct representing a single undo+redo atom to be placed in the stack.
+ */
+
+typedef struct TkUndoAtom {
+ TkUndoAtomType type; /* The type that will trigger the required
+ * action. */
+ TkUndoSubAtom *apply; /* Linked list of 'apply' actions to perform
+ * for this operation. */
+ TkUndoSubAtom *revert; /* Linked list of 'revert' actions to perform
+ * for this operation. */
+ struct TkUndoAtom *next; /* Pointer to the next element in the
+ * stack. */
+} TkUndoAtom;
+
+/*
+ * Struct defining a single undo+redo stack.
+ */
+
+typedef struct TkUndoRedoStack {
+ TkUndoAtom *undoStack; /* The undo stack. */
+ TkUndoAtom *redoStack; /* The redo stack. */
+ Tcl_Interp *interp; /* The interpreter in which to execute the
+ * revert and apply scripts. */
+ int maxdepth;
+ int depth;
+} TkUndoRedoStack;
+
+/*
+ * Basic functions.
+ */
+
+MODULE_SCOPE void TkUndoPushStack(TkUndoAtom **stack, TkUndoAtom *elem);
+MODULE_SCOPE TkUndoAtom *TkUndoPopStack(TkUndoAtom **stack);
+MODULE_SCOPE int TkUndoInsertSeparator(TkUndoAtom **stack);
+MODULE_SCOPE void TkUndoClearStack(TkUndoAtom **stack);
+
+/*
+ * Functions for working on an undo/redo stack.
+ */
+
+MODULE_SCOPE TkUndoRedoStack *TkUndoInitStack(Tcl_Interp *interp, int maxdepth);
+MODULE_SCOPE void TkUndoSetDepth(TkUndoRedoStack *stack, int maxdepth);
+MODULE_SCOPE void TkUndoClearStacks(TkUndoRedoStack *stack);
+MODULE_SCOPE void TkUndoFreeStack(TkUndoRedoStack *stack);
+MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack);
+MODULE_SCOPE TkUndoSubAtom *TkUndoMakeCmdSubAtom(Tcl_Command command,
+ Tcl_Obj *actionScript, TkUndoSubAtom *subAtomList);
+MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr,
+ ClientData clientData, Tcl_Obj *actionScript,
+ TkUndoSubAtom *subAtomList);
+MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack,
+ TkUndoSubAtom *apply, TkUndoSubAtom *revert);
+MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack);
+MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack);
+
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+
+#endif /* _TKUNDO */