diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-18 14:15:49 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-18 14:15:49 (GMT) |
commit | 9bd0f9a676dc8cf52d4f73b0cf766d4643b64956 (patch) | |
tree | f23e6916460d21f4cdab3544051f4c297ef9007b | |
parent | 3eac0e260bf334098c61c36eff9890b2c97a52b3 (diff) | |
parent | c00e981adab518faf0a905cb261fbddae340d33f (diff) | |
download | tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.zip tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.tar.gz tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.tar.bz2 |
Merge 8.7
148 files changed, 1682 insertions, 2096 deletions
diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index ccbb846..a0cc262 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -193,3 +193,4 @@ jobs: echo "::error::Failure during Test" exit 1 } + timeout-minutes: 15 diff --git a/.github/workflows/linux-with-tcl86-build.yml b/.github/workflows/linux-with-tcl86-build.yml index 5e79e3c..814330f 100644 --- a/.github/workflows/linux-with-tcl86-build.yml +++ b/.github/workflows/linux-with-tcl86-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -174,3 +174,4 @@ jobs: echo "::error::Failure during Test" exit 1 } + timeout-minutes: 15 diff --git a/.github/workflows/linux-with-tcl9-build.yml b/.github/workflows/linux-with-tcl9-build.yml index 5ecd8ea..7d79a59 100644 --- a/.github/workflows/linux-with-tcl9-build.yml +++ b/.github/workflows/linux-with-tcl9-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -174,3 +174,4 @@ jobs: echo "::error::Failure during Test" exit 1 } + timeout-minutes: 15 diff --git a/.github/workflows/linux-with-tcl91-build.yml b/.github/workflows/linux-with-tcl91-build.yml index a2dd5fb..fb79421 100644 --- a/.github/workflows/linux-with-tcl91-build.yml +++ b/.github/workflows/linux-with-tcl91-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -174,3 +174,4 @@ jobs: echo "::error::Failure during Test" exit 1 } + timeout-minutes: 15 diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 669abc6..0c89a7b 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -54,6 +54,7 @@ jobs: echo "::error::Failure during Test" exit 1 fi + timeout-minutes: 30 clang: runs-on: macos-11 strategy: @@ -159,6 +160,7 @@ jobs: echo "::error::Failure in ttk test results" exit 1 } + timeout-minutes: 15 - name: Carry out trial installation run: | make install || { diff --git a/.github/workflows/onefiledist.yml b/.github/workflows/onefiledist.yml index dd99523..ab0ef26 100644 --- a/.github/workflows/onefiledist.yml +++ b/.github/workflows/onefiledist.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 4db21ba..d5153d6 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -3,7 +3,7 @@ on: push: branches: - "main" - - "core-8-branch" + - "core-8-6-branch" tags: - "core-**" permissions: @@ -84,6 +84,7 @@ jobs: env: CI_BUILD_WITH_MSVC: 1 shell: bash + timeout-minutes: 15 - name: Build Help (OPTS=${{ matrix.symbols }}) run: | &nmake -f makefile.vc htmlhelp OPTS=${{ matrix.symbols }} @@ -171,3 +172,4 @@ jobs: echo "::error::Failure during Test" exit 1 } + timeout-minutes: 15 diff --git a/compat/stdint.h b/compat/stdint.h deleted file mode 100644 index 88383b0..0000000 --- a/compat/stdint.h +++ /dev/null @@ -1,919 +0,0 @@ -/* A portable stdint.h - **************************************************************************** - * BSD License: - **************************************************************************** - * - * Copyright (c) 2005-2016 Paul Hsieh - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - **************************************************************************** - * - * Version 0.1.16.0 - * - * The ANSI C standard committee, for the C99 standard, specified the - * inclusion of a new standard include file called stdint.h. This is - * a very useful and long desired include file which contains several - * very precise definitions for integer scalar types that is critically - * important for making several classes of applications portable - * including cryptography, hashing, variable length integer libraries - * and so on. But for most developers its likely useful just for - * programming sanity. - * - * The problem is that some compiler vendors chose to ignore the C99 - * standard and some older compilers have no opportunity to be updated. - * Because of this situation, simply including stdint.h in your code - * makes it unportable. - * - * So that's what this file is all about. It's an attempt to build a - * single universal include file that works on as many platforms as - * possible to deliver what stdint.h is supposed to. Even compilers - * that already come with stdint.h can use this file instead without - * any loss of functionality. A few things that should be noted about - * this file: - * - * 1) It is not guaranteed to be portable and/or present an identical - * interface on all platforms. The extreme variability of the - * ANSI C standard makes this an impossibility right from the - * very get go. Its really only meant to be useful for the vast - * majority of platforms that possess the capability of - * implementing usefully and precisely defined, standard sized - * integer scalars. Systems which are not intrinsically 2s - * complement may produce invalid constants. - * - * 2) There is an unavoidable use of non-reserved symbols. - * - * 3) Other standard include files are invoked. - * - * 4) This file may come in conflict with future platforms that do - * include stdint.h. The hope is that one or the other can be - * used with no real difference. - * - * 5) In the current version, if your platform can't represent - * int32_t, int16_t and int8_t, it just dumps out with a compiler - * error. - * - * 6) 64 bit integers may or may not be defined. Test for their - * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. - * Note that this is different from the C99 specification which - * requires the existence of 64 bit support in the compiler. If - * this is not defined for your platform, yet it is capable of - * dealing with 64 bits then it is because this file has not yet - * been extended to cover all of your system's capabilities. - * - * 7) (u)intptr_t may or may not be defined. Test for its presence - * with the test: #ifdef PTRDIFF_MAX. If this is not defined - * for your platform, then it is because this file has not yet - * been extended to cover all of your system's capabilities, not - * because its optional. - * - * 8) The following might not been defined even if your platform is - * capable of defining it: - * - * WCHAR_MIN - * WCHAR_MAX - * (u)int64_t - * PTRDIFF_MIN - * PTRDIFF_MAX - * (u)intptr_t - * - * 9) The following have not been defined: - * - * WINT_MIN - * WINT_MAX - * - * 10) The criteria for defining (u)int_least(*)_t isn't clear, - * except for systems which don't have a type that precisely - * defined 8, 16, or 32 bit types (which this include file does - * not support anyways). Default definitions have been given. - * - * 11) The criteria for defining (u)int_fast(*)_t isn't something I - * would trust to any particular compiler vendor or the ANSI C - * committee. It is well known that "compatible systems" are - * commonly created that have very different performance - * characteristics from the systems they are compatible with, - * especially those whose vendors make both the compiler and the - * system. Default definitions have been given, but its strongly - * recommended that users never use these definitions for any - * reason (they do *NOT* deliver any serious guarantee of - * improved performance -- not in this file, nor any vendor's - * stdint.h). - * - * 12) The following macros: - * - * PRINTF_INTMAX_MODIFIER - * PRINTF_INT64_MODIFIER - * PRINTF_INT32_MODIFIER - * PRINTF_INT16_MODIFIER - * PRINTF_LEAST64_MODIFIER - * PRINTF_LEAST32_MODIFIER - * PRINTF_LEAST16_MODIFIER - * PRINTF_INTPTR_MODIFIER - * - * are strings which have been defined as the modifiers required - * for the "d", "u" and "x" printf formats to correctly output - * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, - * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. - * PRINTF_INTPTR_MODIFIER is not defined for some systems which - * provide their own stdint.h. PRINTF_INT64_MODIFIER is not - * defined if INT64_MAX is not defined. These are an extension - * beyond what C99 specifies must be in stdint.h. - * - * In addition, the following macros are defined: - * - * PRINTF_INTMAX_HEX_WIDTH - * PRINTF_INT64_HEX_WIDTH - * PRINTF_INT32_HEX_WIDTH - * PRINTF_INT16_HEX_WIDTH - * PRINTF_INT8_HEX_WIDTH - * PRINTF_INTMAX_DEC_WIDTH - * PRINTF_INT64_DEC_WIDTH - * PRINTF_INT32_DEC_WIDTH - * PRINTF_INT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * PRINTF_UINTMAX_DEC_WIDTH - * PRINTF_UINT64_DEC_WIDTH - * PRINTF_UINT32_DEC_WIDTH - * PRINTF_UINT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * - * Which specifies the maximum number of characters required to - * print the number of that type in either hexadecimal or decimal. - * These are an extension beyond what C99 specifies must be in - * stdint.h. - * - * Compilers tested (all with 0 warnings at their highest respective - * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 - * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio - * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 - * - * This file should be considered a work in progress. Suggestions for - * improvements, especially those which increase coverage are strongly - * encouraged. - * - * Acknowledgements - * - * The following people have made significant contributions to the - * development and testing of this file: - * - * Chris Howie - * John Steele Scott - * Dave Thorup - * John Dill - * Florian Wobbe - * Christopher Sean Morrison - * Mikkel Fahnoe Jorgensen - * - */ - -#include <stddef.h> -#include <limits.h> -#include <signal.h> - -/* - * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and - * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. - */ - -#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) -#include <stdint.h> -#define _PSTDINT_H_INCLUDED -# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__)) -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "l" -# endif -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# else -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# ifndef PRINTF_INT32_MODIFIER -# if (UINT_MAX == UINT32_MAX) -# define PRINTF_INT32_MODIFIER "" -# else -# define PRINTF_INT32_MODIFIER "l" -# endif -# endif -# endif -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_UINT64_HEX_WIDTH -# define PRINTF_UINT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_UINT32_HEX_WIDTH -# define PRINTF_UINT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_UINT16_HEX_WIDTH -# define PRINTF_UINT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_UINT8_HEX_WIDTH -# define PRINTF_UINT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -# endif -# ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -# endif -# ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_UINTMAX_HEX_WIDTH -# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif -# ifndef PRINTF_UINTMAX_DEC_WIDTH -# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif - -/* - * Something really weird is going on with Open Watcom. Just pull some of - * these duplicated definitions from Open Watcom's stdint.h file for now. - */ - -# if defined (__WATCOMC__) && __WATCOMC__ >= 1250 -# if !defined (INT64_C) -# define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) -# endif -# if !defined (UINT64_C) -# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) -# endif -# if !defined (INT32_C) -# define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) -# endif -# if !defined (UINT32_C) -# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) -# endif -# if !defined (INT16_C) -# define INT16_C(x) (x) -# endif -# if !defined (UINT16_C) -# define UINT16_C(x) (x) -# endif -# if !defined (INT8_C) -# define INT8_C(x) (x) -# endif -# if !defined (UINT8_C) -# define UINT8_C(x) (x) -# endif -# if !defined (UINT64_MAX) -# define UINT64_MAX 18446744073709551615ULL -# endif -# if !defined (INT64_MAX) -# define INT64_MAX 9223372036854775807LL -# endif -# if !defined (UINT32_MAX) -# define UINT32_MAX 4294967295UL -# endif -# if !defined (INT32_MAX) -# define INT32_MAX 2147483647L -# endif -# if !defined (INTMAX_MAX) -# define INTMAX_MAX INT64_MAX -# endif -# if !defined (INTMAX_MIN) -# define INTMAX_MIN INT64_MIN -# endif -# endif -#endif - -/* - * I have no idea what is the truly correct thing to do on older Solaris. - * From some online discussions, this seems to be what is being - * recommended. For people who actually are developing on older Solaris, - * what I would like to know is, does this define all of the relevant - * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is - * considered optional. - */ - -#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED) -#include <sys/inttypes.h> -#define _PSTDINT_H_INCLUDED -#endif - -#ifndef _PSTDINT_H_INCLUDED -#define _PSTDINT_H_INCLUDED - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t)-1) -#endif - -/* - * Deduce the type assignments from limits.h under the assumption that - * integer sizes in bits are powers of 2, and follow the ANSI - * definitions. - */ - -#ifndef UINT8_MAX -# define UINT8_MAX 0xff -#endif -#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks) -# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) - typedef unsigned char uint8_t; -# define UINT8_C(v) ((uint8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef INT8_MAX -# define INT8_MAX 0x7f -#endif -#ifndef INT8_MIN -# define INT8_MIN INT8_C(0x80) -#endif -#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks) -# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) - typedef signed char int8_t; -# define INT8_C(v) ((int8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef UINT16_MAX -# define UINT16_MAX 0xffff -#endif -#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks) -#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) - typedef unsigned int uint16_t; -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -# define UINT16_C(v) ((uint16_t) (v)) -#elif (USHRT_MAX == UINT16_MAX) - typedef unsigned short uint16_t; -# define UINT16_C(v) ((uint16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT16_MAX -# define INT16_MAX 0x7fff -#endif -#ifndef INT16_MIN -# define INT16_MIN INT16_C(0x8000) -#endif -#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks) -#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) - typedef signed int int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -#elif (SHRT_MAX == INT16_MAX) - typedef signed short int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef UINT32_MAX -# define UINT32_MAX (0xffffffffUL) -#endif -#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks) -#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) - typedef unsigned long uint32_t; -# define UINT32_C(v) v ## UL -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (UINT_MAX == UINT32_MAX) - typedef unsigned int uint32_t; -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# define UINT32_C(v) v ## U -#elif (USHRT_MAX == UINT32_MAX) - typedef unsigned short uint32_t; -# define UINT32_C(v) ((unsigned short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT32_MAX -# define INT32_MAX (0x7fffffffL) -#endif -#ifndef INT32_MIN -# define INT32_MIN INT32_C(0x80000000) -#endif -#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks) -#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) - typedef signed long int32_t; -# define INT32_C(v) v ## L -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (INT_MAX == INT32_MAX) - typedef signed int int32_t; -# define INT32_C(v) v -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#elif (SHRT_MAX == INT32_MAX) - typedef signed short int32_t; -# define INT32_C(v) ((short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -/* - * The macro stdint_int64_defined is temporarily used to record - * whether or not 64 integer support is available. It must be - * defined for any 64 integer extensions for new platforms that are - * added. - */ - -#undef stdint_int64_defined -#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) -# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# endif -#endif - -#if !defined (stdint_int64_defined) -# if defined(__GNUC__) && !defined(vxWorks) -# define stdint_int64_defined - __extension__ typedef long long int64_t; - __extension__ typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) -# define stdint_int64_defined - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; -# define UINT64_C(v) v ## UI64 -# define INT64_C(v) v ## I64 -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "I64" -# endif -# endif -#endif - -#if !defined (LONG_LONG_MAX) && defined (INT64_C) -# define LONG_LONG_MAX INT64_C (9223372036854775807) -#endif -#ifndef ULONG_LONG_MAX -# define ULONG_LONG_MAX UINT64_C (18446744073709551615) -#endif - -#if !defined (INT64_MAX) && defined (INT64_C) -# define INT64_MAX INT64_C (9223372036854775807) -#endif -#if !defined (INT64_MIN) && defined (INT64_C) -# define INT64_MIN INT64_C (-9223372036854775808) -#endif -#if !defined (UINT64_MAX) && defined (INT64_C) -# define UINT64_MAX UINT64_C (18446744073709551615) -#endif - -/* - * Width of hexadecimal for number field. - */ - -#ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -#endif -#ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -#endif -#ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -#endif -#ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -#endif -#ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -#endif -#ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -#endif -#ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -#endif -#ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -#endif - -/* - * Ok, lets not worry about 128 bit integers for now. Moore's law says - * we don't need to worry about that until about 2040 at which point - * we'll have bigger things to worry about. - */ - -#ifdef stdint_int64_defined - typedef int64_t intmax_t; - typedef uint64_t uintmax_t; -# define INTMAX_MAX INT64_MAX -# define INTMAX_MIN INT64_MIN -# define UINTMAX_MAX UINT64_MAX -# define UINTMAX_C(v) UINT64_C(v) -# define INTMAX_C(v) INT64_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH -# endif -#else - typedef int32_t intmax_t; - typedef uint32_t uintmax_t; -# define INTMAX_MAX INT32_MAX -# define UINTMAX_MAX UINT32_MAX -# define UINTMAX_C(v) UINT32_C(v) -# define INTMAX_C(v) INT32_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH -# endif -#endif - -/* - * Because this file currently only supports platforms which have - * precise powers of 2 as bit sizes for the default integers, the - * least definitions are all trivial. Its possible that a future - * version of this file could have different definitions. - */ - -#ifndef stdint_least_defined - typedef int8_t int_least8_t; - typedef uint8_t uint_least8_t; - typedef int16_t int_least16_t; - typedef uint16_t uint_least16_t; - typedef int32_t int_least32_t; - typedef uint32_t uint_least32_t; -# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER -# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER -# define UINT_LEAST8_MAX UINT8_MAX -# define INT_LEAST8_MAX INT8_MAX -# define UINT_LEAST16_MAX UINT16_MAX -# define INT_LEAST16_MAX INT16_MAX -# define UINT_LEAST32_MAX UINT32_MAX -# define INT_LEAST32_MAX INT32_MAX -# define INT_LEAST8_MIN INT8_MIN -# define INT_LEAST16_MIN INT16_MIN -# define INT_LEAST32_MIN INT32_MIN -# ifdef stdint_int64_defined - typedef int64_t int_least64_t; - typedef uint64_t uint_least64_t; -# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER -# define UINT_LEAST64_MAX UINT64_MAX -# define INT_LEAST64_MAX INT64_MAX -# define INT_LEAST64_MIN INT64_MIN -# endif -#endif -#undef stdint_least_defined - -/* - * The ANSI C committee has defined *int*_fast*_t types as well. This, - * of course, defies rationality -- you can't know what will be fast - * just from the type itself. Even for a given architecture, compatible - * implementations might have different performance characteristics. - * Developers are warned to stay away from these types when using this - * or any other stdint.h. - */ - -typedef int_least8_t int_fast8_t; -typedef uint_least8_t uint_fast8_t; -typedef int_least16_t int_fast16_t; -typedef uint_least16_t uint_fast16_t; -typedef int_least32_t int_fast32_t; -typedef uint_least32_t uint_fast32_t; -#define UINT_FAST8_MAX UINT_LEAST8_MAX -#define INT_FAST8_MAX INT_LEAST8_MAX -#define UINT_FAST16_MAX UINT_LEAST16_MAX -#define INT_FAST16_MAX INT_LEAST16_MAX -#define UINT_FAST32_MAX UINT_LEAST32_MAX -#define INT_FAST32_MAX INT_LEAST32_MAX -#define INT_FAST8_MIN INT_LEAST8_MIN -#define INT_FAST16_MIN INT_LEAST16_MIN -#define INT_FAST32_MIN INT_LEAST32_MIN -#ifdef stdint_int64_defined - typedef int_least64_t int_fast64_t; - typedef uint_least64_t uint_fast64_t; -# define UINT_FAST64_MAX UINT_LEAST64_MAX -# define INT_FAST64_MAX INT_LEAST64_MAX -# define INT_FAST64_MIN INT_LEAST64_MIN -#endif - -#undef stdint_int64_defined - -/* - * Whatever piecemeal, per compiler thing we can do about the wchar_t - * type limits. - */ - -#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks) -# include <wchar.h> -# ifndef WCHAR_MIN -# define WCHAR_MIN 0 -# endif -# ifndef WCHAR_MAX -# define WCHAR_MAX ((wchar_t)-1) -# endif -#endif - -/* - * Whatever piecemeal, per compiler/platform thing we can do about the - * (u)intptr_t types and limits. - */ - -#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T) -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -#ifndef STDINT_H_UINTPTR_T_DEFINED -# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__) -# define stdint_intptr_bits 64 -# elif defined (__WATCOMC__) || defined (__TURBOC__) -# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) -# define stdint_intptr_bits 16 -# else -# define stdint_intptr_bits 32 -# endif -# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__) -# define stdint_intptr_bits 32 -# elif defined (__INTEL_COMPILER) -/* TODO -- what did Intel do about x86-64? */ -# else -/* #error "This platform might not be supported yet" */ -# endif - -# ifdef stdint_intptr_bits -# define stdint_intptr_glue3_i(a,b,c) a##b##c -# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) -# ifndef PRINTF_INTPTR_MODIFIER -# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) -# endif -# ifndef PTRDIFF_MAX -# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef PTRDIFF_MIN -# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef UINTPTR_MAX -# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MAX -# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MIN -# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef INTPTR_C -# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) -# endif -# ifndef UINTPTR_C -# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) -# endif - typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; - typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; -# else -/* TODO -- This following is likely wrong for some platforms, and does - nothing for the definition of uintptr_t. */ - typedef ptrdiff_t intptr_t; -# endif -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -/* - * Assumes sig_atomic_t is signed and we have a 2s complement machine. - */ - -#ifndef SIG_ATOMIC_MAX -# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) -#endif - -#endif - -#if defined (__TEST_PSTDINT_FOR_CORRECTNESS) - -/* - * Please compile with the maximum warning settings to make sure macros are - * not defined more than once. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#define glue3_aux(x,y,z) x ## y ## z -#define glue3(x,y,z) glue3_aux(x,y,z) - -#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0); -#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0); - -#define DECL(us,bits) glue3(DECL,us,) (bits) - -#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits) - -#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; } - -#define X_SIZE_MAX ((size_t)-1) - -int main () { - int err_n = 0; - int err_first = 0; - DECL(I,8) - DECL(U,8) - DECL(I,16) - DECL(U,16) - DECL(I,32) - DECL(U,32) -#ifdef INT64_MAX - DECL(I,64) - DECL(U,64) -#endif - intmax_t imax = INTMAX_C(0); - uintmax_t umax = UINTMAX_C(0); - char str0[256], str1[256]; - - sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647)); - if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH)); - sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295)); - if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807)); - if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1))); - sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591)); - if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1))); -#endif - - sprintf (str0, "%d %x\n", 0, ~0); - - sprintf (str1, "%d %x\n", i8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1)); - sprintf (str1, "%u %x\n", u8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1)); - sprintf (str1, "%d %x\n", i16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1)); - sprintf (str1, "%u %x\n", u16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1)); -#endif - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1)); - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1)); - - TESTUMAX(8); - TESTUMAX(16); - TESTUMAX(32); -#ifdef INT64_MAX - TESTUMAX(64); -#endif - -#define STR(v) #v -#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v)); - if (err_n) { - printf ("pstdint.h is not correct. Please use sizes below to correct it:\n"); - } - - Q(int) - Q(unsigned) - Q(long int) - Q(short int) - Q(int8_t) - Q(int16_t) - Q(int32_t) -#ifdef INT64_MAX - Q(int64_t) -#endif - -#if UINT_MAX < X_SIZE_MAX - printf ("UINT_MAX < X_SIZE_MAX\n"); -#else - printf ("UINT_MAX >= X_SIZE_MAX\n"); -#endif - printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX); - - return EXIT_SUCCESS; -} - -#endif diff --git a/doc/3DBorder.3 b/doc/3DBorder.3 index 0bc41d0..a6deb30 100644 --- a/doc/3DBorder.3 +++ b/doc/3DBorder.3 @@ -9,7 +9,7 @@ .so man.macros .BS .SH NAME -Tk_Alloc3DBorderFromObj, Tk_ClipDrawableToRect, Tk_DrawHighlightBorder, Tk_Get3DBorder, fBTk_Get3DBorderColors, Tk_Get3DBorderFromObj, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorderFromObj, Tk_Free3DBorder \- draw borders with three-dimensional appearance +Tk_Alloc3DBorderFromObj, Tk_ClipDrawableToRect, Tk_DrawHighlightBorder, Tk_Get3DBorder, Tk_Get3DBorderColors, Tk_Get3DBorderFromObj, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorderFromObj, Tk_Free3DBorder \- draw borders with three-dimensional appearance .SH SYNOPSIS .nf \fB#include <tk.h>\fR diff --git a/doc/AddOption.3 b/doc/AddOption.3 index a331455..fc46492 100644 --- a/doc/AddOption.3 +++ b/doc/AddOption.3 @@ -14,7 +14,7 @@ Tk_AddOption \- Add an option to the option database void \fBTk_AddOption\fR(\fItkwin, name, value, priority\fR) .sp -void +Tcl_Obj * \fBTk_GetSystemDefault\fR(\fItkwin, dbName, className\fR) .SH ARGUMENTS .AP Tk_Window tkwin in @@ -40,20 +40,22 @@ classes separated by asterisks or dots, in the usual X format. this value will be returned in calls to \fBTk_GetOption\fR. \fIPriority\fR specifies the priority of the value; when options are queried using \fBTk_GetOption\fR, the value with the highest priority -is returned. \fIPriority\fR must be between 0 and \fBTK_MAX_PRIO\fR. Some -common priority values are: -.IP 20 +is returned. \fIPriority\fR must be between 0 and \fBTK_MAX_PRIO\fR (100). +Some common priority values are: +.IP \fBTK_WIDGET_DEFAULT_PRIO\fR (20) Used for default values hard-coded into widgets. -.IP 40 +.IP \fBTK_STARTUP_FILE_PRIO\fR (40) Used for options specified in application-specific startup files. -.IP 60 +.IP \fBTK_USER_DEFAULT_PRIO\fR (60) Used for options specified in user-specific defaults files, such as \fB.Xdefaults\fR, resource databases loaded into the X server, or user-specific startup files. -.IP 80 +.IP \fBTK_INTERACTIVE_PRIO\fR (80) Used for options specified interactively after the application starts running. -\fBTk_GetSystemDefault\fR return a Tk_Uid string representation of the given \fIdbname\fR and \fIclassName\fR of a configuration option. +.PP +\fBTk_GetSystemDefault\fR returns a Tcl_Obj* with the string identifying +a configuration option matching the given \fIdbname\fR and \fIclassName\fR. Returns NULL if there are no system defaults that match this pair. .SH KEYWORDS class, name, option, add diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index 08d5342..c568dd6 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -127,20 +127,20 @@ called to free all of its resources. All of the option tables for a Tcl interpreter are freed automatically if the interpreter is deleted. .PP \fBTk_InitOptions\fR is invoked when a new widget is created to set the -default values for all of the widget's configuration options that do not -have \fBTK_OPTION_DONT_SET_DEFAULT\fR set in their \fIflags\fR field. +default values. \fBTk_InitOptions\fR is passed a token for an option table (\fIoptionTable\fR) and a pointer to a widget record (\fIrecordPtr\fR), which is the C structure that holds information about this widget. \fBTk_InitOptions\fR uses the information in the option table to choose an -appropriate default for each option, except those having -\fBTK_OPTION_DONT_SET_DEFAULT\fR set, then it stores the default value +appropriate default for each option, then it stores the default value directly into the widget record, overwriting any information that was already present in the widget record. \fBTk_InitOptions\fR normally returns \fBTCL_OK\fR. If an error occurred while setting the default values (e.g., because a default value was erroneous) then \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's result if -\fIinterp\fR is not NULL. +\fIinterp\fR is not NULL. For any widget's configuration option that +has \fBTK_OPTION_DONT_SET_DEFAULT\fR set in its \fIflags\fR field, +the above initialization is fully skipped, see below. .PP \fBTk_SetOptions\fR is invoked to modify configuration options based on information specified in a Tcl command. The command might be one that @@ -533,6 +533,10 @@ To implement a new type of option, you can use \fBTK_OPTION_STRING\fR as the type in the Tk_OptionSpec structure and set the \fIobjOffset\fR field but not the \fIinternalOffset\fR field. Then, after calling \fBTk_SetOptions\fR, convert the object to internal form yourself. +.PP +Ttk widgets do not support the \fIinternalOffset\fR machinery. +Option values of Ttk widgets are always stored as (Tcl_Obj *), meaning that +the \fIobjOffset\fR field must be used. .SH "CUSTOM OPTION TYPES" .PP Applications can extend the built-in configuration types with diff --git a/doc/entry.n b/doc/entry.n index 23b8cab..80e8428 100644 --- a/doc/entry.n +++ b/doc/entry.n @@ -239,6 +239,9 @@ or .QW \fBsel.f\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. .SS SUBCOMMANDS .PP The following commands are possible for entry widgets: diff --git a/doc/listbox.n b/doc/listbox.n index aa87904..fa24ec7 100644 --- a/doc/listbox.n +++ b/doc/listbox.n @@ -126,6 +126,9 @@ specified by \fIx\fR and \fIy\fR (in pixel coordinates). If no element covers that point, then the closest element to that point is used. .LP +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. In the widget command descriptions below, arguments named \fIindex\fR, \fIfirst\fR, and \fIlast\fR always contain text indices in one of the above forms. @@ -356,9 +356,14 @@ Specifies the entry numerically, where 0 corresponds to the top-most entry of the menu, 1 to the entry below it, and so on. .TP 12 +\fIid\fR +. +If the index does not satisfy one of the above forms then the menu is +searched for an entry with the specified id. +.TP 12 \fIpattern\fR . -If the index does not satisfy one of the above forms then this +If all of the above methods for finding an entry fail, this form is used. \fIPattern\fR is pattern-matched against the label of each entry in the menu, in order from the top down, until a matching entry is found. The rules of \fBstring match\fR @@ -366,6 +371,9 @@ are used. .PP If the index could match more than one of the above forms, then the form earlier in the above list takes precedence. +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. .PP The following widget commands are possible for menu widgets: .TP @@ -378,15 +386,18 @@ is specified as \fB{}\fR or \fBnone\fR, or if the specified entry is disabled, then the menu ends up with no active entry. Returns an empty string. .TP -\fIpathName \fBadd \fItype \fR?\fIoption value option value ...\fR? +\fIpathName \fBadd \fItype \fR?\fIid\fR? ?\fIoption value option value ...\fR? . Add a new entry to the bottom of the menu. The new entry's type is given by \fItype\fR and must be one of \fBcascade\fR, \fBcheckbutton\fR, \fBcommand\fR, \fBradiobutton\fR, or \fBseparator\fR, -or a unique abbreviation of one of the above. If additional arguments -are present, they specify the options listed in the \fBMENU ENTRY OPTIONS\fR -section below. -The \fBadd\fR widget command returns an empty string. +or a unique abbreviation of one of the above. +If the \fIid\fR argument is specified, it is used as the entry identifier; +\fIid\fR must not already exist in the menu. Otherwise, a new unique +identifier is generated. +If additional arguments are present, they specify the options listed in the +\fBMENU ENTRY OPTIONS\fR section below. +The \fBadd\fR widget command returns the id of the new entry. .TP \fIpathName \fBcget \fIoption\fR . @@ -447,19 +458,28 @@ If no \fIoptions\fR are specified, returns a list describing the current options for entry \fIindex\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). .TP +\fIpathName \fBid \fIindex\fR +. +Returns the id of the menu entry given by \fIindex\fR. +This is the identifier that was assigned to the entry when it was created +using the \fBadd\fR or \fBinsert\fR widget command. +Returns an empty string for the tear-off entry, or if \fIindex\fR is +equivalent to \fB{}\fR. +.TP \fIpathName \fBindex \fIindex\fR . Returns the numerical index corresponding to \fIindex\fR, or \fB{}\fR if \fIindex\fR was specified as \fB{}\fR or \fBnone\fR. .TP -\fIpathName \fBinsert \fIindex type \fR?\fIoption value option value ...\fR? +\fIpathName \fBinsert \fIindex type \fR?\fIid\fR? ?\fIoption value option value ...\fR? . Same as the \fBadd\fR widget command except that it inserts the new entry just before the entry given by \fIindex\fR, instead of appending -to the end of the menu. The \fItype\fR, \fIoption\fR, and \fIvalue\fR -arguments have the same interpretation as for the \fBadd\fR widget -command. It is not possible to insert new menu entries before the +to the end of the menu. The \fItype\fR, \fIid\fR, \fIoption\fR, and +\fIvalue\fR arguments have the same interpretation as for the \fBadd\fR +widget command. It is not possible to insert new menu entries before the tear-off entry, if the menu has one. +The \fBinsert\fR widget command returns the id of the new entry. .TP \fIpathName \fBinvoke \fIindex\fR . diff --git a/doc/options.n b/doc/options.n index b1af80d..de03ec8 100644 --- a/doc/options.n +++ b/doc/options.n @@ -316,7 +316,8 @@ Specifies the integer index of a character to underline in the widget. This option is used by the default bindings to implement keyboard traversal for menu buttons and menu entries. 0 corresponds to the first character of the text displayed in the -widget, 1 to the next character, and so on. +widget, 1 to the next character, and so on. \fBend\fR corresponds to the +last character, \fBend\fR-1 to the before last character, and so on. .OP \-wraplength wrapLength WrapLength For widgets that can perform word-wrapping, this option specifies the maximum line length. diff --git a/doc/spinbox.n b/doc/spinbox.n index d33c2d2..104ef13 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -288,6 +288,9 @@ or .QW \fBsel.f\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. .SS SUBCOMMANDS .PP The following commands are possible for spinbox widgets: diff --git a/doc/ttk_combobox.n b/doc/ttk_combobox.n index b6eddd8..fdc51af 100644 --- a/doc/ttk_combobox.n +++ b/doc/ttk_combobox.n @@ -65,7 +65,9 @@ combobox widgets support the following additional commands: If \fInewIndex\fR is supplied, sets the combobox value to the element at position \fInewIndex\fR in the list of \fB\-values\fR (in addition to integers, the \fBend\fR index is supported and indicates -the last element of the list). +the last element of the list, moreover the same simple interpretation as +for the command \fBstring index\fR is supported, with simple integer index +arithmetic and indexing relative to \fBend\fR). Otherwise, returns the index of the current value in the list of \fB\-values\fR or \fB\-1\fR if the current value does not appear in the list. .TP diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index 816c08b..e71bd01 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -137,6 +137,9 @@ or .QW \fBsel.l\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. .SH "WIDGET COMMAND" .PP In addition to the standard diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index bc6c95a..869e4bf 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -101,6 +101,10 @@ The literal string which returns the number of tabs (only valid for .QW "\fIpathname \fBindex\fR" ). +.PP +Indexes support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. .SH "WIDGET COMMAND" .PP In addition to the standard diff --git a/doc/ttk_style.n b/doc/ttk_style.n index 057a1db..09c8f6c 100644 --- a/doc/ttk_style.n +++ b/doc/ttk_style.n @@ -169,6 +169,33 @@ ttk::style layout Horizontal.TScrollbar { } } .CE +.SH ROOT STYLE +.PP +The +.QW . +theme root style can be configured like any other style, providing defaults +for its derived styles. In addition to the usual options, +.QW . +styling options configurable with \fBttk::style\fP are: +.PP +\fB\-insertofftime\fP \fIamount\fP +.RS +Specifies a non-negative integer value indicating the number of milliseconds +the insertion cursor should remain +.QW off +in each blink cycle. If this option is zero then the cursor does not blink: +it is on all the time. Defaults to 300 ms, unless overriden with a +\fBRESOURCE_MANAGER\fR property or \fB.Xdefaults\fR file. +.RE +.PP +\fB\-insertontime\fP \fIamount\fP +.RS +Specifies a non-negative integer value indicating the number of milliseconds +the insertion cursor should remain +.QW on +in each blink cycle. Defaults to 600 ms, unless overriden with a +\fBRESOURCE_MANAGER\fR property or \fB.Xdefaults\fR file. +.RE .SH "SEE ALSO" ttk::intro(n), ttk::widget(n), photo(n), ttk_image(n) .SH KEYWORDS diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index c163603..757be86 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -556,6 +556,10 @@ An integer \fIn\fR, specifying the \fIn\fRth data column. A string of the form \fB#\fIn\fR, where \fIn\fR is an integer, specifying the \fIn\fRth display column. .PP +Column identifiers support the same simple interpretation as +for the command \fBstring index\fR, with simple integer index +arithmetic and indexing relative to \fBend\fR. +.PP \fBNOTE:\fR Item \fB\-values\fR may be displayed in a different order than the order in which they are stored. diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 23f2118..635c782 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -136,7 +136,8 @@ Specifies the name of a global variable whose value will be used in place of the \fB\-text\fR resource. .OP \-underline underline Underline If set, specifies the integer index (0-based) of a character to underline -in the text string. +in the text string. \fBend\fR corresponds to the last character, +\fBend\fR-1 to the before last character, and so on. The underlined character is used for mnemonic activation. .OP \-width width Width If greater than zero, specifies how much space, in character widths, diff --git a/generic/nanosvgrast.h b/generic/nanosvgrast.h index 7992640..eee5bfd 100644 --- a/generic/nanosvgrast.h +++ b/generic/nanosvgrast.h @@ -73,10 +73,10 @@ NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void); * w - width of the image to render * h - height of the image to render * stride - number of bytes per scaleline in the destination buffer + */ NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride); - */ /* Deletes rasterizer context. */ NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*); diff --git a/generic/tk.h b/generic/tk.h index 8965b08..51dc7fb 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -149,6 +149,8 @@ typedef const char *Tk_Uid; #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION == 6) # define Tcl_Size int +# define TCL_SIZE_MAX INT_MAX +# define TCL_SIZE_MODIFIER "" #endif /* diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index e80760d..9f97b33 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -1084,7 +1084,7 @@ BitmapInit( * TkReadBitmapFile -- * * Loads a bitmap image in X bitmap format into the specified drawable. - * This is equivelent to the XReadBitmapFile in X. + * This is equivalent to the XReadBitmapFile in X. * * Results: * Sets the size, hotspot, and bitmap on success. diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 27f162a..aaf7c14 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -120,13 +120,11 @@ UnderlineParseProc( obj.bytes = (char *)value; obj.length = strlen(value); obj.typePtr = NULL; - code = TkGetIntForIndex(&obj, TCL_INDEX_END, 0, &underline); + code = TkGetIntForIndex(&obj, TCL_INDEX_NONE, 0, &underline); if (code == TCL_OK) { - if (underline < 0) { - underline = (Tcl_Size)INT_MIN; - } else if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { - underline++; - } else if (underline >= INT_MAX) { + if (underline < INT_MIN) { + underline = INT_MIN; + } else if (underline > INT_MAX) { underline = INT_MAX; } *underlinePtr = (int)underline; diff --git a/generic/tkConfig.c b/generic/tkConfig.c index bc36846..e3bad9d 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -683,17 +683,17 @@ DoObjConfig( case TK_OPTION_INDEX: { Tcl_Size newIndex; - if (TkGetIntForIndex(valuePtr, TCL_INDEX_END, 0, &newIndex) != TCL_OK) { + if (TkGetIntForIndex(valuePtr, TCL_INDEX_NONE, 0, &newIndex) != TCL_OK) { if (interp) { Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr), "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL); } return TCL_ERROR; } - if (newIndex < 0) { + if (newIndex < INT_MIN) { newIndex = INT_MIN; - } else if ((size_t)newIndex > (size_t)TCL_INDEX_END>>1) { - newIndex++; + } else if (newIndex > INT_MAX) { + newIndex = INT_MAX; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); diff --git a/generic/tkFont.c b/generic/tkFont.c index 226f2a9..844ed78 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -422,12 +422,16 @@ TkFontPkgFree( TkFontInfo *fiPtr = mainPtr->fontInfoPtr; Tcl_HashEntry *hPtr, *searchPtr; Tcl_HashSearch search; +#ifdef PURIFY int fontsLeft = 0; +#endif for (searchPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); searchPtr != NULL; searchPtr = Tcl_NextHashEntry(&search)) { +#ifdef PURIFY fontsLeft++; +#endif #ifdef DEBUG_FONTS fprintf(stderr, "Font %s still in cache.\n", (char *) Tcl_GetHashKey(&fiPtr->fontCache, searchPtr)); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index fecf775..91ab80d 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1480,7 +1480,7 @@ DisplayFrame( Tk_Window tkwin = framePtr->tkwin; int bdX1, bdY1, bdX2, bdY2, hlWidth; Pixmap pixmap; - TkRegion clipRegion = NULL; + Bool useClipping = False; framePtr->flags &= ~REDRAW_PENDING; if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { @@ -1619,11 +1619,9 @@ DisplayFrame( if ((labelframePtr->labelBox.width < labelframePtr->labelReqWidth) || (labelframePtr->labelBox.height < labelframePtr->labelReqHeight)) { - clipRegion = TkCreateRegion(); - TkUnionRectWithRegion(&labelframePtr->labelBox, clipRegion, - clipRegion); - TkSetRegion(framePtr->display, labelframePtr->textGC, - clipRegion); + useClipping = True; + XSetClipRectangles(framePtr->display, labelframePtr->textGC, 0, 0, + &labelframePtr->labelBox, 1, Unsorted); } Tk_DrawTextLayout(framePtr->display, pixmap, @@ -1631,9 +1629,8 @@ DisplayFrame( labelframePtr->labelTextX + LABELSPACING, labelframePtr->labelTextY + LABELSPACING, 0, -1); - if (clipRegion != NULL) { + if (useClipping) { XSetClipMask(framePtr->display, labelframePtr->textGC, None); - TkDestroyRegion(clipRegion); } } else { /* diff --git a/generic/tkIcu.c b/generic/tkIcu.c index 342bd11..5639336 100644 --- a/generic/tkIcu.c +++ b/generic/tkIcu.c @@ -11,13 +11,6 @@ */ #include "tkInt.h" -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif /* * Runtime linking of libicu. diff --git a/generic/tkInt.decls b/generic/tkInt.decls index eabef03..3d04961 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1339,12 +1339,10 @@ declare 80 win { Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height) } -# This slot is reserved for use by the clipping rectangle patch: -# declare 81 win { -# XSetClipRectangles(Display *display, GC gc, int clip_x_origin, -# int clip_y_origin, XRectangle rectangles[], int n, int ordering) -# } - +declare 81 win { + int XSetClipRectangles(Display *display, GC gc, int clip_x_origin, + int clip_y_origin, XRectangle rectangles[], int n, int ordering) +} declare 82 win { Status XParseColor(Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr) diff --git a/generic/tkInt.h b/generic/tkInt.h index c3b875c..50829aa 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -31,6 +31,8 @@ #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> #endif +#include <stdint.h> +#include <stdlib.h> #ifdef BYTE_ORDER # ifdef BIG_ENDIAN # if BYTE_ORDER == BIG_ENDIAN @@ -1458,6 +1460,8 @@ MODULE_SCOPE Status TkParseColor (Display * display, MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion); #endif +MODULE_SCOPE void TkpCopyRegion(TkRegion dst, TkRegion src); + #if !defined(__cplusplus) && !defined(c_plusplus) # define c_class class #endif diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 7e86d52..9725cc5 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -281,7 +281,10 @@ EXTERN int TkPutImage(unsigned long *colors, int ncolors, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); -/* Slot 81 is reserved */ +/* 81 */ +EXTERN int XSetClipRectangles(Display * display, GC gc, + int clip_x_origin, int clip_y_origin, + XRectangle rectangles[], int n, int ordering); /* 82 */ EXTERN Status XParseColor(Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); @@ -983,7 +986,7 @@ typedef struct TkIntXlibStubs { Bool (*xFilterEvent) (XEvent *x, Window w); /* 78 */ int (*xmbLookupString) (XIC xi, XKeyPressedEvent *xk, char *c, int i, KeySym *k, Status *s); /* 79 */ int (*tkPutImage) (unsigned long *colors, int ncolors, Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); /* 80 */ - void (*reserved81)(void); + int (*xSetClipRectangles) (Display* display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 81 */ Status (*xParseColor) (Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); /* 82 */ GC (*xCreateGC) (Display *display, Drawable d, unsigned long valuemask, XGCValues *values); /* 83 */ int (*xFreeGC) (Display *display, GC gc); /* 84 */ @@ -1400,7 +1403,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xmbLookupString) /* 79 */ #define TkPutImage \ (tkIntXlibStubsPtr->tkPutImage) /* 80 */ -/* Slot 81 is reserved */ +#define XSetClipRectangles \ + (tkIntXlibStubsPtr->xSetClipRectangles) /* 81 */ #define XParseColor \ (tkIntXlibStubsPtr->xParseColor) /* 82 */ #define XCreateGC \ diff --git a/generic/tkListbox.c b/generic/tkListbox.c index d41bece..f66c1b3 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -317,26 +317,23 @@ static const Tk_OptionSpec optionSpecs[] = { */ static const Tk_OptionSpec itemAttrOptionSpecs[] = { - {TK_OPTION_BORDER, "-background", "background", "Background", + {TK_OPTION_BORDER, "-background", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border), - TK_OPTION_NULL_OK, - DEF_LISTBOX_BG_MONO, 0}, + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, - {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + {TK_OPTION_COLOR, "-foreground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor), - TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder), - TK_OPTION_NULL_OK, - DEF_LISTBOX_SELECT_MONO, 0}, - {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor), - TK_OPTION_NULL_OK, - DEF_LISTBOX_SELECT_FG_MONO, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, NULL, 0} }; /* diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 3eaa86e..ff1148d 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -306,12 +306,12 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { static const char *const menuOptions[] = { "activate", "add", "cget", "clone", "configure", "delete", "entrycget", - "entryconfigure", "index", "insert", "invoke", "post", "postcascade", + "entryconfigure", "id", "index", "insert", "invoke", "post", "postcascade", "type", "unpost", "xposition", "yposition", NULL }; enum options { MENU_ACTIVATE, MENU_ADD, MENU_CGET, MENU_CLONE, MENU_CONFIGURE, - MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_INDEX, + MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_ID, MENU_INDEX, MENU_INSERT, MENU_INVOKE, MENU_POST, MENU_POSTCASCADE, MENU_TYPE, MENU_UNPOST, MENU_XPOSITION, MENU_YPOSITION }; @@ -451,6 +451,8 @@ Tk_MenuObjCmd( menuPtr->cursorPtr = NULL; menuPtr->mainMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; + Tcl_InitHashTable(&menuPtr->items, TCL_STRING_KEYS); + menuPtr->serial = 0; TkMenuInitializeDrawingFields(menuPtr); Tk_SetClass(menuPtr->tkwin, "Menu"); @@ -821,6 +823,28 @@ MenuWidgetObjCmd( Tcl_Release(mePtr); break; } + case MENU_ID: { + Tcl_Size index; + const char *idStr; + Tcl_HashEntry *entryPtr; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "index"); + goto error; + } + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index == TCL_INDEX_NONE) { + goto done; + } + entryPtr = menuPtr->entries[index]->entryPtr; + if (entryPtr) { + idStr = Tcl_GetHashKey(&menuPtr->items, entryPtr); + Tcl_SetObjResult(interp, Tcl_NewStringObj(idStr, TCL_INDEX_NONE)); + } + break; + } case MENU_INDEX: { Tcl_Size index; @@ -1189,6 +1213,7 @@ DestroyMenuInstance( ckfree(menuPtr->entries); menuPtr->entries = NULL; } + Tcl_DeleteHashTable(&menuPtr->items); TkMenuFreeDrawOptions(menuPtr); Tk_FreeConfigOptions((char *) menuPtr, tsdPtr->menuOptionTable, menuPtr->tkwin); @@ -1455,6 +1480,10 @@ DestroyMenuEntry( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, mePtr); } + if (mePtr->entryPtr) { + Tcl_DeleteHashEntry(mePtr->entryPtr); + mePtr->entryPtr = NULL; + } TkpDestroyMenuEntry(mePtr); TkMenuEntryFreeDrawOptions(mePtr); Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, menuPtr->tkwin); @@ -2112,6 +2141,7 @@ GetMenuIndex( { int i; const char *string; + Tcl_HashEntry *entryPtr; if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) { /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ @@ -2147,12 +2177,19 @@ GetMenuIndex( #endif if (string[0] == '@') { - if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr) + if (GetIndexFromCoords(interp, menuPtr, string, indexPtr) == TCL_OK) { goto success; } } + entryPtr = Tcl_FindHashEntry(&menuPtr->items, string); + if (entryPtr) { + TkMenuEntry *mePtr = Tcl_GetHashValue(entryPtr); + *indexPtr = mePtr->index; + return TCL_OK; + } + for (i = 0; i < (int)menuPtr->numEntries; i++) { Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr; const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); @@ -2301,6 +2338,7 @@ MenuNewEntry( ckfree(mePtr); return NULL; } + mePtr->entryPtr = NULL; TkMenuInitializeEntryDrawingFields(mePtr); if (TkpMenuNewEntry(mePtr) != TCL_OK) { Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, @@ -2343,6 +2381,10 @@ MenuAddOrInsert( Tcl_Size index; TkMenuEntry *mePtr; TkMenu *menuListPtr; + Tcl_HashEntry *entryPtr; + Tcl_Obj *idPtr = NULL; + int isNew; + int offs; if (indexPtr != NULL) { if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { @@ -2369,11 +2411,26 @@ MenuAddOrInsert( sizeof(char *), "menu entry type", 0, &type) != TCL_OK) { return TCL_ERROR; } + offs = 1; /* - * Now we have to add an entry for every instance related to this menu. + * Check for a user supplied id */ + if (objc % 2 == 0) { + idPtr = objv[offs]; + if (Tcl_FindHashEntry(&menuPtr->items, Tcl_GetString(idPtr))) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "entry \"%s\" already exists", Tcl_GetString(idPtr))); + Tcl_SetErrorCode(interp, "TK", "MENU", "ENTRY_EXISTS", NULL); + return TCL_ERROR; + } + offs++; + } + + /* + * Now we have to add an entry for every instance related to this menu. + */ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { @@ -2381,7 +2438,7 @@ MenuAddOrInsert( if (mePtr == NULL) { return TCL_ERROR; } - if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) { + if (ConfigureMenuEntry(mePtr, objc - offs, objv + offs) != TCL_OK) { TkMenu *errorMenuPtr; Tcl_Size i; @@ -2405,6 +2462,23 @@ MenuAddOrInsert( return TCL_ERROR; } + if (idPtr == NULL) { + char idbuf[16]; + /* Generate an id for the new entry on the main menu */ + do { + snprintf(idbuf, sizeof(idbuf), "e%03X", ++menuPtr->serial); + entryPtr = Tcl_CreateHashEntry( + &menuListPtr->items, idbuf, &isNew); + } while (!isNew); + idPtr = Tcl_NewStringObj(idbuf, TCL_INDEX_NONE); + } else { + /* Reuse the specified or previously generated id on all clones */ + entryPtr = Tcl_CreateHashEntry( + &menuListPtr->items, Tcl_GetString(idPtr), &isNew); + } + Tcl_SetHashValue(entryPtr, mePtr); + mePtr->entryPtr = entryPtr; + /* * If a menu has cascades, then every instance of the menu has to have * its own parallel cascade structure. So adding an entry to a menu @@ -2450,6 +2524,8 @@ MenuAddOrInsert( } } } + + Tcl_SetObjResult(interp, idPtr); return TCL_OK; } @@ -2960,10 +3036,13 @@ GetIndexFromCoords( x = y; p = end + 1; y = strtol(p, &end, 0); - if (end == p) { + if ((end == p) || (*end != '\0')) { goto error; } } else { + if (*end != '\0') { + goto error; + } x = borderwidth; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 21ca097..f459277 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -183,6 +183,7 @@ typedef struct TkMenuEntry { int index; /* Need to know which index we are. This is * zero-based. This is the top-left entry of * the menu. */ + Tcl_HashEntry *entryPtr; /* Back-pointer to hash table entry */ /* * Bookeeping for main menus and cascade menus. @@ -379,6 +380,8 @@ typedef struct TkMenu { * multiple menus get changed during one * ConfigureMenu call. */ Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */ + Tcl_HashTable items; /* Map: id -> entry */ + int serial; /* Next item # for autogenerated ids */ } TkMenu; /* diff --git a/generic/tkObj.c b/generic/tkObj.c index 416b2dd..3f9cad4 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -241,18 +241,11 @@ TkGetIntForIndex( const char *value = Tcl_GetString(indexObj); if (!*value) { /* empty string */ - *indexPtr = TCL_INDEX_NONE; + *indexPtr = (end == -1) ? -1 - TCL_SIZE_MAX : TCL_INDEX_NONE; return TCL_OK; } return TCL_ERROR; } - if (*indexPtr < -1) { - *indexPtr = TCL_INDEX_NONE; - } else if (end >= -1) { - if (*indexPtr > end) { - *indexPtr = end + 1; - } - } return TCL_OK; } diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index eddc743..4e7d270 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -761,7 +761,7 @@ static const TkIntXlibStubs tkIntXlibStubs = { XFilterEvent, /* 78 */ XmbLookupString, /* 79 */ TkPutImage, /* 80 */ - 0, /* 81 */ + XSetClipRectangles, /* 81 */ XParseColor, /* 82 */ XCreateGC, /* 83 */ XFreeGC, /* 84 */ diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c index fc48af9..c64793e 100644 --- a/generic/ttk/ttkBlink.c +++ b/generic/ttk/ttkBlink.c @@ -10,12 +10,10 @@ * to display the cursor or not (e.g., readonly or disabled states); * TtkBlinkCursor() does not account for this. * - * TODO: - * Add script-level access to configure application-wide blink rate. */ #include "tkInt.h" -#include "ttkTheme.h" +#include "ttkThemeInt.h" #include "ttkWidget.h" #define DEF_CURSOR_ON_TIME 600 /* milliseconds */ @@ -52,6 +50,9 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp) { static const char *cm_key = "ttk::CursorManager"; CursorManager *cm = (CursorManager *)Tcl_GetAssocData(interp, cm_key,0); + Tk_Window window; + Tk_Uid value; + int intValue; if (!cm) { cm = (CursorManager *)ckalloc(sizeof(*cm)); @@ -59,6 +60,27 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp) cm->owner = 0; cm->onTime = DEF_CURSOR_ON_TIME; cm->offTime = DEF_CURSOR_OFF_TIME; + + /* Override on and off default times with values obtained from + * the option database (if such values are specified). + */ + + window = Tk_MainWindow(interp); + if (window) { + value = Tk_GetOption(window, "insertOnTime", "OnTime"); + if (value) { + if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) { + cm->onTime = intValue; + } + } + value = Tk_GetOption(window, "insertOffTime", "OffTime"); + if (value) { + if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) { + cm->offTime = intValue; + } + } + } + Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm); } return cm; @@ -154,6 +176,49 @@ CursorEventProc(ClientData clientData, XEvent *eventPtr) } } +void TtkSetBlinkCursorOnTime(Tcl_Interp* interp, int onTime) +{ + CursorManager* cm = GetCursorManager(interp); + + if (onTime >= 0) + cm->onTime = onTime; +} + +void TtkSetBlinkCursorOffTime(Tcl_Interp* interp, int offTime) +{ + CursorManager* cm = GetCursorManager(interp); + + if (offTime >= 0) + cm->offTime = offTime; +} + +/* + * TtkSetBlinkCursorTimes -- + * Set cursor blink on and off times from the "." style defaults + * -insertontime and -insertofftime - For instance to set cursor + * blinking off: + * ttk::style configure . -insertofftime 0 + */ +void TtkSetBlinkCursorTimes(Tcl_Interp* interp) +{ + Ttk_Theme theme; + Ttk_Style style = NULL; + Tcl_Obj* result; + int timeInterval; + + theme = Ttk_GetCurrentTheme(interp); + style = Ttk_GetStyle(theme, "."); + result = Ttk_StyleDefault(style, "-insertontime"); + if (result) { + Tcl_GetIntFromObj(interp, result, &timeInterval); + TtkSetBlinkCursorOnTime(interp, timeInterval); + } + result = Ttk_StyleDefault(style, "-insertofftime"); + if (result) { + Tcl_GetIntFromObj(interp, result, &timeInterval); + TtkSetBlinkCursorOffTime(interp, timeInterval); + } +} /* * TtkBlinkCursor (main routine) -- * Arrange to blink the cursor on and off whenever the diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index baa6f6a..d94cb23 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -130,7 +130,7 @@ static void TextCleanup(TextElement *text) static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj); - Tcl_Size underline = TCL_INDEX_NONE; + Tcl_Size underline = INT_MIN; XGCValues gcValues; GC gc1, gc2; Tk_Anchor anchor = TK_ANCHOR_CENTER; @@ -175,11 +175,13 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/); if (text->underlineObj != NULL) { - TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline); - if (underline >= 0) { - if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { - underline++; - } + TkGetIntForIndex(text->underlineObj, TCL_INDEX_NONE, 0, &underline); + if (underline < INT_MIN) { + underline = INT_MIN; + } else if (underline > INT_MAX) { + underline = INT_MAX; + } + if (underline != INT_MIN) { if (text->embossed) { Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, underline); diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 852287e..57b0610 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -516,6 +516,8 @@ static void ThemeChangedProc(ClientData clientData) */ static void ThemeChanged(StylePackageData *pkgPtr) { + TtkSetBlinkCursorTimes(pkgPtr->interp); + if (!pkgPtr->themeChangePending) { Tcl_DoWhenIdle(ThemeChangedProc, pkgPtr); pkgPtr->themeChangePending = 1; diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index 67ffc34..e8d9665 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -39,6 +39,8 @@ MODULE_SCOPE Ttk_LayoutTemplate Ttk_FindLayoutTemplate( MODULE_SCOPE const char *Ttk_StyleName(Ttk_Style); +MODULE_SCOPE void TtkSetBlinkCursorTimes(Tcl_Interp* interp); + #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) # define TTK_OPTION_UNDERLINE_DEF(type, field) "-1", offsetof(type, field), TCL_INDEX_NONE, 0, NULL #else diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 4494a65..11de5e0 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1922,8 +1922,9 @@ static Ttk_Layout TreeviewGetLayout( if ((objPtr = Ttk_QueryOption(treeLayout, "-rowheight", 0))) { (void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.rowHeight); - tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1); } + tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1); + if ((objPtr = Ttk_QueryOption(treeLayout, "-columnseparatorwidth", 0))) { (void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.colSeparatorWidth); } diff --git a/library/demos/anilabel.tcl b/library/demos/anilabel.tcl index 61e6315..be1b402 100644 --- a/library/demos/anilabel.tcl +++ b/library/demos/anilabel.tcl @@ -66,10 +66,10 @@ proc animateLabelText {w text interval} { ## Next, a similar pair of procedures to animate a GIF loaded into a ## photo image. proc SelectNextImageFrame {w interval} { - global animationCallbacks + global animationCallbacks image zoomFactor set animationCallbacks($w) \ [after $interval SelectNextImageFrame $w $interval] - set image [$w cget -image] + set image2 [$w cget -image] # The easy way to animate a GIF! set idx -1 @@ -80,15 +80,23 @@ proc SelectNextImageFrame {w interval} { }]} then { $image configure -format "GIF -index 0" } + $image2 copy $image -zoom $zoomFactor } proc animateLabelImage {w imageData interval} { - global animationCallbacks + global animationCallbacks image zoomFactor # Create a multi-frame GIF from base-64-encoded data set image [image create photo -format GIF -data $imageData] - # Install the image into the widget - $w configure -image $image + # Create a copy of the image just created, magnified according to the + # display's DPI scaling level. Since the zooom factor must be an integer, + # the copy will only be effectively magnified if $tk::scalingPct >= 200. + set image2 [image create photo] + set zoomFactor [expr {$tk::scalingPct / 100}] + $image2 copy $image -zoom $zoomFactor + + # Install the image copy into the widget + $w configure -image $image2 # Schedule the start of the animation loop set animationCallbacks($w) \ @@ -109,16 +117,16 @@ proc animateLabelImage {w imageData interval} { # Make some widgets to contain the animations labelframe $w.left -text "Scrolling Texts" labelframe $w.right -text "GIF Image" -pack $w.left $w.right -side left -padx 10 -pady 10 -expand yes +pack $w.left $w.right -side left -padx 7.5p -pady 7.5p -expand yes # This method of scrolling text looks far better with a fixed-width font -label $w.left.l1 -bd 4 -relief ridge -font fixedFont -label $w.left.l2 -bd 4 -relief groove -font fixedFont -label $w.left.l3 -bd 4 -relief flat -font fixedFont -width 18 -pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 10 -pady 10 -anchor w +label $w.left.l1 -bd 3p -relief ridge -font fixedFont +label $w.left.l2 -bd 3p -relief groove -font fixedFont +label $w.left.l3 -bd 3p -relief flat -font fixedFont -width 18 +pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 7.5p -pady 7.5p -anchor w # Don't need to do very much with this label except turn off the border label $w.right.l -bd 0 -pack $w.right.l -side top -expand yes -padx 10 -pady 10 +pack $w.right.l -side top -expand yes -padx 7.5p -pady 7.5p # This is a base-64-encoded animated GIF file. set tclPoweredData { diff --git a/library/demos/aniwave.tcl b/library/demos/aniwave.tcl index a7539fb..1f7e8f3 100644 --- a/library/demos/aniwave.tcl +++ b/library/demos/aniwave.tcl @@ -26,7 +26,7 @@ pack $btns -side bottom -fill x # Create a canvas large enough to hold the wave. In fact, the wave # sticks off both sides of the canvas to prevent visual glitches. -pack [canvas $w.c -width 300 -height 200 -background black] -padx 10 -pady 10 -expand yes +pack [canvas $w.c -width 225p -height 150p -background black] -padx 7.5p -pady 7.5p -expand yes # Ensure that this this is an array array set animationCallbacks {} @@ -41,12 +41,15 @@ lappend waveCoords $x 0 [incr x 5] 200 # Create a smoothed line and arrange for its coordinates to be the # contents of the variable waveCoords. -$w.c create line $waveCoords -tags wave -width 1 -fill green -smooth 1 +$w.c create line $waveCoords -tags wave -width 0.75p -fill green -smooth 1 proc waveCoordsTracer {w args} { global waveCoords # Actual visual update will wait until we have finished # processing; Tk does that for us automatically. $w.c coords wave $waveCoords + + set scaleFactor [expr {$tk::scalingPct / 100.0}] + $w.c scale wave 0 0 $scaleFactor $scaleFactor } trace add variable waveCoords write [list waveCoordsTracer $w] diff --git a/library/demos/arrow.tcl b/library/demos/arrow.tcl index 3d0b406..5674be9 100644 --- a/library/demos/arrow.tcl +++ b/library/demos/arrow.tcl @@ -9,6 +9,16 @@ if {![info exists widgetDemo]} { package require Tk +# scl -- +# Scales an integer according to the display's current scaling percentage. +# +# Arguments: +# num - An integer. + +proc scl num { + return [expr {round($num*$tk::scalingPct/100.0)}] +} + # arrowSetup -- # This procedure regenerates all the text and graphics in the canvas # window. It's called when the canvas is initially created, and also @@ -33,74 +43,78 @@ proc arrowSetup c { # Create the arrow and outline. $c delete all - eval {$c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \ + $c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \ -width [expr {10*$v(width)}] -arrowshape [list \ - [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]]} \ - $v(bigLineStyle) + [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]] \ + {*}$v(bigLineStyle) set xtip [expr {$v(x2)-10*$v(b)}] set deltaY [expr {10*$v(c)+5*$v(width)}] $c create line $v(x2) $v(y) $xtip [expr {$v(y)+$deltaY}] \ [expr {$v(x2)-10*$v(a)}] $v(y) $xtip [expr {$v(y)-$deltaY}] \ - $v(x2) $v(y) -width 2 -capstyle round -joinstyle round + $v(x2) $v(y) -width 1.5p -capstyle round -joinstyle round # Create the boxes for reshaping the line and arrowhead. - eval {$c create rect [expr {$v(x2)-10*$v(a)-5}] [expr {$v(y)-5}] \ - [expr {$v(x2)-10*$v(a)+5}] [expr {$v(y)+5}] \ - -tags {box1 box}} $v(boxStyle) - eval {$c create rect [expr {$xtip-5}] [expr {$v(y)-$deltaY-5}] \ - [expr {$xtip+5}] [expr {$v(y)-$deltaY+5}] \ - -tags {box2 box}} $v(boxStyle) - eval {$c create rect [expr {$v(x1)-5}] [expr {$v(y)-5*$v(width)-5}] \ - [expr {$v(x1)+5}] [expr {$v(y)-5*$v(width)+5}] \ - -tags {box3 box}} $v(boxStyle) + set _5 [scl 5] + $c create rect [expr {$v(x2)-10*$v(a)-$_5}] [expr {$v(y)-$_5}] \ + [expr {$v(x2)-10*$v(a)+$_5}] [expr {$v(y)+$_5}] \ + -tags {box1 box} {*}$v(boxStyle) + $c create rect [expr {$xtip-$_5}] [expr {$v(y)-$deltaY-$_5}] \ + [expr {$xtip+$_5}] [expr {$v(y)-$deltaY+$_5}] \ + -tags {box2 box} {*}$v(boxStyle) + $c create rect [expr {$v(x1)-$_5}] [expr {$v(y)-5*$v(width)-$_5}] \ + [expr {$v(x1)+$_5}] [expr {$v(y)-5*$v(width)+$_5}] \ + -tags {box3 box} {*}$v(boxStyle) if {$cur != ""} { - eval $c itemconfigure $cur $v(activeStyle) + $c itemconfigure $cur {*}$v(activeStyle) } - # Create three arrows in actual size with the same parameters - - $c create line [expr {$v(x2)+50}] 0 [expr {$v(x2)+50}] 1000 \ - -width 2 - set tmp [expr {$v(x2)+100}] - $c create line $tmp [expr {$v(y)-125}] $tmp [expr {$v(y)-75}] \ - -width $v(width) \ - -arrow both -arrowshape "$v(a) $v(b) $v(c)" - $c create line [expr {$tmp-25}] $v(y) [expr {$tmp+25}] $v(y) \ - -width $v(width) \ - -arrow both -arrowshape "$v(a) $v(b) $v(c)" - $c create line [expr {$tmp-25}] [expr {$v(y)+75}] [expr {$tmp+25}] \ - [expr {$v(y)+125}] -width $v(width) \ - -arrow both -arrowshape "$v(a) $v(b) $v(c)" + # Create three arrows in actual size with the same parameters. + + set _10 [scl 10] + set _15 [scl 15] + set _25 [scl 25] + set _50 [scl 50] + set _75 [scl 75] + set _125 [scl 125] + $c create line [expr {$v(x2)+$_50}] 0 [expr {$v(x2)+$_50}] 750p -width 1.5p + set tmp [expr {$v(x2)+[scl 100]}] + $c create line $tmp [expr {$v(y)-$_125}] $tmp [expr {$v(y)-$_75}] \ + -width $v(width) -arrow both -arrowshape "$v(a) $v(b) $v(c)" + $c create line [expr {$tmp-$_25}] $v(y) [expr {$tmp+$_25}] $v(y) \ + -width $v(width) -arrow both -arrowshape "$v(a) $v(b) $v(c)" + $c create line [expr {$tmp-$_25}] [expr {$v(y)+$_75}] \ + [expr {$tmp+$_25}] [expr {$v(y)+$_125}] \ + -width $v(width) -arrow both -arrowshape "$v(a) $v(b) $v(c)" # Create a bunch of other arrows and text items showing the # current dimensions. - set tmp [expr {$v(x2)+10}] + set tmp [expr {$v(x2)+$_10}] $c create line $tmp [expr {$v(y)-5*$v(width)}] \ $tmp [expr {$v(y)-$deltaY}] \ -arrow both -arrowshape $v(smallTips) - $c create text [expr {$v(x2)+15}] [expr {$v(y)-$deltaY+5*$v(c)}] \ + $c create text [expr {$v(x2)+$_15}] [expr {$v(y)-$deltaY+5*$v(c)}] \ -text $v(c) -anchor w - set tmp [expr {$v(x1)-10}] + set tmp [expr {$v(x1)-$_10}] $c create line $tmp [expr {$v(y)-5*$v(width)}] \ $tmp [expr {$v(y)+5*$v(width)}] \ -arrow both -arrowshape $v(smallTips) - $c create text [expr {$v(x1)-15}] $v(y) -text $v(width) -anchor e - set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+10}] + $c create text [expr {$v(x1)-$_15}] $v(y) -text $v(width) -anchor e + set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+$_10}] $c create line [expr {$v(x2)-10*$v(a)}] $tmp $v(x2) $tmp \ -arrow both -arrowshape $v(smallTips) - $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+5}] \ + $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+$_5}] \ -text $v(a) -anchor n - set tmp [expr {$tmp+25}] + set tmp [expr {$tmp+$_25}] $c create line [expr {$v(x2)-10*$v(b)}] $tmp $v(x2) $tmp \ -arrow both -arrowshape $v(smallTips) - $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+5}] \ + $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+$_5}] \ -text $v(b) -anchor n - $c create text $v(x1) 310 -text "-width $v(width)" \ + $c create text $v(x1) 232.5p -text "-width $v(width)" \ -anchor w -font {Helvetica 18} - $c create text $v(x1) 330 -text "-arrowshape {$v(a) $v(b) $v(c)}" \ + $c create text $v(x1) 247.5p -text "-arrowshape {$v(a) $v(b) $v(c)}" \ -anchor w -font {Helvetica 18} incr v(count) @@ -121,18 +135,18 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -canvas $c -width 500 -height 350 -relief sunken -borderwidth 2 +canvas $c -width 375p -height 262.5p -relief sunken -borderwidth 2 pack $c -expand yes -fill both -set demo_arrowInfo(a) 8 -set demo_arrowInfo(b) 10 -set demo_arrowInfo(c) 3 -set demo_arrowInfo(width) 2 +set demo_arrowInfo(a) [scl 8] +set demo_arrowInfo(b) [scl 10] +set demo_arrowInfo(c) [scl 3] +set demo_arrowInfo(width) [scl 2] set demo_arrowInfo(motionProc) arrowMoveNull -set demo_arrowInfo(x1) 40 -set demo_arrowInfo(x2) 350 -set demo_arrowInfo(y) 150 -set demo_arrowInfo(smallTips) {5 5 2} +set demo_arrowInfo(x1) [scl 40] +set demo_arrowInfo(x2) [scl 350] +set demo_arrowInfo(y) [scl 150] +set demo_arrowInfo(smallTips) {3.75p 3.75p 1.5p} set demo_arrowInfo(count) 0 if {[winfo depth $c] > 1} { if {[tk windowingsystem] eq "aqua"} { @@ -140,14 +154,14 @@ if {[winfo depth $c] > 1} { } else { set demo_arrowInfo(bigLineStyle) "-fill LightSeaGreen" } - set demo_arrowInfo(boxStyle) "-fill {} -width 1" - set demo_arrowInfo(activeStyle) "-fill red -width 1" + set demo_arrowInfo(boxStyle) "-fill {} -width 0.75p" + set demo_arrowInfo(activeStyle) "-fill red -width 0.75p" } else { # Main widget program sets variable tk_demoDirectory set demo_arrowInfo(bigLineStyle) "-fill black \ -stipple @[file join $tk_demoDirectory images grey.25]" - set demo_arrowInfo(boxStyle) "-fill {} -outline black -width 1" - set demo_arrowInfo(activeStyle) "-fill black -outline black -width 1" + set demo_arrowInfo(boxStyle) "-fill {} -outline black -width 0.75p" + set demo_arrowInfo(activeStyle) "-fill black -outline black -width 0.75p" } arrowSetup $c $c bind box <Enter> "$c itemconfigure current $demo_arrowInfo(activeStyle)" @@ -171,12 +185,13 @@ bind $c <ButtonRelease-1> "arrowSetup $c" proc arrowMove1 {c x y} { upvar #0 demo_arrowInfo v - set newA [expr {($v(x2)+5-round([$c canvasx $x]))/10}] + set newA [expr {($v(x2)+[scl 5]-round([$c canvasx $x]))/10}] if {$newA < 0} { set newA 0 } - if {$newA > 25} { - set newA 25 + set _25 [scl 25] + if {$newA > $_25} { + set newA $_25 } if {$newA != $v(a)} { $c move box1 [expr {10*($v(a)-$newA)}] 0 @@ -195,19 +210,22 @@ proc arrowMove1 {c x y} { proc arrowMove2 {c x y} { upvar #0 demo_arrowInfo v - set newB [expr {($v(x2)+5-round([$c canvasx $x]))/10}] + set _5 [scl 5] + set newB [expr {($v(x2)+$_5-round([$c canvasx $x]))/10}] if {$newB < 0} { set newB 0 } - if {$newB > 25} { - set newB 25 + set _25 [scl 25] + if {$newB > $_25} { + set newB $_25 } - set newC [expr {($v(y)+5-round([$c canvasy $y])-5*$v(width))/10}] + set newC [expr {($v(y)+$_5-round([$c canvasy $y])-5*$v(width))/10}] if {$newC < 0} { set newC 0 } - if {$newC > 20} { - set newC 20 + set _20 [scl 20] + if {$newC > $_20} { + set newC $_20 } if {($newB != $v(b)) || ($newC != $v(c))} { $c move box2 [expr {10*($v(b)-$newB)}] [expr {10*($v(c)-$newC)}] @@ -227,12 +245,13 @@ proc arrowMove2 {c x y} { proc arrowMove3 {c x y} { upvar #0 demo_arrowInfo v - set newWidth [expr {($v(y)+2-round([$c canvasy $y]))/5}] + set newWidth [expr {($v(y)+[scl 2]-round([$c canvasy $y]))/5}] if {$newWidth < 0} { set newWidth 0 } - if {$newWidth > 20} { - set newWidth 20 + set _20 [scl 20] + if {$newWidth > $_20} { + set newWidth $_20 } if {$newWidth != $v(width)} { $c move box3 0 [expr {5*($v(width)-$newWidth)}] diff --git a/library/demos/button.tcl b/library/demos/button.tcl index bb943e6..0169c2a 100644 --- a/library/demos/button.tcl +++ b/library/demos/button.tcl @@ -44,4 +44,4 @@ button $w.b3 -text "Sea Green" -width 10 \ -command [list colorrefresh $w SeaGreen2] button $w.b4 -text "Yellow" -width 10 \ -command [list colorrefresh $w Yellow1] -pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2 +pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 1.5p diff --git a/library/demos/check.tcl b/library/demos/check.tcl index c072096..96ff251 100644 --- a/library/demos/check.tcl +++ b/library/demos/check.tcl @@ -30,8 +30,8 @@ checkbutton $w.b0 -text "Safety Check" -variable safety -relief flat \ checkbutton $w.b1 -text "Wipers OK" -variable wipers -relief flat checkbutton $w.b2 -text "Brakes OK" -variable brakes -relief flat checkbutton $w.b3 -text "Driver Sober" -variable sober -relief flat -pack $w.b0 -side top -pady 2 -anchor w -pack $w.b1 $w.b2 $w.b3 -side top -pady 2 -anchor w -padx 15 +pack $w.b0 -side top -pady 1.5p -anchor w +pack $w.b1 $w.b2 $w.b3 -side top -pady 1.5p -anchor w -padx 12p ## This code makes $w.b0 function as a tri-state button; it's not ## needed at all for just straight yes/no buttons. @@ -65,7 +65,7 @@ proc tristate_check {n1 n2 op} { set in_check 0 } -trace variable wipers w tristate_check -trace variable brakes w tristate_check -trace variable sober w tristate_check -trace variable safety w tristate_check +trace add variable wipers write tristate_check +trace add variable brakes write tristate_check +trace add variable sober write tristate_check +trace add variable safety write tristate_check diff --git a/library/demos/colors.tcl b/library/demos/colors.tcl index fdfdc5b..63d4402 100644 --- a/library/demos/colors.tcl +++ b/library/demos/colors.tcl @@ -24,7 +24,7 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -side top -expand yes -fill y scrollbar $w.frame.scroll -command "$w.frame.list yview" diff --git a/library/demos/combo.tcl b/library/demos/combo.tcl index acab497..53e5a27 100644 --- a/library/demos/combo.tcl +++ b/library/demos/combo.tcl @@ -56,7 +56,7 @@ bind $w.c1.c <Return> { } } -pack $w.c1 $w.c2 $w.c3 -side top -pady 5 -padx 10 -pack $w.c1.c -pady 5 -padx 10 -pack $w.c2.c -pady 5 -padx 10 -pack $w.c3.c -pady 5 -padx 10 +pack $w.c1 $w.c2 $w.c3 -side top -pady 3p -padx 7.5p +pack $w.c1.c -pady 3p -padx 7.5p +pack $w.c2.c -pady 3p -padx 7.5p +pack $w.c3.c -pady 3p -padx 7.5p diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index d3fec33..6874226 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -31,16 +31,16 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -canvas $c -relief flat -borderwidth 0 -width 500 -height 350 +canvas $c -relief flat -borderwidth 0 -width 375p -height 262.5p pack $w.c -side top -expand yes -fill both set textFont {Helvetica 24} -$c create rectangle 245 195 255 205 -outline black -fill red +$c create rectangle 183.75p 122.25p 191.25p 129.75p -outline black -fill red # First, create the text item and give it bindings so it can be edited. -$c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left] +$c addtag text withtag [$c create text 187.5p 126p -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 330p -anchor n -font $textFont -justify left] $c bind text <Button-1> "textB1Press $c %x %y" $c bind text <B1-Motion> "textB1Move $c %x %y" $c bind text <Shift-Button-1> "$c select adjust current @%x,%y" @@ -59,43 +59,43 @@ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] # Next, create some items that allow the text's anchor position # to be edited. -proc mkTextConfigBox {w x y option value color} { - set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \ - -outline black -fill $color -width 1] +proc mkTextConfigBox {w x y option value color} { ;# x, y are in points + set item [$w create rect ${x}p ${y}p [expr {$x+22.5}]p [expr {$y+22.5}]p \ + -outline black -fill $color -width 0.75p] $w bind $item <Button-1> "$w itemconf text $option $value" $w addtag config withtag $item } -proc mkTextConfigPie {w x y a option value color} { - set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \ +proc mkTextConfigPie {w x y a option value color} { ;# x, y are in points + set item [$w create arc ${x}p ${y}p [expr {$x+67.5}]p [expr {$y+67.5}]p \ -start [expr {$a-15}] -extent 30 -outline black -fill $color \ - -width 1] + -width 0.75p] $w bind $item <Button-1> "$w itemconf text $option $value" $w addtag config withtag $item } -set x 50 -set y 50 +set x 37.5 ;# in points +set y 37.5 ;# in points set color LightSkyBlue1 mkTextConfigBox $c $x $y -anchor se $color -mkTextConfigBox $c [expr {$x+30}] [expr {$y }] -anchor s $color -mkTextConfigBox $c [expr {$x+60}] [expr {$y }] -anchor sw $color -mkTextConfigBox $c [expr {$x }] [expr {$y+30}] -anchor e $color -mkTextConfigBox $c [expr {$x+30}] [expr {$y+30}] -anchor center $color -mkTextConfigBox $c [expr {$x+60}] [expr {$y+30}] -anchor w $color -mkTextConfigBox $c [expr {$x }] [expr {$y+60}] -anchor ne $color -mkTextConfigBox $c [expr {$x+30}] [expr {$y+60}] -anchor n $color -mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color +mkTextConfigBox $c [expr {$x+22.5}] [expr {$y }] -anchor s $color +mkTextConfigBox $c [expr {$x+45 }] [expr {$y }] -anchor sw $color +mkTextConfigBox $c [expr {$x }] [expr {$y+22.5}] -anchor e $color +mkTextConfigBox $c [expr {$x+22.5}] [expr {$y+22.5}] -anchor center $color +mkTextConfigBox $c [expr {$x+45 }] [expr {$y+22.5}] -anchor w $color +mkTextConfigBox $c [expr {$x }] [expr {$y+45 }] -anchor ne $color +mkTextConfigBox $c [expr {$x+22.5}] [expr {$y+45 }] -anchor n $color +mkTextConfigBox $c [expr {$x+45 }] [expr {$y+45 }] -anchor nw $color set item [$c create rect \ - [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \ + [expr {$x+30}]p [expr {$y+30}]p [expr {$x+37.5}]p [expr {$y+37.5}]p \ -outline black -fill red] $c bind $item <Button-1> "$c itemconf text -anchor center" -$c create text [expr {$x+45}] [expr {$y-5}] \ +$c create text [expr {$x+33.75}]p [expr {$y-3.75}]p \ -text {Text Position} -anchor s -font {Times 20} -fill brown # Now create some items that allow the text's angle to be changed. -set x 205 -set y 50 +set x 153.75 ;# in points +set y 37.5 ;# in points set color Yellow mkTextConfigPie $c $x $y 0 -angle 90 $color mkTextConfigPie $c $x $y 30 -angle 120 $color @@ -109,19 +109,19 @@ mkTextConfigPie $c $x $y 240 -angle 330 $color mkTextConfigPie $c $x $y 270 -angle 0 $color mkTextConfigPie $c $x $y 300 -angle 30 $color mkTextConfigPie $c $x $y 330 -angle 60 $color -$c create text [expr {$x+45}] [expr {$y-5}] \ - -text {Text Angle} -anchor s -font {Times 20} -fill brown +$c create text [expr {$x+33.75}]p [expr {$y-3.75}]p \ + -text {Text Angle} -anchor s -font {Times 20} -fill brown # Lastly, create some items that allow the text's justification to be # changed. -set x 350 -set y 50 +set x 262.5 ;# in points +set y 37.5 ;# in points set color SeaGreen2 mkTextConfigBox $c $x $y -justify left $color -mkTextConfigBox $c [expr {$x+30}] $y -justify center $color -mkTextConfigBox $c [expr {$x+60}] $y -justify right $color -$c create text [expr {$x+45}] [expr {$y-5}] \ +mkTextConfigBox $c [expr {$x+22.5}] $y -justify center $color +mkTextConfigBox $c [expr {$x+45}] $y -justify right $color +$c create text [expr {$x+33.75}]p [expr {$y-3.75}]p \ -text {Justification} -anchor s -font {Times 20} -fill brown $c bind config <Enter> "textEnter $c" diff --git a/library/demos/entry1.tcl b/library/demos/entry1.tcl index 58eda03..f41c2ab 100644 --- a/library/demos/entry1.tcl +++ b/library/demos/entry1.tcl @@ -26,7 +26,7 @@ pack $btns -side bottom -fill x entry $w.e1 entry $w.e2 entry $w.e3 -placeholder {Enter text here} -placeholderforeground gray75 -pack $w.e1 $w.e2 $w.e3 -side top -pady 5 -padx 10 -fill x +pack $w.e1 $w.e2 $w.e3 -side top -pady 3p -padx 7.5p -fill x $w.e1 insert 0 "Initial value" $w.e2 insert end "This entry contains a long value, much too long " diff --git a/library/demos/entry2.tcl b/library/demos/entry2.tcl index 1b143bc..ac82c6a 100644 --- a/library/demos/entry2.tcl +++ b/library/demos/entry2.tcl @@ -23,17 +23,17 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -side top -fill x -expand 1 entry $w.frame.e1 -xscrollcommand "$w.frame.s1 set" ttk::scrollbar $w.frame.s1 -orient horizontal -command \ "$w.frame.e1 xview" -frame $w.frame.spacer1 -width 20 -height 10 +frame $w.frame.spacer1 -width 15p -height 7.5p entry $w.frame.e2 -xscrollcommand "$w.frame.s2 set" ttk::scrollbar $w.frame.s2 -orient horizontal -command \ "$w.frame.e2 xview" -frame $w.frame.spacer2 -width 20 -height 10 +frame $w.frame.spacer2 -width 15p -height 7.5p entry $w.frame.e3 -xscrollcommand "$w.frame.s3 set" ttk::scrollbar $w.frame.s3 -orient horizontal -command \ "$w.frame.e3 xview" diff --git a/library/demos/filebox.tcl b/library/demos/filebox.tcl index e06ebba..261d113 100644 --- a/library/demos/filebox.tcl +++ b/library/demos/filebox.tcl @@ -33,7 +33,7 @@ foreach i {open save} { pack $f.lab -side left pack $f.ent -side left -expand yes -fill x pack $f.but -side left - pack $f -fill x -padx 1c -pady 3 + pack $f -fill x -padx 1c -pady 3p } if {[tk windowingsystem] eq "x11"} { diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl index 7d0ad3b..81920ed 100644 --- a/library/demos/floor.tcl +++ b/library/demos/floor.tcl @@ -53,6 +53,12 @@ proc floorDisplay {w active} { fg$active $w $colors(offices) $w raise room + # Rescale the coordinates in pixels of all of the + # items according to the display's DPI scaling level. + + set scaleFactor [expr {$tk::scalingPct / 100.0}] + $w scale all 0 0 $scaleFactor $scaleFactor + # Offset the floors diagonally from each other. $w move floor1 2c 2c @@ -60,9 +66,17 @@ proc floorDisplay {w active} { # Create items for the room entry and its label. - $w create window 600 100 -anchor w -window $w.entry - $w create text 600 100 -anchor e -text "Room: " - $w config -scrollregion [$w bbox all] + $w create window 450p 75p -anchor w -window $w.entry + $w create text 450p 75p -anchor e -text "Room: " + + # Configure the canvas. + + set bbox [$w bbox all] + lassign $bbox x1 y1 x2 y2 + set morePx [expr {round(20 * $tk::scalingPct / 100.0)}] + set width [expr {$x2 - $x1 + $morePx}] + set height [expr {$y2 - $y1 + $morePx}] + $w configure -scrollregion $bbox -width $width -height $height } # newRoom -- @@ -1296,7 +1310,7 @@ toplevel $w wm title $w "Floorplan Canvas Demonstration" wm iconname $w "Floorplan" wm geometry $w +20+20 -wm minsize $w 100 100 +wm minsize $w 75p 75p label $w.msg -font $font -wraplength 8i -justify left -text "This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up." pack $w.msg -side top @@ -1310,9 +1324,8 @@ pack $f -side top -fill both -expand yes set h [ttk::scrollbar $f.hscroll -orient horizontal] set v [ttk::scrollbar $f.vscroll -orient vertical] set f1 [frame $f.f1 -borderwidth 2 -relief sunken] -set c [canvas $f1.c -width 900 -height 500 -highlightthickness 0 \ - -xscrollcommand [list $h set] \ - -yscrollcommand [list $v set]] +set c [canvas $f1.c -highlightthickness 0 \ + -xscrollcommand [list $h set] -yscrollcommand [list $v set]] pack $c -expand yes -fill both grid $f1 -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news grid $v -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news @@ -1368,4 +1381,4 @@ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] } bind $c <Destroy> "unset currentRoom" set currentRoom "" -trace variable currentRoom w "roomChanged $c" +trace add variable currentRoom write "roomChanged $c" diff --git a/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl index 446ed34..4353a4d 100644 --- a/library/demos/fontchoose.tcl +++ b/library/demos/fontchoose.tcl @@ -40,7 +40,7 @@ bind $w <<TkFontchooserVisibility>> { } -set f [ttk::frame $w.f -relief sunken -padding 2] +set f [ttk::frame $w.f -relief sunken -padding 1.5p] text $f.msg -font FontchooseDemoFont -width 40 -height 6 -borderwidth 0 \ -yscrollcommand [list $f.vs set] diff --git a/library/demos/goldberg.tcl b/library/demos/goldberg.tcl index be64050..7326da6 100644 --- a/library/demos/goldberg.tcl +++ b/library/demos/goldberg.tcl @@ -50,11 +50,19 @@ wm iconname $w "goldberg" wm resizable $w 0 0 #positionWindow $w -label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\ - demonstration of just how complex you can make your animations\ +label $w.msg -font {Helvetica 10} -wraplength 4.5i -justify left -text "This\ + is a demonstration of just how complex you can make your animations\ become. Click the ball to start things moving!\n\n\"Man will always\ find a difficult means to perform a simple task\"\n - Rube Goldberg" -pack $w.msg -side top +pack $w.msg -side top -fill x + +if {[tk windowingsystem] ne "aqua"} { + ttk::button $w.hide -text "×" -command [list pack forget $w.msg] -width 2 +} else { + button $w.hide -text "×" -command [list pack forget $w.msg] -width 1 \ + -highlightthickness 0 -padx 0 -pady 0 +} +place $w.hide -in $w.msg -relx 1 -rely 0 -anchor ne ###--- End of Boilerplate ---### @@ -62,15 +70,16 @@ pack $w.msg -side top array set animationCallbacks {} bind $w <Destroy> { if {"%W" eq [winfo toplevel %W]} { - unset S C speed + unset S C delays } } set S(title) "Tk Goldberg" set S(speed) 5 set S(cnt) 0 -set S(message) "\\nWelcome\\nto\\nTcl/Tk" -array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500} +set S(message) "\\nWelcome\\nto\\nTcl/Tk!" +array set delays \ + {1 500 2 400 3 300 4 200 5 150 6 100 7 80 8 50 9 20 10 10} set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5 set S(mode) $::MSTART @@ -96,13 +105,13 @@ set C(24c) black; set C(26) $C(0); proc DoDisplay {w} { global S C - ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5 - pack [frame $w.screen -bd 2 -relief raised] \ + ttk::frame $w.ctrl -relief ridge -borderwidth 1 -padding 3p + pack [frame $w.screen -bd 1 -relief raised] \ -side left -fill both -expand 1 - canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0 - $w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up - $w.c yview moveto .05 + canvas $w.c -width 645p -height 480p -bg $C(bg) -highlightthickness 0 + $w.c config -scrollregion {0 0 750p 750p} ;# Kludge: move everything up + $w.c yview moveto .09 pack $w.c -in $w.screen -side top -fill both -expand 1 bind $w.c <Button-3> [list $w.pause invoke] @@ -113,9 +122,11 @@ proc DoDisplay {w} { DoCtrlFrame $w DoDetailFrame $w if {[tk windowingsystem] ne "aqua"} { - ttk::button $w.show -text "»" -command [list ShowCtrl $w] -width 2 + ttk::button $w.show -text "▶" -command [list ShowCtrl $w] -width 2 } else { - button $w.show -text "»" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg) + button $w.show -text "▶" -command [list ShowCtrl $w] -width 1 \ + -borderwidth 1 -highlightthickness 0 -padx 0 -pady 0 \ + -highlightbackground $C(bg) } place $w.show -in $w.c -relx 1 -rely 0 -anchor ne update @@ -136,46 +147,50 @@ proc DoCtrlFrame {w} { ttk::labelframe $w.message -text "Message" ttk::entry $w.message.e -textvariable S(message) -justify center ttk::labelframe $w.speed -text "Speed: 0" - ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 -variable S(speed) + ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 \ + -variable S(speed) ttk::button $w.about -text About -command [list About $w] grid $w.start -in $w.ctrl -row 0 -sticky ew - grid rowconfigure $w.ctrl 1 -minsize 10 + grid rowconfigure $w.ctrl 1 -minsize 7.5p grid $w.pause -in $w.ctrl -row 2 -sticky ew - grid $w.step -in $w.ctrl -sticky ew -pady 2 + grid $w.step -in $w.ctrl -sticky ew -pady 1.5p grid $w.bstep -in $w.ctrl -sticky ew - grid $w.reset -in $w.ctrl -sticky ew -pady 2 - grid rowconfigure $w.ctrl 10 -minsize 18 + grid $w.reset -in $w.ctrl -sticky ew -pady 1.5p + grid rowconfigure $w.ctrl 10 -minsize 13.5p grid $w.details -in $w.ctrl -row 11 -sticky ew - grid rowconfigure $w.ctrl 11 -minsize 20 + grid rowconfigure $w.ctrl 11 -minsize 15p $w.details configure -labelwidget $w.details.cb grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug raise $w.details raise $w.details.cb grid rowconfigure $w.ctrl 50 -weight 1 - trace variable ::S(mode) w [list ActiveGUI $w] - trace variable ::S(details) w [list ActiveGUI $w] - trace variable ::S(speed) w [list ActiveGUI $w] + trace add variable ::S(mode) write [list ActiveGUI $w] + trace add variable ::S(details) write [list ActiveGUI $w] + trace add variable ::S(speed) write [list ActiveGUI $w] - grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5 + grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 3p grid $w.message.e -sticky nsew - grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5} + grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 3p} pack $w.speed.scale -fill both -expand 1 grid $w.about -in $w.ctrl -row 100 -sticky ew bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging ## See Code / Dismiss buttons hack! - set btns [addSeeDismiss $w.ctrl.buttons $w] - grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4 - set i 0 - foreach b [winfo children $btns] { + grid [ttk::separator $w.ctrl.sep] -sticky ew -pady {3p 1.5p} + set btns {} + foreach b [winfo children [addSeeDismiss $w.ctrl.buttons $w]] { if {[winfo class $b] eq "TButton"} { - grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew - foreach b3 [$b configure] { - set b3 [lindex $b3 0] - # Some options are read-only; ignore those errors - catch {$b2 configure $b3 [$b cget $b3]} - } + set btns [linsert $btns 0 $b] ;# Prepend + } + } + set i 0 + foreach b $btns { + grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew -pady {1.5p 0} + foreach b3 [$b configure] { + set b3 [lindex $b3 0] + # Some options are read-only; ignore those errors + catch {$b2 configure $b3 [$b cget $b3]} } } destroy $btns @@ -185,7 +200,6 @@ proc DoDetailFrame {w} { set w2 $w.details.f ttk::frame $w2 - set bd 2 ttk::label $w2.l -textvariable S(cnt) -background white grid $w2.l - - - -sticky ew -row 0 for {set i 1} {1} {incr i} { @@ -204,10 +218,10 @@ proc DoDetailFrame {w} { proc ShowCtrl {w} { if {[winfo ismapped $w.ctrl]} { pack forget $w.ctrl - $w.show config -text "»" + $w.show config -text "▶" } else { pack $w.ctrl -side right -fill both -ipady 5 - $w.show config -text "»" + $w.show config -text "◀" } } @@ -219,6 +233,27 @@ proc DrawAll {w} { if {[info procs $p] eq ""} break $p $w } + + set scaleFactor [expr {$::tk::scalingPct / 100.0}] + $w.c scale all 0 0 $scaleFactor $scaleFactor + + # Tile the strike box with the built-in bitmap gray25 + lassign [$w.c coords StrikeBox] x1 y1 x2 y2 + set x1 [expr {round($x1)}]; set y1 [expr {round($y1)}] + set x2 [expr {round($x2)}]; set y2 [expr {round($y2)}] + set rowCount [expr {($y2 - $y1) / 16}] + set colCount [expr {($x2 - $x1) / 16}] + for {set row 0; set y $y1} {$row < $rowCount} {incr row; incr y 16} { + for {set col 0; set x $x1} {$col < $colCount} {incr col; incr x 16} { + $w.c create bitmap $x $y -bitmap gray25 -anchor nw \ + -foreground $::C(fg) + } + $w.c create bitmap $x2 $y -bitmap gray25 -anchor ne -foreground $::C(fg) + } + for {set col 0; set x $x1} {$col < $colCount} {incr col; incr x 16} { + $w.c create bitmap $x $y2 -bitmap gray25 -anchor sw -foreground $::C(fg) + } + $w.c create bitmap $x2 $y2 -bitmap gray25 -anchor se -foreground $::C(fg) } proc ActiveGUI {w var1 var2 op} { @@ -267,12 +302,12 @@ proc DoButton {w what} { } proc Go {w {who {}}} { - global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP + global S delays animationCallbacks MGO MPAUSE MSSTEP MBSTEP set now [clock clicks -milliseconds] catch {after cancel $animationCallbacks(goldberg)} if {$who ne ""} { ;# Start here for debugging - set S(active) $who; + set S(active) $who set S(mode) $MGO } if {$S(mode) == -1} return ;# Debugging @@ -288,7 +323,7 @@ proc Go {w {who {}}} { } set elapsed [expr {[clock click -milliseconds] - $now}] - set delay [expr {$speed($S(speed)) - $elapsed}] + set delay [expr {$delays($S(speed)) - $elapsed}] if {$delay <= 0} { set delay 1 } @@ -322,6 +357,7 @@ proc NextStep {w} { set S(active) $alive return $rval } + proc About {w} { set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\ permission of the author)\n\n\"Man will always find a difficult\ @@ -336,12 +372,12 @@ proc About {w} { # START HERE! banner proc Draw0 {w} { set color $::C(0) - set xy {579 119} - $w.c create text $xy -text "START HERE!" -fill $color -anchor w \ - -tag I0 -font {{Times Roman} 12 italic bold} + set xy {699 119} + $w.c create text $xy -text "START HERE!" -fill $color -anchor e \ + -tag {I0 I0_0} -font {Times 12 italic bold} set xy {719 119 763 119} - $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \ - -arrowshape {18 18 5} + $w.c create line $xy -tag {I0 I0_1} -fill $color -width 3.75p -arrow last \ + -arrowshape {13.5p 13.5p 3.75p} $w.c bind I0 <Button-1> Start } proc Move0 {w {step {}}} { @@ -352,12 +388,14 @@ proc Move0 {w {step {}}} { return 2 } - set pos { - {673 119} {678 119} {683 119} {688 119} - {693 119} {688 119} {683 119} {678 119} - } + set pos [scl { + {719 119} {724 119} {729 119} {734 119} + {739 119} {734 119} {729 119} {724 119} + }] set step [expr {$step % [llength $pos]}] - MoveAbs $w I0 [lindex $pos $step] + lassign [lindex $pos $step] x y + $w.c coords I0_0 [expr {$x - [scl 20]}] $y + $w.c coords I0_1 $x $y [expr {$x + [scl 44]}] $y return 1 } @@ -366,9 +404,9 @@ proc Draw1 {w} { set color $::C(1a) set color2 $::C(1b) set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133} - $w.c create poly $xy -width 3 -fill $color -outline {} + $w.c create poly $xy -width 2.25p -fill $color -outline {} set xy {771 133 685 133 685 168 751 168 751 346 771 346 771 133} - $w.c create poly $xy -width 3 -fill $color -outline {} + $w.c create poly $xy -width 2.25p -fill $color -outline {} set xy [box 812 122 9] $w.c create oval $xy -tag I1 -fill $color2 -outline {} @@ -376,11 +414,11 @@ proc Draw1 {w} { } proc Move1 {w {step {}}} { set step [GetStep 1 $step] - set pos { + set pos [scl { {807 122} {802 122} {797 123} {793 124} {789 129} {785 153} {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503} {824 585 y} {838 587} {848 593} {857 601} {-100 -100} - } + }] if {$step >= [llength $pos]} { return 0 } @@ -403,21 +441,14 @@ proc Draw2 {w} { set xy {750 369 740 392 760 392} ;# Fulcrum $w.c create poly $xy -fill $::C(fg) -outline $::C(fg) set xy {628 335 660 383} ;# Strike box - $w.c create rect $xy -fill {} -outline $::C(fg) - for {set y 0} {$y < 3} {incr y} { - set yy [expr {335+$y*16}] - $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \ - -foreground $::C(fg) - $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \ - -foreground $::C(fg) - } + $w.c create rect $xy -fill {} -outline $::C(fg) -tag StrikeBox set xy {702 366 798 366} ;# Lever - $w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0 + $w.c create line $xy -fill $::C(fg) -width 5.25p -tag I2_0 set xy {712 363 712 355} ;# R strap - $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1 + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I2_1 set xy {705 363 705 355} ;# L strap - $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2 + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I2_2 set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick $w.c create line $xy -fill $::C(fg) -tag I2_3 @@ -432,15 +463,16 @@ proc Move2 {w {step {}}} { set step [GetStep 2 $step] set stages {0 0 1 2 0 2 1 0 1 2 0 2 1} - set xy(0) { + set xy(0) [scl { 686 333 692 323 682 316 674 309 671 295 668 307 662 318 662 328 671 336 - } - set xy(1) {687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335} - set xy(2) { + }] + set xy(1) [scl { + 687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335}] + set xy(2) [scl { 686 331 704 322 688 300 678 283 678 283 674 298 666 309 660 324 672 336 - } + }] if {$step >= [llength $stages]} { $w.c delete I2 @@ -468,24 +500,24 @@ proc Draw3 {w} { set xy {602 296 577 174 518 174} foreach {x y} $xy { ;# 3 Pulleys $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \ - -width 3 + -width 2.25p $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg) } set xy {750 309 670 309} ;# Wall to flame - $w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1 + $w.c create line $xy -tag I3_s -width 2.25p -fill $::C(fg) -smooth 1 set xy {670 309 650 309} ;# Flame to pulley 1 - $w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg) + $w.c create line $xy -tag I3_0 -width 2.25p -fill $::C(fg) set xy {650 309 600 309} ;# Flame to pulley 1 - $w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg) + $w.c create line $xy -tag I3_1 -width 2.25p -fill $::C(fg) set xy {589 296 589 235} ;# Pulley 1 half way to 2 - $w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg) + $w.c create line $xy -tag I3_2 -width 2.25p -fill $::C(fg) set xy {589 235 589 174} ;# Pulley 1 other half to 2 - $w.c create line $xy -width 3 -fill $::C(fg) + $w.c create line $xy -width 2.25p -fill $::C(fg) set xy {577 161 518 161} ;# Across the top - $w.c create line $xy -width 3 -fill $::C(fg) + $w.c create line $xy -width 2.25p -fill $::C(fg) set xy {505 174 505 205} ;# Down to weight - $w.c create line $xy -tag I3_w -width 3 -fill $::C(fg) + $w.c create line $xy -tag I3_w -width 2.25p -fill $::C(fg) # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle set xy {515 207 495 207} @@ -502,19 +534,19 @@ proc Draw3 {w} { set xy [RoundRect $w $xy 15] $w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2 set xy {500 217 511 217} - $w.c create line $xy -tag I3_ -fill $color2 -width 10 + $w.c create line $xy -tag I3_ -fill $color2 -width 7.5p set xy {502 393 522 393 522 465} ;# Bottom weight target - $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10 + $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 7.5p } proc Move3 {w {step {}}} { set step [GetStep 3 $step] - set pos {{505 247} {505 297} {505 386.5} {505 386.5}} - set rope(0) {750 309 729 301 711 324 690 300} - set rope(1) {750 309 737 292 736 335 717 315 712 320} - set rope(2) {750 309 737 309 740 343 736 351 725 340} - set rope(3) {750 309 738 321 746 345 742 356} + set pos [scl {{505 247} {505 297} {505 386.5} {505 386.5}}] + set rope(0) [scl {750 309 729 301 711 324 690 300}] + set rope(1) [scl {750 309 737 292 736 335 717 315 712 320}] + set rope(2) [scl {750 309 737 309 740 343 736 351 725 340}] + set rope(3) [scl {750 309 738 321 746 345 742 356}] if {$step >= [llength $pos]} { return 0 @@ -523,7 +555,7 @@ proc Move3 {w {step {}}} { $w.c delete "I3_$step" ;# Delete part of the rope MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down $w.c coords I3_s $rope($step) ;# Flapping rope end - $w.c coords I3_w [concat 505 174 [lindex $pos $step]] + $w.c coords I3_w [concat [scl {505 174}] [lindex $pos $step]] if {$step == 2} { $w.c move I3__ 0 30 return 2 @@ -537,14 +569,14 @@ proc Draw4 {w} { lassign {527 356 611 464} x0 y0 x1 y1 for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars - $w.c create line $x0 $y $x1 $y -fill $color -width 1 + $w.c create line $x0 $y $x1 $y -fill $color -width 0.75p } for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars - $w.c create line $x $y0 $x $y1 -fill $color -width 1 + $w.c create line $x $y0 $x $y1 -fill $color -width 0.75p } set xy {518 464 518 428} ;# Swing gate - $w.c create line $xy -tag I4 -fill $color -width 3 + $w.c create line $xy -tag I4 -fill $color -width 2.25p } proc Move4 {w {step {}}} { set step [GetStep 4 $step] @@ -553,7 +585,7 @@ proc Move4 {w {step {}}} { if {$step >= [llength $angles]} { return 0 } - RotateItem $w I4 518 464 [lindex $angles $step] + RotateItem $w I4 [scl 518] [scl 464] [lindex $angles $step] $w.c raise I4 return [expr {$step == 3 ? 3 : 1}] } @@ -564,7 +596,7 @@ proc Draw5 {w} { set color2 $::C(5b) set xy {377 248 410 248 410 465 518 465} ;# Mouse course lappend xy 518 428 451 428 451 212 377 212 - $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3 + $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 2.25p set xy { 534.5 445.5 541 440 552 436 560 436 569 440 574 446 575 452 574 454 @@ -572,29 +604,29 @@ proc Draw5 {w} { } $w.c create poly $xy -tag {I5 I5_0} -fill $color set xy {573 452 592 458 601 460 613 456} ;# Tail - $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3 + $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 2.25p set xy [box 540 446 2] ;# Eye set xy {540 444 541 445 541 447 540 448 538 447 538 445} #.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} $w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1 set xy {538 454 535 461} ;# Front leg - $w.c create line $xy -tag {I5 I5_3} -fill $color -width 2 + $w.c create line $xy -tag {I5 I5_3} -fill $color -width 1.5p set xy {566 455 569 462} ;# Back leg - $w.c create line $xy -tag {I5 I5_4} -fill $color -width 2 + $w.c create line $xy -tag {I5 I5_4} -fill $color -width 1.5p set xy {544 455 545 460} ;# 2nd front leg - $w.c create line $xy -tag {I5 I5_5} -fill $color -width 2 + $w.c create line $xy -tag {I5 I5_5} -fill $color -width 1.5p set xy {560 455 558 460} ;# 2nd back leg - $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2 + $w.c create line $xy -tag {I5 I5_6} -fill $color -width 1.5p } proc Move5 {w {step {}}} { set step [GetStep 5 $step] - set pos { + set pos [scl { {553 452} {533 452} {513 452} {493 452} {473 452} {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394} {422 374} {422 354} {422 334} {422 314} {422 294} {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237} - } + }] if {$step >= [llength $pos]} { return 0 } @@ -631,22 +663,22 @@ proc Draw6 {w} { set color $::C(6) set xy {324 130 391 204} ;# Ball holder set xy [RoundRect $w $xy 10] - $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color + $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 2.25p -fill $color set xy {339 204 376 253} ;# Below the ball holder - $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \ + $w.c create rect $xy -fill {} -outline $::C(fg) -width 2.25p -fill $color \ -tag I6c set xy [box 346 339 28] $w.c create oval $xy -fill $color -outline {} ;# Rotor - $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 1.5p -style arc \ -start 80 -extent 205 - $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 1.5p -style arc \ -start -41 -extent 85 set xy [box 346 339 15] ;# Center of rotor $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor $w.c create poly $xy -fill $color -outline {} - $w.c create line $xy -fill $::C(fg) -width 2 + $w.c create line $xy -fill $::C(fg) -width 1.5p set xy {353 240 367 300} ;# Poke bottom hole $w.c create rect $xy -fill $color -outline {} @@ -654,21 +686,21 @@ proc Draw6 {w} { $w.c create rect $xy -fill $color -outline {} set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366} - $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor - $w.c create line $xy -fill $::C(fg) -width 2 + $w.c create poly $xy -fill $color -outline {} -width 1.5p ;# Below rotor + $w.c create line $xy -fill $::C(fg) -width 1.5p set xy [box 275 342 7] ;# On/off rotor $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) set xy {276 334 342 325} ;# Fan belt top - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy {276 349 342 353} ;# Fan belt bottom - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy {337 212 337 247} ;# What the mouse pushes - $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I6_ set xy {392 212 392 247} - $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I6_ set xy {337 230 392 230} - $w.c create line $xy -fill $::C(fg) -width 7 -tag I6_ + $w.c create line $xy -fill $::C(fg) -width 5.25p -tag I6_ set who -1 ;# All the balls set colors {red cyan orange green blue darkblue} @@ -682,15 +714,23 @@ proc Draw6 {w} { } Draw6a $w 12 ;# The wheel } -proc Draw6a {w beta} { +proc Draw6a {w beta {scale 0}} { $w.c delete I6_0 - lassign {346 339} Ox Oy + if {$scale} { + lassign [scl {346 339}] Ox Oy + } else { + lassign {346 339} Ox Oy + } for {set i 0} {$i < 4} {incr i} { set b [expr {$beta + $i * 45}] - lassign [RotateC 28 0 0 0 $b] x y + if {$scale} { + lassign [RotateC [scl 28] 0 0 0 $b] x y + } else { + lassign [RotateC 28 0 0 0 $b] x y + } set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \ [expr {$Ox-$x}] [expr {$Oy-$y}]] - $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2 + $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 1.5p } } proc Move6 {w {step {}}} { @@ -700,9 +740,9 @@ proc Move6 {w {step {}}} { } if {$step < 2} { ;# Open gate for balls to drop - $w.c move I6_ -7 0 + $w.c move I6_ -5.25p 0 if {$step == 1} { ;# Poke a hole - set xy {348 226 365 240} + set xy [scl {348 226 365 240}] $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {} } return 1 @@ -715,9 +755,9 @@ proc Move6 {w {step {}}} { set loc [expr {$s - 3 * $i}] if {[info exists ::XY6($loc,$i)]} { - MoveAbs $w $tag $::XY6($loc,$i) + MoveAbs $w $tag [scl $::XY6($loc,$i)] } elseif {[info exists ::XY6($loc)]} { - MoveAbs $w $tag $::XY6($loc) + MoveAbs $w $tag [scl $::XY6($loc)] } } if {($s % 3) == 1} { @@ -726,13 +766,13 @@ proc Move6 {w {step {}}} { set tag "I6_b$i" if {[$w.c find withtag $tag] eq ""} break set loc [expr {$first - $i}] - MoveAbs $w $tag $::XY6($loc) + MoveAbs $w $tag [scl $::XY6($loc)] } } if {$s >= 3} { ;# Rotate the motor set idx [expr {$s % 3}] #Draw6a $w [lindex {12 35 64} $idx] - Draw6a $w [expr {12 + $s * 15}] + Draw6a $w [expr {12 + $s * 15}] 1 } return [expr {$s == 3 ? 3 : 1}] } @@ -741,15 +781,15 @@ proc Move6 {w {step {}}} { proc Draw7 {w} { set color $::C(7) set xy {198 306 277 374} ;# Box - $w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z + $w.c create rect $xy -outline $::C(fg) -width 1.5p -fill $color -tag I7z $w.c lower I7z set xy {275 343 230 349} $w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \ - -arrowshape {23 23 8} -width 6 + -arrowshape {17.25p 17.25p 6p} -width 4.5p set xy {225 324} ;# On button $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) set xy {218 323} ;# On text - set font {{Times Roman} 8} + set font {Times 8} $w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font set xy {225 350} ;# Off button $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) @@ -763,14 +803,14 @@ proc Move7 {w {step {}}} { return 0 } set beta [expr {30.0 / $numsteps}] - RotateItem $w I7 275 343 $beta + RotateItem $w I7 [scl 275] [scl 343] $beta return [expr {$step == $numsteps ? 3 : 1}] } # Electricity to the fan proc Draw8 {w} { - Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3 + Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 2.25p } proc Move8 {w {step {}}} { set step [GetStep 8 $step] @@ -806,24 +846,24 @@ proc Draw9 {w} { $w.c create poly $xy -fill $color set xy {255 206 265 234} ;# Fan blades - $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 + $w.c create oval $xy -fill {} -outline $::C(fg) -width 2.25p -tag I9_0 set xy {255 176 265 204} - $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 + $w.c create oval $xy -fill {} -outline $::C(fg) -width 2.25p -tag I9_0 set xy {255 206 265 220} - $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1 + $w.c create oval $xy -fill {} -outline $::C(fg) -width 0.75p -tag I9_1 set xy {255 190 265 204} - $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1 + $w.c create oval $xy -fill {} -outline $::C(fg) -width 0.75p -tag I9_1 } proc Move9 {w {step {}}} { set step [GetStep 9 $step] if {$step & 1} { - $w.c itemconfig I9_0 -width 4 - $w.c itemconfig I9_1 -width 1 + $w.c itemconfig I9_0 -width 3p + $w.c itemconfig I9_1 -width 0.75p $w.c lower I9_1 I9_0 } else { - $w.c itemconfig I9_0 -width 1 - $w.c itemconfig I9_1 -width 4 + $w.c itemconfig I9_0 -width 0.75p + $w.c itemconfig I9_1 -width 3p $w.c lower I9_0 I9_1 } if {$step == 0} { @@ -837,47 +877,47 @@ proc Draw10 {w} { set color $::C(10a) set color2 $::C(10b) set xy {191 230 233 230 233 178 191 178} ;# Sail - $w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10 + $w.c create poly $xy -fill $color -width 2.25p -outline $::C(fg) -tag I10 set xy [box 209 204 31] ;# Front $w.c create arc $xy -outline {} -fill $color -style pie \ -start 120 -extent 120 -tag I10 - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc \ -start 120 -extent 120 -tag I10 set xy [box 249 204 31] ;# Back - $w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \ + $w.c create arc $xy -outline {} -fill $::C(bg) -width 2.25p -style pie \ -start 120 -extent 120 -tag I10 - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc \ -start 120 -extent 120 -tag I10 set xy {200 171 200 249} ;# Mast - $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I10 set xy {159 234 182 234} ;# Bow sprit - $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I10 set xy {180 234 180 251 220 251} ;# Hull - $w.c create line $xy -fill $::C(fg) -width 6 -tag I10 + $w.c create line $xy -fill $::C(fg) -width 4.5p -tag I10 set xy {92 255 221 255} ;# Waves - Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w + Sine $w {*}$xy 2 25 -fill $color2 -width 0.75p -tag I10w set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water set xy [concat $xy 222 266 222 277 99 277] $w.c create poly $xy -fill $color2 -outline $color2 set xy {222 266 222 277 97 277 97 266} ;# Water bottom - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy [box 239 262 17] - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc \ -start 95 -extent 103 set xy [box 76 266 21] - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190 + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc -extent 190 } proc Move10 {w {step {}}} { set step [GetStep 10 $step] - set pos { + set pos [scl { {195 212} {193 212} {190 212} {186 212} {181 212} {176 212} {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212} {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212} - } + }] if {$step >= [llength $pos]} { return 0 @@ -901,31 +941,31 @@ proc Draw11 {w} { $w.c create oval $xy -fill $color -outline {} set xy {55 264 55 458} ;# Top right side - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy {55 504 55 591} ;# Bottom right side - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy [box 71 460 48] ;# Outer loop - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc \ -start 110 -extent -290 -tag I11i set xy [box 71 460 16] ;# Inner loop - $w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i - $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3 + $w.c create oval $xy -outline $::C(fg) -fill {} -width 2.25p -tag I11i + $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 2.25p set xy {23 264 23 591} ;# Left side - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy [box 1 266 23] ;# Top left curve - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90 + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc -extent 90 set xy [box 75 235 9] ;# The ball - $w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11 + $w.c create oval $xy -fill $color2 -outline {} -width 2.25p -tag I11 } proc Move11 {w {step {}}} { set step [GetStep 11 $step] - set pos { + set pos [scl { {75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296} {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423} {-100 -100} {38 505} {38 527 x} {38 591} - } + }] if {$step >= [llength $pos]} { return 0 @@ -952,11 +992,11 @@ proc Draw12 {w} { lappend xy $x $y0 $x1 $y1 $x2 $y0 } $w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \ - -width 3 + -width 2.25p } proc Move12 {w {step {}}} { set step [GetStep 12 $step] - set pos {{42.5 641 x}} + set pos [scl {{42 641 x}}] if {$step >= [llength $pos]} { return 0 } @@ -976,29 +1016,27 @@ proc Draw13 {w} { set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671} set radii {2 9 9 8 5 5 2} - RoundPoly $w.c $xy $radii -width 3 -outline $::C(fg) -fill $color - RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color + RoundPoly $w.c $xy $radii -width 2.25p -outline $::C(fg) -fill $color + RoundPoly $w.c $xy2 $radii -width 2.25p -outline $::C(fg) -fill $color set xy {56 677} - $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 2.25p \ -tag I13 set xy {809 677} - $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 2.25p \ -tag I13R set xy {112 687} ;# Label - $w.c create text $xy -text "FAX" -fill $::C(fg) \ - -font {{Times Roman} 12 bold} + $w.c create text $xy -text "FAX" -fill $::C(fg) -font {Times 12 bold} set xy {762 687} - $w.c create text $xy -text "FAX" -fill $::C(fg) \ - -font {{Times Roman} 12 bold} + $w.c create text $xy -text "FAX" -fill $::C(fg) -font {Times 12 bold} set xy {138 663 148 636 178 636} ;# Paper guide - $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 + $w.c create line $xy -smooth 1 -fill $::C(fg) -width 2.25p set xy {732 663 722 636 692 636} - $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 + $w.c create line $xy -smooth 1 -fill $::C(fg) -width 2.25p - Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3 + Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 2.25p } proc Move13 {w {step {}}} { set step [GetStep 13 $step] @@ -1006,7 +1044,7 @@ proc Move13 {w {step {}}} { if {$step == $numsteps+2} { MoveAbs $w I13_star {-100 -100} - $w.c itemconfig I13R -fill $::C(13b) -width 2 + $w.c itemconfig I13R -fill $::C(13b) -width 1.5p return 2 } if {$step == 0} { ;# Button down @@ -1025,22 +1063,22 @@ proc Move13 {w {step {}}} { proc Draw14 {w} { set color $::C(14) set xy {102 661 113 632 130 618} ;# Left paper edge - $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0 + $w.c create line $xy -smooth 1 -fill $color -width 2.25p -tag I14L_0 set xy {148 629 125 640 124 662} ;# Right paper edge - $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1 + $w.c create line $xy -smooth 1 -fill $color -width 2.25p -tag I14L_1 Draw14a $w L set xy { 768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171 } - $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_0 + $w.c create line $xy -smooth 1 -fill $color -width 2.25p -tag I14R_0 $w.c lower I14R_0 # NB. these numbers are VERY sensitive, you must start with final size # and shrink down to get the values set xy { 745.947897349 662.428358855 745.997829056 662.452239237 746.0 662.5 } - $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1 + $w.c create line $xy -smooth 1 -fill $color -width 2.25p -tag I14R_1 $w.c lower I14R_1 } proc Draw14a {w side} { @@ -1054,7 +1092,7 @@ proc Draw14a {w side} { $x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5] $w.c delete I14$side $w.c create poly $zz -tag I14$side -smooth 1 -fill $color -outline $color \ - -width 3 + -width 2.25p $w.c lower I14$side } proc Move14 {w {step {}}} { @@ -1090,28 +1128,28 @@ proc Move14 {w {step {}}} { proc Draw15 {w} { set color $::C(15a) set xy {824 599 824 585 820 585 829 585} - $w.c create line $xy -fill $::C(fg) -width 3 -tag I15a + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I15a set xy {789 599 836 643} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p set xy {778 610 788 632} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p set xy {766 617 776 625} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p set xy {633 600 681 640} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p set xy {635 567 657 599} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 2 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p set xy {765 557 784 583} - $w.c create rect $xy -fill $color -outline $::C(fg) -width 2 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2.25p - Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3 + Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 2.25p } proc Move15a {w} { set color $::C(15b) - $w.c scale I15a 824 599 1 .3 ;# Button down - set xy {765 621 681 621} - $w.c create line $xy -dash "-" -width 3 -fill $color -tag I15 + $w.c scale I15a [scl 824] [scl 599] 1 .3 ;# Button down + set xy [scl {765 621 681 621}] + $w.c create line $xy -dash "-" -width 2.25p -fill $color -tag I15 } proc Move15 {w {step {}}} { set step [GetStep 15 $step] @@ -1123,7 +1161,7 @@ proc Move15 {w {step {}}} { } if {$step == 0} { ;# Break the light beam Sparkle $w {-100 -100} I15_star - set xy {765 621 745 621} + set xy [scl {765 621 745 621}] $w.c coords I15 $xy return 1 } @@ -1138,14 +1176,14 @@ proc Move15 {w {step {}}} { proc Draw16 {w} { set color $::C(16) set xy {722 485 791 556} - $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 + $w.c create rect $xy -fill {} -outline $::C(fg) -width 2.25p set xy [box 752 515 25] ;# Bell - $w.c create oval $xy -fill $color -outline black -tag I16b -width 2 + $w.c create oval $xy -fill $color -outline black -tag I16b -width 1.5p set xy [box 752 515 5] ;# Bell button $w.c create oval $xy -fill black -outline black -tag I16b set xy {784 523 764 549} ;# Clapper - $w.c create line $xy -width 3 -tag I16c -fill $::C(fg) + $w.c create line $xy -width 2.25p -tag I16c -fill $::C(fg) set xy [box 784 523 4] $w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d } @@ -1153,13 +1191,13 @@ proc Move16 {w {step {}}} { set step [GetStep 16 $step] # Note: we never stop - lassign {760 553} Ox Oy + lassign [scl {760 553}] Ox Oy if {$step & 1} { set beta 12 - $w.c move I16b 3 0 + $w.c move I16b 2.25p 0 } else { set beta -12 - $w.c move I16b -3 0 + $w.c move I16b -2.25p 0 } RotateItem $w I16c $Ox $Oy $beta RotateItem $w I16d $Ox $Oy $beta @@ -1172,82 +1210,82 @@ proc Draw17 {w} { set color $::C(17) set xy {584 556 722 556} - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy {584 485 722 485} - $w.c create line $xy -fill $::C(fg) -width 3 + $w.c create line $xy -fill $::C(fg) -width 2.25p set xy {664 523 717 549} ;# Body - $w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \ + $w.c create arc $xy -outline $::C(fg) -fill $color -width 2.25p \ -style chord -start 128 -extent -260 -tag I17 set xy {709 554 690 543} ;# Paw - $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 + $w.c create oval $xy -outline $::C(fg) -fill $color -width 2.25p -tag I17 set xy {657 544 676 555} - $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 + $w.c create oval $xy -outline $::C(fg) -fill $color -width 2.25p -tag I17 set xy [box 660 535 15] ;# Lower face - $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -style arc \ -start 150 -extent 240 -tag I17_ - $w.c create arc $xy -outline {} -fill $color -width 1 -style chord \ + $w.c create arc $xy -outline {} -fill $color -width 0.75p -style chord \ -start 150 -extent 240 -tag I17_ set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - $w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c} + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ + $w.c create poly $xy -fill $color -outline {} -width 0.75p -tag {I17_ I17_c} set xy {652 542 628 539} ;# Whiskers - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ set xy {652 543 632 545} - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ set xy {652 546 632 552} - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ set xy {668 543 687 538} - $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag {I17_ I17w} set xy {668 544 688 546} - $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag {I17_ I17w} set xy {668 547 688 553} - $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag {I17_ I17w} set xy {649 530 654 538 659 530} ;# Left eye - $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 + $w.c create line $xy -fill $::C(fg) -width 1.5p -smooth 1 -tag I17 set xy {671 530 666 538 661 530} ;# Right eye - $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 + $w.c create line $xy -fill $::C(fg) -width 1.5p -smooth 1 -tag I17 set xy {655 543 660 551 665 543} ;# Mouth - $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 + $w.c create line $xy -fill $::C(fg) -width 1.5p -smooth 1 -tag I17 } proc Move17 {w {step {}}} { set step [GetStep 17 $step] if {$step == 0} { $w.c delete I17 ;# Delete most of the cat - set xy {655 543 660 535 665 543} ;# Mouth - $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ - set xy [box 654 530 4] ;# Left eye - $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ - set xy [box 666 530 4] ;# Right eye - $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ - - $w.c move I17_ 0 -20 ;# Move face up - set xy {652 528 652 554} ;# Front leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {670 528 670 554} ;# 2nd front leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - - set xy { + set xy [scl {655 543 660 535 665 543}] ;# Mouth + $w.c create line $xy -fill $::C(fg) -width 2.25p -smooth 1 -tag I17_ + set xy [box [scl 654] [scl 530] [scl 4]] ;# Left eye + $w.c create oval $xy -outline $::C(fg) -width 2.25p -fill {} -tag I17_ + set xy [box [scl 666] [scl 530] [scl 4]] ;# Right eye + $w.c create oval $xy -outline $::C(fg) -width 2.25p -fill {} -tag I17_ + + $w.c move I17_ 0 -15p ;# Move face up + set xy [scl {652 528 652 554}] ;# Front leg + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ + set xy [scl {670 528 670 554}] ;# 2nd front leg + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ + + set xy [scl { 675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517 677 512 - } ;# Body + }] ;# Body $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \ - -outline $::C(fg) -width 3 -smooth 1 -tag I17_ - set xy {716 514 716 554} ;# Back leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {694 532 694 554} ;# 2nd back leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {715 514 718 506 719 495 716 488};# Tail - $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ + -outline $::C(fg) -width 2.25p -smooth 1 -tag I17_ + set xy [scl {716 514 716 554}] ;# Back leg + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ + set xy [scl {694 532 694 554}] ;# 2nd back leg + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I17_ + set xy [scl {715 514 718 506 719 495 716 488}] ;# Tail + $w.c create line $xy -fill $::C(fg) -width 2.25p -smooth 1 -tag I17_ $w.c raise I17w ;# Make whiskers visible - $w.c move I17_ -5 0 ;# Move away from wall a bit + $w.c move I17_ -3.75p 0 ;# Move away from wall a bit return 2 } return 0 @@ -1257,31 +1295,31 @@ proc Move17 {w {step {}}} { proc Draw18 {w} { set color $::C(18) set xy {721 506 627 506} ;# Sling hold - $w.c create line $xy -width 4 -fill $::C(fg) -tag I18 + $w.c create line $xy -width 3p -fill $::C(fg) -tag I18 set xy {607 500 628 513} ;# Sling rock $w.c create oval $xy -fill $color -outline {} -tag I18a set xy {526 513 606 507 494 502} ;# Sling band - $w.c create line $xy -fill $::C(fg) -width 4 -tag I18b + $w.c create line $xy -fill $::C(fg) -width 3p -tag I18b set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling - $w.c create line $xy -fill $::C(fg) -width 6 + $w.c create line $xy -fill $::C(fg) -width 4.5p } proc Move18 {w {step {}}} { set step [GetStep 18 $step] - set pos { + set pos [scl { {587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506} {16 506} {-100 -100} - } + }] - set b(0) {490 502 719 507 524 512} ;# Band collapsing - set b(1) { + set b(0) [scl {490 502 719 507 524 512}] ;# Band collapsing + set b(1) [scl { 491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534 532 519 529 499 - } - set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500} - set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501} + }] + set b(2) [scl {491 503 508 563 542 533 551 526 561 539 549 550 530 500}] + set b(3) [scl {491 503 508 563 530 554 541 562 525 568 519 544 530 501}] if {$step >= [llength $pos]} { return 0 @@ -1309,67 +1347,67 @@ proc Draw19 {w} { set xx {249 181 155 118 86 55 22 0} foreach {x1 x2} $xx { $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19 - $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top - $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom + $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 0.75p;# Pipe top + $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 0.75p;# Pipe btm } $w.c raise I11i set xy [box 168 460 16] ;# Bulge by the joint $w.c create oval $xy -fill $color -outline {} - $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p -style arc \ -start 21 -extent 136 - $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p -style arc \ -start -21 -extent -130 set xy {249 447 255 473} ;# First joint 26x6 - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy [box 257 433 34] ;# Bend up - $w.c create arc $xy -outline {} -fill $color -width 1 \ + $w.c create arc $xy -outline {} -fill $color -width 0.75p \ -style pie -start 0 -extent -91 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 0 -extent -90 set xy [box 257 433 20] $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ -style pie -start 0 -extent -92 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 0 -extent -90 set xy [box 257 421 34] ;# Bend left - $w.c create arc $xy -outline {} -fill $color -width 1 \ + $w.c create arc $xy -outline {} -fill $color -width 0.75p \ -style pie -start 1 -extent 91 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 0 -extent 90 set xy [box 257 421 20] - $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ + $w.c create arc $xy -outline {} -fill $::C(bg) -width 0.75p \ -style pie -start 0 -extent 90 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 0 -extent 90 set xy [box 243 421 34] ;# Bend down - $w.c create arc $xy -outline {} -fill $color -width 1 \ + $w.c create arc $xy -outline {} -fill $color -width 0.75p \ -style pie -start 90 -extent 90 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 90 -extent 90 set xy [box 243 421 20] - $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ + $w.c create arc $xy -outline {} -fill $::C(bg) -width 0.75p \ -style pie -start 90 -extent 90 - $w.c create arc $xy -outline $::C(fg) -width 1 \ + $w.c create arc $xy -outline $::C(fg) -width 0.75p \ -style arc -start 90 -extent 90 set xy {270 427 296 433} ;# 2nd joint bottom - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy {270 421 296 427} ;# 2nd joint top - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy {249 382 255 408} ;# Third joint right - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy {243 382 249 408} ;# Third joint left - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy {203 420 229 426} ;# Last joint - $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 0.75p set xy [box 168 460 6] ;# Handle joint $w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a set xy {168 460 168 512} ;# Handle bar - $w.c create line $xy -fill $::C(fg) -width 5 -tag I19b + $w.c create line $xy -fill $::C(fg) -width 3.75p -tag I19b } proc Move19 {w {step {}}} { set step [GetStep 19 $step] @@ -1389,12 +1427,12 @@ proc Draw20 {w} { proc Move20 {w {step {}}} { set step [GetStep 20 $step] - set pos {451 462 473 484 496 504 513 523 532} + set pos [scl {451 462 473 484 496 504 513 523 532}] set freq {20 40 40 40 40 40 40 40 40} - set pos { + set pos [scl { {451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40} {523 40} {532 40 x} - } + }] if {$step >= [llength $pos]} { return 0 } @@ -1412,36 +1450,36 @@ proc H2O {w y f} { set color $::C(20) $w.c delete I20 - Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \ - -smooth 1 - $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + Sine $w [scl 208] [scl 428] [scl 208] $y 4 $f -tag {I20 I20s} \ + -width 2.25p -fill $color -smooth 1 + $w.c create line [$w.c coords I20s] -width 2.25p -fill $color -smooth 1 \ -tag {I20 I20a} - $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + $w.c create line [$w.c coords I20s] -width 2.25p -fill $color -smooth 1 \ -tag {I20 I20b} - $w.c move I20a 8 0 - $w.c move I20b 16 0 + $w.c move I20a 6p 0 + $w.c move I20b 12p 0 } # Bucket proc Draw21 {w} { set color $::C(21) set xy {217 451 244 490} ;# Right handle - $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a + $w.c create line $xy -fill $::C(fg) -width 1.5p -tag I21_a set xy {201 467 182 490} ;# Left handle - $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a + $w.c create line $xy -fill $::C(fg) -width 1.5p -tag I21_a set xy {245 490 237 535} ;# Right side set xy2 {189 535 181 490} ;# Left side $w.c create poly [concat $xy $xy2] -fill $color -outline {} \ -tag {I21 I21f} - $w.c create line $xy -fill $::C(fg) -width 2 -tag I21 - $w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21 + $w.c create line $xy -fill $::C(fg) -width 1.5p -tag I21 + $w.c create line $xy2 -fill $::C(fg) -width 1.5p -tag I21 set xy {182 486 244 498} ;# Top - $w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f} - $w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t} + $w.c create oval $xy -fill $color -outline {} -width 1.5p -tag {I21 I21f} + $w.c create oval $xy -fill {} -outline $::C(fg) -width 1.5p -tag {I21 I21t} set xy {189 532 237 540} ;# Bottom - $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \ + $w.c create oval $xy -fill $color -outline $::C(fg) -width 1.5p \ -tag {I21 I21b} } proc Move21 {w {step {}}} { @@ -1454,10 +1492,10 @@ proc Move21 {w {step {}}} { lassign [$w.c coords I21b] x1 y1 x2 y2 #lassign [$w.c coords I21t] X1 Y1 X2 Y2 - lassign {183 492 243 504} X1 Y1 X2 Y2 + lassign [scl {183 492 243 504}] X1 Y1 X2 Y2 set f [expr {$step / double($numsteps)}] - set y2 [expr {$y2 - 3}] + set y2 [expr {$y2 - [scl 3]}] set xx1 [expr {$x1 + ($X1 - $x1) * $f}] set yy1 [expr {$y1 + ($Y1 - $y1) * $f}] set xx2 [expr {$x2 + ($X2 - $x2) * $f}] @@ -1480,7 +1518,7 @@ proc Draw22 {w} { } proc Move22 {w {step {}}} { set step [GetStep 22 $step] - set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}} + set pos [scl {{213 513} {213 523} {213 543 x} {213 583} {213 593}}] if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)} if {$step >= [llength $pos]} { @@ -1504,31 +1542,31 @@ proc Draw23 {w} { set color3 $::C(23c) set xy {185 623 253 650} ;# Block - $w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a + $w.c create rect $xy -fill black -outline $::C(fg) -width 1.5p -tag I23a set xy {187 592 241 623} ;# Balloon $w.c create oval $xy -outline {} -fill $color -tag I23b - $w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \ + $w.c create arc $xy -outline $::C(fg) -width 2.25p -tag I23b \ -style arc -start 12 -extent 336 set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle $w.c create poly $xy -outline {} -fill $color -tag I23b - $w.c create line $xy -fill $::C(fg) -width 3 -tag I23b + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I23b set xy {285 611 250 603} ;# Dart body - $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d + $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 2.25p -tag I23d set xy {249 596 249 618 264 607 249 596} ;# Dart tail - $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d + $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 2.25p -tag I23d set xy {249 607 268 607} ;# Dart detail - $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I23d set xy {285 607 305 607} ;# Dart needle - $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I23d } proc Move23 {w {step {}}} { set step [GetStep 23 $step] - set pos { + set pos [scl { {277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607} {587 607} {687 607} {787 607} {-100 -100} - } + }] if {$step >= [llength $pos]} { return 0 @@ -1549,20 +1587,20 @@ proc Move23 {w {step {}}} { proc Draw24 {w} { set color $::C(24a) set xy {366 518 462 665} ;# Balloon - $w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24 + $w.c create oval $xy -fill $color -outline $::C(fg) -width 2.25p -tag I24 set xy {414 666 414 729} ;# String - $w.c create line $xy -fill $::C(fg) -width 3 -tag I24 + $w.c create line $xy -fill $::C(fg) -width 2.25p -tag I24 set xy {410 666 404 673 422 673 418 666} ;# Nozzle - $w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24 + $w.c create poly $xy -fill $color -outline $::C(fg) -width 2.25p -tag I24 set xy {387 567 390 549 404 542} ;# Reflections - $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 1.5p -tag I24 set xy {395 568 399 554 413 547} - $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 1.5p -tag I24 set xy {403 570 396 555 381 553} - $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 1.5p -tag I24 set xy {408 564 402 547 386 545} - $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 1.5p -tag I24 } proc Move24 {w {step {}}} { global S @@ -1576,23 +1614,22 @@ proc Move24 {w {step {}}} { if {$step == 0} { $w.c delete I24 ;# Exploding balloon - set xy { + set xy [scl { 347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626 320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508 431 441 431 440 400 502 347 465 347 465 - } + }] $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ - -width 10 -smooth 1 + -width 7.5p -smooth 1 set msg [subst $S(message)] $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \ - -fill $::C(24c) \ - -justify center -font {{Times Roman} 18 bold} + -fill $::C(24c) -justify center -font {Times 18 bold} return 1 } - $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold] - $w.c move I24 0 -60 + $w.c itemconfig I24t -font [list Times [expr {18 + 6*$step}] bold] + $w.c move I24 0 -45p $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25 return 1 } @@ -1619,16 +1656,15 @@ proc Move26 {w {step {}}} { if {$step >= 3} { $w.c delete I24 I26 - $w.c create text 430 755 -anchor s -tag I26 \ - -fill $::C(26) \ - -text "click to continue" -font {{Times Roman} 24 bold} + $w.c create text 318p 489p -anchor s -tag I26 \ + -fill $::C(26) -text "click to continue" -font {Times 24 bold} bind $w.c <Button-1> [list Reset $w] return 4 } $w.c scale I24 {*}[Centroid $w I24] .8 .8 - $w.c move I24 0 60 - $w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold] + $w.c move I24 0 45p + $w.c itemconfig I24t -font [list Times [expr {30 - 6*$step}] bold] return 1 } @@ -1830,6 +1866,25 @@ proc Anchor {w item where} { return [list $x $y] } +proc scl {lst} { + set lst2 {} + foreach elem $lst { + set elem2 {} + set idx 0 + foreach val $elem { + if {$idx < 2} { + set val [expr {round($val * $::tk::scalingPct / 100.0)}] + } + lappend elem2 $val + incr idx + } + + lappend lst2 $elem2 + } + + return $lst2 +} + DoDisplay $w Reset $w Go $w ;# Start everything going diff --git a/library/demos/hscale.tcl b/library/demos/hscale.tcl index 1df144d..26745bc 100644 --- a/library/demos/hscale.tcl +++ b/library/demos/hscale.tcl @@ -22,15 +22,15 @@ pack $w.msg -side top -padx .5c set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -side top -fill x -canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0 +canvas $w.frame.canvas -width 37.5p -height 37.5p -bd 0 -highlightthickness 0 $w.frame.canvas create polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line -scale $w.frame.scale -orient horizontal -length 284 -from 0 -to 250 \ +scale $w.frame.scale -orient horizontal -length 213p -from 0 -to 250 \ -command "setWidth $w.frame.canvas" -tickinterval 50 -pack $w.frame.canvas -side top -expand yes -anchor s -fill x -padx 15 +pack $w.frame.canvas -side top -expand yes -anchor s -fill x -padx 12p pack $w.frame.scale -side bottom -expand yes -anchor n $w.frame.scale set 75 @@ -42,4 +42,8 @@ proc setWidth {w width} { } $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15 $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15 + + set scaleFactor [expr {$tk::scalingPct / 100.0}] + $w scale poly 0 0 $scaleFactor $scaleFactor + $w scale line 0 0 $scaleFactor $scaleFactor } diff --git a/library/demos/icon.tcl b/library/demos/icon.tcl index 224d8f9..c8c1e18 100644 --- a/library/demos/icon.tcl +++ b/library/demos/icon.tcl @@ -30,7 +30,7 @@ image create bitmap flagup \ image create bitmap flagdown \ -file [file join $tk_demoDirectory images flagdown.xbm] \ -maskfile [file join $tk_demoDirectory images flagdown.xbm] -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -side top checkbutton $w.frame.b1 -image flagdown -selectimage flagup \ diff --git a/library/demos/image1.tcl b/library/demos/image1.tcl index 0bd2f49..c174a92 100644 --- a/library/demos/image1.tcl +++ b/library/demos/image1.tcl @@ -25,11 +25,20 @@ pack $btns -side bottom -fill x # Main widget program sets variable tk_demoDirectory catch {image delete image1a} image create photo image1a -file [file join $tk_demoDirectory images earth.gif] -label $w.l1 -image image1a -bd 1 -relief sunken - catch {image delete image1b} image create photo image1b \ -file [file join $tk_demoDirectory images earthris.gif] -label $w.l2 -image image1b -bd 1 -relief sunken + +# Create copies of the images just created, magnified according to the +# display's DPI scaling level. Since the zooom factor must be an integer, +# the copies will only be effectively magnified if $tk::scalingPct >= 200. +set zoomFactor [expr {$tk::scalingPct / 100}] +image create photo image1a2 +image1a2 copy image1a -zoom $zoomFactor +image create photo image1b2 +image1b2 copy image1b -zoom $zoomFactor + +label $w.l1 -image image1a2 -bd 1 -relief sunken +label $w.l2 -image image1b2 -bd 1 -relief sunken pack $w.l1 $w.l2 -side top -padx .5m -pady .5m diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 19cd4f4..5f51a90 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -45,11 +45,11 @@ grid columnconfig $w.frame 0 -weight 1 -minsize 0 # Display a 3x3 rectangular grid. -$c create rect 0c 0c 30c 24c -width 2 -$c create line 0c 8c 30c 8c -width 2 -$c create line 0c 16c 30c 16c -width 2 -$c create line 10c 0c 10c 24c -width 2 -$c create line 20c 0c 20c 24c -width 2 +$c create rect 0c 0c 30c 24c -width 1.5p +$c create line 0c 8c 30c 8c -width 1.5p +$c create line 0c 16c 30c 16c -width 1.5p +$c create line 10c 0c 10c 24c -width 1.5p +$c create line 20c 0c 20c 24c -width 1.5p set font1 {Helvetica 12} set font2 {Helvetica 24 bold} @@ -74,7 +74,7 @@ $c create line 4.67c 1c 4.67c 4c -arrow last -tags item $c create line 6.33c 1c 6.33c 4c -arrow both -tags item $c create line 5c 6c 9c 6c 9c 1c 8c 1c 8c 4.8c 8.8c 4.8c 8.8c 1.2c \ 8.2c 1.2c 8.2c 4.6c 8.6c 4.6c 8.6c 1.4c 8.4c 1.4c 8.4c 4.4c \ - -width 3 -fill $red -tags item + -width 2.25p -fill $red -tags item # Main widget program sets variable tk_demoDirectory $c create line 1c 5c 7c 5c 7c 7c 9c 7c -width .5c \ -stipple @[file join $tk_demoDirectory images gray25.xbm] \ @@ -86,7 +86,7 @@ $c create text 15c .2c -text "Curves (smoothed lines)" -anchor n $c create line 11c 4c 11.5c 1c 13.5c 1c 14c 4c -smooth on \ -fill $blue -tags item $c create line 15.5c 1c 19.5c 1.5c 15.5c 4.5c 19.5c 4c -smooth on \ - -arrow both -width 3 -tags item + -arrow both -width 2.25p -tags item $c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \ 16.5c 4.5c 13.5c 7.5c 12c 6c -smooth on -width 3m -cap round \ -stipple @[file join $tk_demoDirectory images gray25.xbm] \ @@ -95,7 +95,7 @@ $c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \ $c create text 25c .2c -text Polygons -anchor n $c create polygon 21c 1.0c 22.5c 1.75c 24c 1.0c 23.25c 2.5c \ 24c 4.0c 22.5c 3.25c 21c 4.0c 21.75c 2.5c -fill $green \ - -outline {} -width 4 -tags item + -outline {} -width 3p -tags item $c create polygon 25c 4c 25c 4c 25c 1c 26c 1c 27c 4c 28c 1c \ 29c 1c 29c 4c 29c 4c -fill $red -outline {} -smooth on -tags item $c create polygon 22c 4.5c 25c 4.5c 25c 6.75c 28c 6.75c \ @@ -148,8 +148,13 @@ image create photo items.ousterhout \ -file [file join $tk_demoDirectory images ouster.png] image create photo items.ousterhout.active -format "png -alpha 0.5" \ -file [file join $tk_demoDirectory images ouster.png] -$c create image 13c 20c -tags item -image items.ousterhout \ - -activeimage items.ousterhout.active +set zoomFactor [expr {$tk::scalingPct / 100}] +foreach img {items.ousterhout items.ousterhout.active} { + image create photo ${img}2 + ${img}2 copy $img -zoom $zoomFactor +} +$c create image 13c 20c -tags item -image items.ousterhout2 \ + -activeimage items.ousterhout.active2 } $c create bitmap 17c 18.5c -tags item \ -bitmap @[file join $tk_demoDirectory images noletter.xbm] diff --git a/library/demos/ixset b/library/demos/ixset index 85664d9..3457ed7 100644 --- a/library/demos/ixset +++ b/library/demos/ixset @@ -1,6 +1,6 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" ${1+"$@"} +exec wish8.7 "$0" ${1+"$@"} # ixset -- # A nice interface to "xset" to change X server settings @@ -193,7 +193,7 @@ proc createwindows {} { button .buttons.quit -default normal -command quit -text "Quit" pack .buttons.ok .buttons.apply .buttons.cancel .buttons.quit \ - -side left -expand yes -pady 5 + -side left -expand yes -pady 3p bind . <Return> {.buttons.ok flash; .buttons.ok invoke} bind . <Escape> {.buttons.quit flash; .buttons.quit invoke} @@ -221,14 +221,14 @@ proc createwindows {} { labelframe .bell -text "Bell Settings" -padx 1.5m -pady 1.5m scale .bell.vol \ - -from 0 -to 100 -length 200 -tickinterval 20 \ + -from 0 -to 100 -length 150p -tickinterval 20 \ -label "Volume (%)" -orient horizontal frame .bell.val labelentry .bell.val.pit "Pitch (Hz)" 6 {25 20000} labelentry .bell.val.dur "Duration (ms)" 6 {1 10000} - pack .bell.val.pit -side left -padx 5 - pack .bell.val.dur -side right -padx 5 + pack .bell.val.pit -side left -padx 3p + pack .bell.val.dur -side right -padx 3p pack .bell.vol .bell.val -side top -expand yes # @@ -243,12 +243,12 @@ proc createwindows {} { -onvalue "on" -offvalue "off" -variable kbdrep \ -relief flat scale .kbd.val.cli \ - -from 0 -to 100 -length 200 -tickinterval 20 \ + -from 0 -to 100 -length 150p -tickinterval 20 \ -label "Click Volume (%)" -orient horizontal pack .kbd.val.onoff -side left -fill x -expand yes -padx {0 1m} pack .kbd.val.cli -side left -expand yes -fill x -padx {1m 0} - pack .kbd.val -side top -expand yes -pady 2 -fill x + pack .kbd.val -side top -expand yes -pady 1.5p -fill x # # Mouse settings diff --git a/library/demos/knightstour.tcl b/library/demos/knightstour.tcl index 09ceff0..8367477 100644 --- a/library/demos/knightstour.tcl +++ b/library/demos/knightstour.tcl @@ -81,8 +81,7 @@ proc Edgemost {a b} { # Display a square number as a standard chess square notation. proc N {square} { - return [format %c%d [expr {97 + $square % 8}] \ - [expr {$square / 8 + 1}]] + return [format %c%d [expr {97 + $square % 8}] [expr {$square / 8 + 1}]] } # Perform a Knight's move and schedule the next move. @@ -90,7 +89,8 @@ proc MovePiece {dlg last square} { variable visited variable delay variable continuous - $dlg.f.txt insert end "[llength $visited]. [N $last] .. [N $square]\n" {} + set line [format "%2d. %s .. %s" [llength $visited] [N $last] [N $square]] + $dlg.f.txt insert end $line\n $dlg.f.txt see end $dlg.f.c itemconfigure [expr {1+$last}] -state normal -outline black $dlg.f.c itemconfigure [expr {1+$square}] -state normal -outline red @@ -106,14 +106,14 @@ proc MovePiece {dlg last square} { if {$initial == $square} { $dlg.f.txt insert end "Closed tour!" } else { - $dlg.f.txt insert end "Success\n" {} + $dlg.f.txt insert end "Success" if {$continuous} { after [expr {$delay * 2}] [namespace code \ [list Tour $dlg [expr {int(rand() * 64)}]]] } } } else { - $dlg.f.txt insert end "FAILED!\n" {} + $dlg.f.txt insert end "FAILED!" } } } @@ -145,7 +145,8 @@ proc Exit {dlg} { } proc SetDelay {new} { - variable delay [expr {int($new)}] + variable speed [expr {int($new)}] + variable delay [expr {2000 - $speed}] } proc DragStart {w x y} { @@ -171,22 +172,23 @@ proc DragEnd {w x y} { proc CreateGUI {} { catch {destroy .knightstour} set dlg [toplevel .knightstour] - wm title $dlg "Knights tour" + wm title $dlg "Knight's Tour" wm withdraw $dlg set f [ttk::frame $dlg.f] - set c [canvas $f.c -width 240 -height 240] - text $f.txt -width 10 -height 1 \ - -yscrollcommand [list $f.vs set] -font {Arial 8} + set c [canvas $f.c -width 192p -height 192p] + text $f.txt -width 12 -height 1 -padx 3p \ + -yscrollcommand [list $f.vs set] -font TkFixedFont ttk::scrollbar $f.vs -command [list $f.txt yview] - variable delay 600 + variable speed 1400 + variable delay [expr {2000 - $speed}] variable continuous 0 ttk::frame $dlg.tf - ttk::label $dlg.tf.ls -text Speed - ttk::scale $dlg.tf.sc -from 8 -to 2000 -command [list SetDelay] \ - -variable [namespace which -variable delay] ttk::checkbutton $dlg.tf.cc -text Repeat \ -variable [namespace which -variable continuous] + ttk::scale $dlg.tf.sc -from 0 -to 1992 -command [list SetDelay] \ + -variable [namespace which -variable speed] + ttk::label $dlg.tf.ls -text Speed ttk::button $dlg.tf.b1 -text Start -command [list Tour $dlg] ttk::button $dlg.tf.b2 -text Exit -command [list Exit $dlg] set square 0 @@ -197,25 +199,29 @@ proc CreateGUI {} { } else { set fill bisque ; set dfill bisque3 } - set coords [list [expr {$col * 30 + 4}] [expr {$row * 30 + 4}] \ - [expr {$col * 30 + 30}] [expr {$row * 30 + 30}]] + set coords [list [expr {$col * 24 + 3}]p \ + [expr {$row * 24 + 3}]p \ + [expr {$col * 24 + 24}]p \ + [expr {$row * 24 + 24}]p] $c create rectangle $coords -fill $fill -disabledfill $dfill \ - -width 2 -state disabled -outline black + -width 1.5p -state disabled -outline black } } if {[tk windowingsystem] ne "x11"} { - catch {eval font create KnightFont -size -24} + catch {eval font create KnightFont -size 18} $c create text 0 0 -font KnightFont -text "♞" \ -anchor nw -tags knight -fill black -activefill "#600000" } else { # On X11 we cannot reliably tell if the ♞ glyph is available # so just use a polygon set pts { - 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16 + 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16 2 17 4 14 5 15 3 17 5 17 9 14 10 15 5 21 } $c create polygon $pts -tag knight -offset 8 \ -fill black -activefill "#600000" + set scaleFactor [expr {$tk::scalingPct / 100.0}] + $c scale knight 0 0 $scaleFactor $scaleFactor } $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1] $c bind knight <Button-1> [namespace code [list DragStart %W %x %y]] @@ -227,14 +233,14 @@ proc CreateGUI {} { grid columnconfigure $f 1 -weight 1 grid $f - - - - - -sticky news - set things [list $dlg.tf.ls $dlg.tf.sc $dlg.tf.cc $dlg.tf.b1] + set things [list $dlg.tf.cc $dlg.tf.sc $dlg.tf.ls $dlg.tf.b1] if {![info exists ::widgetDemo]} { lappend things $dlg.tf.b2 if {[tk windowingsystem] ne "aqua"} { set things [linsert $things 0 [ttk::sizegrip $dlg.tf.sg]] } } - pack {*}$things -side right + pack {*}$things -side right -padx 3p if {[tk windowingsystem] eq "aqua"} { pack configure {*}$things -padx {4 4} -pady {12 12} pack configure [lindex $things 0] -padx {4 24} diff --git a/library/demos/label.tcl b/library/demos/label.tcl index 13463f7..d2823e1 100644 --- a/library/demos/label.tcl +++ b/library/demos/label.tcl @@ -25,16 +25,23 @@ pack $btns -side bottom -fill x frame $w.left frame $w.right -pack $w.left $w.right -side left -expand yes -padx 10 -pady 10 -fill both +pack $w.left $w.right -side left -expand yes -padx 7.5p -pady 7.5p -fill both label $w.left.l1 -text "First label" label $w.left.l2 -text "Second label, raised" -relief raised label $w.left.l3 -text "Third label, sunken" -relief sunken -pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -pady 2 -anchor w +pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -pady 1.5p -anchor w # Main widget program sets variable tk_demoDirectory image create photo label.ousterhout \ -file [file join $tk_demoDirectory images ouster.png] -label $w.right.picture -borderwidth 2 -relief sunken -image label.ousterhout + +# Create a copy of the image just created, magnified according to the +# display's DPI scaling level. Since the zooom factor must be an integer, +# the copy will only be effectively magnified if $tk::scalingPct >= 200. +image create photo label.ousterhout2 +label.ousterhout2 copy label.ousterhout -zoom [expr {$tk::scalingPct / 100}] + +label $w.right.picture -borderwidth 2 -relief sunken -image label.ousterhout2 label $w.right.caption -text "Tcl/Tk Creator" pack $w.right.picture $w.right.caption -side top diff --git a/library/demos/labelframe.tcl b/library/demos/labelframe.tcl index 21d079f..b40bd54 100644 --- a/library/demos/labelframe.tcl +++ b/library/demos/labelframe.tcl @@ -35,13 +35,13 @@ set w $w.f # A group of radiobuttons in a labelframe -labelframe $w.f -text "Value" -padx 2 -pady 2 +labelframe $w.f -text "Value" -padx 1.5p -pady 1.5p grid $w.f -row 0 -column 0 -pady 2m -padx 2m foreach value {1 2 3 4} { radiobutton $w.f.b$value -text "This is value $value" \ -variable lfdummy -value $value - pack $w.f.b$value -side top -fill x -pady 2 + pack $w.f.b$value -side top -fill x -pady 1.5p } @@ -58,7 +58,7 @@ proc lfEnableButtons {w} { } } -labelframe $w.f2 -pady 2 -padx 2 +labelframe $w.f2 -pady 1.5p -padx 1.5p checkbutton $w.f2.cb -text "Use this option." -variable lfdummy2 \ -command "lfEnableButtons $w.f2" -padx 0 $w.f2 configure -labelwidget $w.f2.cb @@ -67,7 +67,7 @@ grid $w.f2 -row 0 -column 1 -pady 2m -padx 2m set t 0 foreach str {Option1 Option2 Option3} { checkbutton $w.f2.b$t -text $str - pack $w.f2.b$t -side top -fill x -pady 2 + pack $w.f2.b$t -side top -fill x -pady 1.5p incr t } lfEnableButtons $w.f2 diff --git a/library/demos/mclist.tcl b/library/demos/mclist.tcl index f0136be..d91fb5c 100644 --- a/library/demos/mclist.tcl +++ b/library/demos/mclist.tcl @@ -37,13 +37,23 @@ grid $w.hsb -in $w.container -sticky nsew grid column $w.container 0 -weight 1 grid row $w.container 0 -weight 1 -image create photo upArrow -data { - R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAImhI+ - py+1LIsJHiBAh+BgmiEAJQITgW6DgUQIAECH4JN8IPqYuNxUAOw==} -image create photo downArrow -data { - R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAInhI+ - py+1I4ocQ/IgDEYIPgYJICUCE4F+YIBolEoKPEJKZmVJK6ZACADs=} -image create photo noArrow -height 14 -width 14 +image create photo upArrow -format $tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="16" height="4" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <path d="m4 4 4-4 4 4z" fill="#000"/> + </svg> +} +image create photo downArrow -format $tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="16" height="4" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <path d="m4 0 4 4 4-4z" fill="#000"/> + </svg> +} +image create photo noArrow -format $tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="16" height="4" version="1.1" xmlns="http://www.w3.org/2000/svg"> + </svg> +} ## The data we're going to insert set data { @@ -66,12 +76,11 @@ set data { ## Code to insert the data nicely set font [ttk::style lookup Heading -font] +set morePx [expr {[image width noArrow] + round(4 * $tk::scalingPct / 100.0)}] foreach col {country capital currency} name {Country Capital Currency} { $w.tree heading $col -text $name -image noArrow -anchor w \ -command [list SortBy $w.tree $col 0] - $w.tree column $col -width [expr { - [font measure $font $name] + [image width noArrow] + 5 - }] + $w.tree column $col -width [expr {[font measure $font $name] + $morePx}] } set font [ttk::style lookup Treeview -font] foreach {country capital currency} $data { diff --git a/library/demos/menubu.tcl b/library/demos/menubu.tcl index 453b05c..cb52f43 100644 --- a/library/demos/menubu.tcl +++ b/library/demos/menubu.tcl @@ -47,12 +47,12 @@ set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x set body $w.body.center -label $body.label -wraplength 300 -font "Helvetica 14" -justify left -text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette." -pack $body.label -side top -padx 25 -pady 25 +label $body.label -wraplength 225p -font "Helvetica 14" -justify left -text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette." +pack $body.label -side top -padx 18p -pady 18p frame $body.buttons -pack $body.buttons -padx 25 -pady 25 +pack $body.buttons -padx 18p -pady 18p tk_optionMenu $body.buttons.options menubuttonoptions one two three -pack $body.buttons.options -side left -padx 25 -pady 25 +pack $body.buttons.options -side left -padx 18p -pady 18p set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet] if {[tk windowingsystem] eq "aqua"} { set topBorderColor Black @@ -61,21 +61,24 @@ if {[tk windowingsystem] eq "aqua"} { set topBorderColor gray50 set bottomBorderColor gray75 } +set dim [expr {round(16 * $tk::scalingPct / 100.0)}] +set dim1 [expr {$dim - 1}] +set dim2 [expr {$dim - 2}] for {set i 0} {$i <= [$m index last]} {incr i} { set name [$m entrycget $i -label] - image create photo image_$name -height 16 -width 16 - image_$name put $topBorderColor -to 0 0 16 1 - image_$name put $topBorderColor -to 0 1 1 16 - image_$name put $bottomBorderColor -to 0 15 16 16 - image_$name put $bottomBorderColor -to 15 1 16 16 - image_$name put $name -to 1 1 15 15 + image create photo image_$name -height $dim -width $dim + image_$name put $topBorderColor -to 0 0 $dim 1 + image_$name put $topBorderColor -to 0 1 1 $dim + image_$name put $bottomBorderColor -to 0 $dim1 $dim $dim + image_$name put $bottomBorderColor -to $dim1 1 $dim $dim + image_$name put $name -to 1 1 $dim1 $dim1 - image create photo image_${name}_s -height 16 -width 16 - image_${name}_s put Black -to 0 0 16 2 - image_${name}_s put Black -to 0 2 2 16 - image_${name}_s put Black -to 2 14 16 16 - image_${name}_s put Black -to 14 2 16 14 - image_${name}_s put $name -to 2 2 14 14 + image create photo image_${name}_s -height $dim -width $dim + image_${name}_s put Black -to 0 0 $dim 2 + image_${name}_s put Black -to 0 2 2 $dim + image_${name}_s put Black -to 2 $dim2 $dim $dim + image_${name}_s put Black -to $dim2 2 $dim $dim2 + image_${name}_s put $name -to 2 2 $dim2 $dim2 $m entryconfigure $i -image image_$name -selectimage image_${name}_s -hidemargin 1 } @@ -84,4 +87,4 @@ foreach i {Black gray75 gray50 White} { $m entryconfigure $i -columnbreak 1 } -pack $body.buttons.colors -side left -padx 25 -pady 25 +pack $body.buttons.colors -side left -padx 18p -pady 18p diff --git a/library/demos/msgbox.tcl b/library/demos/msgbox.tcl index 2c2cc2d..6f34e16 100644 --- a/library/demos/msgbox.tcl +++ b/library/demos/msgbox.tcl @@ -36,7 +36,7 @@ set msgboxIcon info foreach i {error info question warning} { radiobutton $w.left.b$i -text $i -variable msgboxIcon \ -relief flat -value $i -width 16 -anchor w - pack $w.left.b$i -side top -pady 2 -anchor w -fill x + pack $w.left.b$i -side top -pady 1.5p -anchor w -fill x } label $w.right.label -text "Type" @@ -48,7 +48,7 @@ set msgboxType ok foreach t {abortretryignore ok okcancel retrycancel yesno yesnocancel} { radiobutton $w.right.$t -text $t -variable msgboxType \ -relief flat -value $t -width 16 -anchor w - pack $w.right.$t -side top -pady 2 -anchor w -fill x + pack $w.right.$t -side top -pady 1.5p -anchor w -fill x } proc showMessageBox {w} { diff --git a/library/demos/paned1.tcl b/library/demos/paned1.tcl index 6b21d35..829988a 100644 --- a/library/demos/paned1.tcl +++ b/library/demos/paned1.tcl @@ -24,9 +24,9 @@ set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x panedwindow $w.pane -pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m +pack $w.pane -side top -expand yes -fill both -pady 1.5p -padx 2m label $w.pane.left -text "This is the\nleft side" -fg black -bg yellow label $w.pane.right -text "This is the\nright side" -fg black -bg cyan -$w.pane add $w.pane.left $w.pane.right +$w.pane add $w.pane.left $w.pane.right -stretch always diff --git a/library/demos/paned2.tcl b/library/demos/paned2.tcl index c549249..73af21d 100644 --- a/library/demos/paned2.tcl +++ b/library/demos/paned2.tcl @@ -25,7 +25,7 @@ pack $btns -side bottom -fill x # Create the pane itself panedwindow $w.pane -orient vertical -pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m +pack $w.pane -side top -expand yes -fill both -pady 1.5p -padx 2m # The top window is a listbox with scrollbar set paneList { @@ -71,4 +71,4 @@ grid rowconfigure $f 0 -weight 1 $f.text insert 1.0 "This is just a normal text widget" # Now add our contents to the paned window -$w.pane add $w.pane.top $w.pane.bottom +$w.pane add $w.pane.top $w.pane.bottom -stretch always diff --git a/library/demos/pendulum.tcl b/library/demos/pendulum.tcl index 50760c1..d76a1ec 100644 --- a/library/demos/pendulum.tcl +++ b/library/demos/pendulum.tcl @@ -25,42 +25,46 @@ pack $btns -side bottom -fill x # Create some structural widgets pack [panedwindow $w.p] -fill both -expand 1 -$w.p add [labelframe $w.p.l1 -text "Pendulum Simulation"] -$w.p add [labelframe $w.p.l2 -text "Phase Space"] +$w.p add [labelframe $w.p.l1 -text "Pendulum Simulation"] -stretch always +$w.p add [labelframe $w.p.l2 -text "Phase Space"] -stretch always # Create the canvas containing the graphical representation of the # simulated system. -canvas $w.c -width 320 -height 200 -background white -bd 2 -relief sunken -$w.c create text 5 5 -anchor nw -text "Click to Adjust Bob Start Position" +canvas $w.c -width 240p -height 150p -background white -bd 1.5p -relief sunken +$w.c create text 3p 3p -anchor nw -text "Click to Adjust Bob Start Position" # Coordinates of these items don't matter; they will be set properly below -$w.c create line 0 25 320 25 -tags plate -fill grey50 -width 2 +$w.c create line 0 25 320 25 -tags plate -fill grey50 -width 1.5p $w.c create oval 155 20 165 30 -tags pivot -fill grey50 -outline {} -$w.c create line 1 1 1 1 -tags rod -fill black -width 3 +$w.c create line 1 1 1 1 -tags rod -fill black -width 2.25p $w.c create oval 1 1 2 2 -tags bob -fill yellow -outline black pack $w.c -in $w.p.l1 -fill both -expand true # Create the canvas containing the phase space graph; this consists of # a line that gets gradually paler as it ages, which is an extremely # effective visual trick. -canvas $w.k -width 320 -height 200 -background white -bd 2 -relief sunken -$w.k create line 160 200 160 0 -fill grey75 -arrow last -tags y_axis -$w.k create line 0 100 320 100 -fill grey75 -arrow last -tags x_axis +canvas $w.k -width 240p -height 150p -background white -bd 1.5p -relief sunken +$w.k create line 120p 150p 120p 0 -fill grey75 -arrow last -tags y_axis +$w.k create line 0 75p 240p 75p -fill grey75 -arrow last -tags x_axis for {set i 90} {$i>=0} {incr i -10} { # Coordinates of these items don't matter; they will be set properly below $w.k create line 0 0 1 1 -smooth true -tags graph$i -fill grey$i } -$w.k create text 0 0 -anchor ne -text "θ" -tags label_theta +$w.k create text 0 0 -anchor ne -text "θ" -tags label_theta $w.k create text 0 0 -anchor ne -text "δθ" -tags label_dtheta pack $w.k -in $w.p.l2 -fill both -expand true # Initialize some variables set points {} -set Theta 45.0 -set dTheta 0.0 -set pi 3.1415926535897933 -set length 150 -set home 160 +set Theta 45.0 +set dTheta 0.0 +set pi 3.1415926535897933 +set tkScl [tk scaling] +set length [expr {round(111*$tkScl)}] ;# 111p -> pixels +set xHome [expr {round(120*$tkScl)}] ;# 120p -> pixels +set yHome [expr {round( 18*$tkScl)}] ;# 18p -> pixels +set rBob [expr {round( 12*$tkScl)}] ;# 12p -> pixels +set rPivot [expr {round( 3*$tkScl)}] ;# 3p -> pixels # This procedure makes the pendulum appear at the correct place on the # canvas. If the additional arguments "at $x $y" are passed (the 'at' @@ -69,21 +73,22 @@ set home 160 # length and angle are computed in reverse from the given location # (which is taken to be the centre of the pendulum bob.) proc showPendulum {canvas {at {}} {x {}} {y {}}} { - global Theta dTheta pi length home - if {$at eq "at" && ($x!=$home || $y!=25)} { + global Theta dTheta pi length xHome yHome rBob + + if {$at eq "at" && ($x!=$xHome || $y!=$yHome)} { set dTheta 0.0 - set x2 [expr {$x - $home}] - set y2 [expr {$y - 25}] + set x2 [expr {$x - $xHome}] + set y2 [expr {$y - $yHome}] set length [expr {hypot($x2, $y2)}] set Theta [expr {atan2($x2, $y2) * 180/$pi}] } else { set angle [expr {$Theta * $pi/180}] - set x [expr {$home + $length*sin($angle)}] - set y [expr {25 + $length*cos($angle)}] + set x [expr {$xHome + $length*sin($angle)}] + set y [expr {$yHome + $length*cos($angle)}] } - $canvas coords rod $home 25 $x $y - $canvas coords bob \ - [expr {$x-15}] [expr {$y-15}] [expr {$x+15}] [expr {$y+15}] + $canvas coords rod $xHome $yHome $x $y + $canvas coords bob [expr {$x - $rBob}] [expr {$y - $rBob}] \ + [expr {$x + $rBob}] [expr {$y + $rBob}] } showPendulum $w.c @@ -92,7 +97,9 @@ showPendulum $w.c # respect to time.) proc showPhase {canvas} { global Theta dTheta points psw psh - lappend points [expr {$Theta+$psw}] [expr {-20*$dTheta+$psh}] + set sclFactor [expr {$tk::scalingPct / 100.0}] + + lappend points [expr {$Theta + $psw}] [expr {-20*$sclFactor*$dTheta + $psh}] if {[llength $points] > 100} { set points [lrange $points end-99 end] } @@ -100,6 +107,7 @@ proc showPhase {canvas} { set list [lrange $points end-[expr {$i-1}] end-[expr {$i-12}]] if {[llength $list] >= 4} { $canvas coords graph$i $list + $canvas scale graph$i $psw $psh $sclFactor $sclFactor } } } @@ -125,17 +133,18 @@ bind $w.c <ButtonRelease-1> { set animationCallbacks(pendulum) [after 15 repeat [winfo toplevel %W]] } bind $w.c <Configure> { - %W coords plate 0 25 %w 25 - set home [expr {%w/2}] - %W coords pivot [expr {$home-5}] 20 [expr {$home+5}] 30 + %W coords plate 0 18p %w 18p + set xHome [expr {%w/2}] + %W coords pivot [expr {$xHome - $rPivot}] 15p [expr {$xHome + $rPivot}] 21p } bind $w.k <Configure> { set psh [expr {%h/2}] set psw [expr {%w/2}] - %W coords x_axis 2 $psh [expr {%w-2}] $psh - %W coords y_axis $psw [expr {%h-2}] $psw 2 - %W coords label_dtheta [expr {$psw-4}] 6 - %W coords label_theta [expr {%w-6}] [expr {$psh+4}] + %W coords x_axis 1.5p $psh [expr {%w - round(1.5*$tkScl)}] $psh + %W coords y_axis $psw [expr {%h - round(1.5*$tkScl)}] $psw 1.5p + %W coords label_dtheta [expr {$psw - round(3*$tkScl)}] 4.5p + %W coords label_theta [expr {%w - round(4.5*$tkScl)}] \ + [expr {$psh + round(3*$tkScl)}] } # This procedure is the "business" part of the simulation that does diff --git a/library/demos/plot.tcl b/library/demos/plot.tcl index 453b7a6..5df318b 100644 --- a/library/demos/plot.tcl +++ b/library/demos/plot.tcl @@ -24,33 +24,33 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -canvas $c -relief raised -width 450 -height 300 +canvas $c -relief raised -width 337.5p -height 225p pack $w.c -side top -fill x -set plotFont {Helvetica 18} +set plotFont {Helvetica 16} -$c create line 100 250 400 250 -width 2 -$c create line 100 250 100 50 -width 2 -$c create text 225 20 -text "A Simple Plot" -font $plotFont -fill brown +$c create line 75p 187.5p 300p 187.5p -width 1.5p +$c create line 75p 187.5p 75p 37.5p -width 1.5p +$c create text 168.75p 15p -text "A Simple Plot" -font $plotFont -fill brown for {set i 0} {$i <= 10} {incr i} { - set x [expr {100 + ($i*30)}] - $c create line $x 250 $x 245 -width 2 - $c create text $x 254 -text [expr {10*$i}] -anchor n -font $plotFont + set x [expr {75 + ($i*22.5)}] ;# in points + $c create line ${x}p 187.5p ${x}p 183.75p -width 1.5p + $c create text ${x}p 190.5p -text [expr {10*$i}] -anchor n -font $plotFont } for {set i 0} {$i <= 5} {incr i} { - set y [expr {250 - ($i*40)}] - $c create line 100 $y 105 $y -width 2 - $c create text 96 $y -text [expr {$i*50}].0 -anchor e -font $plotFont + set y [expr {187.5 - ($i*30)}] ;# in points + $c create line 75p ${y}p 78.75p ${y}p -width 1.5p + $c create text 72p ${y}p -text [expr {$i*50}].0 -anchor e -font $plotFont } foreach point { - {12 56} {20 94} {33 98} {32 120} {61 180} {75 160} {98 223} + {9 42} {15 70.5} {24.75 73.5} {24 90} {45.75 135} {56.25 120} {73.5 167.25} } { - set x [expr {100 + (3*[lindex $point 0])}] - set y [expr {250 - (4*[lindex $point 1])/5}] - set item [$c create oval [expr {$x-6}] [expr {$y-6}] \ - [expr {$x+6}] [expr {$y+6}] -width 1 -outline black \ + set x [expr {75 + (2.25*[lindex $point 0])}] ;# in points + set y [expr {187.5 - (3*[lindex $point 1])/5}] ;# in points + set item [$c create oval [expr {$x-4.5}]p [expr {$y-4.5}]p \ + [expr {$x+4.5}]p [expr {$y+4.5}]p -width 0.75p -outline black \ -fill SkyBlue2] $c addtag point withtag $item } diff --git a/library/demos/print.tcl b/library/demos/print.tcl index 00ccd2a..a1ef1f5 100644 --- a/library/demos/print.tcl +++ b/library/demos/print.tcl @@ -47,30 +47,24 @@ agyc3NsFGrXVZMipWVBCzKv4Q0JvCviDsjAwf4ylxBeX0KcwGs81ccgqGS3MBxc3RjDDVAvdBRcf eFy1MFd3bcQHJEQdlddkP5E1Cf9yXfbaV2d9RBAAOw== } -# -# Create a copy of the image just created, magnified according -# to the display's DPI scaling level. Note that the copy will -# only be effectively magnified if $tk::scalingPct >= 200. -# +# Create a copy of the image just created, magnified according to the +# display's DPI scaling level. Since the zooom factor must be an integer, +# the copy will only be effectively magnified if $tk::scalingPct >= 200. image create photo logo2 logo2 copy logo -zoom [expr {$tk::scalingPct / 100}] set c [canvas $w.m.c -bg white] pack $c -fill both -expand yes -fill both -side left -# # For scaling-awareness specify the coordinates of the canvas items in points # rather than pixels. Create the items with a left and top padding of 15 pt. -# $c create rectangle 15p 15p 165p 60p -fill blue -outline black ;# 150p x 45p $c create oval 15p 75p 165p 120p -fill green ;# 150p x 45p set imgId [$c create image 90p 135p -image logo2 -anchor n] - -# + # Compute the scaled y coordinate of the next canvas item's top edge in pixels -# lassign [$c bbox $imgId] x1 y1 x2 y2 ;# x1, y1, x2, y2 are in pixels -incr y2 [expr {int(15 * [tk scaling])}] ;# convert 15 pt to pixels +incr y2 [expr {round(15 * [tk scaling])}] ;# convert 15 pt to pixels $c create text 15p $y2 -anchor nw -font {Helvetica 12} \ -text "A short demo of simple canvas elements." @@ -88,9 +82,9 @@ $t insert end $txt frame $w.f pack [button $w.f.c -text "Print Canvas" -command [list tk print $w.m.c]] \ - -side left -anchor w -padx 4 + -side left -anchor w -padx 3p pack [button $w.f.t -text "Print Text" -command [list tk print $w.m.t]] \ - -side right -anchor e -padx 4 + -side right -anchor e -padx 3p pack $w.f -side bottom -fill x pack $w.m -expand yes -fill both -side top diff --git a/library/demos/puzzle.tcl b/library/demos/puzzle.tcl index f06de5d..30c0562 100644 --- a/library/demos/puzzle.tcl +++ b/library/demos/puzzle.tcl @@ -58,12 +58,12 @@ scrollbar $w.s # slightly larger frame here... if {[tk windowingsystem] eq "aqua"} { - set frameSize 168 + set frameSize 126p } else { - set frameSize 120 + set frameSize 90p } -frame $w.frame -width $frameSize -height $frameSize -borderwidth 2\ +frame $w.frame -width $frameSize -height $frameSize -borderwidth 2 \ -relief sunken -bg [$w.s cget -troughcolor] pack $w.frame -side top -pady 1c -padx 1c destroy $w.s diff --git a/library/demos/radio.tcl b/library/demos/radio.tcl index 5c73703..41f8db2 100644 --- a/library/demos/radio.tcl +++ b/library/demos/radio.tcl @@ -22,13 +22,13 @@ grid $w.msg -row 0 -column 0 -columnspan 3 -sticky nsew set btns [addSeeDismiss $w.buttons $w [list size color align]] grid $btns -row 3 -column 0 -columnspan 3 -sticky ew -labelframe $w.left -pady 2 -text "Point Size" -padx 2 -labelframe $w.mid -pady 2 -text "Color" -padx 2 -labelframe $w.right -pady 2 -text "Alignment" -padx 2 +labelframe $w.left -pady 1.5p -text "Point Size" -padx 1.5p +labelframe $w.mid -pady 1.5p -text "Color" -padx 1.5p +labelframe $w.right -pady 1.5p -text "Alignment" -padx 1.5p button $w.tristate -text Tristate -command "set size multi; set color multi" \ - -pady 2 -padx 2 + -pady 1.5p -padx 1.5p if {[tk windowingsystem] eq "aqua"} { - $w.tristate configure -padx 10 + $w.tristate configure -padx 7.5p } grid $w.left -column 0 -row 1 -pady .5c -padx .5c -rowspan 2 grid $w.mid -column 1 -row 1 -pady .5c -padx .5c -rowspan 2 @@ -38,7 +38,7 @@ grid $w.tristate -column 2 -row 2 -pady .5c -padx .5c foreach i {10 12 14 18 24} { radiobutton $w.left.b$i -text "Point Size $i" -variable size \ -relief flat -value $i -tristatevalue "multi" - pack $w.left.b$i -side top -pady 2 -anchor w -fill x + pack $w.left.b$i -side top -pady 1.5p -anchor w -fill x } foreach c {Red Green Blue Yellow Orange Purple} { @@ -47,7 +47,7 @@ foreach c {Red Green Blue Yellow Orange Purple} { -relief flat -value $lower -anchor w \ -command "$w.mid configure -fg \$color" \ -tristatevalue "multi" - pack $w.mid.$lower -side top -pady 2 -fill x + pack $w.mid.$lower -side top -pady 1.5p -fill x } diff --git a/library/demos/rolodex b/library/demos/rolodex index 8941570..abbf028 100644 --- a/library/demos/rolodex +++ b/library/demos/rolodex @@ -1,6 +1,6 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" ${1+"$@"} +exec wish8.7 "$0" ${1+"$@"} # rolodex -- # This script was written as an entry in Tom LaStrange's rolodex @@ -27,17 +27,17 @@ set names {{} Name: Address: {} {} {Home Phone:} {Work Phone:} Fax:} foreach i {1 2 3 4 5 6 7} { label .frame.label$i -text [lindex $names $i] -anchor e entry .frame.entry$i -width 35 - grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 + grid .frame.label$i .frame.entry$i -sticky ew -pady 1.5p -padx 0.75p } frame .buttons -pack .buttons -side bottom -pady 2 -anchor center +pack .buttons -side bottom -pady 1.5p -anchor center button .buttons.clear -text Clear button .buttons.add -text Add button .buttons.search -text Search button .buttons.delete -text "Delete ..." pack .buttons.clear .buttons.add .buttons.search .buttons.delete \ - -side left -padx 2 + -side left -padx 1.5p #------------------------------------------ # Phase 1: Add menus, dialog boxes diff --git a/library/demos/sayings.tcl b/library/demos/sayings.tcl index aa3479c..3458016 100644 --- a/library/demos/sayings.tcl +++ b/library/demos/sayings.tcl @@ -24,7 +24,7 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -side top -expand yes -fill both -padx 1c diff --git a/library/demos/search.tcl b/library/demos/search.tcl index a1a3d7f..b4beb28 100644 --- a/library/demos/search.tcl +++ b/library/demos/search.tcl @@ -92,7 +92,7 @@ entry $w.file.entry -width 40 -textvariable fileName button $w.file.button -text "Load File" \ -command "textLoadFile $w.text \$fileName" pack $w.file.label $w.file.entry -side left -pack $w.file.button -side left -pady 5 -padx 10 +pack $w.file.button -side left -pady 3p -padx 7.5p bind $w.file.entry <Return> " textLoadFile $w.text \$fileName focus $w.string.entry @@ -105,7 +105,7 @@ entry $w.string.entry -width 40 -textvariable searchString button $w.string.button -text "Highlight" \ -command "textSearch $w.text \$searchString search" pack $w.string.label $w.string.entry -side left -pack $w.string.button -side left -pady 5 -padx 10 +pack $w.string.button -side left -pady 3p -padx 7.5p bind $w.string.entry <Return> "textSearch $w.text \$searchString search" text $w.text -yscrollcommand "$w.scroll set" -setgrid true diff --git a/library/demos/spin.tcl b/library/demos/spin.tcl index 72f3aa4..b08ed16 100644 --- a/library/demos/spin.tcl +++ b/library/demos/spin.tcl @@ -45,7 +45,7 @@ spinbox $w.s3 -values $australianCities -width 10 #entry $w.e1 #entry $w.e2 #entry $w.e3 -pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x +pack $w.s1 $w.s2 $w.s3 -side top -pady 3p -padx 7.5p ;#-fill x #$w.e1 insert 0 "Initial value" #$w.e2 insert end "This entry contains a long value, much too long " diff --git a/library/demos/states.tcl b/library/demos/states.tcl index aeb3d5b..e2acd80 100644 --- a/library/demos/states.tcl +++ b/library/demos/states.tcl @@ -26,7 +26,7 @@ foreach c {Left Center Right} { -relief flat -value $lower -anchor w \ -command "$w.frame.list configure -justify \$just" \ -tristatevalue "multi" - pack $w.justif.$lower -side left -pady 2 -fill x + pack $w.justif.$lower -side left -pady 1.5p -fill x } pack $w.justif diff --git a/library/demos/systray.tcl b/library/demos/systray.tcl index 9ca9745..6954143 100644 --- a/library/demos/systray.tcl +++ b/library/demos/systray.tcl @@ -37,10 +37,10 @@ labelframe $w.f -text "Tray Icon" button $w.f.b0 -text "Create" -command create button $w.f.b1 -text "Modify" -command modify button $w.f.b2 -text "Destroy" -command remove -pack $w.f.b0 $w.f.b1 $w.f.b2 -padx 5 -pady 3 -side left -expand true -fill x +pack $w.f.b0 $w.f.b1 $w.f.b2 -padx 3p -pady 3p -side left -expand true -fill x button $w.b3 -text "Display Notification" -command notify -pack $w.f $w.b3 -fill x -padx 4 -pady 4 +pack $w.f $w.b3 -fill x -padx 3p -pady 3p proc create {} { global trayIconExists diff --git a/library/demos/toolbar.tcl b/library/demos/toolbar.tcl index a53e390..c8248e3 100644 --- a/library/demos/toolbar.tcl +++ b/library/demos/toolbar.tcl @@ -31,7 +31,7 @@ ttk::separator $w.sep ttk::frame $t.tearoff -cursor fleur ttk::separator $t.tearoff.to -orient vertical ttk::separator $t.tearoff.to2 -orient vertical -pack $t.tearoff.to -fill y -expand 1 -padx 4 -side left +pack $t.tearoff.to -fill y -expand 1 -padx 3p -side left pack $t.tearoff.to2 -fill y -expand 1 -side left ttk::frame $t.contents grid $t.tearoff $t.contents -sticky nsew @@ -79,7 +79,7 @@ text $w.txt -width 40 -height 10 interp alias {} doInsert {} $w.txt insert end ;# Make bindings easy to write ## Arrange contents -grid $t.button $t.check $t.menu $t.combo -in $t.contents -padx 2 -pady 4 -sticky ns +grid $t.button $t.check $t.menu $t.combo -in $t.contents -padx 1.5p -pady 3p -sticky ns grid $t -sticky ew grid $w.sep -sticky ew grid $w.msg -sticky ew diff --git a/library/demos/ttkbut.tcl b/library/demos/ttkbut.tcl index f6d94ac..b740ca3 100644 --- a/library/demos/ttkbut.tcl +++ b/library/demos/ttkbut.tcl @@ -29,7 +29,7 @@ ttk::labelframe $w.buttons -text "Buttons" foreach theme [ttk::themes] { ttk::button $w.buttons.$theme -text $theme \ -command [list ttk::setTheme $theme] - pack $w.buttons.$theme -pady 2 + pack $w.buttons.$theme -pady 1.5p } ## Helper procedure for the top checkbutton @@ -65,7 +65,7 @@ ttk::separator $w.checks.sep2 ttk::checkbutton $w.checks.c3 -text Basil -variable basil ttk::checkbutton $w.checks.c4 -text Oregano -variable oregano pack $w.checks.e $w.checks.sep1 $w.checks.c1 $w.checks.c2 $w.checks.sep2 \ - $w.checks.c3 $w.checks.c4 -fill x -pady 2 + $w.checks.c3 $w.checks.c4 -fill x -pady 1.5p ## Set up the radiobutton group ttk::labelframe $w.radios -text "Radiobuttons" @@ -75,10 +75,10 @@ ttk::radiobutton $w.radios.r3 -text "OK" -variable happiness -value ok ttk::radiobutton $w.radios.r4 -text "Poor" -variable happiness -value poor ttk::radiobutton $w.radios.r5 -text "Awful" -variable happiness -value awful pack $w.radios.r1 $w.radios.r2 $w.radios.r3 $w.radios.r4 $w.radios.r5 \ - -fill x -padx 3 -pady 2 + -fill x -padx 3p -pady 1.5p ## Arrange things neatly pack [ttk::frame $w.f] -fill both -expand 1 lower $w.f -grid $w.buttons $w.checks $w.radios -in $w.f -sticky nwe -pady 2 -padx 3 +grid $w.buttons $w.checks $w.radios -in $w.f -sticky nwe -pady 1.5p -padx 3p grid columnconfigure $w.f {0 1 2} -weight 1 -uniform yes diff --git a/library/demos/ttkmenu.tcl b/library/demos/ttkmenu.tcl index 0084dd6..efa6688 100644 --- a/library/demos/ttkmenu.tcl +++ b/library/demos/ttkmenu.tcl @@ -48,6 +48,6 @@ pack [ttk::frame $w.f1] -fill both -expand yes lower $w.f grid anchor $w.f center -grid x $w.m1 x -in $w.f -padx 3 -pady 2 -grid $w.m2 $w.m4 $w.m3 -in $w.f -padx 3 -pady 2 -grid x $w.m5 x -in $w.f -padx 3 -pady 2 +grid x $w.m1 x -in $w.f -padx 2.25p -pady 1.5p +grid $w.m2 $w.m4 $w.m3 -in $w.f -padx 2.25p -pady 1.5p +grid x $w.m5 x -in $w.f -padx 2.25p -pady 1.5p diff --git a/library/demos/ttknote.tcl b/library/demos/ttknote.tcl index 50a9258..5e5551d 100644 --- a/library/demos/ttknote.tcl +++ b/library/demos/ttknote.tcl @@ -25,7 +25,7 @@ set w $w.f ## Make the notebook and set up Ctrl+Tab traversal ttk::notebook $w.note -pack $w.note -fill both -expand 1 -padx 2 -pady 3 +pack $w.note -fill both -expand 1 -padx 1.5p -pady 3p ttk::notebook::enableTraversal $w.note ## Popuplate the first pane @@ -37,9 +37,9 @@ ttk::button $w.note.msg.b -text "Neat!" -underline 0 -command { } bind $w <Alt-n> "focus $w.note.msg.b; $w.note.msg.b invoke" ttk::label $w.note.msg.l -textvariable neat -$w.note add $w.note.msg -text "Description" -underline 0 -padding 2 -grid $w.note.msg.m - -sticky new -pady 2 -grid $w.note.msg.b $w.note.msg.l -pady {2 4} +$w.note add $w.note.msg -text "Description" -underline 0 -padding 1.5p +grid $w.note.msg.m - -sticky new -pady 1.5p +grid $w.note.msg.b $w.note.msg.l -pady {1.5p 3p} grid rowconfigure $w.note.msg 1 -weight 1 grid columnconfigure $w.note.msg {0 1} -weight 1 -uniform 1 @@ -53,5 +53,5 @@ $w.note add $w.note.editor -text "Text Editor" -underline 0 text $w.note.editor.t -width 40 -height 10 -wrap char \ -yscroll "$w.note.editor.s set" ttk::scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview" -pack $w.note.editor.s -side right -fill y -padx {0 2} -pady 2 -pack $w.note.editor.t -fill both -expand 1 -pady 2 -padx {2 0} +pack $w.note.editor.s -side right -fill y -padx {0 1.5p} -pady 1.5p +pack $w.note.editor.t -fill both -expand 1 -pady 1.5p -padx {1.5p 0} diff --git a/library/demos/ttkpane.tcl b/library/demos/ttkpane.tcl index 3f88987..bae8716 100644 --- a/library/demos/ttkpane.tcl +++ b/library/demos/ttkpane.tcl @@ -42,7 +42,7 @@ ttk::button $w.outer.inLeft.top.b -text "Press Me" -command { tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \ -parent .ttkpane -title "Button Pressed" } -pack $w.outer.inLeft.top.b -padx 2 -pady 5 +pack $w.outer.inLeft.top.b -padx 1.5p -pady 3p # Fill the clocks pane set i 0 @@ -97,7 +97,7 @@ if {[tk windowingsystem] ne "aqua"} { # the surrounding border to show through (2 pixels seems to be enough). ttk::frame $w.outer.inRight.bot.f -style TEntry text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0 - pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 2 -padx 2 + pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 1.5p -padx 1.5p ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview" pack $w.sb -side right -fill y -in $w.outer.inRight.bot pack $w.outer.inRight.bot.f -fill both -expand 1 diff --git a/library/demos/ttkprogress.tcl b/library/demos/ttkprogress.tcl index 29ac508..e5d0e22 100644 --- a/library/demos/ttkprogress.tcl +++ b/library/demos/ttkprogress.tcl @@ -38,9 +38,9 @@ ttk::button $w.start -text "Start Progress" -command [list \ ttk::button $w.stop -text "Stop Progress" -command [list \ doBars stop $w.p1 $w.p2] -grid $w.p1 - -pady 5 -padx 10 -grid $w.p2 - -pady 5 -padx 10 -grid $w.start $w.stop -padx 10 -pady 5 +grid $w.p1 - -pady 3p -padx 7.5p +grid $w.p2 - -pady 3p -padx 7.5p +grid $w.start $w.stop -padx 7.5p -pady 3p grid configure $w.start -sticky e grid configure $w.stop -sticky w grid columnconfigure $w all -weight 1 diff --git a/library/demos/ttkscale.tcl b/library/demos/ttkscale.tcl index 1a95416..e08d9b2 100644 --- a/library/demos/ttkscale.tcl +++ b/library/demos/ttkscale.tcl @@ -24,10 +24,10 @@ pack $w.msg -side top -padx .5c set btns [addSeeDismiss $w.buttons [winfo toplevel $w]] pack $btns -side bottom -fill x -ttk::frame $w.frame -borderwidth 10 +ttk::frame $w.frame -borderwidth 7.5p pack $w.frame -side top -fill x -# List of colors from rainbox; "Indigo" is not a standard color +# List of colors from rainbow; "Indigo" is not a standard color set colorList {Red Orange Yellow Green Blue Violet} ttk::label $w.frame.label ttk::scale $w.frame.scale -from 0 -to 5 -command [list apply {{w idx} { diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl index 74f11eb..5268fdf 100644 --- a/library/demos/twind.tcl +++ b/library/demos/twind.tcl @@ -37,7 +37,7 @@ ttk::scrollbar $w.scroll -command "$t yview" pack $w.scroll -side right -fill y panedwindow $w.pane pack $w.pane -expand yes -fill both -$w.pane add $w.f +$w.pane add $w.f -stretch always # Import to raise given creation order above raise $w.f @@ -92,7 +92,7 @@ $t insert end "display the same underlying text. Click this button to " $t window create end \ -create {button %W.peer -text "Make A Peer" -command "textMakePeer %W" \ -cursor top_left_arrow - blend %W.peer} -padx 3 + blend %W.peer} -padx 3p $t insert end " widget. Notice how peer widgets can have different " $t insert end "font settings, and by default contain all the images " $t insert end "of the 'parent', but that the embedded windows, " @@ -105,7 +105,7 @@ $t insert end "peers is for " $t window create end \ -create {button %W.split -text "Split Windows" -command "textSplitWindow %W" \ -cursor top_left_arrow - blend %W.split} -padx 3 + blend %W.split} -padx 3p $t insert end " \n\n" $t insert end "Users of previous versions of Tk will also be interested " @@ -128,13 +128,13 @@ $t insert end "to restore the short string.\n" $t insert end "\nNOTE: these buttons will not appear in peers!\n" "peer_warning" button $t.default -text Default -command "embDefBg $t" \ -cursor top_left_arrow -$t window create end -window $t.default -padx 3 +$t window create end -window $t.default -padx 3p global embToggle set embToggle Short checkbutton $t.toggle -textvariable embToggle -indicatoron 0 \ -variable embToggle -onvalue "A much longer string" \ - -offvalue "Short" -cursor top_left_arrow -pady 5 -padx 2 -$t window create end -window $t.toggle -padx 3 -pady 2 + -offvalue "Short" -cursor top_left_arrow -pady 3p -padx 1.5p +$t window create end -window $t.toggle -padx 3p -pady 1.5p set i 1 foreach color {AntiqueWhite3 Bisque1 Bisque2 Bisque3 Bisque4 SlateBlue3 RoyalBlue1 SteelBlue2 DeepSkyBlue3 LightBlue1 @@ -142,7 +142,7 @@ foreach color {AntiqueWhite3 Bisque1 Bisque2 Bisque3 Bisque4 Yellow1 IndianRed1 IndianRed2 Tan1 Tan4} { button $t.color$i -text $color -cursor top_left_arrow -command \ "changeBg $t $color" - $t window create end -window [blend $t.color$i] -padx 3 -pady 2 + $t window create end -window [blend $t.color$i] -padx 3p -pady 1.5p incr i } $t tag add buttons [blend $t.default] end @@ -175,19 +175,26 @@ $t window create end -window [blend $t.smallP] $t insert end "\n\nFinally, images fit comfortably in text widgets too:" -$t image create end -image \ - [image create photo -file [file join $tk_demoDirectory images ouster.png]] +image create photo img -file [file join $tk_demoDirectory images ouster.png] + +# Create a copy of the image just created, magnified according to the +# display's DPI scaling level. Since the zooom factor must be an integer, +# the copy will only be effectively magnified if $tk::scalingPct >= 200. +image create photo img2 +img2 copy img -zoom [expr {$tk::scalingPct / 100}] + +$t image create end -image img2 proc textWindBigB w { - $w configure -borderwidth 15 + $w configure -borderwidth 12p } proc textWindBigH w { - $w configure -highlightthickness 15 + $w configure -highlightthickness 12p } proc textWindBigP w { - $w configure -padx 15 -pady 15 + $w configure -padx 12p -pady 12p } proc textWindSmallB w { @@ -343,7 +350,7 @@ proc textSplitWindow {textW} { set t [$textW peer create $w.peer \ -yscrollcommand "$w.scroll set"] $t tag configure peer_warning -font boldFont - $w.pane add $t + $w.pane add $t -stretch always } } else { return diff --git a/library/demos/vscale.tcl b/library/demos/vscale.tcl index 2c7ea76..3a041a6 100644 --- a/library/demos/vscale.tcl +++ b/library/demos/vscale.tcl @@ -22,15 +22,15 @@ pack $w.msg -side top -padx .5c set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -frame $w.frame -borderwidth 10 +frame $w.frame -borderwidth 7.5p pack $w.frame -scale $w.frame.scale -orient vertical -length 284 -from 0 -to 250 \ +scale $w.frame.scale -orient vertical -length 213p -from 0 -to 250 \ -command "setHeight $w.frame.canvas" -tickinterval 50 -canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0 +canvas $w.frame.canvas -width 37.5p -height 37.5p -bd 0 -highlightthickness 0 $w.frame.canvas create polygon 0 0 1 1 2 2 -fill SeaGreen3 -tags poly $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line -frame $w.frame.right -borderwidth 15 +frame $w.frame.right -borderwidth 11.25p pack $w.frame.scale -side left -anchor ne pack $w.frame.canvas -side left -anchor nw -fill y $w.frame.scale set 75 @@ -43,4 +43,8 @@ proc setHeight {w height} { } $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 + + set scaleFactor [expr {$tk::scalingPct / 100.0}] + $w scale poly 0 0 $scaleFactor $scaleFactor + $w scale line 0 0 $scaleFactor $scaleFactor } diff --git a/library/demos/widget b/library/demos/widget index f96e778..ad59d81 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -129,12 +129,12 @@ if {[tk windowingsystem] eq "aqua"} { ttk::separator .statusBar.sep pack .statusBar.sep -side top -expand yes -fill x -pady 0 } -pack .statusBar.lab -side left -padx 2 -expand yes -fill both +pack .statusBar.lab -side left -padx 1.5p -expand yes -fill both if {[tk windowingsystem] ne "aqua"} { ttk::sizegrip .statusBar.foo - pack .statusBar.foo -side left -padx 2 + pack .statusBar.foo -side left -padx 1.5p } -pack .statusBar -side bottom -fill x -pady 2 +pack .statusBar -side bottom -fill x -pady 1.5p set textheight 30 catch { @@ -149,7 +149,7 @@ ttk::scrollbar .s -orient vertical -command {.t yview} -takefocus 1 pack .s -in .textFrame -side right -fill y text .t -yscrollcommand {.s set} -wrap word -width 70 -height $textheight \ -font mainFont -setgrid 1 -highlightthickness 0 \ - -padx 4 -pady 2 -takefocus 0 + -padx 3p -pady 1.5p -takefocus 0 pack .t -in .textFrame -expand y -fill both -padx 1 pack .textFrame -expand yes -fill both if {[tk windowingsystem] eq "aqua"} { @@ -431,9 +431,9 @@ focus .s proc addSeeDismiss {w show {vars {}} {extra {}}} { ## See Code / Dismiss buttons ttk::frame $w - ttk::separator $w.sep #ttk::frame $w.sep -height 2 -relief sunken - grid $w.sep -columnspan 4 -row 0 -sticky ew -pady 2 + ttk::separator $w.sep + grid $w.sep -columnspan 4 -row 0 -sticky ew -pady 1.5p ttk::button $w.dismiss -text [mc "Dismiss"] \ -image ::img::delete -compound left \ -command [list destroy [winfo toplevel $w]] @@ -450,7 +450,7 @@ proc addSeeDismiss {w show {vars {}} {extra {}}} { if {$extra ne ""} { set buttons [linsert $buttons 1 [uplevel 1 $extra]] } - grid {*}$buttons -padx 4 -pady 4 + grid {*}$buttons -padx 3p -pady 3p grid columnconfigure $w 0 -weight 1 if {[tk windowingsystem] eq "aqua"} { foreach b [lrange $buttons 1 end] {$b configure -takefocus 0} @@ -493,15 +493,15 @@ proc showVars {w args} { foreach var $args { ttk::label $f.n$var -text "$var:" -anchor w ttk::label $f.v$var -textvariable $var -anchor w - grid $f.n$var $f.v$var -padx 2 -pady 2 -sticky w + grid $f.n$var $f.v$var -padx 1.5p -pady 1.5p -sticky w } ttk::button $b.ok -text [mc "OK"] \ -command [list destroy $w] -default active bind $w <Return> [list $b.ok invoke] bind $w <Escape> [list $b.ok invoke] - grid $f -sticky news -padx 4 - grid $b.ok -sticky e -padx 4 -pady {6 4} + grid $f -sticky news -padx 3p + grid $b.ok -sticky e -padx 3p -pady {4.5p 3p} if {[tk windowingsystem] eq "aqua"} { $b.ok configure -takefocus 0 grid configure $b.ok -pady {10 12} -padx {16 18} @@ -592,7 +592,8 @@ proc showCode w { set text [text $t.text -font fixedFont -height 24 -wrap word \ -xscrollcommand [list $t.xscroll set] \ -yscrollcommand [list $t.yscroll set] \ - -setgrid 1 -highlightthickness 0 -pady 2 -padx 3] + -setgrid 1 -highlightthickness 0 -padx 3p -pady 1.5p \ + -tabstyle wordprocessor] ttk::scrollbar $t.xscroll -command [list $t.text xview] \ -orient horizontal ttk::scrollbar $t.yscroll -command [list $t.text yview] \ @@ -605,7 +606,7 @@ proc showCode w { set btns [ttk::frame $top.btns] ttk::separator $btns.sep - grid $btns.sep -columnspan 4 -row 0 -sticky ew -pady 2 + grid $btns.sep -columnspan 4 -row 0 -sticky ew -pady 1.5p ttk::button $btns.dismiss -text [mc "Dismiss"] \ -default active -command [list destroy $top] \ -image ::img::delete -compound left @@ -616,7 +617,7 @@ proc showCode w { -command [list evalShowCode $text] \ -image ::img::refresh -compound left set buttons [list x $btns.rerun $btns.print $btns.dismiss] - grid {*}$buttons -padx 4 -pady 4 + grid {*}$buttons -padx 3p -pady 3p grid columnconfigure $btns 0 -weight 1 if {[tk windowingsystem] eq "aqua"} { foreach b [lrange $buttons 1 end] {$b configure -takefocus 0} diff --git a/library/demos/windowicons.tcl b/library/demos/windowicons.tcl index 25c8308..0c1e0c0 100644 --- a/library/demos/windowicons.tcl +++ b/library/demos/windowicons.tcl @@ -92,19 +92,17 @@ image create photo icon -data { set ::tk::icons::base_icon(.) icon -# -# Create a copy of the image just created, magnified according -# to the display's DPI scaling level. Note that the copy will -# only be effectively magnified if $tk::scalingPct >= 200. -# +# Create a copy of the image just created, magnified according to the +# display's DPI scaling level. Since the zooom factor must be an integer, +# the copy will only be effectively magnified if $tk::scalingPct >= 200. image create photo icon2 icon2 copy icon -zoom [expr {$tk::scalingPct / 100}] pack [button $w.i -text "Set Window Icon to Globe" -image icon2 \ - -compound top -command {wm iconphoto . icon}] -fill x -padx 4 + -compound top -command {wm iconphoto . icon}] -fill x -padx 3p pack [button $w.b -text "Set Badge to 3" -command {wm iconbadge . 3}] \ - -fill x -padx 4 + -fill x -padx 3p pack [button $w.e -text "Set Badge to 11" -command {wm iconbadge . 11}] \ - -fill x -padx 4 + -fill x -padx 3p pack [button $w.f -text "Reset Badge" -command {wm iconbadge . ""}] \ - -fill x -padx 4 + -fill x -padx 3p diff --git a/library/scaling.tcl b/library/scaling.tcl index a7b6ea6..51180e8 100644 --- a/library/scaling.tcl +++ b/library/scaling.tcl @@ -125,21 +125,14 @@ proc ::tk::ScalingPct {} { # ::tk::ScaleNum -- # -# Scales a nonnegative integer according to the display's current scaling -# percentage. +# Scales an integer according to the display's current scaling percentage. # # Arguments: -# num - A nonnegative integer. +# num - An integer. proc ::tk::ScaleNum num { - set pct [::tk::ScalingPct] - set factor [expr {$num * $pct}] - set result [expr {$factor / 100}] - if {$factor % 100 >= 50} { - incr result - } - - return $result + variable scalingPct + return [expr {round($num * $scalingPct / 100.0)}] } # ::tk::ScanMonitorsFile -- diff --git a/library/tearoff.tcl b/library/tearoff.tcl index 856f8a2..63d4f43 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -140,7 +140,7 @@ proc ::tk::MenuDup {src dst type} { set last [$src index last] if {$last >= 0} { for {set i [$src cget -tearoff]} {$i <= $last} {incr i} { - set cmd [list $dst add [$src type $i]] + set cmd [list $dst add [$src type $i] [$src id $i]] foreach option [$src entryconfigure $i] { lappend cmd [lindex $option 0] [lindex $option 4] } diff --git a/library/text.tcl b/library/text.tcl index eb73db0..e5a4c11 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -457,16 +457,16 @@ bind Text <B2-Motion> { set ::tk::Priv(prevPos) {} bind Text <MouseWheel> { - tk::MouseWheel %W y %D -4.0 pixels + tk::MouseWheel %W y [tk::ScaleNum %D] -4.0 pixels } bind Text <Option-MouseWheel> { - tk::MouseWheel %W y %D -1.2 pixels + tk::MouseWheel %W y [tk::ScaleNum %D] -1.2 pixels } bind Text <Shift-MouseWheel> { - tk::MouseWheel %W x %D -4.0 pixels + tk::MouseWheel %W x [tk::ScaleNum %D] -4.0 pixels } bind Text <Shift-Option-MouseWheel> { - tk::MouseWheel %W x %D -1.2 pixels + tk::MouseWheel %W x [tk::ScaleNum %D] -1.2 pixels } # ::tk::TextClosestGap -- diff --git a/library/tk.tcl b/library/tk.tcl index 7f3ede3..a6dc37c 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -186,10 +186,13 @@ proc ::tk::RestoreFocusGrab {grab focus {destroy destroy}} { } } if {[winfo exists $oldGrab] && [winfo ismapped $oldGrab]} { + # The "grab" command will fail if another application + # already holds the grab on a window with the same name. + # So catch it. See [7447ed20ec] for an example. if {$oldStatus eq "global"} { - grab -global $oldGrab + catch {grab -global $oldGrab} } else { - grab $oldGrab + catch {grab $oldGrab} } } } diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 9c43cf6..b87534d 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -51,7 +51,7 @@ namespace eval ::tk::dialog::file { <?xml version="1.0" encoding="UTF-8"?> <svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="m2 1h8l4 4v11h-12z" fill="#808080"/> - <path d="m3 2h6.5l3.5 3.5v9.5h-10z" fill="#e8e8e8"/> + <path d="m3 2h6.5l3.5 3.5v9.5h-10z" fill="#f0f0f0"/> <path d="m9 1v5h5v-1h-4v-4h-1z" fill="#808080"/> </svg> }] diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index 7b6dd9c..06b8769 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -151,8 +151,8 @@ namespace eval ttk::theme::aqua { -foreground systemTextColor \ -background systemWindowBackgroundColor ttk::style configure Treeview -rowheight 18 \ - -background systemTextBackgroundColor \ - -stripedbackground systemDisabledControlTextColor \ + -background systemControlBackgroundColor \ + -stripedbackground systemControlAlternatingRowColor \ -foreground systemTextColor \ -fieldbackground systemTextBackgroundColor ttk::style map Treeview \ diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 15cf3df..e383a94 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -23,6 +23,7 @@ static Tcl_HashTable systemColors; static size_t numSystemColors; static size_t rgbColorIndex; static size_t controlAccentIndex; +static size_t controlAlternatingRowIndex; static size_t selectedTabTextIndex; static size_t pressedButtonTextIndex; static Bool useFakeAccentColor = NO; @@ -71,6 +72,7 @@ void initColorTable() if ([colorName isEqualToString:@"controlAccentColor"]) { useFakeAccentColor = YES; } else if ( ![colorName isEqualToString:@"selectedTabTextColor"] + && ![colorName isEqualToString:@"controlAlternatingRowColor"] && ![colorName isEqualToString:@"pressedButtonTextColor"]) { /* Uncomment to print all unsupported colors: */ /* printf("Unsupported color %s\n", colorName.UTF8String); */ @@ -148,6 +150,9 @@ void initColorTable() hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); controlAccentIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "ControlAlternatingRowColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + controlAlternatingRowIndex = entry->index; hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); selectedTabTextIndex = entry->index; @@ -332,6 +337,15 @@ GetRGBA( color = [[NSColor colorForControlTint: [NSColor currentControlTint]] colorUsingColorSpace:sRGB]; #endif + } else if (entry->index == controlAlternatingRowIndex) { + /* + * Color which is now called alternatingContentBackgroundColor on 10.14. + * Taken from NSColor.controlAlternatingRowBackgroundColors (which was + * replaced by NSColor.alternatingContentBackgroundColors on 10.14). + */ + color = [[NSColor colorWithCatalogName:@"System" + colorName:@"controlAlternatingRowColor"] + colorUsingColorSpace:sRGB]; } else if (entry->index == selectedTabTextIndex) { if (OSVersion > 100600 && OSVersion < 110000) { color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; @@ -382,6 +396,11 @@ SetCGColorComponents( { CGFloat rgba[4] = {0, 0, 0, 1}; + if (entry->type == HIBrush) { + OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); + return err == noErr; + } + /* * This function is called before our autorelease pool is set up, * so it needs its own pool. @@ -389,11 +408,6 @@ SetCGColorComponents( NSAutoreleasePool *pool = [NSAutoreleasePool new]; - if (entry->type == HIBrush) { - OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); - [pool drain]; - return err == noErr; - } GetRGBA(entry, pixel, rgba); *c = CGColorCreate(sRGB.CGColorSpace, rgba); [pool drain]; diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 77f1558..ab5a3b4 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -187,6 +187,8 @@ static SystemColorDatum systemColorData[] = { {"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL }, {"SeparatorColor", semantic, 0, "grayColor", 0, NULL }, {"UnemphasizedSelectedTextBackgroundColor", semantic, 0, "grayColor", 0, NULL }, +/* This color is available since 10.3, so the fallback is unused */ +{"ControlAlternatingRowColor", semantic, 0, "grayColor" , 0, NULL }, {NULL, rgbColor, 0, NULL, 0, NULL } }; diff --git a/macosx/tkMacOSXConfig.c b/macosx/tkMacOSXConfig.c index cf90577..a85c6a9 100644 --- a/macosx/tkMacOSXConfig.c +++ b/macosx/tkMacOSXConfig.c @@ -23,7 +23,7 @@ * return a string representation of the option. * * Results: - * Returns a Tk_Uid that is the string identifier that identifies + * Returns a Tcl_Obj* with the string identifier that identifies * this option. Returns NULL if there are no system defaults * that match this pair. * diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f0f5d1d..dea8588 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1152,6 +1152,8 @@ TkScrollWindow( srcRgn = HIShapeCreateWithRect(&srcRect); dstRgn = HIShapeCreateWithRect(&dstRect); ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn); + CFRelease(dstRgn); + CFRelease(srcRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; } @@ -1162,10 +1164,6 @@ TkScrollWindow( TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); - /* - * Mutable shapes are not reference counted, and must be released. - */ - CFRelease(dmgRgn); return result; } diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 3494818..443b34f 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -437,6 +437,10 @@ TkMacOSXGetHostToplevel( { TkWindow *contWinPtr, *topWinPtr; + if (!(winPtr && winPtr->privatePtr)) { + return NULL; + } + topWinPtr = winPtr->privatePtr->toplevel->winPtr; if (!Tk_IsEmbedded(topWinPtr)) { return winPtr->privatePtr->toplevel; @@ -447,9 +451,6 @@ TkMacOSXGetHostToplevel( * TODO: Here we should handle out of process embedding. */ - if (!contWinPtr) { - return NULL; - } return TkMacOSXGetHostToplevel(contWinPtr); } @@ -666,7 +667,7 @@ Tk_GetOtherWindow( * process... */ - if (!(((TkWindow *)tkwin)->flags & TK_BOTH_HALVES)) { + if (!(tkwin && (((TkWindow*)tkwin)->flags & TK_BOTH_HALVES))) { return NULL; } diff --git a/macosx/tkMacOSXFileTypes.c b/macosx/tkMacOSXFileTypes.c index 847cb98..9a91c25 100644 --- a/macosx/tkMacOSXFileTypes.c +++ b/macosx/tkMacOSXFileTypes.c @@ -25,9 +25,6 @@ without generating deprecation warnings. #include "tkMacOSXPrivate.h" #include "tkMacOSXFileTypes.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 -#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> -#endif #define CHARS_TO_OSTYPE(string) (OSType) string[0] << 24 | \ (OSType) string[1] << 16 | \ diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index a540946..0a27cbf 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -121,7 +121,7 @@ static void ReleaseData( ckfree(info); } -CGImageRef +static CGImageRef TkMacOSXCreateCGImageWithXImage( XImage *image, uint32_t alphaInfo) diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 145e7c0..f47ed6e 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -160,9 +160,6 @@ typedef struct TkWindowPrivate MacDrawable; */ MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); -MODULE_SCOPE void TkpRetainRegion(Region r); -MODULE_SCOPE void TkpReleaseRegion(Region r); -MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable); /* diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 3c71a16..d282427 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -670,9 +670,12 @@ setXEventPoint( local.x -= contPtr->wmInfoPtr->xInParent; local.y -= contPtr->wmInfoPtr->yInParent; } else { - TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr; - local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x); - local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y); + MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr); + if (topMacWin) { + TkWindow *topPtr = topMacWin->winPtr; + local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x); + local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y); + } } } else if (winPtr->wmInfoPtr != NULL) { local.x -= winPtr->wmInfoPtr->xInParent; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 1f76eea..f91dc89 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -761,9 +761,10 @@ TkpConfigureMenuEntry( [menuItem setImage:image]; if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr && mePtr->labelLength) { - title = [[TKNSString alloc] + title = [[[TKNSString alloc] initWithTclUtfBytes:Tcl_GetString(mePtr->labelPtr) - length:mePtr->labelLength]; + length:mePtr->labelLength] + autorelease]; if ([title hasSuffix:@"..."]) { title = [NSString stringWithFormat:@"%@%C", [title substringToIndex:[title length] - 3], 0x2026]; @@ -813,6 +814,7 @@ TkpConfigureMenuEntry( attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes]; [menuItem setAttributedTitle:attributedTitle]; + [attributedTitle release]; [menuItem setEnabled:(mePtr->state != ENTRY_DISABLED)]; [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY || mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 68f9344..d4ed5ad 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -319,6 +319,7 @@ enum { if ([NSApp tkDragTarget]) { TkWindow *dragPtr = (TkWindow *) [NSApp tkDragTarget]; TKWindow *dragWindow = nil; + MacDrawable *topMacWin; if (dragPtr) { dragWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable( dragPtr->window); @@ -328,7 +329,10 @@ enum { target = NULL; return theEvent; } - winPtr = TkMacOSXGetHostToplevel((TkWindow *) [NSApp tkDragTarget])->winPtr; + topMacWin = TkMacOSXGetHostToplevel(dragPtr); + if (topMacWin) { + winPtr = topMacWin->winPtr; + } } else if (eventType == NSScrollWheel) { winPtr = scrollTarget; } else { @@ -368,9 +372,12 @@ enum { local.x -= contPtr->wmInfoPtr->xInParent; local.y -= contPtr->wmInfoPtr->yInParent; } else { - TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr; - local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x); - local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y); + MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr); + if (topMacWin) { + TkWindow* topPtr = topMacWin->winPtr; + local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x); + local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y); + } } } else { diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 8d8966e..f2b7c16 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -524,7 +524,6 @@ TkMacOSXEventsCheckProc( int flags) { NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; - int eventsFound = 0; /* * runloopMode will be nil if we are in a Tcl event loop. @@ -570,7 +569,6 @@ TkMacOSXEventsCheckProc( NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent]; if (processedEvent) { - eventsFound++; #ifdef TK_MAC_DEBUG_EVENTS TKLog(@" event: %@", currentEvent); diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index 5cc004b..e015485 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -25,7 +25,6 @@ #include <math.h> #include <string.h> #include <limits.h> -#include <stdlib.h> #include <sys/types.h> #include <sys/file.h> #ifdef HAVE_SYS_SELECT_H @@ -39,9 +38,7 @@ # include <sys/time.h> #endif #include <time.h> -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#endif +#include <inttypes.h> #include <unistd.h> #if defined(__GNUC__) && !defined(__cplusplus) # pragma GCC diagnostic ignored "-Wc++-compat" diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 0537c7b..25af2fd 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -29,7 +29,7 @@ static int totalRegionRetainCount = 0; * * XCreateRegion -- * - * Implements the equivelent of the X window function XCreateRegion. See + * Implements the equivalent of the X window function XCreateRegion. See * Xwindow documentation for more details. * * Results: @@ -55,7 +55,7 @@ XCreateRegion(void) * * XDestroyRegion -- * - * Implements the equivelent of the X window function XDestroyRegion. See + * Implements the equivalent of the X window function XDestroyRegion. See * Xwindow documentation for more details. * * Results: @@ -139,7 +139,7 @@ XSubtractRegion( * * XUnionRectWithRegion -- * - * Implements the equivelent of the X window function + * Implements the equivalent of the X window function * XUnionRectWithRegion. See Xwindow documentation for more details. * * Results: @@ -201,7 +201,7 @@ TkMacOSXIsEmptyRegion( * * XRectInRegion -- * - * Implements the equivelent of the X window function XRectInRegion. See + * Implements the equivalent of the X window function XRectInRegion. See * Xwindow documentation for more details. * * Results: @@ -237,7 +237,7 @@ XRectInRegion( * * XClipBox -- * - * Implements the equivelent of the X window function XClipBox. See + * Implements the equivalent of the X window function XClipBox. See * Xwindow documentation for more details. * * Results: @@ -478,6 +478,30 @@ XOffsetRegion( /* *---------------------------------------------------------------------- * + * TkpCopyRegion -- + * + * Makes the destination region a copy of the source region. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkpCopyRegion( + TkRegion dst, + TkRegion src) +{ + ChkErr(HIShapeSetWithShape, (HIMutableShapeRef)dst, (HIShapeRef)src); +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXHIShapeCreateEmpty, TkMacOSXHIShapeCreateMutableWithRect, * TkMacOSXHIShapeSetWithShape, * TkMacOSHIShapeDifferenceWithRect, TkMacOSHIShapeUnionWithRect, diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index ae2b149..6d3bfc7 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -87,6 +87,7 @@ XDestroyWindow( if (macWin->toplevel->referenceCount == 0) { ckfree(macWin->toplevel); } + macWin->winPtr->privatePtr = NULL; ckfree(macWin); return Success; } @@ -103,6 +104,7 @@ XDestroyWindow( macWin->drawRgn = NULL; } macWin->view = nil; + macWin->winPtr->privatePtr = NULL; /* * Delay deletion of a toplevel data structure until all children have @@ -1481,11 +1483,7 @@ Tk_FreePixmap( if (data) { ckfree(data); } - /* - * Releasing the context here causes a crash in the 8.7 regression - * tests, but not in 8.6. - * CFRelease(macPix->context); - */ + CFRelease(macPix->context); } ckfree(macPix); } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 345d66e..8b72faf 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1114,7 +1114,6 @@ TkWmDeadWindow( { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; TKWindow *deadNSWindow; - TkWindow *dragTarget = [NSApp tkDragTarget]; if (wmPtr == NULL) { return; @@ -1194,9 +1193,6 @@ TkWmDeadWindow( * state which is recorded in the NSApplication object. */ - if (dragTarget && winPtr == TkMacOSXGetHostToplevel(dragTarget)->winPtr) { - [NSApp setTkDragTarget:nil]; - } if (winPtr == [NSApp tkPointerWindow]) { NSWindow *w; NSPoint mouse = [NSEvent mouseLocation]; diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 9d7f1f7..76b8b33 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -187,7 +187,6 @@ TkpOpenDisplay( const char *display_name) { Display *display; - NSAutoreleasePool *pool = [NSAutoreleasePool new]; if (gMacDisplay != NULL) { if (strcmp(DisplayString(gMacDisplay->display), display_name) == 0) { @@ -197,6 +196,8 @@ TkpOpenDisplay( } } + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + display = XkbOpenDisplay((char *)display_name, NULL, NULL, NULL, NULL, NULL); /* @@ -879,30 +880,6 @@ XForceScreenSaver( return Success; } -int -XSetClipRectangles( - Display *d, - GC gc, - int clip_x_origin, - int clip_y_origin, - XRectangle* rectangles, - int n, - TCL_UNUSED(int)) -{ - TkRegion clipRgn = TkCreateRegion(); - - while (n--) { - XRectangle rect = *rectangles; - - rect.x += clip_x_origin; - rect.y += clip_y_origin; - TkUnionRectWithRegion(&rect, clipRgn, clipRgn); - rectangles++; - } - TkSetRegion(d, gc, clipRgn); - TkDestroyRegion(clipRgn); - return 1; -} /* *---------------------------------------------------------------------- * diff --git a/tests/button.test b/tests/button.test index b15614f..260cd95 100644 --- a/tests/button.test +++ b/tests/button.test @@ -2910,7 +2910,7 @@ test button-3.23 {ButtonWidgetCmd procedure, "deselect" option} -body { test button-3.24 {ButtonWidgetCmd procedure, "deselect" option} -body { checkbutton .c -variable checkvar -onvalue 1 -offvalue 0 set checkvar 1 - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace .c deselect } -cleanup { destroy .c @@ -2919,7 +2919,7 @@ test button-3.24 {ButtonWidgetCmd procedure, "deselect" option} -body { test button-3.25 {ButtonWidgetCmd procedure, "deselect" option} -body { checkbutton .c -variable checkvar -onvalue 1 -offvalue 0 set checkvar 1 - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace catch {.c deselect} list $errorInfo $checkvar } -cleanup { @@ -2932,7 +2932,7 @@ test button-3.25 {ButtonWidgetCmd procedure, "deselect" option} -body { test button-3.26 {ButtonWidgetCmd procedure, "deselect" option} -body { radiobutton .r -variable radiovar -value red set radiovar red - trace variable radiovar w bogusTrace + trace add variable radiovar write bogusTrace .r deselect } -cleanup { destroy .r @@ -2941,7 +2941,7 @@ test button-3.26 {ButtonWidgetCmd procedure, "deselect" option} -body { test button-3.27 {ButtonWidgetCmd procedure, "deselect" option} -body { radiobutton .r -variable radiovar -value red set radiovar red - trace variable radiovar w bogusTrace + trace add variable radiovar write bogusTrace catch {.r deselect} list $errorInfo $radiovar } -cleanup { @@ -3070,7 +3070,7 @@ test button-3.43 {ButtonWidgetCmd procedure, "select" option} -body { test button-3.44 {ButtonWidgetCmd procedure, "select" option} -body { radiobutton .r -variable radiovar -value red set radiovar yellow - trace variable radiovar w bogusTrace + trace add variable radiovar write bogusTrace .r select } -cleanup { destroy .r @@ -3079,7 +3079,7 @@ test button-3.44 {ButtonWidgetCmd procedure, "select" option} -body { test button-3.45 {ButtonWidgetCmd procedure, "select" option} -body { radiobutton .r -variable radiovar -value red set radiovar yellow - trace variable radiovar w bogusTrace + trace add variable radiovar write bogusTrace catch {.r select} list $errorInfo $radiovar } -cleanup { @@ -3131,7 +3131,7 @@ test button-3.50 {ButtonWidgetCmd procedure, "toggle" option} -body { test button-3.51 {ButtonWidgetCmd procedure, "toggle" option} -body { checkbutton .c -variable checkvar -onvalue xyz -offvalue abc set checkvar xyz - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace .c toggle } -cleanup { destroy .c @@ -3140,7 +3140,7 @@ test button-3.51 {ButtonWidgetCmd procedure, "toggle" option} -body { test button-3.52 {ButtonWidgetCmd procedure, "toggle" option} -body { checkbutton .c -variable checkvar -onvalue xyz -offvalue abc set checkvar xyz - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace catch {.c toggle} list $errorInfo $checkvar } -cleanup { @@ -3153,7 +3153,7 @@ test button-3.52 {ButtonWidgetCmd procedure, "toggle" option} -body { test button-3.53 {ButtonWidgetCmd procedure, "toggle" option} -body { checkbutton .c -variable checkvar -onvalue xyz -offvalue abc set checkvar abc - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace .c toggle } -cleanup { trace vdelete checkvar w bogusTrace @@ -3162,7 +3162,7 @@ test button-3.53 {ButtonWidgetCmd procedure, "toggle" option} -body { test button-3.54 {ButtonWidgetCmd procedure, "toggle" option} -body { checkbutton .c -variable checkvar -onvalue xyz -offvalue abc set checkvar abc - trace variable checkvar w bogusTrace + trace add variable checkvar write bogusTrace catch {.c toggle} list $errorInfo $checkvar } -cleanup { @@ -3304,7 +3304,7 @@ test button-5.9 {ConfigureButton - setting selected state from variable} -setup test button-5.10 {ConfigureButton - error in setting variable} -setup { unset -nocomplain x } -body { - trace variable x w bogusTrace + trace add variable x write bogusTrace radiobutton .r -variable x } -cleanup { destroy .r @@ -3337,7 +3337,7 @@ test button-5.13 {ConfigureButton - using current value of variable} -body { test button-5.14 {ConfigureButton - variable handling} -setup { unset -nocomplain x } -body { - trace variable x w bogusTrace + trace add variable x write bogusTrace radiobutton .r -text foo -textvariable x } -cleanup { trace vdelete x w bogusTrace @@ -3346,7 +3346,7 @@ test button-5.14 {ConfigureButton - variable handling} -setup { test button-5.15 {ConfigureButton - variable handling} -setup { unset -nocomplain x } -body { - trace variable x w bogusTrace + trace add variable x write bogusTrace catch {radiobutton .r -text foo -textvariable x} return $x } -cleanup { @@ -3538,7 +3538,7 @@ test button-8.2 {TkInvokeButton procedure} -setup { set x 0 } -body { checkbutton .c -variable x - trace variable x w bogusTrace + trace add variable x write bogusTrace .c invoke } -cleanup { destroy .c @@ -3548,7 +3548,7 @@ test button-8.3 {TkInvokeButton procedure} -setup { set x 0 } -body { checkbutton .c -variable x - trace variable x w bogusTrace + trace add variable x write bogusTrace catch {.c invoke} return $x } -cleanup { @@ -3559,7 +3559,7 @@ test button-8.4 {TkInvokeButton procedure} -setup { set x 1 } -body { checkbutton .c -variable x - trace variable x w bogusTrace + trace add variable x write bogusTrace .c invoke } -cleanup { destroy .c @@ -3569,7 +3569,7 @@ test button-8.5 {TkInvokeButton procedure} -setup { set x 1 } -body { checkbutton .c -variable x - trace variable x w bogusTrace + trace add variable x write bogusTrace catch {.c invoke} return $x } -cleanup { @@ -3593,7 +3593,7 @@ test button-8.6 {TkInvokeButton procedure} -setup { test button-8.7 {TkInvokeButton procedure} -body { radiobutton .r -variable x -value red set x green - trace variable x w bogusTrace + trace add variable x write bogusTrace .r invoke } -cleanup { destroy .r @@ -3602,7 +3602,7 @@ test button-8.7 {TkInvokeButton procedure} -body { test button-8.8 {TkInvokeButton procedure} -body { radiobutton .r -variable x -value red set x green - trace variable x w bogusTrace + trace add variable x write bogusTrace catch {.r invoke} list $errorInfo $x } -cleanup { diff --git a/tests/entry.test b/tests/entry.test index e5fdbb6..54ae174 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -17,7 +17,7 @@ proc scroll args { global scrollInfo set scrollInfo $args } -# For trace variable +# For trace add variable proc override args { global x set x 12345 @@ -1626,7 +1626,7 @@ test entry-5.4 {ConfigureEntry procedure, -textvariable} -setup { unset -nocomplain x entry .e } -body { - trace variable x w override + trace add variable x write override .e insert 0 "Some text" .e configure -textvariable x list $x [.e get] @@ -2353,7 +2353,7 @@ test entry-8.18 {DeleteChars procedure} -setup { test entry-9.1 {EntryValueChanged procedure} -setup { unset -nocomplain x } -body { - trace variable x w override + trace add variable x write override entry .e -textvariable x -width 0 .e insert 0 foo list $x [.e get] @@ -3551,7 +3551,7 @@ test entry-22.2 {lost namespaced textvar} -body { test entry-23.1 {error in trace proc attached to the textvariable} -setup { destroy .e } -body { - trace variable myvar w traceit + trace add variable myvar write traceit proc traceit args {error "Intentional error here!"} entry .e -textvariable myvar catch {.e insert end mystring} result1 diff --git a/tests/event.test b/tests/event.test index 4cbd529..1eb23c0 100644 --- a/tests/event.test +++ b/tests/event.test @@ -887,7 +887,7 @@ test event-9.2 {enter toplevel window by destroying a toplevel - bug b1d115fa60} _pause 200 toplevel .top2 -width 200 -height 200 wm geometry .top2 +[expr {[winfo rootx .top1]+50}]+[expr {[winfo rooty .top1]+50}] - update idletasks + _pause 200 wm deiconify .top2 update idletasks raise .top2 diff --git a/tests/listbox.test b/tests/listbox.test index 6b32297..e9d06e1 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2830,12 +2830,12 @@ test listbox-23.2 {ConfigureListboxItem} -setup { .l itemconfigure 0 } -cleanup { destroy .l -} -result [list {-background background Background {} {}} \ +} -result [list {-background {} {} {} {}} \ {-bg -background} \ {-fg -foreground} \ - {-foreground foreground Foreground {} {}} \ - {-selectbackground selectBackground Foreground {} {}} \ - {-selectforeground selectForeground Background {} {}}] + {-foreground {} {} {} {}} \ + {-selectbackground {} {} {} {}} \ + {-selectforeground {} {} {} {}}] test listbox-23.3 {ConfigureListboxItem, itemco shortcut} -setup { destroy .l } -body { @@ -2844,7 +2844,7 @@ test listbox-23.3 {ConfigureListboxItem, itemco shortcut} -setup { .l itemco 0 -background } -cleanup { destroy .l -} -result {-background background Background {} {}} +} -result {-background {} {} {} {}} test listbox-23.4 {ConfigureListboxItem, wrong num args} -setup { destroy .l } -body { diff --git a/tests/menu.test b/tests/menu.test index ed40e07..2ab4aaa 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -1310,7 +1310,7 @@ test menu-3.10 {MenuWidgetCmd procedure, "add" option} -setup { .m1 add separator } -cleanup { destroy .m1 -} -result {} +} -result {e001} test menu-3.11 {MenuWidgetCmd procedure, "cget" option} -setup { destroy .m1 } -body { @@ -1819,7 +1819,7 @@ test menu-3.67 {MenuWidgetCmd procedure, bad option} -setup { .m1 foo } -cleanup { destroy .m1 -} -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition} +} -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, id, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition} test menu-3.68 {MenuWidgetCmd procedure, fix for bug#508988} -setup { deleteWindows } -body { @@ -2647,7 +2647,7 @@ test menu-11.15 {ConfigureMenuEntry} -setup { list [.m1 add checkbutton -label "test"] [.m1 entrycget 1 -variable] } -cleanup { deleteWindows -} -result {{} test} +} -result {e001 test} test menu-11.16 {ConfigureMenuEntry} -setup { deleteWindows } -body { @@ -2655,7 +2655,7 @@ test menu-11.16 {ConfigureMenuEntry} -setup { .m1 add radiobutton -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-11.17 {ConfigureMenuEntry} -setup { deleteWindows } -body { @@ -2818,7 +2818,7 @@ test menu-13.4 {TkGetMenuIndex} -setup { list [.m1 insert last command -label "test2"] [.m1 entrycget last -label] } -cleanup { deleteWindows -} -result {{} test2} +} -result {e002 test2} test menu-13.5 {TkGetMenuIndex} -setup { deleteWindows } -body { @@ -2827,7 +2827,7 @@ test menu-13.5 {TkGetMenuIndex} -setup { list [.m1 insert end command -label "test2"] [.m1 entrycget end -label] } -cleanup { deleteWindows -} -result {{} test2} +} -result {e002 test2} test menu-13.6 {TkGetMenuIndex} -setup { deleteWindows } -body { @@ -2924,7 +2924,7 @@ test menu-15.1 {MenuNewEntry} -setup { .m1 add command -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-15.2 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2934,7 +2934,7 @@ test menu-15.2 {MenuNewEntry} -setup { .m1 insert 2 command -label "test2" } -cleanup { deleteWindows -} -result {} +} -result {e003} test menu-15.3 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2943,7 +2943,7 @@ test menu-15.3 {MenuNewEntry} -setup { .m1 add command -label "test2" } -cleanup { deleteWindows -} -result {} +} -result {e002} test menu-15.4 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2951,7 +2951,7 @@ test menu-15.4 {MenuNewEntry} -setup { .m1 add command -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.1 {MenuAddOrInsert} -setup { deleteWindows @@ -2967,7 +2967,7 @@ test menu-16.2 {MenuAddOrInsert} -setup { .m1 insert test command -label "foo" } -cleanup { deleteWindows -} -result {} +} -result {e002} test menu-16.3 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -2991,7 +2991,7 @@ test menu-16.5 {MenuAddOrInsert} -setup { .m1 add cascade } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.6 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -2999,7 +2999,7 @@ test menu-16.6 {MenuAddOrInsert} -setup { .m1 add checkbutton } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.7 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3007,7 +3007,7 @@ test menu-16.7 {MenuAddOrInsert} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.8 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3015,7 +3015,7 @@ test menu-16.8 {MenuAddOrInsert} -setup { .m1 add radiobutton } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.9 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3023,7 +3023,7 @@ test menu-16.9 {MenuAddOrInsert} -setup { .m1 add separator } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.10 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3037,7 +3037,7 @@ test menu-16.11 {MenuAddOrInsert} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.12 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3047,7 +3047,7 @@ test menu-16.12 {MenuAddOrInsert} -setup { list [.m2 add command -label "test"] [.m1 entrycget 1 -label] [.m3 entrycget 1 -label] } -cleanup { deleteWindows -} -result {{} test test} +} -result {e001 test test} test menu-16.13 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3057,12 +3057,12 @@ test menu-16.13 {MenuAddOrInsert} -setup { list [.m3 add command -label "test"] [.m1 entrycget 1 -label] [.m2 entrycget 1 -label] } -cleanup { deleteWindows -} -result {{} test test} +} -result {e001 test test} test menu-16.14 {MenuAddOrInsert} -setup { deleteWindows } -body { menu .m1 - .m1 add command -blork + .m1 add command -blork fish } -returnCodes error -result {unknown option "-blork"} test menu-16.15 {MenuAddOrInsert} -setup { deleteWindows @@ -3074,7 +3074,7 @@ test menu-16.15 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.16 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3084,7 +3084,7 @@ test menu-16.16 {MenuAddOrInsert} -setup { list [.m2 add cascade -menu .m1] [$tearoff unpost] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.17 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3095,7 +3095,7 @@ test menu-16.17 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.18 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3106,7 +3106,7 @@ test menu-16.18 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e002 {}} test menu-16.19 {MenuAddOrInsert - Insert a cascade deep into the tree} -setup { deleteWindows } -body { @@ -3135,7 +3135,7 @@ test menu-17.1 {MenuVarProc} -setup { [unset foo] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} # menu-17.2 - Don't know how to generate the flags in the if test menu-17.2 {MenuVarProc} -setup { deleteWindows @@ -3146,7 +3146,7 @@ test menu-17.2 {MenuVarProc} -setup { [set foo ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-17.3 {MenuVarProc} -setup { deleteWindows } -body { @@ -3157,7 +3157,7 @@ test menu-17.3 {MenuVarProc} -setup { [set foo "hello"] [unset foo] } -cleanup { deleteWindows -} -result {{} hello {}} +} -result {e001 hello {}} test menu-17.4 {MenuVarProc} -setup { deleteWindows } -body { @@ -3167,7 +3167,7 @@ test menu-17.4 {MenuVarProc} -setup { [set foo "hello"] [unset foo] } -cleanup { deleteWindows -} -result {{} hello {}} +} -result {e001 hello {}} test menu-17.5 {MenuVarProc} -setup { deleteWindows } -body { @@ -3177,7 +3177,7 @@ test menu-17.5 {MenuVarProc} -setup { [set foo "goodbye"] [unset foo] } -cleanup { deleteWindows -} -result {{} goodbye {}} +} -result {e001 goodbye {}} test menu-17.6 {MenuVarProc [5d991b822e]} -setup { deleteWindows } -body { @@ -3487,8 +3487,52 @@ test menu-22.5 {GetIndexFromCoords: mapped wide window} -setup { } -cleanup { deleteWindows } -result 0 +test menu-22.6 {GetIndexFromCoords: syntax error in @x,y indices} -setup { + deleteWindows +} -body { + menu .m + .m add command -label "First entry" + .m add command -label "Second entry" + .m add command -label "Last entry" + .m index @4bogus +} -cleanup { + deleteWindows +} -returnCodes error -result {bad menu entry index "@4bogus"} +test menu-22.7 {GetIndexFromCoords: syntax error in @x,y indices} -setup { + deleteWindows +} -body { + menu .m + .m add command -label "First entry" + .m add command -label "Second entry" + .m add command -label "Last entry" + .m index @10,4bogus +} -cleanup { + deleteWindows +} -returnCodes error -result {bad menu entry index "@10,4bogus"} +test menu-22.8 {GetIndexFromCoords: syntax error in @x,y indices} -setup { + deleteWindows +} -body { + menu .m + .m add command -label "First entry" + .m add command -label "Second entry" + .m add command -label "Last entry" + .m index @10,bogus +} -cleanup { + deleteWindows +} -returnCodes error -result {bad menu entry index "@10,bogus"} +test menu-22.9 {GetIndexFromCoords: index type pecedence} -setup { + deleteWindows +} -body { + menu .m -tearoff 0 + .m add command -label "First entry" + .m add command -label "@42nd street" + .m add command -label "Last entry" + .m index "@42nd*" ; # shall be interpreted as a pattern, not as @42 +} -cleanup { + deleteWindows +} -result {1} -test menu-22.6 {tk_popup on separator entry} -setup { +test menu-22.10 {tk_popup on separator entry} -setup { deleteWindows } -constraints {x11} -body { menu .m1 @@ -4056,6 +4100,157 @@ test menu-39.1 {empty -type - bug be8f5b9fc2} -setup { destroy .m } -returnCodes error -result {ambiguous type "": must be menubar, normal, or tearoff} +test menu-40.1 {identifiers - auto generated} -setup { + destroy .m +} -body { + menu .m + list [.m add command -label 1] [.m add command -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e001 e002 e003} +test menu-40.2 {identifiers - out of sequence} -setup { + destroy .m +} -body { + menu .m -tearoff 0 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m index e001] [.m index e002] [.m index e003] +} -cleanup { + destroy .m +} -result {1 0 2} +test menu-40.3 {identifiers - out of sequence with tearoff} -setup { + destroy .m +} -body { + menu .m -tearoff 1 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m index e001] [.m index e002] [.m index e003] +} -cleanup { + destroy .m +} -result {2 1 3} +test menu-40.4 {identifiers - entry id} -setup { + destroy .m +} -body { + menu .m -tearoff 1 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m id 0] [.m id 1] [.m id 2] [.m id 3] +} -cleanup { + destroy .m +} -result {{} e002 e001 e003} +test menu-40.5 {identifiers - assigned} -setup { + destroy .m +} -body { + menu .m + list [.m add command cmd1 -label 1] [.m insert 0 command cmd2 -label 2] [.m add command cmd3 -label 3] +} -cleanup { + destroy .m +} -result {cmd1 cmd2 cmd3} +test menu-40.6 {identifiers - mixed} -setup { + destroy .m +} -body { + menu .m + list [.m add command -label 1] [.m insert 0 command cmd2 -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e001 cmd2 e002} +test menu-40.7 {identifiers - conflict} -setup { + destroy .m +} -body { + menu .m + list [.m add command e002 -label 1] [.m add command -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e002 e001 e003} +test menu-40.8 {identifiers - clone of complete menu} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 add command -label 1 + .m1 insert 0 command -label 2 + .m1 add command cmd3 -label 3 + .m1 clone .m2 + list [.m2 index e001] [.m2 index e002] [.m2 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.9 {identifiers - modify after cloning} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 clone .m2 + .m1 add command -label 1 + .m1 insert 0 command -label 2 + .m1 add command cmd3 -label 3 + list [.m2 index e001] [.m2 index e002] [.m2 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.10 {identifiers - modify clone} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 clone .m2 + .m2 add command -label 1 + .m2 insert 0 command -label 2 + .m2 add command cmd3 -label 3 + list [.m1 index e001] [.m1 index e002] [.m1 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.11 {identifiers - entrycget by id} -setup { + destroy .m +} -body { + menu .m + .m add command -label 1 + .m add command -label 2 + .m add command cmd3 -label 3 + list [.m entrycget e001 -label] [.m entrycget e002 -label] [.m entrycget cmd3 -label] +} -cleanup { + destroy .m +} -result {1 2 3} +test menu-40.12 {identifiers - delete by id} -setup { + destroy .m +} -body { + menu .m + .m add command -label 1 + .m add command -label 2 + .m add command -label 3 + .m add command -label 4 + .m add command -label 5 + .m add command -label 6 + .m add command -label 7 + .m add command cmd8 -label 8 + .m add command cmd9 -label 9 + .m delete e003 cmd8 + list [.m id 0] [.m id 1] [.m id 2] +} -cleanup { + destroy .m +} -result {e001 e002 cmd9} +test menu-40.13 {identifiers - duplicate} -setup { + destroy .m +} -body { + menu .m + .m add command foo -label 1 + .m add command bar -label 2 + .m add command foo -label 3 +} -cleanup { + destroy .m +} -returnCodes error -result {entry "foo" already exists} +test menu-40.14 {identifiers - reserved word} -setup { + destroy .m +} -body { + menu .m -tearoff 0 + .m add command last -label 1 + .m add command -label 2 + .m add command -label 3 + .m index last +} -cleanup { + destroy .m +} -result {2} # cleanup imageFinish diff --git a/tests/menuDraw.test b/tests/menuDraw.test index ff639c1..2cafc31 100644 --- a/tests/menuDraw.test +++ b/tests/menuDraw.test @@ -27,7 +27,7 @@ test menuDraw-2.1 {TkInitializeMenuEntryDrawingFields} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-3.1 {TkMenuFreeDrawOptions} -setup { @@ -86,7 +86,7 @@ test menuDraw-6.1 {TkMenuConfigureEntryDrawOptions - no tkfont specified} -setup .m1 add command -label "foo" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.2 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { deleteWindows } -body { @@ -94,7 +94,7 @@ test menuDraw-6.2 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { .m1 add command -label "foo" -font "Courier 12" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.3 {TkMenuConfigureEntryDrawOptions - active state - wrong entry} -setup { deleteWindows } -body { @@ -140,7 +140,7 @@ test menuDraw-6.7 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { .m1 add command -label "foo" -font "Courier 12" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.8 {TkMenuConfigureEntryDrawOptions - border specified} -setup { deleteWindows } -body { @@ -148,7 +148,7 @@ test menuDraw-6.8 {TkMenuConfigureEntryDrawOptions - border specified} -setup { .m1 add command -label "foo" -background "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.9 {TkMenuConfigureEntryDrawOptions - foreground specified} -setup { deleteWindows } -body { @@ -156,7 +156,7 @@ test menuDraw-6.9 {TkMenuConfigureEntryDrawOptions - foreground specified} -setu .m1 add command -label "foo" -foreground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.10 {TkMenuConfigureEntryDrawOptions - activeBorder specified} -setup { deleteWindows } -body { @@ -164,7 +164,7 @@ test menuDraw-6.10 {TkMenuConfigureEntryDrawOptions - activeBorder specified} -s .m1 add command -label "foo" -activebackground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.11 {TkMenuConfigureEntryDrawOptions - activeforeground specified} -setup { deleteWindows } -body { @@ -172,7 +172,7 @@ test menuDraw-6.11 {TkMenuConfigureEntryDrawOptions - activeforeground specified .m1 add command -label "foo" -activeforeground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.12 {TkMenuConfigureEntryDrawOptions - selectcolor specified} -setup { deleteWindows } -body { @@ -180,7 +180,7 @@ test menuDraw-6.12 {TkMenuConfigureEntryDrawOptions - selectcolor specified} -se .m1 add radiobutton -label "foo" -selectcolor "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.13 {TkMenuConfigureEntryDrawOptions - textGC disposal} -setup { deleteWindows } -body { diff --git a/tests/scale.test b/tests/scale.test index 8a459e8..53e7f72 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -1091,7 +1091,7 @@ test scale-13.6 {SetScaleValue procedure} -body { .s set 50 update - trace variable y w varTrace + trace add variable y write varTrace set traceInfo empty set x untouched .s set 50 diff --git a/tests/spinbox.test b/tests/spinbox.test index 409b1f8..e04da0d 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -17,7 +17,7 @@ proc scroll args { global scrollInfo set scrollInfo $args } -# For trace variable +# For trace add variable proc override args { global x set x 12345 @@ -1952,7 +1952,7 @@ test spinbox-5.4 {ConfigureSpinbox procedure, -textvariable} -setup { unset -nocomplain x spinbox .e } -body { - trace variable x w override + trace add variable x write override .e insert 0 "Some text" .e configure -textvariable x list $x [.e get] @@ -2643,7 +2643,7 @@ test spinbox-8.18 {DeleteChars procedure} -setup { test spinbox-9.1 {SpinboxValueChanged procedure} -setup { unset -nocomplain x } -body { - trace variable x w override + trace add variable x write override spinbox .e -textvariable x -width 0 .e insert 0 foo list $x [.e get] @@ -3865,7 +3865,7 @@ test spinbox-23.1 {selection present while disabled, bug 637828} -body { test spinbox-24.1 {error in trace proc attached to the textvariable} -setup { destroy .s } -body { - trace variable myvar w traceit + trace add variable myvar write traceit proc traceit args {error "Intentional error here!"} spinbox .s -textvariable myvar -from 1 -to 10 catch {.s set mystring} result1 diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index 61d28cf..fd4cddf 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -246,7 +246,7 @@ test entry-6.1 {Update linked variable in write trace} -body { } catch {destroy .e} set x "" - trace variable x w override + trace add variable x write override ttk::entry .e -textvariable x .e insert 0 "Some text" set result [list $x [.e get]] diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index 7cb174c..9f9e5f9 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -74,7 +74,7 @@ test progressbar-2.4 "step with linked variable" -body { } -result 6.0 test progressbar-2.5 "error in write trace" -body { - trace variable PB w { error "YIPES!" ;# } + trace add variable PB write { error "YIPES!" ;# } .pb step set PB ;# NOTREACHED } -cleanup { unset PB } -returnCodes error -match glob -result "*YIPES!" diff --git a/tests/ttk/scale.test b/tests/ttk/scale.test index 0851cb6..08143e2 100644 --- a/tests/ttk/scale.test +++ b/tests/ttk/scale.test @@ -4,7 +4,7 @@ namespace import -force tcltest::* loadTestedCommands test scale-1.0 "Self-destruction" -body { - trace variable v w { destroy .s ;# } + trace add variable v write { destroy .s ;# } ttk::scale .s -variable v pack .s ; update .s set 1 ; update diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index da25c1c..5f2cc84 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -1369,6 +1369,13 @@ test treeview-bc602049ab "treeview with custom background does not change size w image delete tvbg } -result {1} +test treeview-6ee162c3d9 "style configure Treeview -rowheight 0" -setup { + tvSetupWithItems +} -body { + ttk::style configure Treeview -rowheight 0 ; # shall not crash + update +} -result {} + test treeview-column0-leak "Test for leak in tree column" -setup { destroy .ttt set heading [string range _Hej_ 1 3] diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index c417132..0f80487 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -29,7 +29,7 @@ proc selfdestruct {w args} { } test ttk-6.1 "Self-destructing checkbutton" -body { pack [ttk::checkbutton .sd -text "Self-destruction" -variable ::sd] - trace variable sd w [list selfdestruct .sd] + trace add variable sd write [list selfdestruct .sd] update .sd invoke } -returnCodes error @@ -41,7 +41,7 @@ test ttk-6.2 "Checkbutton self-destructed" -body { test ttk-6.4 "Destroy widget in configure" -setup { set OUCH ouch - trace variable OUCH r { kill.b } + trace add variable OUCH read { kill.b } proc kill.b {args} { destroy .b } } -cleanup { unset OUCH @@ -111,7 +111,7 @@ test ttk-construction-failure-1 "Excercise construction failure path" -setup { test ttk-construction-failure-2 "Destroy widget in constructor" -setup { set OUCH ouch - trace variable OUCH r { kill.b } + trace add variable OUCH read { kill.b } proc kill.b {args} { destroy .b } } -cleanup { unset OUCH @@ -600,7 +600,7 @@ test ttk-15.1 {Bug 3062331} -setup { } -body { set Y {} ttk::button .b -textvariable Y - trace variable Y u "destroy .b; #" + trace add variable Y unset "destroy .b; #" unset Y } -cleanup { destroy .b diff --git a/tests/winMenu.test b/tests/winMenu.test index 3b7dbec..21768ef 100644 --- a/tests/winMenu.test +++ b/tests/winMenu.test @@ -93,91 +93,91 @@ test winMenu-6.2 {GetEntryText} -constraints { menu .m1 image create test image1 list [catch {.m1 add command -image image1} msg] $msg [destroy .m1] [image delete image1] -} -result {0 {} {} {}} +} -result {0 e001 {} {}} test winMenu-6.3 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -bitmap questhead} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.4 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.5 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.6 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.7 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.8 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.9 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo" -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.10 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it" -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.11 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.12 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.13 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo" -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.14 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it" -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.15 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.16 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-7.1 {ReconfigureWindowsMenu - system menu item removal} -constraints { win @@ -427,7 +427,7 @@ test winMenu-9.1 {TkpMenuNewEntry} -constraints win -setup { } -body { menu .m1 list [catch {.m1 add command} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-10.1 {TkwinMenuProc} -constraints { @@ -859,7 +859,7 @@ test winMenu-28.1 {TkpConfigureMenuEntry - update pending} -constraints { menu .m1 -tearoff 0 .m1 add command -label Hello list [catch {.m1 add command -label Two} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e002 {}} test winMenu-28.2 {TkpConfigureMenuEntry - update not pending} -constraints { win } -setup { @@ -869,7 +869,7 @@ test winMenu-28.2 {TkpConfigureMenuEntry - update not pending} -constraints { .m1 add command -label One update idletasks list [catch {.m1 add command -label Two} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e002 {}} test winMenu-29.1 {TkpDrawMenuEntry - gc for active and not strict motif} -constraints { diff --git a/unix/Makefile.in b/unix/Makefile.in index af6fe23..6de5c29 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -678,7 +678,7 @@ objs: ${OBJS} ${WISH_EXE}: $(TK_STUB_LIB_FILE) $(WISH_OBJS) $(TK_LIB_FILE) @APP_RSRC_FILE@ - ${CC} ${CFLAGS} ${LDFLAGS} $(WISH_OBJS) @TK_BUILD_LIB_SPEC@ \ + ${CC} ${CFLAGS} $(WISH_OBJS) @TK_BUILD_LIB_SPEC@ ${LDFLAGS} \ $(WISH_LIBS) $(CC_SEARCH_FLAGS) -o ${WISH_EXE} @if test "${ZIPFS_BUILD}" = "2" ; then \ if test "x$(MACHER)" = "x" ; then \ @@ -700,7 +700,7 @@ $(TKTEST_EXE): $(TKTEST_OBJS) $(TK_LIB_FILE) $(MAKE) tktest-real LIB_RUNTIME_DIR="`pwd`:$(TCL_BIN_DIR)" tktest-real: ${TK_STUB_LIB_FILE} - ${CC} ${CFLAGS} ${LDFLAGS} $(TKTEST_OBJS) @TK_BUILD_LIB_SPEC@ $(WISH_LIBS) \ + ${CC} ${CFLAGS} $(TKTEST_OBJS) @TK_BUILD_LIB_SPEC@ ${LDFLAGS} $(WISH_LIBS) \ ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} $(CC_SEARCH_FLAGS) -o $(TKTEST_EXE) # # FIXME: This xttest rule seems to be broken in a number of ways. It should @@ -708,8 +708,8 @@ tktest-real: ${TK_STUB_LIB_FILE} # # tktest, and it is not clear where this test.o object file comes from. # # xttest: test.o tkTest.o tkSquare.o $(TK_LIB_FILE) ${TK_STUB_LIB_FILE} -# ${CC} ${CFLAGS} ${LDFLAGS} test.o tkTest.o tkSquare.o \ -# @TK_BUILD_LIB_SPEC@ ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} \ +# ${CC} ${CFLAGS} test.o tkTest.o tkSquare.o \ +# @TK_BUILD_LIB_SPEC@ ${LDFLAGS} ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} \ # $(WISH_LIBS) $(LD_SEARCH_FLAGS) -lXt -o xttest # Note, in the target below TCL_LIBRARY needs to be set or else @@ -1745,7 +1745,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC $(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \ $(DISTDIR)/macosx/Tk.xcodeproj $(INSTALL_DATA_DIR) $(DISTDIR)/compat - $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TOP_DIR)/compat/stdint.h \ + $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms \ $(TOP_DIR)/compat/stdbool.h $(DISTDIR)/compat $(INSTALL_DATA_DIR) $(DISTDIR)/xlib $(DIST_INSTALL_DATA) $(XLIB_DIR)/*.[ch] $(DISTDIR)/xlib diff --git a/unix/configure b/unix/configure index 79659ce..e06493c 100755 --- a/unix/configure +++ b/unix/configure @@ -7593,7 +7593,7 @@ printf "%s\n" "#define MAC_OSX_TK 1" >>confdefs.h LIBS="$LIBS -framework UserNotifications" fi if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then - LIBS="$LIBS -framework UniformTypeIdentifiers" + LIBS="$LIBS -weak_framework UniformTypeIdentifiers" fi EXTRA_CC_SWITCHES='-x objective-c' TK_WINDOWINGSYSTEM=AQUA diff --git a/unix/configure.ac b/unix/configure.ac index f803a35..1540bc5 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -289,7 +289,7 @@ if test $tk_aqua = yes; then LIBS="$LIBS -framework UserNotifications" fi if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then - LIBS="$LIBS -framework UniformTypeIdentifiers" + LIBS="$LIBS -weak_framework UniformTypeIdentifiers" fi EXTRA_CC_SWITCHES='-x objective-c' TK_WINDOWINGSYSTEM=AQUA diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 3717893..fc0cfb7 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1932,8 +1932,6 @@ dnl # preprocessing tests use only CPPFLAGS. # Results: # # Defines some of the following vars: -# NO_DIRENT_H -# NO_STDLIB_H # NO_STRING_H # NO_SYS_WAIT_H # NO_DLFCN_H @@ -1943,38 +1941,6 @@ dnl # preprocessing tests use only CPPFLAGS. #-------------------------------------------------------------------- AC_DEFUN([SC_MISSING_POSIX_HEADERS], [ - AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> -#include <dirent.h>]], [[ -#ifndef _POSIX_SOURCE -# ifdef __Lynx__ - /* - * Generate compilation error to make the test fail: Lynx headers - * are only valid if really in the POSIX environment. - */ - - missing_procedure(); -# endif -#endif -DIR *d; -struct dirent *entryPtr; -char *p; -d = opendir("foobar"); -entryPtr = readdir(d); -p = entryPtr->d_name; -closedir(d); -]])],[tcl_cv_dirent_h=yes],[tcl_cv_dirent_h=no])]) - - if test $tcl_cv_dirent_h = no; then - AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?]) - fi - - AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0) - AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0) - AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0) - if test $tcl_ok = 0; then - AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?]) - fi AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0) AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0) @@ -2388,7 +2354,7 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [ case 1: case (sizeof(long long)==sizeof(long)): ; }]])],[tcl_cv_type_64bit="long long"],[])]) if test "${tcl_cv_type_64bit}" = none ; then - AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, ['long' and 'long long' have the same size]) + AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Do 'long' and 'long long' have the same size (64-bit)?]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) diff --git a/unix/tkUnix.c b/unix/tkUnix.c index 553d8fc..0477b1c 100644 --- a/unix/tkUnix.c +++ b/unix/tkUnix.c @@ -121,6 +121,32 @@ Tk_UpdatePointer( /* *---------------------------------------------------------------------- * + * TkpCopyRegion -- + * + * Makes the destination region a copy of the source region. + * Currently unused on X11. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkpCopyRegion( + TkRegion dst, + TkRegion src) +{ + /* XUnionRegion() in Xlib is optimized to detect copying */ + XUnionRegion(src, src, dst); +} + +/* + *---------------------------------------------------------------------- + * * TkpBuildRegionFromAlphaData -- * * Set up a rectangle of the given region based on the supplied alpha diff --git a/unix/tkUnixConfig.c b/unix/tkUnixConfig.c index 3a5aed1..055c004 100644 --- a/unix/tkUnixConfig.c +++ b/unix/tkUnixConfig.c @@ -22,7 +22,7 @@ * string representation of the option. * * Results: - * Returns a Tk_Uid that is the string identifier that identifies this + * Returns a Tcl_Obj* with the string identifier that identifies this * option. Returns NULL if there are no system defaults that match this * pair. * diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index bb43adb..1cd2e8a 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -26,7 +26,6 @@ #include <math.h> #include <string.h> #include <limits.h> -#include <stdlib.h> #include <sys/types.h> #include <sys/file.h> #ifdef HAVE_SYS_SELECT_H @@ -40,9 +39,7 @@ # include <sys/time.h> #endif #include <time.h> -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#endif +#include <inttypes.h> #include <unistd.h> #if defined(__GNUC__) && !defined(__cplusplus) # pragma GCC diagnostic ignored "-Wc++-compat" diff --git a/win/configure b/win/configure index bb26d7a..3c6b333 100755 --- a/win/configure +++ b/win/configure @@ -4910,53 +4910,6 @@ printf "%s\n" "#define EXCEPTION_DISPOSITION int" >>confdefs.h fi - # Check to see if winnt.h defines CHAR, SHORT, and LONG - # even if VOID has already been #defined. The win32api - # used by mingw and cygwin is known to do this. - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5 -printf %s "checking for winnt.h that ignores VOID define... " >&6; } -if test ${tcl_cv_winnt_ignore_void+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #define VOID void - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #undef WIN32_LEAN_AND_MEAN - -int -main (void) -{ - - CHAR c; - SHORT s; - LONG l; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - tcl_cv_winnt_ignore_void=yes -else $as_nop - tcl_cv_winnt_ignore_void=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5 -printf "%s\n" "$tcl_cv_winnt_ignore_void" >&6; } - if test "$tcl_cv_winnt_ignore_void" = "yes" ; then - -printf "%s\n" "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h - - fi - ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" if test "x$ac_cv_header_stdbool_h" = xyes then : @@ -5200,31 +5153,6 @@ fi #-------------------------------------------------------------------- -# Windows XP theme engine header for Ttk -#-------------------------------------------------------------------- - -ac_fn_c_check_header_compile "$LINENO" "uxtheme.h" "ac_cv_header_uxtheme_h" "#include <windows.h> -" -if test "x$ac_cv_header_uxtheme_h" = xyes -then : - printf "%s\n" "#define HAVE_UXTHEME_H 1" >>confdefs.h - -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: xpnative theme will be unavailable" >&5 -printf "%s\n" "$as_me: xpnative theme will be unavailable" >&6;} -fi - -ac_fn_c_check_header_compile "$LINENO" "vssym32.h" "ac_cv_header_vssym32_h" "#include <windows.h> -#include <uxtheme.h> -" -if test "x$ac_cv_header_vssym32_h" = xyes -then : - printf "%s\n" "#define HAVE_VSSYM32_H 1" >>confdefs.h - -fi - - -#-------------------------------------------------------------------- # Set the default compiler switches based on the --enable-symbols # option. This macro depends on C flags, and should be called # after SC_CONFIG_CFLAGS macro is called. diff --git a/win/configure.ac b/win/configure.ac index ae5a1e3..62f057e 100644 --- a/win/configure.ac +++ b/win/configure.ac @@ -152,17 +152,6 @@ AC_CHECK_TYPE([uintptr_t], [ ]) #-------------------------------------------------------------------- -# Windows XP theme engine header for Ttk -#-------------------------------------------------------------------- - -AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)], - [AC_MSG_NOTICE([xpnative theme will be unavailable])], - [#include <windows.h>]) -AC_CHECK_HEADER([vssym32.h], [AC_DEFINE(HAVE_VSSYM32_H)], [], - [#include <windows.h> -#include <uxtheme.h>]) - -#-------------------------------------------------------------------- # Set the default compiler switches based on the --enable-symbols # option. This macro depends on C flags, and should be called # after SC_CONFIG_CFLAGS macro is called. diff --git a/win/makefile.vc b/win/makefile.vc index 0fecad6..2648127 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -23,8 +23,6 @@ # noembed = Embeds Tcl scripts into the wish executable. Currently only
# applicable for static builds. Non-static builds currently
# never embed.
-# noxp = If you do not have the uxtheme.h header then you
-# cannot include support for XP themeing.
# square = Include the demo square widget.
#
# Possible values for TARGET are:
@@ -109,16 +107,9 @@ USING_PRE87_TCL = 1 # Extra makefile options processing for non-standard OPTS values ...
!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
-HAVE_UXTHEME_H = 1
TTK_SQUARE_WIDGET = 0
TK_EMBED_SCRIPTS = $(STATIC_BUILD)
!else
-!if [nmakehlp -f $(OPTS) "noxp"]
-!message *** Exclude support for XP theme
-HAVE_UXTHEME_H = 0
-!else
-HAVE_UXTHEME_H = 1
-!endif
!if [nmakehlp -f "$(OPTS)" "square"]
!message *** Include ttk square demo widget
TTK_SQUARE_WIDGET = 1
@@ -348,9 +339,6 @@ PRJ_INCLUDES = -I"$(BITMAPDIR)" -I"$(XLIBDIR)" CONFIG_DEFS =/DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
/DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \
/DHAVE_STRINGS_H=1 /DTCL_UTF_MAX=3 \
-!if $(HAVE_UXTHEME_H)
- /DHAVE_UXTHEME_H=1 \
-!endif
!if $(TTK_SQUARE_WIDGET)
/DTTK_SQUARE_WIDGET=1 \
!endif
@@ -522,7 +510,8 @@ $(TKSCRIPTZIP): .PHONY @if not exist "$(LIBTKVFS)" $(MKDIR) "$(LIBTKVFS)"
@if exist "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)" $(RMDIR) "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)"
@$(CPYDIR) $(LIBDIR) "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)"
- @cd "$(OUT_DIR)" && $(TCLSH) <<
+ @$(TCLSH) <<
+cd {$(OUT_DIR)}
file delete -force {$@}
zipfs mkzip {$@} {$(LIBTKVFS)} {$(LIBTKVFS)}
<<
@@ -531,7 +520,8 @@ zipfs mkzip {$@} {$(LIBTKVFS)} {$(LIBTKVFS)} $(WISHSCRIPTZIP): $(TKSCRIPTZIP)
@echo Building Wish Tcl+Tk library zip file
@if exist "$(LIBTKVFS)\tcl_library" $(RMDIR) "$(LIBTKVFS)\tcl_library"
- @cd "$(OUT_DIR)" && $(TCLSH) <<
+ @$(TCLSH) <<
+cd {$(OUT_DIR)}
file delete -force {$@}
zipfs mount mnt "$(TCLSCRIPTZIP:\=/)"
file copy [file join [zipfs root] mnt tcl_library] "$(LIBTKVFS:\=/)"
@@ -938,30 +938,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION]) fi - # Check to see if winnt.h defines CHAR, SHORT, and LONG - # even if VOID has already been #defined. The win32api - # used by mingw and cygwin is known to do this. - - AC_CACHE_CHECK(for winnt.h that ignores VOID define, - tcl_cv_winnt_ignore_void, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #define VOID void - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #undef WIN32_LEAN_AND_MEAN - ]], [[ - CHAR c; - SHORT s; - LONG l; - ]])], - [tcl_cv_winnt_ignore_void=yes], - [tcl_cv_winnt_ignore_void=no]) - ) - if test "$tcl_cv_winnt_ignore_void" = "yes" ; then - AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1, - [Defined when cygwin/mingw ignores VOID define in winnt.h]) - fi - AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],) # See if the compiler supports casting to a union type. @@ -1044,7 +1020,7 @@ AC_DEFUN([SC_WITH_TCL], [ # none # # Results -# Subst's the following values: +# Substitutes the following values: # TCLSH_PROG #------------------------------------------------------------------------ @@ -1090,7 +1066,7 @@ AC_DEFUN([SC_PROG_TCLSH], [ # none # # Results -# Subst's the following values: +# Substitutes the following values: # BUILD_TCLSH #------------------------------------------------------------------------ diff --git a/win/tkWinConfig.c b/win/tkWinConfig.c index ab0bb5f..e2f8ac1 100644 --- a/win/tkWinConfig.c +++ b/win/tkWinConfig.c @@ -22,7 +22,7 @@ * string representation of the option. * * Results: - * Returns a Tk_Uid that is the string identifier that identifies this + * Returns a Tcl_Obj* with the string identifier that identifies this * option. Returns NULL if there are no system defaults that match this * pair. * diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c index c335fb0..8b1bbff 100644 --- a/win/tkWinGDI.c +++ b/win/tkWinGDI.c @@ -14,7 +14,6 @@ #include <windows.h> -#include <stdlib.h> #include <math.h> #include <wtypes.h> #include <winspool.h> diff --git a/win/tkWinPort.h b/win/tkWinPort.h index e5e9e6c..d3471ca 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -24,7 +24,6 @@ #include <stdio.h> #include <wchar.h> #include <io.h> -#include <stdlib.h> #include <assert.h> #include <errno.h> #include <fcntl.h> diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c index 95ddc8b..b6f87dc 100644 --- a/win/tkWinRegion.c +++ b/win/tkWinRegion.c @@ -278,6 +278,30 @@ TkSubtractRegion( } /* + *---------------------------------------------------------------------- + * + * TkpCopyRegion -- + * + * Makes the destination region a copy of the source region. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkpCopyRegion( + TkRegion dst, + TkRegion src) +{ + CombineRgn((HRGN)dst, (HRGN)src, NULL, RGN_COPY); +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c index 8ca6a45..8399abb 100644 --- a/win/tkWinSysTray.c +++ b/win/tkWinSysTray.c @@ -33,14 +33,6 @@ #define GETHINSTANCE Tk_GetHINSTANCE() -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif - typedef struct IcoInfo { HICON hIcon; /* icon handle returned by LoadIcon. */ unsigned id; /* Identifier for command; used to diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 708ab7a..1ad3bfc 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -16,19 +16,9 @@ */ #include "tkWinInt.h" -#ifndef HAVE_UXTHEME_H -/* Stub for platforms that lack the XP theme API headers: */ -int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; } -#else - #include <windows.h> #include <uxtheme.h> -#if defined(HAVE_VSSYM32_H) || _MSC_VER > 1500 -# include <vssym32.h> -#else -# include <tmschema.h> -#endif - +#include <vssym32.h> #include "ttk/ttkTheme.h" typedef HTHEME (STDAPICALLTYPE OpenThemeDataProc)(HWND hwnd, @@ -1360,5 +1350,3 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) return TCL_OK; } - -#endif /* HAVE_UXTHEME_H */ diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index d485a2a..1b2710a 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -1743,6 +1743,10 @@ EXTERN Status XInitThreads( void ); +EXTERN Status XFreeThreads( + void +); + EXTERN void XLockDisplay( Display* /* display */ ); @@ -46,7 +46,11 @@ static TkpClipMask *AllocClipMask(GC gc) { if (clip_mask == NULL) { clip_mask = (TkpClipMask *)ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; + } else if (clip_mask->type == TKP_CLIP_REGION) { + TkDestroyRegion(clip_mask->value.region); } + clip_mask->type = TKP_CLIP_PIXMAP; + clip_mask->value.pixmap = None; return clip_mask; } @@ -67,10 +71,15 @@ static TkpClipMask *AllocClipMask(GC gc) { */ static void FreeClipMask(GC gc) { - if (gc->clip_mask != None) { - ckfree((char *)gc->clip_mask); - gc->clip_mask = None; + TkpClipMask * clip_mask = (TkpClipMask*)gc->clip_mask; + if (clip_mask == NULL) { + return; + } + if (clip_mask->type == TKP_CLIP_REGION) { + TkDestroyRegion(clip_mask->value.region); } + ckfree(clip_mask); + gc->clip_mask = None; } /* @@ -420,14 +429,12 @@ XSetClipOrigin( /* *---------------------------------------------------------------------- * - * TkSetRegion, XSetClipMask -- + * TkSetRegion, XSetClipMask, XSetClipRectangles -- * * Sets the clipping region/pixmap for a GC. * - * Note that unlike the Xlib equivalent, it is not safe to delete the - * region after setting it into the GC (except on Mac OS X). The only - * uses of TkSetRegion are currently in DisplayFrame and in - * ImgPhotoDisplay, which use the GC immediately. + * Like the Xlib equivalent, it is safe to delete the + * region after setting it into the GC. * * Results: * None. @@ -453,6 +460,8 @@ TkSetRegion( clip_mask->type = TKP_CLIP_REGION; clip_mask->value.region = r; + clip_mask->value.region = TkCreateRegion(); + TkpCopyRegion(clip_mask->value.region, r); } return Success; } @@ -476,6 +485,32 @@ XSetClipMask( return Success; } +int +XSetClipRectangles( + TCL_UNUSED(Display*), + GC gc, + int clip_x_origin, + int clip_y_origin, + XRectangle* rectangles, + int n, + TCL_UNUSED(int)) +{ + TkRegion clipRgn = TkCreateRegion(); + TkpClipMask * clip_mask = AllocClipMask(gc); + clip_mask->type = TKP_CLIP_REGION; + clip_mask->value.region = clipRgn; + + while (n--) { + XRectangle rect = *rectangles; + + rect.x += clip_x_origin; + rect.y += clip_y_origin; + TkUnionRectWithRegion(&rect, clipRgn, clipRgn); + rectangles++; + } + return 1; +} + /* * Some additional dummy functions (hopefully implemented soon). */ |