From b699b7f784bb3d3a71abd9a58580388514f4566e Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 24 Jun 2007 16:07:34 +0000 Subject: Cleaning up whitespace, comments, declarations. No functional changes. --- generic/tkArgv.c | 847 ++++++++++++++++++++++++------------------------- generic/tkButton.h | 647 ++++++++++++++++++------------------- generic/tkCanvas.h | 614 +++++++++++++++++------------------ generic/tkColor.h | 170 +++++----- generic/tkFont.c | 36 +-- generic/tkImgPhoto.c | 301 ++++++++---------- generic/tkInt.h | 34 +- generic/tkMenu.c | 155 +++++---- generic/tkMenu.h | 41 ++- generic/tkMenubutton.c | 84 ++--- generic/tkMenubutton.h | 459 ++++++++++++++------------- generic/tkOption.c | 60 ++-- generic/tkPlace.c | 73 +++-- generic/tkScale.c | 87 +++-- generic/tkSelect.h | 346 ++++++++++---------- generic/tkText.h | 156 +++++---- generic/tkUndo.h | 245 +++++++------- 17 files changed, 2160 insertions(+), 2195 deletions(-) diff --git a/generic/tkArgv.c b/generic/tkArgv.c index c1eb479..d0bfd77 100644 --- a/generic/tkArgv.c +++ b/generic/tkArgv.c @@ -1,426 +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.5 2005/11/04 11:52:50 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; - } else { - *((CONST char **)infoPtr->dst) = argv[srcIndex]; - srcIndex++; - argc--; - } - break; - case TK_ARGV_UID: - if (argc == 0) { - goto missingArg; - } else { - *((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; - - handlerProc = (ArgvFunc *) infoPtr->src; - if ((*handlerProc)(infoPtr->dst, infoPtr->key, argv[srcIndex])) { - srcIndex += 1; - argc -= 1; - } - break; - } - case TK_ARGV_GENFUNC: { - typedef int (ArgvGenFunc)(char *, Tcl_Interp *, char *, int, - CONST char **); - ArgvGenFunc *handlerProc; - - 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.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: + */ diff --git a/generic/tkButton.h b/generic/tkButton.h index def38c2..f753127 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -1,323 +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.13 2005/11/27 02:36:13 das 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.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 */ diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index de1aaf2..6fbb5e0 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -1,306 +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.9 2005/11/27 02:36:13 das 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.10 2007/06/24 16:07:34 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 */ diff --git a/generic/tkColor.h b/generic/tkColor.h index 71e02ee..e2d9aff 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.8 2005/11/27 02:36:13 das Exp $ - */ - -#ifndef _TKCOLOR -#define _TKCOLOR - -#include - -#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.9 2007/06/24 16:07:34 dkf Exp $ + */ + +#ifndef _TKCOLOR +#define _TKCOLOR + +#include + +#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/tkFont.c b/generic/tkFont.c index dac1ede..450061f 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkFont.c,v 1.36 2007/05/31 13:31:26 das Exp $ + * RCS: @(#) $Id: tkFont.c,v 1.37 2007/06/24 16:07:34 dkf Exp $ */ #include "tkPort.h" @@ -994,8 +994,8 @@ TkCreateNamedFont( * * TkDeleteNamedFont -- * - * Delete the named font. If there are still widgets using this - * font, then it isn't deleted right away. + * Delete the named font. If there are still widgets using this font, + * then it isn't deleted right away. * *--------------------------------------------------------------------------- */ @@ -1009,13 +1009,13 @@ TkDeleteNamedFont( TkFontInfo *fiPtr; NamedFont *nfPtr; Tcl_HashEntry *namedHashPtr; - + fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, name); if (namedHashPtr == NULL) { Tcl_AppendResult(interp, "named font \"", name, - "\" doesn't exist", (char *) NULL); + "\" doesn't exist", NULL); return TCL_ERROR; } nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr); @@ -1749,14 +1749,12 @@ Tk_PostscriptFontName( slantString = NULL; if (fontPtr->fa.slant == TK_FS_ROMAN) { ; + } else if ((strcmp(family, "Helvetica") == 0) + || (strcmp(family, "Courier") == 0) + || (strcmp(family, "AvantGarde") == 0)) { + slantString = "Oblique"; } else { - if ((strcmp(family, "Helvetica") == 0) - || (strcmp(family, "Courier") == 0) - || (strcmp(family, "AvantGarde") == 0)) { - slantString = "Oblique"; - } else { - slantString = "Italic"; - } + slantString = "Italic"; } /* @@ -1856,9 +1854,7 @@ Tk_UnderlineChars( int lastByte) /* Index of first byte after the last * character. */ { - TkFont *fontPtr; - - fontPtr = (TkFont *) tkfont; + TkFont *fontPtr = (TkFont *) tkfont; TkUnderlineCharsInContext(display, drawable, gc, tkfont, string, lastByte, x, y, firstByte, lastByte); @@ -2777,10 +2773,10 @@ Tk_IntersectTextLayout( chunkPtr = layoutPtr->chunks; fontPtr = (TkFont *) layoutPtr->tkfont; - left = x; - top = y; - right = x + width; - bottom = y + height; + left = x; + top = y; + right = x + width; + bottom = y + height; result = 0; for (i = 0; i < layoutPtr->numChunks; i++) { @@ -2827,7 +2823,7 @@ Tk_IntersectTextLayout( * lines in the text layout will be rendered by the user supplied * Postscript function. The function should be of the form: * - * justify x y string function -- + * justify x y string function -- * * Justify is -1, 0, or 1, depending on whether the following string * should be left, center, or right justified, x and y is the location diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 15662eb..6b4132b 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.70 2007/06/23 00:25:38 das Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.71 2007/06/24 16:07:34 dkf Exp $ */ #include "tkInt.h" @@ -79,7 +79,7 @@ typedef unsigned int pixel; */ typedef struct { - Display *display; /* Qualifies the colormap resource ID */ + Display *display; /* Qualifies the colormap resource ID. */ Colormap colormap; /* Colormap that the windows are using. */ double gamma; /* Gamma exponent value for images. */ Tk_Uid palette; /* Specifies how many shades of each primary @@ -106,8 +106,8 @@ typedef struct ColorTable { pixel redValues[256]; /* Maps 8-bit values of red intensity to a * pixel value or index in pixelMap. */ - pixel greenValues[256]; /* Ditto for green intensity */ - pixel blueValues[256]; /* Ditto for blue intensity */ + pixel greenValues[256]; /* Ditto for green intensity. */ + pixel blueValues[256]; /* Ditto for blue intensity. */ unsigned long *pixelMap; /* Actual pixel values allocated. */ unsigned char colorQuant[3][256]; @@ -240,7 +240,8 @@ struct SubcommandOptions { int subsampleX, subsampleY; /* Values specified for -subsample option. */ Tcl_Obj *format; /* Value specified for -format option. */ XColor *background; /* Value specified for -background option. */ - int compositingRule; /* Value specified for -compositingrule opt */ + int compositingRule; /* Value specified for -compositingrule + * option. */ }; /* @@ -329,7 +330,7 @@ Tk_ImageType tkPhotoImageType = { ImgPhotoFree, /* freeProc */ ImgPhotoDelete, /* deleteProc */ ImgPhotoPostscript, /* postscriptProc */ - NULL /* nextPtr */ + NULL /* nextPtr */ }; typedef struct ThreadSpecificData { @@ -405,8 +406,8 @@ static int ImgPhotoConfigureMaster(Tcl_Interp *interp, PhotoMaster *masterPtr, int objc, Tcl_Obj *const objv[], int flags); static void ImgPhotoConfigureInstance(PhotoInstance *instancePtr); -static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr); -static void ImgPhotoBlendComplexAlpha(XImage *bgImg, +static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr); +static void ImgPhotoBlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr, int xOffset, int yOffset, int width, int height); static int ImgPhotoSetSize(PhotoMaster *masterPtr, int width, @@ -468,7 +469,7 @@ PhotoFormatThreadExitProc( { Tk_PhotoImageFormat *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); while (tsdPtr->oldFormatList != NULL) { freePtr = tsdPtr->oldFormatList; @@ -513,7 +514,7 @@ Tk_CreateOldPhotoImageFormat( { Tk_PhotoImageFormat *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -537,7 +538,7 @@ Tk_CreatePhotoImageFormat( { Tk_PhotoImageFormat *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -642,7 +643,6 @@ ImgPhotoCmd( int objc, /* Number of arguments. */ Tcl_Obj *CONST objv[]) /* Argument objects. */ { - int oldformat = 0; static const char *photoOptions[] = { "blank", "cget", "configure", "copy", "data", "get", "put", "read", "redither", "transparency", "write", NULL @@ -654,22 +654,18 @@ ImgPhotoCmd( }; PhotoMaster *masterPtr = (PhotoMaster *) clientData; - int result, index; - int x, y, width, height; - int dataWidth, dataHeight; + int result, index, x, y, width, height, dataWidth, dataHeight, listObjc; struct SubcommandOptions options; - int listObjc; Tcl_Obj **listObjv, **srcObjv; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight; - int matched, length; + int imageWidth, imageHeight, matched, length, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); @@ -1239,15 +1235,15 @@ ImgPhotoCmd( return TCL_ERROR; } - /* - * Prevent file system access in safe interpreters. - */ + /* + * Prevent file system access in safe interpreters. + */ - if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't get image from a file in a", + if (Tcl_IsSafe(interp)) { + Tcl_AppendResult(interp, "can't get image from a file in a", " safe interpreter", NULL); - return TCL_ERROR; - } + return TCL_ERROR; + } /* * Open the image file and look for a handler for it. @@ -1258,16 +1254,16 @@ ImgPhotoCmd( if (chan == NULL) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { Tcl_Close(NULL, chan); - return TCL_ERROR; - } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") + return TCL_ERROR; + } + if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { Tcl_Close(NULL, chan); - return TCL_ERROR; - } + return TCL_ERROR; + } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, &imageFormat, @@ -1489,15 +1485,15 @@ ImgPhotoCmd( char *data; Tcl_Obj *format; - /* - * Prevent file system access in safe interpreters. - */ + /* + * Prevent file system access in safe interpreters. + */ - if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't write image to a file in a", + if (Tcl_IsSafe(interp)) { + Tcl_AppendResult(interp, "can't write image to a file in a", " safe interpreter", NULL); - return TCL_ERROR; - } + return TCL_ERROR; + } /* * photo write command - first parse and check any options given. @@ -1638,11 +1634,9 @@ ParseSubcommandOptions( int objc, /* Number of arguments in objv[]. */ Tcl_Obj *const objv[]) /* Arguments to be parsed. */ { - int index, c, bit, currentBit; - int length; + int index, c, bit, currentBit, length; + int values[4], numValues, maxValues, argIndex; char *option, **listPtr; - int values[4]; - int numValues, maxValues, argIndex; for (index = *optIndexPtr; index < objc; *optIndexPtr = ++index) { /* @@ -1775,7 +1769,7 @@ ParseSubcommandOptions( if (argIndex >= objc) { break; } - val = Tcl_GetString(objv[argIndex]); + val = Tcl_GetString(objv[argIndex]); if ((argIndex < objc) && (isdigit(UCHAR(val[0])) || ((val[0] == '-') && isdigit(UCHAR(val[1]))))) { if (Tcl_GetInt(interp, val, &values[numValues]) @@ -1910,15 +1904,12 @@ ImgPhotoConfigureMaster( PhotoInstance *instancePtr; const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; - int length, i, j; + Tcl_Obj *tempdata, *tempformat; + int length, i, j, result, imageWidth, imageHeight, oldformat; double oldGamma; - int result; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight; const char **args; - int oldformat; - Tcl_Obj *tempdata, *tempformat; args = (const char **) ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { @@ -2045,16 +2036,16 @@ ImgPhotoConfigureMaster( && ((masterPtr->fileString != oldFileString) || (masterPtr->format != oldFormat))) { - /* - * Prevent file system access in a safe interpreter. - */ + /* + * Prevent file system access in a safe interpreter. + */ - if (Tcl_IsSafe(interp)) { + if (Tcl_IsSafe(interp)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, + Tcl_AppendResult(interp, "can't get image from a file in a safe interpreter", NULL); goto errorExit; - } + } chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0); if (chan == NULL) { @@ -2065,7 +2056,7 @@ ImgPhotoConfigureMaster( * -translation binary also sets -encoding binary */ - if ((Tcl_SetChannelOption(interp, chan, + if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) || (MatchFileFormat(interp, chan, masterPtr->fileString, masterPtr->format, &imageFormat, &imageWidth, @@ -2341,10 +2332,9 @@ ImgPhotoGet( PhotoMaster *masterPtr = (PhotoMaster *) masterData; PhotoInstance *instancePtr; Colormap colormap; - int mono, nRed, nGreen, nBlue; + int mono, nRed, nGreen, nBlue, numVisuals; XVisualInfo visualInfo, *visInfoPtr; char buf[TCL_INTEGER_SPACE * 3]; - int numVisuals; XColor *white, *black; XGCValues gcValues; @@ -2536,7 +2526,7 @@ ToggleComplexAlphaIfNeeded( */ mPtr->flags &= ~COMPLEX_ALPHA; - c += 3; /* start at first alpha byte */ + c += 3; /* Start at first alpha byte. */ for (; c < end; c += 4) { if (*c && *c != 255) { mPtr->flags |= COMPLEX_ALPHA; @@ -2565,16 +2555,15 @@ ToggleComplexAlphaIfNeeded( * Side effects: * Background image passed in gets drawn over with image data. * - *---------------------------------------------------------------------- - */ - -/* - * This should work on all platforms that set mask and shift data properly - * from the visualInfo. RGB is really only a 24+ bpp version whereas RGB15 is - * the correct version and works for 15bpp+, but it slower, so it's only used - * for 15bpp+. + * Notes: + * This should work on all platforms that set mask and shift data + * properly from the visualInfo. RGB is really only a 24+ bpp version + * whereas RGB15 is the correct version and works for 15bpp+, but it + * slower, so it's only used for 15bpp+. + * + * Note that Win32 pre-defines those operations that we really need. * - * Note that Win32 pre-defines those operations that we really need. + *---------------------------------------------------------------------- */ #ifndef __WIN32__ @@ -2593,16 +2582,16 @@ ToggleComplexAlphaIfNeeded( static void ImgPhotoBlendComplexAlpha( - XImage *bgImg, /* background image to draw on */ - PhotoInstance *iPtr, /* image instance to draw */ - int xOffset, int yOffset, /* X & Y offset into image instance to draw */ - int width, int height) /* width & height of image to draw */ + XImage *bgImg, /* Background image to draw on. */ + PhotoInstance *iPtr, /* Image instance to draw. */ + int xOffset, int yOffset, /* X & Y offset into image instance to + * draw. */ + int width, int height) /* Width & height of image to draw. */ { int x, y, line; unsigned long pixel; - unsigned char r, g, b, alpha, unalpha; + unsigned char r, g, b, alpha, unalpha, *masterPtr; unsigned char *alphaAr = iPtr->masterPtr->pix32; - unsigned char *masterPtr; /* * This blending is an integer version of the Source-Over compositing rule @@ -2688,7 +2677,7 @@ ImgPhotoBlendComplexAlpha( ra = GetRValue(pixel) << red_mlen; ga = GetGValue(pixel) << green_mlen; ba = GetBValue(pixel) << blue_mlen; - unalpha = 255 - alpha; /* calculate once */ + unalpha = 255 - alpha; /* Calculate once. */ r = ALPHA_BLEND(ra, r, alpha, unalpha); g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); @@ -2731,7 +2720,7 @@ ImgPhotoBlendComplexAlpha( ra = GetRValue(pixel); ga = GetGValue(pixel); ba = GetBValue(pixel); - unalpha = 255 - alpha; /* calculate once */ + unalpha = 255 - alpha; /* Calculate once. */ r = ALPHA_BLEND(ra, r, alpha, unalpha); g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); @@ -3180,8 +3169,7 @@ ImgPhotoInstanceSetSize( PhotoInstance *instancePtr) /* Instance whose size is to be changed. */ { PhotoMaster *masterPtr; - schar *newError; - schar *errSrcPtr, *errDestPtr; + schar *newError, *errSrcPtr, *errDestPtr; int h, offset; XRectangle validBox; Pixmap newPixmap; @@ -3198,9 +3186,9 @@ ImgPhotoInstanceSetSize( (masterPtr->width > 0) ? masterPtr->width: 1, (masterPtr->height > 0) ? masterPtr->height: 1, instancePtr->visualInfo.depth); - if (!newPixmap) { - Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.\n"); - } + if (!newPixmap) { + Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.\n"); + } /* * The following is a gross hack needed to properly support colormaps @@ -3461,7 +3449,6 @@ GetColorTable( */ colorPtr = (ColorTable *) Tcl_GetHashValue(entry); - } else { /* * No color table currently available; need to make one. @@ -3536,6 +3523,7 @@ FreeColorTable( if (colorPtr->refCount > 0) { return; } + if (force) { if ((colorPtr->flags & DISPOSE_PENDING) != 0) { Tcl_CancelIdleCall(DisposeColorTable, (ClientData) colorPtr); @@ -3853,10 +3841,9 @@ DisposeColorTable( ClientData clientData) /* Pointer to the ColorTable whose * colors are to be released. */ { - ColorTable *colorPtr; + ColorTable *colorPtr = (ColorTable *) clientData; Tcl_HashEntry *entry; - colorPtr = (ColorTable *) clientData; if (colorPtr->pixelMap != NULL) { if (colorPtr->numColors > 0) { XFreeColors(colorPtr->id.display, colorPtr->id.colormap, @@ -3905,14 +3892,13 @@ ReclaimColors( Tcl_HashSearch srch; Tcl_HashEntry *entry; ColorTable *colorPtr; - int nAvail; + int nAvail = 0; /* * First scan through the color hash table to get an upper bound on how * many colors we might be able to free. */ - nAvail = 0; entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch); while (entry != NULL) { colorPtr = (ColorTable *) Tcl_GetHashValue(entry); @@ -3964,7 +3950,7 @@ ReclaimColors( entry = Tcl_NextHashEntry(&srch); } - return 1; /* we freed some colors */ + return 1; /* We freed some colors. */ } /* @@ -4013,7 +3999,7 @@ DisposeInstance( } else { for (prevPtr = instancePtr->masterPtr->instancePtr; prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { - /* Empty loop body */ + /* Empty loop body. */ } prevPtr->nextPtr = instancePtr->nextPtr; } @@ -4055,13 +4041,12 @@ MatchFileFormat( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ - int *oldformat) /* returns 1 if the old image API is used */ + int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched; - int useoldformat = 0; + int matched = 0, useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char *formatString = NULL; if (formatObj) { @@ -4073,9 +4058,8 @@ MatchFileFormat( * handle the image. */ - matched = 0; for (formatPtr = tsdPtr->formatList; formatPtr != NULL; - formatPtr = formatPtr->nextPtr) { + formatPtr = formatPtr->nextPtr) { if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { @@ -4186,13 +4170,12 @@ MatchStringFormat( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ - int *oldformat) /* returns 1 if the old image API is used */ + int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched; - int useoldformat = 0; + int matched = 0, useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char *formatString = NULL; if (formatObj) { @@ -4204,7 +4187,6 @@ MatchStringFormat( * handle the image. */ - matched = 0; for (formatPtr = tsdPtr->formatList; formatPtr != NULL; formatPtr = formatPtr->nextPtr) { if (formatObj != NULL) { @@ -4340,13 +4322,9 @@ Tk_PhotoPutBlock( * transparent pixels. */ { register PhotoMaster *masterPtr; - int xEnd, yEnd; - int greenOffset, blueOffset, alphaOffset; - int wLeft, hLeft; - int wCopy, hCopy; - unsigned char *srcPtr, *srcLinePtr; - unsigned char *destPtr, *destLinePtr; - int pitch; + int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; + int wLeft, hLeft, wCopy, hCopy, pitch; + unsigned char *srcPtr, *srcLinePtr, *destPtr, *destLinePtr; int sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; XRectangle rect; @@ -4615,6 +4593,7 @@ Tk_PhotoPutBlock( * builds up large simple-alpha images by single pixels. We don't * negate COMPLEX_ALPHA in this case. [Bug 1409140] */ + if (!(masterPtr->flags & COMPLEX_ALPHA)) { unsigned char newAlpha; @@ -4632,6 +4611,7 @@ Tk_PhotoPutBlock( * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ + ToggleComplexAlphaIfNeeded(masterPtr); } @@ -4688,17 +4668,11 @@ Tk_PhotoPutZoomedBlock( int compRule) /* Compositing rule to use when processing * transparent pixels. */ { - register PhotoMaster *masterPtr; - int xEnd, yEnd; - int greenOffset, blueOffset, alphaOffset; - int wLeft, hLeft; - int wCopy, hCopy; - int blockWid, blockHt; - unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr; - unsigned char *destPtr, *destLinePtr; - int pitch; - int xRepeat, yRepeat; - int blockXSkip, blockYSkip, sourceIsSimplePhoto; + register PhotoMaster *masterPtr = (PhotoMaster *) handle; + int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; + int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt; + unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr, *destPtr, *destLinePtr; + int pitch, xRepeat, yRepeat, blockXSkip, blockYSkip, sourceIsSimplePhoto; XRectangle rect; if (zoomX==1 && zoomY==1 && subsampleX==1 && subsampleY==1) { @@ -4708,7 +4682,6 @@ Tk_PhotoPutZoomedBlock( sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO; - masterPtr = (PhotoMaster *) handle; if (zoomX <= 0 || zoomY <= 0) { return TCL_OK; @@ -4819,7 +4792,7 @@ Tk_PhotoPutZoomedBlock( srcPtr = srcLinePtr; for (; wCopy > 0; wCopy -= zoomX) { for (xRepeat = MIN(wCopy, zoomX); xRepeat > 0; xRepeat--) { - int alpha = srcPtr[alphaOffset];/* source alpha */ + int alpha = srcPtr[alphaOffset];/* Source alpha. */ /* * Common case (solid pixels) first @@ -4846,7 +4819,8 @@ Tk_PhotoPutZoomedBlock( *destPtr++ = srcPtr[blueOffset]; *destPtr++ = alpha; } else if (alpha) { - int Alpha = destPtr[3]; /* destination alpha */ + int Alpha = destPtr[3]; /* Destination + * alpha. */ destPtr[0] = PD_SRC_OVER(srcPtr[0], alpha, destPtr[0], Alpha); @@ -5057,23 +5031,14 @@ DitherInstance( * block to be dithered. */ int width, int height) /* Dimensions of the block to be dithered. */ { - PhotoMaster *masterPtr; - ColorTable *colorPtr; + PhotoMaster *masterPtr = instancePtr->masterPtr; + ColorTable *colorPtr = instancePtr->colorTablePtr; XImage *imagePtr; - int nLines, bigEndian; - int i, c, x, y; - int xEnd, yEnd; + int nLines, bigEndian, i, c, x, y, xEnd, doDithering = 1; int bitsPerPixel, bytesPerLine, lineLength; - unsigned char *srcLinePtr, *srcPtr; + unsigned char *srcLinePtr; schar *errLinePtr, *errPtr; - unsigned char *destBytePtr, *dstLinePtr; - pixel *destLongPtr; pixel firstBit, word, mask; - int col[3]; - int doDithering = 1; - - colorPtr = instancePtr->colorTablePtr; - masterPtr = instancePtr->masterPtr; /* * Turn dithering off in certain cases where it is not needed (TrueColor, @@ -5107,7 +5072,7 @@ DitherInstance( imagePtr = instancePtr->imagePtr; if (imagePtr == NULL) { - return; /* we must be really tight on memory */ + return; /* We must be really tight on memory. */ } bitsPerPixel = imagePtr->bits_per_pixel; bytesPerLine = ((bitsPerPixel * width + 31) >> 3) & ~3; @@ -5130,16 +5095,19 @@ DitherInstance( */ for (; height > 0; height -= nLines) { + unsigned char *dstLinePtr = (unsigned char *) imagePtr->data; + int yEnd; + if (nLines > height) { nLines = height; } - dstLinePtr = (unsigned char *) imagePtr->data; yEnd = yStart + nLines; for (y = yStart; y < yEnd; ++y) { - srcPtr = srcLinePtr; - errPtr = errLinePtr; - destBytePtr = dstLinePtr; - destLongPtr = (pixel *) dstLinePtr; + unsigned char *srcPtr = srcLinePtr; + schar *errPtr = errLinePtr; + unsigned char *destBytePtr = dstLinePtr; + pixel *destLongPtr = (pixel *) dstLinePtr; + if (colorPtr->flags & COLOR_WINDOW) { /* * Color window. We dither the three components independently, @@ -5149,6 +5117,8 @@ DitherInstance( */ for (x = xStart; x < xEnd; ++x) { + int col[3]; + if (doDithering) { for (i = 0; i < 3; ++i) { /* @@ -5397,10 +5367,9 @@ void Tk_PhotoBlank( Tk_PhotoHandle handle) /* Handle for the image to be blanked. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; PhotoInstance *instancePtr; - masterPtr = (PhotoMaster *) handle; masterPtr->ditherX = masterPtr->ditherY = 0; masterPtr->flags = 0; @@ -5464,9 +5433,7 @@ Tk_PhotoExpand( Tk_PhotoHandle handle, /* Handle for the image to be expanded. */ int width, int height) /* Desired minimum dimensions of the image. */ { - PhotoMaster *masterPtr; - - masterPtr = (PhotoMaster *) handle; + PhotoMaster *masterPtr = (PhotoMaster *) handle; if (width <= masterPtr->width) { width = masterPtr->width; @@ -5513,9 +5480,8 @@ Tk_PhotoGetSize( /* The dimensions of the image are returned * here. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; *widthPtr = masterPtr->width; *heightPtr = masterPtr->height; } @@ -5546,9 +5512,7 @@ Tk_PhotoSetSize( * set. */ int width, int height) /* New dimensions for the image. */ { - PhotoMaster *masterPtr; - - masterPtr = (PhotoMaster *) handle; + PhotoMaster *masterPtr = (PhotoMaster *) handle; masterPtr->userWidth = width; masterPtr->userHeight = height; @@ -5590,9 +5554,8 @@ TkPhotoGetValidRegion( Tk_PhotoHandle handle) /* Handle for the image whose valid region is * to obtained. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; return masterPtr->validRegion; } @@ -5721,9 +5684,10 @@ ImgGetPhoto( */ } else if (optPtr->options & OPT_BACKGROUND) { if (newPixelSize > 2) { - int red = optPtr->background->red>>8; - int green = optPtr->background->green>>8; - int blue = optPtr->background->blue>>8; + int red = optPtr->background->red>>8; + int green = optPtr->background->green>>8; + int blue = optPtr->background->blue>>8; + for (y = blockPtr->height; y > 0; y--) { for (x = blockPtr->width; x > 0; x--) { destPtr[0] += (unsigned char) (((255 - *srcPtr) * @@ -5805,7 +5769,7 @@ ImgStringWrite( Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr) { - int row,col; + int row, col; char *line, *linePtr; unsigned char *pixelPtr; int greenOffset, blueOffset; @@ -5863,9 +5827,8 @@ Tk_PhotoGetImage( /* Information about the address and layout of * the image data is returned here. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; blockPtr->pixelPtr = masterPtr->pix32; blockPtr->width = masterPtr->width; blockPtr->height = masterPtr->height; @@ -5962,9 +5925,10 @@ PhotoOptionCleanupProc( Tcl_Interp *interp) /* Interpreter that is being deleted. */ { OptionAssocData *list = (OptionAssocData *) clientData; - OptionAssocData *ptr; while (list != NULL) { + register OptionAssocData *ptr; + list = (ptr = list)->nextPtr; ckfree((char *) ptr); } @@ -5989,14 +5953,13 @@ PhotoOptionCleanupProc( MODULE_SCOPE void Tk_CreatePhotoOption( - Tcl_Interp *interp, /* Interpreter */ - CONST char *name, /* Option name */ - Tcl_ObjCmdProc *proc) /* Function to execute command */ + Tcl_Interp *interp, /* Interpreter. */ + CONST char *name, /* Option name. */ + Tcl_ObjCmdProc *proc) /* Function to execute command. */ { OptionAssocData *typePtr2, *prevPtr, *ptr; - OptionAssocData *list; - - list = (OptionAssocData *) Tcl_GetAssocData(interp, "photoOption", NULL); + OptionAssocData *list = (OptionAssocData *) + Tcl_GetAssocData(interp, "photoOption", NULL); /* * If there's already a photo option with the given name, remove it. @@ -6041,12 +6004,12 @@ Tk_CreatePhotoOption( static int ImgPhotoPostscript( - ClientData clientData, /* Handle for the photo image */ - Tcl_Interp *interp, /* Interpreter */ + ClientData clientData, /* Handle for the photo image. */ + Tcl_Interp *interp, /* Interpreter. */ Tk_Window tkwin, /* (unused) */ - Tk_PostscriptInfo psInfo, /* postscript info */ - int x, int y, /* First pixel to output */ - int width, int height, /* Width and height of area */ + Tk_PostscriptInfo psInfo, /* Postscript info. */ + int x, int y, /* First pixel to output. */ + int width, int height, /* Width and height of area. */ int prepass) /* (unused) */ { Tk_PhotoImageBlock block; diff --git a/generic/tkInt.h b/generic/tkInt.h index 627ec58..80e5858 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: $Id: tkInt.h,v 1.77 2007/01/18 23:56:43 nijtmans Exp $ + * RCS: $Id: tkInt.h,v 1.78 2007/06/24 16:07:34 dkf Exp $ */ #ifndef _TKINT @@ -192,7 +192,8 @@ typedef struct TkDisplay { * corresponding to the "Meta" key. If no such * modifier, then this is zero. */ enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage; - /* Indicates how to interpret lock modifier */ + /* Indicates how to interpret lock + * modifier. */ int numModKeyCodes; /* Number of entries in modKeyCodes array * below. */ KeyCode *modKeyCodes; /* Pointer to an array giving keycodes for all @@ -503,7 +504,7 @@ typedef struct TkDisplay { */ #ifdef TK_USE_INPUT_METHODS - XIM inputMethod; /* Input method for this display */ + XIM inputMethod; /* Input method for this display. */ #if TK_XIM_SPOT XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ #endif @@ -511,14 +512,16 @@ typedef struct TkDisplay { Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ int refCount; /* Reference count of how many Tk applications - * are using this display. Used to clean up - * the display when we no longer have any Tk - * applications using it. */ + * are using this display. Used to clean up + * the display when we no longer have any Tk + * applications using it. */ + /* * The following field were all added for Tk8.3 */ + int mouseButtonState; /* Current mouse button state for this - * display */ + * display. */ Window mouseButtonWindow; /* Window the button state was set in, added * in Tk 8.4. */ Window warpWindow; @@ -534,8 +537,8 @@ typedef struct TkDisplay { TkCaret caret; /* Information about the caret for this * display. This is not a pointer. */ - int iconDataSize; /* Size of default iconphoto image data */ - unsigned char *iconDataPtr; /* Default iconphoto image data, if set */ + int iconDataSize; /* Size of default iconphoto image data. */ + unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */ } TkDisplay; /* @@ -620,7 +623,7 @@ typedef struct TkMainInfo { Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow * structs for all windows related to this * main window. Managed by tkWindow.c. */ - long deletionEpoch; /* Incremented by window deletions */ + long deletionEpoch; /* Incremented by window deletions. */ Tk_BindingTable bindingTable; /* Used in conjunction with "bind" command to * bind events to Tcl commands. */ @@ -854,7 +857,7 @@ typedef struct TkStateMap { */ typedef struct TkpClipMask { - int type; /* One of TKP_CLIP_PIXMAP or TKP_CLIP_REGION */ + int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */ union { Pixmap pixmap; TkRegion region; @@ -1171,19 +1174,18 @@ MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp, MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin); MODULE_SCOPE void TkpDrawCharsInContext(Display * display, Drawable drawable, GC gc, Tk_Font tkfont, - const char * source, int numBytes, int rangeStart, + const char *source, int numBytes, int rangeStart, int rangeLength, int x, int y); MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont, - const char * source, int numBytes, int rangeStart, + const char *source, int numBytes, int rangeStart, int rangeLength, int maxLength, int flags, - int * lengthPtr); + int *lengthPtr); MODULE_SCOPE void TkUnderlineCharsInContext(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *string, int numBytes, int x, int y, int firstByte, int lastByte); MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont, - Tcl_UniChar c, - struct TkFontAttributes *faPtr); + Tcl_UniChar c, struct TkFontAttributes *faPtr); /* * Unsupported commands. diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 0545412..f46ebea 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.38 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.39 2007/06/24 16:07:35 dkf Exp $ */ /* @@ -53,7 +53,7 @@ * Clones are rather tricky when a menu with cascade entries is cloned (such * as a menubar). Not only does the menu have to be cloned, but each cascade * entry's corresponding menu must also be cloned. This maintains the pathname - * parent-child hierarchy necessary for menubars and toplevels to work. This + * parent-child hierarchy necessary for menubars and toplevels to work. This * leads to several special cases: * * 1. When a new menu is created, and it is pointed to by cascade entries in @@ -61,8 +61,8 @@ * structure. * 2. When a cascade item is added to a menu that has been cloned, and the * menu that the cascade item points to exists, that menu has to be cloned. - * 3. When the menu that a cascade entry points to is changed, the old - * cloned cascade menu has to be discarded, and the new one has to be cloned. + * 3. When the menu that a cascade entry points to is changed, the old cloned + * cascade menu has to be discarded, and the new one has to be cloned. */ #if 0 @@ -80,9 +80,9 @@ #define MENU_HASH_KEY "tkMenus" typedef struct ThreadSpecificData { - int menusInitialized; /* Flag indicates whether thread-specific - * elements of the Windows Menu module - * have been initialized. */ + int menusInitialized; /* Flag indicates whether thread-specific + * elements of the Windows Menu module have + * been initialized. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -137,7 +137,7 @@ static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { DEF_MENU_ENTRY_COMMAND, Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, + DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, (ClientData) compoundStrings, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, DEF_MENU_ENTRY_FONT, @@ -251,8 +251,8 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { Tk_Offset(TkMenu, activeBorderPtr), -1, 0, (ClientData) DEF_MENU_ACTIVE_BG_MONO}, {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth", - "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, - Tk_Offset(TkMenu, activeBorderWidthPtr), -1}, + "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, + Tk_Offset(TkMenu, activeBorderWidthPtr), -1}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENU_ACTIVE_FG_COLOR, Tk_Offset(TkMenu, activeFgPtr), -1, 0, @@ -297,7 +297,7 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { "TearOffCommand", DEF_MENU_TEAROFF_CMD, Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING, "-title", "title", "Title", - DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1, + DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING_TABLE, "-type", "type", "Type", DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypePtr), -1, TK_OPTION_NULL_OK, @@ -454,8 +454,7 @@ MenuCmd( Tk_Window newWin; register TkMenu *menuPtr; TkMenuReferences *menuRefPtr; - int i, index; - int toplevel; + int i, index, toplevel; char *windowName; static CONST char *typeStringList[] = {"-type", NULL}; TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *) clientData; @@ -552,12 +551,11 @@ MenuCmd( */ if (menuRefPtr->parentEntryPtr != NULL) { - TkMenuEntry *cascadeListPtr = menuRefPtr->parentEntryPtr; - TkMenuEntry *nextCascadePtr; - Tcl_Obj *newMenuName; - Tcl_Obj *newObjv[2]; + TkMenuEntry *cascadeListPtr = menuRefPtr->parentEntryPtr; + TkMenuEntry *nextCascadePtr; + Tcl_Obj *newMenuName, *newObjv[2]; - while (cascadeListPtr != NULL) { + while (cascadeListPtr != NULL) { nextCascadePtr = cascadeListPtr->nextCascadePtr; /* @@ -587,27 +585,27 @@ MenuCmd( Tcl_IncrRefCount(normalPtr); Tcl_IncrRefCount(windowNamePtr); - newMenuName = TkNewMenuName(menuPtr->interp, + newMenuName = TkNewMenuName(menuPtr->interp, windowNamePtr, menuPtr); Tcl_IncrRefCount(newMenuName); - CloneMenu(menuPtr, newMenuName, normalPtr); + CloneMenu(menuPtr, newMenuName, normalPtr); - /* - * Now we can set the new menu instance to be the cascade - * entry of the parent's instance. - */ + /* + * Now we can set the new menu instance to be the cascade + * entry of the parent's instance. + */ newObjv[0] = Tcl_NewStringObj("-menu", -1); newObjv[1] = newMenuName; Tcl_IncrRefCount(newObjv[0]); - ConfigureMenuEntry(cascadeListPtr, 2, newObjv); + ConfigureMenuEntry(cascadeListPtr, 2, newObjv); Tcl_DecrRefCount(normalPtr); Tcl_DecrRefCount(newObjv[0]); Tcl_DecrRefCount(newObjv[1]); Tcl_DecrRefCount(windowNamePtr); - } - cascadeListPtr = nextCascadePtr; - } + } + cascadeListPtr = nextCascadePtr; + } } /* @@ -620,8 +618,8 @@ MenuCmd( TkMenuTopLevelList *topLevelListPtr = menuRefPtr->topLevelListPtr; TkMenuTopLevelList *nextPtr; Tk_Window listtkwin; - while (topLevelListPtr != NULL) { + while (topLevelListPtr != NULL) { /* * Need to get the next pointer first. TkSetWindowMenuBar changes * the list, so that the next pointer is different after calling @@ -1022,7 +1020,7 @@ TkInvokeMenu( Tcl_Interp *interp, /* The interp that the menu lives in. */ TkMenu *menuPtr, /* The menu we are invoking. */ int index) /* The zero based index of the item we are - * invoking */ + * invoking. */ { int result = TCL_OK; TkMenuEntry *mePtr; @@ -1177,18 +1175,18 @@ DestroyMenuInstance( } if (menuPtr->masterMenuPtr != menuPtr) { - for (menuInstancePtr = menuPtr->masterMenuPtr; - menuInstancePtr != NULL; - menuInstancePtr = menuInstancePtr->nextInstancePtr) { - if (menuInstancePtr->nextInstancePtr == menuPtr) { - menuInstancePtr->nextInstancePtr = - menuInstancePtr->nextInstancePtr->nextInstancePtr; - break; - } - } - } else if (menuPtr->nextInstancePtr != NULL) { - Tcl_Panic("Attempting to delete master menu when there are still clones."); - } + for (menuInstancePtr = menuPtr->masterMenuPtr; + menuInstancePtr != NULL; + menuInstancePtr = menuInstancePtr->nextInstancePtr) { + if (menuInstancePtr->nextInstancePtr == menuPtr) { + menuInstancePtr->nextInstancePtr = + menuInstancePtr->nextInstancePtr->nextInstancePtr; + break; + } + } + } else if (menuPtr->nextInstancePtr != NULL) { + Tcl_Panic("Attempting to delete master menu when there are still clones."); + } /* * Free up all the stuff that requires special handling, then let @@ -1329,7 +1327,7 @@ UnhookCascadeEntry( menuRefPtr = mePtr->childMenuRefPtr; if (menuRefPtr == NULL) { - return; + return; } cascadeEntryPtr = menuRefPtr->parentEntryPtr; @@ -1366,15 +1364,15 @@ UnhookCascadeEntry( for (prevCascadePtr = cascadeEntryPtr, cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr; cascadeEntryPtr != NULL; - prevCascadePtr = cascadeEntryPtr, + prevCascadePtr = cascadeEntryPtr, cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr == mePtr){ prevCascadePtr->nextCascadePtr = - cascadeEntryPtr->nextCascadePtr; + cascadeEntryPtr->nextCascadePtr; cascadeEntryPtr->nextCascadePtr = NULL; break; } - } + } mePtr->nextCascadePtr = NULL; } mePtr->childMenuRefPtr = NULL; @@ -1447,9 +1445,9 @@ DestroyMenuEntry( } UnhookCascadeEntry(mePtr); if (menuRefPtr != NULL) { - if (menuRefPtr->menuPtr == destroyThis) { - menuRefPtr->menuPtr = NULL; - } + if (menuRefPtr->menuPtr == destroyThis) { + menuRefPtr->menuPtr = NULL; + } if (destroyThis != NULL) { TkDestroyMenu(destroyThis); } @@ -1489,10 +1487,10 @@ DestroyMenuEntry( * all its graphics contexts and determine its new geometry. * * Results: - * None. + * None. * * Side effects: - * Menu will be relayed out and redisplayed. + * Menu will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ @@ -1535,8 +1533,8 @@ MenuWorldChanged( static int ConfigureMenu( Tcl_Interp *interp, /* Used for error reporting. */ - register TkMenu *menuPtr, /* Information about widget; may or may - * not already have values for some fields. */ + register TkMenu *menuPtr, /* Information about widget; may or may not + * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *CONST objv[]) /* Arguments. */ { @@ -2142,7 +2140,7 @@ TkGetMenuIndex( } if (isdigit(UCHAR(string[0]))) { - if (Tcl_GetInt(interp, string, &i) == TCL_OK) { + if (Tcl_GetInt(interp, string, &i) == TCL_OK) { if (i >= menuPtr->numEntries) { if (lastOK) { i = menuPtr->numEntries; @@ -2256,7 +2254,7 @@ MenuNewEntry( for (i = 0; i < index; i++) { newEntries[i] = menuPtr->entries[i]; } - for ( ; i < menuPtr->numEntries; i++) { + for (; i < menuPtr->numEntries; i++) { newEntries[i+1] = menuPtr->entries[i]; newEntries[i+1]->index = i + 1; } @@ -2418,14 +2416,13 @@ MenuAddOrInsert( if ((mePtr->namePtr != NULL) && (mePtr->childMenuRefPtr != NULL) && (mePtr->childMenuRefPtr->menuPtr != NULL)) { - TkMenu *cascadeMenuPtr = + TkMenu *cascadeMenuPtr = mePtr->childMenuRefPtr->menuPtr->masterMenuPtr; - Tcl_Obj *newCascadePtr; + Tcl_Obj *newCascadePtr, *newObjv[2]; Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), -1); Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1); - Tcl_Obj *newObjv[2]; TkMenuReferences *menuRefPtr; Tcl_IncrRefCount(windowNamePtr); @@ -2444,8 +2441,8 @@ MenuAddOrInsert( newObjv[1] = newCascadePtr; Tcl_IncrRefCount(menuNamePtr); Tcl_IncrRefCount(newCascadePtr); - ConfigureMenuEntry(mePtr, 2, newObjv); - Tcl_DecrRefCount(newCascadePtr); + ConfigureMenuEntry(mePtr, 2, newObjv); + Tcl_DecrRefCount(newCascadePtr); Tcl_DecrRefCount(menuNamePtr); Tcl_DecrRefCount(windowNamePtr); Tcl_DecrRefCount(normalPtr); @@ -2659,8 +2656,8 @@ TkPostCommand( static int CloneMenu( - TkMenu *menuPtr, /* The menu we are going to clone */ - Tcl_Obj *newMenuNamePtr, /* The name to give the new menu */ + TkMenu *menuPtr, /* The menu we are going to clone. */ + Tcl_Obj *newMenuNamePtr, /* The name to give the new menu. */ Tcl_Obj *newMenuTypePtr) /* What kind of menu is this, a normal menu a * menubar, or a tearoff? */ { @@ -2917,10 +2914,10 @@ MenuDoYPosition( static int GetIndexFromCoords( - Tcl_Interp *interp, /* interp of menu */ - TkMenu *menuPtr, /* the menu we are searching */ - char *string, /* The @string we are parsing */ - int *indexPtr) /* The index of the item that matches */ + Tcl_Interp *interp, /* Interpreter of menu. */ + TkMenu *menuPtr, /* The menu we are searching. */ + char *string, /* The @string we are parsing. */ + int *indexPtr) /* The index of the item that matches. */ { int x, y, i; char *p, *end; @@ -2983,7 +2980,7 @@ GetIndexFromCoords( static void RecursivelyDeleteMenu( - TkMenu *menuPtr) /* The menubar instance we are deleting */ + TkMenu *menuPtr) /* The menubar instance we are deleting. */ { int i; TkMenuEntry *mePtr; @@ -3109,7 +3106,7 @@ TkNewMenuName( void TkSetWindowMenuBar( Tcl_Interp *interp, /* The interpreter the toplevel lives in. */ - Tk_Window tkwin, /* The toplevel window */ + Tk_Window tkwin, /* The toplevel window. */ char *oldMenuName, /* The name of the menubar previously set in * this toplevel. NULL means no menu was set * previously. */ @@ -3159,7 +3156,7 @@ TkSetWindowMenuBar( prevTopLevelPtr = NULL; while ((topLevelListPtr != NULL) - && (topLevelListPtr->tkwin != tkwin)) { + && (topLevelListPtr->tkwin != tkwin)) { prevTopLevelPtr = topLevelListPtr; topLevelListPtr = topLevelListPtr->nextPtr; } @@ -3271,8 +3268,8 @@ TkSetWindowMenuBar( static void DestroyMenuHashTable( - ClientData clientData, /* The menu hash table we are destroying */ - Tcl_Interp *interp) /* The interpreter we are destroying */ + ClientData clientData, /* The menu hash table we are destroying. */ + Tcl_Interp *interp) /* The interpreter we are destroying. */ { Tcl_DeleteHashTable((Tcl_HashTable *) clientData); ckfree((char *) clientData); @@ -3337,7 +3334,7 @@ TkGetMenuHashTable( TkMenuReferences * TkCreateMenuReferences( Tcl_Interp *interp, - char *pathName) /* The path of the menu widget */ + char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr; @@ -3381,7 +3378,7 @@ TkCreateMenuReferences( TkMenuReferences * TkFindMenuReferences( Tcl_Interp *interp, /* The interp the menu is living in. */ - char *pathName) /* The path of the menu widget */ + char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr = NULL; @@ -3418,7 +3415,7 @@ TkFindMenuReferences( TkMenuReferences * TkFindMenuReferencesObj( Tcl_Interp *interp, /* The interp the menu is living in. */ - Tcl_Obj *objPtr) /* The path of the menu widget */ + Tcl_Obj *objPtr) /* The path of the menu widget. */ { char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); @@ -3445,7 +3442,7 @@ TkFindMenuReferencesObj( int TkFreeMenuReferences( TkMenuReferences *menuRefPtr) - /* The menu reference to free */ + /* The menu reference to free. */ { if ((menuRefPtr->menuPtr == NULL) && (menuRefPtr->parentEntryPtr == NULL) @@ -3516,14 +3513,14 @@ DeleteMenuCloneEntries( * * TkMenuCleanup -- * - * Resets menusInitialized to allow Tk to be finalized and reused without - * the DLL being unloaded. + * Resets menusInitialized to allow Tk to be finalized and reused without + * the DLL being unloaded. * * Results: - * None. + * None. * * Side effects: - * None. + * None. * *---------------------------------------------------------------------- */ diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 0c726a0..1a4f3d8 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.h,v 1.12 2007/01/05 00:00:51 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.h,v 1.13 2007/06/24 16:07:35 dkf Exp $ */ #ifndef _TKMENU @@ -139,7 +139,7 @@ typedef struct TkMenuEntry { * Malloc'ed. */ Tcl_Obj *namePtr; /* Name of variable (for check buttons and * radio buttons) or menu (for cascade - * entries). Malloc'ed.*/ + * entries). Malloc'ed. */ Tcl_Obj *onValuePtr; /* Value to store in variable when selected * (only for radio and check buttons). * Malloc'ed. */ @@ -155,19 +155,19 @@ typedef struct TkMenuEntry { * horizontal dimension. Not used except in * menubars. The width of norma menus is * dependent on the rest of the menu. */ - int x; /* X-coordinate of leftmost pixel in entry */ + int x; /* X-coordinate of leftmost pixel in entry. */ int height; /* Number of pixels occupied by entry in * vertical dimension, including raised border * drawn around entry when active. */ int y; /* Y-coordinate of topmost pixel in entry. */ - GC textGC; /* GC for drawing text in entry. NULL means + GC textGC; /* GC for drawing text in entry. NULL means * use overall textGC for menu. */ GC activeGC; /* GC for drawing text in entry when active. * NULL means use overall activeGC for * menu. */ GC disabledGC; /* Used to produce disabled effect for entry. * NULL means use overall disabledGC from menu - * structure. See comments for disabledFg in + * structure. See comments for disabledFg in * menu structure for more information. */ GC indicatorGC; /* For drawing indicators. None means use GC * from menu. */ @@ -313,8 +313,8 @@ typedef struct TkMenu { * Information about geometry of menu. */ - int totalWidth; /* Width of entire menu */ - int totalHeight; /* Height of entire menu */ + int totalWidth; /* Width of entire menu. */ + int totalHeight; /* Height of entire menu. */ /* * Miscellaneous information: @@ -335,16 +335,16 @@ typedef struct TkMenu { * whenever the menu is torn-off. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal - * scripts. Malloc'ed, but may be NULL. */ + * scripts. Malloc'ed, but may be NULL. */ Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */ Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy * trees when preprocessing postcommands on * some platforms. See PostMenu for more * details. */ int postCommandGeneration; /* Need to do pre-invocation post command - * traversal */ + * traversal. */ int menuFlags; /* Flags for use by X; see below for - definition */ + * definition. */ TkMenuEntry *postedCascade; /* Points to menu entry for cascaded submenu * that is currently posted or NULL if no * submenu posted. */ @@ -373,8 +373,8 @@ typedef struct TkMenu { * have this menu specified as a cascade. */ TkMenuPlatformData platformData; /* The data for the specific type of menu. - * Depends on platform and menu type what kind - * of options are in this structure. */ + * Depends on platform and menu type what kind + * of options are in this structure. */ Tk_OptionSpec *extensionPtr;/* Needed by the configuration package for * this widget to be extended. */ Tk_SavedOptions *errorStructPtr; @@ -391,7 +391,7 @@ typedef struct TkMenu { typedef struct TkMenuTopLevelList { struct TkMenuTopLevelList *nextPtr; - /* The next window in the list */ + /* The next window in the list. */ Tk_Window tkwin; /* The window that has this menu as its * menubar. */ } TkMenuTopLevelList; @@ -451,14 +451,14 @@ typedef struct TkMenuOptionTables { * when TkDestroyMenu was called again on this * menu (via a destroy binding or somesuch). * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of - * destroying this menu's Tk_Window. + * destroying this menu's Tk_Window. * MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu * code. */ -#define REDRAW_PENDING 1 -#define RESIZE_PENDING 2 -#define MENU_DELETION_PENDING 4 +#define REDRAW_PENDING 1 +#define RESIZE_PENDING 2 +#define MENU_DELETION_PENDING 4 #define MENU_WIN_DESTRUCTION_PENDING 8 #define MENU_PLATFORM_FLAG1 (1 << 30) #define MENU_PLATFORM_FLAG2 (1 << 29) @@ -482,9 +482,9 @@ typedef struct TkMenuOptionTables { * Various geometry definitions: */ -#define CASCADE_ARROW_HEIGHT 10 -#define CASCADE_ARROW_WIDTH 8 -#define DECORATION_BORDER_WIDTH 2 +#define CASCADE_ARROW_HEIGHT 10 +#define CASCADE_ARROW_WIDTH 8 +#define DECORATION_BORDER_WIDTH 2 /* * Menu-related functions that are shared among Tk modules but not exported to @@ -560,4 +560,3 @@ MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKMENU */ - diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 9fa7c4f..ebffdb7 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenubutton.c,v 1.15 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkMenubutton.c,v 1.16 2007/06/24 16:07:35 dkf Exp $ */ #include "tkMenubutton.h" @@ -50,19 +50,19 @@ static char *compoundStrings[] = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", - DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1, - Tk_Offset(TkMenuButton, activeBorder), 0, - (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0}, + DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1, + Tk_Offset(TkMenuButton, activeBorder), 0, + (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1, - Tk_Offset(TkMenuButton, activeFg), - 0, (ClientData) DEF_MENUBUTTON_ACTIVE_FG_MONO, 0}, + Tk_Offset(TkMenuButton, activeFg), + 0, (ClientData) DEF_MENUBUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MENUBUTTON_ANCHOR, -1, - Tk_Offset(TkMenuButton, anchor), 0, 0, 0}, + Tk_Offset(TkMenuButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder), - 0, (ClientData) DEF_MENUBUTTON_BG_MONO, 0}, + 0, (ClientData) DEF_MENUBUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0, @@ -72,12 +72,12 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENUBUTTON_BORDER_WIDTH, -1, - Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0}, + Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction", - DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction), + DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction), 0, (ClientData) directionStrings, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR, @@ -91,13 +91,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR, -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_MENUBUTTON_HIGHLIGHT, -1, - Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0}, + Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH, -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0}, @@ -106,7 +106,7 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn", DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0}, {TK_OPTION_STRING, "-menu", "menu", "Menu", @@ -120,30 +120,30 @@ static const Tk_OptionSpec optionSpecs[] = { 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0, - (ClientData) compoundStrings, 0}, + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state), 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_MENUBUTTON_TAKE_FOCUS, -1, - Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0}, + Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_MENUBUTTON_TEXT_VARIABLE, -1, - Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, + Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-underline", "underline", "Underline", DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0} }; @@ -179,7 +179,7 @@ static int MenuButtonWidgetObjCmd(ClientData clientData, Tcl_Obj *CONST objv[]); static int ConfigureMenuButton(Tcl_Interp *interp, TkMenuButton *mbPtr, int objc, - Tcl_Obj *CONST objv[]); + Tcl_Obj *CONST objv[]); static void DestroyMenuButton(char *memPtr); /* @@ -246,8 +246,8 @@ Tk_MenubuttonObjCmd( mbPtr->display = Tk_Display (tkwin); mbPtr->interp = interp; mbPtr->widgetCmd = Tcl_CreateObjCommand(interp, - Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, - (ClientData) mbPtr, MenuButtonCmdDeletedProc); + Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, + (ClientData) mbPtr, MenuButtonCmdDeletedProc); mbPtr->optionTable = optionTable; mbPtr->menuName = NULL; mbPtr->text = NULL; @@ -342,13 +342,13 @@ MenuButtonWidgetObjCmd( Tcl_Obj *objPtr; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, "option", 0, &index); if (result != TCL_OK) { - return result; + return result; } Tcl_Preserve((ClientData) mbPtr); @@ -418,7 +418,7 @@ DestroyMenuButton( TkpDestroyMenuButton(mbPtr); if (mbPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr); + Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr); } /* @@ -451,7 +451,7 @@ DestroyMenuButton( Tk_FreeBitmap(mbPtr->display, mbPtr->gray); } if (mbPtr->textLayout != NULL) { - Tk_FreeTextLayout(mbPtr->textLayout); + Tk_FreeTextLayout(mbPtr->textLayout); } Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable, mbPtr->tkwin); mbPtr->tkwin = NULL; @@ -483,7 +483,7 @@ static int ConfigureMenuButton( Tcl_Interp *interp, /* Used for error reporting. */ register TkMenuButton *mbPtr, - /* Information about widget; may or may not + /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in objv. */ Tcl_Obj *CONST objv[]) /* Arguments. */ @@ -566,7 +566,7 @@ ConfigureMenuButton( mbPtr->imageString, MenuButtonImageProc, (ClientData) mbPtr); if (image == NULL) { - return TCL_ERROR; + return TCL_ERROR; } } else { image = NULL; @@ -582,25 +582,25 @@ ConfigureMenuButton( if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, - &mbPtr->width) != TCL_OK) { + &mbPtr->width) != TCL_OK) { widthError: - Tcl_AddErrorInfo(interp, "\n (processing -width option)"); + Tcl_AddErrorInfo(interp, "\n (processing -width option)"); continue; } if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString, &mbPtr->height) != TCL_OK) { heightError: - Tcl_AddErrorInfo(interp, "\n (processing -height option)"); + Tcl_AddErrorInfo(interp, "\n (processing -height option)"); continue; } } else { if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width) != TCL_OK) { - goto widthError; + goto widthError; } if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height) != TCL_OK) { - goto heightError; + goto heightError; } } break; @@ -641,7 +641,7 @@ ConfigureMenuButton( if (error) { Tcl_SetObjResult(interp, errorResult); Tcl_DecrRefCount(errorResult); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; } @@ -651,15 +651,15 @@ ConfigureMenuButton( * * TkMenuButtonWorldChanged -- * - * This function is called when the world has changed in some way and the - * widget needs to recompute all its graphics contexts and determine its - * new geometry. + * This function is called when the world has changed in some way and the + * widget needs to recompute all its graphics contexts and determine its + * new geometry. * * Results: - * None. + * None. * * Side effects: - * TkMenuButton will be relayed out and redisplayed. + * TkMenuButton will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ @@ -785,7 +785,7 @@ MenuButtonEventProc( goto redraw; } else if (eventPtr->type == DestroyNotify) { - DestroyMenuButton((char *) mbPtr); + DestroyMenuButton((char *) mbPtr); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { mbPtr->flags |= GOT_FOCUS; diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 087db07..9c36003 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -1,227 +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.11 2005/11/27 02:36:14 das 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.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 */ diff --git a/generic/tkOption.c b/generic/tkOption.c index b930f8c..64d53ca 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkOption.c,v 1.20 2007/05/03 15:21:32 dkf Exp $ + * RCS: @(#) $Id: tkOption.c,v 1.21 2007/06/24 16:07:35 dkf Exp $ */ #include "tkPort.h" @@ -180,7 +180,7 @@ typedef struct StackLevel { } StackLevel; typedef struct ThreadSpecificData { - int initialized; /* 0 means the ThreadSpecific Data structure + int initialized; /* 0 means the ThreadSpecific Data structure * for the current thread needs to be * initialized. */ ElArray *stacks[NUM_STACKS]; @@ -193,9 +193,9 @@ typedef struct ThreadSpecificData { * This array grows dynamically to become as large as needed. */ - StackLevel *levels; /* Array describing current stack. */ - int numLevels; /* Total space allocated. */ - int curLevel; /* Highest level currently in use. Note: + StackLevel *levels; /* Array describing current stack. */ + int numLevels; /* Total space allocated. */ + int curLevel; /* Highest level currently in use. Note: * curLevel is never 0! (I don't remember why * anymore...) */ int serial; /* A serial number for all options entered @@ -204,9 +204,8 @@ typedef struct ThreadSpecificData { * used in computing option priorities, so * that the most recent entry wins when * choosing between options at the same - * priority level. - */ - Element defaultMatch; /* Special "no match" Element to use as + * priority level. */ + Element defaultMatch; /* Special "no match" Element to use as * default for searches.*/ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -267,7 +266,7 @@ Tk_AddOption( #define TMP_SIZE 100 char tmp[TMP_SIZE+1]; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->mainPtr->optionRootPtr == NULL) { OptionInit(winPtr->mainPtr); @@ -339,7 +338,8 @@ Tk_AddOption( if (count == 0) { newEl.child.arrayPtr = NewArray(5); *arrayPtrPtr = ExtendArray(*arrayPtrPtr, &newEl); - arrayPtrPtr = &((*arrayPtrPtr)->nextToUse[-1].child.arrayPtr); + arrayPtrPtr = &((*arrayPtrPtr) + ->nextToUse[-1].child.arrayPtr); break; } if ((elPtr->nameUid == newEl.nameUid) @@ -414,7 +414,7 @@ Tk_GetOption( StackLevel *levelPtr; int stackDepth[NUM_STACKS]; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Note: no need to call OptionInit here: it will be done by the @@ -619,7 +619,7 @@ Tk_OptionObjCmd( Tk_Window tkwin = (Tk_Window) clientData; int index, result; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static CONST char *optionCmds[] = { "add", "clear", "get", "readfile", NULL @@ -744,14 +744,14 @@ TkOptionDeadWindow( register TkWindow *winPtr) /* Window to be cleaned up. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If this window is in the option stacks, then clear the stacks. * * XXX: OptionThreadExitProc will be invoked before DeleteWindowsExitProc * XXX: if it is thread-specific (which it should be), invalidating the - * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. + * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. */ if (tsdPtr->initialized && (winPtr->optionLevel != -1)) { @@ -800,7 +800,7 @@ TkOptionClassChanged( int i, j, *basePtr; ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->optionLevel == -1) { return; @@ -880,7 +880,7 @@ ParsePriority( priority = strtoul(string, &end, 0); if ((end == string) || (*end != 0) || (priority < 0) || (priority > 100)) { - Tcl_AppendResult(interp, "bad priority level \"", string, + Tcl_AppendResult(interp, "bad priority level \"", string, "\": must be widgetDefault, startupFile, userDefault, ", "interactive, or a number between 0 and 100", NULL); return -1; @@ -1084,9 +1084,9 @@ ReadOptionFile( */ if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't read options from a file in a", - " safe interpreter", NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "can't read options from a file in a", + " safe interpreter", NULL); + return TCL_ERROR; } realName = Tcl_TranslateFileName(interp, fileName, &newName); @@ -1096,7 +1096,7 @@ ReadOptionFile( chan = Tcl_OpenFileChannel(interp, realName, "r", 0); Tcl_DStringFree(&newName); if (chan == NULL) { - Tcl_ResetResult(interp); + Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ", Tcl_PosixError(interp), NULL); return TCL_ERROR; @@ -1237,7 +1237,7 @@ SetupStacks( register StackLevel *levelPtr; register ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * The following array defines the order in which the current stacks are @@ -1399,15 +1399,15 @@ ExtendStacks( register int count; register Element *elPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (elPtr = arrayPtr->els, count = arrayPtr->numUsed; count > 0; elPtr++, count--) { if (!(elPtr->flags & (NODE|WILDCARD)) && !leaf) { continue; } - tsdPtr->stacks[elPtr->flags] = ExtendArray( - tsdPtr->stacks[elPtr->flags], elPtr); + tsdPtr->stacks[elPtr->flags] = + ExtendArray(tsdPtr->stacks[elPtr->flags], elPtr); } } @@ -1432,7 +1432,7 @@ OptionThreadExitProc( ClientData clientData) /* not used */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->initialized) { int i; @@ -1470,7 +1470,7 @@ OptionInit( int i; Tcl_Interp *interp; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Element *defaultMatchPtr = &tsdPtr->defaultMatch; /* @@ -1478,14 +1478,14 @@ OptionInit( */ if (tsdPtr->initialized == 0) { - tsdPtr->initialized = 1; - tsdPtr->cachedWindow = NULL; + tsdPtr->initialized = 1; + tsdPtr->cachedWindow = NULL; tsdPtr->numLevels = 5; tsdPtr->curLevel = -1; tsdPtr->serial = 0; - tsdPtr->levels = (StackLevel *) ckalloc((unsigned) - (5*sizeof(StackLevel))); + tsdPtr->levels = (StackLevel *) + ckalloc((unsigned) (5*sizeof(StackLevel))); for (i = 0; i < NUM_STACKS; i++) { tsdPtr->stacks[i] = NewArray(10); tsdPtr->levels[0].bases[i] = 0; diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 9effd23..6fc36ef 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkPlace.c,v 1.20 2007/01/05 00:00:50 nijtmans Exp $ + * RCS: @(#) $Id: tkPlace.c,v 1.21 2007/06/24 16:07:35 dkf Exp $ */ #include "tkPort.h" @@ -58,12 +58,14 @@ typedef struct Slave { int x, y; /* X and Y pixel coordinates for tkwin. */ Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel - * spec. information */ + * spec. information. */ double relX, relY; /* X and Y coordinates relative to size of * master. */ int width, height; /* Absolute dimensions for tkwin. */ - Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel spec */ - Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel spec */ + Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel + * spec. */ + Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel + * spec. */ double relWidth, relHeight; /* Dimensions for tkwin relative to size of * master. */ Tcl_Obj *relWidthPtr; @@ -154,9 +156,9 @@ static void PlaceLostSlaveProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr placerType = { - "place", /* name */ - PlaceRequestProc, /* requestProc */ - PlaceLostSlaveProc, /* lostSlaveProc */ + "place", /* name */ + PlaceRequestProc, /* requestProc */ + PlaceLostSlaveProc, /* lostSlaveProc */ }; /* @@ -170,7 +172,7 @@ static int ConfigureSlave(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *CONST objv[]); static int PlaceInfoCommand(Tcl_Interp *interp, Tk_Window tkwin); static Slave * CreateSlave(Tk_Window tkwin, Tk_OptionTable table); -static void FreeSlave(Slave *slavePtr); +static void FreeSlave(Slave *slavePtr); static Slave * FindSlave(Tk_Window tkwin); static Master * CreateMaster(Tk_Window tkwin); static Master * FindMaster(Tk_Window tkwin); @@ -380,20 +382,25 @@ CreateSlave( TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew); - if (isNew) { - slavePtr = (Slave *) ckalloc(sizeof(Slave)); - memset(slavePtr, 0, sizeof(Slave)); - slavePtr->tkwin = tkwin; - slavePtr->inTkwin = None; - slavePtr->anchor = TK_ANCHOR_NW; - slavePtr->borderMode = BM_INSIDE; - slavePtr->optionTable = table; - Tcl_SetHashValue(hPtr, slavePtr); - Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - (ClientData) slavePtr); - } else { - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); + if (!isNew) { + return (Slave *) Tcl_GetHashValue(hPtr); } + + /* + * No preexisting slave structure for that window, so make a new one and + * populate it with some default values. + */ + + slavePtr = (Slave *) ckalloc(sizeof(Slave)); + memset(slavePtr, 0, sizeof(Slave)); + slavePtr->tkwin = tkwin; + slavePtr->inTkwin = None; + slavePtr->anchor = TK_ANCHOR_NW; + slavePtr->borderMode = BM_INSIDE; + slavePtr->optionTable = table; + Tcl_SetHashValue(hPtr, slavePtr); + Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, + (ClientData) slavePtr); return slavePtr; } @@ -446,7 +453,7 @@ FindSlave( { Tcl_HashEntry *hPtr; register Slave *slavePtr; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); if (hPtr == NULL) { @@ -524,7 +531,7 @@ CreateMaster( Tcl_HashEntry *hPtr; register Master *masterPtr; int isNew; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew); if (isNew) { @@ -566,7 +573,7 @@ FindMaster( { Tcl_HashEntry *hPtr; register Master *masterPtr; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin); if (hPtr == NULL) { @@ -703,8 +710,8 @@ ConfigureSlave( */ if (masterWin == NULL) { - masterWin = Tk_Parent(slavePtr->tkwin); - slavePtr->inTkwin = masterWin; + masterWin = Tk_Parent(slavePtr->tkwin); + slavePtr->inTkwin = masterWin; } /* @@ -860,13 +867,13 @@ RecomputePlacement( if (slavePtr->borderMode == BM_INSIDE) { masterX = Tk_InternalBorderLeft(masterPtr->tkwin); masterY = Tk_InternalBorderTop(masterPtr->tkwin); - masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); - masterHeight -= masterY + + masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); + masterHeight -= masterY + Tk_InternalBorderBottom(masterPtr->tkwin); } else if (slavePtr->borderMode == BM_OUTSIDE) { masterX = masterY = -Tk_Changes(masterPtr->tkwin)->border_width; - masterWidth -= 2 * masterX; - masterHeight -= 2 * masterY; + masterWidth -= 2 * masterX; + masterHeight -= 2 * masterY; } /* @@ -1104,7 +1111,7 @@ SlaveStructureProc( XEvent *eventPtr) /* Describes what just happened. */ { register Slave *slavePtr = (Slave *) clientData; - TkDisplay * dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; if (eventPtr->type == DestroyNotify) { if (slavePtr->masterPtr != NULL) { @@ -1182,7 +1189,7 @@ PlaceLostSlaveProc( Tk_Window tkwin) /* Tk's handle for the slave window. */ { register Slave *slavePtr = (Slave *) clientData; - TkDisplay * dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); @@ -1190,7 +1197,7 @@ PlaceLostSlaveProc( Tk_UnmapWindow(tkwin); UnlinkSlave(slavePtr); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, - (char *) tkwin)); + (char *) tkwin)); Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, (ClientData) slavePtr); FreeSlave(slavePtr); diff --git a/generic/tkScale.c b/generic/tkScale.c index 2e371b6..39de74f 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.c,v 1.24 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkScale.c,v 1.25 2007/06/24 16:07:35 dkf Exp $ */ #include "tkPort.h" @@ -50,15 +50,15 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder), 0, (ClientData) DEF_SCALE_BG_MONO, 0}, {TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement", - DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement), - 0, 0, 0}, + DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement), + 0, 0, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_SCALE_COMMAND, -1, Tk_Offset(TkScale, command), TK_OPTION_NULL_OK, 0, 0}, @@ -67,20 +67,20 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-digits", "digits", "Digits", DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0, - (ClientData) DEF_SCALE_FG_MONO, 0}, + (ClientData) DEF_SCALE_FG_MONO, 0}, {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1, - Tk_Offset(TkScale, fromValue), 0, 0, 0}, + Tk_Offset(TkScale, fromValue), 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR, -1, Tk_Offset(TkScale, highlightBorder), - 0, (ClientData) DEF_SCALE_HIGHLIGHT_BG_MONO, 0}, + 0, (ClientData) DEF_SCALE_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_SCALE_HIGHLIGHT, -1, Tk_Offset(TkScale, highlightColorPtr), 0, 0, 0}, @@ -93,42 +93,42 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_SCALE_LENGTH, -1, Tk_Offset(TkScale, length), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", - DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient), - 0, (ClientData) orientStrings, 0}, + DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient), + 0, (ClientData) orientStrings, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_SCALE_RELIEF, -1, Tk_Offset(TkScale, relief), 0, 0, 0}, {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", - DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay), - 0, 0, 0}, + DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay), + 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", - DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval), - 0, 0, 0}, + DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval), + 0, 0, 0}, {TK_OPTION_DOUBLE, "-resolution", "resolution", "Resolution", - DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution), - 0, 0, 0}, + DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution), + 0, 0, 0}, {TK_OPTION_BOOLEAN, "-showvalue", "showValue", "ShowValue", - DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue), - 0, 0, 0}, + DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue), + 0, 0, 0}, {TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength", - DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength), - 0, 0, 0}, + DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength), + 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, -1, Tk_Offset(TkScale, sliderRelief), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", - DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state), - 0, (ClientData) stateStrings, 0}, + DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state), + 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval", - DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval), - 0, 0, 0}, + DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval), + 0, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", - DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0}, + DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0}, {TK_OPTION_COLOR, "-troughcolor", "troughColor", "Background", - DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr), - 0, (ClientData) DEF_SCALE_TROUGH_MONO, 0}, + DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr), + 0, (ClientData) DEF_SCALE_TROUGH_MONO, 0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varNamePtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -217,7 +217,7 @@ Tk_ScaleObjCmd( } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), NULL); + Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -338,11 +338,11 @@ ScaleWidgetObjCmd( int index, result; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, - "option", 0, &index); + "option", 0, &index); if (result != TCL_OK) { return result; } @@ -620,10 +620,10 @@ ConfigureScale( */ scalePtr->fromValue = TkRoundToResolution(scalePtr, - scalePtr->fromValue); + scalePtr->fromValue); scalePtr->toValue = TkRoundToResolution(scalePtr, scalePtr->toValue); scalePtr->tickInterval = TkRoundToResolution(scalePtr, - scalePtr->tickInterval); + scalePtr->tickInterval); /* * Make sure that the tick interval has the right sign so that @@ -648,7 +648,7 @@ ConfigureScale( break; } if (!error) { - Tk_FreeSavedOptions(&savedOptions); + Tk_FreeSavedOptions(&savedOptions); } /* @@ -678,27 +678,26 @@ ConfigureScale( valuePtr, &varValue) != TCL_OK)) { ScaleSetVariable(scalePtr); } else { - char varString[TCL_DOUBLE_SPACE]; - char scaleString[TCL_DOUBLE_SPACE]; + char varString[TCL_DOUBLE_SPACE], scaleString[TCL_DOUBLE_SPACE]; + sprintf(varString, scalePtr->format, varValue); sprintf(scaleString, scalePtr->format, scalePtr->value); if (strcmp(varString, scaleString)) { ScaleSetVariable(scalePtr); } } - Tcl_TraceVar(interp, Tcl_GetString(scalePtr->varNamePtr), - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ScaleVarProc, (ClientData) scalePtr); + Tcl_TraceVar(interp, Tcl_GetString(scalePtr->varNamePtr), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + ScaleVarProc, (ClientData) scalePtr); } ScaleWorldChanged((ClientData) scalePtr); if (error) { - Tcl_SetObjResult(interp, errorResult); + Tcl_SetObjResult(interp, errorResult); Tcl_DecrRefCount(errorResult); return TCL_ERROR; - } else { - return TCL_OK; } + return TCL_OK; } /* @@ -1212,10 +1211,10 @@ ScaleVarProc( } resultStr = NULL; valuePtr = Tcl_ObjGetVar2(interp, scalePtr->varNamePtr, NULL, - TCL_GLOBAL_ONLY); + TCL_GLOBAL_ONLY); result = Tcl_GetDoubleFromObj(interp, valuePtr, &value); if (result != TCL_OK) { - resultStr = "can't assign non-numeric value to scale variable"; + resultStr = "can't assign non-numeric value to scale variable"; ScaleSetVariable(scalePtr); } else { scalePtr->value = TkRoundToResolution(scalePtr, value); diff --git a/generic/tkSelect.h b/generic/tkSelect.h index 784dedf..5ce2fa5 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.6 2005/11/27 02:36:14 das 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.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 */ diff --git a/generic/tkText.h b/generic/tkText.h index 5ac25aa..d691a2d 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.h,v 1.31 2007/01/18 23:20:37 nijtmans Exp $ + * RCS: @(#) $Id: tkText.h,v 1.32 2007/06/24 16:07:35 dkf Exp $ */ #ifndef _TKTEXT @@ -120,7 +120,7 @@ typedef struct TkTextEmbWindow { * temporary value, copied from 'clients', to * make option table updating easier. NULL * means that the window hasn't been created - * yet. */ + * yet. */ TkTextLine *linePtr; /* Line structure that contains this * window. */ char *create; /* Script to create window on-demand. NULL @@ -149,12 +149,12 @@ typedef struct TkTextEmbImage { * text widget. This is used when the image * changes or is deleted. */ TkTextLine *linePtr; /* Line structure that contains this image. */ - char *imageString; /* Name of the image for this segment */ + char *imageString; /* Name of the image for this segment. */ char *imageName; /* Name used by text widget to identify this - * image. May be unique-ified */ + * image. May be unique-ified. */ char *name; /* Name used in the hash table. Used by * "image names" to identify this instance of - * the image */ + * the image. */ Tk_Image image; /* Image for this segment. NULL means that the * image hasn't been created yet. */ int align; /* How to align image in vertical space. See @@ -172,7 +172,8 @@ typedef struct TkTextEmbImage { */ typedef struct TkTextSegment { - const struct Tk_SegType *typePtr; /* Pointer to record describing segment's + const struct Tk_SegType *typePtr; + /* Pointer to record describing segment's * type. */ struct TkTextSegment *nextPtr; /* Next in list of segments for this line, or @@ -305,9 +306,10 @@ typedef struct TkTextTag { * freed explicitly. For 'sel' tags this is * just a static string, so again need not be * freed. */ - const struct TkText*textPtr;/* If non-NULL, then this tag only applies to - * the given text widget (when there are peer - * widgets). */ + const struct TkText *textPtr; + /* If non-NULL, then this tag only applies to + * the given text widget (when there are peer + * widgets). */ int priority; /* Priority of this tag within widget. 0 means * lowest priority. Exactly one tag has each * integer value between 0 and numTags-1. */ @@ -317,7 +319,7 @@ typedef struct TkTextTag { * there is no information about the tag. One * or more children of the node do contain * information about the tag. */ - int toggleCount; /* Total number of tag toggles */ + int toggleCount; /* Total number of tag toggles. */ /* * Information for displaying text with this tag. The information belows @@ -330,7 +332,7 @@ typedef struct TkTextTag { Tk_3DBorder border; /* Used for drawing background. NULL means no * value specified here. */ int borderWidth; /* Width of 3-D border for background. */ - Tcl_Obj* borderWidthPtr; /* Width of 3-D border for background. */ + Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */ char *reliefString; /* -relief option string (malloc-ed). NULL * means option not specified. */ int relief; /* 3-D relief for background. */ @@ -393,8 +395,8 @@ typedef struct TkTextTag { struct TkTextTabArray *tabArrayPtr; /* Info about tabs for tag (malloc-ed) or * NULL. Corresponds to tabString. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if - * not specified). */ + int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if + * not specified). */ char *underlineString; /* -underline option string (malloc-ed). NULL * means option not specified. */ int underline; /* Non-zero means draw underline underneath @@ -414,10 +416,10 @@ typedef struct TkTextTag { * (so need to redisplay if tag changes). */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - int affectsDisplayGeometry; /* Non-zero means that this tag affects the - * size with which information is displayed on - * the screen (so need to recalculate line - * dimensions if tag changes). */ + int affectsDisplayGeometry; /* Non-zero means that this tag affects the + * size with which information is displayed on + * the screen (so need to recalculate line + * dimensions if tag changes). */ } TkTextTag; #define TK_TAG_AFFECTS_DISPLAY 0x1 @@ -518,8 +520,7 @@ typedef enum { */ typedef struct TkSharedText { - int refCount; /* Reference count this shared object */ - + int refCount; /* Reference count this shared object. */ TkTextBTree tree; /* B-tree representation of text and tags for * widget. */ Tcl_HashTable tagTable; /* Hash table that maps from tag names to @@ -548,33 +549,33 @@ typedef struct TkSharedText { * exist, so the table hasn't been created. * Each "object" used for this table is the * name of a tag. */ - int stateEpoch; /* This is incremented each time the B-tree's - * contents change structurally, and means - * that any cached TkTextIndex objects are no - * longer valid. */ + int stateEpoch; /* This is incremented each time the B-tree's + * contents change structurally, and means + * that any cached TkTextIndex objects are no + * longer valid. */ /* * Information related to the undo/redo functonality */ - TkUndoRedoStack *undoStack; /* The undo/redo stack */ + TkUndoRedoStack *undoStack; /* The undo/redo stack. */ int undo; /* Non-zero means the undo/redo behaviour is - * enabled */ + * enabled. */ int maxUndo; /* The maximum depth of the undo stack * expressed as the maximum number of compound - * statements */ + * statements. */ int autoSeparators; /* Non-zero means the separators will be - * inserted automatically */ + * inserted automatically. */ int modifiedSet; /* Flag indicating that the 'dirtynesss' of * the text widget has been expplicitly set. */ int isDirty; /* Flag indicating the 'dirtynesss' of the * text widget. If the flag is not zero, * unsaved modifications have been applied to - * the text widget */ + * the text widget. */ int isDirtyIncrement; /* Amount with which the isDirty flag is - * incremented every edit action */ + * incremented every edit action. */ TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode - * was */ + * was. */ /* * Keep track of all the peers @@ -595,14 +596,13 @@ typedef struct TkText { */ TkSharedText *sharedTextPtr;/* Shared section of all peers. */ - struct TkText *next; /* Next in list of linked peers. */ - TkTextLine *start; /* First B-tree line to show, or NULL to start - * at the beginning. */ - TkTextLine *end; /* Last B-tree line to show, or NULL for up to - * the end. */ - int pixelReference; /* Counter into the current tree reference - * index corresponding to this widget */ - + struct TkText *next; /* Next in list of linked peers. */ + TkTextLine *start; /* First B-tree line to show, or NULL to start + * at the beginning. */ + TkTextLine *end; /* Last B-tree line to show, or NULL for up to + * the end. */ + int pixelReference; /* Counter into the current tree reference + * index corresponding to this widget. */ int abortSelections; /* Set to 1 whenever the text is modified in a * way that interferes with selection * retrieval: used to abort incremental @@ -624,6 +624,7 @@ typedef struct TkText { Tcl_Command widgetCmd; /* Token for text's widget command. */ int state; /* Either STATE_NORMAL or STATE_DISABLED. A * text widget is read-only when disabled. */ + /* * Default information for displaying (may be overridden by tags applied * to ranges of characters). @@ -656,12 +657,12 @@ typedef struct TkText { * for the same text line. */ int spacing3; /* Default extra spacing below last display * line for each text line. */ - Tcl_Obj *tabOptionPtr; /* Value of -tabs option string */ + Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ TkTextTabArray *tabArrayPtr; /* Information about tab stops (malloc'ed). * NULL means perform default tabbing * behavior. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ + int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ /* * Additional information used for displaying: @@ -693,9 +694,9 @@ typedef struct TkText { Tk_3DBorder inactiveSelBorder; /* Border and background for selected * characters when they don't have the - * focus. */ + * focus. */ int selBorderWidth; /* Width of border around selection. */ - Tcl_Obj* selBorderWidthPtr; /* Width of border around selection. */ + Tcl_Obj *selBorderWidthPtr; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected text. This is * a copy of information in *selTagPtr, so it * shouldn't be explicitly freed. */ @@ -752,28 +753,25 @@ typedef struct TkText { * vertical scrollbar when view changes. */ int flags; /* Miscellaneous flags; see below for * definitions. */ - Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ + int refCount; /* Number of cached TkTextIndex objects + * refering to us. */ + int insertCursorType; /* 0 = standard insertion cursor, 1 = block + * cursor. */ - int refCount; /* Number of cached TkTextIndex objects - * refering to us */ - int insertCursorType; /* 0 = standard insertion cursor, 1 = block - * cursor. */ /* * Copies of information from the shared section relating to the undo/redo * functonality */ int undo; /* Non-zero means the undo/redo behaviour is - * enabled */ - + * enabled. */ int maxUndo; /* The maximum depth of the undo stack * expressed as the maximum number of compound - * statements */ - + * statements. */ int autoSeparators; /* Non-zero means the separators will be - * inserted automatically */ + * inserted automatically. */ } TkText; /* @@ -790,10 +788,10 @@ typedef struct TkText { * duration of button presses. * UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated * during next redisplay operation. - * NEED_REPICK This appears unused and should probably be - * ignored - * OPTIONS_FREED The widget's options have been freed - * DESTROYED The widget is going away + * NEED_REPICK This appears unused and should probably be + * ignored. + * OPTIONS_FREED The widget's options have been freed. + * DESTROYED The widget is going away. */ #define GOT_SELECTION 1 @@ -879,62 +877,62 @@ typedef int TkTextCountType; #define LOTSA_TAGS 1000 typedef struct TkTextElideInfo { - int numTags; /* Total tags in widget */ - int elide; /* Is the state currently elided */ - int elidePriority; /* Tag priority controlling elide state */ - TkTextSegment *segPtr; /* Segment to look at next */ - int segOffset; /* Offset of segment within line */ + int numTags; /* Total tags in widget. */ + int elide; /* Is the state currently elided. */ + int elidePriority; /* Tag priority controlling elide state. */ + TkTextSegment *segPtr; /* Segment to look at next. */ + int segOffset; /* Offset of segment within line. */ int deftagCnts[LOTSA_TAGS]; TkTextTag *deftagPtrs[LOTSA_TAGS]; - int *tagCnts; /* 0 or 1 depending if the tag with that - * priority is on or off */ - TkTextTag **tagPtrs; /* Only filled with a tagPtr if the - * corresponding tagCnt is 1 */ + int *tagCnts; /* 0 or 1 depending if the tag with that + * priority is on or off. */ + TkTextTag **tagPtrs; /* Only filled with a tagPtr if the + * corresponding tagCnt is 1. */ } TkTextElideInfo; /* - * The constant below is used to specify a line when what is really - * wanted is the entire text. For now, just use a very big number. + * The constant below is used to specify a line when what is really wanted is + * the entire text. For now, just use a very big number. */ -#define TK_END_OF_TEXT 1000000 +#define TK_END_OF_TEXT 1000000 /* * The following definition specifies the maximum number of characters needed * in a string to hold a position specifier. */ -#define TK_POS_CHARS 30 +#define TK_POS_CHARS 30 /* * Mask used for those options which may impact the pixel height calculations * of individual lines displayed in the widget. */ -#define TK_TEXT_LINE_GEOMETRY 1 +#define TK_TEXT_LINE_GEOMETRY 1 /* * Mask used for those options which may impact the start and end lines used * in the widget. */ -#define TK_TEXT_LINE_RANGE 2 +#define TK_TEXT_LINE_RANGE 2 /* * Used as 'action' values in calls to TkTextInvalidateLineMetrics */ -#define TK_TEXT_INVALIDATE_ONLY 0 -#define TK_TEXT_INVALIDATE_INSERT 1 -#define TK_TEXT_INVALIDATE_DELETE 2 +#define TK_TEXT_INVALIDATE_ONLY 0 +#define TK_TEXT_INVALIDATE_INSERT 1 +#define TK_TEXT_INVALIDATE_DELETE 2 /* * Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or * positive values indicate a number of pixels. */ -#define TK_TEXT_PICKPLACE -1 -#define TK_TEXT_NOPIXELADJUST -2 +#define TK_TEXT_PICKPLACE -1 +#define TK_TEXT_NOPIXELADJUST -2 /* * Declarations for variables shared among the text-related files: @@ -1075,7 +1073,7 @@ MODULE_SCOPE void TkTextIndexForwChars(const TkText *textPtr, TkTextIndex *dstPtr, TkTextCountType type); MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x, TkTextIndex *indexPtr); -MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr, +MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr, const TkTextIndex *indexPtr); MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr, int *offsetPtr); @@ -1096,7 +1094,7 @@ MODULE_SCOPE int TkTextIsElided(const TkText *textPtr, MODULE_SCOPE TkTextIndex *TkTextMakeByteIndex(TkTextBTree tree, const TkText *textPtr, int lineIndex, int byteIndex, TkTextIndex *indexPtr); -MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr, +MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr, int pixelIndex, TkTextIndex *indexPtr); MODULE_SCOPE void TkTextInvalidateLineMetrics( TkSharedText *sharedTextPtr, TkText *textPtr, @@ -1118,7 +1116,7 @@ MODULE_SCOPE void TkTextPixelIndex(TkText *textPtr, int x, int y, TkTextIndex *indexPtr, int *nearest); MODULE_SCOPE int TkTextPrintIndex(const TkText *textPtr, const TkTextIndex *indexPtr, char *string); -MODULE_SCOPE Tcl_Obj* TkTextNewIndexObj(TkText *textPtr, +MODULE_SCOPE Tcl_Obj * TkTextNewIndexObj(TkText *textPtr, const TkTextIndex *indexPtr); MODULE_SCOPE void TkTextRedrawRegion(TkText *textPtr, int x, int y, int width, int height); diff --git a/generic/tkUndo.h b/generic/tkUndo.h index 5d50edd..c4c83a4 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -1,122 +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.5 2005/11/27 02:36:14 das 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.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 */ -- cgit v0.12