Codebase list tk8.6 / f873e5c
New upstream version 8.6.11 Sergei Golovan 3 years ago
406 changed file(s) with 23512 addition(s) and 17708 deletion(s). Raw diff Collapse all Expand all
0 name: Linux
1 on: [push]
2 defaults:
3 run:
4 shell: bash
5 working-directory: tk/unix
6 env:
7 ERROR_ON_FAILURES: 1
8 jobs:
9 build:
10 runs-on: ubuntu-20.04
11 strategy:
12 matrix:
13 compiler:
14 - "gcc"
15 - "clang"
16 symbols:
17 - "no"
18 - "mem"
19 disables:
20 - ""
21 - "--disable-shared"
22 - "--disable-xft"
23 - "--disable-xss"
24 steps:
25 - name: Checkout
26 uses: actions/checkout@v2
27 with:
28 path: tk
29 - name: Checkout Tcl
30 uses: actions/checkout@v2
31 with:
32 repository: tcltk/tcl
33 ref: core-8-6-branch
34 path: tcl
35 - name: Setup Environment (compiler=${{ matrix.compiler }})
36 run: |
37 sudo apt-get install tcl8.6-dev libxss-dev
38 mkdir "$HOME/install dir"
39 touch tk/doc/man.macros tk/generic/tkStubInit.c
40 echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6" >> $GITHUB_ENV
41 echo "CC=$COMPILER" >> $GITHUB_ENV
42 echo "TOOL_DIR=$(cd tcl/tools;pwd)" >> $GITHUB_ENV
43 echo "BUILD_CONFIG_ID=$OPTS" >> $GITHUB_ENV
44 working-directory: "."
45 env:
46 CFGOPT: --enable-symbols=${{ matrix.symbols }} ${{ matrix.disables }}
47 COMPILER: ${{ matrix.compiler }}
48 OPTS: ${{ matrix.compiler }}-${{ matrix.symbols }}${{ matrix.disables }}
49 - name: Configure (symbols=${{ matrix.symbols }} opts=${{ matrix.disables }})
50 run: |
51 ./configure $CFGOPT "--prefix=$HOME/install dir" || {
52 cat config.log
53 echo "::error::Failure during Configure"
54 exit 1
55 }
56 - name: Build
57 run: |
58 make binaries libraries || {
59 echo "::error::Failure during Build"
60 exit 1
61 }
62 - name: Build Test Harness
63 run: |
64 make tktest || {
65 echo "::error::Failure during Build"
66 exit 1
67 }
68 - name: Test-Drive Installation
69 run: |
70 make install || {
71 echo "::error::Failure during Install"
72 exit 1
73 }
74 - name: Create Distribution Package
75 run: |
76 make dist || {
77 echo "::error::Failure during Distribute"
78 exit 1
79 }
80 - name: Convert Documentation to HTML
81 run: |
82 make html-tk TOOL_DIR=$TOOL_DIR || {
83 echo "::error::Failure during Distribute"
84 exit 1
85 }
86 - name: Discover Version ID
87 if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }}
88 run: |
89 cd /tmp/dist
90 echo "VERSION=`ls -d tk* | sed 's/tk//'`" >> $GITHUB_ENV
91 - name: Upload Source Distribution
92 if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }}
93 uses: actions/upload-artifact@v2
94 with:
95 name: Tk ${{ env.VERSION }} Source distribution (unofficial)
96 path: |
97 /tmp/dist/tk*
98 !/tmp/dist/tk*/html/**
99 - name: Upload Documentation Distribution
100 if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }}
101 uses: actions/upload-artifact@v2
102 with:
103 name: Tk ${{ env.VERSION }} HTML documentation (unofficial)
104 path: /tmp/dist/tk*/html
105 test:
106 runs-on: ubuntu-20.04
107 strategy:
108 matrix:
109 compiler:
110 - "gcc"
111 symbols:
112 - "no"
113 - "mem"
114 steps:
115 - name: Checkout
116 uses: actions/checkout@v2
117 with:
118 path: tk
119 - name: Setup Environment (compiler=${{ matrix.compiler }})
120 run: |
121 sudo apt-get install tcl8.6-dev libxss-dev xvfb
122 mkdir "$HOME/install dir"
123 touch tk/doc/man.macros tk/generic/tkStubInit.c
124 echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6" >> $GITHUB_ENV
125 echo "CC=$COMPILER" >> $GITHUB_ENV
126 working-directory: "."
127 env:
128 CFGOPT: --enable-symbols=${{ matrix.symbols }}
129 COMPILER: ${{ matrix.compiler }}
130 - name: Configure (symbols=${{ matrix.symbols }})
131 run: |
132 ./configure $CFGOPT "--prefix=$HOME/install dir" || {
133 cat config.log
134 echo "::error::Failure during Configure"
135 exit 1
136 }
137 - name: Build
138 run: |
139 make binaries libraries tktest || {
140 echo "::error::Failure during Build"
141 exit 1
142 }
143 - name: Run Tests
144 run: |
145 xvfb-run --auto-servernum make test-classic | tee out-classic.txt
146 xvfb-run --auto-servernum make test-ttk | tee out-ttk.txt
147 grep -q "Failed 0" out-classic.txt || {
148 echo "::error::Failure during Test"
149 exit 1
150 }
151 grep -q "Failed 0" out-ttk.txt || {
152 echo "::error::Failure during Test"
153 exit 1
154 }
0 name: macOS
1 on: [push]
2 env:
3 ERROR_ON_FAILURES: 1
4 jobs:
5 xcode:
6 runs-on: macos-11.0
7 defaults:
8 run:
9 shell: bash
10 working-directory: tk/macosx
11 steps:
12 - name: Check out Tk
13 uses: actions/checkout@v2
14 with:
15 path: tk
16 - name: Check out Tcl
17 uses: actions/checkout@v2
18 with:
19 repository: tcltk/tcl
20 ref: core-8-6-branch
21 path: tcl
22 - name: Prepare checked out repositories
23 run: |
24 touch tk/generic/tkStubInit.c
25 mkdir build
26 echo "BUILD_DIR=`cd build && pwd`" >> $GITHUB_ENV
27 echo "DESTDIR=`cd build && pwd`" >> $GITHUB_ENV
28 working-directory: .
29 - name: Build Tcl
30 run: |
31 make all
32 working-directory: tcl/macosx
33 - name: Build
34 run: |
35 make all install || {
36 echo "::error::Failure during Build"
37 exit 1
38 }
39 clang:
40 runs-on: macos-11.0
41 strategy:
42 matrix:
43 symbols:
44 - 'no'
45 - 'mem'
46 options:
47 - '--enable-aqua'
48 - '--disable-aqua'
49 defaults:
50 run:
51 shell: bash
52 working-directory: tk/unix
53 steps:
54 - name: Check out Tk
55 uses: actions/checkout@v2
56 with:
57 path: tk
58 - name: Check out Tcl
59 uses: actions/checkout@v2
60 with:
61 repository: tcltk/tcl
62 ref: core-8-6-branch
63 path: tcl
64 - name: Prepare checked out repositories
65 run: |
66 touch tkStubInit.c
67 mkdir "$HOME/install dir"
68 echo "USE_XVFB=$SET_DISPLAY" >> $GITHUB_ENV
69 working-directory: tk/generic
70 env:
71 SET_DISPLAY: ${{ contains(matrix.options, '--disable-aqua') }}
72 - name: Add X11 (if required)
73 if: ${{ env.USE_XVFB }}
74 # This involves black magic
75 run: |
76 brew cask install xquartz
77 sudo /opt/X11/lib/X11/xinit/privileged_startx.d/10-tmpdirs || true
78 working-directory: .
79 - name: Build Tcl
80 # Note that macOS is always a 64 bit platform
81 run: |
82 ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" || {
83 cat config.log
84 echo "::error::Failure during Tcl Configure"
85 exit 1
86 }
87 make all || {
88 echo "::error::Failure during Tcl Build"
89 exit 1
90 }
91 make install || {
92 echo "::error::Failure during Tcl Install"
93 exit 1
94 }
95 working-directory: tcl/unix
96 env:
97 CFGOPT: --enable-symbols=${{ matrix.symbols }}
98 - name: Configure (symbols=${{ matrix.symbols }} ${{matrix.options }})
99 # Note that macOS is always a 64 bit platform
100 run: |
101 ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" || {
102 cat config.log
103 echo "::error::Failure during Configure"
104 exit 1
105 }
106 env:
107 CFGOPT: --enable-symbols=${{ matrix.symbols }} ${{matrix.options }}
108 - name: Build
109 run: |
110 make all tktest || {
111 echo "::error::Failure during Build"
112 exit 1
113 }
114 - name: Run Tests
115 run: |
116 if [ $USE_XVFB == true ]; then
117 function runXvfb {
118 PATH=$PATH:/opt/X11/bin
119 Xvfb $1 &
120 XVFB_PID=$!
121 echo Launched Xvfb $1 as process $XVFB_PID >&2
122 trap "echo killing process $XVFB_PID... >&2; kill $XVFB_PID" 0
123 export DISPLAY=$1
124 sleep 2
125 }
126 else
127 function runXvfb {
128 : do nothing
129 }
130 fi
131 ( runXvfb :0; make test-classic; exit $? ) | tee out-classic.txt || {
132 echo "::error::Failure during Test"
133 exit 1
134 }
135 ( runXvfb :0; make test-ttk; exit $? ) | tee out-ttk.txt || {
136 echo "::error::Failure during Test"
137 exit 1
138 }
139 cat out-classic.txt out-ttk.txt | grep -q "Failed[[:space:]][[:space:]]*[1-9]" && {
140 echo "::error::Failure during Test"
141 exit 1
142 }
143 env:
144 MAC_CI: 1
145 - name: Carry out trial installation
146 run: |
147 make install || {
148 cat config.log
149 echo "::error::Failure during Install"
150 exit 1
151 }
0 name: Windows
1 on: [push]
2 env:
3 ERROR_ON_FAILURES: 1
4 jobs:
5 msvc:
6 runs-on: windows-2019
7 defaults:
8 run:
9 shell: powershell
10 working-directory: tk/win
11 # Using powershell means we need to explicitly stop on failure
12 steps:
13 - name: Checkout
14 uses: actions/checkout@v2
15 with:
16 path: tk
17 - name: Checkout
18 uses: actions/checkout@v2
19 with:
20 repository: tcltk/tcl
21 ref: core-8-6-branch
22 path: tcl
23 - name: Init MSVC
24 uses: ilammy/msvc-dev-cmd@v1
25 - name: Make Install Location
26 working-directory: tcl
27 run: |
28 echo "TCLDIR=`pwd`" >> $GITHUB_ENV
29 cd ..
30 mkdir install
31 cd install
32 echo "INSTALLDIR=`pwd`" >> $GITHUB_ENV
33 - name: Build Tcl
34 run: |
35 &nmake -f makefile.vc release install
36 if ($lastexitcode -ne 0) {
37 throw "nmake exit code: $lastexitcode"
38 }
39 working-directory: tcl/win
40 - name: Build
41 run: |
42 &nmake -f makefile.vc all
43 if ($lastexitcode -ne 0) {
44 throw "nmake exit code: $lastexitcode"
45 }
46 - name: Build Test Harness
47 run: |
48 &nmake -f makefile.vc tktest
49 if ($lastexitcode -ne 0) {
50 throw "nmake exit code: $lastexitcode"
51 }
52 - name: Run Tests
53 run: |
54 nmake -f makefile.vc test-classic | tee out-classic.txt || {
55 echo "::error::Failure during Test"
56 exit 1
57 }
58 nmake -f makefile.vc test-ttk | tee out-ttk.txt || {
59 echo "::error::Failure during Test"
60 exit 1
61 }
62 grep -q "Failed 0" out-classic.txt || {
63 echo "::error::Failure during Test"
64 exit 1
65 }
66 grep -q "Failed 0" out-ttk.txt || {
67 echo "::error::Failure during Test"
68 exit 1
69 }
70 env:
71 CI_BUILD_WITH_MSVC: 1
72 shell: bash
73 - name: Build Help
74 run: |
75 &nmake -f makefile.vc htmlhelp
76 if ($lastexitcode -ne 0) {
77 throw "nmake exit code: $lastexitcode"
78 }
79 - name: Install
80 run: |
81 &nmake -f makefile.vc install
82 if ($lastexitcode -ne 0) {
83 throw "nmake exit code: $lastexitcode"
84 }
85 gcc:
86 runs-on: windows-2019
87 defaults:
88 run:
89 shell: bash
90 working-directory: win
91 strategy:
92 matrix:
93 symbols:
94 - "no"
95 - "mem"
96 - "all"
97 # Using powershell means we need to explicitly stop on failure
98 steps:
99 - name: Checkout
100 uses: actions/checkout@v2
101 - name: Checkout
102 uses: actions/checkout@v2
103 with:
104 repository: tcltk/tcl
105 ref: core-8-6-branch
106 path: tcl
107 - name: Install MSYS2, Make
108 run: choco install -y msys2 make
109 - name: Prepare
110 run: |
111 touch tkStubInit.c
112 touch "${HOME}/forWinDialog-5.12.7"
113 mkdir "${HOME}/install_dir"
114 echo "INSTALL_DIR=${HOME}/install_dir" >> $GITHUB_ENV
115 working-directory: generic
116 - name: Configure and Build Tcl
117 run: |
118 ./configure ${CFGOPT} "--prefix=$INSTALL_DIR" || {
119 cat config.log
120 echo "::warning::Failure during Tcl Configure"
121 exit 1
122 }
123 make all install || {
124 echo "::warning::Failure during Tcl Build"
125 exit 1
126 }
127 echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
128 env:
129 CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }}
130 working-directory: tcl/win
131 - name: Configure (symbols=${{ matrix.symbols }})
132 run: |
133 ./configure ${CFGOPT} "--prefix=$HOME/INSTALL_DIR" "--with-tcl=$TCL_CONFIG_PATH" || {
134 cat config.log
135 echo "::error::Failure during Configure"
136 exit 1
137 }
138 env:
139 CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }}
140 - name: Build
141 run: |
142 make all tktest || {
143 echo "::error::Failure during Build"
144 exit 1
145 }
146 - name: Run Tests
147 run: |
148 make test-classic | tee out-classic.txt
149 make test-ttk | tee out-ttk.txt
150 grep -q "Failed 0" out-classic.txt || {
151 echo "::error::Failure during Test"
152 exit 1
153 }
154 grep -q "Failed 0" out-ttk.txt || {
155 echo "::error::Failure during Test"
156 exit 1
157 }
0 language: c
1 addons:
2 apt:
3 sources:
4 - ubuntu-toolchain-r-test
5 packages:
6 - binutils-mingw-w64-i686
7 - binutils-mingw-w64-x86-64
8 - gcc-mingw-w64
9 - gcc-mingw-w64-base
10 - gcc-mingw-w64-i686
11 - gcc-mingw-w64-x86-64
12 - gcc-multilib
13 - tcl8.6-dev
14 - libx11-dev
15 - libxss-dev
16 - xvfb
17 homebrew:
18 packages:
19 - tcl-tk
20 # casks:
21 # - xquartz
22 jobs:
23 include:
24 # Testing on Linux GCC
25 - name: "Linux/GCC/Shared"
26 os: linux
27 dist: focal
28 services:
29 - xvfb
30 compiler: gcc
31 env:
32 - BUILD_DIR=unix
33 script: &x11gui
34 - make binaries libraries tktest
35 - make install
36 - make test-classic >out-classic.txt
37 - cat out-classic.txt
38 - grep -q "Failed 0" out-classic.txt
39 - make test-ttk >out-ttk.txt
40 - cat out-ttk.txt
41 - grep -q "Failed 0" out-ttk.txt
42 - name: "Linux/GCC/Shared/no-xft"
43 os: linux
44 dist: focal
45 services:
46 - xvfb
47 compiler: gcc
48 env:
49 - BUILD_DIR=unix
50 - CFGOPT="--disable-xft"
51 script: *x11gui
52 - name: "Linux/GCC/Shared/bionic"
53 os: linux
54 dist: bionic
55 services:
56 - xvfb
57 compiler: gcc
58 env:
59 - BUILD_DIR=unix
60 script: *x11gui
61 - name: "Linux/GCC/Shared/xenial"
62 os: linux
63 dist: xenial
64 services:
65 - xvfb
66 compiler: gcc
67 env:
68 - BUILD_DIR=unix
69 script: *x11gui
70 - name: "Linux/GCC/Static"
71 os: linux
72 dist: focal
73 compiler: gcc
74 env:
75 - BUILD_DIR=unix
76 - CFGOPT="--disable-shared"
77 - name: "Linux/GCC/Debug"
78 os: linux
79 dist: focal
80 compiler: gcc
81 env:
82 - BUILD_DIR=unix
83 - CFGOPT="--enable-symbols"
84 # Newer/Older versions of GCC
85 - name: "Linux/GCC 10/Shared"
86 os: linux
87 dist: focal
88 compiler: gcc-10
89 addons:
90 apt:
91 packages:
92 - g++-10
93 env:
94 - BUILD_DIR=unix
95 - name: "Linux/GCC 5/Shared"
96 os: linux
97 dist: bionic
98 compiler: gcc-5
99 addons:
100 apt:
101 packages:
102 - g++-5
103 env:
104 - BUILD_DIR=unix
105 # Testing on Linux Clang
106 - name: "Linux/Clang/Shared"
107 os: linux
108 dist: focal
109 compiler: clang
110 env:
111 - BUILD_DIR=unix
112 - name: "Linux/Clang/Shared/no-xft"
113 os: linux
114 dist: focal
115 compiler: clang
116 env:
117 - BUILD_DIR=unix
118 - CFGOPT="--disable-xft"
119 - name: "Linux/Clang/Static"
120 os: linux
121 dist: focal
122 compiler: clang
123 env:
124 - CFGOPT="--disable-shared"
125 - BUILD_DIR=unix
126 - name: "Linux/Clang/Debug"
127 os: linux
128 dist: focal
129 compiler: clang
130 env:
131 - BUILD_DIR=unix
132 - CFGOPT="--enable-symbols"
133 # Testing on Mac, various styles
134 - name: "macOS/Xcode 12/Shared"
135 os: osx
136 osx_image: xcode12
137 env:
138 - BUILD_DIR=unix
139 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
140 - name: "macOS/Xcode 12/Static"
141 os: osx
142 osx_image: xcode12
143 env:
144 - BUILD_DIR=unix
145 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --disable-shared CFLAGS=-I/usr/local/opt/tcl-tk/include"
146 - name: "macOS/Xcode 12/Debug"
147 os: osx
148 osx_image: xcode12
149 env:
150 - BUILD_DIR=unix
151 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --enable-symbols CFLAGS=-I/usr/local/opt/tcl-tk/include"
152 # - name: "macOS/Xcode 12/Shared/XQuartz"
153 # os: osx
154 # osx_image: xcode12
155 # env:
156 # - BUILD_DIR=unix
157 # - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include"
158 # Older MacOS versions
159 - name: "macOS/Xcode 11/Shared"
160 os: osx
161 osx_image: xcode11.7
162 env:
163 - BUILD_DIR=unix
164 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.14"
165 - name: "macOS/Xcode 10/Shared"
166 os: osx
167 osx_image: xcode10.3
168 addons:
169 homebrew:
170 packages:
171 - tcl-tk
172 update: true
173 env:
174 - BUILD_DIR=unix
175 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.14"
176 - name: "macOS/Xcode 9/Shared"
177 os: osx
178 osx_image: xcode9.4
179 addons:
180 homebrew:
181 packages:
182 - tcl-tk
183 update: true
184 env:
185 - BUILD_DIR=unix
186 - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.13"
187 # Test on Windows with MSVC native
188 # - name: "Windows/MSVC/Shared"
189 # os: windows
190 # compiler: cl
191 # env: &vcenv
192 # - BUILD_DIR=win
193 # - VCDIR="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build"
194 # before_install: &vcpreinst
195 # - PATH="$PATH:$VCDIR"
196 # - cd ${BUILD_DIR}
197 # install: []
198 # script:
199 # - cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc all tktest
200 # "make dist" only
201 - name: "Linux: make dist"
202 os: linux
203 dist: focal
204 compiler: gcc
205 env:
206 - BUILD_DIR=unix
207 script:
208 - touch ../doc/man.macros
209 - make dist
210 before_install:
211 - |-
212 case $TRAVIS_OS_NAME in
213 windows)
214 choco install -y magicsplat-tcl-tk
215 ;;
216 esac
217 - cd ${BUILD_DIR}
218 install:
219 - mkdir "$HOME/install dir"
220 - ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
221 script:
222 - make binaries libraries tktest
223 - make install
224 before_cache:
225 - |-
226 case $TRAVIS_OS_NAME in
227 osx)
228 brew cleanup
229 ;;
230 esac
231 cache:
232 directories:
233 - $HOME/Library/Caches/Homebrew
234 - $HOME/AppData/Local/Temp/chocolatey
235 - $HOME/AppData/Local/Apps/Tcl86
00 # README: Tk
11
2 This is the **Tk 8.6.10** source distribution.
2 This is the **Tk 8.6.11** source distribution.
33
44 You can get any source release of Tk from [our distribution
55 site](https://sourceforge.net/projects/tcl/files/Tcl/).
66
7 [![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch)
8 [![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch)
9 [![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch)
710
811 ## <a id="intro">1.</a> Introduction
912
1720
1821 Tk is maintained, enhanced, and distributed freely by the Tcl community.
1922 Source code development and tracking of bug reports and feature requests
20 takes place at [core.tcl-lang.org](https://core.tcl-lang.org/).
23 take place at [core.tcl-lang.org](https://core.tcl-lang.org/).
2124 Tcl/Tk release and mailing list services are [hosted by
2225 SourceForge](https://sourceforge.net/projects/tcl/)
2326 with the Tcl Developer Xchange hosted at
2427 [www.tcl-lang.org](https://www.tcl-lang.org).
2528
26 Tk is a freely available open source package. You can do virtually
29 Tk is a freely available open-source package. You can do virtually
2730 anything you like with it, such as modifying it, redistributing it,
2831 and selling it either in whole or in part. See the file
2932 `license.terms` for complete information.
75717571
75727572 2018-11-19 (bug)[0a9c91] crash in text-11a.22 (vogel)
75737573
7574 2018-11-20 (bug)[9705d1] crash activating "Alt" theme (culler)
7575
7576 2018-11-24 (bug)[e3b954] cursor offset at full screen display (culler)
7574 2018-11-20 (bug)[9705d1] crash activating "Alt" theme (culler)
7575
7576 2018-11-24 (bug)[e3b954] cursor offset at full screen display (culler)
75777577
75787578 2019-01-04 (bug)[18a4ba] cross-platform [winfo containing] (culler)
75797579
76977697 2019-11-19 (new) Partial Emoji support in text displays (nijtmans,culler)
76987698
76997699 - Released 8.6.10, Nov 21, 2019 - https://core.tcl-lang.org/tk/ for details
7700
7701 2019-11-25 (bug)[a95373] TkKeyEvent platform variations (werner)
7702
7703 2019-11-26 (bug) workaround Win bug so test bind-34.3 passes (nijtmans)
7704
7705 2019-12-03 Aqua: white cursors in dark mode (culler)
7706
7707 2019-12-04 (bug)[749bd9] Aqua: systemControlAccentColor (bll,culler)
7708
7709 2019-12-14 (bug)[b3b56a] ttk respect -cursor option (vogel)
7710
7711 2019-12-14 (bug)[b094cb] Win: $tv -show grows widget width 1 pixel (vogel)
7712
7713 2019-12-14 (bug)[02a694] spinbox options used wrong db names (vogel)
7714
7715 2020-01-11 (bug)[2b8fa6] MouseWheel for ttk::scrollbar (oehlmann)
7716
7717 2020-01-18 (bug)[1771594] icursor and scrollregion, canvText-14.7 (vogel)
7718
7719 2020-01-18 (bug)[587937] tag list ops preserve list order (vogel)
7720
7721 2020-01-18 (bug)[2830360] lose invalid state at focus event, entry-10.1 (vogel)
7722
7723 2020-01-18 (bug)[077d49] string table options support null ok (vogel)
7724
7725 2020-01-18 (bug)[bf93d0] Aqua: unresponsive menubar (culler)
7726
7727 2020-01-31 (bug)[a196fb] restore support for unthreaded Tcl (porter,sebres)
7728
7729 2020-02-09 (bug)[90a4d7] fontconfig crash when no font installed (vogel)
7730
7731 2020-02-24 (bug) Aqua: incomplete floating window display (walzer)
7732
7733 2020-03-11 (bug)[fb2ec3] OSX 10.15+: full screen options (nicolas,walzer)
7734
7735 2020-03-12 (bug)[08e2f8] focus on unmapped windows, focus-7.1 (vogel)
7736
7737 2020-03-12 (bug)[2edd84] [$c postscript] result management (gavilan)
7738
7739 2020-03-22 (bug)[98662d] restore TK_MAC_DEBUG_DRAWING build (chavez)
7740
7741 2020-03-29 (bug)[655fe2] tearoff menu redraw artifacts (vogel)
7742
7743 2020-04-03 (bug)[efbedd] Aqua: compund button-like widget appearance (chavez)
7744
7745 2020-04-14 (bug)[87bade] Aqua: improved dealing with PressAndHold (culler)
7746
7747 2020-04-14 (bug)[376788] X: stop crash w/Noto Color Emoji font (nijtmans)
7748
7749 2020-04-15 (bug)[89354d] Aqua: text color w/o clipping (culler)
7750
7751 2020-04-15 (new) Aqua: assign Button 3 to the middle button (chavez)
7752
7753 2020-04-25 (bug)[3519111] treeview horizontal scroll, entry-2.1.1 (vogel)
7754
7755 2020-04-25 (bug)[141881] treeview vertical scroll, treeview-9.2 (vogel)
7756
7757 2020-05-01 (bug)[2712f4] X: crash angled text w/o Xft, canvText-20.2 (vogel)
7758
7759 2020-05-01 (bug)[cd8714] Win: long angled text (chavez)
7760
7761 2020-05-09 (bug)[88c9e0] treeview -selectmode none focus ring (gavilan)
7762
7763 2020-05-12 (new) Aqua: Rewrite of the Key event system (culler)
7764
7765 2020-05-12 (bug)[411359] Aqua: stop crashes/zombies related to TouchBar (culler)
7766
7767 2020-05-12 (new) Aqua: systemLinkColor (chavez)
7768
7769 2020-05-16 (bug)[40ada9] crash when active button is destroyed (chavez)
7770
7771 2020-05-28 (bug)[3c6660,601cea,4b50b7] Win10: ttk scale (nemethi,lanam)
7772
7773 2020-06-08 (bug)[2790615] Some callbacks not eval'd in global scope (nijtmans)
7774
7775 2020-06-25 Aqua: Update OSX version tests to support Big Sur (culler)
7776
7777 2020-06-27 (bug)[6920b2] dup in spinbox -values causes trouble (lanam)
7778
7779 2020-06-27 (bug)[5c51be] invalid mem read buffer in Tk_PhotoPut* (chavez)
7780
7781 2020-06-27 (bug)[16ef16] restore bind sequence support, bind-33.(16-21) (vogel)
7782
7783 2020-07-02 (bug)[2d2459] default style for combobox (bll)
7784
7785 2020-07-06 (bug)[40c4bf] double free, entry-19.21 (vogel)
7786
7787 2020-07-06 (bug)[e3888d] grab & warp, bind-36.1 (vogel)
7788
7789 2020-07-12 (bug)[2442314] fontchooser i18n (nijtmans)
7790
7791 2020-07-13 (bug)[7655f6] [*entry]: selected text drawing reform (chavez)
7792
7793 2020-07-14 (bug)[09abd7] workaround invalid key codes from Debian 10 (vogel)
7794
7795 2020-07-20 (bug)[cf3853] Aqua: improve bounds on non-Retina displays (chavez)
7796
7797 2020-08-01 Aqua: [winfo rgb] light and dark mode support (culler)
7798
7799 2020-08-15 (bug)[315104] Aqua: appearance change virtual events (culler)
7800
7801 2020-08-21 (bug)[291699] mouse binding for scrollbar grip (bll)
7802
7803 2020-09-08 (bug)[6c2425] buffer bounds violation (chavez)
7804
7805 2020-09-08 (bug)[2a6d63] OSX 10.6 crash (hellstrom,culler)
7806
7807 2020-09-08 (bug)[420feb] undefined behavior due to alignment (chavez,nijtmans)
7808
7809 2020-09-10 (bug)[ab1fea] Aqua init issues (culler)
7810
7811 2020-09-14 (bug)[71e18c] Aqua: crash in full screen toggle (culler)
7812
7813 2020-09-18 (bug)[4f4f03] Aqua: mouse drags across title bar (nab,culler)
7814
7815 2020-09-21 (bug)[d91e05] select/copy in disabled text (bll)
7816
7817 2020-09-27 (TIP #581) disfavor Master/Slave terminology (nijtmans)
7818
7819 2020-09-30 (bug)[59cba3] win: improve theme detection (bll,nijtmans)
7820
7821 2020-10-06 (bug)[175a6e] Aqua: support tiled windows (culler)
7822
7823 2020-10-07 (bug)[1fa8c3] Aqua: crash on resize during display (nab,culler)
7824
7825 2020-10-16 (bug)[c2483b] Aqua: consistent finalization (culler,nijtmans)
7826
7827 2020-11-06 (bug)[c9ebac] Aqua: use standard about dialog (culler)
7828
7829 2020-11-07 (bug)[4ebcc0] sticky fontchooser options (roseman,vogel)
7830
7831 2020-11-10 (bug)[f9fa92] Aqua: crash in color caching scheme (culler)
7832
7833 2020-11-20 (bug)[7185d2] Aqua: fixes to special menu support (culler)
7834
7835 2020-11-24 (bug)[4a40c6] Aqua: [wm manage] frame offset (chavez)
7836
7837 2020-12-04 (bug)[3ef77f] Aqua dark mode combobox focus ring (walzer,culler)
7838
7839 2020-12-15 (bug)[80e4c6] Aqua: progressbar animation (nab,culler)
7840
7841 2020-12-24 (bug)[6157a8] Aqua: file dialog -filetypes (davis,culler)
7842
7843 - Released 8.6.11, Dec 31, 2020 - https://core.tcl-lang.org/tk/ for details
22 *
33 * Declares facilities exported by the "stdlib" portion of the C library.
44 * This file isn't complete in the ANSI-C sense; it only declares things
5 * that are needed by Tcl. This file is needed even on many systems with
5 * that are needed by Tk. This file is needed even on many systems with
66 * their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare
77 * all the procedures needed here (such as strtod).
88 *
1616 #ifndef _STDLIB
1717 #define _STDLIB
1818
19 #ifndef _TCL
20 # include <tcl.h>
21 #endif
22
1923 extern void abort(void);
2024 extern double atof(const char *string);
2125 extern int atoi(const char *string);
2832 extern void qsort(void *base, int n, int size, int (*compar)(
2933 const void *element1, const void *element2));
3034 extern char * realloc(char *ptr, unsigned int numBytes);
35 extern double strtod(const char *string, char **endPtr);
3136 extern long strtol(const char *string, char **endPtr, int base);
3237 extern unsigned long strtoul(const char *string, char **endPtr, int base);
3338
1414 #define _UNISTD
1515
1616 #include <sys/types.h>
17 #ifndef _TCL
18 # include <tcl.h>
19 #endif
1720
1821 #ifndef NULL
1922 #define NULL 0
3639 extern int execlp(const char *file, ...);
3740 extern int execv(const char *path, char **argv);
3841 extern int execve(const char *path, char **argv, char **envp);
39 extern int execvpw(const char *file, char **argv);
42 extern int execvp(const char *file, char **argv);
4043 extern pid_t fork(void);
4144 extern char * getcwd(char *buf, size_t size);
4245 extern gid_t getegid(void);
6467 extern int ioctl(int fd, int request, ...);
6568 extern int readlink(const char *path, char *buf, int bufsize);
6669 extern int setegid(gid_t group);
67 extern int seteuidw(uid_t user);
70 extern int seteuid(uid_t user);
6871 extern int setreuid(int ruid, int euid);
6972 extern int symlink(const char *, const char *);
7073 extern int ttyslot(void);
7376 #endif /* _POSIX_SOURCE */
7477
7578 #endif /* _UNISTD */
79
88 .so man.macros
99 .BS
1010 .SH NAME
11 Tk_CreateImageType, Tk_GetImageMasterData, Tk_InitImageArgs \- define new kind of image
11 Tk_CreateImageType, Tk_GetImageMasterData, Tk_GetImageModelData, Tk_InitImageArgs \- define new kind of image
1212 .SH SYNOPSIS
1313 .nf
1414 \fB#include <tk.h>\fR
1717 .sp
1818 ClientData
1919 \fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR)
20 .sp
21 .VS "TIP 581"
22 ClientData
23 \fBTk_GetImageModelData\fR(\fIinterp, name, typePtrPtr\fR)
24 .VE "TIP 581"
2025 .sp
2126 \fBTk_InitImageArgs\fR(\fIinterp, argc, argvPtr\fR)
2227 .SH ARGUMENTS
7075 of this entry.
7176 .PP
7277 The second major data structure manipulated by an image manager
73 is called an \fIimage master\fR; it contains overall information
78 is called an \fIimage model\fR; it contains overall information
7479 about a particular image, such as the values of the configuration
7580 options specified in an \fBimage create\fR command.
7681 There will usually be one of these structures for each
112117 int \fIobjc\fR,
113118 Tcl_Obj *const \fIobjv\fR[],
114119 const Tk_ImageType *\fItypePtr\fR,
115 Tk_ImageMaster \fImaster\fR,
116 ClientData *\fImasterDataPtr\fR);
120 Tk_ImageMaster \fImodel\fR,
121 ClientData *\fImodelDataPtr\fR);
117122 .CE
118123 The \fIinterp\fR argument is the interpreter in which the \fBimage\fR
119124 command was invoked, and \fIname\fR is the name for the new image,
122127 The \fIobjc\fR and \fIobjv\fR arguments describe all the configuration
123128 options for the new image (everything after the name argument to
124129 \fBimage\fR).
125 The \fImaster\fR argument is a token that refers to Tk's information
130 The \fImodel\fR argument is a token that refers to Tk's information
126131 about this image; the image manager must return this token to
127132 Tk when invoking the \fBTk_ImageChanged\fR procedure.
128133 Typically \fIcreateProc\fR will parse \fIobjc\fR and \fIobjv\fR
129 and create an image master data structure for the new image.
134 and create an image model data structure for the new image.
130135 \fIcreateProc\fR may store an arbitrary one-word value at
131 *\fImasterDataPtr\fR, which will be passed back to the
136 *\fImodelDataPtr\fR, which will be passed back to the
132137 image manager when other callbacks are invoked.
133 Typically the value is a pointer to the master data
138 Typically the value is a pointer to the model data
134139 structure for the image.
135140 .PP
136141 If \fIcreateProc\fR encounters an error, it should leave an error
147152 .CS
148153 typedef ClientData \fBTk_ImageGetProc\fR(
149154 Tk_Window \fItkwin\fR,
150 ClientData \fImasterData\fR);
155 ClientData \fImodelData\fR);
151156 .CE
152157 The \fItkwin\fR argument identifies the window in which the
153 image will be used and \fImasterData\fR is the value
154 returned by \fIcreateProc\fR when the image master was created.
158 image will be used and \fImodelData\fR is the value
159 returned by \fIcreateProc\fR when the image model was created.
155160 \fIgetProc\fR will usually create a data structure for the new
156161 instance, including such things as the resources needed to
157162 display the image in the given window.
220225 \fIdeleteProc\fR must match the following prototype:
221226 .CS
222227 typedef void \fBTk_ImageDeleteProc\fR(
223 ClientData \fImasterData\fR);
224 .CE
225 The \fImasterData\fR argument will be the same as the value
226 stored in \fI*masterDataPtr\fR by \fIcreateProc\fR when the
228 ClientData \fImodelData\fR);
229 .CE
230 The \fImodelData\fR argument will be the same as the value
231 stored in \fI*modelDataPtr\fR by \fIcreateProc\fR when the
227232 image was created.
228233 \fIdeleteProc\fR should release any resources associated with
229234 the image.
230 .SH TK_GETIMAGEMASTERDATA
235 .SH TK_GETIMAGEMODELDATA
231236 .PP
232237 The procedure \fBTk_GetImageMasterData\fR may be invoked to retrieve
233238 information about an image. For example, an image manager can use this
234 procedure to locate its image master data for an image.
239 procedure to locate its image model data for an image.
235240 If there exists an image named \fIname\fR
236241 in the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR is
237242 filled in with type information for the image (the \fItypePtr\fR value
238243 passed to \fBTk_CreateImageType\fR when the image type was registered)
239244 and the return value is the ClientData value returned by the
240245 \fIcreateProc\fR when the image was created (this is typically a
241 pointer to the image master data structure). If no such image exists
246 pointer to the image model data structure). If no such image exists
242247 then NULL is returned and NULL is stored at \fI*typePtrPtr\fR.
248 .PP
249 .VS "TIP 581"
250 \fBTk_GetImageModelData\fR is synonym for \fBTk_GetImageMasterData\fR
251 .VE "TIP 581"
243252 .SH "LEGACY INTERFACE SUPPORT"
244253 .PP
245254 In Tk 8.2 and earlier, the definition of \fBTk_ImageCreateProc\fR
251260 int \fIargc\fR,
252261 char **\fIargv\fR,
253262 Tk_ImageType *\fItypePtr\fR,
254 Tk_ImageMaster \fImaster\fR,
255 ClientData *\fImasterDataPtr\fR);
263 Tk_ImageMaster \fImodel\fR,
264 ClientData *\fImodelDataPtr\fR);
256265 .CE
257266 Legacy programs and libraries dating from those days may still
258267 contain code that defines extended Tk image types using the old
259268 interface. The Tk header file will still support this legacy
260269 interface if the code is compiled with the macro \fBUSE_OLD_IMAGE\fR
261270 defined.
271 .PP
272 .VS "TIP 581"
273 \fITk_ImageModel\fR is synonym for \fITk_ImageMaster\fR
274 .VE "TIP 581"
262275 .PP
263276 When the \fBUSE_OLD_IMAGE\fR legacy support is enabled, you may
264277 see the routine \fBTk_InitImageArgs\fR in use. This was a migration
279292 .SH "SEE ALSO"
280293 Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage
281294 .SH KEYWORDS
282 image manager, image type, instance, master
295 image manager, image type, instance, model
2424 Interpreter to use for error reporting.
2525 .AP int objc in
2626 Number of Tcl_Obj's in \fIobjv\fR array.
27 .AP "Tcl_Obj *const" objv[] in
27 .AP "Tcl_Obj *const *" objv in
2828 Argument objects. These represent the entire widget command, of
2929 which the first word is typically the widget name and the second
3030 word is typically \fBxview\fR or \fByview\fR.
3131 .AP int argc in
3232 Number of strings in \fIargv\fR array.
33 .AP "const char" *argv[] in
33 .AP "const char **" argv in
3434 Argument strings. These represent the entire widget command, of
3535 which the first word is typically the widget name and the second
3636 word is typically \fBxview\fR or \fByview\fR.
1313 .nf
1414 \fB#include <tk.h>\fR
1515 .sp
16 \fBTk_ImageChanged\fR(\fIimageMaster, x, y, width, height, imageWidth, imageHeight\fR)
16 \fBTk_ImageChanged\fR(\fImodel, x, y, width, height, imageWidth, imageHeight\fR)
1717 .SH ARGUMENTS
1818 .AS Tk_ImageMaster imageHeight
19 .AP Tk_ImageMaster imageMaster in
19 .AP Tk_ImageMaster model in
2020 Token for image, which was passed to image's \fIcreateProc\fR when
2121 the image was created.
2222 .AP int x in
4141 As a result of calling \fBTk_ImageChanged\fR, any widgets using
4242 the image are notified so that they can redisplay themselves
4343 appropriately.
44 The \fIimageMaster\fR argument identifies the image, and
44 The \fImodel\fR argument identifies the image, and
4545 \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
4646 specify a rectangular region within the image that needs to
4747 be redrawn.
4848 \fIimageWidth\fR and \fIimageHeight\fR specify the image's (new) size.
49 .PP
50 .VS "TIP 581"
51 \fITk_ImageModel\fR is synonym for \fITk_ImageMaster\fR
52 .VE "TIP 581"
4953 .PP
5054 An image manager should call \fBTk_ImageChanged\fR during
5155 its \fIcreateProc\fR to specify the image's initial size and to
1313 .nf
1414 \fB#include <tk.h>\fR
1515 .sp
16 \fBTk_MaintainGeometry\fR(\fIslave, master, x, y, width, height\fR)
16 \fBTk_MaintainGeometry\fR(\fIwindow, container, x, y, width, height\fR)
1717 .sp
18 \fBTk_UnmaintainGeometry\fR(\fIslave, master\fR)
18 \fBTk_UnmaintainGeometry\fR(\fIwindow, container\fR)
1919 .SH ARGUMENTS
20 .AS Tk_Window master
21 .AP Tk_Window slave in
20 .AS Tk_Window container
21 .AP Tk_Window window in
2222 Window whose geometry is to be controlled.
23 .AP Tk_Window master in
24 Window relative to which \fIslave\fR's geometry will be controlled.
23 .AP Tk_Window container in
24 Window relative to which \fIwindow\fR's geometry will be controlled.
2525 .AP int x in
26 Desired x-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels
27 from the inside of \fImaster\fR's left border to the outside of
28 \fIslave\fR's left border.
26 Desired x-coordinate of \fIwindow\fR in \fIcontainer\fR, measured in pixels
27 from the inside of \fIcontainer\fR's left border to the outside of
28 \fIwindow\fR's left border.
2929 .AP int y in
30 Desired y-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels
31 from the inside of \fImaster\fR's top border to the outside of
32 \fIslave\fR's top border.
30 Desired y-coordinate of \fIwindow\fR in \fIcontainer\fR, measured in pixels
31 from the inside of \fIcontainer\fR's top border to the outside of
32 \fIwindow\fR's top border.
3333 .AP int width in
34 Desired width for \fIslave\fR, in pixels.
34 Desired width for \fIwindow\fR, in pixels.
3535 .AP int height in
36 Desired height for \fIslave\fR, in pixels.
36 Desired height for \fIwindow\fR, in pixels.
3737 .BE
3838 .SH DESCRIPTION
3939 .PP
4040 \fBTk_MaintainGeometry\fR and \fBTk_UnmaintainGeometry\fR make it
41 easier for geometry managers to deal with slaves whose masters are not
41 easier for geometry managers to deal with windows whose containers are not
4242 their parents.
43 Three problems arise if the master for a slave is not its parent:
43 Three problems arise if the container for a window is not its parent:
4444 .IP [1]
45 The x- and y-position of the slave must be translated from the
46 coordinate system of the master to that of the parent before
47 positioning the slave.
45 The x- and y-position of the window must be translated from the
46 coordinate system of the container to that of the parent before
47 positioning the window.
4848 .IP [2]
49 If the master window, or any of its ancestors up to the slave's
50 parent, is moved, then the slave must be repositioned within its
49 If the container window, or any of its ancestors up to the window's
50 parent, is moved, then the window must be repositioned within its
5151 parent in order to maintain the correct position relative to the
52 master.
52 container.
5353 .IP [3]
54 If the master or one of its ancestors is mapped or unmapped, then
55 the slave must be mapped or unmapped to correspond.
54 If the container or one of its ancestors is mapped or unmapped, then
55 the window must be mapped or unmapped to correspond.
5656 .LP
57 None of these problems is an issue if the parent and master are
58 the same. For example, if the master or one of its ancestors
59 is unmapped, the slave is automatically removed by the screen
57 None of these problems is an issue if the parent and container are
58 the same. For example, if the container or one of its ancestors
59 is unmapped, the window is automatically removed by the screen
6060 by X.
6161 .PP
62 \fBTk_MaintainGeometry\fR deals with these problems for slaves
63 whose masters are not their parents, as well as handling the simpler
64 case of slaves whose masters are their parents.
62 \fBTk_MaintainGeometry\fR deals with these problems for windows
63 whose containers are not their parents, as well as handling the simpler
64 case of windows whose container are their parents.
6565 \fBTk_MaintainGeometry\fR is typically called by a window manager
66 once it has decided where a slave should be positioned relative
67 to its master.
66 once it has decided where a window should be positioned relative
67 to its container.
6868 \fBTk_MaintainGeometry\fR translates the coordinates to the
69 coordinate system of \fIslave\fR's parent and then moves and
70 resizes the slave appropriately.
69 coordinate system of \fIwindow\fR's parent and then moves and
70 resizes the window appropriately.
7171 Furthermore, it remembers the desired position and creates event
72 handlers to monitor the master and all of its ancestors up
73 to (but not including) the slave's parent.
72 handlers to monitor the container and all of its ancestors up
73 to (but not including) the window's parent.
7474 If any of these windows is moved, mapped, or unmapped,
75 the slave will be adjusted so that it is mapped only when the
76 master is mapped and its geometry relative to the master
75 the window will be adjusted so that it is mapped only when the
76 container is mapped and its geometry relative to the container
7777 remains as specified by \fIx\fR, \fIy\fR, \fIwidth\fR, and
7878 \fIheight\fR.
7979 .PP
8282 screen under any conditions, it calls \fBTk_UnmaintainGeometry\fR.
8383 \fBTk_UnmaintainGeometry\fR unmaps the window and cancels any
8484 previous calls to \fBTk_MaintainGeometry\fR for the
85 \fImaster\fR\-\fIslave\fR pair, so that the slave's
85 \fIcontainer\fR\-\fIwindow\fR pair, so that the window's
8686 geometry and mapped state are no longer maintained
8787 automatically.
8888 \fBTk_UnmaintainGeometry\fR need not be called by a geometry
89 manager if the slave, the master, or any of the master's ancestors
89 manager if the window, the container, or any of the container's ancestors
9090 is destroyed: Tk will call it automatically.
9191 .PP
9292 If \fBTk_MaintainGeometry\fR is called repeatedly for the same
93 \fImaster\fR\-\fIslave\fR pair, the information from the most
93 \fIcontainer\fR\-\fIwindow\fR pair, the information from the most
9494 recent call supersedes any older information.
95 If \fBTk_UnmaintainGeometry\fR is called for a \fImaster\fR\-\fIslave\fR
95 If \fBTk_UnmaintainGeometry\fR is called for a \fIcontainer\fR\-\fIwindow\fR
9696 pair that is is not currently managed, the call has no effect.
9797 .SH KEYWORDS
98 geometry manager, map, master, parent, position, slave, unmap
98 geometry manager, map, container, parent, position, window, unmap
3131 .PP
3232 \fBTk_ManageGeometry\fR arranges for a particular geometry manager,
3333 described by the \fImgrPtr\fR argument, to control the geometry
34 of a particular slave window, given by \fItkwin\fR.
34 of a particular content window, given by \fItkwin\fR.
3535 If \fItkwin\fR was previously managed by some other geometry manager,
3636 the previous manager loses control in favor of the new one.
3737 If \fImgrPtr\fR is NULL, geometry management is cancelled for
5252 .PP
5353 \fIrequestProc\fR is a procedure in the geometry manager that
5454 will be invoked whenever \fBTk_GeometryRequest\fR is called by the
55 slave to change its desired geometry.
55 content window to change its desired geometry.
5656 \fIrequestProc\fR should have arguments and results that match the
5757 type \fBTk_GeomRequestProc\fR:
5858 .CS
2525 This procedure is invoked by image managers to find out the name
2626 of an image. Given the token for the image, it returns the
2727 string name for the image.
28 .PP
29 .VS "TIP 581"
30 \fITk_ImageModel\fR is synonym for \fITk_ImageMaster\fR
31 .VE "TIP 581"
2832 .SH KEYWORDS
2933 image manager, image name
6262 this argument.
6363 .AP int objc in
6464 Number of values in \fIobjv\fR.
65 .AP Tcl_Obj "*const objv[]" in
65 .AP Tcl_Obj "*const *objv" in
6666 Command-line arguments for setting configuring options.
6767 .AP Tk_SavedOptions *savePtr out
6868 If not NULL, the structure pointed to by this argument is filled
442442 be one of the strings in the table, or a unique abbreviation of
443443 one of the strings. The internal form is an integer giving the index
444444 into the table of the matching string, like the return value
445 from \fBTcl_GetStringFromObj\fR.
445 from \fBTcl_GetStringFromObj\fR. This option type supports the
446 \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal
447 representation is set to -1.
446448 .TP
447449 \fBTK_OPTION_SYNONYM\fR
448450 This type is used to provide alternative names for an option (for
200200 Many contemporary mice support a mouse wheel, which is used
201201 for scrolling documents without using the scrollbars. By rolling the
202202 wheel, the system will generate \fBMouseWheel\fR events that the
203 application can use to scroll. Like \fBKey\fR events the event is
204 always routed to the window that currently has focus. When the event
203 application can use to scroll. The event is routed to the
204 window currently under the mouse pointer. When the event
205205 is received you can use the \fB%D\fR substitution to get the
206 \fIdelta\fR field for the event, which is a integer value describing how
206 \fIdelta\fR field for the event, which is an integer value describing how
207207 the mouse wheel has moved. The smallest value for which the
208 system will report is defined by the OS. The sign of the
208 system will report is defined by the OS. The sign of the
209209 value determines which direction your widget should scroll. Positive
210210 values should scroll up and negative values should scroll down.
211 .RS
212 .PP
213 Horizontal scrolling uses \fBShift-MouseWheel\fR events, with positive
214 \fB%D\fR \fIdelta\fR substitution indicating left scrolling and negative
215 right scrolling.
216 Only Windows and macOS Aqua typically fire \fBMouseWheel\fR and
217 \fBShift-MouseWheel\fR events. On
218 X11 vertical scrolling is rather supported through \fBButton-4\fR and
219 \fBButton-5\fR events, and horizontal scrolling through \fBShift-Button-4\fR
220 and \fBShift-Button-5\fR events. Horizontal scrolling events may fire from
221 many different hardware units such as tilt wheels or touchpads. Horizontal
222 scrolling can also be emulated by holding Shift and scrolling vertically.
223 .RE
211224 .IP "\fBKeyPress\fR, \fBKeyRelease\fR" 5
212225 The \fBKeyPress\fR and \fBKeyRelease\fR events are generated
213226 whenever a key is pressed or released. \fBKeyPress\fR and \fBKeyRelease\fR
269282 When the \fBDestroy\fR event is delivered
270283 to a widget, it is in a
271284 .QW half-dead
272 state: the widget still exists, but most operations on it will fail.
285 state: the widget still exists, but operations that involve it
286 may return invalid results, or return an error.
273287 .RE
274288 .IP "\fBFocusIn\fR, \fBFocusOut\fR" 5
275289 The \fBFocusIn\fR and \fBFocusOut\fR events are generated
509523 \fBKeyPress\fR, \fBKeyRelease\fR, and \fBMouseWheel\fR events,
510524 \fB%x\fR and \fB%y\fR indicate the position of the mouse pointer
511525 relative to the receiving window.
526 For key events on the Macintosh these are the coordinates of the
527 mouse at the moment when an X11 KeyEvent is sent to Tk, which could
528 be slightly later than the time of the physical press or release.
512529 For \fBEnter\fR and \fBLeave\fR events, the position where the
513530 mouse pointer crossed the window, relative to the receiving window.
514531 For \fBConfigure\fR and \fBCreate\fR requests, the \fIx\fR and \fIy\fR
516533 .IP \fB%A\fR 5
517534 Substitutes the UNICODE character corresponding to the event, or
518535 the empty string if the event does not correspond to a UNICODE character
519 (e.g. the shift key was pressed). \fBXmbLookupString\fR (or
536 (e.g. the shift key was pressed). On X11, \fBXmbLookupString\fR (or
520537 \fBXLookupString\fR when input method support is turned off) does all
521538 the work of translating from the event to a UNICODE character.
522 Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
539 On X11, valid only for \fBKeyPress\fR event. On Windows and macOS/aqua,
540 valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
523541 .IP \fB%B\fR 5
524542 The \fIborder_width\fR field from the event. Valid only for
525543 \fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events.
752752 \fIpathName \fBmoveto \fItagOrId xPos yPos\fR
753753 .VS 8.6
754754 Move the items given by \fItagOrId\fR in the canvas coordinate
755 space so that the first coordinate pair of the bottommost item with
755 space so that the first coordinate pair (the upper-left corner of the
756 bounding box) of the first item (the lowest in the display list) with
756757 tag \fItagOrId\fR is located at
757758 position (\fIxPos\fR,\fIyPos\fR). \fIxPos\fR and \fIyPos\fR may be
758759 the empty string, in which case the corresponding coordinate
11211122 becomes visible.
11221123 .RE
11231124 .TP
1124 \fIpathName \fByview \fI?args\fR?
1125 \fIpathName \fByview ?\fIargs\fR?
11251126 .
11261127 This command is used to query and change the vertical position of the
11271128 information displayed in the canvas's window.
15221523 \fBlast\fR (for an arrowhead at the last point of the line), or
15231524 \fBboth\fR (for arrowheads at both ends).
15241525 This option defaults to \fBnone\fR.
1526 When requested to draw an arrowhead, Tk internally adjusts the corresponding
1527 line end point so that the rendered line ends at the neck of the arrowhead
1528 rather than at its tip so that the line doesn't extend past the edge of the
1529 arrowhead. This may trigger a \fBLeave\fR event if the mouse is hovering this
1530 line end. Conversely, when removing an arrowhead Tk adjusts the corresponding
1531 line point the other way round, which may trigger an \fBEnter\fR event.
15251532 .TP
15261533 \fB\-arrowshape \fIshape\fR
15271534 This option indicates how to draw arrowheads.
783783 .TP
784784 \fBMac OS X\fR
785785 .
786 On macOS, the following additional system colors are available.
787 This first group contains all colors available in the HIToolbox library.
788 (Note that in some cases the actual color values may depend on the
789 current Appearance.)
786 On macOS, the following additional system colors are available. This
787 first group contains all of the HIBrush colors available in the
788 HIToolbox library. Note that on macOS 10.14 (Mojave) and later these
789 colors are unlikely to match the color actually used for the purpose
790 suggested by the color name.
790791 .RS
791792 .DS
792793 systemActiveAreaFill
793 systemAlertActiveText
794794 systemAlertBackgroundActive
795795 systemAlertBackgroundInactive
796 systemAlertInactiveText
797796 systemAlternatePrimaryHighlightColor
798797 systemAppleGuideCoachmark
799798 systemBevelActiveDark
800799 systemBevelActiveLight
801 systemBevelButtonActiveText
802 systemBevelButtonInactiveText
803 systemBevelButtonPressedText
804 systemBevelButtonStickyActiveText
805 systemBevelButtonStickyInactiveText
806800 systemBevelInactiveDark
807801 systemBevelInactiveLight
808802 systemBlack
809 systemBlackText
810803 systemButtonActiveDarkHighlight
811804 systemButtonActiveDarkShadow
812805 systemButtonActiveLightHighlight
826819 systemButtonPressedDarkShadow
827820 systemButtonPressedLightHighlight
828821 systemButtonPressedLightShadow
829 systemButtonText
830822 systemChasingArrows
831 systemDialogActiveText
832823 systemDialogBackgroundActive
833824 systemDialogBackgroundInactive
834 systemDialogInactiveText
835825 systemDocumentWindowBackground
836 systemDocumentWindowTitleActiveText
837 systemDocumentWindowTitleInactiveText
838826 systemDragHilite
839827 systemDrawerBackground
840828 systemFinderWindowBackground
842830 systemHighlight
843831 systemHighlightAlternate
844832 systemHighlightSecondary
845 systemHighlightText
846833 systemIconLabelBackground
847834 systemIconLabelBackgroundSelected
848 systemIconLabelSelectedText
849 systemIconLabelText
850835 systemListViewBackground
851836 systemListViewColumnDivider
852837 systemListViewEvenRowBackground
853838 systemListViewOddRowBackground
854839 systemListViewSeparator
855840 systemListViewSortColumnBackground
856 systemListViewText
857 systemListViewWindowHeaderBackground
858841 systemMenu
859842 systemMenuActive
860 systemMenuActiveText
861843 systemMenuBackground
862844 systemMenuBackgroundSelected
863 systemMenuDisabled
864 systemMenuItemActiveText
865 systemMenuItemDisabledText
866 systemMenuItemSelectedText
867 systemMenuText
868 systemMetalBackground
869 systemModelessDialogActiveText
870845 systemModelessDialogBackgroundActive
871846 systemModelessDialogBackgroundInactive
872 systemModelessDialogInactiveText
873847 systemMovableModalBackground
874 systemMovableModalWindowTitleActiveText
875 systemMovableModalWindowTitleInactiveText
876 systemNotificationText
877848 systemNotificationWindowBackground
878 systemPlacardActiveText
879 systemPlacardBackground
880 systemPlacardInactiveText
881 systemPlacardPressedText
882849 systemPopupArrowActive
883850 systemPopupArrowInactive
884851 systemPopupArrowPressed
885 systemPopupButtonActiveText
886 systemPopupButtonInactiveText
887 systemPopupButtonPressedText
888 systemPopupLabelActiveText
889 systemPopupLabelInactiveText
890 systemPopupWindowTitleActiveText
891 systemPopupWindowTitleInactiveText
892852 systemPrimaryHighlightColor
893 systemPushButtonActiveText
894 systemPushButtonInactiveText
895 systemPushButtonPressedText
896 systemRootMenuActiveText
897 systemRootMenuDisabledText
898 systemRootMenuSelectedText
899853 systemScrollBarDelimiterActive
900854 systemScrollBarDelimiterInactive
901 systemSecondaryGroupBoxBackground
902855 systemSecondaryHighlightColor
903856 systemSelectedTabTextColor
904857 systemSheetBackground
905858 systemSheetBackgroundOpaque
906859 systemSheetBackgroundTransparent
907860 systemStaticAreaFill
908 systemSystemDetailText
909 systemTabFrontActiveText
910 systemTabFrontInactiveText
911 systemTabNonFrontActiveText
912 systemTabNonFrontInactiveText
913 systemTabNonFrontPressedText
914 systemTabPaneBackground
915861 systemToolbarBackground
916862 systemTransparent
917863 systemUtilityWindowBackgroundActive
918864 systemUtilityWindowBackgroundInactive
919 systemUtilityWindowTitleActiveText
920 systemUtilityWindowTitleInactiveText
921865 systemWhite
922 systemWhiteText
923866 systemWindowBody
924 systemWindowHeaderActiveText
925 systemWindowHeaderBackground
926 systemWindowHeaderInactiveText
927867 .DE
928868 .RE
929869 .
930 The second group of MacOS colors below are based on Apple's "semantic"
931 NScolors. On OSX 10.14 (Mojave) and later these colors change value
932 when Dark Mode is enabled. However, the change is only observable
933 when the Apple window manager is drawing to the screen. So the
934 \fBwinfo rgb\fR command will return the color coordinates used in the
935 standard Aqua mode, even if Dark Mode has been selected in the system
936 preferences. The numbered systemWindowBackgroundColors are used in
937 the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets to provide a
938 contrasting background. Each numbered color constrasts with its
939 predecessor.
870 Tk supports all of the NSColors in the macOS System ColorList. The
871 convention for naming these colors is that the Tk name is generated by
872 capitalizing the macOS name and adding the prefix "system". On OSX
873 10.14 (Mojave) and later many of these "semantic" colors will appear
874 differently depending on whether the NSWindow in which they are used has
875 the Aqua or DarkAqua appearance. The System ColorList differs between
876 releases of macOS and some colors, such as systemLinkColor and
877 systemControlAccentColor, are simulated on older systems which did not
878 provide them. All of the colors below are available on all supported
879 macOS releases, but newer systems will support additional colors.
940880 .RS
941881 .DS
942882 systemControlAccentColor
943883 systemControlTextColor
944884 systemDisabledControlTextColor
945 systemLabelColor
946 systemSelectedTextBackgroundColor
885 systemLabelColor
886 systemLinkColor
887 systemPlaceholderTextColor
888 systemSelectedTextBackgroundColor
947889 systemSelectedTextColor
890 systemSeparatorColor
948891 systemTextBackgroundColor
949 systemTextColor
892 systemTextColor
893 .DE
894 .RE
895 .
896 The numbered systemWindowBackgroundColors below
897 are used in the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets
898 to provide a contrasting background. Each numbered color constrasts
899 with its predecessor.
900 .RS
901 .DS
950902 systemWindowBackgroundColor
951903 systemWindowBackgroundColor1
952904 systemWindowBackgroundColor2
958910 .DE
959911 .RE
960912 .TP
961
962913
963914 \fBWindows\fR
964915 .
2424 Tk is loaded into a tclsh interpreter with
2525 .QW "\fBpackage require Tk\fR" ,
2626 as a conventional terminal is expected to be present in that case.
27 In TkAqua, this command is only available when stdin is \fB/dev/null\fR
28 (as is the case e.g. when the application embedding Tk is started
29 from the Mac OS X Finder).
27 In TkAqua, this command is disabled when there is a startup script
28 and stdin is \fB/dev/null\fR (as is the case e.g. when a bundled application
29 embedding Tk is started by the macOS Launcher). To enable the command
30 in that case, define the environment variable \fBTK_CONSOLE\fR. This can be
31 done by modifying the Info.plist file by adding the LSEnvironment key
32 to the main dict and setting its value to be a dict with the key \fBTK_CONSOLE\fR.
3033 .PP
3134 .TP
3235 \fBconsole eval \fIscript\fR
447447 If any normal printing characters are typed in an entry, they are
448448 inserted at the point of the insertion cursor.
449449 .IP [7]
450 The view in the entry can be adjusted by dragging with mouse button 2.
451 If mouse button 2 is clicked without moving the mouse, the selection
452 is copied into the entry at the position of the mouse cursor.
450 The view in the entry can be adjusted by dragging with the middle
451 mouse button (button 2, or button 3 in TkAqua). If the middle mouse
452 button is clicked without moving the mouse, the selection is copied
453 into the entry at the position of the mouse cursor.
453454 .IP [8]
454455 If the mouse is dragged out of the entry on the left or right sides
455456 while button 1 is pressed, the entry will automatically scroll to
33 '\"
44 '\" See the file "license.terms" for information on usage and redistribution
55 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
6 '\"
77 .TH frame n 8.4 Tk "Tk Built-In Commands"
88 .so man.macros
99 .BS
115115 \fIOption\fR may have any of the values accepted by the \fBframe\fR
116116 command.
117117 .TP
118 \fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
118 \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
119119 .
120120 Query or modify the configuration options of the widget.
121121 If no \fIoption\fR is specified, returns a list describing all of
22 '\"
33 '\" See the file "license.terms" for information on usage and redistribution
44 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5 '\"
5 '\"
66 .TH grid n 8.5 Tk "Tk Built-In Commands"
77 .so man.macros
88 .BS
1616 .PP
1717 The \fBgrid\fR command is used to communicate with the grid
1818 geometry manager that arranges widgets in rows and columns inside
19 of another window, called the geometry master (or master window).
19 of another window, called the geometry container (or container window).
2020 The \fBgrid\fR command can have any of several forms, depending
2121 on the \fIoption\fR argument:
2222 .TP
23 \fBgrid \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
24 .
25 If the first argument to \fBgrid\fR is suitable as the first slave
23 \fBgrid \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
24 .
25 If the first argument to \fBgrid\fR is suitable as the first window
2626 argument to \fBgrid configure\fR, either a window name (any value
2727 starting with \fB.\fR) or one of the characters \fBx\fR or \fB^\fR
2828 (see the \fBRELATIVE PLACEMENT\fR section below), then the command is
2929 processed in the same way as \fBgrid configure\fR.
3030 .TP
31 \fBgrid anchor \fImaster\fR ?\fIanchor\fR?
32 .
33 The anchor value controls how to place the grid within the master
31 \fBgrid anchor \fIwindow\fR ?\fIanchor\fR?
32 .
33 The anchor value controls how to place the grid within the container window
3434 when no row/column has any weight. See \fBTHE GRID ALGORITHM\fR below
3535 for further details. The default \fIanchor\fR is \fInw\fR.
3636 .TP
37 \fBgrid bbox \fImaster\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR?
37 \fBgrid bbox \fIwindow\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR?
3838 .
3939 With no arguments,
4040 the bounding box (in pixels) of the grid is returned.
4141 The return value consists of 4 integers. The first two are the pixel
42 offset from the master window (x then y) of the top-left corner of the
42 offset from the container window (x then y) of the top-left corner of the
4343 grid, and the second two integers are the width and height of the grid,
4444 also in pixels. If a single \fIcolumn\fR and \fIrow\fR is specified on
4545 the command line, then the bounding box for that cell is returned, where the
4747 arguments are specified, then the bounding box spanning the rows and columns
4848 indicated is returned.
4949 .TP
50 \fBgrid columnconfigure \fImaster index \fR?\fI\-option value...\fR?
50 \fBgrid columnconfigure \fIwindow index \fR?\fI\-option value...\fR?
5151 .
5252 Query or set the column properties of the \fIindex\fR column of the
53 geometry master, \fImaster\fR.
53 geometry container, \fIwindow\fR.
5454 The valid options are \fB\-minsize\fR, \fB\-weight\fR, \fB\-uniform\fR
5555 and \fB\-pad\fR.
5656 If one or more options are provided, then \fIindex\fR may be given as
5757 a list of column indices to which the configuration options will operate on.
5858 Indices may be integers, window names or the keyword \fIall\fR. For \fIall\fR
59 the options apply to all columns currently occupied be slave windows. For
60 a window name, that window must be a slave of this master and the options
61 apply to all columns currently occupied be the slave.
59 the options apply to all columns currently occupied be content windows. For
60 a window name, that window must be a content of this container and the options
61 apply to all columns currently occupied be the content.
6262 The \fB\-minsize\fR option sets the minimum size, in screen units,
6363 that will be permitted for this column.
6464 The \fB\-weight\fR option (an integer value)
7979 grid geometry manager requests a size from the containing window.
8080 If only an option is specified, with no value,
8181 the current value of that option is returned.
82 If only the master window and index is specified, all the current settings
82 If only the container window and index is specified, all the current settings
8383 are returned in a list of
8484 .QW "\-option value"
8585 pairs.
8686 .TP
87 \fBgrid configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
88 .
89 The arguments consist of the names of one or more slave windows
87 \fBgrid configure \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
88 .
89 The arguments consist of the names of one or more content windows
9090 followed by pairs of arguments that specify how
91 to manage the slaves.
91 to manage the content.
9292 The characters \fB\-\fR, \fBx\fR and \fB^\fR,
9393 can be specified instead of a window name to alter the default
94 location of a \fIslave\fR, as described in the \fBRELATIVE PLACEMENT\fR
94 location of a \fIwindow\fR, as described in the \fBRELATIVE PLACEMENT\fR
9595 section, below.
9696 The following options are supported:
9797 .RS
9898 .TP
9999 \fB\-column \fIn\fR
100100 .
101 Insert the slave so that it occupies the \fIn\fRth column in the grid.
101 Insert the window so that it occupies the \fIn\fRth column in the grid.
102102 Column numbers start with 0. If this option is not supplied, then the
103 slave is arranged just to the right of previous slave specified on this
103 window is arranged just to the right of previous window specified on this
104104 call to \fBgrid\fR, or column
105105 .QW 0
106 if it is the first slave. For each
107 \fBx\fR that immediately precedes the \fIslave\fR, the column position
106 if it is the first window. For each
107 \fBx\fR that immediately precedes the \fIwindow\fR, the column position
108108 is incremented by one. Thus the \fBx\fR represents a blank column
109109 for this row in the grid.
110110 .TP
111111 \fB\-columnspan \fIn\fR
112112 .
113 Insert the slave so that it occupies \fIn\fR columns in the grid.
113 Insert the window so that it occupies \fIn\fR columns in the grid.
114114 The default is one column, unless the window name is followed by a
115115 \fB\-\fR, in which case the columnspan is incremented once for each immediately
116116 following \fB\-\fR.
117117 .TP
118 \fB\-in \fIother\fR
119 .
120 Insert the slave(s) in the master
121 window given by \fIother\fR. The default is the first slave's
118 \fB\-in \fIcontainer\fR
119 .
120 Insert the window(s) in the container
121 window given by \fIcontainer\fR. The default is the first window's
122122 parent window.
123123 .TP
124124 \fB\-ipadx \fIamount\fR
125125 .
126126 The \fIamount\fR specifies how much horizontal internal padding to
127 leave on each side of the slave(s). This is space is added
128 inside the slave(s) border.
127 leave on each side of the content. This is space is added
128 inside the content border.
129129 The \fIamount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR.
130130 It defaults to 0.
131131 .TP
132132 \fB\-ipady \fIamount\fR
133133 .
134134 The \fIamount\fR specifies how much vertical internal padding to
135 leave on the top and bottom of the slave(s).
136 This space is added inside the slave(s) border.
135 leave on the top and bottom of the content.
136 This space is added inside the content border.
137137 The \fIamount\fR defaults to 0.
138138 .TP
139139 \fB\-padx \fIamount\fR
140140 .
141141 The \fIamount\fR specifies how much horizontal external padding to
142 leave on each side of the slave(s), in screen units.
142 leave on each side of the content, in screen units.
143143 \fIAmount\fR may be a list
144144 of two values to specify padding for left and right separately.
145145 The \fIamount\fR defaults to 0.
146 This space is added outside the slave(s) border.
146 This space is added outside the content border.
147147 .TP
148148 \fB\-pady \fIamount\fR
149149 .
150150 The \fIamount\fR specifies how much vertical external padding to
151 leave on the top and bottom of the slave(s), in screen units.
151 leave on the top and bottom of the content, in screen units.
152152 \fIAmount\fR may be a list
153153 of two values to specify padding for top and bottom separately.
154154 The \fIamount\fR defaults to 0.
155 This space is added outside the slave(s) border.
155 This space is added outside the content border.
156156 .TP
157157 \fB\-row \fIn\fR
158158 .
159 Insert the slave so that it occupies the \fIn\fRth row in the grid.
159 Insert the content so that it occupies the \fIn\fRth row in the grid.
160160 Row numbers start with 0. If this option is not supplied, then the
161 slave is arranged on the same row as the previous slave specified on this
161 content is arranged on the same row as the previous content specified on this
162162 call to \fBgrid\fR, or the next row after the highest occupied row
163 if this is the first slave.
163 if this is the first content.
164164 .TP
165165 \fB\-rowspan \fIn\fR
166166 .
167 Insert the slave so that it occupies \fIn\fR rows in the grid.
167 Insert the content so that it occupies \fIn\fR rows in the grid.
168168 The default is one row. If the next \fBgrid\fR command contains
169 \fB^\fR characters instead of \fIslaves\fR that line up with the columns
170 of this \fIslave\fR, then the \fBrowspan\fR of this \fIslave\fR is
169 \fB^\fR characters instead of \fIcontent\fR that line up with the columns
170 of this \fIcontent\fR, then the \fBrowspan\fR of this \fIcontent\fR is
171171 extended by one.
172172 .TP
173173 \fB\-sticky \fIstyle\fR
174174 .
175 If a slave's cell is larger than its requested dimensions, this
176 option may be used to position (or stretch) the slave within its cell.
175 If a content's cell is larger than its requested dimensions, this
176 option may be used to position (or stretch) the content within its cell.
177177 \fIStyle\fR is a string that contains zero or more of the characters
178178 \fBn\fR, \fBs\fR, \fBe\fR or \fBw\fR.
179179 The string can optionally contains spaces or
180180 commas, but they are ignored. Each letter refers to a side (north, south,
181 east, or west) that the slave will
181 east, or west) that the content will
182182 .QW stick
183183 to. If both \fBn\fR and \fBs\fR (or \fBe\fR and \fBw\fR) are
184 specified, the slave will be stretched to fill the entire
184 specified, the content will be stretched to fill the entire
185185 height (or width) of its cavity. The \fB\-sticky\fR option subsumes the
186186 combination of \fB\-anchor\fR and \fB\-fill\fR that is used by \fBpack\fR.
187187 The default is
188188 .QW "" ,
189 which causes the slave to be centered in its cavity, at its requested size.
189 which causes the content to be centered in its cavity, at its requested size.
190190 .LP
191 If any of the slaves are already managed by the geometry manager
191 If any of the content is already managed by the geometry manager
192192 then any unspecified options for them retain their previous values rather
193193 than receiving default values.
194194 .RE
195195 .TP
196 \fBgrid forget \fIslave \fR?\fIslave ...\fR?
197 .
198 Removes each of the \fIslave\fRs from grid for its
199 master and unmaps their windows.
200 The slaves will no longer be managed by the grid geometry manager.
196 \fBgrid forget \fIwindow \fR?\fIwindow ...\fR?
197 .
198 Removes each of the \fIwindow\fRs from grid for its
199 container and unmaps their windows.
200 The content will no longer be managed by the grid geometry manager.
201201 The configuration options for that window are forgotten, so that if the
202 slave is managed once more by the grid geometry manager, the initial
202 window is managed once more by the grid geometry manager, the initial
203203 default settings are used.
204204 .TP
205 \fBgrid info \fIslave\fR
205 \fBgrid info \fIwindow\fR
206206 .
207207 Returns a list whose elements are the current configuration state of
208 the slave given by \fIslave\fR in the same option-value form that
208 the content given by \fIwindow\fR in the same option-value form that
209209 might be specified to \fBgrid configure\fR.
210210 The first two elements of the list are
211 .QW "\fB\-in \fImaster\fR"
212 where \fImaster\fR is the slave's master.
213 .TP
214 \fBgrid location \fImaster x y\fR
215 .
216 Given \fIx\fR and \fIy\fR values in screen units relative to the master window,
211 .QW "\fB\-in \fIcontainer\fR"
212 where \fIcontainer\fR is the windows's container window.
213 .TP
214 \fBgrid location \fIwindow x y\fR
215 .
216 Given \fIx\fR and \fIy\fR values in screen units relative to the container window,
217217 the column and row number at that \fIx\fR and \fIy\fR location is returned.
218218 For locations that are above or to the left of the grid, \fB\-1\fR is
219219 returned.
220220 .TP
221 \fBgrid propagate \fImaster\fR ?\fIboolean\fR?
221 \fBgrid propagate \fIwindow\fR ?\fIboolean\fR?
222222 .
223223 If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR
224 then propagation is enabled for \fImaster\fR, which must be a window
224 then propagation is enabled for \fIwindow\fR, which must be a window
225225 name (see \fBGEOMETRY PROPAGATION\fR below).
226226 If \fIboolean\fR has a false boolean value then propagation is
227 disabled for \fImaster\fR.
227 disabled for \fIwindow\fR.
228228 In either of these cases an empty string is returned.
229229 If \fIboolean\fR is omitted then the command returns \fB0\fR or
230230 \fB1\fR to indicate whether propagation is currently enabled
231 for \fImaster\fR.
231 for \fIwindow\fR.
232232 Propagation is enabled by default.
233233 .TP
234 \fBgrid rowconfigure \fImaster index \fR?\fI\-option value...\fR?
234 \fBgrid rowconfigure \fIwindow index \fR?\fI\-option value...\fR?
235235 .
236236 Query or set the row properties of the \fIindex\fR row of the
237 geometry master, \fImaster\fR.
237 geometry window, \fIwindow\fR.
238238 The valid options are \fB\-minsize\fR, \fB\-weight\fR, \fB\-uniform\fR
239239 and \fB\-pad\fR.
240240 If one or more options are provided, then \fIindex\fR may be given as
241241 a list of row indices to which the configuration options will operate on.
242242 Indices may be integers, window names or the keyword \fIall\fR. For \fIall\fR
243 the options apply to all rows currently occupied be slave windows. For
244 a window name, that window must be a slave of this master and the options
245 apply to all rows currently occupied be the slave.
243 the options apply to all rows currently occupied by content windows. For
244 a window name, that window must be a content window of this container and the options
245 apply to all rows currently occupied by the container window.
246246 The \fB\-minsize\fR option sets the minimum size, in screen units,
247247 that will be permitted for this row.
248248 The \fB\-weight\fR option (an integer value)
263263 grid geometry manager requests a size from the containing window.
264264 If only an option is specified, with no value,
265265 the current value of that option is returned.
266 If only the master window and index is specified, all the current settings
266 If only the container window and index is specified, all the current settings
267267 are returned in a list of
268268 .QW "-option value"
269269 pairs.
270270 .TP
271 \fBgrid remove \fIslave \fR?\fIslave ...\fR?
272 .
273 Removes each of the \fIslave\fRs from grid for its
274 master and unmaps their windows.
275 The slaves will no longer be managed by the grid geometry manager.
271 \fBgrid remove \fIwindow \fR?\fIwindow ...\fR?
272 .
273 Removes each of the \fIwindow\fRs from grid for its
274 container and unmaps their windows.
275 The content will no longer be managed by the grid geometry manager.
276276 However, the configuration options for that window are remembered,
277 so that if the
278 slave is managed once more by the grid geometry manager, the previous
279 values are retained.
280 .TP
281 \fBgrid size \fImaster\fR
282 .
283 Returns the size of the grid (in columns then rows) for \fImaster\fR.
284 The size is determined either by the \fIslave\fR occupying the largest
277 so that if the content window is managed once more by the grid
278 geometry manager, the previous values are retained.
279 .TP
280 \fBgrid size \fIcontainer\fR
281 .
282 Returns the size of the grid (in columns then rows) for \fIcontainer\fR.
283 The size is determined either by the \fIcontent\fR occupying the largest
285284 row or column, or the largest column or row with a \fB\-minsize\fR,
286285 \fB\-weight\fR, or \fB\-pad\fR that is non-zero.
287286 .TP
288 \fBgrid slaves \fImaster\fR ?\fI\-option value\fR?
289 .
290 If no options are supplied, a list of all of the slaves in \fImaster\fR
291 are returned, most recently manages first.
287 \fBgrid slaves \fIwindow\fR ?\fI\-option value\fR?
288 .
289 If no options are supplied, a list of all of the content in \fIwindow\fR
290 are returned, most recently managed first.
292291 \fIOption\fR can be either \fB\-row\fR or \fB\-column\fR which
293 causes only the slaves in the row (or column) specified by \fIvalue\fR
292 causes only the content in the row (or column) specified by \fIvalue\fR
294293 to be returned.
294 .VS "TIP 581"
295 .TP
296 \fBgrid content \fIwindow\fR ?\fI\-option value\fR?
297 .
298 Synonym for . \fBgrid slaves \fIwindow\fR ?\fI\-option value\fR?
299 .VE "TIP 581"
295300 .SH "RELATIVE PLACEMENT"
296301 .PP
297302 The \fBgrid\fR command contains a limited set of capabilities that
298303 permit layouts to be created without specifying the row and column
299 information for each slave. This permits slaves to be rearranged,
304 information for each content. This permits content to be rearranged,
300305 added, or removed without the need to explicitly specify row and
301306 column information.
302 When no column or row information is specified for a \fIslave\fR,
307 When no column or row information is specified for a \fIcontent\fR,
303308 default values are chosen for
304309 \fB\-column\fR, \fB\-row\fR, \fB\-columnspan\fR and \fB\-rowspan\fR
305 at the time the \fIslave\fR is managed. The values are chosen
306 based upon the current layout of the grid, the position of the \fIslave\fR
307 relative to other \fIslave\fRs in the same grid command, and the presence
310 at the time the \fIcontent\fR is managed. The values are chosen
311 based upon the current layout of the grid, the position of the \fIcontent\fR
312 relative to other \fIcontent\fRs in the same grid command, and the presence
308313 of the characters \fB\-\fR, \fBx\fR, and \fB^\fR in \fBgrid\fR
309 command where \fIslave\fR names are normally expected.
314 command where \fIcontent\fR names are normally expected.
310315 .RS
311316 .TP
312317 \fB\-\fR
313318 .
314 This increases the \fB\-columnspan\fR of the \fIslave\fR to the left. Several
319 This increases the \fB\-columnspan\fR of the \fIcontent\fR to the left. Several
315320 \fB\-\fR's in a row will successively increase the number of columns spanned. A \fB\-\fR
316 may not follow a \fB^\fR or a \fBx\fR, nor may it be the first \fIslave\fR
321 may not follow a \fB^\fR or a \fBx\fR, nor may it be the first \fIcontent\fR
317322 argument to \fBgrid configure\fR.
318323 .TP
319324 \fBx\fR
320325 .
321 This leaves an empty column between the \fIslave\fR on the left and
322 the \fIslave\fR on the right.
326 This leaves an empty column between the \fIcontent\fR on the left and
327 the \fIcontent\fR on the right.
323328 .TP
324329 \fB^\fR
325330 .
326 This extends the \fB\-rowspan\fR of the \fIslave\fR above the \fB^\fR's
331 This extends the \fB\-rowspan\fR of the \fIcontent\fR above the \fB^\fR's
327332 in the grid. The number of \fB^\fR's in a row must match the number of
328 columns spanned by the \fIslave\fR above it.
333 columns spanned by the \fIcontent\fR above it.
329334 .RE
330335 .SH "THE GRID ALGORITHM"
331336 .PP
332 The grid geometry manager lays out its slaves in three steps.
333 In the first step, the minimum size needed to fit all of the slaves
337 The grid geometry manager lays out its content in three steps.
338 In the first step, the minimum size needed to fit all of the content
334339 is computed, then (if propagation is turned on), a request is made
335 of the master window to become that size.
340 of the container window to become that size.
336341 In the second step, the requested size is compared against the actual size
337 of the master. If the sizes are different, then spaces is added to or taken
342 of the container. If the sizes are different, then spaces is added to or taken
338343 away from the layout as needed.
339 For the final step, each slave is positioned in its row(s) and column(s)
344 For the final step, each content is positioned in its row(s) and column(s)
340345 based on the setting of its \fIsticky\fR flag.
341346 .PP
342347 To compute the minimum size of a layout, the grid geometry manager
343 first looks at all slaves whose \fB\-columnspan\fR and \fB\-rowspan\fR values are one,
348 first looks at all content whose \fB\-columnspan\fR and \fB\-rowspan\fR values are one,
344349 and computes the nominal size of each row or column to be either the
345350 \fIminsize\fR for that row or column, or the sum of the \fIpad\fRding
346 plus the size of the largest slave, whichever is greater. After that
351 plus the size of the largest content, whichever is greater. After that
347352 the rows or columns in each uniform group adapt to each other. Then
348 the slaves whose row-spans or column-spans are greater than one are
353 the content whose row-spans or column-spans are greater than one are
349354 examined. If a group of rows or columns need to be increased in size
350 in order to accommodate these slaves, then extra space is added to each
355 in order to accommodate these content, then extra space is added to each
351356 row or column in the group according to its \fIweight\fR. For each
352357 group whose weights are all zero, the additional space is apportioned
353358 equally.
368373 same weight, then each row or column will have the same size as the
369374 largest row or column in the group.
370375 .PP
371 For masters whose size is larger than the requested layout, the additional
376 For containers whose size is larger than the requested layout, the additional
372377 space is apportioned according to the row and column weights. If all of
373 the weights are zero, the layout is placed within its master according to
378 the weights are zero, the layout is placed within its container according to
374379 the \fIanchor\fR value.
375 For masters whose size is smaller than the requested layout, space is taken
380 For containers whose size is smaller than the requested layout, space is taken
376381 away from columns and rows according to their weights. However, once a
377382 column or row shrinks to its minsize, its weight is taken to be zero.
378383 If more space needs to be removed from a layout than would be permitted, as
380385 placed and clipped according to the \fIanchor\fR value.
381386 .SH "GEOMETRY PROPAGATION"
382387 .PP
383 The grid geometry manager normally computes how large a master must be to
384 just exactly meet the needs of its slaves, and it sets the
385 requested width and height of the master to these dimensions.
388 The grid geometry manager normally computes how large a container must be to
389 just exactly meet the needs of its content, and it sets the
390 requested width and height of the container to these dimensions.
386391 This causes geometry information to propagate up through a
387392 window hierarchy to a top-level window so that the entire
388393 sub-tree sizes itself to fit the needs of the leaf windows.
389394 However, the \fBgrid propagate\fR command may be used to
390 turn off propagation for one or more masters.
395 turn off propagation for one or more containers.
391396 If propagation is disabled then grid will not set
392 the requested width and height of the master window.
393 This may be useful if, for example, you wish for a master
397 the requested width and height of the container window.
398 This may be useful if, for example, you wish for a container
394399 window to have a fixed size that you specify.
395 .SH "RESTRICTIONS ON MASTER WINDOWS"
396 .PP
397 The master for each slave must either be the slave's parent
398 (the default) or a descendant of the slave's parent.
400 .SH "RESTRICTIONS ON CONTAINER WINDOWS"
401 .PP
402 The container for each content must either be the content's parent
403 (the default) or a descendant of the content's parent.
399404 This restriction is necessary to guarantee that the
400 slave can be placed over any part of its master that is
401 visible without danger of the slave being clipped by its parent.
402 In addition, all slaves in one call to \fBgrid\fR must have the same master.
405 content can be placed over any part of its container that is
406 visible without danger of the content being clipped by its parent.
407 In addition, all content in one call to \fBgrid\fR must have the same container.
403408 .SH "STACKING ORDER"
404409 .PP
405 If the master for a slave is not its parent then you must make sure
406 that the slave is higher in the stacking order than the master.
407 Otherwise the master will obscure the slave and it will appear as
408 if the slave has not been managed correctly.
409 The easiest way to make sure the slave is higher than the master is
410 to create the master window first: the most recently created window
410 If the container for a content is not its parent then you must make sure
411 that the content is higher in the stacking order than the container.
412 Otherwise the container will obscure the content and it will appear as
413 if the content has not been managed correctly.
414 The easiest way to make sure the content is higher than the container is
415 to create the container window first: the most recently created window
411416 will be highest in the stacking order.
412417 .SH CREDITS
413418 .PP
107107 \fIOption\fR may have any of the values accepted by the \fBlabelframe\fR
108108 command.
109109 .TP
110 \fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
110 \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
111111 Query or modify the configuration options of the widget.
112112 If no \fIoption\fR is specified, returns a list describing all of
113113 the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
1010 .SH NAME
1111 safe::loadTk \- Load Tk into a safe interpreter.
1212 .SH SYNOPSIS
13 \fBsafe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR?
13 \fBsafe::loadTk \fIchild\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR?
1414 .BE
1515 .SH DESCRIPTION
1616 .PP
4242 Please read the \fBsafe\fR manual page for Tcl to learn about the basic
4343 security considerations for Safe Tcl.
4444 .PP
45 \fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the master
45 \fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the parent
4646 interpreter to the virtual access path of the safe interpreter so that
4747 auto-loading will work in the safe interpreter.
4848 .PP
49 Tk initialization is now safe with respect to not trusting the slave's state
50 for startup. \fBsafe::loadTk\fR registers the slave's name so when the Tk
51 initialization (\fBTk_SafeInit\fR) is called and in turn calls the master's
49 Tk initialization is now safe with respect to not trusting the child's state
50 for startup. \fBsafe::loadTk\fR registers the child's name so when the Tk
51 initialization (\fBTk_SafeInit\fR) is called and in turn calls the parent's
5252 \fBsafe::InitTk\fR it will return the desired \fBargv\fR equivalent
5353 (\fB\-use\fR \fIwindowId\fR, correct \fB\-display\fR, etc.)
5454 .PP
6161 .SH "SEE ALSO"
6262 safe(n), interp(n), library(n), load(n), package(n), source(n), unknown(n)
6363 .SH KEYWORDS
64 alias, auto-loading, auto_mkindex, load, master interpreter, safe
65 interpreter, slave interpreter, source
64 alias, auto-loading, auto_mkindex, load, parent interpreter, safe
65 interpreter, child interpreter, source
6666 '\" Local Variables:
6767 '\" mode: nroff
6868 '\" End:
3939 entries will number starting at 1. The default
4040 menu bindings arrange for the menu to be torn off when the tear-off
4141 entry is invoked.
42 This option is ignored under Aqua/Mac OS X, where menus cannot
42 This option is ignored under Aqua/MacOS, where menus cannot
4343 be torn off.
4444 .OP \-tearoffcommand tearOffCommand TearOffCommand
4545 If this option has a non-empty value, then it specifies a Tcl command
5353 create a new menu \fB.x.tearoff1\fR, then the command
5454 .QW "\fBa b .x.y .x.tearoff1\fR"
5555 will be invoked.
56 This option is ignored under Aqua/Mac OS X, where menus cannot
56 This option is ignored under Aqua/MacOS, where menus cannot
5757 be torn off.
5858 .OP \-title title Title
5959 The string will be used to title the window created when this menu is
522522 \fB\-activebackground \fIvalue\fR
523523 .
524524 Specifies a background color to use for displaying this entry when it
525 is active.
526 If this option is specified as an empty string (the default), then the
525 is active. This option is ignored on Aqua/MacOS.
526 If it is specified as an empty string (the default), then the
527527 \fB\-activebackground\fR option for the overall menu is used.
528528 If the \fBtk_strictMotif\fR variable has been set to request strict
529529 Motif compliance, then this option is ignored and the \fB\-background\fR
533533 \fB\-activeforeground \fIvalue\fR
534534 .
535535 Specifies a foreground color to use for displaying this entry when it
536 is active.
536 is active. This option is ignored on Aqua/macOS.
537537 If this option is specified as an empty string (the default), then the
538538 \fB\-activeforeground\fR option for the overall menu is used.
539539 This option is not available for separator or tear-off entries.
551551 .
552552 Specifies a background color to use for displaying this entry when it
553553 is in the normal state (neither active nor disabled).
554 If this option is specified as an empty string (the default), then the
554 This option is ignored on Aqua/macOS.
555 If it is specified as an empty string (the default), then the
555556 \fB\-background\fR option for the overall menu is used.
556557 This option is not available for separator or tear-off entries.
557558 .TP
572573 When this option is zero, the entry appears below the previous entry. When
573574 this option is one, the entry appears at the top of a new column in the
574575 menu.
575 This option is ignored on Aqua/Mac OS X, where menus are always a single
576 This option is ignored on Aqua/macOS, where menus are always a single
576577 column.
577578 .TP
578579 \fB\-command \fIvalue\fR
602603 .
603604 Specifies a foreground color to use for displaying this entry when it
604605 is in the normal state (neither active nor disabled).
605 If this option is specified as an empty string (the default), then the
606 This option is ignored on Aqua/macOS.
607 If it is specified as an empty string (the default), then the
606608 \fB\-foreground\fR option for the overall menu is used.
607609 This option is not available for separator or tear-off entries.
608610 .TP
33 '\"
44 '\" See the file "license.terms" for information on usage and redistribution
55 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
6 '\"
77 .TH pack n 4.0 Tk "Tk Built-In Commands"
88 .so man.macros
99 .BS
2121 The \fBpack\fR command can have any of several forms, depending
2222 on the \fIoption\fR argument:
2323 .TP
24 \fBpack \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
24 \fBpack \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
2525 If the first argument to \fBpack\fR is a window name (any value
2626 starting with
2727 .QW . ),
2828 then the command is processed in the same way as \fBpack configure\fR.
2929 .TP
30 \fBpack configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
31 The arguments consist of the names of one or more slave windows
30 \fBpack configure \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
31 The arguments consist of the names of one or more content windows
3232 followed by pairs of arguments that specify how
33 to manage the slaves.
33 to manage the content.
3434 See \fBTHE PACKER ALGORITHM\fR below for details on how the options
3535 are used by the packer.
3636 The following options are supported:
3838 .TP
3939 \fB\-after \fIother\fR
4040 \fIOther\fR must the name of another window.
41 Use its master as the master for the slaves, and insert
42 the slaves just after \fIother\fR in the packing order.
41 Use its container as the container for the content, and insert
42 the content just after \fIother\fR in the packing order.
4343 .TP
4444 \fB\-anchor \fIanchor\fR
4545 \fIAnchor\fR must be a valid anchor position such as \fBn\fR
46 or \fBsw\fR; it specifies where to position each slave in its
46 or \fBsw\fR; it specifies where to position each content in its
4747 parcel.
4848 Defaults to \fBcenter\fR.
4949 .TP
5050 \fB\-before \fIother\fR
5151 \fIOther\fR must the name of another window.
52 Use its master as the master for the slaves, and insert
53 the slaves just before \fIother\fR in the packing order.
52 Use its container as the container for the content, and insert
53 the content just before \fIother\fR in the packing order.
5454 .TP
5555 \fB\-expand \fIboolean\fR
56 Specifies whether the slaves should be expanded to consume
57 extra space in their master.
56 Specifies whether the content should be expanded to consume
57 extra space in their container.
5858 \fIBoolean\fR may have any proper boolean value, such as \fB1\fR
5959 or \fBno\fR.
6060 Defaults to 0.
6161 .TP
6262 \fB\-fill \fIstyle\fR
63 If a slave's parcel is larger than its requested dimensions, this
64 option may be used to stretch the slave.
63 If a content's parcel is larger than its requested dimensions, this
64 option may be used to stretch the content.
6565 \fIStyle\fR must have one of the following values:
6666 .RS
6767 .TP
6868 \fBnone\fR
69 Give the slave its requested dimensions plus any internal padding
69 Give the content its requested dimensions plus any internal padding
7070 requested with \fB\-ipadx\fR or \fB\-ipady\fR. This is the default.
7171 .TP
7272 \fBx\fR
73 Stretch the slave horizontally to fill the entire width of its
73 Stretch the content horizontally to fill the entire width of its
7474 parcel (except leave external padding as specified by \fB\-padx\fR).
7575 .TP
7676 \fBy\fR
77 Stretch the slave vertically to fill the entire height of its
77 Stretch the content vertically to fill the entire height of its
7878 parcel (except leave external padding as specified by \fB\-pady\fR).
7979 .TP
8080 \fBboth\fR
81 Stretch the slave both horizontally and vertically.
81 Stretch the content both horizontally and vertically.
8282 .RE
8383 .TP
84 \fB\-in \fIother\fR
85 Insert the slave(s) at the end of the packing order for the master
86 window given by \fIother\fR.
84 \fB\-in \fIcontainer\fR
85 Insert the window at the end of the packing order for the container
86 window given by \fIcontainer\fR.
8787 .TP
8888 \fB\-ipadx \fIamount\fR
8989 \fIAmount\fR specifies how much horizontal internal padding to
90 leave on each side of the slave(s).
90 leave on each side of the content.
9191 \fIAmount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR.
9292 It defaults to 0.
9393 .TP
9494 \fB\-ipady \fIamount\fR
9595 \fIAmount\fR specifies how much vertical internal padding to
96 leave on each side of the slave(s).
96 leave on each side of the content.
9797 \fIAmount\fR defaults to 0.
9898 .TP
9999 \fB\-padx \fIamount\fR
100100 \fIAmount\fR specifies how much horizontal external padding to
101 leave on each side of the slave(s). \fIAmount\fR may be a list
101 leave on each side of the content. \fIAmount\fR may be a list
102102 of two values to specify padding for left and right separately.
103103 \fIAmount\fR defaults to 0.
104104 .TP
105105 \fB\-pady \fIamount\fR
106106 \fIAmount\fR specifies how much vertical external padding to
107 leave on each side of the slave(s). \fIAmount\fR may be a list
107 leave on each side of the content. \fIAmount\fR may be a list
108108 of two values to specify padding for top and bottom separately.
109109 \fIAmount\fR defaults to 0.
110110 .TP
111111 \fB\-side \fIside\fR
112 Specifies which side of the master the slave(s) will be packed against.
112 Specifies which side of the container the content will be packed against.
113113 Must be \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR.
114114 Defaults to \fBtop\fR.
115115 .LP
116116 If no \fB\-in\fR, \fB\-after\fR or \fB\-before\fR option is specified
117 then each of the slaves will be inserted at the end of the packing list
117 then each of the content will be inserted at the end of the packing list
118118 for its parent unless it is already managed by the packer (in which
119119 case it will be left where it is).
120 If one of these options is specified then all the slaves will be
120 If one of these options is specified then all the content will be
121121 inserted at the specified point.
122 If any of the slaves are already managed by the geometry manager
122 If any of the content are already managed by the geometry manager
123123 then any unspecified options for them retain their previous values rather
124124 than receiving default values.
125125 .RE
126126 .TP
127 \fBpack forget \fIslave \fR?\fIslave ...\fR?
128 Removes each of the \fIslave\fRs from the packing order for its
129 master and unmaps their windows.
130 The slaves will no longer be managed by the packer.
131 .TP
132 \fBpack info \fIslave\fR
127 \fBpack forget \fIwindow \fR?\fIwindow ...\fR?
128 Removes each of the \fIwindow\fRs from the packing order for its
129 container and unmaps their windows.
130 The content will no longer be managed by the packer.
131 .TP
132 \fBpack info \fIwindow\fR
133133 Returns a list whose elements are the current configuration state of
134 the slave given by \fIslave\fR in the same option-value form that
134 the window given by \fIwindow\fR in the same option-value form that
135135 might be specified to \fBpack configure\fR.
136136 The first two elements of the list are
137 .QW "\fB\-in \fImaster\fR"
138 where \fImaster\fR is the slave's master.
139 .TP
140 \fBpack propagate \fImaster\fR ?\fIboolean\fR?
137 .QW "\fB\-in \fIcontainer\fR"
138 where \fIcontainer\fR is the window's container.
139 .TP
140 \fBpack propagate \fIcontainer\fR ?\fIboolean\fR?
141141 If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR
142 then propagation is enabled for \fImaster\fR, which must be a window
142 then propagation is enabled for \fIcontainer\fR, which must be a window
143143 name (see \fBGEOMETRY PROPAGATION\fR below).
144144 If \fIboolean\fR has a false boolean value then propagation is
145 disabled for \fImaster\fR.
145 disabled for \fIcontainer\fR.
146146 In either of these cases an empty string is returned.
147147 If \fIboolean\fR is omitted then the command returns \fB0\fR or
148148 \fB1\fR to indicate whether propagation is currently enabled
149 for \fImaster\fR.
149 for \fIcontainer\fR.
150150 Propagation is enabled by default.
151151 .TP
152 \fBpack slaves \fImaster\fR
153 Returns a list of all of the slaves in the packing order for \fImaster\fR.
154 The order of the slaves in the list is the same as their order in
152 \fBpack slaves \fIwindow\fR
153 Returns a list of all of the content windows in the packing order for \fIwindow\fR.
154 The order of the content windows in the list is the same as their order in
155155 the packing order.
156 If \fImaster\fR has no slaves then an empty string is returned.
156 If \fIwindow\fR has no content then an empty string is returned.
157 .VS "TIP 581"
158 .TP
159 \fBpack content \fIwindow\fR
160 .
161 Synonym for . \fBpack slaves \fIwindow\fR
162 .VE "TIP 581"
157163 .SH "THE PACKER ALGORITHM"
158164 .PP
159 For each master the packer maintains an ordered list of slaves
160 called the \fIpacking list\fR.
165 For each container the packer maintains an ordered list of content
166 windows called the \fIpacking list\fR.
161167 The \fB\-in\fR, \fB\-after\fR, and \fB\-before\fR configuration
162 options are used to specify the master for each slave and the slave's
168 options are used to specify the container for each content and the content's
163169 position in the packing list.
164 If none of these options is given for a slave then the slave
170 If none of these options is given for a content then the content
165171 is added to the end of the packing list for its parent.
166172 .PP
167 The packer arranges the slaves for a master by scanning the
173 The packer arranges the content windows for a container by scanning the
168174 packing list in order.
169 At the time it processes each slave, a rectangular area within
170 the master is still unallocated.
171 This area is called the \fIcavity\fR; for the first slave it
172 is the entire area of the master.
173 .PP
174 For each slave the packer carries out the following steps:
175 At the time it processes each content, a rectangular area within
176 the container is still unallocated.
177 This area is called the \fIcavity\fR; for the first content it
178 is the entire area of the container.
179 .PP
180 For each content the packer carries out the following steps:
175181 .IP [1]
176 The packer allocates a rectangular \fIparcel\fR for the slave
177 along the side of the cavity given by the slave's \fB\-side\fR option.
182 The packer allocates a rectangular \fIparcel\fR for the content
183 along the side of the cavity given by the content's \fB\-side\fR option.
178184 If the side is top or bottom then the width of the parcel is
179185 the width of the cavity and its height is the requested height
180 of the slave plus the \fB\-ipady\fR and \fB\-pady\fR options.
186 of the content plus the \fB\-ipady\fR and \fB\-pady\fR options.
181187 For the left or right side the height of the parcel is
182188 the height of the cavity and the width is the requested width
183 of the slave plus the \fB\-ipadx\fR and \fB\-padx\fR options.
189 of the content plus the \fB\-ipadx\fR and \fB\-padx\fR options.
184190 The parcel may be enlarged further because of the \fB\-expand\fR
185191 option (see \fBEXPANSION\fR below)
186192 .IP [2]
187 The packer chooses the dimensions of the slave.
188 The width will normally be the slave's requested width plus
193 The packer chooses the dimensions of the content.
194 The width will normally be the content's requested width plus
189195 twice its \fB\-ipadx\fR option and the height will normally be
190 the slave's requested height plus twice its \fB\-ipady\fR
196 the content's requested height plus twice its \fB\-ipady\fR
191197 option.
192198 However, if the \fB\-fill\fR option is \fBx\fR or \fBboth\fR
193 then the width of the slave is expanded to fill the width of the parcel,
199 then the width of the content is expanded to fill the width of the parcel,
194200 minus twice the \fB\-padx\fR option.
195201 If the \fB\-fill\fR option is \fBy\fR or \fBboth\fR
196 then the height of the slave is expanded to fill the width of the parcel,
202 then the height of the content is expanded to fill the width of the parcel,
197203 minus twice the \fB\-pady\fR option.
198204 .IP [3]
199 The packer positions the slave over its parcel.
200 If the slave is smaller than the parcel then the \fB\-anchor\fR
201 option determines where in the parcel the slave will be placed.
205 The packer positions the content over its parcel.
206 If the content is smaller than the parcel then the \fB\-anchor\fR
207 option determines where in the parcel the content will be placed.
202208 If \fB\-padx\fR or \fB\-pady\fR is non-zero, then the given
203209 amount of external padding will always be left between the
204 slave and the edges of the parcel.
205 .PP
206 Once a given slave has been packed, the area of its parcel
210 content and the edges of the parcel.
211 .PP
212 Once a given content has been packed, the area of its parcel
207213 is subtracted from the cavity, leaving a smaller rectangular
208 cavity for the next slave.
209 If a slave does not use all of its parcel, the unused space
210 in the parcel will not be used by subsequent slaves.
214 cavity for the next content.
215 If a content does not use all of its parcel, the unused space
216 in the parcel will not be used by subsequent content.
211217 If the cavity should become too small to meet the needs of
212 a slave then the slave will be given whatever space is
218 a content then the content will be given whatever space is
213219 left in the cavity.
214 If the cavity shrinks to zero size, then all remaining slaves
220 If the cavity shrinks to zero size, then all remaining content
215221 on the packing list will be unmapped from the screen until
216 the master window becomes large enough to hold them again.
222 the container window becomes large enough to hold them again.
217223 .SS "EXPANSION"
218224 .PP
219 If a master window is so large that there will be extra space
220 left over after all of its slaves have been packed, then the
221 extra space is distributed uniformly among all of the slaves
225 If a container window is so large that there will be extra space
226 left over after all of its content have been packed, then the
227 extra space is distributed uniformly among all of the content
222228 for which the \fB\-expand\fR option is set.
223229 Extra horizontal space is distributed among the expandable
224 slaves whose \fB\-side\fR is \fBleft\fR or \fBright\fR,
230 content whose \fB\-side\fR is \fBleft\fR or \fBright\fR,
225231 and extra vertical space is distributed among the expandable
226 slaves whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR.
232 content whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR.
227233 .SS "GEOMETRY PROPAGATION"
228234 .PP
229 The packer normally computes how large a master must be to
230 just exactly meet the needs of its slaves, and it sets the
231 requested width and height of the master to these dimensions.
235 The packer normally computes how large a container must be to
236 just exactly meet the needs of its content, and it sets the
237 requested width and height of the container to these dimensions.
232238 This causes geometry information to propagate up through a
233239 window hierarchy to a top-level window so that the entire
234240 sub-tree sizes itself to fit the needs of the leaf windows.
235241 However, the \fBpack propagate\fR command may be used to
236 turn off propagation for one or more masters.
242 turn off propagation for one or more containers.
237243 If propagation is disabled then the packer will not set
238244 the requested width and height of the packer.
239 This may be useful if, for example, you wish for a master
245 This may be useful if, for example, you wish for a container
240246 window to have a fixed size that you specify.
241 .SH "RESTRICTIONS ON MASTER WINDOWS"
242 .PP
243 The master for each slave must either be the slave's parent
244 (the default) or a descendant of the slave's parent.
247 .SH "RESTRICTIONS ON CONTAINER WINDOWS"
248 .PP
249 The container for each content must either be the content's parent
250 (the default) or a descendant of the content's parent.
245251 This restriction is necessary to guarantee that the
246 slave can be placed over any part of its master that is
247 visible without danger of the slave being clipped by its parent.
252 content can be placed over any part of its container that is
253 visible without danger of the content being clipped by its parent.
248254 .SH "PACKING ORDER"
249255 .PP
250 If the master for a slave is not its parent then you must make sure
251 that the slave is higher in the stacking order than the master.
252 Otherwise the master will obscure the slave and it will appear as
253 if the slave has not been packed correctly.
254 The easiest way to make sure the slave is higher than the master is
255 to create the master window first: the most recently created window
256 If the container for a content is not its parent then you must make sure
257 that the content is higher in the stacking order than the container.
258 Otherwise the container will obscure the content and it will appear as
259 if the content has not been packed correctly.
260 The easiest way to make sure the content is higher than the container is
261 to create the container window first: the most recently created window
256262 will be highest in the stacking order.
257263 Or, you can use the \fBraise\fR and \fBlower\fR commands to change
258 the stacking order of either the master or the slave.
264 the stacking order of either the container or the content.
259265 .SH EXAMPLE
260266 .PP
261267 .CS
329329 fill, and the containing toplevel is resized), space is added to the final
330330 (rightmost or bottommost) pane in the window.
331331 .PP
332 Unlike slave windows managed by e.g. pack or grid, the panes managed by a
332 Unlike child windows managed by e.g. pack or grid, the panes managed by a
333333 panedwindow do not change width or height to accommodate changes in the
334334 requested widths or heights of the panes, once these have become mapped.
335335 Therefore it may be advisable, particularly when creating layouts
33 '\"
44 '\" See the file "license.terms" for information on usage and redistribution
55 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
6 '\"
77 .TH place n "" Tk "Tk Built-In Commands"
88 .so man.macros
99 .BS
1717 .PP
1818 The placer is a geometry manager for Tk.
1919 It provides simple fixed placement of windows, where you specify
20 the exact size and location of one window, called the \fIslave\fR,
21 within another window, called the \fImaster\fR.
20 the exact size and location of one window, called the \fIcontent\fR,
21 within another window, called the \fIcontainer\fR.
2222 The placer also provides rubber-sheet placement, where you specify the
23 size and location of the slave in terms of the dimensions of
24 the master, so that the slave changes size and location
25 in response to changes in the size of the master.
23 size and location of the content in terms of the dimensions of
24 the container, so that the content changes size and location
25 in response to changes in the size of the container.
2626 Lastly, the placer allows you to mix these styles of placement so
27 that, for example, the slave has a fixed width and height but is
28 centered inside the master.
27 that, for example, the content has a fixed width and height but is
28 centered inside the container.
2929 .PP
3030 .TP
3131 \fBplace \fIwindow option value \fR?\fIoption value ...\fR?
32 Arrange for the placer to manage the geometry of a slave whose
32 Arrange for the placer to manage the geometry of a content whose
3333 pathName is \fIwindow\fR. The remaining arguments consist of one or
3434 more \fIoption\-value\fR pairs that specify the way in which
3535 \fIwindow\fR's geometry is managed. \fIOption\fR may have any of the
3636 values accepted by the \fBplace configure\fR command.
3737 .TP
3838 \fBplace configure \fIwindow \fR?\fIoption\fR? ?\fIvalue option value ...\fR?
39 Query or modify the geometry options of the slave given by
39 Query or modify the geometry options of the content given by
4040 \fIwindow\fR. If no \fIoption\fR is specified, this command returns a
4141 list describing the available options (see \fBTk_ConfigureInfo\fR for
4242 information on the format of this list). If \fIoption\fR is specified
5858 including its border, if any.
5959 Thus if \fIwhere\fR is \fBse\fR then the lower-right corner of
6060 \fIwindow\fR's border will appear at the given (x,y) location
61 in the master.
61 in the container.
6262 The anchor position defaults to \fBnw\fR.
6363 .TP
6464 \fB\-bordermode \fImode\fR
6565 \fIMode\fR determines the degree to which borders within the
66 master are used in determining the placement of the slave.
66 container are used in determining the placement of the content.
6767 The default and most common value is \fBinside\fR.
68 In this case the placer considers the area of the master to
69 be the innermost area of the master, inside any border:
68 In this case the placer considers the area of the container to
69 be the innermost area of the container, inside any border:
7070 an option of \fB\-x 0\fR corresponds to an x-coordinate just
7171 inside the border and an option of \fB\-relwidth 1.0\fR
72 means \fIwindow\fR will fill the area inside the master's
72 means \fIwindow\fR will fill the area inside the container's
7373 border.
7474 .RS
7575 .PP
7676 If \fImode\fR is \fBoutside\fR then the placer considers
77 the area of the master to include its border;
77 the area of the container to include its border;
7878 this mode is typically used when placing \fIwindow\fR
79 outside its master, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR.
79 outside its container, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR.
8080 Lastly, \fImode\fR may be specified as \fBignore\fR, in which
81 case borders are ignored: the area of the master is considered
81 case borders are ignored: the area of the container is considered
8282 to be its official X area, which includes any internal border but
8383 no external border. A bordermode of \fBignore\fR is probably
8484 not very useful.
9393 \fB\-relheight\fR option is specified, then the height requested
9494 internally by the window will be used.
9595 .TP
96 \fB\-in \fImaster\fR
97 \fIMaster\fR specifies the path name of the window relative
96 \fB\-in \fIcontainer\fR
97 \fIContainer\fR specifies the path name of the window relative
9898 to which \fIwindow\fR is to be placed.
99 \fIMaster\fR must either be \fIwindow\fR's parent or a descendant
99 \fIContainer\fR must either be \fIwindow\fR's parent or a descendant
100100 of \fIwindow\fR's parent.
101 In addition, \fImaster\fR and \fIwindow\fR must both be descendants
101 In addition, \fIcontainer\fR and \fIwindow\fR must both be descendants
102102 of the same top-level window.
103103 These restrictions are necessary to guarantee
104 that \fIwindow\fR is visible whenever \fImaster\fR is visible.
105 If this option is not specified then the master defaults to
104 that \fIwindow\fR is visible whenever \fIcontainer\fR is visible.
105 If this option is not specified then the other window defaults to
106106 \fIwindow\fR's parent.
107107 .TP
108108 \fB\-relheight \fIsize\fR
109109 \fISize\fR specifies the height for \fIwindow\fR.
110110 In this case the height is specified as a floating-point number
111 relative to the height of the master: 0.5 means \fIwindow\fR will
112 be half as high as the master, 1.0 means \fIwindow\fR will have
113 the same height as the master, and so on.
114 If both \fB\-height\fR and \fB\-relheight\fR are specified for a slave,
111 relative to the height of the container: 0.5 means \fIwindow\fR will
112 be half as high as the container, 1.0 means \fIwindow\fR will have
113 the same height as the container, and so on.
114 If both \fB\-height\fR and \fB\-relheight\fR are specified for a content,
115115 their values are summed. For example, \fB\-relheight 1.0 \-height \-2\fR
116 makes the slave 2 pixels shorter than the master.
116 makes the content 2 pixels shorter than the container.
117117 .TP
118118 \fB\-relwidth \fIsize\fR
119119 \fISize\fR specifies the width for \fIwindow\fR.
120120 In this case the width is specified as a floating-point number
121 relative to the width of the master: 0.5 means \fIwindow\fR will
122 be half as wide as the master, 1.0 means \fIwindow\fR will have
123 the same width as the master, and so on.
124 If both \fB\-width\fR and \fB\-relwidth\fR are specified for a slave,
121 relative to the width of the container: 0.5 means \fIwindow\fR will
122 be half as wide as the container, 1.0 means \fIwindow\fR will have
123 the same width as the container, and so on.
124 If both \fB\-width\fR and \fB\-relwidth\fR are specified for a content,
125125 their values are summed. For example, \fB\-relwidth 1.0 \-width 5\fR
126 makes the slave 5 pixels wider than the master.
126 makes the content 5 pixels wider than the container.
127127 .TP
128128 \fB\-relx \fIlocation\fR
129 \fILocation\fR specifies the x-coordinate within the master window
129 \fILocation\fR specifies the x-coordinate within the container window
130130 of the anchor point for \fIwindow\fR.
131131 In this case the location is specified in a relative fashion
132132 as a floating-point number: 0.0 corresponds to the left edge
133 of the master and 1.0 corresponds to the right edge of the master.
133 of the container and 1.0 corresponds to the right edge of the container.
134134 \fILocation\fR need not be in the range 0.0\-1.0.
135 If both \fB\-x\fR and \fB\-relx\fR are specified for a slave
135 If both \fB\-x\fR and \fB\-relx\fR are specified for a content
136136 then their values are summed. For example, \fB\-relx 0.5 \-x \-2\fR
137 positions the left edge of the slave 2 pixels to the left of the
138 center of its master.
137 positions the left edge of the content 2 pixels to the left of the
138 center of its container.
139139 .TP
140140 \fB\-rely \fIlocation\fR
141 \fILocation\fR specifies the y-coordinate within the master window
141 \fILocation\fR specifies the y-coordinate within the container window
142142 of the anchor point for \fIwindow\fR.
143143 In this case the value is specified in a relative fashion
144144 as a floating-point number: 0.0 corresponds to the top edge
145 of the master and 1.0 corresponds to the bottom edge of the master.
145 of the container and 1.0 corresponds to the bottom edge of the container.
146146 \fILocation\fR need not be in the range 0.0\-1.0.
147 If both \fB\-y\fR and \fB\-rely\fR are specified for a slave
147 If both \fB\-y\fR and \fB\-rely\fR are specified for a content
148148 then their values are summed. For example, \fB\-rely 0.5 \-x 3\fR
149 positions the top edge of the slave 3 pixels below the
150 center of its master.
149 positions the top edge of the content 3 pixels below the
150 center of its container.
151151 .TP
152152 \fB\-width \fIsize\fR
153153 \fISize\fR specifies the width for \fIwindow\fR in screen units
159159 internally by the window will be used.
160160 .TP
161161 \fB\-x \fIlocation\fR
162 \fILocation\fR specifies the x-coordinate within the master window
162 \fILocation\fR specifies the x-coordinate within the container window
163163 of the anchor point for \fIwindow\fR.
164164 The location is specified in screen units (i.e. any of the forms
165165 accepted by \fBTk_GetPixels\fR) and need not lie within the bounds
166 of the master window.
166 of the container window.
167167 .TP
168168 \fB\-y \fIlocation\fR
169 \fILocation\fR specifies the y-coordinate within the master window
169 \fILocation\fR specifies the y-coordinate within the container window
170170 of the anchor point for \fIwindow\fR.
171171 The location is specified in screen units (i.e. any of the forms
172172 accepted by \fBTk_GetPixels\fR) and need not lie within the bounds
173 of the master window.
173 of the container window.
174174 .PP
175175 If the same value is specified separately with
176176 two different options, such as \fB\-x\fR and \fB\-relx\fR, then
191191 command.
192192 .TP
193193 \fBplace slaves \fIwindow\fR
194 Returns a list of all the slave windows for which \fIwindow\fR is the master.
195 If there are no slaves for \fIwindow\fR then an empty string is returned.
194 Returns a list of all the content windows for which \fIwindow\fR is the container.
195 If there is no content for \fIwindow\fR then an empty string is returned.
196 .VS "TIP 581"
197 .TP
198 \fBplace content \fIwindow\fR
199 .
200 Synonym for . \fBplace slaves \fIwindow\fR
201 .VE "TIP 581"
196202 .PP
197203 If the configuration of a window has been retrieved with
198204 \fBplace info\fR, that configuration can be restored later by
201207 the saved information.
202208 .SH "FINE POINTS"
203209 .PP
204 It is not necessary for the master window to be the parent
205 of the slave window.
210 It is not necessary for the container window to be the parent
211 of the content window.
206212 This feature is useful in at least two situations.
207213 First, for complex window layouts it means you can create a
208214 hierarchy of subwindows whose only purpose
220226 without being aware of the structure of the geometry-management
221227 hierarchy.
222228 .PP
223 A second reason for having a master different than the slave's
229 A second reason for having a container different than the content's
224230 parent is to tie two siblings together.
225231 For example, the placer can be used to force a window always to
226232 be positioned centered just below one of its
228234 .CS
229235 \fB\-in \fIsibling\fB \-relx 0.5 \-rely 1.0 \-anchor n \-bordermode outside\fR
230236 .CE
231 Whenever the sibling is repositioned in the future, the slave
237 Whenever the sibling is repositioned in the future, the content
232238 will be repositioned as well.
233239 .PP
234240 Unlike many other geometry managers (such as the packer)
235241 the placer does not make any attempt to manipulate the geometry of
236 the master windows or the parents of slave windows (i.e. it does not
242 the container windows or the parents of content windows (i.e. it does not
237243 set their requested sizes).
238244 To control the sizes of these windows, make them windows like
239245 frames and canvases that provide configuration options for this purpose.
248254 .SH "SEE ALSO"
249255 grid(n), pack(n)
250256 .SH KEYWORDS
251 geometry manager, height, location, master, place, rubber sheet, slave, width
257 geometry manager, height, location, container, place, rubber sheet, content, width
252258 '\" Local Variables:
253259 '\" mode: nroff
254260 '\" End:
149149 .PP
150150 On X11, the \fBPRIMARY\fR selection is a system-wide feature of the X server, allowing communication between different processes that are X11 clients.
151151 .PP
152 On Windows, the \fBPRIMARY\fR selection is not provided by the system, but only by Tk, and so it is shared only between windows of a master interpreter and its unsafe slave interpreters. It is not shared between interpreters in different processes or different threads. Each master interpreter has a separate \fBPRIMARY\fR selection that is shared only with its unsafe slaves.
152 On Windows, the \fBPRIMARY\fR selection is not provided by the system, but only by Tk, and so it is shared only between windows of a parent interpreter and its child interpreters. It is not shared between interpreters in different processes or different threads. Each parent interpreter has a separate \fBPRIMARY\fR selection that is shared only with its child interpreters which are not safe interpreters.
153153 .PP
154154 .SH SECURITY
155155 .PP
513513 If any normal printing characters are typed in a spinbox, they are
514514 inserted at the point of the insertion cursor.
515515 .IP [7]
516 The view in the spinbox can be adjusted by dragging with mouse button 2.
517 If mouse button 2 is clicked without moving the mouse, the selection
518 is copied into the spinbox at the position of the mouse cursor.
516 The view in the spinbox can be adjusted by dragging with the middle
517 mouse button (button 2, or button 3 in TkAqua). If the middle mouse
518 button is clicked without moving the mouse, the selection is copied
519 into the spinbox at the position of the mouse cursor.
519520 .IP [8]
520521 If the mouse is dragged out of the spinbox on the left or right sides
521522 while button 1 is pressed, the spinbox will automatically scroll to
33 '\"
44 '\" See the file "license.terms" for information on usage and redistribution
55 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
6 '\"
77 .TH text n 8.5 Tk "Tk Built-In Commands"
88 .so man.macros
99 .BS
10811081 the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR refers
10821082 to an earlier character in the text than \fIindex2\fR, and so on.
10831083 .TP
1084 \fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
1084 \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
10851085 .
10861086 Query or modify the configuration options of the widget. If no \fIoption\fR is
10871087 specified, returns a list describing all of the available options for
10941094 this case the command returns an empty string. \fIOption\fR may have any of
10951095 the values accepted by the \fBtext\fR command.
10961096 .TP
1097 \fIpathName \fBcount\fR \fI?options\fR? \fIindex1 index2\fR
1097 \fIpathName \fBcount\fR ?\fIoptions\fR? \fIindex1 index2\fR
10981098 .
10991099 Counts the number of relevant things between the two indices. If \fIindex1\fR
11001100 is after \fIindex2\fR, the result will be a negative number (and this holds
20242024 .SH BINDINGS
20252025 .PP
20262026 Tk automatically creates class bindings for texts that give them the following
2027 default behavior. In the descriptions below,
2027 default behavior.
2028 In the descriptions below,
20282029 .QW word
2029 is dependent on the value of the \fBtcl_wordchars\fR variable. See
2030 \fBtclvars\fR(n).
2030 is dependent on the value of
2031 the \fBtcl_wordchars\fR variable. See \fBtclvars\fR(n).
20312032 .IP [1]
20322033 Clicking mouse button 1 positions the insertion cursor just before the
20332034 character underneath the mouse cursor, sets the input focus to this widget,
20562057 If any normal printing characters are typed, they are inserted at the point of
20572058 the insertion cursor.
20582059 .IP [7]
2059 The view in the widget can be adjusted by dragging with mouse button 2. If
2060 mouse button 2 is clicked without moving the mouse, the selection is copied
2061 into the text at the position of the mouse cursor. The Insert key also inserts
2062 the selection, but at the position of the insertion cursor.
2060 The view in the widget can be adjusted by dragging with the middle mouse
2061 button (button 2, or button 3 in TkAqua). If the middle mouse button is
2062 clicked without moving the mouse, the selection is copied into the text at the
2063 position of the mouse cursor. The Insert key also inserts the selection,
2064 but at the position of the insertion cursor.
20632065 .IP [8]
20642066 If the mouse is dragged out of the widget while button 1 is pressed, the entry
20652067 will automatically scroll to make more text visible (if there is more text
217217 .TP
218218 \fB::tk::mac::standardAboutPanel\fR
219219 .
220 Brings the standard Cocoa about panel to the front, with all its information
221 filled in from your application bundle files (standard about panel with no
222 options specified). See Apple Technote TN2179 and the AppKit documentation for
223 -[NSApplication orderFrontStandardAboutPanelWithOptions:] for details on the
224 Info.plist keys and app bundle files used by the about panel.
220 Brings the standard Cocoa about panel to the front with information filled in
221 from the application bundle files. The panel displays the application icon and
222 the values associated to the info.plist keys named CFBundleName,
223 CFBundleShortVersionString, NSAboutPanelOptionVersion and
224 NSHumanReadableCopyright. If a file named \fICredits.html\fR or
225 \fICredits.rtf\fR exists in the bundle's Resources directory then its contents
226 will be displayed in a scrolling text box at the bottom of the dialog. See the
227 documentation for -[NSApplication orderFrontStandardAboutPanelWithOptions:]
228 for more details. A hook is also provided for a custom About dialog. If a Tcl
229 proc named tkAboutDialog is defined in the main interpreter then that
230 procedure will be called instead of opening the standardAboutPanel.
225231 .SH "SYSTEM CONFIGURATION"
226232 .PP
227233 There are a number of additional global configuration options that control the
6565 .AP short bottom in
6666 Extra padding (in pixels) to add to the bottom of a region.
6767 .AP Ttk_Box box in
68 Specifies a rectangular region.
6869 .AP "Ttk_Box *" box_rtn out
69 Specifies a rectangular region.
70 A rectangular region.
7071 .AP int height in
7172 The height in pixels of a region.
7273 .AP "Tcl_Interp *" interp in
7879 to be converted to an enumerated value or bitmask.
7980 Internal rep may be be modified to cache corresponding value.
8081 .AP Ttk_Padding padding in
82 Extra padding to add on the inside of a region.
8183 .AP "Ttk_Padding *" padding_rtn out
82 Extra padding to add on the inside of a region.
84 Padding present in the inside of a region.
8385 .AP Ttk_Box parcel in
8486 A rectangular region, allocated from a cavity.
8587 .AP int relief in
8688 One of the standard Tk relief options
87 (TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, etc.).
89 (\fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, etc.).
8890 See \fBTk_GetReliefFromObj\fR.
8991 .AP short right in
9092 Extra padding (in pixels) to add to the right side of a region.
9496 .AP unsigned sticky in
9597 A bitmask containing one or more of the bits
9698 \fBTTK_STICK_W\fR (west, or left),
97 \fBTTK_STICK_E\fR (east, or right,
99 \fBTTK_STICK_E\fR (east, or right),
98100 \fBTTK_STICK_N\fR (north, or top), and
99101 \fBTTK_STICK_S\fR (south, or bottom).
100 \fBTTK_FILL_X\fR is defined as a synonym for (TTK_STICK_W|TTK_STICK_E),
101 \fBTTK_FILL_Y\fR is a synonym for (TTK_STICK_N|TTK_STICK_S),
102 and \fBTTK_FILL_BOTH\fR and \fBTTK_STICK_ALL\fR
103 are synonyms for (TTK_FILL_X|TTK_FILL_Y).
102 \fBTTK_FILL_X\fR is defined as a synonym for (\fBTTK_STICK_W\fR|\fBTTK_STICK_E\fR),
103 \fBTTK_FILL_Y\fR is a synonym for (\fBTTK_STICK_N\fR|\fBTTK_STICK_S\fR),
104 and \fBTTK_FILL_BOTH\fR
105 is a synonym for (\fBTTK_FILL_X\fR|\fBTTK_FILL_Y\fR).
104106 See also: \fIgrid(n)\fR.
105107 .AP Tk_Window tkwin in
106108 Window whose screen geometry determines
141141 .RS
142142 Can only be changed when using non-native and non-graphical themes.
143143 .RE
144 \fB\-insertcolor\fP \fIcolor\fP
145 .br
144146 \fB\-insertwidth\fP \fIamount\fP
145147 .br
146148 \fB\-lightcolor\fP \fIcolor\fP
2222 Entry widgets support horizontal scrolling with the
2323 standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command.
2424 .SO ttk_widget
25 \-class \-cursor \-style
25 \-class \-cursor
26 \-font \-foreground
27 \-style
2628 \-takefocus \-xscrollcommand
2729 .SE
2830 .SH "WIDGET-SPECIFIC OPTIONS"
3335 the current X selection, selecting outside the widget deselects any
3436 widget selection, and the widget will respond to selection retrieval
3537 requests when it has a selection.
36 .\" MAYBE: .OP \-font font Font
37 .\" MAYBE: .OP \-foreground foreground Foreground
3838 .\" MAYBE: .OP \-insertbackground insertBackground Foreground
3939 .\" MAYBE: .OP \-insertwidth insertWidth InsertWidth
4040 .OP \-invalidcommand invalidCommand InvalidCommand
352352 If any normal printing characters are typed in an entry, they are
353353 inserted at the point of the insert cursor.
354354 .IP \0\(bu 4
355 The view in the entry can be adjusted by dragging with mouse button 2.
356 If mouse button 2 is clicked without moving the mouse, the selection
357 is copied into the entry at the position of the mouse cursor.
355 The view in the entry can be adjusted by dragging with the middle
356 mouse button (button 2, or button 3 in TkAqua). If the middle mouse
357 button is clicked without moving the mouse, the selection is copied
358 into the entry at the position of the mouse cursor.
358359 .IP \0\(bu 4
359360 If the mouse is dragged out of the entry on the left or right sides
360361 while button 1 is pressed, the entry will automatically scroll to
445446 Some themes use a graphical background and their field background colors cannot be changed.
446447 .RE
447448 \fB\-foreground\fP \fIcolor\fP
449 .br
450 \fB\-insertcolor\fP \fIcolor\fP
448451 .br
449452 \fB\-insertwidth\fP \fIamount\fP
450453 .br
5959 (which displays a text string) has
6060 \fB\-text\fR, \fB\-font\fR, \fB\-foreground\fR, \fB\-background\fR,
6161 \fB\-underline\fR, and \fB\-width\fR options.
62 The value of an element option is taken from:
62 The value of an element option is taken from (in precedence order):
6363 .IP \(bu
6464 an option of the same name and type in the widget containing the element;
6565 .IP \(bu
8585 Scrollbar.trough \-children {
8686 Scrollbar.leftarrow \-side left \-sticky w
8787 Scrollbar.rightarrow \-side right \-sticky e
88 Scrollbar.thumb \-side left \-expand true \-sticky ew
88 Scrollbar.thumb \-sticky ew
8989 }
9090 }
9191 .CE
1919 .SH DESCRIPTION
2020 A \fBttk::notebook\fR widget manages a collection of windows
2121 and displays a single one at a time.
22 Each slave window is associated with a \fItab\fR,
22 Each content window is associated with a \fItab\fR,
2323 which the user may select to change the currently-displayed window.
2424 .SO ttk_widget
2525 \-class \-cursor \-takefocus
5555 If \fBdisabled\fR, then the tab is not selectable.
5656 If \fBhidden\fR, then the tab is not shown.
5757 .OP \-sticky sticky Sticky
58 Specifies how the slave window is positioned within the pane area.
58 Specifies how the content window is positioned within the pane area.
5959 Value is a string containing zero or more of the characters
6060 \fBn, s, e,\fR or \fBw\fR.
6161 Each letter refers to a side (north, south, east, or west)
62 that the slave window will
62 that the content window will
6363 .QW stick
6464 to, as per the \fBgrid\fR geometry manager.
6565 .OP \-padding padding Padding
8585 .IP \(bu
8686 An integer between zero and the number of tabs;
8787 .IP \(bu
88 The name of a slave window;
88 The name of a content window;
8989 .IP \(bu
9090 A positional specification of the form
9191 .QW @\fIx\fR,\fIy\fR ,
155155 .TP
156156 \fIpathname \fBselect\fR ?\fItabid\fR?
157157 Selects the specified tab.
158 The associated slave window will be displayed,
158 The associated content window will be displayed,
159159 and the previously-selected window (if different) is unmapped.
160160 If \fItabid\fR is omitted, returns the widget name of the
161161 currently selected pane.
106106 .br
107107 \fB\-foreground\fP \fIcolor\fP
108108 .br
109 \fB\-insertcolor\fP \fIcolor\fP
110 .br
111 \fB\-insertwidth\fP \fIamount\fP
112 .br
109113 \fB\-lightcolor\fP \fIcolor\fP
110114 .br
111115 \fB\-padding\fP \fIpadding\fP
3333 \fBttk::style configure \fIstyle\fR ?\fI\-option\fR ?\fIvalue option value...\fR? ?
3434 Sets the default value of the specified option(s) in \fIstyle\fR.
3535 .TP
36 \fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR?
37 Sets dynamic values of the specified option(s) in \fIstyle\fR.
38 Each \fIstatespec / value\fR pair is examined in order;
39 the value corresponding to the first matching \fIstatespec\fR
40 is used.
41 .TP
42 \fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR??
43 Returns the value specified for \fI\-option\fR in style \fIstyle\fR
44 in state \fIstate\fR, using the standard lookup rules for element options.
45 \fIstate\fR is a list of state names; if omitted,
46 it defaults to all bits off (the
47 .QW normal
48 state).
49 If the \fIdefault\fR argument is present, it is used as a fallback
50 value in case no specification for \fI\-option\fR is found.
51 .\" Otherwise -- signal error? return empty string? Leave unspecified for now.
52 .TP
53 \fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR?
54 Define the widget layout for style \fIstyle\fR.
55 See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR.
56 If \fIlayoutSpec\fR is omitted, return the layout specification
57 for style \fIstyle\fR.
36 \fBttk::style element\fR \fIargs\fR
37 .RS
5838 .TP
5939 \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR?
6040 Creates a new element in the current theme of type \fItype\fR.
6949 .TP
7050 \fBttk::style element options \fIelement\fR
7151 Returns the list of \fIelement\fR's options.
52 .RE
53 .TP
54 \fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR?
55 Define the widget layout for style \fIstyle\fR.
56 See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR.
57 If \fIlayoutSpec\fR is omitted, return the layout specification
58 for style \fIstyle\fR.
59 .TP
60 \fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR??
61 Returns the value specified for \fI\-option\fR in style \fIstyle\fR
62 in state \fIstate\fR, using the standard lookup rules for element options.
63 \fIstate\fR is a list of state names; if omitted,
64 it defaults to all bits off (the
65 .QW normal
66 state).
67 If the \fIdefault\fR argument is present, it is used as a fallback
68 value in case no specification for \fI\-option\fR is found.
69 .\" Otherwise -- signal error? return empty string? Leave unspecified for now.
70 .TP
71 \fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR?
72 Sets dynamic values of the specified option(s) in \fIstyle\fR.
73 Each \fIstatespec / value\fR pair is examined in order;
74 the value corresponding to the first matching \fIstatespec\fR
75 is used.
76 .TP
77 \fBttk::style theme\fR \fIargs\fR
78 .RS
7279 .TP
7380 \fBttk::style theme create\fR \fIthemeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ?
7481 Creates a new theme. It is an error if \fIthemeName\fR already exists.
7784 If \fB\-settings\fR is present, \fIscript\fR is evaluated in the
7885 context of the new theme as per \fBttk::style theme settings\fR.
7986 .TP
87 \fBttk::style theme names\fR
88 Returns a list of all known themes.
89 .TP
8090 \fBttk::style theme settings \fIthemeName\fR \fIscript\fR
8191 Temporarily sets the current theme to \fIthemeName\fR,
8292 evaluate \fIscript\fR, then restore the previous theme.
8393 Typically \fIscript\fR simply defines styles and elements,
8494 though arbitrary Tcl code may appear.
8595 .TP
86 \fBttk::style theme names\fR
87 Returns a list of all known themes.
88 .TP
8996 \fBttk::style theme use\fR ?\fIthemeName\fR?
9097 Without an argument the result is the name of the current theme.
9198 Otherwise this command sets the current theme to \fIthemeName\fR,
9299 and refreshes all widgets.
100 .RE
93101 .SH LAYOUTS
94102 .PP
95103 A \fIlayout\fR specifies a list of elements, each followed
97105 The layout mechanism uses a simplified version of the \fBpack\fR
98106 geometry manager: given an initial cavity,
99107 each element is allocated a parcel.
108 Then the parcel actually used by the element is adjusted within
109 the allocated parcel.
100110 Valid options are:
111 .\" -border should remain undocumented for now (dubious usefulness)
112 .\" .TP
113 .\" \fB\-border\fR \fIboolean\fR
114 .\" Specifies whether the element is drawn after its children. Defaults to 0.
115 .TP
116 \fB\-children { \fIsublayout...\fB }\fR
117 Specifies a list of elements to place inside the element.
118 .TP
119 \fB\-expand\fR \fIboolean\fR
120 Specifies whether the allocated parcel is the entire cavity. If so,
121 simultaneous specification of \fB\-side\fR is ignored.
122 Defaults to 0.
101123 .TP
102124 \fB\-side \fIside\fR
103125 Specifies which side of the cavity to place the element;
104126 one of \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR.
105 If omitted, the element occupies the entire cavity.
127 For instance, \fB\-side top\fR allocates the parcel along the top of
128 the cavity having width and height respectively the width of the cavity
129 and the height of the element.
130 If omitted, the allocated parcel is the entire cavity (same effect
131 as \fB\-expand\fR 1).
106132 .TP
107133 \fB\-sticky\fR \fB[\fInswe\fB]\fR
108 Specifies where the element is placed inside its allocated parcel.
109 .TP
110 \fB\-children { \fIsublayout... \fB}\fR
111 Specifies a list of elements to place inside the element.
112 .\" Also: -border, -unit, -expand: may go away.
134 Specifies the actual parcel position and size inside the allocated parcel.
135 If specified as an empty string then the actual parcel is centered in
136 the allocated parcel. Default is \fBnswe\fR.
137 .\" -unit should remain undocumented for now (dubious usefulness)
138 .\" .TP
139 .\" \fB\-unit\fR \fIboolean\fR
140 .\" Specifies whether the element propagates its state to its children.
141 .\" Defaults to 0.
113142 .PP
114143 For example:
115144 .CS
7373 .OP \-compound compound Compound
7474 Specifies how to display the image relative to the text,
7575 in the case both \fB\-text\fR and \fB\-image\fR are present.
76 If set to the empty string (the default), the rules described in the
77 "Elements" section of \fIttk::intro(n)\fR explain which value is actually
78 used.
7679 Valid values are:
7780 .RS
7881 .IP text
8790 .IP right
8891 Display image above, below, left of, or right of the text, respectively.
8992 .IP none
90 The default; display the image if present, otherwise the text.
91 .RE
93 Display the image if present, otherwise the text.
94 .RE
95 .OP \-font font Font
96 Font to use for the text displayed by the widget.
97 .OP \-foreground textColor TextColor
98 The widget's foreground color.
99 If unspecified, the theme default is used.
92100 .OP \-image image Image
93101 Specifies an image to display.
94102 This is a list of 1 or more elements.
707707 specified then the command returns the current title for the
708708 \fIwindow\fR. The title for a window defaults to its name.
709709 .TP
710 \fBwm transient \fIwindow\fR ?\fImaster\fR?
711 .
712 If \fImaster\fR is specified, then the window manager is informed that
710 \fBwm transient \fIwindow\fR ?\fIcontainer\fR?
711 .
712 If \fIcontainer\fR is specified, then the window manager is informed that
713713 \fIwindow\fR is a transient window (e.g. pull-down menu) working on
714 behalf of \fImaster\fR (where \fImaster\fR is the path name for a
715 top-level window). If \fImaster\fR is specified as an empty string
714 behalf of \fIcontainer\fR (where \fIcontainer\fR is the path name for a
715 top-level window). If \fIcontainer\fR is specified as an empty string
716716 then \fIwindow\fR is marked as not being a transient window any more.
717717 Otherwise the command returns the path name of \fIwindow\fR's current
718 master, or an empty string if \fIwindow\fR is not currently a
718 container, or an empty string if \fIwindow\fR is not currently a
719719 transient window. A transient window will mirror state changes in the
720 master and inherit the state of the master when initially mapped. The
721 directed graph with an edge from each transient to its master must be
720 container and inherit the state of the container when initially mapped. The
721 directed graph with an edge from each transient to its container must be
722722 acyclic. In particular, it is an error to attempt to make a window a
723723 transient of itself. The window manager may also decorate a transient
724724 window differently, removing some features normally present (e.g.,
471471 Tk_Window Tk_IdToWindow(Display *display, Window window)
472472 }
473473 declare 117 {
474 void Tk_ImageChanged(Tk_ImageMaster master, int x, int y,
474 void Tk_ImageChanged(Tk_ImageMaster model, int x, int y,
475475 int width, int height, int imageWidth, int imageHeight)
476476 }
477477 declare 118 {
485485 int width, int height)
486486 }
487487 declare 121 {
488 void Tk_MaintainGeometry(Tk_Window slave,
489 Tk_Window master, int x, int y, int width, int height)
488 void Tk_MaintainGeometry(Tk_Window window,
489 Tk_Window container, int x, int y, int width, int height)
490490 }
491491 declare 122 {
492492 Tk_Window Tk_MainWindow(Tcl_Interp *interp)
538538 CONST84_RETURN char *Tk_NameOfFont(Tk_Font font)
539539 }
540540 declare 137 {
541 CONST84_RETURN char *Tk_NameOfImage(Tk_ImageMaster imageMaster)
541 CONST84_RETURN char *Tk_NameOfImage(Tk_ImageMaster model)
542542 }
543543 declare 138 {
544544 CONST84_RETURN char *Tk_NameOfJoinStyle(int join)
691691 void Tk_Ungrab(Tk_Window tkwin)
692692 }
693693 declare 181 {
694 void Tk_UnmaintainGeometry(Tk_Window slave, Tk_Window master)
694 void Tk_UnmaintainGeometry(Tk_Window window, Tk_Window container)
695695 }
696696 declare 182 {
697697 void Tk_UnmapWindow(Tk_Window tkwin)
10671067 declare 273 {
10681068 void Tk_CreateOldPhotoImageFormat(const Tk_PhotoImageFormat *formatPtr)
10691069 }
1070 declare 280 {
1071 void TkUnusedStubEntry(void)
1072 }
10701073
10711074 # Define the platform specific public Tk interface. These functions are
10721075 # only available on the designated platform.
11381141 declare 10 aqua {
11391142 int Tk_MacOSXIsAppInFront(void)
11401143 }
1144 declare 11 aqua {
1145 Tk_Window Tk_MacOSXGetTkWindow(void *w)
1146 }
1147 declare 12 aqua {
1148 void *Tk_MacOSXGetCGContextForDrawable(Drawable drawable)
1149 }
1150 # Replaces TkMacOSXDrawable
1151 declare 13 aqua {
1152 void *Tk_MacOSXGetNSWindowForDrawable(Drawable drawable)
1153 }
1154 declare 16 aqua {
1155 void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width,
1156 int height, int flags)
1157 }
11411158
11421159 ##############################################################################
11431160
7474 #define TK_MAJOR_VERSION 8
7575 #define TK_MINOR_VERSION 6
7676 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE
77 #define TK_RELEASE_SERIAL 10
77 #define TK_RELEASE_SERIAL 11
7878
7979 #define TK_VERSION "8.6"
80 #define TK_PATCH_LEVEL "8.6.10"
80 #define TK_PATCH_LEVEL "8.6.11"
8181
8282 /*
8383 * A special definition used to allow this header file to be included from
121121 * Dummy types that are used by clients:
122122 */
123123
124 #define Tk_ImageModel Tk_ImageMaster
124125 typedef struct Tk_BindingTable_ *Tk_BindingTable;
125126 typedef struct Tk_Canvas_ *Tk_Canvas;
126127 typedef struct Tk_Cursor_ *Tk_Cursor;
613614 * the geometry manager to carry out certain functions.
614615 */
615616
617 #define Tk_GeomLostContentProc Tk_GeomLostSlaveProc
616618 typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin);
617 typedef void (Tk_GeomLostSlaveProc) (ClientData clientData, Tk_Window tkwin);
619 typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin);
618620
619621 typedef struct Tk_GeomMgr {
620622 const char *name; /* Name of the geometry manager (command used
621623 * to invoke it, or name of widget class that
622624 * allows embedded widgets). */
623625 Tk_GeomRequestProc *requestProc;
624 /* Procedure to invoke when a slave's
626 /* Procedure to invoke when a content's
625627 * requested geometry changes. */
626 Tk_GeomLostSlaveProc *lostSlaveProc;
627 /* Procedure to invoke when a slave is taken
628 Tk_GeomLostContentProc *lostSlaveProc;
629 /* Procedure to invoke when content is taken
628630 * away from one geometry manager by another.
629631 * NULL means geometry manager doesn't care
630 * when slaves are lost. */
632 * when content lost. */
631633 } Tk_GeomMgr;
632634
633635 /*
883885 * window.
884886 * TK_WM_MANAGEABLE 1 marks a window as capable of being converted
885887 * into a toplevel using [wm manage].
888 * TK_CAN_INPUT_TEXT 1 means that this window accepts text input.
889 * Used on macOS to indicate that key events can be
890 * processed with the NSTextInputClient protocol.
891 * Not currently accessible through the public API.
886892 */
887893
888894 #define TK_MAPPED 1
896902 #define TK_EMBEDDED 0x100
897903 #define TK_CONTAINER 0x200
898904 #define TK_BOTH_HALVES 0x400
905
899906 #define TK_WRAPPER 0x1000
900907 #define TK_REPARENTED 0x2000
901908 #define TK_ANONYMOUS_WINDOW 0x4000
904911 #define TK_TOP_HIERARCHY 0x20000
905912 #define TK_PROP_PROPCHANGE 0x40000
906913 #define TK_WM_MANAGEABLE 0x80000
914 #define TK_CAN_INPUT_TEXT 0x100000
907915
908916 /*
909917 *----------------------------------------------------------------------
12211229 typedef struct Tk_ImageType Tk_ImageType;
12221230 #ifdef USE_OLD_IMAGE
12231231 typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc,
1224 char **argv, Tk_ImageType *typePtr, Tk_ImageMaster master,
1225 ClientData *masterDataPtr);
1232 char **argv, Tk_ImageType *typePtr, Tk_ImageMaster model,
1233 ClientData *clientDataPtr);
12261234 #else
12271235 typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, CONST86 char *name, int objc,
1228 Tcl_Obj *const objv[], CONST86 Tk_ImageType *typePtr, Tk_ImageMaster master,
1229 ClientData *masterDataPtr);
1236 Tcl_Obj *const objv[], CONST86 Tk_ImageType *typePtr, Tk_ImageMaster model,
1237 ClientData *clientDataPtr);
12301238 #endif /* USE_OLD_IMAGE */
1231 typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData masterData);
1232 typedef void (Tk_ImageDisplayProc) (ClientData instanceData, Display *display,
1239 typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData);
1240 typedef void (Tk_ImageDisplayProc) (ClientData clientData, Display *display,
12331241 Drawable drawable, int imageX, int imageY, int width, int height,
12341242 int drawableX, int drawableY);
1235 typedef void (Tk_ImageFreeProc) (ClientData instanceData, Display *display);
1236 typedef void (Tk_ImageDeleteProc) (ClientData masterData);
1243 typedef void (Tk_ImageFreeProc) (ClientData clientData, Display *display);
1244 typedef void (Tk_ImageDeleteProc) (ClientData clientData);
12371245 typedef void (Tk_ImageChangedProc) (ClientData clientData, int x, int y,
12381246 int width, int height, int imageWidth, int imageHeight);
12391247 typedef int (Tk_ImagePostscriptProc) (ClientData clientData,
8989 if (objPtr->typePtr != &tkBorderObjType) {
9090 InitBorderObj(objPtr);
9191 }
92 borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
92 borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
9393
9494 /*
9595 * If the object currently points to a TkBorder, see if it's the one we
126126 */
127127
128128 if (borderPtr != NULL) {
129 TkBorder *firstBorderPtr = Tcl_GetHashValue(borderPtr->hashPtr);
129 TkBorder *firstBorderPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
130130
131131 FreeBorderObj(objPtr);
132132 for (borderPtr = firstBorderPtr ; borderPtr != NULL;
199199
200200 hashPtr = Tcl_CreateHashEntry(&dispPtr->borderTable, colorName, &isNew);
201201 if (!isNew) {
202 existingBorderPtr = Tcl_GetHashValue(hashPtr);
202 existingBorderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
203203 for (borderPtr = existingBorderPtr; borderPtr != NULL;
204204 borderPtr = borderPtr->nextPtr) {
205205 if ((Tk_Screen(tkwin) == borderPtr->screen)
419419 Display *display = DisplayOfScreen(borderPtr->screen);
420420 TkBorder *prevPtr;
421421
422 borderPtr->resourceRefCount--;
423 if (borderPtr->resourceRefCount > 0) {
422 if (borderPtr->resourceRefCount-- > 1) {
424423 return;
425424 }
426425
427 prevPtr = Tcl_GetHashValue(borderPtr->hashPtr);
426 prevPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
428427 TkpFreeBorder(borderPtr);
429428 if (borderPtr->bgColorPtr != NULL) {
430429 Tk_FreeColor(borderPtr->bgColorPtr);
526525 FreeBorderObj(
527526 Tcl_Obj *objPtr) /* The object we are releasing. */
528527 {
529 TkBorder *borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
528 TkBorder *borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
530529
531530 if (borderPtr != NULL) {
532531 borderPtr->objRefCount--;
561560 Tcl_Obj *srcObjPtr, /* The object we are copying from. */
562561 Tcl_Obj *dupObjPtr) /* The object we are copying to. */
563562 {
564 TkBorder *borderPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
563 TkBorder *borderPtr = (TkBorder *)srcObjPtr->internalRep.twoPtrValue.ptr1;
565564
566565 dupObjPtr->typePtr = srcObjPtr->typePtr;
567566 dupObjPtr->internalRep.twoPtrValue.ptr1 = borderPtr;
593592 Tk_Window tkwin, /* Window whose background is to be set. */
594593 Tk_3DBorder border) /* Token for border. */
595594 {
596 register TkBorder *borderPtr = (TkBorder *) border;
595 TkBorder *borderPtr = (TkBorder *) border;
597596
598597 Tk_SetWindowBackground(tkwin, borderPtr->bgColorPtr->pixel);
599598 }
758757 {
759758 XPoint poly[4], b1, b2, newB1, newB2;
760759 XPoint perp, c, shift1, shift2; /* Used for handling parallel lines. */
761 register XPoint *p1Ptr, *p2Ptr;
760 XPoint *p1Ptr, *p2Ptr;
762761 TkBorder *borderPtr = (TkBorder *) border;
763762 GC gc;
764763 int i, lightOnLeft, dx, dy, parallel, pointsSeen;
955954 int relief) /* Indicates 3D effect: TK_RELIEF_FLAT,
956955 * TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */
957956 {
958 register TkBorder *borderPtr = (TkBorder *) border;
957 TkBorder *borderPtr = (TkBorder *) border;
959958 int doubleBorder;
960959
961960 /*
10261025 * TK_RELIEF_FLAT, TK_RELIEF_RAISED, or
10271026 * TK_RELIEF_SUNKEN. */
10281027 {
1029 register TkBorder *borderPtr = (TkBorder *) border;
1028 TkBorder *borderPtr = (TkBorder *) border;
10301029
10311030 XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
10321031 pointPtr, numPoints, Complex, CoordModeOrigin);
12521251 * cached in the internal representation of the Tcl_Obj. Check it out...
12531252 */
12541253
1255 borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
1254 borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
12561255 if ((borderPtr != NULL)
12571256 && (borderPtr->resourceRefCount > 0)
12581257 && (Tk_Screen(tkwin) == borderPtr->screen)
12801279 if (hashPtr == NULL) {
12811280 goto error;
12821281 }
1283 for (borderPtr = Tcl_GetHashValue(hashPtr); borderPtr != NULL;
1282 for (borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr); borderPtr != NULL;
12841283 borderPtr = borderPtr->nextPtr) {
12851284 if ((Tk_Screen(tkwin) == borderPtr->screen)
12861285 && (Tk_Colormap(tkwin) == borderPtr->colormap)) {
13701369 resultPtr = Tcl_NewObj();
13711370 hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, name);
13721371 if (hashPtr != NULL) {
1373 TkBorder *borderPtr = Tcl_GetHashValue(hashPtr);
1372 TkBorder *borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
13741373
13751374 if (borderPtr == NULL) {
13761375 Tcl_Panic("TkDebugBorder found empty hash table entry");
5858
5959 /*
6060 * In old implementation (the one that used an event ring), <Double-1> and <1><1> were
61 * equivalent sequences. However it is logical to give <Double-1> higher precedence.
61 * equivalent sequences. However it is logical to give <Double-1> higher precedence
62 * since it is more specific. Indeed <Double-1> includes time and space requirements,
63 * which is not the case for <1><1>.
6264 * This can be achieved by setting PREFER_MOST_SPECIALIZED_EVENT to 1.
6365 */
6466
134136 * this count considers the detail (keySym or button). */
135137 } Event;
136138
137 /*
138 * We need a structure providing a list of pattern sequences.
139 */
140
141 typedef unsigned EventMask;
142 typedef unsigned long ModMask;
143
144139 struct PatSeq; /* forward declaration */
145140
146141 /* We need this array for bookkeeping the last matching modifier mask per pattern. */
147 TK_ARRAY_DEFINE(PSModMaskArr, ModMask);
142 TK_ARRAY_DEFINE(PSModMaskArr, unsigned);
148143
149144 typedef struct PSEntry {
150145 TK_DLIST_LINKS(PSEntry); /* Makes this struct a double linked list; must be first entry. */
200195 /* Containing the most recent event for every event type. */
201196 PromArr *promArr; /* Contains the promoted pattern sequences. */
202197 Event *curEvent; /* Pointing to most recent event. */
203 ModMask curModMask; /* Containing the current modifier mask. */
198 unsigned curModMask; /* Containing the current modifier mask. */
204199 LookupTables lookupTables; /* Containing hash tables for fast lookup. */
205200 Tcl_HashTable objectTable; /* Used to map from an object to a list of patterns associated with
206201 * that object. Keys are ClientData, values are (PatSeq *). */
262257 typedef struct {
263258 unsigned eventType; /* Type of X event, e.g. ButtonPress. */
264259 unsigned count; /* Multi-event count, e.g. double-clicks, triple-clicks, etc. */
265 ModMask modMask; /* Mask of modifiers that must be present (zero means no modifiers
260 unsigned modMask; /* Mask of modifiers that must be present (zero means no modifiers
266261 * are required). */
267262 Info info; /* Additional information that must match event. Normally this is zero,
268263 * meaning no additional information must match. For KeyPress and
343338 #define NEARBY_MS 500
344339
345340 /*
346 * Needed as "no-number" constant for integers. The value of this constant is
347 * outside of integer range (type "int"). (Unfortunatly current version of
348 * Tcl/Tk does not provide C99 integer support.)
349 */
350
351 #define NO_NUMBER (((Tcl_WideInt) (~ (unsigned) 0)) + 1)
352
353 /*
354341 * The following structure is used in the nameTable of a virtual event table
355342 * to associate a virtual event with all the physical events that can trigger
356343 * it.
421408
422409 typedef struct {
423410 const char *name; /* Name of modifier. */
424 ModMask mask; /* Button/modifier mask value, such as Button1Mask. */
411 unsigned mask; /* Button/modifier mask value, such as Button1Mask. */
425412 unsigned flags; /* Various flags; see below for definitions. */
426413 } ModInfo;
427414
560547 #define COLORMAP (1<<16)
561548 #define VIRTUAL (1<<17)
562549 #define ACTIVATE (1<<18)
563 #define MAPREQ (1<<19)
564 #define CONFIGREQ (1<<20)
565 #define RESIZEREQ (1<<21)
566 #define CIRCREQ (1<<22)
567
568 #define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL)
569 #define KEY_BUTTON_MOTION_CROSSING (KEY|BUTTON|MOTION|VIRTUAL|CROSSING)
550 #define WHEEL (1<<19)
551 #define MAPREQ (1<<20)
552 #define CONFIGREQ (1<<21)
553 #define RESIZEREQ (1<<22)
554 #define CIRCREQ (1<<23)
555
556 /*
557 * These structs agree with xkey for the fields type, serial, send_event, display,
558 * window, root, subwindow, time, x, y, x_root, and y_root. So when accessing
559 * these fields we may pretend that we are using a struct xkey.
560 */
561
562 #define HAS_XKEY_HEAD (KEY|BUTTON|MOTION|VIRTUAL|CROSSING|WHEEL)
563
564 /*
565 * The xcrossing struct puts the state field in a different location, but the other
566 * events above agree on where state is located.
567 */
568
569 #define HAS_XKEY_HEAD_AND_STATE (KEY|BUTTON|MOTION|VIRTUAL|WHEEL)
570
571 /*
572 * Event types which support -warp.
573 */
574
575 #define CAN_WARP (KEY|BUTTON|MOTION|WHEEL)
570576
571577 static const int flagArray[TK_LASTEVENT] = {
572578 /* Not used */ 0,
607613 /* VirtualEvent */ VIRTUAL,
608614 /* Activate */ ACTIVATE,
609615 /* Deactivate */ ACTIVATE,
610 /* MouseWheel */ KEY
616 /* MouseWheel */ WHEEL
611617 };
612618
613619 /*
699705 unsigned scriptCount, Tcl_DString *dsPtr);
700706 static PatSeq * FindSequence(Tcl_Interp *interp, LookupTables *lookupTables,
701707 ClientData object, const char *eventString, int create,
702 int allowVirtual, EventMask *maskPtr);
708 int allowVirtual, unsigned *maskPtr);
703709 static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr);
704710 static const char * GetField(const char *p, char *copy, unsigned size);
705711 static Tcl_Obj * GetPatternObj(const PatSeq *psPtr);
715721 static int NameToWindow(Tcl_Interp *interp, Tk_Window main,
716722 Tcl_Obj *objPtr, Tk_Window *tkwinPtr);
717723 static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr,
718 TkPattern *patPtr, EventMask *eventMaskPtr);
724 TkPattern *patPtr, unsigned *eventMaskPtr);
719725 static void DoWarp(ClientData clientData);
720726 static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr,
721727 Tcl_Obj *object, int onlyConsiderDetailedEvents);
747753
748754 static int
749755 IsSubsetOf(
750 ModMask lhsMask, /* this is a subset */
751 ModMask rhsMask) /* of this bit field? */
756 unsigned lhsMask, /* this is a subset */
757 unsigned rhsMask) /* of this bit field? */
752758 {
753759 return (lhsMask & rhsMask) == lhsMask;
754760 }
783789 }
784790
785791 static Time
786 CurrentTimeInMilliSecs()
792 CurrentTimeInMilliSecs(void)
787793 {
788794 Tcl_Time now;
789795 Tcl_GetTime(&now);
834840 return sndCount - fstCount;
835841 }
836842
843 int
844 IsKeyEventType(
845 unsigned eventType)
846 {
847 return eventType == KeyPress || eventType == KeyRelease;
848 }
849
850 int
851 IsButtonEventType(
852 unsigned eventType)
853 {
854 return eventType == ButtonPress || eventType == ButtonRelease;
855 }
856
837857 static int
838858 MatchEventNearby(
839859 const XEvent *lhs, /* previous button event */
841861 {
842862 assert(lhs);
843863 assert(rhs);
844 assert(lhs->type == ButtonPress || lhs->type == ButtonRelease);
864 assert(IsButtonEventType(lhs->type));
845865 assert(lhs->type == rhs->type);
846866
847867 /* assert: lhs->xbutton.time <= rhs->xbutton.time */
853873
854874 static int
855875 MatchEventRepeat(
856 const XEvent *lhs, /* previous key event */
857 const XEvent *rhs) /* current key event */
876 const XKeyEvent *lhs, /* previous key event */
877 const XKeyEvent *rhs) /* current key event */
858878 {
859879 assert(lhs);
860880 assert(rhs);
861 assert(lhs->type == KeyPress || lhs->type == KeyRelease);
881 assert(IsKeyEventType(lhs->type));
862882 assert(lhs->type == rhs->type);
863883
864 /* assert: lhs->xkey.time <= rhs->xkey.time */
865 return TestNearbyTime(rhs->xkey.time, lhs->xkey.time);
884 /* assert: lhs->time <= rhs->time */
885 return lhs->keycode == rhs->keycode && TestNearbyTime(lhs->time, rhs->time);
866886 }
867887
868888 static void
921941
922942 static PSEntry *
923943 FreePatSeqEntry(
924 PSList *pool,
944 TCL_UNUSED(PSList *),
925945 PSEntry *entry)
926946 {
927947 PSEntry *next = PSList_Next(entry);
939959
940960 if (dispPtr->metaModMask) {
941961 if (modMask & META_MASK) {
942 modMask &= ~(ModMask)META_MASK;
962 modMask &= ~META_MASK;
943963 modMask |= dispPtr->metaModMask;
944964 }
945965 }
946966 if (dispPtr->altModMask) {
947967 if (modMask & ALT_MASK) {
948 modMask &= ~(ModMask)ALT_MASK;
968 modMask &= ~ALT_MASK;
949969 modMask |= dispPtr->altModMask;
950970 }
951971 }
10221042 assert(TEST_PSENTRY(psPtr));
10231043
10241044 if (PSList_IsEmpty(pool)) {
1025 newEntry = ckalloc(sizeof(PSEntry));
1045 newEntry = (PSEntry *)ckalloc(sizeof(PSEntry));
10261046 newEntry->lastModMaskArr = NULL;
10271047 DEBUG(countEntryItems += 1;)
10281048 } else {
10991119 key.object = object;
11001120 key.type = eventPtr->xev.type;
11011121 hPtr = Tcl_FindHashEntry(&lookupTables->listTable, (char *) &key);
1102 return hPtr ? Tcl_GetHashValue(hPtr) : NULL;
1122 return hPtr ? (PSList *)Tcl_GetHashValue(hPtr) : NULL;
11031123 }
11041124
11051125 /*
11371157 nextPtr = Tcl_NextHashEntry(&search);
11381158
11391159 if (object) {
1140 const PatternTableKey *key = Tcl_GetHashKey(&lookupTables->listTable, hPtr);
1160 const PatternTableKey *key = (const PatternTableKey *)Tcl_GetHashKey(&lookupTables->listTable, hPtr);
11411161 if (key->object != object) {
11421162 continue;
11431163 }
1144 Tcl_DeleteHashEntry(hPtr);
1145 }
1146
1147 psList = Tcl_GetHashValue(hPtr);
1164 }
1165
1166 psList = (PSList *)Tcl_GetHashValue(hPtr);
11481167 PSList_Move(pool, psList);
11491168 ckfree(psList);
11501169 DEBUG(countListItems -= 1;)
1170 Tcl_DeleteHashEntry(hPtr);
11511171 }
11521172 }
11531173
12321252
12331253 /* ensure that our matching algorithm is working (when testing detail) */
12341254 assert(sizeof(Detail) == sizeof(Tk_Uid));
1235
1236 /* test that constant NO_NUMBER is indeed out of integer range */
1237 assert(sizeof(NO_NUMBER) > sizeof(int));
1238 assert(((int) NO_NUMBER) == 0 && NO_NUMBER != 0);
12391255
12401256 /* test expected indices of Button1..Button5, otherwise our button handling is not working */
12411257 assert(Button1 == 1 && Button2 == 2 && Button3 == 3 && Button4 == 4 && Button5 == 5);
13581374
13591375 mainPtr->bindingTable = Tk_CreateBindingTable(mainPtr->interp);
13601376
1361 bindInfoPtr = ckalloc(sizeof(BindInfo));
1377 bindInfoPtr = (BindInfo *)ckalloc(sizeof(BindInfo));
13621378 InitVirtualEventTable(&bindInfoPtr->virtualEventTable);
13631379 bindInfoPtr->screenInfo.curDispPtr = NULL;
13641380 bindInfoPtr->screenInfo.curScreenIndex = -1;
14341450 Tcl_Interp *interp) /* Interpreter to associate with the binding table: commands are
14351451 * executed in this interpreter. */
14361452 {
1437 BindingTable *bindPtr = ckalloc(sizeof(BindingTable));
1453 BindingTable *bindPtr = (BindingTable *)ckalloc(sizeof(BindingTable));
14381454 unsigned i;
14391455
14401456 assert(interp);
14931509 PatSeq *nextPtr;
14941510 PatSeq *psPtr;
14951511
1496 for (psPtr = Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
1512 for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
14971513 assert(TEST_PSENTRY(psPtr));
14981514 nextPtr = psPtr->nextSeqPtr;
14991515 FreePatSeq(psPtr);
15601576 hPtr = Tcl_CreateHashEntry(&lookupTables->listTable, (char *) &key, &isNew);
15611577
15621578 if (isNew) {
1563 psList = ckalloc(sizeof(PSList));
1579 psList = (PSList *)ckalloc(sizeof(PSList));
15641580 PSList_Init(psList);
15651581 Tcl_SetHashValue(hPtr, psList);
15661582 DEBUG(countListItems += 1;)
15671583 } else {
1568 psList = Tcl_GetHashValue(hPtr);
1584 psList = (PSList *)Tcl_GetHashValue(hPtr);
15691585 }
15701586
15711587 psEntry = MakeListEntry(&lookupTables->entryPool, psPtr, 0);
16101626 * existing binding will always be replaced. */
16111627 {
16121628 PatSeq *psPtr;
1613 EventMask eventMask;
1629 unsigned eventMask;
16141630 char *oldStr;
16151631 char *newStr;
16161632
16531669 */
16541670
16551671 hPtr = Tcl_CreateHashEntry(&bindPtr->objectTable, (char *) object, &isNew);
1656 psPtr->ptr.nextObj = isNew ? NULL : Tcl_GetHashValue(hPtr);
1672 psPtr->ptr.nextObj = isNew ? NULL : (PatSeq *)Tcl_GetHashValue(hPtr);
16571673 Tcl_SetHashValue(hPtr, psPtr);
16581674 InsertPatSeq(&bindPtr->lookupTables, psPtr);
16591675 }
16631679 size_t length1 = strlen(oldStr);
16641680 size_t length2 = strlen(script);
16651681
1666 newStr = ckalloc(length1 + length2 + 2);
1682 newStr = (char *)ckalloc(length1 + length2 + 2);
16671683 memcpy(newStr, oldStr, length1);
16681684 newStr[length1] = '\n';
16691685 memcpy(newStr + length1 + 1, script, length2 + 1);
16701686 } else {
16711687 size_t length = strlen(script);
16721688
1673 newStr = ckalloc(length + 1);
1689 newStr = (char *)ckalloc(length + 1);
16741690 memcpy(newStr, script, length + 1);
16751691 }
16761692 ckfree(oldStr);
17251741 if (!(hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object))) {
17261742 Tcl_Panic("Tk_DeleteBinding couldn't find object table entry");
17271743 }
1728 prevPtr = Tcl_GetHashValue(hPtr);
1744 prevPtr = (PatSeq *)Tcl_GetHashValue(hPtr);
17291745 if (prevPtr == psPtr) {
17301746 Tcl_SetHashValue(hPtr, psPtr->ptr.nextObj);
17311747 } else {
18261842 * For each binding, output information about each of the patterns in its sequence.
18271843 */
18281844
1829 for (psPtr = Tcl_GetHashValue(hPtr); psPtr; psPtr = psPtr->ptr.nextObj) {
1845 for (psPtr = (const PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = psPtr->ptr.nextObj) {
18301846 assert(TEST_PSENTRY(psPtr));
18311847 Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(psPtr));
18321848 }
18651881 SetupPatternKey(&key, psPtr);
18661882
18671883 if ((hPtr = Tcl_FindHashEntry(&lookupTables->listTable, (char *) &key))) {
1868 PSList *psList = Tcl_GetHashValue(hPtr);
1884 PSList *psList = (PSList *)Tcl_GetHashValue(hPtr);
18691885 PSEntry *psEntry;
18701886
18711887 TK_DLIST_FOREACH(psEntry, psList) {
19491965 assert(!psPtr->added);
19501966 assert(!psPtr->owned);
19511967
1952 prevPtr = Tcl_GetHashValue(psPtr->hPtr);
1968 prevPtr = (PatSeq *)Tcl_GetHashValue(psPtr->hPtr);
19531969 nextPtr = psPtr->ptr.nextObj;
19541970
19551971 /*
20202036 ClearLookupTable(&bindPtr->lookupTables, object);
20212037 ClearPromotionLists(bindPtr, object);
20222038
2023 for (psPtr = Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
2039 for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
20242040 assert(TEST_PSENTRY(psPtr));
20252041 DEBUG(psPtr->added = 0;)
20262042 nextPtr = DeletePatSeq(psPtr);
21352151 TkDisplay *dispPtr;
21362152 TkDisplay *oldDispPtr;
21372153 Event *curEvent;
2138 TkWindow *winPtr = (TkWindow *) tkwin;
2154 TkWindow *winPtr = (TkWindow *)tkwin;
21392155 BindInfo *bindInfoPtr;
21402156 Tcl_InterpState interpState;
21412157 LookupTables *physTables;
21772193 return;
21782194 }
21792195
2180 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
2196 if (flags & HAS_XKEY_HEAD_AND_STATE) {
21812197 bindPtr->curModMask = eventPtr->xkey.state;
21822198 } else if (flags & CROSSING) {
21832199 bindPtr->curModMask = eventPtr->xcrossing.state;
21912207 * Ignore the event completely if it is an Enter, Leave, FocusIn, or
21922208 * FocusOut event with detail NotifyInferior. The reason for ignoring
21932209 * these events is that we don't want transitions between a window and its
2194 * children to visible to bindings on the parent: this would cause
2210 * children to be visible to bindings on the parent: this would cause
21952211 * problems for mega-widgets, since the internal structure of a
21962212 * mega-widget isn't supposed to be visible to people watching the parent.
21972213 *
22752291 switch (eventPtr->type) {
22762292 case KeyPress:
22772293 case KeyRelease:
2278 if (MatchEventRepeat(&curEvent->xev, eventPtr)) {
2294 if (MatchEventRepeat(&curEvent->xev.xkey, &eventPtr->xkey)) {
22792295 if (curEvent->xev.xkey.keycode == eventPtr->xkey.keycode) {
22802296 ++curEvent->countDetailed;
22812297 } else {
23452361
23462362 if ((size_t) numObjects > SIZE_OF_ARRAY(matchPtrBuf)) {
23472363 /* it's unrealistic that the buffer size is too small, but who knows? */
2348 matchPtrArr = ckalloc(numObjects*sizeof(matchPtrArr[0]));
2364 matchPtrArr = (PatSeq **)ckalloc(numObjects*sizeof(matchPtrArr[0]));
23492365 }
23502366 memset(matchPtrArr, 0, numObjects*sizeof(matchPtrArr[0]));
23512367
23862402 PSList *psSuccList = PromArr_First(bindPtr->promArr);
23872403 PatSeq *bestPtr;
23882404
2389 psl[0] = GetLookupForEvent(physTables, curEvent, objArr[k], 1);
2390 psl[1] = GetLookupForEvent(physTables, curEvent, objArr[k], 0);
2405 psl[0] = GetLookupForEvent(physTables, curEvent, (Tcl_Obj *)objArr[k], 1);
2406 psl[1] = GetLookupForEvent(physTables, curEvent, (Tcl_Obj *)objArr[k], 0);
23912407
23922408 assert(psl[0] == NULL || psl[0] != psl[1]);
23932409
24252441 LookupTables *virtTables = &bindInfoPtr->virtualEventTable.lookupTables;
24262442 PatSeq *matchPtr = matchPtrArr[k];
24272443 PatSeq *mPtr;
2428 PSList *psl[2];
24292444
24302445 /*
24312446 * Note that virtual events cannot promote.
24992514 switch (patPtr->eventType) {
25002515 case ButtonPress:
25012516 case ButtonRelease:
2502 if (curEvent->xev.type == KeyPress || curEvent->xev.type == KeyRelease) {
2517 if (IsKeyEventType(curEvent->xev.type)) {
25032518 RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
25042519 }
25052520 break;
25062521 case KeyPress:
25072522 case KeyRelease:
2508 if (curEvent->xev.type == ButtonPress || curEvent->xev.type == ButtonRelease) {
2523 if (IsButtonEventType(curEvent->xev.type)) {
25092524 RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
25102525 }
25112526 break;
27032718 CompareModMasks(
27042719 const PSModMaskArr *fstModMaskArr,
27052720 const PSModMaskArr *sndModMaskArr,
2706 ModMask fstModMask,
2707 ModMask sndModMask)
2721 unsigned fstModMask,
2722 unsigned sndModMask)
27082723 {
27092724 int fstCount = 0;
27102725 int sndCount = 0;
27282743 assert(PSModMaskArr_Size(fstModMaskArr) == PSModMaskArr_Size(sndModMaskArr));
27292744
27302745 for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) {
2731 ModMask fstModMask = *PSModMaskArr_Get(fstModMaskArr, i);
2732 ModMask sndModMask = *PSModMaskArr_Get(sndModMaskArr, i);
2733
2734 if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; }
2735 if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; }
2746 unsigned fstiModMask = *PSModMaskArr_Get(fstModMaskArr, i);
2747 unsigned sndiModMask = *PSModMaskArr_Get(sndModMaskArr, i);
2748
2749 if (IsSubsetOf(fstiModMask, sndiModMask)) { ++sndCount; }
2750 if (IsSubsetOf(sndiModMask, fstiModMask)) { ++fstCount; }
27362751 }
27372752 }
27382753
27622777 PSEntry *psEntry;
27632778 PatSeq *bestPtr;
27642779 PatSeq *bestPhysPtr;
2765 ModMask bestModMask;
2780 unsigned bestModMask;
27662781 const PSModMaskArr *bestModMaskArr = NULL;
2782 int i, isModKeyOnly = 0;
27672783
27682784 assert(dispPtr);
27692785 assert(bindPtr);
27782794 bestPhysPtr = NULL;
27792795 window = curEvent->xev.xany.window;
27802796
2797 /*
2798 * Modifier key events interlaced between patterns parts of a
2799 * sequence shall not prevent a sequence from ultimately
2800 * matching. Example: when trying to trigger <a><Control-c>
2801 * from the keyboard, the sequence of events actually seen is
2802 * <a> then <Control_L> (possibly repeating if the key is hold
2803 * down), and finally <Control-c>. At the time <Control_L> is
2804 * seen, we shall keep the <a><Control-c> pattern sequence in
2805 * the promotion list, otherwise it is impossible to trigger
2806 * it from the keyboard. See bug [16ef161925].
2807 */
2808 if (IsKeyEventType(curEvent->xev.type)) {
2809 for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
2810 if (dispPtr->modKeyCodes[i] == curEvent->xev.xkey.keycode) {
2811 isModKeyOnly = 1;
2812 break;
2813 }
2814 }
2815 }
2816
27812817 for (psEntry = PSList_First(psList); psEntry; psEntry = PSList_Next(psEntry)) {
27822818 if (patIndex == 0 || psEntry->window == window) {
27832819 PatSeq* psPtr = psEntry->psPtr;
27912827 ? psPtr->object == object
27922828 : VirtPatIsBound(bindPtr, psPtr, object, physPtrPtr)) {
27932829 TkPattern *patPtr = psPtr->pats + patIndex;
2830
2831 /* ignore modifier key events, and KeyRelease events if the current event
2832 * is of a different type (e.g. a Button event)
2833 */
2834 psEntry->keepIt = isModKeyOnly || \
2835 ((patPtr->eventType != (unsigned) curEvent->xev.type) && curEvent->xev.type == KeyRelease);
27942836
27952837 if (patPtr->eventType == (unsigned) curEvent->xev.type
27962838 && (curEvent->xev.type != CreateNotify
28022844 * cannot be done in ParseEventDescription, otherwise this function would
28032845 * be the better place.
28042846 */
2805 ModMask modMask = ResolveModifiers(dispPtr, patPtr->modMask);
2806 ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask);
2847 unsigned modMask = ResolveModifiers(dispPtr, patPtr->modMask);
2848 unsigned curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask);
28072849
28082850 psEntry->expired = 1; /* remove it from promotion list */
2809
2810 if ((modMask & ~curModMask) == 0) {
2851 psEntry->keepIt = 0; /* don't keep matching patterns */
2852
2853 if (IsSubsetOf(modMask, curModMask)) {
28112854 unsigned count = patPtr->info ? curEvent->countDetailed : curEvent->countAny;
28122855
28132856 if (patIndex < PSModMaskArr_Size(psEntry->lastModMaskArr)) {
29232966 evPtr = &eventPtr->xev;
29242967 flags = (evPtr->type < TK_LASTEVENT) ? flagArray[evPtr->type] : 0;
29252968
2969 #define SET_NUMBER(value) { number = (value); \
2970 snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "d", number); \
2971 string = numStorage; \
2972 }
2973
2974 #define SET_UNUMBER(value) { unumber = (value); \
2975 snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "u", unumber); \
2976 string = numStorage; \
2977 }
2978
29262979 while (1) {
29272980 char numStorage[TCL_INTEGER_SPACE];
29282981 const char *string;
2929 Tcl_WideInt number;
2982 Tcl_WideInt number; /* signed */
2983 Tcl_WideUInt unumber; /* unsigned */
29302984
29312985 /*
29322986 * Find everything up to the next % character and append it to the
29473001 * There's a percent sequence here. Process it.
29483002 */
29493003
2950 number = NO_NUMBER;
29513004 string = "??";
2952
29533005 switch (before[1]) {
29543006 case '#':
2955 number = evPtr->xany.serial;
3007 SET_UNUMBER(evPtr->xany.serial);
29563008 break;
29573009 case 'a':
29583010 if (flags & CONFIG) {
29623014 break;
29633015 case 'b':
29643016 if (flags & BUTTON) {
2965 number = evPtr->xbutton.button;
3017 SET_UNUMBER(evPtr->xbutton.button);
29663018 }
29673019 break;
29683020 case 'c':
29693021 if (flags & EXPOSE) {
2970 number = evPtr->xexpose.count;
3022 SET_NUMBER(evPtr->xexpose.count);
29713023 }
29723024 break;
29733025 case 'd':
29873039 break;
29883040 case 'f':
29893041 if (flags & CROSSING) {
2990 number = evPtr->xcrossing.focus;
3042 SET_NUMBER(evPtr->xcrossing.focus != 0);
29913043 }
29923044 break;
29933045 case 'h':
29943046 if (flags & EXPOSE) {
2995 number = evPtr->xexpose.height;
3047 SET_NUMBER(evPtr->xexpose.height);
29963048 } else if (flags & CONFIG) {
2997 number = evPtr->xconfigure.height;
3049 SET_NUMBER(evPtr->xconfigure.height);
29983050 } else if (flags & CREATE) {
2999 number = evPtr->xcreatewindow.height;
3051 SET_NUMBER(evPtr->xcreatewindow.height);
30003052 } else if (flags & CONFIGREQ) {
3001 number = evPtr->xconfigurerequest.height;
3053 SET_NUMBER(evPtr->xconfigurerequest.height);
30023054 } else if (flags & RESIZEREQ) {
3003 number = evPtr->xresizerequest.height;
3055 SET_NUMBER(evPtr->xresizerequest.height);
30043056 }
30053057 break;
30063058 case 'i':
30163068 string = numStorage;
30173069 break;
30183070 case 'k':
3019 if ((flags & KEY) && evPtr->type != MouseWheelEvent) {
3020 number = evPtr->xkey.keycode;
3071 if (flags & KEY) {
3072 SET_UNUMBER(evPtr->xkey.keycode);
30213073 }
30223074 break;
30233075 case 'm':
30293081 break;
30303082 case 'o':
30313083 if (flags & CREATE) {
3032 number = evPtr->xcreatewindow.override_redirect;
3084 SET_NUMBER(evPtr->xcreatewindow.override_redirect != 0);
30333085 } else if (flags & MAP) {
3034 number = evPtr->xmap.override_redirect;
3086 SET_NUMBER(evPtr->xmap.override_redirect != 0);
30353087 } else if (flags & REPARENT) {
3036 number = evPtr->xreparent.override_redirect;
3088 SET_NUMBER(evPtr->xreparent.override_redirect != 0);
30373089 } else if (flags & CONFIG) {
3038 number = evPtr->xconfigure.override_redirect;
3090 SET_NUMBER(evPtr->xconfigure.override_redirect != 0);
30393091 }
30403092 break;
30413093 case 'p':
30463098 }
30473099 break;
30483100 case 's':
3049 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
3050 number = evPtr->xkey.state;
3101 if (flags & HAS_XKEY_HEAD_AND_STATE) {
3102 SET_UNUMBER(evPtr->xkey.state);
30513103 } else if (flags & CROSSING) {
3052 number = evPtr->xcrossing.state;
3104 SET_UNUMBER(evPtr->xcrossing.state);
30533105 } else if (flags & PROP) {
30543106 string = TkFindStateString(propNotify, evPtr->xproperty.state);
30553107 } else if (flags & VISIBILITY) {
30573109 }
30583110 break;
30593111 case 't':
3060 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
3061 number = (int) evPtr->xkey.time;
3062 } else if (flags & CROSSING) {
3063 number = (int) evPtr->xcrossing.time;
3112 if (flags & HAS_XKEY_HEAD) {
3113 SET_UNUMBER(evPtr->xkey.time);
30643114 } else if (flags & PROP) {
3065 number = (int) evPtr->xproperty.time;
3115 SET_UNUMBER(evPtr->xproperty.time);
30663116 }
30673117 break;
30683118 case 'v':
3069 number = evPtr->xconfigurerequest.value_mask;
3119 SET_UNUMBER(evPtr->xconfigurerequest.value_mask);
30703120 break;
30713121 case 'w':
30723122 if (flags & EXPOSE) {
3073 number = evPtr->xexpose.width;
3123 SET_NUMBER(evPtr->xexpose.width);
30743124 } else if (flags & CONFIG) {
3075 number = evPtr->xconfigure.width;
3125 SET_NUMBER(evPtr->xconfigure.width);
30763126 } else if (flags & CREATE) {
3077 number = evPtr->xcreatewindow.width;
3127 SET_NUMBER(evPtr->xcreatewindow.width);
30783128 } else if (flags & CONFIGREQ) {
3079 number = evPtr->xconfigurerequest.width;
3129 SET_NUMBER(evPtr->xconfigurerequest.width);
30803130 } else if (flags & RESIZEREQ) {
3081 number = evPtr->xresizerequest.width;
3131 SET_NUMBER(evPtr->xresizerequest.width);
30823132 }
30833133 break;
30843134 case 'x':
3085 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
3086 number = evPtr->xkey.x;
3087 } else if (flags & CROSSING) {
3088 number = evPtr->xcrossing.x;
3135 if (flags & HAS_XKEY_HEAD) {
3136 SET_NUMBER(evPtr->xkey.x);
30893137 } else if (flags & EXPOSE) {
3090 number = evPtr->xexpose.x;
3138 SET_NUMBER(evPtr->xexpose.x);
30913139 } else if (flags & (CREATE|CONFIG|GRAVITY)) {
3092 number = evPtr->xcreatewindow.x;
3140 SET_NUMBER(evPtr->xcreatewindow.x);
30933141 } else if (flags & REPARENT) {
3094 number = evPtr->xreparent.x;
3095 } else if (flags & CREATE) {
3096 number = evPtr->xcreatewindow.x;
3142 SET_NUMBER(evPtr->xreparent.x);
30973143 } else if (flags & CONFIGREQ) {
3098 number = evPtr->xconfigurerequest.x;
3144 SET_NUMBER(evPtr->xconfigurerequest.x);
30993145 }
31003146 break;
31013147 case 'y':
3102 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
3103 number = evPtr->xkey.y;
3148 if (flags & HAS_XKEY_HEAD) {
3149 SET_NUMBER(evPtr->xkey.y);
31043150 } else if (flags & EXPOSE) {
3105 number = evPtr->xexpose.y;
3151 SET_NUMBER(evPtr->xexpose.y);
31063152 } else if (flags & (CREATE|CONFIG|GRAVITY)) {
3107 number = evPtr->xcreatewindow.y;
3153 SET_NUMBER(evPtr->xcreatewindow.y);
31083154 } else if (flags & REPARENT) {
3109 number = evPtr->xreparent.y;
3110 } else if (flags & CROSSING) {
3111 number = evPtr->xcrossing.y;
3112 } else if (flags & CREATE) {
3113 number = evPtr->xcreatewindow.y;
3155 SET_NUMBER(evPtr->xreparent.y);
31143156 } else if (flags & CONFIGREQ) {
3115 number = evPtr->xconfigurerequest.y;
3157 SET_NUMBER(evPtr->xconfigurerequest.y);
31163158 }
31173159 break;
31183160 case 'A':
3119 if ((flags & KEY) && evPtr->type != MouseWheelEvent) {
3161 if (flags & KEY) {
31203162 Tcl_DStringFree(&buf);
31213163 string = TkpGetString(winPtr, evPtr, &buf);
31223164 }
31233165 break;
31243166 case 'B':
31253167 if (flags & CREATE) {
3126 number = evPtr->xcreatewindow.border_width;
3168 SET_NUMBER(evPtr->xcreatewindow.border_width);
31273169 } else if (flags & CONFIGREQ) {
3128 number = evPtr->xconfigurerequest.border_width;
3170 SET_NUMBER(evPtr->xconfigurerequest.border_width);
31293171 } else if (flags & CONFIG) {
3130 number = evPtr->xconfigure.border_width;
3172 SET_NUMBER(evPtr->xconfigure.border_width);
31313173 }
31323174 break;
31333175 case 'D':
3134 /*
3135 * This is used only by the MouseWheel event.
3136 */
3137 if ((flags & KEY) && evPtr->type == MouseWheelEvent) {
3138 number = evPtr->xkey.keycode;
3176 if (flags & WHEEL) {
3177 SET_NUMBER((int)evPtr->xbutton.button); /* mis-use button field for this */
31393178 }
31403179 break;
31413180 case 'E':
3142 number = (int) evPtr->xany.send_event;
3181 SET_NUMBER(evPtr->xany.send_event != 0);
31433182 break;
31443183 case 'K':
3145 if ((flags & KEY) && evPtr->type != MouseWheelEvent) {
3184 if (flags & KEY) {
31463185 const char *name = TkKeysymToString(eventPtr->detail.info);
31473186 if (name) {
31483187 string = name;
31503189 }
31513190 break;
31523191 case 'M':
3153 number = scriptCount;
3192 SET_UNUMBER(scriptCount);
31543193 break;
31553194 case 'N':
3156 if ((flags & KEY) && evPtr->type != MouseWheelEvent) {
3157 number = (int) eventPtr->detail.info;
3195 if (flags & KEY) {
3196 SET_UNUMBER(eventPtr->detail.info);
31583197 }
31593198 break;
31603199 case 'P':
31633202 }
31643203 break;
31653204 case 'R':
3166 if (flags & KEY_BUTTON_MOTION_CROSSING) {
3205 if (flags & HAS_XKEY_HEAD) {
31673206 TkpPrintWindowId(numStorage, evPtr->xkey.root);
31683207 string = numStorage;
31693208 }
31703209 break;
31713210 case 'S':
3172 if (flags & KEY_BUTTON_MOTION_CROSSING) {
3211 if (flags & HAS_XKEY_HEAD) {
31733212 TkpPrintWindowId(numStorage, evPtr->xkey.subwindow);
31743213 string = numStorage;
31753214 }
31763215 break;
31773216 case 'T':
3178 number = evPtr->type;
3217 SET_NUMBER(evPtr->type);
31793218 break;
31803219 case 'W': {
31813220 Tk_Window tkwin = Tk_IdToWindow(evPtr->xany.display, evPtr->xany.window);
31853224 break;
31863225 }
31873226 case 'X':
3188 if (flags & KEY_BUTTON_MOTION_CROSSING) {
3189 number = evPtr->xkey.x_root;
3227 if (flags & HAS_XKEY_HEAD) {
3228 SET_NUMBER(evPtr->xkey.x_root);
31903229 }
31913230 break;
31923231 case 'Y':
3193 if (flags & KEY_BUTTON_MOTION_CROSSING) {
3194 number = evPtr->xkey.y_root;
3232 if (flags & HAS_XKEY_HEAD) {
3233 SET_NUMBER(evPtr->xkey.y_root);
31953234 }
31963235 break;
31973236 default:
31993238 numStorage[1] = '\0';
32003239 string = numStorage;
32013240 break;
3202 }
3203
3204 if (number != NO_NUMBER) {
3205 snprintf(numStorage, sizeof(numStorage), "%d", (int) number);
3206 string = numStorage;
32073241 }
32083242 { /* local scope */
32093243 int cvtFlags;
32173251 before += 2;
32183252 }
32193253 }
3254
3255 #undef SET_NUMBER
3256 #undef SET_UNUMBER
32203257
32213258 Tcl_DStringFree(&buf);
32223259 }
34293466 PatSeq *nextPtr;
34303467 PatSeq *psPtr;
34313468
3432 for (psPtr = Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
3469 for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
34333470 assert(TEST_PSENTRY(psPtr));
34343471 nextPtr = psPtr->nextSeqPtr;
34353472 DEBUG(psPtr->owned = 0;)
34433480 ckfree(Tcl_GetHashValue(hPtr));
34443481 }
34453482 Tcl_DeleteHashTable(&vetPtr->nameTable);
3483
3484 ClearLookupTable(&vetPtr->lookupTables, NULL);
34463485 Tcl_DeleteHashTable(&vetPtr->lookupTables.listTable);
34473486
3448 ClearLookupTable(&vetPtr->lookupTables, NULL);
34493487 DEBUG(countEntryItems -= PSList_Size(&vetPtr->lookupTables.entryPool);)
34503488 PSList_Traverse(&vetPtr->lookupTables.entryPool, FreePatSeqEntry);
34513489 }
34593497 * already defined, the new definition augments those that already exist.
34603498 *
34613499 * Results:
3462 * The return value is TCL_ERROR if an error occured while creating the
3500 * The return value is TCL_ERROR if an error occurred while creating the
34633501 * virtual binding. In this case, an error message will be left in the
34643502 * interp's result. If all went well then the return value is TCL_OK.
34653503 *
35103548 * Make virtual event own the physical event.
35113549 */
35123550
3513 owned = Tcl_GetHashValue(vhPtr);
3551 owned = (PhysOwned *)Tcl_GetHashValue(vhPtr);
35143552
35153553 if (!PhysOwned_Contains(owned, psPtr)) {
35163554 PhysOwned_Append(&owned, psPtr);
35723610 if (!(vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid))) {
35733611 return TCL_OK;
35743612 }
3575 owned = Tcl_GetHashValue(vhPtr);
3613 owned = (PhysOwned *)Tcl_GetHashValue(vhPtr);
35763614
35773615 eventPSPtr = NULL;
35783616 if (eventString) {
37043742 }
37053743
37063744 resultObj = Tcl_NewObj();
3707 owned = Tcl_GetHashValue(vhPtr);
3745 owned = (const PhysOwned *)Tcl_GetHashValue(vhPtr);
37083746 for (iPhys = 0; iPhys < PhysOwned_Size(owned); ++iPhys) {
37093747 Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(PhysOwned_Get(owned, iPhys)));
37103748 }
37933831 int objc, /* Number of arguments. */
37943832 Tcl_Obj *const objv[]) /* Argument objects. */
37953833 {
3796 union { XEvent general; XVirtualEvent virtual; } event;
3834 union { XEvent general; XVirtualEvent virt; } event;
37973835
37983836 const char *p;
37993837 const char *name;
38033841 Tk_Window tkwin;
38043842 Tk_Window tkwin2;
38053843 TkWindow *mainPtr;
3806 EventMask eventMask;
3844 unsigned eventMask;
38073845 Tcl_Obj *userDataObj;
38083846 int synch;
38093847 int warp;
38893927 Tk_DestroyWindow(tkwin);
38903928 return TCL_OK;
38913929 }
3892 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
3930 if (flags & HAS_XKEY_HEAD_AND_STATE) {
38933931 event.general.xkey.state = pat.modMask;
3894 if ((flags & KEY) && event.general.xany.type != MouseWheelEvent) {
3932 if (flags & KEY) {
38953933 TkpSetKeycodeAndState(tkwin, pat.info, &event.general);
38963934 } else if (flags & BUTTON) {
38973935 event.general.xbutton.button = pat.info;
38983936 } else if (flags & VIRTUAL) {
3899 event.virtual.name = pat.name;
3937 event.virt.name = pat.name;
39003938 }
39013939 }
39023940 if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
39033941 event.general.xcreatewindow.window = event.general.xany.window;
39043942 }
39053943
3906 if (flags & KEY_BUTTON_MOTION_CROSSING) {
3944 if (flags & HAS_XKEY_HEAD) {
39073945 event.general.xkey.x_root = -1;
39083946 event.general.xkey.y_root = -1;
39093947 }
39513989 if (Tcl_GetBooleanFromObj(interp, valuePtr, &warp) != TCL_OK) {
39523990 return TCL_ERROR;
39533991 }
3954 if (!(flags & KEY_BUTTON_MOTION_VIRTUAL)) {
3992 if (!(flags & CAN_WARP)) {
39553993 badOpt = 1;
39563994 }
39573995 break;
40184056 if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
40194057 return TCL_ERROR;
40204058 }
4021 if ((flags & KEY) && event.general.xkey.type == MouseWheelEvent) {
4022 event.general.xkey.keycode = number;
4059 if (flags & WHEEL) {
4060 event.general.xbutton.button = (unsigned)number; /* mis-use button field for this */
40234061 } else {
40244062 badOpt = 1;
40254063 }
40634101 if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
40644102 return TCL_ERROR;
40654103 }
4066 if ((flags & KEY) && event.general.xkey.type != MouseWheelEvent) {
4104 if (flags & KEY) {
40674105 event.general.xkey.keycode = number;
40684106 } else {
40694107 badOpt = 1;
40874125 Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value, NULL);
40884126 return TCL_ERROR;
40894127 }
4090 if (!(flags & KEY) || (event.general.xkey.type == MouseWheelEvent)) {
4128 if (!(flags & KEY)) {
40914129 badOpt = 1;
40924130 }
40934131 break;
41344172 if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
41354173 return TCL_ERROR;
41364174 }
4137 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4175 if (flags & HAS_XKEY_HEAD) {
41384176 event.general.xkey.root = Tk_WindowId(tkwin2);
41394177 } else {
41404178 badOpt = 1;
41444182 if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
41454183 return TCL_ERROR;
41464184 }
4147 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4185 if (flags & HAS_XKEY_HEAD) {
41484186 event.general.xkey.x_root = number;
41494187 } else {
41504188 badOpt = 1;
41544192 if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
41554193 return TCL_ERROR;
41564194 }
4157 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4195 if (flags & HAS_XKEY_HEAD) {
41584196 event.general.xkey.y_root = number;
41594197 } else {
41604198 badOpt = 1;
41934231 event.general.xany.serial = number;
41944232 break;
41954233 case EVENT_STATE:
4196 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4234 if (flags & HAS_XKEY_HEAD) {
41974235 if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
41984236 return TCL_ERROR;
41994237 }
4200 if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
4238 if (flags & HAS_XKEY_HEAD_AND_STATE) {
42014239 event.general.xkey.state = number;
42024240 } else {
42034241 event.general.xcrossing.state = number;
42154253 if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
42164254 return TCL_ERROR;
42174255 }
4218 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4256 if (flags & HAS_XKEY_HEAD) {
42194257 event.general.xkey.subwindow = Tk_WindowId(tkwin2);
42204258 } else {
42214259 badOpt = 1;
42294267 } else if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
42304268 return TCL_ERROR;
42314269 }
4232 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4270 if (flags & HAS_XKEY_HEAD) {
42334271 event.general.xkey.time = number;
42344272 } else if (flags & PROP) {
42354273 event.general.xproperty.time = number;
42644302 if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
42654303 return TCL_ERROR;
42664304 }
4267 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4305 if (flags & HAS_XKEY_HEAD) {
42684306 event.general.xkey.x = number;
42694307
42704308 /*
42914329 if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
42924330 return TCL_ERROR;
42934331 }
4294 if (flags & KEY_BUTTON_MOTION_CROSSING) {
4332 if (flags & HAS_XKEY_HEAD) {
42954333 event.general.xkey.y = number;
42964334
42974335 /*
43364374 * refcount before firing it into the low-level event subsystem; the
43374375 * refcount will be decremented once the event has been processed.
43384376 */
4339 event.virtual.user_data = userDataObj;
4377 event.virt.user_data = userDataObj;
43404378 Tcl_IncrRefCount(userDataObj);
4341 }
4342
4343 /*
4344 * Now we have constructed the event, inject it into the event handling
4345 * code.
4346 */
4347
4348 if (synch) {
4349 Tk_HandleEvent(&event.general);
4350 } else {
4351 Tk_QueueWindowEvent(&event.general, pos);
43524379 }
43534380
43544381 /*
43594386 TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
43604387
43614388 Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window);
4362
4363 if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
4364 Tcl_DoWhenIdle(DoWarp, dispPtr);
4365 dispPtr->flags |= TK_DISPLAY_IN_WARP;
4366 }
43674389
43684390 if (warpWindow != dispPtr->warpWindow) {
43694391 if (warpWindow) {
43774399 dispPtr->warpMainwin = mainWin;
43784400 dispPtr->warpX = event.general.xmotion.x;
43794401 dispPtr->warpY = event.general.xmotion.y;
4402
4403 if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
4404 Tcl_DoWhenIdle(DoWarp, dispPtr);
4405 dispPtr->flags |= TK_DISPLAY_IN_WARP;
4406 }
4407 }
4408
4409 /*
4410 * Now we have constructed the event, inject it into the event handling
4411 * code.
4412 */
4413
4414 if (synch) {
4415 Tk_HandleEvent(&event.general);
4416 } else {
4417 Tk_QueueWindowEvent(&event.general, pos);
43804418 }
43814419 }
43824420
45754613 * 1 means create. */
45764614 int allowVirtual, /* 0 means that virtual events are not allowed in the sequence.
45774615 * 1 otherwise. */
4578 EventMask *maskPtr) /* *maskPtr is filled in with the event types on which this
4616 unsigned *maskPtr) /* *maskPtr is filled in with the event types on which this
45794617 * pattern sequence depends. */
45804618 {
45814619 unsigned patsBufSize = 1;
45894627 int isNew;
45904628 unsigned count;
45914629 unsigned maxCount = 0;
4592 EventMask eventMask = 0;
4593 ModMask modMask = 0;
4630 unsigned eventMask = 0;
4631 unsigned modMask = 0;
45944632 PatternTableKey key;
45954633
45964634 assert(lookupTables);
45974635 assert(eventString);
45984636
4599 psPtr = ckalloc(PATSEQ_MEMSIZE(patsBufSize));
4637 psPtr = (PatSeq *)ckalloc(PATSEQ_MEMSIZE(patsBufSize));
46004638
46014639 /*
46024640 *------------------------------------------------------------------
46084646 if (numPats >= patsBufSize) {
46094647 unsigned pos = patPtr - psPtr->pats;
46104648 patsBufSize += patsBufSize;
4611 psPtr = ckrealloc(psPtr, PATSEQ_MEMSIZE(patsBufSize));
4649 psPtr = (PatSeq *)ckrealloc(psPtr, PATSEQ_MEMSIZE(patsBufSize));
46124650 patPtr = psPtr->pats + pos;
46134651 }
46144652
46574695 return NULL;
46584696 }
46594697 if (patsBufSize > numPats) {
4660 psPtr = ckrealloc(psPtr, PATSEQ_MEMSIZE(numPats));
4698 psPtr = (PatSeq *)ckrealloc(psPtr, PATSEQ_MEMSIZE(numPats));
46614699 }
46624700
46634701 patPtr = psPtr->pats;
4664 psPtr->object = object;
4702 psPtr->object = (Tcl_Obj *)object;
46654703 SetupPatternKey(&key, psPtr);
46664704 hPtr = Tcl_CreateHashEntry(&lookupTables->patternTable, (char *) &key, &isNew);
46674705 if (!isNew) {
46684706 unsigned sequenceSize = numPats*sizeof(TkPattern);
46694707 PatSeq *psPtr2;
46704708
4671 for (psPtr2 = Tcl_GetHashValue(hPtr); psPtr2; psPtr2 = psPtr2->nextSeqPtr) {
4709 for (psPtr2 = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr2; psPtr2 = psPtr2->nextSeqPtr) {
46724710 assert(TEST_PSENTRY(psPtr2));
46734711 if (numPats == psPtr2->numPats && memcmp(patPtr, psPtr2->pats, sequenceSize) == 0) {
46744712 ckfree(psPtr);
47044742 psPtr->added = 0;
47054743 psPtr->modMaskUsed = (modMask != 0);
47064744 psPtr->script = NULL;
4707 psPtr->nextSeqPtr = Tcl_GetHashValue(hPtr);
4745 psPtr->nextSeqPtr = (PatSeq *)Tcl_GetHashValue(hPtr);
47084746 psPtr->hPtr = hPtr;
47094747 psPtr->ptr.nextObj = NULL;
47104748 assert(psPtr->ptr.owners == NULL);
47644802 const char **eventStringPtr,/* On input, holds a pointer to start of event string. On exit,
47654803 * gets pointer to rest of string after parsed event. */
47664804 TkPattern *patPtr, /* Filled with the pattern parsed from the event string. */
4767 EventMask *eventMaskPtr) /* Filled with event mask of matched event. */
4805 unsigned *eventMaskPtr) /* Filled with event mask of matched event. */
47684806 {
47694807 const char *p;
4770 EventMask eventMask = 0;
4808 unsigned eventMask = 0;
47714809 unsigned count = 1;
47724810
47734811 assert(eventStringPtr);
48464884
48474885 size = p - field;
48484886 if (size >= sizeof(buf)) {
4849 bufPtr = ckalloc(size + 1);
4887 bufPtr = (char *)ckalloc(size + 1);
48504888 }
48514889 strncpy(bufPtr, field, size);
48524890 bufPtr[size] = '\0';
48784916 if (!(hPtr = Tcl_FindHashEntry(&modTable, field))) {
48794917 break;
48804918 }
4881 modPtr = Tcl_GetHashValue(hPtr);
4919 modPtr = (ModInfo *)Tcl_GetHashValue(hPtr);
48824920 patPtr->modMask |= modPtr->mask;
48834921 if (modPtr->flags & MULT_CLICKS) {
48844922 unsigned i = modPtr->flags & MULT_CLICKS;
48934931
48944932 eventFlags = 0;
48954933 if ((hPtr = Tcl_FindHashEntry(&eventTable, field))) {
4896 const EventInfo *eiPtr = Tcl_GetHashValue(hPtr);
4934 const EventInfo *eiPtr = (const EventInfo *)Tcl_GetHashValue(hPtr);
48974935
48984936 patPtr->eventType = eiPtr->type;
48994937 eventFlags = flagArray[eiPtr->type];
50805118 assert(patPtr->name);
50815119 Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->name);
50825120 } else {
5083 ModMask modMask;
5121 unsigned modMask;
50845122 const ModInfo *modPtr;
50855123
50865124 /*
51295167 case ButtonPress:
51305168 case ButtonRelease:
51315169 assert(patPtr->info <= Button5);
5132 Tcl_AppendPrintfToObj(patternObj, "-%d", (int) patPtr->info);
5170 Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned) patPtr->info);
51335171 break;
51345172 #if PRINT_SHORT_MOTION_SYNTAX
51355173 case MotionNotify: {
5136 ModMask mask = patPtr->modMask;
5174 unsigned mask = patPtr->modMask;
51375175 while (mask & ALL_BUTTONS) {
51385176 unsigned button = ButtonNumberFromState(mask);
51395177 Tcl_AppendPrintfToObj(patternObj, "-%u", button);
52175255 Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
52185256
52195257 if (hPtr) {
5220 return Tcl_GetHashValue(hPtr);
5258 return (const char *)Tcl_GetHashValue(hPtr);
52215259 }
52225260 #endif /* REDO_KEYSYM_LOOKUP */
52235261
5353 Window parent);
5454 static inline Tk_Window NextChild(Tk_Window tkwin);
5555 static void RefWinEventProc(ClientData clientData,
56 register XEvent *eventPtr);
56 XEvent *eventPtr);
5757 static inline void SetWindowInstanceData(Tk_Window tkwin,
5858 ClientData instanceData);
5959
121121 *----------------------------------------------------------------------
122122 */
123123
124 /* ARGSUSED */
125124 static void
126125 BusyCustodyProc(
127126 ClientData clientData, /* Information about the busy window. */
128 Tk_Window tkwin) /* Not used. */
129 {
130 Busy *busyPtr = clientData;
127 TCL_UNUSED(Tk_Window)) /* Not used. */
128 {
129 Busy *busyPtr = (Busy *)clientData;
131130
132131 Tk_DeleteEventHandler(busyPtr->tkBusy, StructureNotifyMask, BusyEventProc,
133132 busyPtr);
155154 *----------------------------------------------------------------------
156155 */
157156
158 /* ARGSUSED */
159157 static void
160158 BusyGeometryProc(
161 ClientData clientData, /* Information about window that got new
159 TCL_UNUSED(void *), /* Information about window that got new
162160 * preferred geometry. */
163 Tk_Window tkwin) /* Other Tk-related information about the
161 TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
164162 * window. */
165163 {
166164 /* Should never get here */
248246 static void
249247 RefWinEventProc(
250248 ClientData clientData, /* Busy window record */
251 register XEvent *eventPtr) /* Event which triggered call to routine */
252 {
253 register Busy *busyPtr = clientData;
249 XEvent *eventPtr) /* Event which triggered call to routine */
250 {
251 Busy *busyPtr = (Busy *)clientData;
254252
255253 switch (eventPtr->type) {
256254 case ReparentNotify:
332330 DestroyBusy(
333331 void *data) /* Busy window structure record */
334332 {
335 register Busy *busyPtr = data;
333 Busy *busyPtr = (Busy *)data;
336334
337335 if (busyPtr->hashPtr != NULL) {
338336 Tcl_DeleteHashEntry(busyPtr->hashPtr);
376374 ClientData clientData, /* Busy window record */
377375 XEvent *eventPtr) /* Event which triggered call to routine */
378376 {
379 Busy *busyPtr = clientData;
377 Busy *busyPtr = (Busy *)clientData;
380378
381379 if (eventPtr->type == DestroyNotify) {
382380 busyPtr->tkBusy = NULL;
526524 Window parent;
527525 Tk_FakeWin *winPtr;
528526
529 busyPtr = ckalloc(sizeof(Busy));
527 busyPtr = (Busy *)ckalloc(sizeof(Busy));
530528 x = y = 0;
531529 length = strlen(Tk_Name(tkRef));
532 name = ckalloc(length + 6);
530 name = (char *)ckalloc(length + 6);
533531 if (Tk_IsTopLevel(tkRef)) {
534532 fmt = "_Busy"; /* Child */
535533 tkParent = tkRef;
695693 Tcl_GetString(windowObj), NULL);
696694 return NULL;
697695 }
698 return Tcl_GetHashValue(hPtr);
696 return (Busy *)Tcl_GetHashValue(hPtr);
699697 }
700698
701699 /*
745743 Tcl_SetHashValue(hPtr, busyPtr);
746744 busyPtr->hashPtr = hPtr;
747745 } else {
748 busyPtr = Tcl_GetHashValue(hPtr);
746 busyPtr = (Busy *)Tcl_GetHashValue(hPtr);
749747 }
750748
751749 busyPtr->tablePtr = busyTablePtr;
788786 int objc, /* Number of arguments. */
789787 Tcl_Obj *const objv[]) /* Argument objects. */
790788 {
791 Tk_Window tkwin = clientData;
789 Tk_Window tkwin = (Tk_Window)clientData;
792790 Tcl_HashTable *busyTablePtr = &((TkWindow *) tkwin)->mainPtr->busyTable;
793791 Busy *busyPtr;
794792 Tcl_Obj *objPtr;
854852 }
855853 Tcl_Preserve(busyPtr);
856854 if (objc <= 4) {
857 objPtr = Tk_GetOptionInfo(interp, (char *) busyPtr,
855 objPtr = Tk_GetOptionInfo(interp, (char *)busyPtr,
858856 busyPtr->optionTable, (objc == 4) ? objv[3] : NULL,
859857 busyPtr->tkBusy);
860858 if (objPtr == NULL) {
876874 objPtr = Tcl_NewObj();
877875 for (hPtr = Tcl_FirstHashEntry(busyTablePtr, &cursor); hPtr != NULL;
878876 hPtr = Tcl_NextHashEntry(&cursor)) {
879 busyPtr = Tcl_GetHashValue(hPtr);
877 busyPtr = (Busy *)Tcl_GetHashValue(hPtr);
880878 if (pattern == NULL ||
881879 Tcl_StringCaseMatch(Tk_PathName(busyPtr->tkRef), pattern, 0)) {
882880 Tcl_ListObjAppendElement(interp, objPtr,
305305 */
306306
307307 #ifndef TkpButtonSetDefaults
308 MODULE_SCOPE void TkpButtonSetDefaults();
308 MODULE_SCOPE void TkpButtonSetDefaults(void);
309309 #endif
310310 MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
311311 MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
351351 objs[2] = Tcl_NewDoubleObj(arcPtr->bbox[2]);
352352 objs[3] = Tcl_NewDoubleObj(arcPtr->bbox[3]);
353353 Tcl_SetObjResult(interp, Tcl_NewListObj(4, objs));
354 } else if ((objc == 1)||(objc == 4)) {
355 if (objc==1) {
354 } else if ((objc == 1) || (objc == 4)) {
355 if (objc == 1) {
356356 if (Tcl_ListObjGetElements(interp, objv[0], &objc,
357357 (Tcl_Obj ***) &objv) != TCL_OK) {
358358 return TCL_ERROR;
509509 if (arcPtr->disabledFillStipple!=None) {
510510 stipple = arcPtr->disabledFillStipple;
511511 }
512 }
512 }
513513
514514 if (arcPtr->style == ARC_STYLE) {
515515 newGC = NULL;
575575
576576 static void
577577 DeleteArc(
578 Tk_Canvas canvas, /* Info about overall canvas. */
578 TCL_UNUSED(Tk_Canvas), /* Info about overall canvas. */
579579 Tk_Item *itemPtr, /* Item that is being deleted. */
580580 Display *display) /* Display containing window for canvas. */
581581 {
582 ArcItem *arcPtr = (ArcItem *) itemPtr;
582 ArcItem *arcPtr = (ArcItem *)itemPtr;
583583
584584 Tk_DeleteOutline(display, &(arcPtr->outline));
585585 if (arcPtr->numOutlinePoints != 0) {
625625 *--------------------------------------------------------------
626626 */
627627
628 /* ARGSUSED */
629628 static void
630629 ComputeArcBbox(
631630 Tk_Canvas canvas, /* Canvas that contains item. */
662661 */
663662
664663 if (arcPtr->bbox[1] > arcPtr->bbox[3]) {
665 double tmp = arcPtr->bbox[3];
664 tmp = arcPtr->bbox[3];
666665
667666 arcPtr->bbox[3] = arcPtr->bbox[1];
668667 arcPtr->bbox[1] = tmp;
669668 }
670669 if (arcPtr->bbox[0] > arcPtr->bbox[2]) {
671 double tmp = arcPtr->bbox[2];
670 tmp = arcPtr->bbox[2];
672671
673672 arcPtr->bbox[2] = arcPtr->bbox[0];
674673 arcPtr->bbox[0] = tmp;
677676 ComputeArcOutline(canvas,arcPtr);
678677
679678 /*
680 * To compute the bounding box, start with the the bbox formed by the two
679 * To compute the bounding box, start with the bbox formed by the two
681680 * endpoints of the arc. Then add in the center of the arc's oval (if
682681 * relevant) and the 3-o'clock, 6-o'clock, 9-o'clock, and 12-o'clock
683682 * positions, if they are relevant.
768767 Tk_Item *itemPtr, /* Item to be displayed. */
769768 Display *display, /* Display on which to draw item. */
770769 Drawable drawable, /* Pixmap or window in which to draw item. */
771 int x, int y, /* Describes region of canvas that must be */
772 int width, int height) /* redisplayed (not used). */
770 TCL_UNUSED(int), /* Describes region of canvas that must be */
771 TCL_UNUSED(int), /* redisplayed (not used). */
772 TCL_UNUSED(int),
773 TCL_UNUSED(int))
773774 {
774775 ArcItem *arcPtr = (ArcItem *) itemPtr;
775776 short x1, y1, x2, y2;
941942 *--------------------------------------------------------------
942943 */
943944
944 /* ARGSUSED */
945945 static double
946946 ArcToPoint(
947947 Tk_Canvas canvas, /* Canvas containing item. */
11061106 *--------------------------------------------------------------
11071107 */
11081108
1109 /* ARGSUSED */
11101109 static int
11111110 ArcToArea(
11121111 Tk_Canvas canvas, /* Canvas containing item. */
14461445 */
14471446
14481447 if (arcPtr->numOutlinePoints == 0) {
1449 arcPtr->outlinePtr = ckalloc(26 * sizeof(double));
1448 arcPtr->outlinePtr = (double *)ckalloc(26 * sizeof(double));
14501449 arcPtr->numOutlinePoints = 22;
14511450 }
14521451 outlinePtr = arcPtr->outlinePtr;
14601459 * curved arc segment, which are marked with X's in the figure below:
14611460 *
14621461 *
1463 * * * *
1462 * * * *
14641463 * * *
14651464 * * * * *
14661465 * * * * *
18131812 Tcl_Interp *interp, /* Leave Postscript or error message here. */
18141813 Tk_Canvas canvas, /* Information about overall canvas. */
18151814 Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
1816 int prepass) /* 1 means this is a prepass to collect font
1815 TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
18171816 * information; 0 means final Postscript is
18181817 * being created. */
18191818 {
20272026
20282027 static int
20292028 StyleParseProc(
2030 ClientData clientData, /* some flags.*/
2029 TCL_UNUSED(void *),
20312030 Tcl_Interp *interp, /* Used for reporting errors. */
2032 Tk_Window tkwin, /* Window containing canvas widget. */
2031 TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
20332032 const char *value, /* Value of option. */
20342033 char *widgRec, /* Pointer to record for item. */
20352034 int offset) /* Offset into item. */
20362035 {
20372036 int c;
20382037 size_t length;
2039
2040 register Style *stylePtr = (Style *) (widgRec + offset);
2038 Style *stylePtr = (Style *) (widgRec + offset);
20412039
20422040 if (value == NULL || *value == 0) {
20432041 *stylePtr = PIESLICE_STYLE;
20912089
20922090 static const char *
20932091 StylePrintProc(
2094 ClientData clientData, /* Ignored. */
2095 Tk_Window tkwin, /* Ignored. */
2092 TCL_UNUSED(void *), /* Ignored. */
2093 TCL_UNUSED(Tk_Window), /* Ignored. */
20962094 char *widgRec, /* Pointer to record for item. */
20972095 int offset, /* Offset into item. */
2098 Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
2096 TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
20992097 * information about how to reclaim storage
21002098 * for return string. */
21012099 {
2102 register Style *stylePtr = (Style *) (widgRec + offset);
2100 Style *stylePtr = (Style *) (widgRec + offset);
21032101
21042102 if (*stylePtr == ARC_STYLE) {
21052103 return "arc";
405405
406406 numPoints = objc/2;
407407 if (linePtr->numPoints != numPoints) {
408 coordPtr = ckalloc(sizeof(double) * objc);
408 coordPtr = (double *)ckalloc(sizeof(double) * objc);
409409 if (linePtr->coordPtr != NULL) {
410410 ckfree(linePtr->coordPtr);
411411 }
601601
602602 static void
603603 DeleteLine(
604 Tk_Canvas canvas, /* Info about overall canvas widget. */
604 TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */
605605 Tk_Item *itemPtr, /* Item that is being deleted. */
606606 Display *display) /* Display containing window for canvas. */
607607 {
705705
706706 tsoffset = &linePtr->outline.tsoffset;
707707 if (tsoffset->flags & TK_OFFSET_INDEX) {
708 double *coordPtr = linePtr->coordPtr
708 coordPtr = linePtr->coordPtr
709709 + (tsoffset->flags & ~TK_OFFSET_INDEX);
710710
711711 if (tsoffset->flags <= 0) {
829829 Tk_Item *itemPtr, /* Item to be displayed. */
830830 Display *display, /* Display on which to draw item. */
831831 Drawable drawable, /* Pixmap or window in which to draw item. */
832 int x, int y, int width, int height)
833 /* Describes region of canvas that must be
834 * redisplayed (not used). */
832 TCL_UNUSED(int), /* Describes region of canvas that must be */
833 TCL_UNUSED(int), /* redisplayed (not used). */
834 TCL_UNUSED(int),
835 TCL_UNUSED(int))
835836 {
836837 LineItem *linePtr = (LineItem *) itemPtr;
837838 XPoint staticPoints[MAX_STATIC_POINTS*3];
874875 if (numPoints <= MAX_STATIC_POINTS) {
875876 pointPtr = staticPoints;
876877 } else {
877 pointPtr = ckalloc(numPoints * 3 * sizeof(XPoint));
878 pointPtr = (XPoint *)ckalloc(numPoints * 3 * sizeof(XPoint));
878879 }
879880
880881 if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
983984 linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
984985 linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
985986 }
986 newCoordPtr = ckalloc(sizeof(double) * (length + objc));
987 newCoordPtr = (double *)ckalloc(sizeof(double) * (length + objc));
987988 for (i=0; i<beforeThis; i++) {
988989 newCoordPtr[i] = linePtr->coordPtr[i];
989990 }
13181319 *--------------------------------------------------------------
13191320 */
13201321
1321 /* ARGSUSED */
13221322 static double
13231323 LineToPoint(
13241324 Tk_Canvas canvas, /* Canvas containing item. */
13641364 if (numPoints <= MAX_STATIC_POINTS) {
13651365 linePoints = staticSpace;
13661366 } else {
1367 linePoints = ckalloc(2 * numPoints * sizeof(double));
1367 linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
13681368 }
13691369 numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
13701370 linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
15461546 *--------------------------------------------------------------
15471547 */
15481548
1549 /* ARGSUSED */
15501549 static int
15511550 LineToArea(
15521551 Tk_Canvas canvas, /* Canvas containing item. */
15991598 if (numPoints <= MAX_STATIC_POINTS) {
16001599 linePoints = staticSpace;
16011600 } else {
1602 linePoints = ckalloc(2 * numPoints * sizeof(double));
1601 linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
16031602 }
16041603 numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
16051604 linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
16941693 linePtr->firstArrowPtr = NULL;
16951694 }
16961695 if (linePtr->lastArrowPtr != NULL) {
1697 int i;
1698
16991696 i = 2*(linePtr->numPoints-1);
17001697 linePtr->coordPtr[i] = linePtr->lastArrowPtr[0];
17011698 linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1];
18721869 *--------------------------------------------------------------
18731870 */
18741871
1875 /* ARGSUSED */
18761872 static int
18771873 ParseArrowShape(
1878 ClientData clientData, /* Not used. */
1874 TCL_UNUSED(void *), /* Not used. */
18791875 Tcl_Interp *interp, /* Used for error reporting. */
1880 Tk_Window tkwin, /* Not used. */
1876 TCL_UNUSED(Tk_Window), /* Not used. */
18811877 const char *value, /* Textual specification of arrow shape. */
18821878 char *recordPtr, /* Pointer to item record in which to store
18831879 * arrow information. */
19411937 *--------------------------------------------------------------
19421938 */
19431939
1944 /* ARGSUSED */
19451940 static const char *
19461941 PrintArrowShape(
1947 ClientData clientData, /* Not used. */
1948 Tk_Window tkwin, /* Window associated with linePtr's widget. */
1942 TCL_UNUSED(void *), /* Not used. */
1943 TCL_UNUSED(Tk_Window), /* Window associated with linePtr's widget. */
19491944 char *recordPtr, /* Pointer to item record containing current
19501945 * shape information. */
1951 int offset, /* Offset of arrow information in record. */
1946 TCL_UNUSED(int), /* Offset of arrow information in record. */
19521947 Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
19531948 * string here. */
19541949 {
19551950 LineItem *linePtr = (LineItem *) recordPtr;
1956 char *buffer = ckalloc(120);
1951 char *buffer = (char *)ckalloc(120);
19571952
19581953 sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
19591954 linePtr->arrowShapeB, linePtr->arrowShapeC);
19811976
19821977 static int
19831978 ArrowParseProc(
1984 ClientData clientData, /* some flags.*/
1979 TCL_UNUSED(void *),
19851980 Tcl_Interp *interp, /* Used for reporting errors. */
1986 Tk_Window tkwin, /* Window containing canvas widget. */
1981 TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
19871982 const char *value, /* Value of option. */
19881983 char *widgRec, /* Pointer to record for item. */
19891984 int offset) /* Offset into item. */
19901985 {
19911986 int c;
19921987 size_t length;
1993
1994 register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
1988 Arrows *arrowPtr = (Arrows *) (widgRec + offset);
19951989
19961990 if (value == NULL || *value == 0) {
19971991 *arrowPtr = ARROWS_NONE;
20492043
20502044 static const char *
20512045 ArrowPrintProc(
2052 ClientData clientData, /* Ignored. */
2053 Tk_Window tkwin, /* Window containing canvas widget. */
2046 TCL_UNUSED(void *), /* Ignored. */
2047 TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
20542048 char *widgRec, /* Pointer to record for item. */
20552049 int offset, /* Offset into item. */
2056 Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
2050 TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
20572051 * information about how to reclaim storage
20582052 * for return string. */
20592053 {
2060 register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
2054 Arrows *arrowPtr = (Arrows *) (widgRec + offset);
20612055
20622056 switch (*arrowPtr) {
20632057 case ARROWS_FIRST:
20912085 *--------------------------------------------------------------
20922086 */
20932087
2094 /* ARGSUSED */
20952088 static int
20962089 ConfigureArrows(
20972090 Tk_Canvas canvas, /* Canvas in which arrows will be displayed
21522145 if (linePtr->arrow != ARROWS_LAST) {
21532146 poly = linePtr->firstArrowPtr;
21542147 if (poly == NULL) {
2155 poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
2148 poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
21562149 poly[0] = poly[10] = linePtr->coordPtr[0];
21572150 poly[1] = poly[11] = linePtr->coordPtr[1];
21582151 linePtr->firstArrowPtr = poly;
21962189 coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
21972190 poly = linePtr->lastArrowPtr;
21982191 if (poly == NULL) {
2199 poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
2192 poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
22002193 poly[0] = poly[10] = coordPtr[2];
22012194 poly[1] = poly[11] = coordPtr[3];
22022195 linePtr->lastArrowPtr = poly;
22532246 Tcl_Interp *interp, /* Leave Postscript or error message here. */
22542247 Tk_Canvas canvas, /* Information about overall canvas. */
22552248 Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
2256 int prepass) /* 1 means this is a prepass to collect font
2249 TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
22572250 * information; 0 means final Postscript is
22582251 * being created. */
22592252 {
23652358 linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
23662359 pointPtr = staticPoints;
23672360 if (numPoints > MAX_STATIC_POINTS) {
2368 pointPtr = ckalloc(numPoints * 2 * sizeof(double));
2361 pointPtr = (double *)ckalloc(numPoints * 2 * sizeof(double));
23692362 }
23702363 numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
23712364 linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr);
375375 * another point to close the polygon.
376376 */
377377
378 polyPtr->coordPtr = ckalloc(sizeof(double) * (objc+2));
378 polyPtr->coordPtr = (double *)ckalloc(sizeof(double) * (objc+2));
379379 polyPtr->pointsAllocated = numPoints+1;
380380 }
381381 for (i = objc-1; i >= 0; i--) {
563563
564564 static void
565565 DeletePolygon(
566 Tk_Canvas canvas, /* Info about overall canvas widget. */
566 TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */
567567 Tk_Item *itemPtr, /* Item that is being deleted. */
568568 Display *display) /* Display containing window for canvas. */
569569 {
824824 if (numPoints <= MAX_STATIC_POINTS) {
825825 pointPtr = staticPoints;
826826 } else {
827 pointPtr = ckalloc(numPoints * sizeof(XPoint));
827 pointPtr = (XPoint *)ckalloc(numPoints * sizeof(XPoint));
828828 }
829829
830830 for (i=0, pPtr=pointPtr ; i<numPoints; i+=1, coordPtr+=2, pPtr++) {
873873 Tk_Item *itemPtr, /* Item to be displayed. */
874874 Display *display, /* Display on which to draw item. */
875875 Drawable drawable, /* Pixmap or window in which to draw item. */
876 int x, int y, int width, int height)
877 /* Describes region of canvas that must be
878 * redisplayed (not used). */
876 TCL_UNUSED(int), /* Describes region of canvas that must be */
877 TCL_UNUSED(int), /* redisplayed (not used). */
878 TCL_UNUSED(int),
879 TCL_UNUSED(int))
879880 {
880881 PolygonItem *polyPtr = (PolygonItem *) itemPtr;
881882 Tk_State state = itemPtr->state;
970971 if (numPoints <= MAX_STATIC_POINTS) {
971972 pointPtr = staticPoints;
972973 } else {
973 pointPtr = ckalloc(numPoints * sizeof(XPoint));
974 pointPtr = (XPoint *)ckalloc(numPoints * sizeof(XPoint));
974975 }
975976 numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
976977 polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL);
997998 *
998999 * PolygonInsert --
9991000 *
1000 * Insert coords into a polugon item at a given index.
1001 * Insert coords into a polygon item at a given index.
10011002 *
10021003 * Results:
10031004 * None.
10371038 while (beforeThis < 0) {
10381039 beforeThis += length;
10391040 }
1040 newCoordPtr = ckalloc(sizeof(double) * (length + 2 + objc));
1041 newCoordPtr = (double *)ckalloc(sizeof(double) * (length + 2 + objc));
10411042 for (i=0; i<beforeThis; i++) {
10421043 newCoordPtr[i] = polyPtr->coordPtr[i];
10431044 }
12391240 *--------------------------------------------------------------
12401241 */
12411242
1242 /* ARGSUSED */
12431243 static double
12441244 PolygonToPoint(
12451245 Tk_Canvas canvas, /* Canvas containing item. */
12871287 if (numPoints <= MAX_STATIC_POINTS) {
12881288 polyPoints = staticSpace;
12891289 } else {
1290 polyPoints = ckalloc(2 * numPoints * sizeof(double));
1290 polyPoints = (double *)ckalloc(2 * numPoints * sizeof(double));
12911291 }
12921292 numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
12931293 polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints);
14291429 *--------------------------------------------------------------
14301430 */
14311431
1432 /* ARGSUSED */
14331432 static int
14341433 PolygonToArea(
14351434 Tk_Canvas canvas, /* Canvas containing item. */
14961495 if (numPoints <= MAX_STATIC_POINTS) {
14971496 polyPoints = staticSpace;
14981497 } else {
1499 polyPoints = ckalloc(2 * numPoints * sizeof(double));
1498 polyPoints = (double *)ckalloc(2 * numPoints * sizeof(double));
15001499 }
15011500 numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
15021501 polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints);
16661665 static int
16671666 GetPolygonIndex(
16681667 Tcl_Interp *interp, /* Used for error reporting. */
1669 Tk_Canvas canvas, /* Canvas containing item. */
1668 TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
16701669 Tk_Item *itemPtr, /* Item for which the index is being
16711670 * specified. */
16721671 Tcl_Obj *obj, /* Specification of a particular coord in
17961795 Tcl_Interp *interp, /* Leave Postscript or error message here. */
17971796 Tk_Canvas canvas, /* Information about overall canvas. */
17981797 Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
1799 int prepass) /* 1 means this is a prepass to collect font
1798 TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
18001799 * information; 0 means final Postscript is
18011800 * being created. */
18021801 {
192192 * such.
193193 */
194194
195 result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", -1, 0);
195 result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", -1, TCL_EVAL_GLOBAL);
196196 if (result != TCL_OK) {
197197 return result;
198198 }
571571 continue;
572572 }
573573
574 Tcl_ResetResult(interp);
575574 result = itemPtr->typePtr->postscriptProc(interp,
576575 (Tk_Canvas) canvasPtr, itemPtr, 0);
577576 if (result != TCL_OK) {
584583 Tcl_AppendToObj(psObj, "gsave\n", -1);
585584 Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
586585 Tcl_AppendToObj(psObj, "grestore\n", -1);
586 Tcl_ResetResult(interp);
587587
588588 if (psInfo.chan != NULL) {
589589 if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
16001600 /*
16011601 * Generate data for image in monochrome mode. No attempt at
16021602 * dithering is made--instead, just set a threshold. To handle
1603 * transparecies we need to output two lines: one for the black
1603 * transparencies we need to output two lines: one for the black
16041604 * pixels, one for the white ones.
16051605 */
16061606
956956 */
957957
958958 if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
959 TkDrawAngledTextLayout(display, drawable, textPtr->gc,
960 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
961 0, selFirstChar);
959 if (0 < selFirstChar) {
960 TkDrawAngledTextLayout(display, drawable, textPtr->gc,
961 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
962 0, selFirstChar);
963 }
962964 TkDrawAngledTextLayout(display, drawable, textPtr->selTextGC,
963965 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
964966 selFirstChar, selLastChar + 1);
965 TkDrawAngledTextLayout(display, drawable, textPtr->gc,
966 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
967 selLastChar + 1, -1);
967 if (selLastChar + 1 < textPtr->numChars) {
968 TkDrawAngledTextLayout(display, drawable, textPtr->gc,
969 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
970 selLastChar + 1, textPtr->numChars);
971 }
968972 } else {
969973 TkDrawAngledTextLayout(display, drawable, textPtr->gc,
970974 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
971 0, -1);
975 0, textPtr->numChars);
972976 }
973977 TkUnderlineAngledTextLayout(display, drawable, textPtr->gc,
974978 textPtr->textLayout, drawableX, drawableY, textPtr->angle,
10201024 if (index > textPtr->numChars) {
10211025 index = textPtr->numChars;
10221026 }
1023 byteIndex = Tcl_UtfAtIndex(text, index) - text;
1027 byteIndex = TkUtfAtIndex(text, index) - text;
10241028 byteCount = strlen(string);
10251029 if (byteCount == 0) {
10261030 return;
10271031 }
10281032
1029 newStr = ckalloc(textPtr->numBytes + byteCount + 1);
1030 memcpy(newStr, text, (size_t) byteIndex);
1033 newStr = (char *)ckalloc(textPtr->numBytes + byteCount + 1);
1034 memcpy(newStr, text, byteIndex);
10311035 strcpy(newStr + byteIndex, string);
10321036 strcpy(newStr + byteIndex + byteCount, text + byteIndex);
10331037
11031107 }
11041108 charsRemoved = last + 1 - first;
11051109
1106 byteIndex = Tcl_UtfAtIndex(text, first) - text;
1107 byteCount = Tcl_UtfAtIndex(text + byteIndex, charsRemoved)
1110 byteIndex = TkUtfAtIndex(text, first) - text;
1111 byteCount = TkUtfAtIndex(text + byteIndex, charsRemoved)
11081112 - (text + byteIndex);
11091113
1110 newStr = ckalloc(textPtr->numBytes + 1 - byteCount);
1111 memcpy(newStr, text, (size_t) byteIndex);
1114 newStr = (char *)ckalloc(textPtr->numBytes + 1 - byteCount);
1115 memcpy(newStr, text, byteIndex);
11121116 strcpy(newStr + byteIndex, text + byteIndex + byteCount);
11131117
11141118 ckfree(text);
12621266 *--------------------------------------------------------------
12631267 */
12641268
1265 /* ARGSUSED */
12661269 static void
12671270 ScaleText(
12681271 Tk_Canvas canvas, /* Canvas containing rectangle. */
13331336 static int
13341337 GetTextIndex(
13351338 Tcl_Interp *interp, /* Used for error reporting. */
1336 Tk_Canvas canvas, /* Canvas containing item. */
1339 TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
13371340 Tk_Item *itemPtr, /* Item for which the index is being
13381341 * specified. */
13391342 Tcl_Obj *obj, /* Specification of a particular character in
13441347 TextItem *textPtr = (TextItem *) itemPtr;
13451348 int length;
13461349 int c;
1347 TkCanvas *canvasPtr = (TkCanvas *) canvas;
13481350 Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
13491351 const char *string = Tcl_GetStringFromObj(obj, &length);
13501352
13511353 c = string[0];
13521354
1353 if ((c == 'e') && (strncmp(string, "end", (unsigned) length) == 0)) {
1355 if ((c == 'e') && (strncmp(string, "end", length) == 0)) {
13541356 *indexPtr = textPtr->numChars;
13551357 } else if ((c == 'i')
1356 && (strncmp(string, "insert", (unsigned) length) == 0)) {
1358 && (strncmp(string, "insert", length) == 0)) {
13571359 *indexPtr = textPtr->insertPos;
13581360 } else if ((c == 's') && (length >= 5)
1359 && (strncmp(string, "sel.first", (unsigned) length) == 0)) {
1361 && (strncmp(string, "sel.first", length) == 0)) {
13601362 if (textInfoPtr->selItemPtr != itemPtr) {
13611363 Tcl_SetObjResult(interp, Tcl_NewStringObj(
13621364 "selection isn't in item", -1));
13651367 }
13661368 *indexPtr = textInfoPtr->selectFirst;
13671369 } else if ((c == 's') && (length >= 5)
1368 && (strncmp(string, "sel.last", (unsigned) length) == 0)) {
1370 && (strncmp(string, "sel.last", length) == 0)) {
13691371 if (textInfoPtr->selItemPtr != itemPtr) {
13701372 Tcl_SetObjResult(interp, Tcl_NewStringObj(
13711373 "selection isn't in item", -1));
13751377 *indexPtr = textInfoPtr->selectLast;
13761378 } else if (c == '@') {
13771379 int x, y;
1378 double tmp, c = textPtr->cosine, s = textPtr->sine;
1380 double tmp, cs = textPtr->cosine, s = textPtr->sine;
13791381 char *end;
13801382 const char *p;
13811383
13911393 goto badIndex;
13921394 }
13931395 y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
1394 x += canvasPtr->scrollX1 - (int) textPtr->drawOrigin[0];
1395 y += canvasPtr->scrollY1 - (int) textPtr->drawOrigin[1];
1396 x -= (int) textPtr->drawOrigin[0];
1397 y -= (int) textPtr->drawOrigin[1];
13961398 *indexPtr = Tk_PointToChar(textPtr->textLayout,
1397 (int) (x*c - y*s), (int) (y*c + x*s));
1399 (int) (x*cs - y*s), (int) (y*cs + x*s));
13981400 } else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) {
13991401 if (*indexPtr < 0) {
14001402 *indexPtr = 0;
14311433 *--------------------------------------------------------------
14321434 */
14331435
1434 /* ARGSUSED */
14351436 static void
14361437 SetTextCursor(
1437 Tk_Canvas canvas, /* Record describing canvas widget. */
1438 TCL_UNUSED(Tk_Canvas), /* Record describing canvas widget. */
14381439 Tk_Item *itemPtr, /* Text item in which cursor position is to be
14391440 * set. */
14401441 int index) /* Character index of character just before
14731474
14741475 static int
14751476 GetSelText(
1476 Tk_Canvas canvas, /* Canvas containing selection. */
1477 TCL_UNUSED(Tk_Canvas), /* Canvas containing selection. */
14771478 Tk_Item *itemPtr, /* Text item containing selection. */
14781479 int offset, /* Byte offset within selection of first
14791480 * character to be returned. */
14931494 return 0;
14941495 }
14951496 text = textPtr->text;
1496 selStart = Tcl_UtfAtIndex(text, textInfoPtr->selectFirst);
1497 selEnd = Tcl_UtfAtIndex(selStart,
1497 selStart = TkUtfAtIndex(text, textInfoPtr->selectFirst);
1498 selEnd = TkUtfAtIndex(selStart,
14981499 textInfoPtr->selectLast + 1 - textInfoPtr->selectFirst);
14991500 byteCount = selEnd - selStart - offset;
15001501 if (byteCount > maxBytes) {
16041605 Tcl_GetString(Tcl_GetObjResult(interp)));
16051606 }
16061607
1607 x = 0; y = 0; justify = NULL; /* lint. */
1608 x = 0; y = 0; justify = NULL;
16081609 switch (textPtr->anchor) {
16091610 case TK_ANCHOR_NW: x = 0; y = 0; break;
16101611 case TK_ANCHOR_N: x = 1; y = 0; break;
2727 "true",
2828 TkMakeBezierCurve,
2929 (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr,
30 int numPoints, int numSteps)) TkMakeBezierPostscript,
30 int numPoints, int numSteps))(void *)TkMakeBezierPostscript,
3131 };
3232 static const Tk_SmoothMethod tkRawSmoothMethod = {
3333 "raw",
3434 TkMakeRawCurve,
3535 (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr,
36 int numPoints, int numSteps)) TkMakeRawCurvePostscript,
36 int numPoints, int numSteps))(void *)TkMakeRawCurvePostscript,
3737 };
38
3839
3940 /*
4041 * Function forward-declarations.
754755 }
755756
756757 /*
757 * Backward compatability hack.
758 * Backward compatibility hack.
758759 */
759760
760761 if (strncmp(value, "bezier", length) == 0) {
8484 static int WinItemCoords(Tcl_Interp *interp,
8585 Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
8686 Tcl_Obj *const objv[]);
87 static void WinItemLostSlaveProc(ClientData clientData,
87 static void WinItemLostContentProc(ClientData clientData,
8888 Tk_Window tkwin);
8989 static void WinItemRequestProc(ClientData clientData,
9090 Tk_Window tkwin);
140140 static const Tk_GeomMgr canvasGeomType = {
141141 "canvas", /* name */
142142 WinItemRequestProc, /* requestProc */
143 WinItemLostSlaveProc, /* lostSlaveProc */
143 WinItemLostContentProc, /* lostSlaveProc */
144144 };
145145
146146 /*
10521052 /*
10531053 *--------------------------------------------------------------
10541054 *
1055 * WinItemLostSlaveProc --
1055 * WinItemLostContentProc --
10561056 *
10571057 * This function is invoked by Tk whenever some other geometry claims
1058 * control over a slave that used to be managed by us.
1059 *
1060 * Results:
1061 * None.
1062 *
1063 * Side effects:
1064 * Forgets all canvas-related information about the slave.
1058 * control over a content window that used to be managed by us.
1059 *
1060 * Results:
1061 * None.
1062 *
1063 * Side effects:
1064 * Forgets all canvas-related information about the content window.
10651065 *
10661066 *--------------------------------------------------------------
10671067 */
10681068
10691069 /* ARGSUSED */
10701070 static void
1071 WinItemLostSlaveProc(
1072 ClientData clientData, /* WindowItem structure for slave window that
1071 WinItemLostContentProc(
1072 ClientData clientData, /* WindowItem structure for content window that
10731073 * was stolen away. */
1074 Tk_Window tkwin) /* Tk's handle for the slave window. */
1074 Tk_Window tkwin) /* Tk's handle for the content window. */
10751075 {
10761076 WindowItem *winItemPtr = clientData;
10771077 Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
516516 canvasPtr->display, pixmap, screenX1, screenY1, width, height);
517517 }
518518
519 static inline int
519 static int
520520 ItemIndex(
521521 TkCanvas *canvasPtr,
522522 Tk_Item *itemPtr,
637637 int argc, /* Number of arguments. */
638638 Tcl_Obj *const argv[]) /* Argument objects. */
639639 {
640 Tk_Window tkwin = clientData;
640 Tk_Window tkwin = (Tk_Window)clientData;
641641 TkCanvas *canvasPtr;
642642 Tk_Window newWin;
643643
661661 * pointers).
662662 */
663663
664 canvasPtr = ckalloc(sizeof(TkCanvas));
664 canvasPtr = (TkCanvas *)ckalloc(sizeof(TkCanvas));
665665 canvasPtr->tkwin = newWin;
666666 canvasPtr->display = Tk_Display(newWin);
667667 canvasPtr->interp = interp;
787787 int objc, /* Number of arguments. */
788788 Tcl_Obj *const objv[]) /* Argument objects. */
789789 {
790 TkCanvas *canvasPtr = clientData;
790 TkCanvas *canvasPtr = (TkCanvas *)clientData;
791791 int c, result;
792792 Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent
793793 * compiler warning. */
834834 Tcl_Preserve(canvasPtr);
835835
836836 result = TCL_OK;
837 switch ((enum options) index) {
837 switch ((enum options)index) {
838838 case CANV_ADDTAG:
839839 if (objc < 4) {
840840 Tcl_WrongNumArgs(interp, 2, objv, "tag searchCommand ?arg ...?");
896896 break;
897897 }
898898 case CANV_BIND: {
899 ClientData object;
899 void *object;
900900
901901 if ((objc < 3) || (objc > 5)) {
902902 Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?sequence? ?command?");
947947 Tcl_HashEntry *entryPtr;
948948
949949 entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable,
950 (char *) INT2PTR(searchPtr->id));
950 INT2PTR(searchPtr->id));
951951 if (entryPtr != NULL) {
952 itemPtr = Tcl_GetHashValue(entryPtr);
952 itemPtr = (Tk_Item *)Tcl_GetHashValue(entryPtr);
953953 object = itemPtr;
954954 }
955955
976976
977977 if (objc == 5) {
978978 int append = 0;
979 unsigned long mask;
979 unsigned int mask;
980980 const char *argv4 = Tcl_GetString(objv[4]);
981981
982982 if (argv4[0] == 0) {
10261026 result = TCL_ERROR;
10271027 goto done;
10281028 }
1029 if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask
1029 if (mask & ~(ButtonMotionMask|Button1MotionMask
10301030 |Button2MotionMask|Button3MotionMask|Button4MotionMask
10311031 |Button5MotionMask|ButtonPressMask|ButtonReleaseMask
10321032 |EnterWindowMask|LeaveWindowMask|KeyPressMask
11841184 tmpObj = Tcl_NewListObj(2, objv+4);
11851185
11861186 FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto doneImove) {
1187 int index;
11881187 int x1, x2, y1, y2;
11891188 int dontRedraw1, dontRedraw2;
11901189
12371236 case CANV_CREATE: {
12381237 Tk_ItemType *typePtr;
12391238 Tk_ItemType *matchPtr = NULL;
1240 Tk_Item *itemPtr;
12411239 int isNew = 0;
12421240 Tcl_HashEntry *entryPtr;
12431241 const char *arg;
12961294 }
12971295
12981296 typePtr = matchPtr;
1299 itemPtr = ckalloc(typePtr->itemSize);
1300 itemPtr->id = canvasPtr->nextId;
1301 canvasPtr->nextId++;
1297 itemPtr = (Tk_Item *)ckalloc(typePtr->itemSize);
1298 itemPtr->id = canvasPtr->nextId++;
13021299 itemPtr->tagPtr = itemPtr->staticTagSpace;
13031300 itemPtr->tagSpace = TK_TAG_SPACE;
13041301 itemPtr->numTags = 0;
13141311
13151312 itemPtr->nextPtr = NULL;
13161313 entryPtr = Tcl_CreateHashEntry(&canvasPtr->idTable,
1317 (char *) INT2PTR(itemPtr->id), &isNew);
1314 INT2PTR(itemPtr->id), &isNew);
13181315 Tcl_SetHashValue(entryPtr, itemPtr);
13191316 itemPtr->prevPtr = canvasPtr->lastItemPtr;
13201317 canvasPtr->hotPtr = itemPtr;
13931390 ckfree(itemPtr->tagPtr);
13941391 }
13951392 entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable,
1396 (char *) INT2PTR(itemPtr->id));
1393 INT2PTR(itemPtr->id));
13971394 Tcl_DeleteHashEntry(entryPtr);
13981395 if (itemPtr->nextPtr != NULL) {
13991396 itemPtr->nextPtr->prevPtr = itemPtr->prevPtr;
14501447 FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
14511448 for (i = itemPtr->numTags-1; i >= 0; i--) {
14521449 if (itemPtr->tagPtr[i] == tag) {
1453 itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
1450
1451 /*
1452 * Don't shuffle the tags sequence: memmove the tags.
1453 */
1454
1455 memmove((void *)(itemPtr->tagPtr + i),
1456 itemPtr->tagPtr + i + 1,
1457 (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid));
14541458 itemPtr->numTags--;
1455 }
1459
1460 /*
1461 * There must be no break here: all tags with the same name must
1462 * be deleted.
1463 */
1464
1465 }
14561466 }
14571467 }
14581468 break;
15171527 }
15181528 break;
15191529 case CANV_ICURSOR: {
1520 int index;
15211530
15221531 if (objc != 4) {
15231532 Tcl_WrongNumArgs(interp, 2, objv, "tagOrId index");
15421551 break;
15431552 }
15441553 case CANV_INDEX: {
1545 int index;
15461554
15471555 if (objc != 4) {
15481556 Tcl_WrongNumArgs(interp, 2, objv, "tagOrId string");
16421650 }
16431651 break;
16441652 case CANV_LOWER: {
1645 Tk_Item *itemPtr;
16461653
16471654 if ((objc != 3) && (objc != 4)) {
16481655 Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?belowThis?");
19271934 break;
19281935 }
19291936 case CANV_SELECT: {
1930 int index, optionindex;
1937 int optionindex;
19311938 static const char *const optionStrings[] = {
19321939 "adjust", "clear", "from", "item", "to", NULL
19331940 };
23992406 CanvasWorldChanged(
24002407 ClientData instanceData) /* Information about widget. */
24012408 {
2402 TkCanvas *canvasPtr = instanceData;
2409 TkCanvas *canvasPtr = (TkCanvas *)instanceData;
24032410 Tk_Item *itemPtr;
24042411
24052412 itemPtr = canvasPtr->firstItemPtr;
24372444 DisplayCanvas(
24382445 ClientData clientData) /* Information about widget. */
24392446 {
2440 TkCanvas *canvasPtr = clientData;
2447 TkCanvas *canvasPtr = (TkCanvas *)clientData;
24412448 Tk_Window tkwin = canvasPtr->tkwin;
24422449 Tk_Item *itemPtr;
24432450 Pixmap pixmap;
26912698 ClientData clientData, /* Information about window. */
26922699 XEvent *eventPtr) /* Information about event. */
26932700 {
2694 TkCanvas *canvasPtr = clientData;
2701 TkCanvas *canvasPtr = (TkCanvas *)clientData;
26952702
26962703 if (eventPtr->type == Expose) {
26972704 int x, y;
27812788 CanvasCmdDeletedProc(
27822789 ClientData clientData) /* Pointer to widget record for widget. */
27832790 {
2784 TkCanvas *canvasPtr = clientData;
2791 TkCanvas *canvasPtr = (TkCanvas *)clientData;
27852792 Tk_Window tkwin = canvasPtr->tkwin;
27862793
27872794 /*
32733280 static SearchUids *
32743281 GetStaticUids(void)
32753282 {
3276 SearchUids *searchUids =
3283 SearchUids *searchUids = (SearchUids *)
32773284 Tcl_GetThreadData(&dataKey, sizeof(SearchUids));
32783285
32793286 if (searchUids->allUid == NULL) {
33123319 TagSearchExpr *expr = *exprPtrPtr;
33133320
33143321 if (expr == NULL) {
3315 expr = ckalloc(sizeof(TagSearchExpr));
3322 expr = (TagSearchExpr *)ckalloc(sizeof(TagSearchExpr));
33163323 expr->allocated = 0;
33173324 expr->uids = NULL;
33183325 expr->next = NULL;
33933400 * Allocate primary search struct on first call.
33943401 */
33953402
3396 *searchPtrPtr = searchPtr = ckalloc(sizeof(TagSearch));
3403 *searchPtrPtr = searchPtr = (TagSearch *)ckalloc(sizeof(TagSearch));
33973404 searchPtr->expr = NULL;
33983405
33993406 /*
34013408 */
34023409
34033410 searchPtr->rewritebufferAllocated = 100;
3404 searchPtr->rewritebuffer = ckalloc(searchPtr->rewritebufferAllocated);
3411 searchPtr->rewritebuffer = (char *)ckalloc(searchPtr->rewritebufferAllocated);
34053412 }
34063413 TagSearchExprInit(&searchPtr->expr);
34073414
34183425 if ((unsigned) searchPtr->stringLength >=
34193426 searchPtr->rewritebufferAllocated) {
34203427 searchPtr->rewritebufferAllocated = searchPtr->stringLength + 100;
3421 searchPtr->rewritebuffer =
3428 searchPtr->rewritebuffer = (char *)
34223429 ckrealloc(searchPtr->rewritebuffer,
34233430 searchPtr->rewritebufferAllocated);
34243431 }
36013608 if (expr->index >= expr->allocated-1) {
36023609 expr->allocated += 15;
36033610 if (expr->uids) {
3604 expr->uids = ckrealloc(expr->uids,
3611 expr->uids = (Tk_Uid *)ckrealloc(expr->uids,
36053612 expr->allocated * sizeof(Tk_Uid));
36063613 } else {
3607 expr->uids = ckalloc(expr->allocated * sizeof(Tk_Uid));
3614 expr->uids = (Tk_Uid *)ckalloc(expr->allocated * sizeof(Tk_Uid));
36083615 }
36093616 }
36103617
40144021 if ((itemPtr == NULL) || (itemPtr->id != searchPtr->id)
40154022 || (lastPtr == NULL) || (lastPtr->nextPtr != itemPtr)) {
40164023 entryPtr = Tcl_FindHashEntry(&searchPtr->canvasPtr->idTable,
4017 (char *) INT2PTR(searchPtr->id));
4024 INT2PTR(searchPtr->id));
40184025 if (entryPtr != NULL) {
4019 itemPtr = Tcl_GetHashValue(entryPtr);
4026 itemPtr = (Tk_Item *)Tcl_GetHashValue(entryPtr);
40204027 lastPtr = itemPtr->prevPtr;
40214028 } else {
40224029 lastPtr = itemPtr = NULL;
42354242 Tk_Uid *newTagPtr;
42364243
42374244 itemPtr->tagSpace += 5;
4238 newTagPtr = ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid));
4245 newTagPtr = (Tk_Uid *)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid));
42394246 memcpy((void *) newTagPtr, itemPtr->tagPtr,
42404247 itemPtr->numTags * sizeof(Tk_Uid));
42414248 if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
47454752 ClientData clientData, /* Pointer to canvas structure. */
47464753 XEvent *eventPtr) /* Pointer to X event that just happened. */
47474754 {
4748 TkCanvas *canvasPtr = clientData;
4749 unsigned long mask;
4755 TkCanvas *canvasPtr = (TkCanvas *)clientData;
4756 unsigned mask;
47504757
47514758 Tcl_Preserve(canvasPtr);
47524759
48424849 * ButtonRelease, or MotionNotify. */
48434850 {
48444851 double coords[2];
4845 unsigned long buttonDown;
4852 unsigned int buttonDown;
48464853 Tk_Item *prevItemPtr;
48474854 #ifndef USE_OLD_TAG_SEARCH
48484855 SearchUids *searchUids = GetStaticUids();
49744981 if (itemPtr->tagPtr[i] == searchUids->currentUid)
49754982 #endif /* USE_OLD_TAG_SEARCH */
49764983 /* then */ {
4977 itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
4984 memmove((void *)(itemPtr->tagPtr + i),
4985 itemPtr->tagPtr + i + 1,
4986 (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid));
49784987 itemPtr->numTags--;
49794988 break;
49804989 }
51075116 * processed. */
51085117 {
51095118 #define NUM_STATIC 3
5110 ClientData staticObjects[NUM_STATIC];
5111 ClientData *objectPtr;
5119 void *staticObjects[NUM_STATIC];
5120 void **objectPtr;
51125121 int numObjects, i;
51135122 Tk_Item *itemPtr;
51145123 #ifndef USE_OLD_TAG_SEARCH
52345243 CanvasBlinkProc(
52355244 ClientData clientData) /* Pointer to record describing entry. */
52365245 {
5237 TkCanvas *canvasPtr = clientData;
5246 TkCanvas *canvasPtr = (TkCanvas *)clientData;
52385247
52395248 if (!canvasPtr->textInfo.gotFocus || (canvasPtr->insertOffTime == 0)) {
52405249 return;
53905399 * not including terminating NULL
53915400 * character. */
53925401 {
5393 TkCanvas *canvasPtr = clientData;
5402 TkCanvas *canvasPtr = (TkCanvas *)clientData;
53945403
53955404 return ItemSelection(canvasPtr, canvasPtr->textInfo.selItemPtr, offset,
53965405 buffer, maxBytes);
54185427 CanvasLostSelection(
54195428 ClientData clientData) /* Information about entry widget. */
54205429 {
5421 TkCanvas *canvasPtr = clientData;
5430 TkCanvas *canvasPtr = (TkCanvas *)clientData;
54225431
54235432 EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.selItemPtr);
54245433 canvasPtr->textInfo.selItemPtr = NULL;
55405549 Tcl_DString buf;
55415550
55425551 /*
5543 * Save all the relevant values from the canvasPtr, because it might be
5544 * deleted as part of either of the two calls to Tcl_VarEval below.
5552 * Preserve the relevant values from the canvasPtr, because it might be
5553 * deleted as part of either of the two calls to Tcl_EvalEx below.
55455554 */
55465555
55475556 interp = canvasPtr->interp;
55725581 Tcl_DStringAppend(&buf, xScrollCmd, -1);
55735582 Tcl_DStringAppend(&buf, " ", -1);
55745583 Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
5575 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
5584 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
55765585 Tcl_DStringFree(&buf);
55775586 Tcl_DecrRefCount(fractions);
55785587 if (result != TCL_OK) {
55905599 Tcl_DStringAppend(&buf, yScrollCmd, -1);
55915600 Tcl_DStringAppend(&buf, " ", -1);
55925601 Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
5593 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
5602 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
55945603 Tcl_DStringFree(&buf);
55955604 Tcl_DecrRefCount(fractions);
55965605 if (result != TCL_OK) {
57475756 *----------------------------------------------------------------------
57485757 */
57495758
5750 /* ARGSUSED */
57515759 static const char **
57525760 TkGetStringsFromObjs(
57535761 int objc,
57545762 Tcl_Obj *const objv[])
57555763 {
5756 register int i;
5764 int i;
57575765 const char **argv;
57585766
57595767 if (objc <= 0) {
57605768 return NULL;
57615769 }
5762 argv = ckalloc((objc+1) * sizeof(char *));
5770 argv = (const char **)ckalloc((objc+1) * sizeof(char *));
57635771 for (i = 0; i < objc; i++) {
57645772 argv[i] = Tcl_GetString(objv[i]);
57655773 }
5555 char *buffer, /* Place to store converted selection. */
5656 int maxBytes) /* Maximum # of bytes to store at buffer. */
5757 {
58 TkClipboardTarget *targetPtr = clientData;
58 TkClipboardTarget *targetPtr = (TkClipboardTarget *)clientData;
5959 TkClipboardBuffer *cbPtr;
6060 char *srcPtr, *destPtr;
6161 size_t count = 0;
146146 if (length > (size_t) maxBytes) {
147147 length = maxBytes;
148148 }
149 strncpy(buffer, p, length);
149 memcpy(buffer, p, length);
150 buffer[length] = 0;
150151 return (int)length;
151152 }
152153
171172
172173 static int
173174 ClipboardWindowHandler(
174 ClientData clientData, /* Not used. */
175 int offset, /* Return selection bytes starting at this
175 TCL_UNUSED(void *), /* Not used. */
176 TCL_UNUSED(int), /* Return selection bytes starting at this
176177 * offset. */
177178 char *buffer, /* Place to store converted selection. */
178 int maxBytes) /* Maximum # of bytes to store at buffer. */
179 TCL_UNUSED(int)) /* Maximum # of bytes to store at buffer. */
179180 {
180181 buffer[0] = '.';
181182 buffer[1] = 0;
204205 ClipboardLostSel(
205206 ClientData clientData) /* Pointer to TkDisplay structure. */
206207 {
207 TkDisplay *dispPtr = clientData;
208 TkDisplay *dispPtr = (TkDisplay *)clientData;
208209
209210 dispPtr->clipboardActive = 0;
210211 }
357358 }
358359 }
359360 if (targetPtr == NULL) {
360 targetPtr = ckalloc(sizeof(TkClipboardTarget));
361 targetPtr = (TkClipboardTarget *)ckalloc(sizeof(TkClipboardTarget));
361362 targetPtr->type = type;
362363 targetPtr->format = format;
363364 targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL;
379380 * Append a new buffer to the buffer chain.
380381 */
381382
382 cbPtr = ckalloc(sizeof(TkClipboardBuffer));
383 cbPtr = (TkClipboardBuffer *)ckalloc(sizeof(TkClipboardBuffer));
383384 cbPtr->nextPtr = NULL;
384385 if (targetPtr->lastBufferPtr != NULL) {
385386 targetPtr->lastBufferPtr->nextPtr = cbPtr;
389390 targetPtr->lastBufferPtr = cbPtr;
390391
391392 cbPtr->length = strlen(buffer);
392 cbPtr->buffer = ckalloc(cbPtr->length + 1);
393 cbPtr->buffer = (char *)ckalloc(cbPtr->length + 1);
393394 strcpy(cbPtr->buffer, buffer);
394395
395396 TkSelUpdateClipboard((TkWindow *) dispPtr->clipWindow, targetPtr);
421422 int objc, /* Number of arguments. */
422423 Tcl_Obj *const objv[]) /* Argument strings. */
423424 {
424 Tk_Window tkwin = (Tk_Window) clientData;
425 Tk_Window tkwin = (Tk_Window)clientData;
425426 const char *path = NULL;
426427 Atom selection;
427428 static const char *const optionStrings[] = { "append", "clear", "get", NULL };
634635
635636 int
636637 TkClipInit(
637 Tcl_Interp *interp, /* Interpreter to use for error reporting. */
638 register TkDisplay *dispPtr)/* Display to initialize. */
638 TCL_UNUSED(Tcl_Interp *), /* Interpreter to use for error reporting. */
639 TkDisplay *dispPtr)/* Display to initialize. */
639640 {
640641 XSetWindowAttributes atts;
641642
698699 *--------------------------------------------------------------
699700 */
700701
701 /* ARGSUSED */
702702 static int
703703 ClipboardGetProc(
704704 ClientData clientData, /* Dynamic string holding partially assembled
705705 * selection. */
706 Tcl_Interp *interp, /* Interpreter used for error reporting (not
706 TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not
707707 * used). */
708708 const char *portion) /* New information to be appended. */
709709 {
9898 "-displayof", "-nice", NULL
9999 };
100100 enum options { TK_BELL_DISPLAYOF, TK_BELL_NICE };
101 Tk_Window tkwin = clientData;
101 Tk_Window tkwin = (Tk_Window)clientData;
102102 int i, index, nice = 0;
103103 Tk_ErrorHandler handler;
104104
162162 int objc, /* Number of arguments. */
163163 Tcl_Obj *const objv[]) /* Argument objects. */
164164 {
165 Tk_Window tkwin = clientData;
165 Tk_Window tkwin = (Tk_Window)clientData;
166166 TkWindow *winPtr;
167167 ClientData object;
168168 const char *string;
186186 }
187187 object = (ClientData) winPtr->pathName;
188188 } else {
189 winPtr = clientData;
189 winPtr = (TkWindow *)clientData;
190190 object = (ClientData) Tk_GetUid(string);
191191 }
192192
284284 */
285285
286286 if (winPtr->numTags > MAX_OBJS) {
287 objPtr = ckalloc(winPtr->numTags * sizeof(ClientData));
287 objPtr = (void **)ckalloc(winPtr->numTags * sizeof(void *));
288288 }
289289 for (i = 0; i < winPtr->numTags; i++) {
290 p = winPtr->tagPtr[i];
290 p = (const char *)winPtr->tagPtr[i];
291291 if (*p == '.') {
292292 hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p);
293293 if (hPtr != NULL) {
346346 int objc, /* Number of arguments. */
347347 Tcl_Obj *const objv[]) /* Argument objects. */
348348 {
349 Tk_Window tkwin = clientData;
349 Tk_Window tkwin = (Tk_Window)clientData;
350350 TkWindow *winPtr, *winPtr2;
351351 int i, length;
352352 const char *p;
398398 }
399399
400400 winPtr->numTags = length;
401 winPtr->tagPtr = ckalloc(length * sizeof(ClientData));
401 winPtr->tagPtr = (void **)ckalloc(length * sizeof(void *));
402402 for (i = 0; i < length; i++) {
403403 p = Tcl_GetString(tags[i]);
404404 if (p[0] == '.') {
411411 * is one.
412412 */
413413
414 copy = ckalloc(strlen(p) + 1);
414 copy = (char *)ckalloc(strlen(p) + 1);
415415 strcpy(copy, p);
416416 winPtr->tagPtr[i] = (ClientData) copy;
417417 } else {
447447 const char *p;
448448
449449 for (i = 0; i < winPtr->numTags; i++) {
450 p = winPtr->tagPtr[i];
450 p = (const char *)winPtr->tagPtr[i];
451451 if (*p == '.') {
452452 /*
453453 * Names starting with "." are malloced rather than Uids, so they
487487 Tcl_Obj *const objv[]) /* Argument objects. */
488488 {
489489 Tk_Window window;
490 Tk_Window tkwin = clientData;
490 Tk_Window tkwin = (Tk_Window)clientData;
491491 int i;
492492
493493 for (i = 1; i < objc; i++) {
526526 *----------------------------------------------------------------------
527527 */
528528
529 /* ARGSUSED */
530529 int
531530 Tk_LowerObjCmd(
532531 ClientData clientData, /* Main window associated with interpreter. */
534533 int objc, /* Number of arguments. */
535534 Tcl_Obj *const objv[]) /* Argument objects. */
536535 {
537 Tk_Window mainwin = clientData;
536 Tk_Window mainwin = (Tk_Window)clientData;
538537 Tk_Window tkwin, other;
539538
540539 if ((objc != 2) && (objc != 3)) {
586585 *----------------------------------------------------------------------
587586 */
588587
589 /* ARGSUSED */
590588 int
591589 Tk_RaiseObjCmd(
592590 ClientData clientData, /* Main window associated with interpreter. */
594592 int objc, /* Number of arguments. */
595593 Tcl_Obj *const objv[]) /* Argument objects. */
596594 {
597 Tk_Window mainwin = clientData;
595 Tk_Window mainwin = (Tk_Window)clientData;
598596 Tk_Window tkwin, other;
599597
600598 if ((objc != 2) && (objc != 3)) {
682680 int objc, /* Number of arguments. */
683681 Tcl_Obj *const objv[]) /* Argument objects. */
684682 {
685 Tk_Window tkwin = clientData;
683 Tk_Window tkwin = (Tk_Window)clientData;
686684 TkWindow *winPtr;
687685 const char *string;
688686
714712 int objc, /* Number of arguments. */
715713 Tcl_Obj *const objv[]) /* Argument objects. */
716714 {
717 Tk_Window tkwin = clientData;
715 Tk_Window tkwin = (Tk_Window)clientData;
718716 int index;
719717 Tcl_Obj *objPtr;
720718 TkCaret *caretPtr;
806804 int objc, /* Number of arguments. */
807805 Tcl_Obj *const objv[]) /* Argument objects. */
808806 {
809 Tk_Window tkwin = clientData;
807 Tk_Window tkwin = (Tk_Window)clientData;
810808 Screen *screenPtr;
811809 int skip, width, height;
812810 double d;
857855 int objc, /* Number of arguments. */
858856 Tcl_Obj *const objv[]) /* Argument objects. */
859857 {
860 Tk_Window tkwin = clientData;
858 Tk_Window tkwin = (Tk_Window)clientData;
861859 TkDisplay *dispPtr;
862860 int skip;
863861
905903
906904 int
907905 WindowingsystemCmd(
908 ClientData clientData, /* Main window associated with interpreter. */
906 TCL_UNUSED(void *), /* Main window associated with interpreter. */
909907 Tcl_Interp *interp, /* Current interpreter. */
910908 int objc, /* Number of arguments. */
911909 Tcl_Obj *const objv[]) /* Argument objects. */
934932 int objc, /* Number of arguments. */
935933 Tcl_Obj *const objv[]) /* Argument objects. */
936934 {
937 Tk_Window tkwin = clientData;
935 Tk_Window tkwin = (Tk_Window)clientData;
938936 int skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
939937
940938 if (skip < 0) {
990988 *----------------------------------------------------------------------
991989 */
992990
993 /* ARGSUSED */
994991 int
995992 Tk_TkwaitObjCmd(
996993 ClientData clientData, /* Main window associated with interpreter. */
998995 int objc, /* Number of arguments. */
999996 Tcl_Obj *const objv[]) /* Argument objects. */
1000997 {
1001 Tk_Window tkwin = clientData;
998 Tk_Window tkwin = (Tk_Window)clientData;
1002999 int done, index;
10031000 int code = TCL_OK;
10041001 static const char *const optionStrings[] = {
11191116 return code;
11201117 }
11211118
1122 /* ARGSUSED */
11231119 static char *
11241120 WaitVariableProc(
11251121 ClientData clientData, /* Pointer to integer to set to 1. */
1126 Tcl_Interp *interp, /* Interpreter containing variable. */
1127 const char *name1, /* Name of variable. */
1128 const char *name2, /* Second part of variable name. */
1129 int flags) /* Information about what happened. */
1130 {
1131 int *donePtr = clientData;
1122 TCL_UNUSED(Tcl_Interp *), /* Interpreter containing variable. */
1123 TCL_UNUSED(const char *), /* Name of variable. */
1124 TCL_UNUSED(const char *), /* Second part of variable name. */
1125 TCL_UNUSED(int)) /* Information about what happened. */
1126 {
1127 int *donePtr = (int *)clientData;
11321128
11331129 *donePtr = 1;
11341130 return NULL;
11351131 }
11361132
1137 /*ARGSUSED*/
11381133 static void
11391134 WaitVisibilityProc(
11401135 ClientData clientData, /* Pointer to integer to set to 1. */
11411136 XEvent *eventPtr) /* Information about event (not used). */
11421137 {
1143 int *donePtr = clientData;
1138 int *donePtr = (int *)clientData;
11441139
11451140 if (eventPtr->type == VisibilityNotify) {
11461141 *donePtr = 1;
11541149 ClientData clientData, /* Pointer to integer to set to 1. */
11551150 XEvent *eventPtr) /* Information about event. */
11561151 {
1157 int *donePtr = clientData;
1152 int *donePtr = (int *)clientData;
11581153
11591154 if (eventPtr->type == DestroyNotify) {
11601155 *donePtr = 1;
11781173 *----------------------------------------------------------------------
11791174 */
11801175
1181 /* ARGSUSED */
11821176 int
11831177 Tk_UpdateObjCmd(
1184 ClientData clientData, /* Main window associated with interpreter. */
1178 TCL_UNUSED(void *), /* Main window associated with interpreter. */
11851179 Tcl_Interp *interp, /* Current interpreter. */
11861180 int objc, /* Number of arguments. */
11871181 Tcl_Obj *const objv[]) /* Argument objects. */
12871281 int index, x, y, width, height, useX, useY, c_class, skip;
12881282 const char *string;
12891283 TkWindow *winPtr;
1290 Tk_Window tkwin = clientData;
1284 Tk_Window tkwin = (Tk_Window)clientData;
12911285
12921286 static const TkStateMap visualMap[] = {
12931287 {PseudoColor, "pseudocolor"},
15781572 objv += skip;
15791573 string = Tcl_GetString(objv[2]);
15801574 Tcl_SetObjResult(interp,
1581 Tcl_NewLongObj((long) Tk_InternAtom(tkwin, string)));
1575 Tcl_NewWideIntObj(Tk_InternAtom(tkwin, string)));
15821576 break;
15831577 case WIN_ATOMNAME: {
15841578 const char *name;
1585 long id;
1579 Tcl_WideInt id;
15861580
15871581 skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
15881582 if (skip < 0) {
15931587 return TCL_ERROR;
15941588 }
15951589 objv += skip;
1596 if (Tcl_GetLongFromObj(interp, objv[2], &id) != TCL_OK) {
1590 if (Tcl_GetWideIntFromObj(interp, objv[2], &id) != TCL_OK) {
15971591 return TCL_ERROR;
15981592 }
15991593 name = Tk_GetAtomName(tkwin, (Atom) id);
17471741 if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) {
17481742 return TCL_ERROR;
17491743 }
1744 #ifdef TK_HAS_DYNAMIC_COLORS
1745
1746 /*
1747 * Make sure that the TkColor used for the winfo rgb command is
1748 * destroyed when we are through with it, so we do not get stale RGB
1749 * values next time.
1750 */
1751
1752 {
1753 Colormap temp = Tk_Colormap(tkwin);
1754 Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP;
1755 colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3]));
1756 Tk_Colormap(tkwin) = temp;
1757 }
1758 #else
17501759 colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3]));
1760 #endif
17511761 if (colorPtr == NULL) {
17521762 return TCL_ERROR;
17531763 }
17571767 break;
17581768 }
17591769 case WIN_VISUALSAVAILABLE: {
1760 XVisualInfo template, *visInfoPtr;
1770 XVisualInfo templ, *visInfoPtr;
17611771 int count, i;
17621772 int includeVisualId;
17631773 Tcl_Obj *strPtr, *resultPtr;
17781788 return TCL_ERROR;
17791789 }
17801790
1781 template.screen = Tk_ScreenNumber(tkwin);
1791 templ.screen = Tk_ScreenNumber(tkwin);
17821792 visInfoPtr = XGetVisualInfo(Tk_Display(tkwin), VisualScreenMask,
1783 &template, &count);
1793 &templ, &count);
17841794 if (visInfoPtr == NULL) {
17851795 Tcl_SetObjResult(interp, Tcl_NewStringObj(
17861796 "can't find any visuals for screen", -1));
20772087 }
20782088 string = Tcl_GetStringFromObj(objv[0], &length);
20792089 if ((length >= 2) &&
2080 (strncmp(string, "-displayof", (unsigned) length) == 0)) {
2090 (strncmp(string, "-displayof", length) == 0)) {
20812091 if (objc < 2) {
20822092 Tcl_SetObjResult(interp, Tcl_NewStringObj(
20832093 "value for \"-displayof\" missing", -1));
21112121 *----------------------------------------------------------------------
21122122 */
21132123
2114 /* ARGSUSED */
21152124 int
21162125 TkDeadAppObjCmd(
2117 ClientData clientData, /* Dummy. */
2126 TCL_UNUSED(void *),
21182127 Tcl_Interp *interp, /* Current interpreter. */
2119 int objc, /* Number of arguments. */
2128 TCL_UNUSED(int), /* Number of arguments. */
21202129 Tcl_Obj *const objv[]) /* Argument strings. */
21212130 {
21222131 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
6666 * monochrome displays. */
6767 struct TkOption *synonymPtr;
6868 /* For synonym options, this points to the
69 * master entry. */
69 * original entry. */
7070 const struct Tk_ObjCustomOption *custom;
7171 /* For TK_OPTION_CUSTOM. */
7272 } extra;
177177 const Tk_OptionSpec *specPtr, *specPtr2;
178178 Option *optionPtr;
179179 int numOptions, i;
180 ThreadSpecificData *tsdPtr =
180 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
181181 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
182182
183183 /*
201201 hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *) templatePtr,
202202 &newEntry);
203203 if (!newEntry) {
204 tablePtr = Tcl_GetHashValue(hashEntryPtr);
204 tablePtr = (OptionTable *)Tcl_GetHashValue(hashEntryPtr);
205205 tablePtr->refCount++;
206206 return (Tk_OptionTable) tablePtr;
207207 }
215215 for (specPtr = templatePtr; specPtr->type != TK_OPTION_END; specPtr++) {
216216 numOptions++;
217217 }
218 tablePtr = ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option)));
218 tablePtr = (OptionTable *)ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option)));
219219 tablePtr->refCount = 1;
220220 tablePtr->hashEntryPtr = hashEntryPtr;
221221 tablePtr->nextPtr = NULL;
236236
237237 if (specPtr->type == TK_OPTION_SYNONYM) {
238238 /*
239 * This is a synonym option; find the master option that it refers
240 * to and create a pointer from the synonym to the master.
239 * This is a synonym option; find the original option that it refers
240 * to and create a pointer from the synonym to the origin.
241241 */
242242
243243 for (specPtr2 = templatePtr, i = 0; ; specPtr2++, i++) {
265265 || (specPtr->type == TK_OPTION_BORDER))
266266 && (specPtr->clientData != NULL)) {
267267 optionPtr->extra.monoColorPtr =
268 Tcl_NewStringObj(specPtr->clientData, -1);
268 Tcl_NewStringObj((const char *)specPtr->clientData, -1);
269269 Tcl_IncrRefCount(optionPtr->extra.monoColorPtr);
270270 }
271271
274274 * Get the custom parsing, etc., functions.
275275 */
276276
277 optionPtr->extra.custom = specPtr->clientData;
277 optionPtr->extra.custom = (const Tk_ObjCustomOption *)specPtr->clientData;
278278 }
279279 }
280280 if (((specPtr->type == TK_OPTION_STRING)
299299
300300 if (specPtr->clientData != NULL) {
301301 tablePtr->nextPtr = (OptionTable *)
302 Tk_CreateOptionTable(interp, specPtr->clientData);
302 Tk_CreateOptionTable(interp, (Tk_OptionSpec *)specPtr->clientData);
303303 }
304304
305305 return (Tk_OptionTable) tablePtr;
331331 Option *optionPtr;
332332 int count;
333333
334 tablePtr->refCount--;
335 if (tablePtr->refCount > 0) {
334 if (tablePtr->refCount-- > 1) {
336335 return;
337336 }
338337
677676 case TK_OPTION_STRING_TABLE: {
678677 int newValue;
679678
680 if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
681 optionPtr->specPtr->clientData, sizeof(char *),
682 optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
683 return TCL_ERROR;
684 }
679 if (nullOK && ObjectIsEmpty(valuePtr)) {
680 valuePtr = NULL;
681 newValue = -1;
682 } else {
683 if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
684 optionPtr->specPtr->clientData, sizeof(char *),
685 optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
686 return TCL_ERROR;
687 }
688 }
685689 if (internalPtr != NULL) {
686690 *((int *) oldInternalPtr) = *((int *) internalPtr);
687691 *((int *) internalPtr) = newValue;
11601164
11611165 static void
11621166 FreeOptionInternalRep(
1163 register Tcl_Obj *objPtr) /* Object whose internal rep to free. */
1167 Tcl_Obj *objPtr) /* Object whose internal rep to free. */
11641168 {
1165 register Tk_OptionTable tablePtr = (Tk_OptionTable) objPtr->internalRep.twoPtrValue.ptr1;
1169 Tk_OptionTable tablePtr = (Tk_OptionTable) objPtr->internalRep.twoPtrValue.ptr1;
11661170
11671171 Tk_DeleteOptionTable(tablePtr);
11681172 objPtr->typePtr = NULL;
11861190 Tcl_Obj *srcObjPtr, /* The object we are copying from. */
11871191 Tcl_Obj *dupObjPtr) /* The object we are copying to. */
11881192 {
1189 register OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1;
1193 OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1;
11901194 tablePtr->refCount++;
11911195 dupObjPtr->typePtr = srcObjPtr->typePtr;
11921196 dupObjPtr->internalRep = srcObjPtr->internalRep;
12831287 * more space.
12841288 */
12851289
1286 newSavePtr = ckalloc(sizeof(Tk_SavedOptions));
1290 newSavePtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions));
12871291 newSavePtr->recordPtr = recordPtr;
12881292 newSavePtr->tkwin = tkwin;
12891293 newSavePtr->numItems = 0;
14941498 Tk_FreeSavedOptions(savePtr->nextPtr);
14951499 ckfree(savePtr->nextPtr);
14961500 }
1497 for (count = savePtr->numItems,
1498 savedOptionPtr = &savePtr->items[savePtr->numItems-1];
1499 count > 0; count--, savedOptionPtr--) {
1501 for (count = savePtr->numItems; count > 0; count--) {
1502 savedOptionPtr = &savePtr->items[count-1];
15001503 if (savedOptionPtr->optionPtr->flags & OPTION_NEEDS_FREEING) {
15011504 FreeResources(savedOptionPtr->optionPtr, savedOptionPtr->valuePtr,
15021505 (char *) &savedOptionPtr->internalForm, savePtr->tkwin);
15241527 *----------------------------------------------------------------------
15251528 */
15261529
1527 /* ARGSUSED */
15281530 void
15291531 Tk_FreeConfigOptions(
15301532 char *recordPtr, /* Record whose fields contain current values
18761878 objPtr = NULL;
18771879 switch (optionPtr->specPtr->type) {
18781880 case TK_OPTION_BOOLEAN:
1879 objPtr = Tcl_NewIntObj(*((int *) internalPtr));
1881 objPtr = Tcl_NewIntObj(*((int *)internalPtr));
18801882 break;
18811883 case TK_OPTION_INT:
1882 objPtr = Tcl_NewIntObj(*((int *) internalPtr));
1884 objPtr = Tcl_NewIntObj(*((int *)internalPtr));
18831885 break;
18841886 case TK_OPTION_DOUBLE:
1885 objPtr = Tcl_NewDoubleObj(*((double *) internalPtr));
1887 objPtr = Tcl_NewDoubleObj(*((double *)internalPtr));
18861888 break;
18871889 case TK_OPTION_STRING:
1888 objPtr = Tcl_NewStringObj(*((char **) internalPtr), -1);
1890 objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1);
18891891 break;
18901892 case TK_OPTION_STRING_TABLE:
18911893 objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
18921894 *((int *) internalPtr)], -1);
18931895 break;
18941896 case TK_OPTION_COLOR: {
1895 XColor *colorPtr = *((XColor **) internalPtr);
1897 XColor *colorPtr = *((XColor **)internalPtr);
18961898
18971899 if (colorPtr != NULL) {
18981900 objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
19001902 break;
19011903 }
19021904 case TK_OPTION_FONT: {
1903 Tk_Font tkfont = *((Tk_Font *) internalPtr);
1905 Tk_Font tkfont = *((Tk_Font *)internalPtr);
19041906
19051907 if (tkfont != NULL) {
19061908 objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1);
19081910 break;
19091911 }
19101912 case TK_OPTION_STYLE: {
1911 Tk_Style style = *((Tk_Style *) internalPtr);
1913 Tk_Style style = *((Tk_Style *)internalPtr);
19121914
19131915 if (style != NULL) {
19141916 objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1);
19161918 break;
19171919 }
19181920 case TK_OPTION_BITMAP: {
1919 Pixmap pixmap = *((Pixmap *) internalPtr);
1921 Pixmap pixmap = *((Pixmap *)internalPtr);
19201922
19211923 if (pixmap != None) {
19221924 objPtr = Tcl_NewStringObj(
19251927 break;
19261928 }
19271929 case TK_OPTION_BORDER: {
1928 Tk_3DBorder border = *((Tk_3DBorder *) internalPtr);
1930 Tk_3DBorder border = *((Tk_3DBorder *)internalPtr);
19291931
19301932 if (border != NULL) {
19311933 objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1);
19331935 break;
19341936 }
19351937 case TK_OPTION_RELIEF:
1936 objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *) internalPtr)), -1);
1938 objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *)internalPtr)), -1);
19371939 break;
19381940 case TK_OPTION_CURSOR: {
1939 Tk_Cursor cursor = *((Tk_Cursor *) internalPtr);
1941 Tk_Cursor cursor = *((Tk_Cursor *)internalPtr);
19401942
19411943 if (cursor != NULL) {
19421944 objPtr = Tcl_NewStringObj(
19461948 }
19471949 case TK_OPTION_JUSTIFY:
19481950 objPtr = Tcl_NewStringObj(Tk_NameOfJustify(
1949 *((Tk_Justify *) internalPtr)), -1);
1951 *((Tk_Justify *)internalPtr)), -1);
19501952 break;
19511953 case TK_OPTION_ANCHOR:
19521954 objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(
19531955 *((Tk_Anchor *) internalPtr)), -1);
19541956 break;
19551957 case TK_OPTION_PIXELS:
1956 objPtr = Tcl_NewIntObj(*((int *) internalPtr));
1958 objPtr = Tcl_NewIntObj(*((int *)internalPtr));
19571959 break;
19581960 case TK_OPTION_WINDOW: {
1959 Tk_Window tkwin = *((Tk_Window *) internalPtr);
1961 tkwin = *((Tk_Window *)internalPtr);
19601962
19611963 if (tkwin != NULL) {
19621964 objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
20632065
20642066 Tcl_Obj *
20652067 TkDebugConfig(
2066 Tcl_Interp *interp, /* Interpreter in which the table is
2068 TCL_UNUSED(Tcl_Interp *), /* Interpreter in which the table is
20672069 * defined. */
20682070 Tk_OptionTable table) /* Table about which information is to be
20692071 * returned. May not necessarily exist in the
20732075 Tcl_HashEntry *hashEntryPtr;
20742076 Tcl_HashSearch search;
20752077 Tcl_Obj *objPtr;
2076 ThreadSpecificData *tsdPtr =
2078 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
20772079 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
20782080
20792081 objPtr = Tcl_NewObj();
4343 */
4444
4545 static int ConsoleClose(ClientData instanceData, Tcl_Interp *interp);
46 static int Console2Close(ClientData instanceData, Tcl_Interp *interp, int flags);
4647 static void ConsoleDeleteProc(ClientData clientData);
4748 static void ConsoleEventProc(ClientData clientData, XEvent *eventPtr);
4849 static int ConsoleHandle(ClientData instanceData, int direction,
6566
6667 static const Tcl_ChannelType consoleChannelType = {
6768 "console", /* Type name. */
68 TCL_CHANNEL_VERSION_4, /* v4 channel */
69 TCL_CHANNEL_VERSION_5, /* v5 channel */
6970 ConsoleClose, /* Close proc. */
7071 ConsoleInput, /* Input proc. */
7172 ConsoleOutput, /* Output proc. */
7475 NULL, /* Get option proc. */
7576 ConsoleWatch, /* Watch for events on console. */
7677 ConsoleHandle, /* Get a handle from the device. */
77 NULL, /* close2proc. */
78 Console2Close, /* close2proc. */
7879 NULL, /* Always non-blocking.*/
7980 NULL, /* flush proc. */
8081 NULL, /* handler proc. */
226227 return;
227228 }
228229
229 consoleInitPtr = Tcl_GetThreadData(&consoleInitKey, (int) sizeof(int));
230 consoleInitPtr = (int *)Tcl_GetThreadData(&consoleInitKey, (int) sizeof(int));
230231 if (*consoleInitPtr) {
231232 /*
232233 * We've already initialized console channels in this thread.
254255 * interp for it to live in.
255256 */
256257
257 info = ckalloc(sizeof(ConsoleInfo));
258 info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo));
258259 info->consoleInterp = NULL;
259260 info->interp = NULL;
260261 info->refCount = 0;
261262
262263 if (doIn) {
263 ChannelData *data = ckalloc(sizeof(ChannelData));
264 ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
264265
265266 data->info = info;
266267 data->info->refCount++;
277278 }
278279
279280 if (doOut) {
280 ChannelData *data = ckalloc(sizeof(ChannelData));
281 ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
281282
282283 data->info = info;
283284 data->info->refCount++;
294295 }
295296
296297 if (doErr) {
297 ChannelData *data = ckalloc(sizeof(ChannelData));
298 ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
298299
299300 data->info = info;
300301 data->info->refCount++;
376377 * New ConsoleInfo for a new console window.
377378 */
378379
379 info = ckalloc(sizeof(ConsoleInfo));
380 info = (ConsoleInfo *)ckalloc(sizeof(ConsoleInfo));
380381 info->refCount = 0;
381382
382383 /*
406407 }
407408 }
408409 } else {
409 info = ckalloc(sizeof(ConsoleInfo));
410 info = (ConsoleInfo *)ckalloc(sizeof(ConsoleInfo));
410411 info->refCount = 0;
411412 }
412413
455456 if (mainWindow) {
456457 Tk_DeleteEventHandler(mainWindow, StructureNotifyMask,
457458 ConsoleEventProc, info);
458 if (--info->refCount <= 0) {
459 if (info->refCount-- <= 1) {
459460 ckfree(info);
460461 }
461462 }
496497 int toWrite, /* How many bytes to write? */
497498 int *errorCode) /* Where to store error code. */
498499 {
499 ChannelData *data = instanceData;
500 ChannelData *data = (ChannelData *)instanceData;
500501 ConsoleInfo *info = data->info;
501502
502503 *errorCode = 0;
557558 *----------------------------------------------------------------------
558559 */
559560
560 /* ARGSUSED */
561561 static int
562562 ConsoleInput(
563 ClientData instanceData, /* Unused. */
564 char *buf, /* Where to store data read. */
565 int bufSize, /* How much space is available in the
563 TCL_UNUSED(void *),
564 TCL_UNUSED(char *), /* Where to store data read. */
565 TCL_UNUSED(int), /* How much space is available in the
566566 * buffer? */
567 int *errorCode) /* Where to store error code. */
567 TCL_UNUSED(int *)) /* Where to store error code. */
568568 {
569569 return 0; /* Always return EOF. */
570570 }
572572 /*
573573 *----------------------------------------------------------------------
574574 *
575 * ConsoleClose --
575 * ConsoleClose/Console2Close --
576576 *
577577 * Closes the IO channel.
578578 *
585585 *----------------------------------------------------------------------
586586 */
587587
588 /* ARGSUSED */
589588 static int
590589 ConsoleClose(
591 ClientData instanceData, /* Unused. */
592 Tcl_Interp *interp) /* Unused. */
593 {
594 ChannelData *data = instanceData;
590 ClientData instanceData,
591 TCL_UNUSED(Tcl_Interp *))
592 {
593 ChannelData *data = (ChannelData *)instanceData;
595594 ConsoleInfo *info = data->info;
596595
597596 if (info) {
598 if (--info->refCount <= 0) {
597 if (info->refCount-- <= 1) {
599598 /*
600599 * Assuming the Tcl_Interp * fields must already be NULL.
601600 */
606605 ckfree(data);
607606 return 0;
608607 }
608
609 static int
610 Console2Close(
611 ClientData instanceData, /* Unused. */
612 Tcl_Interp *interp, /* Unused. */
613 int flags)
614 {
615 if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))==0) {
616 return ConsoleClose(instanceData, interp);
617 }
618 return EINVAL;
619 }
609620
610621 /*
611622 *----------------------------------------------------------------------
625636 *----------------------------------------------------------------------
626637 */
627638
628 /* ARGSUSED */
629639 static void
630640 ConsoleWatch(
631 ClientData instanceData, /* Device ID for the channel. */
632 int mask) /* OR-ed combination of TCL_READABLE,
641 TCL_UNUSED(void *), /* Device ID for the channel. */
642 TCL_UNUSED(int)) /* OR-ed combination of TCL_READABLE,
633643 * TCL_WRITABLE and TCL_EXCEPTION, for the
634644 * events we are interested in. */
635645 {
652662 *----------------------------------------------------------------------
653663 */
654664
655 /* ARGSUSED */
656665 static int
657666 ConsoleHandle(
658 ClientData instanceData, /* Device ID for the channel. */
659 int direction, /* TCL_READABLE or TCL_WRITABLE to indicate
667 TCL_UNUSED(void *), /* Device ID for the channel. */
668 TCL_UNUSED(int), /* TCL_READABLE or TCL_WRITABLE to indicate
660669 * which direction of the channel is being
661670 * requested. */
662 ClientData *handlePtr) /* Where to store handle */
671 TCL_UNUSED(void **)) /* Where to store handle */
663672 {
664673 return TCL_ERROR;
665674 }
693702 "eval", "hide", "show", "title", NULL};
694703 enum option {CON_EVAL, CON_HIDE, CON_SHOW, CON_TITLE};
695704 Tcl_Obj *cmd = NULL;
696 ConsoleInfo *info = clientData;
705 ConsoleInfo *info = (ConsoleInfo *)clientData;
697706 Tcl_Interp *consoleInterp = info->consoleInterp;
698707
699708 if (objc < 2) {
783792 int index, result = TCL_OK;
784793 static const char *const options[] = {"eval", "record", NULL};
785794 enum option {OTHER_EVAL, OTHER_RECORD};
786 ConsoleInfo *info = clientData;
795 ConsoleInfo *info = (ConsoleInfo *)clientData;
787796 Tcl_Interp *otherInterp = info->interp;
788797
789798 if (objc < 2) {
802811
803812 if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) {
804813 Tcl_SetObjResult(interp, Tcl_NewStringObj(
805 "no active master interp", -1));
814 "no active parent interp", -1));
806815 Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NO_INTERP", NULL);
807816 return TCL_ERROR;
808817 }
851860 DeleteConsoleInterp(
852861 ClientData clientData)
853862 {
854 Tcl_Interp *interp = clientData;
863 Tcl_Interp *interp = (Tcl_Interp *)clientData;
855864
856865 Tcl_DeleteInterp(interp);
857866 }
878887 ClientData clientData,
879888 Tcl_Interp *interp)
880889 {
881 ConsoleInfo *info = clientData;
890 ConsoleInfo *info = (ConsoleInfo *)clientData;
882891
883892 if (info->consoleInterp == interp) {
884893 Tcl_DeleteThreadExitHandler(DeleteConsoleInterp, info->consoleInterp);
885894 info->consoleInterp = NULL;
886895 }
887 if (--info->refCount <= 0) {
896 if (info->refCount-- <= 1) {
888897 ckfree(info);
889898 }
890899 }
910919 ConsoleDeleteProc(
911920 ClientData clientData)
912921 {
913 ConsoleInfo *info = clientData;
922 ConsoleInfo *info = (ConsoleInfo *)clientData;
914923
915924 if (info->consoleInterp) {
916925 Tcl_DeleteInterp(info->consoleInterp);
917926 }
918 if (--info->refCount <= 0) {
927 if (info->refCount-- <= 1) {
919928 ckfree(info);
920929 }
921930 }
925934 *
926935 * ConsoleEventProc --
927936 *
928 * This event function is registered on the main window of the slave
937 * This event function is registered on the main window of the child
929938 * interpreter. If the user or a running script causes the main window to
930939 * be destroyed, then we need to inform the console interpreter by
931940 * invoking "::tk::ConsoleExit".
945954 XEvent *eventPtr)
946955 {
947956 if (eventPtr->type == DestroyNotify) {
948 ConsoleInfo *info = clientData;
957 ConsoleInfo *info = (ConsoleInfo *)clientData;
949958 Tcl_Interp *consoleInterp = info->consoleInterp;
950959
951960 if (consoleInterp && !Tcl_InterpDeleted(consoleInterp)) {
952961 Tcl_EvalEx(consoleInterp, "tk::ConsoleExit", -1, TCL_EVAL_GLOBAL);
953962 }
954963
955 if (--info->refCount <= 0) {
964 if (info->refCount-- <= 1) {
956965 ckfree(info);
957966 }
958967 }
401401 /* 116 */
402402 EXTERN Tk_Window Tk_IdToWindow(Display *display, Window window);
403403 /* 117 */
404 EXTERN void Tk_ImageChanged(Tk_ImageMaster master, int x, int y,
404 EXTERN void Tk_ImageChanged(Tk_ImageMaster model, int x, int y,
405405 int width, int height, int imageWidth,
406406 int imageHeight);
407407 /* 118 */
412412 EXTERN int Tk_IntersectTextLayout(Tk_TextLayout layout, int x,
413413 int y, int width, int height);
414414 /* 121 */
415 EXTERN void Tk_MaintainGeometry(Tk_Window slave,
416 Tk_Window master, int x, int y, int width,
415 EXTERN void Tk_MaintainGeometry(Tk_Window window,
416 Tk_Window container, int x, int y, int width,
417417 int height);
418418 /* 122 */
419419 EXTERN Tk_Window Tk_MainWindow(Tcl_Interp *interp);
452452 /* 136 */
453453 EXTERN CONST84_RETURN char * Tk_NameOfFont(Tk_Font font);
454454 /* 137 */
455 EXTERN CONST84_RETURN char * Tk_NameOfImage(Tk_ImageMaster imageMaster);
455 EXTERN CONST84_RETURN char * Tk_NameOfImage(Tk_ImageMaster model);
456456 /* 138 */
457457 EXTERN CONST84_RETURN char * Tk_NameOfJoinStyle(int join);
458458 /* 139 */
581581 /* 180 */
582582 EXTERN void Tk_Ungrab(Tk_Window tkwin);
583583 /* 181 */
584 EXTERN void Tk_UnmaintainGeometry(Tk_Window slave,
585 Tk_Window master);
584 EXTERN void Tk_UnmaintainGeometry(Tk_Window window,
585 Tk_Window container);
586586 /* 182 */
587587 EXTERN void Tk_UnmapWindow(Tk_Window tkwin);
588588 /* 183 */
863863 /* 273 */
864864 EXTERN void Tk_CreateOldPhotoImageFormat(
865865 const Tk_PhotoImageFormat *formatPtr);
866 /* Slot 274 is reserved */
867 /* Slot 275 is reserved */
868 /* Slot 276 is reserved */
869 /* Slot 277 is reserved */
870 /* Slot 278 is reserved */
871 /* Slot 279 is reserved */
872 /* 280 */
873 EXTERN void TkUnusedStubEntry(void);
866874
867875 typedef struct {
868876 const struct TkPlatStubs *tkPlatStubs;
9921000 int (*tk_Grab) (Tcl_Interp *interp, Tk_Window tkwin, int grabGlobal); /* 114 */
9931001 void (*tk_HandleEvent) (XEvent *eventPtr); /* 115 */
9941002 Tk_Window (*tk_IdToWindow) (Display *display, Window window); /* 116 */
995 void (*tk_ImageChanged) (Tk_ImageMaster master, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */
1003 void (*tk_ImageChanged) (Tk_ImageMaster model, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */
9961004 int (*tk_Init) (Tcl_Interp *interp); /* 118 */
9971005 Atom (*tk_InternAtom) (Tk_Window tkwin, const char *name); /* 119 */
9981006 int (*tk_IntersectTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height); /* 120 */
999 void (*tk_MaintainGeometry) (Tk_Window slave, Tk_Window master, int x, int y, int width, int height); /* 121 */
1007 void (*tk_MaintainGeometry) (Tk_Window window, Tk_Window container, int x, int y, int width, int height); /* 121 */
10001008 Tk_Window (*tk_MainWindow) (Tcl_Interp *interp); /* 122 */
10011009 void (*tk_MakeWindowExist) (Tk_Window tkwin); /* 123 */
10021010 void (*tk_ManageGeometry) (Tk_Window tkwin, const Tk_GeomMgr *mgrPtr, ClientData clientData); /* 124 */
10121020 CONST84_RETURN char * (*tk_NameOfColor) (XColor *colorPtr); /* 134 */
10131021 CONST84_RETURN char * (*tk_NameOfCursor) (Display *display, Tk_Cursor cursor); /* 135 */
10141022 CONST84_RETURN char * (*tk_NameOfFont) (Tk_Font font); /* 136 */
1015 CONST84_RETURN char * (*tk_NameOfImage) (Tk_ImageMaster imageMaster); /* 137 */
1023 CONST84_RETURN char * (*tk_NameOfImage) (Tk_ImageMaster model); /* 137 */
10161024 CONST84_RETURN char * (*tk_NameOfJoinStyle) (int join); /* 138 */
10171025 CONST84_RETURN char * (*tk_NameOfJustify) (Tk_Justify justify); /* 139 */
10181026 CONST84_RETURN char * (*tk_NameOfRelief) (int relief); /* 140 */
10561064 void (*tk_UnderlineChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int x, int y, int firstByte, int lastByte); /* 178 */
10571065 void (*tk_UnderlineTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int underline); /* 179 */
10581066 void (*tk_Ungrab) (Tk_Window tkwin); /* 180 */
1059 void (*tk_UnmaintainGeometry) (Tk_Window slave, Tk_Window master); /* 181 */
1067 void (*tk_UnmaintainGeometry) (Tk_Window window, Tk_Window container); /* 181 */
10601068 void (*tk_UnmapWindow) (Tk_Window tkwin); /* 182 */
10611069 void (*tk_UnsetGrid) (Tk_Window tkwin); /* 183 */
10621070 void (*tk_UpdatePointer) (Tk_Window tkwin, int x, int y, int state); /* 184 */
11491157 Tcl_Interp * (*tk_Interp) (Tk_Window tkwin); /* 271 */
11501158 void (*tk_CreateOldImageType) (const Tk_ImageType *typePtr); /* 272 */
11511159 void (*tk_CreateOldPhotoImageFormat) (const Tk_PhotoImageFormat *formatPtr); /* 273 */
1160 void (*reserved274)(void);
1161 void (*reserved275)(void);
1162 void (*reserved276)(void);
1163 void (*reserved277)(void);
1164 void (*reserved278)(void);
1165 void (*reserved279)(void);
1166 void (*tkUnusedStubEntry) (void); /* 280 */
11521167 } TkStubs;
11531168
11541169 extern const TkStubs *tkStubsPtr;
17091724 (tkStubsPtr->tk_CreateOldImageType) /* 272 */
17101725 #define Tk_CreateOldPhotoImageFormat \
17111726 (tkStubsPtr->tk_CreateOldPhotoImageFormat) /* 273 */
1727 /* Slot 274 is reserved */
1728 /* Slot 275 is reserved */
1729 /* Slot 276 is reserved */
1730 /* Slot 277 is reserved */
1731 /* Slot 278 is reserved */
1732 /* Slot 279 is reserved */
1733 #define TkUnusedStubEntry \
1734 (tkStubsPtr->tkUnusedStubEntry) /* 280 */
17121735
17131736 #endif /* defined(USE_TK_STUBS) */
17141737
17191742 #undef Tk_Init
17201743 #undef Tk_SafeInit
17211744 #undef Tk_CreateConsoleWindow
1745 #define Tk_GetImageModelData Tk_GetImageMasterData
17221746
17231747 #if defined(_WIN32) && defined(UNICODE)
17241748 # define Tk_MainEx Tk_MainExW
17291753 #undef TCL_STORAGE_CLASS
17301754 #define TCL_STORAGE_CLASS DLLIMPORT
17311755
1756 #undef TkUnusedStubEntry
1757
17321758 #endif /* _TKDECLS */
190190 NULL, 0, -1, 0, "-background", 0},
191191 {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
192192 DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
193 {TK_OPTION_BORDER, "-buttonbackground", "Button.background", "Background",
193 {TK_OPTION_BORDER, "-buttonbackground", "buttonBackground", "Background",
194194 DEF_BUTTON_BG_COLOR, -1, Tk_Offset(Spinbox, buttonBorder),
195195 0, DEF_BUTTON_BG_MONO, 0},
196 {TK_OPTION_CURSOR, "-buttoncursor", "Button.cursor", "Cursor",
196 {TK_OPTION_CURSOR, "-buttoncursor", "buttonCursor", "Cursor",
197197 DEF_BUTTON_CURSOR, -1, Tk_Offset(Spinbox, bCursor),
198198 TK_OPTION_NULL_OK, 0, 0},
199 {TK_OPTION_RELIEF, "-buttondownrelief", "Button.relief", "Relief",
199 {TK_OPTION_RELIEF, "-buttondownrelief", "buttonDownRelief", "Relief",
200200 DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, bdRelief), 0, 0, 0},
201 {TK_OPTION_RELIEF, "-buttonuprelief", "Button.relief", "Relief",
201 {TK_OPTION_RELIEF, "-buttonuprelief", "buttonUpRelief", "Relief",
202202 DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, buRelief), 0, 0, 0},
203203 {TK_OPTION_STRING, "-command", "command", "Command",
204204 DEF_SPINBOX_CMD, -1, Tk_Offset(Spinbox, command),
425425 Tcl_Obj *const objv[]);
426426 static void EntryWorldChanged(ClientData instanceData);
427427 static int GetEntryIndex(Tcl_Interp *interp, Entry *entryPtr,
428 const char *string, int *indexPtr);
428 Tcl_Obj *indexObj, int *indexPtr);
429429 static int InsertChars(Entry *entryPtr, int index, const char *string);
430430
431431 /*
617617 Tcl_WrongNumArgs(interp, 2, objv, "index");
618618 goto error;
619619 }
620 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
620 if (GetEntryIndex(interp, entryPtr, objv[2],
621621 &index) != TCL_OK) {
622622 goto error;
623623 }
669669 Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
670670 goto error;
671671 }
672 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
672 if (GetEntryIndex(interp, entryPtr, objv[2],
673673 &first) != TCL_OK) {
674674 goto error;
675675 }
676676 if (objc == 3) {
677677 last = first + 1;
678 } else if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
678 } else if (GetEntryIndex(interp, entryPtr, objv[3],
679679 &last) != TCL_OK) {
680680 goto error;
681681 }
701701 Tcl_WrongNumArgs(interp, 2, objv, "pos");
702702 goto error;
703703 }
704 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
704 if (GetEntryIndex(interp, entryPtr, objv[2],
705705 &entryPtr->insertPos) != TCL_OK) {
706706 goto error;
707707 }
715715 Tcl_WrongNumArgs(interp, 2, objv, "string");
716716 goto error;
717717 }
718 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
718 if (GetEntryIndex(interp, entryPtr, objv[2],
719719 &index) != TCL_OK) {
720720 goto error;
721721 }
730730 Tcl_WrongNumArgs(interp, 2, objv, "index text");
731731 goto error;
732732 }
733 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
733 if (GetEntryIndex(interp, entryPtr, objv[2],
734734 &index) != TCL_OK) {
735735 goto error;
736736 }
810810 goto error;
811811 }
812812 if (GetEntryIndex(interp, entryPtr,
813 Tcl_GetString(objv[3]), &index) != TCL_OK) {
813 objv[3], &index) != TCL_OK) {
814814 goto error;
815815 }
816816 if (entryPtr->selectFirst >= 0) {
850850 goto error;
851851 }
852852 if (GetEntryIndex(interp, entryPtr,
853 Tcl_GetString(objv[3]), &index) != TCL_OK) {
853 objv[3], &index) != TCL_OK) {
854854 goto error;
855855 }
856856 entryPtr->selectAnchor = index;
870870 Tcl_WrongNumArgs(interp, 3, objv, "start end");
871871 goto error;
872872 }
873 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
873 if (GetEntryIndex(interp, entryPtr, objv[3],
874874 &index) != TCL_OK) {
875875 goto error;
876876 }
877 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[4]),
877 if (GetEntryIndex(interp, entryPtr, objv[4],
878878 &index2) != TCL_OK) {
879879 goto error;
880880 }
901901 goto error;
902902 }
903903 if (GetEntryIndex(interp, entryPtr,
904 Tcl_GetString(objv[3]), &index) != TCL_OK) {
904 objv[3], &index) != TCL_OK) {
905905 goto error;
906906 }
907907 EntrySelectTo(entryPtr, index);
941941 Tcl_SetObjResult(interp, Tcl_NewListObj(2, span));
942942 goto done;
943943 } else if (objc == 3) {
944 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
944 if (GetEntryIndex(interp, entryPtr, objv[2],
945945 &index) != TCL_OK) {
946946 goto error;
947947 }
17261726 }
17271727 }
17281728
1729 /*
1730 * Draw the text in two pieces: first the unselected portion, then the
1731 * selected portion on top of it.
1732 */
1733
1734 Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
1735 entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
1736 entryPtr->leftIndex, entryPtr->numChars);
1737
17381729 if (showSelection && (entryPtr->state != STATE_DISABLED)
17391730 && (entryPtr->selTextGC != entryPtr->textGC)
17401731 && (entryPtr->selectFirst < entryPtr->selectLast)) {
1732
1733 /*
1734 * Draw the selected and unselected portions separately.
1735 */
1736
17411737 int selFirst;
17421738
17431739 if (entryPtr->selectFirst < entryPtr->leftIndex) {
17451741 } else {
17461742 selFirst = entryPtr->selectFirst;
17471743 }
1744 if (entryPtr->leftIndex < selFirst) {
1745 Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
1746 entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
1747 entryPtr->leftIndex, selFirst);
1748 }
17481749 Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC,
17491750 entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
17501751 selFirst, entryPtr->selectLast);
1752 if (entryPtr->selectLast < entryPtr->numChars) {
1753 Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
1754 entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
1755 entryPtr->selectLast, entryPtr->numChars);
1756 }
1757 } else {
1758
1759 /*
1760 * Draw the entire visible text
1761 */
1762
1763 Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
1764 entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
1765 entryPtr->leftIndex, entryPtr->numChars);
17511766 }
17521767
17531768 if (entryPtr->type == TK_SPINBOX) {
20482063 char *newStr;
20492064
20502065 string = entryPtr->string;
2051 byteIndex = Tcl_UtfAtIndex(string, index) - string;
2066 byteIndex = TkUtfAtIndex(string, index) - string;
20522067 byteCount = strlen(value);
20532068 if (byteCount == 0) {
20542069 return TCL_OK;
20722087 entryPtr->string = newStr;
20732088
20742089 /*
2090 * ??? Is this construction still needed with Tcl_NumUtfChars ???
2091 *
20752092 * The following construction is used because inserting improperly formed
20762093 * UTF-8 sequences between other improperly formed UTF-8 sequences could
20772094 * result in actually forming valid UTF-8 sequences; the number of
21522169 }
21532170
21542171 string = entryPtr->string;
2155 byteIndex = Tcl_UtfAtIndex(string, index) - string;
2156 byteCount = Tcl_UtfAtIndex(string + byteIndex, count) - (string+byteIndex);
2172 byteIndex = TkUtfAtIndex(string, index) - string;
2173 byteCount = TkUtfAtIndex(string + byteIndex, count) - (string+byteIndex);
21572174
21582175 newByteCount = entryPtr->numBytes + 1 - byteCount;
21592176 newStr = ckalloc(newByteCount);
25552572 Tcl_Interp *interp, /* For error messages. */
25562573 Entry *entryPtr, /* Entry for which the index is being
25572574 * specified. */
2558 const char *string, /* Specifies character in entryPtr. */
2575 Tcl_Obj *indexObj, /* Specifies character in entryPtr. */
25592576 int *indexPtr) /* Where to store converted character index */
25602577 {
2561 size_t length;
2562
2563 length = strlen(string);
2578 const char *string = Tcl_GetString(indexObj);
2579 size_t length = indexObj->length;
25642580
25652581 switch (string[0]) {
25662582 case 'a':
26352651 break;
26362652 }
26372653 default:
2638 if (Tcl_GetInt(NULL, string, indexPtr) != TCL_OK) {
2654 if (Tcl_GetIntFromObj(NULL, indexObj, indexPtr) != TCL_OK) {
26392655 goto badIndex;
26402656 }
26412657 if (*indexPtr < 0){
28152831 return -1;
28162832 }
28172833 string = entryPtr->displayString;
2818 selStart = Tcl_UtfAtIndex(string, entryPtr->selectFirst);
2819 selEnd = Tcl_UtfAtIndex(selStart,
2834 selStart = TkUtfAtIndex(string, entryPtr->selectFirst);
2835 selEnd = TkUtfAtIndex(selStart,
28202836 entryPtr->selectLast - entryPtr->selectFirst);
28212837 byteCount = selEnd - selStart - offset;
28222838 if (byteCount > maxBytes) {
30053021 Tcl_DStringAppend(&buf, firstStr, -1);
30063022 Tcl_DStringAppend(&buf, " ", -1);
30073023 Tcl_DStringAppend(&buf, lastStr, -1);
3008 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
3024 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
30093025 Tcl_DStringFree(&buf);
30103026 if (code != TCL_OK) {
30113027 Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
32223238 * string). */
32233239 {
32243240 register Tcl_Interp *interp = entryPtr->interp;
3225 int code, bool;
3241 int code, isOK;
32263242
32273243 code = Tcl_EvalEx(interp, cmd, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
32283244
32443260 */
32453261
32463262 if (Tcl_GetBooleanFromObj(interp, Tcl_GetObjResult(interp),
3247 &bool) != TCL_OK) {
3263 &isOK) != TCL_OK) {
32483264 Tcl_AddErrorInfo(interp,
32493265 "\n (invalid boolean result from validation command)");
32503266 Tcl_BackgroundException(interp, TCL_ERROR);
32533269 }
32543270
32553271 Tcl_ResetResult(interp);
3256 return (bool ? TCL_OK : TCL_BREAK);
3272 return (isOK ? TCL_OK : TCL_BREAK);
32573273 }
32583274
32593275 /*
32663282 *
32673283 * Results:
32683284 * TCL_OK if the validatecommand accepts the new string, TCL_ERROR if any
3269 * problems occured with validatecommand.
3285 * problems occurred with validatecommand.
32703286 *
32713287 * Side effects:
32723288 * The insertion/deletion may be aborted, and the validatecommand might
32913307
32923308 if (entryPtr->validateCmd == NULL ||
32933309 entryPtr->validate == VALIDATE_NONE) {
3310 if (entryPtr->flags & VALIDATING) {
3311 entryPtr->flags |= VALIDATE_ABORT;
3312 }
32943313 return (varValidate ? TCL_ERROR : TCL_OK);
32953314 }
32963315
32973316 /*
3298 * If we're already validating, then we're hitting a loop condition Return
3299 * and set validate to 0 to disallow further validations and prevent
3300 * current validation from finishing
3317 * If we're already validating, then we're hitting a loop condition. Set
3318 * validate to none to disallow further validations, arrange for flags
3319 * to prevent current validation from finishing, and return.
33013320 */
33023321
33033322 if (entryPtr->flags & VALIDATING) {
33043323 entryPtr->validate = VALIDATE_NONE;
3324 entryPtr->flags |= VALIDATE_ABORT;
33053325 return (varValidate ? TCL_ERROR : TCL_OK);
33063326 }
33073327
33233343 /*
33243344 * If e->validate has become VALIDATE_NONE during the validation, or we
33253345 * now have VALIDATE_VAR set (from EntrySetValue) and didn't before, it
3326 * means that a loop condition almost occured. Do not allow this
3346 * means that a loop condition almost occurred. Do not allow this
33273347 * validation result to finish.
33283348 */
33293349
37483768 Tcl_WrongNumArgs(interp, 2, objv, "index");
37493769 goto error;
37503770 }
3751 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
3771 if (GetEntryIndex(interp, entryPtr, objv[2],
37523772 &index) != TCL_OK) {
37533773 goto error;
37543774 }
37993819 Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
38003820 goto error;
38013821 }
3802 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
3822 if (GetEntryIndex(interp, entryPtr, objv[2],
38033823 &first) != TCL_OK) {
38043824 goto error;
38053825 }
38063826 if (objc == 3) {
38073827 last = first + 1;
38083828 } else {
3809 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
3829 if (GetEntryIndex(interp, entryPtr, objv[3],
38103830 &last) != TCL_OK) {
38113831 goto error;
38123832 }
38333853 Tcl_WrongNumArgs(interp, 2, objv, "pos");
38343854 goto error;
38353855 }
3836 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
3856 if (GetEntryIndex(interp, entryPtr, objv[2],
38373857 &entryPtr->insertPos) != TCL_OK) {
38383858 goto error;
38393859 }
38663886 Tcl_WrongNumArgs(interp, 2, objv, "string");
38673887 goto error;
38683888 }
3869 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
3889 if (GetEntryIndex(interp, entryPtr, objv[2],
38703890 &index) != TCL_OK) {
38713891 goto error;
38723892 }
38813901 Tcl_WrongNumArgs(interp, 2, objv, "index text");
38823902 goto error;
38833903 }
3884 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
3904 if (GetEntryIndex(interp, entryPtr, objv[2],
38853905 &index) != TCL_OK) {
38863906 goto error;
38873907 }
39783998 goto error;
39793999 }
39804000 if (GetEntryIndex(interp, entryPtr,
3981 Tcl_GetString(objv[3]), &index) != TCL_OK) {
4001 objv[3], &index) != TCL_OK) {
39824002 goto error;
39834003 }
39844004 if (entryPtr->selectFirst >= 0) {
40184038 goto error;
40194039 }
40204040 if (GetEntryIndex(interp, entryPtr,
4021 Tcl_GetString(objv[3]), &index) != TCL_OK) {
4041 objv[3], &index) != TCL_OK) {
40224042 goto error;
40234043 }
40244044 entryPtr->selectAnchor = index;
40394059 goto error;
40404060 }
40414061 if (GetEntryIndex(interp, entryPtr,
4042 Tcl_GetString(objv[3]), &index) != TCL_OK) {
4062 objv[3], &index) != TCL_OK) {
40434063 goto error;
40444064 }
40454065 if (GetEntryIndex(interp, entryPtr,
4046 Tcl_GetString(objv[4]),& index2) != TCL_OK) {
4066 objv[4],& index2) != TCL_OK) {
40474067 goto error;
40484068 }
40494069 if (index >= index2) {
40694089 goto error;
40704090 }
40714091 if (GetEntryIndex(interp, entryPtr,
4072 Tcl_GetString(objv[3]), &index) != TCL_OK) {
4092 objv[3], &index) != TCL_OK) {
40734093 goto error;
40744094 }
40754095 EntrySelectTo(entryPtr, index);
41494169 Tcl_SetObjResult(interp, Tcl_NewListObj(2, span));
41504170 goto done;
41514171 } else if (objc == 3) {
4152 if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
4172 if (GetEntryIndex(interp, entryPtr, objv[2],
41534173 &index) != TCL_OK) {
41544174 goto error;
41554175 }
7272 * Array of event masks corresponding to each X event:
7373 */
7474
75 static const unsigned long realEventMasks[MappingNotify+1] = {
75 static const unsigned long eventMasks[TK_LASTEVENT] = {
7676 0,
7777 0,
7878 KeyPressMask, /* KeyPress */
110110 0, /* SelectionNotify */
111111 ColormapChangeMask, /* ColormapNotify */
112112 0, /* ClientMessage */
113 0 /* Mapping Notify */
114 };
115
116 static const unsigned long virtualEventMasks[TK_LASTEVENT-VirtualEvent] = {
113 0, /* Mapping Notify */
117114 VirtualEventMask, /* VirtualEvents */
118115 ActivateMask, /* ActivateNotify */
119116 ActivateMask, /* DeactivateNotify */
451448 {
452449 unsigned long mask;
453450
454 /*
455 * Get the event mask from the correct table. Note that there are two
456 * tables here because that means we no longer need this code to rely on
457 * the exact value of VirtualEvent, which has caused us problems in the
458 * past when X11 changed the value of LASTEvent. [Bug ???]
459 */
460
461 if (eventPtr->xany.type <= MappingNotify) {
462 mask = realEventMasks[eventPtr->xany.type];
463 } else if (eventPtr->xany.type >= VirtualEvent
464 && eventPtr->xany.type<TK_LASTEVENT) {
465 mask = virtualEventMasks[eventPtr->xany.type - VirtualEvent];
451 if (eventPtr->xany.type <TK_LASTEVENT) {
452 mask = eventMasks[eventPtr->xany.type];
466453 } else {
467454 mask = 0;
468455 }
534521 *----------------------------------------------------------------------
535522 */
536523
537 static const unsigned long buttonMasks[] = {
524 static const unsigned buttonMasks[] = {
538525 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
539526 };
540527
541 unsigned long
528 unsigned
542529 TkGetButtonMask(
543 unsigned int button)
530 unsigned button)
544531 {
545532 return (button > Button5) ? 0 : buttonMasks[button];
546533 }
697684 Tk_EventProc *proc, /* Function to call for each selected event */
698685 ClientData clientData) /* Arbitrary data to pass to proc. */
699686 {
700 register TkEventHandler *handlerPtr;
701 register TkWindow *winPtr = (TkWindow *) token;
687 TkEventHandler *handlerPtr;
688 TkWindow *winPtr = (TkWindow *)token;
702689
703690 /*
704691 * Skim through the list of existing handlers to (a) compute the overall
713700 * No event handlers defined at all, so must create.
714701 */
715702
716 handlerPtr = ckalloc(sizeof(TkEventHandler));
703 handlerPtr = (TkEventHandler *)ckalloc(sizeof(TkEventHandler));
717704 winPtr->handlerList = handlerPtr;
718705 } else {
719706 int found = 0;
744731 * No event handler matched, so create a new one.
745732 */
746733
747 handlerPtr->nextPtr = ckalloc(sizeof(TkEventHandler));
734 handlerPtr->nextPtr = (TkEventHandler *)ckalloc(sizeof(TkEventHandler));
748735 handlerPtr = handlerPtr->nextPtr;
749736 }
750737
787774 Tk_EventProc *proc,
788775 ClientData clientData)
789776 {
790 register TkEventHandler *handlerPtr;
791 register InProgress *ipPtr;
777 TkEventHandler *handlerPtr;
778 InProgress *ipPtr;
792779 TkEventHandler *prevPtr;
793 register TkWindow *winPtr = (TkWindow *) token;
794 ThreadSpecificData *tsdPtr =
780 TkWindow *winPtr = (TkWindow *) token;
781 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
795782 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
796783
797784 /*
863850 ClientData clientData) /* One-word value to pass to proc. */
864851 {
865852 GenericHandler *handlerPtr;
866 ThreadSpecificData *tsdPtr =
853 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
867854 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
868855
869 handlerPtr = ckalloc(sizeof(GenericHandler));
856 handlerPtr = (GenericHandler *)ckalloc(sizeof(GenericHandler));
870857
871858 handlerPtr->proc = proc;
872859 handlerPtr->clientData = clientData;
904891 ClientData clientData)
905892 {
906893 GenericHandler * handler;
907 ThreadSpecificData *tsdPtr =
894 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
908895 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
909896
910897 for (handler=tsdPtr->genericList ; handler ; handler=handler->nextPtr) {
937924 Tk_ClientMessageProc *proc) /* Function to call on event. */
938925 {
939926 GenericHandler *handlerPtr;
940 ThreadSpecificData *tsdPtr =
927 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
941928 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
942929
943930 /*
945932 * with an extra clientData field we'll never use.
946933 */
947934
948 handlerPtr = ckalloc(sizeof(GenericHandler));
935 handlerPtr = (GenericHandler *)ckalloc(sizeof(GenericHandler));
949936
950937 handlerPtr->proc = (Tk_GenericProc *) proc;
951938 handlerPtr->clientData = NULL; /* never used */
983970 Tk_ClientMessageProc *proc)
984971 {
985972 GenericHandler * handler;
986 ThreadSpecificData *tsdPtr =
973 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
987974 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
988975
989976 for (handler=tsdPtr->cmList ; handler!=NULL ; handler=handler->nextPtr) {
10141001 void
10151002 TkEventInit(void)
10161003 {
1017 ThreadSpecificData *tsdPtr =
1004 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
10181005 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
10191006
10201007 tsdPtr->handlersActive = 0;
10471034 static int
10481035 TkXErrorHandler(
10491036 ClientData clientData, /* Pointer to flag we set. */
1050 XErrorEvent *errEventPtr) /* X error info. */
1051 {
1052 int *error = clientData;
1037 TCL_UNUSED(XErrorEvent *)) /* X error info. */
1038 {
1039 int *error = (int *)clientData;
10531040
10541041 *error = 1;
10551042 return 0;
11361123 Tk_HandleEvent(
11371124 XEvent *eventPtr) /* Event to dispatch. */
11381125 {
1139 register TkEventHandler *handlerPtr;
1126 TkEventHandler *handlerPtr;
11401127 TkWindow *winPtr;
11411128 unsigned long mask;
11421129 InProgress ip;
11431130 Tcl_Interp *interp = NULL;
1144 ThreadSpecificData *tsdPtr =
1131 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
11451132 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
11461133
11471134 #if !defined(MAC_OSX_TK) && !defined(_WIN32)
13491336 TkWindow *winPtr) /* Information about the window that is being
13501337 * deleted. */
13511338 {
1352 register TkEventHandler *handlerPtr;
1353 register InProgress *ipPtr;
1354 ThreadSpecificData *tsdPtr =
1339 TkEventHandler *handlerPtr;
1340 InProgress *ipPtr;
1341 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
13551342 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
13561343
13571344 /*
13991386 TkCurrentTime(
14001387 TkDisplay *dispPtr) /* Display for which the time is desired. */
14011388 {
1402 register XEvent *eventPtr;
1403 ThreadSpecificData *tsdPtr =
1389 XEvent *eventPtr;
1390 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
14041391 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
14051392
14061393 if (tsdPtr->pendingPtr == NULL) {
14541441 * argument. */
14551442 {
14561443 Tk_RestrictProc *prev;
1457 ThreadSpecificData *tsdPtr =
1444 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
14581445 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
14591446
14601447 prev = tsdPtr->restrictProc;
15471534 */
15481535
15491536 if (!(dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS)) {
1550 wevPtr = ckalloc(sizeof(TkWindowEvent));
1537 wevPtr = (TkWindowEvent *)ckalloc(sizeof(TkWindowEvent));
15511538 wevPtr->header.proc = WindowEventProc;
15521539 wevPtr->event = *eventPtr;
15531540 Tcl_QueueEvent(&wevPtr->header, position);
15791566 }
15801567 }
15811568
1582 wevPtr = ckalloc(sizeof(TkWindowEvent));
1569 wevPtr = (TkWindowEvent *)ckalloc(sizeof(TkWindowEvent));
15831570 wevPtr->header.proc = WindowEventProc;
15841571 wevPtr->event = *eventPtr;
15851572 if ((eventPtr->type == MotionNotify) && (position == TCL_QUEUE_TAIL)) {
16421629 /*
16431630 *----------------------------------------------------------------------
16441631 *
1632 * TkGenerateActivateEvents --
1633 *
1634 * This function is called by the Mac and Windows window manager routines
1635 * when a toplevel window is activated or deactivated.
1636 * Activate/Deactivate events will be sent to every subwindow of the
1637 * toplevel followed by a FocusIn/FocusOut message.
1638 *
1639 * Results:
1640 * None.
1641 *
1642 * Side effects:
1643 * Generates X events.
1644 *
1645 *----------------------------------------------------------------------
1646 */
1647
1648 void
1649 TkGenerateActivateEvents(
1650 TkWindow *winPtr, /* Toplevel to activate. */
1651 int active) /* Non-zero if the window is being activated,
1652 * else 0.*/
1653 {
1654 XEvent event;
1655
1656 /*
1657 * Generate Activate and Deactivate events. This event is sent to every
1658 * subwindow in a toplevel window.
1659 */
1660
1661 event.xany.serial = NextRequest(winPtr->display);
1662 event.xany.send_event = False;
1663 event.xany.display = winPtr->display;
1664 event.xany.window = winPtr->window;
1665
1666 event.xany.type = active ? ActivateNotify : DeactivateNotify;
1667 TkQueueEventForAllChildren(winPtr, &event);
1668 }
1669
1670 /*
1671 *----------------------------------------------------------------------
1672 *
16451673 * WindowEventProc --
16461674 *
16471675 * This function is called by Tcl_DoOneEvent when a window event reaches
16691697 {
16701698 TkWindowEvent *wevPtr = (TkWindowEvent *) evPtr;
16711699 Tk_RestrictAction result;
1672 ThreadSpecificData *tsdPtr =
1700 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
16731701 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
16741702
16751703 if (!(flags & TCL_WINDOW_EVENTS)) {
17221750 switch (eventPtr->type) {
17231751 case KeyPress:
17241752 case KeyRelease: {
1753
1754 #if !defined(_WIN32) && !defined(MAC_OSX_TK)
17251755 TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
1726
17271756 if (kePtr->charValuePtr != NULL) {
17281757 ckfree(kePtr->charValuePtr);
17291758 kePtr->charValuePtr = NULL;
17301759 kePtr->charValueLen = 0;
17311760 }
1761 #endif
17321762 break;
17331763 }
17341764
17681798 ClientData clientData) /* Pointer to display containing a delayed
17691799 * motion event to be serviced. */
17701800 {
1771 TkDisplay *dispPtr = clientData;
1801 TkDisplay *dispPtr = (TkDisplay *)clientData;
17721802
17731803 if (dispPtr->delayedMotionPtr == NULL) {
17741804 Tcl_Panic("DelayedMotionProc found no delayed mouse motion event");
18001830 {
18011831 ExitHandler *exitPtr;
18021832
1803 exitPtr = ckalloc(sizeof(ExitHandler));
1833 exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler));
18041834 exitPtr->proc = proc;
18051835 exitPtr->clientData = clientData;
18061836 Tcl_MutexLock(&exitMutex);
18961926 ClientData clientData) /* Arbitrary value to pass to proc. */
18971927 {
18981928 ExitHandler *exitPtr;
1899 ThreadSpecificData *tsdPtr =
1929 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
19001930 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
19011931
1902 exitPtr = ckalloc(sizeof(ExitHandler));
1932 exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler));
19031933 exitPtr->proc = proc;
19041934 exitPtr->clientData = clientData;
19051935
19371967 ClientData clientData) /* Arbitrary value to pass to proc. */
19381968 {
19391969 ExitHandler *exitPtr, *prevPtr;
1940 ThreadSpecificData *tsdPtr =
1970 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
19411971 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
19421972
19431973 for (prevPtr = NULL, exitPtr = tsdPtr->firstExitPtr; exitPtr != NULL;
19762006
19772007 void
19782008 TkFinalize(
1979 ClientData clientData) /* Arbitrary value to pass to proc. */
2009 TCL_UNUSED(void *)) /* Arbitrary value to pass to proc. */
19802010 {
19812011 ExitHandler *exitPtr;
19822012
20282058
20292059 void
20302060 TkFinalizeThread(
2031 ClientData clientData) /* Arbitrary value to pass to proc. */
2061 TCL_UNUSED(void *)) /* Arbitrary value to pass to proc. */
20322062 {
20332063 ExitHandler *exitPtr;
2034 ThreadSpecificData *tsdPtr =
2064 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
20352065 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
20362066
20372067 Tcl_DeleteThreadExitHandler(TkFinalizeThread, NULL);
602602
603603 if (displayFocusPtr->focusOnMapPtr != NULL) {
604604 Tk_DeleteEventHandler((Tk_Window) displayFocusPtr->focusOnMapPtr,
605 StructureNotifyMask, FocusMapProc,
605 VisibilityChangeMask, FocusMapProc,
606606 displayFocusPtr->focusOnMapPtr);
607607 displayFocusPtr->focusOnMapPtr = NULL;
608608 }
1313 #include "tkInt.h"
1414 #include "tkFont.h"
1515 #if defined(MAC_OSX_TK)
16 #include "tkMacOSXInt.h"
16 #include "tkMacOSXInt.h" /* Defines TK_DRAW_IN_CONTEXT */
1717 #endif
18
1819 /*
1920 * The following structure is used to keep track of all the fonts that exist
2021 * in the current application. It must be stored in the TkMainInfo for the
9495 * layout. */
9596 int numChunks; /* Number of chunks actually used in following
9697 * array. */
97 LayoutChunk chunks[1]; /* Array of chunks. The actual size will be
98 LayoutChunk chunks[TKFLEXARRAY];/* Array of chunks. The actual size will be
9899 * maxChunks. THIS FIELD MUST BE THE LAST IN
99100 * THE STRUCTURE. */
100101 } TextLayout;
378379 TkFontPkgInit(
379380 TkMainInfo *mainPtr) /* The application being created. */
380381 {
381 TkFontInfo *fiPtr = ckalloc(sizeof(TkFontInfo));
382 TkFontInfo *fiPtr = (TkFontInfo *)ckalloc(sizeof(TkFontInfo));
382383
383384 Tcl_InitHashTable(&fiPtr->fontCache, TCL_STRING_KEYS);
384385 Tcl_InitHashTable(&fiPtr->namedTable, TCL_STRING_KEYS);
471472 Tcl_Obj *const objv[]) /* Argument objects. */
472473 {
473474 int index;
474 Tk_Window tkwin = clientData;
475 Tk_Window tkwin = (Tk_Window)clientData;
475476 TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
476477 static const char *const optionStrings[] = {
477478 "actual", "configure", "create", "delete",
615616 }
616617 string = Tcl_GetString(objv[2]);
617618 namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string);
618 nfPtr = NULL; /* lint. */
619 nfPtr = NULL;
619620 if (namedHashPtr != NULL) {
620 nfPtr = Tcl_GetHashValue(namedHashPtr);
621 nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
621622 }
622623 if ((namedHashPtr == NULL) || nfPtr->deletePending) {
623624 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
738739 }
739740 case FONT_METRICS: {
740741 Tk_Font tkfont;
741 int skip, index, i;
742 int skip, i;
742743 const TkFontMetrics *fmPtr;
743744 static const char *const switches[] = {
744745 "-ascent", "-descent", "-linespace", "-fixed", NULL
795796 resultPtr = Tcl_NewObj();
796797 namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search);
797798 while (namedHashPtr != NULL) {
798 NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr);
799 NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
799800
800801 if (!nfPtr->deletePending) {
801 char *string = Tcl_GetHashKey(&fiPtr->namedTable,
802 char *string = (char *)Tcl_GetHashKey(&fiPtr->namedTable,
802803 namedHashPtr);
803804
804805 Tcl_ListObjAppendElement(NULL, resultPtr,
841842 Tcl_HashEntry *cacheHashPtr;
842843 Tcl_HashSearch search;
843844 TkFont *fontPtr;
844 NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr);
845 NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
845846
846847 if (nfPtr->refCount == 0) {
847848 /*
854855
855856 cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search);
856857 while (cacheHashPtr != NULL) {
857 for (fontPtr = Tcl_GetHashValue(cacheHashPtr);
858 for (fontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr);
858859 fontPtr != NULL; fontPtr = fontPtr->nextPtr) {
859860 if (fontPtr->namedHashPtr == namedHashPtr) {
860861 TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa);
872873 TheWorldHasChanged(
873874 ClientData clientData) /* Info about application's fonts. */
874875 {
875 TkFontInfo *fiPtr = clientData;
876 #if defined(MAC_OSX_TK)
876 TkFontInfo *fiPtr = (TkFontInfo *)clientData;
877877
878878 /*
879879 * On macOS it is catastrophic to recompute all widgets while the
880880 * [NSView drawRect] method is drawing. The best that we can do in
881881 * that situation is to abort the recomputation and hope for the best.
882 * This is ignored on other platforms.
882883 */
883
884 if (TkpAppIsDrawing()) {
884
885 if (TkpWillDrawWidget(NULL)) {
885886 return;
886887 }
887 #endif
888
888889 fiPtr->updatePending = 0;
889890 RecomputeWidgets(fiPtr->mainPtr->winPtr);
890891 }
962963
963964 namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew);
964965 if (!isNew) {
965 nfPtr = Tcl_GetHashValue(namedHashPtr);
966 nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
966967 if (!nfPtr->deletePending) {
967968 if (interp) {
968969 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
984985 return TCL_OK;
985986 }
986987
987 nfPtr = ckalloc(sizeof(NamedFont));
988 nfPtr = (NamedFont *)ckalloc(sizeof(NamedFont));
988989 nfPtr->deletePending = 0;
989990 Tcl_SetHashValue(namedHashPtr, nfPtr);
990991 nfPtr->fa = *faPtr;
10231024 }
10241025 return TCL_ERROR;
10251026 }
1026 nfPtr = Tcl_GetHashValue(namedHashPtr);
1027 nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
10271028 if (nfPtr->refCount != 0) {
10281029 nfPtr->deletePending = 1;
10291030 } else {
11121113 SetFontFromAny(interp, objPtr);
11131114 }
11141115
1115 oldFontPtr = objPtr->internalRep.twoPtrValue.ptr1;
1116 oldFontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
11161117 if (oldFontPtr != NULL) {
11171118 if (oldFontPtr->resourceRefCount == 0) {
11181119 /*
11411142 cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache,
11421143 Tcl_GetString(objPtr), &isNew);
11431144 }
1144 firstFontPtr = Tcl_GetHashValue(cacheHashPtr);
1145 firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr);
11451146 for (fontPtr = firstFontPtr; (fontPtr != NULL);
11461147 fontPtr = fontPtr->nextPtr) {
11471148 if (Tk_Screen(tkwin) == fontPtr->screen) {
11641165 * Construct a font based on a named font.
11651166 */
11661167
1167 nfPtr = Tcl_GetHashValue(namedHashPtr);
1168 nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
11681169 nfPtr->refCount++;
11691170
11701171 fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &nfPtr->fa);
12971298 SetFontFromAny(NULL, objPtr);
12981299 }
12991300
1300 fontPtr = objPtr->internalRep.twoPtrValue.ptr1;
1301 fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
13011302 if (fontPtr != NULL) {
13021303 if (fontPtr->resourceRefCount == 0) {
13031304 /*
13241325 hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr));
13251326 }
13261327 if (hashPtr != NULL) {
1327 for (fontPtr = Tcl_GetHashValue(hashPtr); fontPtr != NULL;
1328 for (fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); fontPtr != NULL;
13281329 fontPtr = fontPtr->nextPtr) {
13291330 if (Tk_Screen(tkwin) == fontPtr->screen) {
13301331 fontPtr->objRefCount++;
13591360
13601361 static int
13611362 SetFontFromAny(
1362 Tcl_Interp *interp, /* Used for error reporting if not NULL. */
1363 TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */
13631364 Tcl_Obj *objPtr) /* The object to convert. */
13641365 {
13651366 const Tcl_ObjType *typePtr;
14351436 if (fontPtr == NULL) {
14361437 return;
14371438 }
1438 fontPtr->resourceRefCount--;
1439 if (fontPtr->resourceRefCount > 0) {
1439 if (fontPtr->resourceRefCount-- > 1) {
14401440 return;
14411441 }
14421442 if (fontPtr->namedHashPtr != NULL) {
14451445 * the named font and free it if no-one else is using it.
14461446 */
14471447
1448 nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr);
1448 nfPtr = (NamedFont *)Tcl_GetHashValue(fontPtr->namedHashPtr);
14491449 nfPtr->refCount--;
14501450 if ((nfPtr->refCount == 0) && nfPtr->deletePending) {
14511451 Tcl_DeleteHashEntry(fontPtr->namedHashPtr);
14531453 }
14541454 }
14551455
1456 prevPtr = Tcl_GetHashValue(fontPtr->cacheHashPtr);
1456 prevPtr = (TkFont *)Tcl_GetHashValue(fontPtr->cacheHashPtr);
14571457 if (prevPtr == fontPtr) {
14581458 if (fontPtr->nextPtr == NULL) {
14591459 Tcl_DeleteHashEntry(fontPtr->cacheHashPtr);
15311531 FreeFontObj(
15321532 Tcl_Obj *objPtr) /* The object we are releasing. */
15331533 {
1534 TkFont *fontPtr = objPtr->internalRep.twoPtrValue.ptr1;
1534 TkFont *fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
15351535
15361536 if (fontPtr != NULL) {
15371537 fontPtr->objRefCount--;
15661566 Tcl_Obj *srcObjPtr, /* The object we are copying from. */
15671567 Tcl_Obj *dupObjPtr) /* The object we are copying to. */
15681568 {
1569 TkFont *fontPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
1569 TkFont *fontPtr = (TkFont *)srcObjPtr->internalRep.twoPtrValue.ptr1;
15701570
15711571 dupObjPtr->typePtr = srcObjPtr->typePtr;
15721572 dupObjPtr->internalRep.twoPtrValue.ptr1 = fontPtr;
19721972 int *heightPtr) /* Filled with height of string. */
19731973 {
19741974 TkFont *fontPtr = (TkFont *) tkfont;
1975 const char *start, *end, *special;
1975 const char *start, *endp, *special;
19761976 int n, y, bytesThisChunk, maxChunks, curLine, layoutHeight;
19771977 int baseline, height, curX, newX, maxWidth, *lineLengths;
19781978 TextLayout *layoutPtr;
20052005
20062006 maxChunks = 1;
20072007
2008 layoutPtr = ckalloc(sizeof(TextLayout)
2009 + (maxChunks-1) * sizeof(LayoutChunk));
2008 layoutPtr = (TextLayout *)ckalloc(Tk_Offset(TextLayout, chunks)
2009 + maxChunks * sizeof(LayoutChunk));
20102010 layoutPtr->tkfont = tkfont;
20112011 layoutPtr->string = string;
20122012 layoutPtr->numChunks = 0;
20202020
20212021 curX = 0;
20222022
2023 end = Tcl_UtfAtIndex(string, numChars);
2023 endp = TkUtfAtIndex(string, numChars);
20242024 special = string;
20252025
20262026 flags &= TK_IGNORE_TABS | TK_IGNORE_NEWLINES;
20272027 flags |= TK_WHOLE_WORDS | TK_AT_LEAST_ONE;
2028 for (start = string; start < end; ) {
2028 for (start = string; start < endp; ) {
20292029 if (start >= special) {
20302030 /*
20312031 * Find the next special character in the string.
20362036 * whitespace set.
20372037 */
20382038
2039 for (special = start; special < end; special++) {
2039 for (special = start; special < endp; special++) {
20402040 if (!(flags & TK_IGNORE_NEWLINES)) {
20412041 if ((*special == '\n') || (*special == '\r')) {
20422042 break;
20702070 }
20712071 }
20722072
2073 if ((start == special) && (special < end)) {
2073 if ((start == special) && (special < endp)) {
20742074 /*
20752075 * Handle the special character.
20762076 *
20872087 start++;
20882088 curX = newX;
20892089 flags &= ~TK_AT_LEAST_ONE;
2090 if ((start < end) &&
2090 if ((start < endp) &&
20912091 ((wrapLength <= 0) || (newX <= wrapLength))) {
20922092 /*
20932093 * More chars can still fit on this line.
21092109 * Consume all extra spaces at end of line.
21102110 */
21112111
2112 while ((start < end) && isspace(UCHAR(*start))) { /* INTL: ISO space */
2112 while ((start < endp) && isspace(UCHAR(*start))) { /* INTL: ISO space */
21132113 if (!(flags & TK_IGNORE_NEWLINES)) {
21142114 if ((*start == '\n') || (*start == '\r')) {
21152115 break;
22972297 int x, int y, /* Upper-left hand corner of rectangle in
22982298 * which to draw (pixels). */
22992299 int firstChar, /* The index of the first character to draw
2300 * from the given text item. 0 specfies the
2300 * from the given text item. 0 specifies the
23012301 * beginning. */
23022302 int lastChar) /* The index just after the last character to
23032303 * draw from the given text item. A number < 0
23042304 * means to draw all characters. */
23052305 {
2306 #if 0
2307 /* Use TkDrawAngledTextLayout() implementation - testing purposes at this point */
2308 TkDrawAngledTextLayout(display, drawable, gc, layout, x, y, 0.0, firstChar, lastChar);
2309 #else
23062310 TextLayout *layoutPtr = (TextLayout *) layout;
23072311 int i, numDisplayChars, drawX;
23082312 const char *firstByte, *lastByte;
23242328 firstChar = 0;
23252329 firstByte = chunkPtr->start;
23262330 } else {
2327 firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
2331 firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
23282332 Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
23292333 firstByte - chunkPtr->start, -1, 0, &drawX);
23302334 }
23312335 if (lastChar < numDisplayChars) {
23322336 numDisplayChars = lastChar;
23332337 }
2334 lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
2338 lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
2339 #if TK_DRAW_IN_CONTEXT
2340 TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont,
2341 chunkPtr->start, chunkPtr->numBytes,
2342 firstByte - chunkPtr->start, lastByte - firstByte,
2343 x+chunkPtr->x, y+chunkPtr->y);
2344 #else /* !TK_DRAW_IN_CONTEXT */
23352345 Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte,
23362346 lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y);
2347 #endif /* TK_DRAW_IN_CONTEXT */
23372348 }
23382349 firstChar -= chunkPtr->numChars;
23392350 lastChar -= chunkPtr->numChars;
23422353 }
23432354 chunkPtr++;
23442355 }
2356 #endif /* Use TkDrawAngledTextLayout() implementation */
23452357 }
23462358
23472359 void
23562368 * which to draw (pixels). */
23572369 double angle,
23582370 int firstChar, /* The index of the first character to draw
2359 * from the given text item. 0 specfies the
2371 * from the given text item. 0 specifies the
23602372 * beginning. */
23612373 int lastChar) /* The index just after the last character to
23622374 * draw from the given text item. A number < 0
23862398 firstChar = 0;
23872399 firstByte = chunkPtr->start;
23882400 } else {
2389 firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
2401 firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
23902402 Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
23912403 firstByte - chunkPtr->start, -1, 0, &drawX);
23922404 }
23932405 if (lastChar < numDisplayChars) {
23942406 numDisplayChars = lastChar;
23952407 }
2396 lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
2408 lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
2409 #if TK_DRAW_IN_CONTEXT
2410 dx = cosA * (chunkPtr->x) + sinA * (chunkPtr->y);
2411 dy = -sinA * (chunkPtr->x) + cosA * (chunkPtr->y);
2412 if (angle == 0.0) {
2413 TkpDrawCharsInContext(display, drawable, gc,
2414 layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes,
2415 firstByte - chunkPtr->start, lastByte - firstByte,
2416 (int)(x + dx), (int)(y + dy));
2417 } else {
2418 TkpDrawAngledCharsInContext(display, drawable, gc,
2419 layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes,
2420 firstByte - chunkPtr->start, lastByte - firstByte,
2421 x+dx, y+dy, angle);
2422 }
2423 #else /* !TK_DRAW_IN_CONTEXT */
23972424 dx = cosA * (chunkPtr->x + drawX) + sinA * (chunkPtr->y);
23982425 dy = -sinA * (chunkPtr->x + drawX) + cosA * (chunkPtr->y);
23992426 if (angle == 0.0) {
24042431 TkDrawAngledChars(display, drawable, gc, layoutPtr->tkfont,
24052432 firstByte, lastByte - firstByte, x+dx, y+dy, angle);
24062433 }
2434 #endif /* TK_DRAW_IN_CONTEXT */
24072435 }
24082436 firstChar -= chunkPtr->numChars;
24092437 lastChar -= chunkPtr->numChars;
27352763 goto check;
27362764 }
27372765 } else if (index < chunkPtr->numChars) {
2738 end = Tcl_UtfAtIndex(chunkPtr->start, index);
2766 end = TkUtfAtIndex(chunkPtr->start, index);
27392767 if (xPtr != NULL) {
27402768 Tk_MeasureChars(tkfont, chunkPtr->start,
27412769 end - chunkPtr->start, -1, 0, &x);
27422770 x += chunkPtr->x;
27432771 }
27442772 if (widthPtr != NULL) {
2745 Tk_MeasureChars(tkfont, end, Tcl_UtfNext(end) - end,
2746 -1, 0, &w);
2773 int ch;
2774 Tk_MeasureChars(tkfont, end, TkUtfToUniChar(end, &ch), -1, 0, &w);
27472775 }
27482776 goto check;
27492777 }
33753403 static int
33763404 ConfigAttributesObj(
33773405 Tcl_Interp *interp, /* Interp for error return. */
3378 Tk_Window tkwin, /* For display on which font will be used. */
3406 TCL_UNUSED(Tk_Window), /* For display on which font will be used. */
33793407 int objc, /* Number of elements in argv. */
33803408 Tcl_Obj *const objv[], /* Command line options. */
33813409 TkFontAttributes *faPtr) /* Font attributes structure whose fields are
35823610 * specified in font name are filled with
35833611 * default values. */
35843612 {
3585 char *dash;
3613 const char *dash;
35863614 int objc, result, i, n;
35873615 Tcl_Obj **objv;
35883616 const char *string;
37503778 maxChunks = *maxPtr;
37513779 if (layoutPtr->numChunks == maxChunks) {
37523780 maxChunks *= 2;
3753 s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk));
3781 s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk));
37543782 layoutPtr = ckrealloc(layoutPtr, s);
37553783
37563784 *layoutPtrPtr = layoutPtr;
42144242 hashPtr = Tcl_FindHashEntry(
42154243 &((TkWindow *) tkwin)->mainPtr->fontInfoPtr->fontCache, name);
42164244 if (hashPtr != NULL) {
4217 fontPtr = Tcl_GetHashValue(hashPtr);
4245 fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr);
42184246 if (fontPtr == NULL) {
42194247 Tcl_Panic("TkDebugFont found empty hash table entry");
42204248 }
42674295 }
42684296 chunkPtr = layoutPtr->chunks;
42694297 numBytesInChunk = chunkPtr->numBytes;
4270 strncpy(dst, chunkPtr->start, (size_t) numBytesInChunk);
4298 strncpy(dst, chunkPtr->start, numBytesInChunk);
42714299 *font = layoutPtr->tkfont;
42724300 return numBytesInChunk;
42734301 }
313313 static void FrameCmdDeletedProc(ClientData clientData);
314314 static void FrameEventProc(ClientData clientData,
315315 XEvent *eventPtr);
316 static void FrameLostSlaveProc(ClientData clientData,
316 static void FrameLostContentProc(ClientData clientData,
317317 Tk_Window tkwin);
318318 static void FrameRequestProc(ClientData clientData,
319319 Tk_Window tkwin);
345345 static const Tk_GeomMgr frameGeomType = {
346346 "labelframe", /* name */
347347 FrameRequestProc, /* requestProc */
348 FrameLostSlaveProc /* lostSlaveProc */
348 FrameLostContentProc /* lostSlaveProc */
349349 };
350350
351351 /*
805805 || ((c == 'v')
806806 && (strncmp(arg, "-visual", (unsigned)length) == 0))) {
807807
808 #ifdef SUPPORT_CONFIG_EMBEDDED
808 #ifdef _WIN32
809809 if (c == 'u') {
810810 const char *string = Tcl_GetString(objv[i+1]);
811811
19131913 /*
19141914 *--------------------------------------------------------------
19151915 *
1916 * FrameLostSlaveProc --
1916 * FrameLostContentProc --
19171917 *
19181918 * This function is invoked by Tk whenever some other geometry claims
1919 * control over a slave that used to be managed by us.
1919 * control over a content window that used to be managed by us.
19201920 *
19211921 * Results:
19221922 * None.
19231923 *
19241924 * Side effects:
1925 * Forgets all frame-related information about the slave.
1925 * Forgets all frame-related information about the content window.
19261926 *
19271927 *--------------------------------------------------------------
19281928 */
19291929
19301930 static void
1931 FrameLostSlaveProc(
1932 ClientData clientData, /* Frame structure for slave window that was
1931 FrameLostContentProc(
1932 ClientData clientData, /* Frame structure for content window that was
19331933 * stolen away. */
1934 Tk_Window tkwin) /* Tk's handle for the slave window. */
1934 Tk_Window tkwin) /* Tk's handle for the content window. */
19351935 {
19361936 Frame *framePtr = clientData;
19371937 Labelframe *labelframePtr = clientData;
1414
1515 /*
1616 * Data structures of the following type are used by Tk_MaintainGeometry. For
17 * each slave managed by Tk_MaintainGeometry, there is one of these structures
18 * associated with its master.
19 */
20
21 typedef struct MaintainSlave {
22 Tk_Window slave; /* The slave window being positioned. */
23 Tk_Window master; /* The master that determines slave's
17 * each content managed by Tk_MaintainGeometry, there is one of these structures
18 * associated with its container.
19 */
20
21 typedef struct MaintainContent {
22 Tk_Window content; /* The content window being positioned. */
23 Tk_Window container; /* The container that determines content's
2424 * position; it must be a descendant of
25 * slave's parent. */
26 int x, y; /* Desired position of slave relative to
27 * master. */
28 int width, height; /* Desired dimensions of slave. */
29 struct MaintainSlave *nextPtr;
25 * content's parent. */
26 int x, y; /* Desired position of content relative to
27 * container. */
28 int width, height; /* Desired dimensions of content. */
29 struct MaintainContent *nextPtr;
3030 /* Next in list of Maintains associated with
31 * master. */
32 } MaintainSlave;
33
34 /*
35 * For each window that has been specified as a master to Tk_MaintainGeometry,
31 * container. */
32 } MaintainContent;
33
34 /*
35 * For each window that has been specified as a content to Tk_MaintainGeometry,
3636 * there is a structure of the following type:
3737 */
3838
39 typedef struct MaintainMaster {
39 typedef struct MaintainContainer {
4040 Tk_Window ancestor; /* The lowest ancestor of this window for
4141 * which we have *not* created a
4242 * StructureNotify handler. May be the same as
4444 int checkScheduled; /* Non-zero means that there is already a call
4545 * to MaintainCheckProc scheduled as an idle
4646 * handler. */
47 MaintainSlave *slavePtr; /* First in list of all slaves associated with
48 * this master. */
49 } MaintainMaster;
47 MaintainContent *contentPtr; /* First in list of all content associated with
48 * this container. */
49 } MaintainContainer;
5050
5151 /*
5252 * Prototypes for static procedures in this file:
5353 */
5454
5555 static void MaintainCheckProc(ClientData clientData);
56 static void MaintainMasterProc(ClientData clientData,
56 static void MaintainContainerProc(ClientData clientData,
5757 XEvent *eventPtr);
58 static void MaintainSlaveProc(ClientData clientData,
58 static void MaintainContentProc(ClientData clientData,
5959 XEvent *eventPtr);
6060
6161 /*
6464 * Tk_ManageGeometry --
6565 *
6666 * Arrange for a particular procedure to manage the geometry of a given
67 * slave window.
67 * content window.
6868 *
6969 * Results:
7070 * None.
8989 ClientData clientData) /* Arbitrary one-word argument to pass to
9090 * geometry manager procedures. */
9191 {
92 register TkWindow *winPtr = (TkWindow *) tkwin;
92 TkWindow *winPtr = (TkWindow *) tkwin;
9393
9494 if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL)
9595 && ((winPtr->geomMgrPtr != mgrPtr)
131131 int reqWidth, int reqHeight)/* Minimum desired dimensions for window, in
132132 * pixels. */
133133 {
134 register TkWindow *winPtr = (TkWindow *) tkwin;
134 TkWindow *winPtr = (TkWindow *) tkwin;
135135
136136 /*
137137 * X gets very upset if a window requests a width or height of zero, so
181181 int left, int right, /* Width of internal border, in pixels. */
182182 int top, int bottom)
183183 {
184 register TkWindow *winPtr = (TkWindow *) tkwin;
185 register int changed = 0;
184 TkWindow *winPtr = (TkWindow *) tkwin;
185 int changed = 0;
186186
187187 if (left < 0) {
188188 left = 0;
217217 }
218218
219219 /*
220 * All the slaves for which this is the master window must now be
220 * All the content for which this is the container window must now be
221221 * repositioned to take account of the new internal border width. To
222222 * signal all the geometry managers to do this, trigger a ConfigureNotify
223223 * event. This will cause geometry managers to recompute everything.
278278 Tk_Window tkwin, /* Window that will have internal border. */
279279 int minWidth, int minHeight)/* Minimum requested size, in pixels. */
280280 {
281 register TkWindow *winPtr = (TkWindow *) tkwin;
281 TkWindow *winPtr = (TkWindow *) tkwin;
282282
283283 if ((winPtr->minReqWidth == minWidth) &&
284284 (winPtr->minReqHeight == minHeight)) {
302302 /*
303303 *----------------------------------------------------------------------
304304 *
305 * TkSetGeometryMaster --
306 *
307 * Set a geometry master for this window. Only one master may own
305 * TkSetGeometryContainer --
306 *
307 * Set a geometry container for this window. Only one container may own
308308 * a window at any time.
309309 *
310310 * Results:
311311 * A standard Tcl result.
312312 *
313313 * Side effects:
314 * The geometry master is recorded for the window.
314 * The geometry container is recorded for the window.
315315 *
316316 *----------------------------------------------------------------------
317317 */
318318
319319 int
320 TkSetGeometryMaster(
320 TkSetGeometryContainer(
321321 Tcl_Interp *interp, /* Current interpreter, for error. */
322 Tk_Window tkwin, /* Window that will have geometry master
322 Tk_Window tkwin, /* Window that will have geometry container
323323 * set. */
324 const char *master) /* The master identity. */
325 {
326 register TkWindow *winPtr = (TkWindow *) tkwin;
324 const char *name) /* The name of the geometry manager. */
325 {
326 TkWindow *winPtr = (TkWindow *) tkwin;
327327
328328 if (winPtr->geomMgrName != NULL &&
329 strcmp(winPtr->geomMgrName, master) == 0) {
329 strcmp(winPtr->geomMgrName, name) == 0) {
330330 return TCL_OK;
331331 }
332332 if (winPtr->geomMgrName != NULL) {
334334 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
335335 "cannot use geometry manager %s inside %s which already"
336336 " has slaves managed by %s",
337 master, Tk_PathName(tkwin), winPtr->geomMgrName));
337 name, Tk_PathName(tkwin), winPtr->geomMgrName));
338338 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL);
339339 }
340340 return TCL_ERROR;
341341 }
342342
343 winPtr->geomMgrName = ckalloc(strlen(master) + 1);
344 strcpy(winPtr->geomMgrName, master);
343 winPtr->geomMgrName = (char *)ckalloc(strlen(name) + 1);
344 strcpy(winPtr->geomMgrName, name);
345345 return TCL_OK;
346346 }
347347
348348 /*
349349 *----------------------------------------------------------------------
350350 *
351 * TkFreeGeometryMaster --
352 *
353 * Remove a geometry master for this window. Only one master may own
351 * TkFreeGeometryContainer --
352 *
353 * Remove a geometry container for this window. Only one container may own
354354 * a window at any time.
355355 *
356356 * Results:
357357 * None.
358358 *
359359 * Side effects:
360 * The geometry master is cleared for the window.
360 * The geometry container is cleared for the window.
361361 *
362362 *----------------------------------------------------------------------
363363 */
364364
365365 void
366 TkFreeGeometryMaster(
367 Tk_Window tkwin, /* Window that will have geometry master
366 TkFreeGeometryContainer(
367 Tk_Window tkwin, /* Window that will have geometry container
368368 * cleared. */
369 const char *master) /* The master identity. */
370 {
371 register TkWindow *winPtr = (TkWindow *) tkwin;
369 const char *name) /* The name of the geometry manager. */
370 {
371 TkWindow *winPtr = (TkWindow *) tkwin;
372372
373373 if (winPtr->geomMgrName != NULL &&
374 strcmp(winPtr->geomMgrName, master) != 0) {
374 strcmp(winPtr->geomMgrName, name) != 0) {
375375 Tcl_Panic("Trying to free %s from geometry manager %s",
376 winPtr->geomMgrName, master);
376 winPtr->geomMgrName, name);
377377 }
378378 if (winPtr->geomMgrName != NULL) {
379379 ckfree(winPtr->geomMgrName);
386386 *
387387 * Tk_MaintainGeometry --
388388 *
389 * This procedure is invoked by geometry managers to handle slaves whose
390 * master's are not their parents. It translates the desired geometry for
391 * the slave into the coordinate system of the parent and respositions
392 * the slave if it isn't already at the right place. Furthermore, it sets
393 * up event handlers so that if the master (or any of its ancestors up to
394 * the slave's parent) is mapped, unmapped, or moved, then the slave will
389 * This procedure is invoked by geometry managers to handle content whose
390 * container's are not their parents. It translates the desired geometry for
391 * the content into the coordinate system of the parent and respositions
392 * the content if it isn't already at the right place. Furthermore, it sets
393 * up event handlers so that if the container (or any of its ancestors up to
394 * the content's parent) is mapped, unmapped, or moved, then the content will
395395 * be adjusted to match.
396396 *
397397 * Results:
399399 *
400400 * Side effects:
401401 * Event handlers are created and state is allocated to keep track of
402 * slave. Note: if slave was already managed for master by
402 * content. Note: if content was already managed for container by
403403 * Tk_MaintainGeometry, then the previous information is replaced with
404404 * the new information. The caller must eventually call
405405 * Tk_UnmaintainGeometry to eliminate the correspondence (or, the state
410410
411411 void
412412 Tk_MaintainGeometry(
413 Tk_Window slave, /* Slave for geometry management. */
414 Tk_Window master, /* Master for slave; must be a descendant of
415 * slave's parent. */
416 int x, int y, /* Desired position of slave within master. */
417 int width, int height) /* Desired dimensions for slave. */
413 Tk_Window window, /* Window for geometry management. */
414 Tk_Window container, /* Container for window; must be a descendant of
415 * window's parent. */
416 int x, int y, /* Desired position of window within container. */
417 int width, int height) /* Desired dimensions for window. */
418418 {
419419 Tcl_HashEntry *hPtr;
420 MaintainMaster *masterPtr;
421 register MaintainSlave *slavePtr;
420 MaintainContainer *containerPtr;
421 MaintainContent *contentPtr;
422422 int isNew, map;
423423 Tk_Window ancestor, parent;
424 TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr;
425
426 ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master;
427
428 ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master;
429 if (master == Tk_Parent(slave)) {
424 TkDisplay *dispPtr = ((TkWindow *) container)->dispPtr;
425
426 ((TkWindow *)window)->maintainerPtr = (TkWindow *)container;
427
428 if (container == Tk_Parent(window)) {
430429 /*
431 * If the slave is a direct descendant of the master, don't bother
430 * If the window is a direct descendant of the container, don't bother
432431 * setting up the extra infrastructure for management, just make a
433432 * call to Tk_MoveResizeWindow; the parent/child relationship will
434433 * take care of the rest.
435434 */
436435
437 Tk_MoveResizeWindow(slave, x, y, width, height);
436 Tk_MoveResizeWindow(window, x, y, width, height);
438437
439438 /*
440 * Map the slave if the master is already mapped; otherwise, wait
441 * until the master is mapped later (in which case mapping the slave
439 * Map the window if the container is already mapped; otherwise, wait
440 * until the container is mapped later (in which case mapping the window
442441 * is taken care of elsewhere).
443442 */
444443
445 if (Tk_IsMapped(master)) {
446 Tk_MapWindow(slave);
444 if (Tk_IsMapped(container)) {
445 Tk_MapWindow(window);
447446 }
448447 return;
449448 }
454453 }
455454
456455 /*
457 * See if there is already a MaintainMaster structure for the master; if
456 * See if there is already a MaintainContainer structure for the container; if
458457 * not, then create one.
459458 */
460459
461 parent = Tk_Parent(slave);
460 parent = Tk_Parent(window);
462461 hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
463 (char *) master, &isNew);
462 (char *) container, &isNew);
464463 if (!isNew) {
465 masterPtr = Tcl_GetHashValue(hPtr);
464 containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr);
466465 } else {
467 masterPtr = ckalloc(sizeof(MaintainMaster));
468 masterPtr->ancestor = master;
469 masterPtr->checkScheduled = 0;
470 masterPtr->slavePtr = NULL;
471 Tcl_SetHashValue(hPtr, masterPtr);
466 containerPtr = (MaintainContainer *)ckalloc(sizeof(MaintainContainer));
467 containerPtr->ancestor = container;
468 containerPtr->checkScheduled = 0;
469 containerPtr->contentPtr = NULL;
470 Tcl_SetHashValue(hPtr, containerPtr);
472471 }
473472
474473 /*
475 * Create a MaintainSlave structure for the slave if there isn't already
474 * Create a MaintainContent structure for the window if there isn't already
476475 * one.
477476 */
478477
479 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
480 slavePtr = slavePtr->nextPtr) {
481 if (slavePtr->slave == slave) {
482 goto gotSlave;
483 }
484 }
485 slavePtr = ckalloc(sizeof(MaintainSlave));
486 slavePtr->slave = slave;
487 slavePtr->master = master;
488 slavePtr->nextPtr = masterPtr->slavePtr;
489 masterPtr->slavePtr = slavePtr;
490 Tk_CreateEventHandler(slave, StructureNotifyMask, MaintainSlaveProc,
491 slavePtr);
478 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
479 contentPtr = contentPtr->nextPtr) {
480 if (contentPtr->content == window) {
481 goto gotContent;
482 }
483 }
484 contentPtr = (MaintainContent *)ckalloc(sizeof(MaintainContent));
485 contentPtr->content = window;
486 contentPtr->container = container;
487 contentPtr->nextPtr = containerPtr->contentPtr;
488 containerPtr->contentPtr = contentPtr;
489 Tk_CreateEventHandler(window, StructureNotifyMask, MaintainContentProc,
490 contentPtr);
492491
493492 /*
494493 * Make sure that there are event handlers registered for all the windows
495 * between master and slave's parent (including master but not slave's
496 * parent). There may already be handlers for master and some of its
497 * ancestors (masterPtr->ancestor tells how many).
494 * between container and windows's parent (including container but not window's
495 * parent). There may already be handlers for container and some of its
496 * ancestors (containerPtr->ancestor tells how many).
498497 */
499498
500 for (ancestor = master; ancestor != parent;
499 for (ancestor = container; ancestor != parent;
501500 ancestor = Tk_Parent(ancestor)) {
502 if (ancestor == masterPtr->ancestor) {
501 if (ancestor == containerPtr->ancestor) {
503502 Tk_CreateEventHandler(ancestor, StructureNotifyMask,
504 MaintainMasterProc, masterPtr);
505 masterPtr->ancestor = Tk_Parent(ancestor);
503 MaintainContainerProc, containerPtr);
504 containerPtr->ancestor = Tk_Parent(ancestor);
506505 }
507506 }
508507
511510 * if it's not currently in the right place or state.
512511 */
513512
514 gotSlave:
515 slavePtr->x = x;
516 slavePtr->y = y;
517 slavePtr->width = width;
518 slavePtr->height = height;
513 gotContent:
514 contentPtr->x = x;
515 contentPtr->y = y;
516 contentPtr->width = width;
517 contentPtr->height = height;
519518 map = 1;
520 for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) {
519 for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) {
521520 if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
522521 map = 0;
523522 }
524523 if (ancestor == parent) {
525 if ((x != Tk_X(slavePtr->slave))
526 || (y != Tk_Y(slavePtr->slave))
527 || (width != Tk_Width(slavePtr->slave))
528 || (height != Tk_Height(slavePtr->slave))) {
529 Tk_MoveResizeWindow(slavePtr->slave, x, y, width, height);
524 if ((x != Tk_X(contentPtr->content))
525 || (y != Tk_Y(contentPtr->content))
526 || (width != Tk_Width(contentPtr->content))
527 || (height != Tk_Height(contentPtr->content))) {
528 Tk_MoveResizeWindow(contentPtr->content, x, y, width, height);
530529 }
531530 if (map) {
532 Tk_MapWindow(slavePtr->slave);
531 Tk_MapWindow(contentPtr->content);
533532 } else {
534 Tk_UnmapWindow(slavePtr->slave);
533 Tk_UnmapWindow(contentPtr->content);
535534 }
536535 break;
537536 }
546545 * Tk_UnmaintainGeometry --
547546 *
548547 * This procedure cancels a previous Tk_MaintainGeometry call, so that
549 * the relationship between slave and master is no longer maintained.
550 *
551 * Results:
552 * None.
553 *
554 * Side effects:
555 * The slave is unmapped and state is released, so that slave won't track
556 * master any more. If we weren't previously managing slave relative to
557 * master, then this procedure has no effect.
548 * the relationship between window and container is no longer maintained.
549 *
550 * Results:
551 * None.
552 *
553 * Side effects:
554 * The window is unmapped and state is released, so that window won't track
555 * container any more. If we weren't previously managing window relative to
556 * container, then this procedure has no effect.
558557 *
559558 *----------------------------------------------------------------------
560559 */
561560
562561 void
563562 Tk_UnmaintainGeometry(
564 Tk_Window slave, /* Slave for geometry management. */
565 Tk_Window master) /* Master for slave; must be a descendant of
566 * slave's parent. */
563 Tk_Window window, /* WIndow for geometry management. */
564 Tk_Window container) /* Container for window; must be a descendant of
565 * window's parent. */
567566 {
568567 Tcl_HashEntry *hPtr;
569 MaintainMaster *masterPtr;
570 register MaintainSlave *slavePtr, *prevPtr;
568 MaintainContainer *containerPtr;
569 MaintainContent *contentPtr, *prevPtr;
571570 Tk_Window ancestor;
572 TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr;
573
574 ((TkWindow *)slave)->maintainerPtr = NULL;
575
576 ((TkWindow *)slave)->maintainerPtr = NULL;
577 if (master == Tk_Parent(slave)) {
571 TkDisplay *dispPtr = ((TkWindow *) window)->dispPtr;
572
573 ((TkWindow *)window)->maintainerPtr = NULL;
574
575 if (container == Tk_Parent(window)) {
578576 /*
579 * If the slave is a direct descendant of the master,
577 * If the window is a direct descendant of the container,
580578 * Tk_MaintainGeometry will not have set up any of the extra
581579 * infrastructure. Don't even bother to look for it, just return.
582580 */
588586 Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS);
589587 }
590588
591 if (!(((TkWindow *) slave)->flags & TK_ALREADY_DEAD)) {
592 Tk_UnmapWindow(slave);
593 }
594 hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, (char *) master);
589 if (!(((TkWindow *) window)->flags & TK_ALREADY_DEAD)) {
590 Tk_UnmapWindow(window);
591 }
592 hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, container);
595593 if (hPtr == NULL) {
596594 return;
597595 }
598 masterPtr = Tcl_GetHashValue(hPtr);
599 slavePtr = masterPtr->slavePtr;
600 if (slavePtr->slave == slave) {
601 masterPtr->slavePtr = slavePtr->nextPtr;
596 containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr);
597 contentPtr = containerPtr->contentPtr;
598 if (contentPtr->content == window) {
599 containerPtr->contentPtr = contentPtr->nextPtr;
602600 } else {
603 for (prevPtr = slavePtr, slavePtr = slavePtr->nextPtr; ;
604 prevPtr = slavePtr, slavePtr = slavePtr->nextPtr) {
605 if (slavePtr == NULL) {
601 for (prevPtr = contentPtr, contentPtr = contentPtr->nextPtr; ;
602 prevPtr = contentPtr, contentPtr = contentPtr->nextPtr) {
603 if (contentPtr == NULL) {
606604 return;
607605 }
608 if (slavePtr->slave == slave) {
609 prevPtr->nextPtr = slavePtr->nextPtr;
606 if (contentPtr->content == window) {
607 prevPtr->nextPtr = contentPtr->nextPtr;
610608 break;
611609 }
612610 }
613611 }
614 Tk_DeleteEventHandler(slavePtr->slave, StructureNotifyMask,
615 MaintainSlaveProc, slavePtr);
616 ckfree(slavePtr);
617 if (masterPtr->slavePtr == NULL) {
618 if (masterPtr->ancestor != NULL) {
619 for (ancestor = master; ; ancestor = Tk_Parent(ancestor)) {
612 Tk_DeleteEventHandler(contentPtr->content, StructureNotifyMask,
613 MaintainContentProc, contentPtr);
614 ckfree(contentPtr);
615 if (containerPtr->contentPtr == NULL) {
616 if (containerPtr->ancestor != NULL) {
617 for (ancestor = container; ; ancestor = Tk_Parent(ancestor)) {
620618 Tk_DeleteEventHandler(ancestor, StructureNotifyMask,
621 MaintainMasterProc, masterPtr);
622 if (ancestor == masterPtr->ancestor) {
619 MaintainContainerProc, containerPtr);
620 if (ancestor == containerPtr->ancestor) {
623621 break;
624622 }
625623 }
626624 }
627 if (masterPtr->checkScheduled) {
628 Tcl_CancelIdleCall(MaintainCheckProc, masterPtr);
625 if (containerPtr->checkScheduled) {
626 Tcl_CancelIdleCall(MaintainCheckProc, containerPtr);
629627 }
630628 Tcl_DeleteHashEntry(hPtr);
631 ckfree(masterPtr);
632 }
633 }
634
635 /*
636 *----------------------------------------------------------------------
637 *
638 * MaintainMasterProc --
629 ckfree(containerPtr);
630 }
631 }
632
633 /*
634 *----------------------------------------------------------------------
635 *
636 * MaintainContainerProc --
639637 *
640638 * This procedure is invoked by the Tk event dispatcher in response to
641 * StructureNotify events on the master or one of its ancestors, on
639 * StructureNotify events on the container or one of its ancestors, on
642640 * behalf of Tk_MaintainGeometry.
643641 *
644642 * Results:
647645 * Side effects:
648646 * It schedules a call to MaintainCheckProc, which will eventually caused
649647 * the postions and mapped states to be recalculated for all the
650 * maintained slaves of the master. Or, if the master window is being
648 * maintained windows of the container. Or, if the container window is being
651649 * deleted then state is cleaned up.
652650 *
653651 *----------------------------------------------------------------------
654652 */
655653
656654 static void
657 MaintainMasterProc(
658 ClientData clientData, /* Pointer to MaintainMaster structure for the
659 * master window. */
655 MaintainContainerProc(
656 ClientData clientData, /* Pointer to MaintainContainer structure for the
657 * container window. */
660658 XEvent *eventPtr) /* Describes what just happened. */
661659 {
662 MaintainMaster *masterPtr = clientData;
663 MaintainSlave *slavePtr;
660 MaintainContainer *containerPtr = (MaintainContainer *)clientData;
661 MaintainContent *contentPtr;
664662 int done;
665663
666664 if ((eventPtr->type == ConfigureNotify)
667665 || (eventPtr->type == MapNotify)
668666 || (eventPtr->type == UnmapNotify)) {
669 if (!masterPtr->checkScheduled) {
670 masterPtr->checkScheduled = 1;
671 Tcl_DoWhenIdle(MaintainCheckProc, masterPtr);
667 if (!containerPtr->checkScheduled) {
668 containerPtr->checkScheduled = 1;
669 Tcl_DoWhenIdle(MaintainCheckProc, containerPtr);
672670 }
673671 } else if (eventPtr->type == DestroyNotify) {
674672 /*
675 * Delete all of the state associated with this master, but be careful
676 * not to use masterPtr after the last slave is deleted, since its
673 * Delete all of the state associated with this container, but be careful
674 * not to use containerPtr after the last window is deleted, since its
677675 * memory will have been freed.
678676 */
679677
680678 done = 0;
681679 do {
682 slavePtr = masterPtr->slavePtr;
683 if (slavePtr->nextPtr == NULL) {
680 contentPtr = containerPtr->contentPtr;
681 if (contentPtr->nextPtr == NULL) {
684682 done = 1;
685683 }
686 Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
684 Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container);
687685 } while (!done);
688686 }
689687 }
691689 /*
692690 *----------------------------------------------------------------------
693691 *
694 * MaintainSlaveProc --
692 * MaintainContentProc --
695693 *
696694 * This procedure is invoked by the Tk event dispatcher in response to
697 * StructureNotify events on a slave being managed by
695 * StructureNotify events on a window being managed by
698696 * Tk_MaintainGeometry.
699697 *
700698 * Results:
702700 *
703701 * Side effects:
704702 * If the event is a DestroyNotify event then the Maintain state and
705 * event handlers for this slave are deleted.
703 * event handlers for this window are deleted.
706704 *
707705 *----------------------------------------------------------------------
708706 */
709707
710708 static void
711 MaintainSlaveProc(
712 ClientData clientData, /* Pointer to MaintainSlave structure for
713 * master-slave pair. */
709 MaintainContentProc(
710 ClientData clientData, /* Pointer to MaintainContent structure for
711 * container-window pair. */
714712 XEvent *eventPtr) /* Describes what just happened. */
715713 {
716 MaintainSlave *slavePtr = clientData;
714 MaintainContent *contentPtr = (MaintainContent *)clientData;
717715
718716 if (eventPtr->type == DestroyNotify) {
719 Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
717 Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container);
720718 }
721719 }
722720
726724 * MaintainCheckProc --
727725 *
728726 * This procedure is invoked by the Tk event dispatcher as an idle
729 * handler, when a master or one of its ancestors has been reconfigured,
730 * mapped, or unmapped. Its job is to scan all of the slaves for the
731 * master and reposition them, map them, or unmap them as needed to
732 * maintain their geometry relative to the master.
733 *
734 * Results:
735 * None.
736 *
737 * Side effects:
738 * Slaves can get repositioned, mapped, or unmapped.
727 * handler, when a container or one of its ancestors has been reconfigured,
728 * mapped, or unmapped. Its job is to scan all of the windows for the
729 * container and reposition them, map them, or unmap them as needed to
730 * maintain their geometry relative to the container.
731 *
732 * Results:
733 * None.
734 *
735 * Side effects:
736 * Windows can get repositioned, mapped, or unmapped.
739737 *
740738 *----------------------------------------------------------------------
741739 */
742740
743741 static void
744742 MaintainCheckProc(
745 ClientData clientData) /* Pointer to MaintainMaster structure for the
746 * master window. */
747 {
748 MaintainMaster *masterPtr = clientData;
749 MaintainSlave *slavePtr;
743 ClientData clientData) /* Pointer to MaintainContainer structure for the
744 * container window. */
745 {
746 MaintainContainer *containerPtr = (MaintainContainer *)clientData;
747 MaintainContent *contentPtr;
750748 Tk_Window ancestor, parent;
751749 int x, y, map;
752750
753 masterPtr->checkScheduled = 0;
754 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
755 slavePtr = slavePtr->nextPtr) {
756 parent = Tk_Parent(slavePtr->slave);
757 x = slavePtr->x;
758 y = slavePtr->y;
751 containerPtr->checkScheduled = 0;
752 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
753 contentPtr = contentPtr->nextPtr) {
754 parent = Tk_Parent(contentPtr->content);
755 x = contentPtr->x;
756 y = contentPtr->y;
759757 map = 1;
760 for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) {
758 for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) {
761759 if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
762760 map = 0;
763761 }
764762 if (ancestor == parent) {
765 if ((x != Tk_X(slavePtr->slave))
766 || (y != Tk_Y(slavePtr->slave))) {
767 Tk_MoveWindow(slavePtr->slave, x, y);
763 if ((x != Tk_X(contentPtr->content))
764 || (y != Tk_Y(contentPtr->content))) {
765 Tk_MoveWindow(contentPtr->content, x, y);
768766 }
769767 if (map) {
770 Tk_MapWindow(slavePtr->slave);
768 Tk_MapWindow(contentPtr->content);
771769 } else {
772 Tk_UnmapWindow(slavePtr->slave);
770 Tk_UnmapWindow(contentPtr->content);
773771 }
774772 break;
775773 }
492492
493493 static void
494494 FreeUidThreadExitProc(
495 ClientData clientData) /* Not used. */
496 {
497 ThreadSpecificData *tsdPtr =
498 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
495 TCL_UNUSED(void *))
496 {
497 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
498 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
499499
500500 Tcl_DeleteHashTable(&tsdPtr->uidTable);
501501 tsdPtr->initialized = 0;
528528 const char *string) /* String to convert. */
529529 {
530530 int dummy;
531 ThreadSpecificData *tsdPtr =
531 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
532532 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
533533 Tcl_HashTable *tablePtr = &tsdPtr->uidTable;
534534
693693 char *end;
694694 double d;
695695
696 if (!tkwin) {
697 Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad screen"));
698 Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL);
699 return TCL_ERROR;
700 }
696701 d = strtod((char *) string, &end);
697702 if (end == string) {
698703 goto error;
165165 *----------------------------------------------------------------------
166166 */
167167
168 /* ARGSUSED */
169168 int
170169 Tk_GrabObjCmd(
171170 ClientData clientData, /* Main window associated with interpreter. */
222221 Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
223222 return TCL_ERROR;
224223 }
225 tkwin = Tk_NameToWindow(interp, arg, clientData);
224 tkwin = Tk_NameToWindow(interp, arg, (Tk_Window)clientData);
226225 if (tkwin == NULL) {
227226 return TCL_ERROR;
228227 }
238237 Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
239238 return TCL_ERROR;
240239 }
241 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData);
240 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), (Tk_Window)clientData);
242241 if (tkwin == NULL) {
243242 return TCL_ERROR;
244243 }
264263 }
265264 if (objc == 3) {
266265 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
267 clientData);
266 (Tk_Window)clientData);
268267 if (tkwin == NULL) {
269268 return TCL_ERROR;
270269 }
293292 Tcl_WrongNumArgs(interp, 1, objv, "release window");
294293 return TCL_ERROR;
295294 }
296 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData);
295 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), (Tk_Window)clientData);
297296 if (tkwin == NULL) {
298297 Tcl_ResetResult(interp);
299298 } else {
310309 if (objc == 3) {
311310 globalGrab = 0;
312311 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
313 clientData);
312 (Tk_Window)clientData);
314313 } else {
315314 globalGrab = 1;
316315
326325 return TCL_ERROR;
327326 }
328327 tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[3]),
329 clientData);
328 (Tk_Window)clientData);
330329 }
331330 if (tkwin == NULL) {
332331 return TCL_ERROR;
343342 return TCL_ERROR;
344343 }
345344 winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
346 clientData);
345 (Tk_Window)clientData);
347346 if (winPtr == NULL) {
348347 return TCL_ERROR;
349348 }
637636
638637 static void
639638 ReleaseButtonGrab(
640 register TkDisplay *dispPtr)/* Display whose button grab is to be
639 TkDisplay *dispPtr)/* Display whose button grab is to be
641640 * released. */
642641 {
643642 unsigned int serial;
683682
684683 int
685684 TkPointerEvent(
686 register XEvent *eventPtr, /* Pointer to the event. */
685 XEvent *eventPtr, /* Pointer to the event. */
687686 TkWindow *winPtr) /* Tk's information for window where event was
688687 * reported. */
689688 {
690 register TkWindow *winPtr2;
689 TkWindow *winPtr2;
691690 TkDisplay *dispPtr = winPtr->dispPtr;
692691 unsigned int serial;
693692 int outsideGrabTree = 0;
871870 } else {
872871 if (eventPtr->xbutton.button != AnyButton &&
873872 ((eventPtr->xbutton.state & ALL_BUTTONS)
874 == (unsigned int)TkGetButtonMask(eventPtr->xbutton.button))) {
873 == TkGetButtonMask(eventPtr->xbutton.button))) {
875874 ReleaseButtonGrab(dispPtr); /* Note 4. */
876875 }
877876 }
906905
907906 void
908907 TkChangeEventWindow(
909 register XEvent *eventPtr, /* Event to retarget. Must have type
908 XEvent *eventPtr, /* Event to retarget. Must have type
910909 * ButtonPress, ButtonRelease, KeyPress,
911910 * KeyRelease, MotionNotify, EnterNotify, or
912911 * LeaveNotify. */
913912 TkWindow *winPtr) /* New target window for event. */
914913 {
915914 int x, y, sameScreen, bd;
916 register TkWindow *childPtr;
915 TkWindow *childPtr;
917916
918917 eventPtr->xmotion.window = Tk_WindowId(winPtr);
919918 if (eventPtr->xmotion.root ==
994993 Tcl_QueuePosition position) /* Position at which events are added to the
995994 * system event queue. */
996995 {
997 register TkWindow *winPtr;
996 TkWindow *winPtr;
998997 int upLevels, downLevels, i, j, focus;
999998
1000999 /*
11871186
11881187 void
11891188 TkGrabDeadWindow(
1190 register TkWindow *winPtr) /* Window that is in the process of being
1189 TkWindow *winPtr) /* Window that is in the process of being
11911190 * deleted. */
11921191 {
11931192 TkDisplay *dispPtr = winPtr->dispPtr;
12771276 ClientData arg,
12781277 XEvent *eventPtr)
12791278 {
1280 GrabInfo *info = arg;
1279 GrabInfo *info = (GrabInfo *)arg;
12811280 int mode, diff;
12821281
12831282 /*
13351334 {
13361335 NewGrabWinEvent *grabEvPtr;
13371336
1338 grabEvPtr = ckalloc(sizeof(NewGrabWinEvent));
1337 grabEvPtr = (NewGrabWinEvent *)ckalloc(sizeof(NewGrabWinEvent));
13391338 grabEvPtr->header.proc = GrabWinEventProc;
13401339 grabEvPtr->dispPtr = dispPtr;
13411340 if (grabWinPtr == NULL) {
13701369 static int
13711370 GrabWinEventProc(
13721371 Tcl_Event *evPtr, /* Event of type NewGrabWinEvent. */
1373 int flags) /* Flags argument to Tcl_DoOneEvent: indicates
1372 TCL_UNUSED(int)) /* Flags argument to Tcl_DoOneEvent: indicates
13741373 * what kinds of events are being processed
13751374 * right now. */
13761375 {
14151414 int *countPtr2) /* Store nesting level of winPtr2 within
14161415 * common ancestor here. */
14171416 {
1418 register TkWindow *winPtr;
1417 TkWindow *winPtr;
14191418 TkWindow *ancestorPtr;
14201419 int count1, count2, i;
14211420
6565 #define GRID_DEFAULT_ANCHOR TK_ANCHOR_NW
6666
6767 /*
68 * Structure to hold information for grid masters. A slot is either a row or
68 * Structure to hold information for grid containers. A slot is either a row or
6969 * column.
7070 */
7171
7979 * inproportion to their weights. */
8080 int pad; /* Extra padding, in pixels, required for this
8181 * slot. This amount is "added" to the largest
82 * slave in the slot. */
82 * content in the slot. */
8383 Tk_Uid uniform; /* Value of -uniform option. It is used to
8484 * group slots that should have the same
8585 * size. */
9898 */
9999
100100 typedef struct GridLayout {
101 struct Gridder *binNextPtr; /* The next slave window in this bin. Each bin
102 * contains a list of all slaves whose spans
101 struct Gridder *binNextPtr; /* The next content window in this bin. Each bin
102 * contains a list of all content whose spans
103103 * are >1 and whose right edges fall in this
104104 * slot. */
105105 int minSize; /* Minimum size needed for this slot, in
106106 * pixels. This is the space required to hold
107 * any slaves contained entirely in this slot,
107 * any content contained entirely in this slot,
108108 * adjusted for any slot constrants, such as
109109 * size or padding. */
110110 int pad; /* Padding needed for this slot */
123123 } GridLayout;
124124
125125 /*
126 * Keep one of these for each geometry master.
126 * Keep one of these for each geometry container.
127127 */
128128
129129 typedef struct {
130130 SlotInfo *columnPtr; /* Pointer to array of column constraints. */
131131 SlotInfo *rowPtr; /* Pointer to array of row constraints. */
132 int columnEnd; /* The last column occupied by any slave. */
132 int columnEnd; /* The last column occupied by any content. */
133133 int columnMax; /* The number of columns with constraints. */
134134 int columnSpace; /* The number of slots currently allocated for
135135 * column constraints. */
136 int rowEnd; /* The last row occupied by any slave. */
136 int rowEnd; /* The last row occupied by any content. */
137137 int rowMax; /* The number of rows with constraints. */
138138 int rowSpace; /* The number of slots currently allocated for
139139 * row constraints. */
140140 int startX; /* Pixel offset of this layout within its
141 * master. */
141 * container. */
142142 int startY; /* Pixel offset of this layout within its
143 * master. */
143 * container. */
144144 Tk_Anchor anchor; /* Value of anchor option: specifies where a
145145 * grid without weight should be placed. */
146 } GridMaster;
146 } GridContainer;
147147
148148 /*
149149 * For each window that the grid cares about (either because the window is
150 * managed by the grid or because the window has slaves that are managed by
150 * managed by the grid or because the window has content that are managed by
151151 * the grid), there is a structure of the following type:
152152 */
153153
156156 * window has been deleted, but the gridder
157157 * hasn't had a chance to clean up yet because
158158 * the structure is still in use. */
159 struct Gridder *masterPtr; /* Master window within which this window is
159 struct Gridder *containerPtr; /* Container window within which this window is
160160 * managed (NULL means this window isn't
161161 * managed by the gridder). */
162 struct Gridder *nextPtr; /* Next window managed within same master.
162 struct Gridder *nextPtr; /* Next window managed within same container.
163163 * List order doesn't matter. */
164 struct Gridder *slavePtr; /* First in list of slaves managed inside this
165 * window (NULL means no grid slaves). */
166 GridMaster *masterDataPtr; /* Additional data for geometry master. */
167 Tcl_Obj *in; /* Store master name when removed. */
164 struct Gridder *contentPtr; /* First in list of content managed inside this
165 * window (NULL means no grid content). */
166 GridContainer *containerDataPtr; /* Additional data for geometry container. */
167 Tcl_Obj *in; /* Store container name when removed. */
168168 int column, row; /* Location in the grid (starting from
169169 * zero). */
170 int numCols, numRows; /* Number of columns or rows this slave spans.
170 int numCols, numRows; /* Number of columns or rows this content spans.
171171 * Should be at least 1. */
172172 int padX, padY; /* Total additional pixels to leave around the
173173 * window. Some is of this space is on each
184184 * sticks to. See below for definitions */
185185 int doubleBw; /* Twice the window's last known border width.
186186 * If this changes, the window must be
187 * re-arranged within its master. */
187 * re-arranged within its container. */
188188 int *abortPtr; /* If non-NULL, it means that there is a
189189 * nested call to ArrangeGrid already working
190190 * on this window. *abortPtr may be set to 1
191191 * to abort that nested call. This happens,
192 * for example, if tkwin or any of its slaves
192 * for example, if tkwin or any of its content
193193 * is deleted. */
194194 int flags; /* Miscellaneous flags; see below for
195195 * definitions. */
198198 * These fields are used temporarily for layout calculations only.
199199 */
200200
201 struct Gridder *binNextPtr; /* Link to next span>1 slave in this bin. */
201 struct Gridder *binNextPtr; /* Link to next span>1 content in this bin. */
202202 int size; /* Nominal size (width or height) in pixels of
203 * the slave. This includes the padding. */
203 * the content. This includes the padding. */
204204 } Gridder;
205205
206206 /*
234234 * Flag values for Grid structures:
235235 *
236236 * REQUESTED_RELAYOUT 1 means a Tcl_DoWhenIdle request has already
237 * been made to re-arrange all the slaves of this
237 * been made to re-arrange all the content of this
238238 * window.
239239 * DONT_PROPAGATE 1 means don't set this window's requested
240 * size. 0 means if this window is a master then
240 * size. 0 means if this window is a container then
241241 * Tk will set its requested size to fit the
242 * needs of its slaves.
243 * ALLOCED_MASTER 1 means that Grid has allocated itself as
244 * geometry master for this window.
242 * needs of its content.
243 * ALLOCED_CONTAINER 1 means that Grid has allocated itself as
244 * geometry container for this window.
245245 */
246246
247247 #define REQUESTED_RELAYOUT 1
248248 #define DONT_PROPAGATE 2
249 #define ALLOCED_MASTER 4
249 #define ALLOCED_CONTAINER 4
250250
251251 /*
252252 * Prototypes for procedures used only in this file:
253253 */
254254
255 static void AdjustForSticky(Gridder *slavePtr, int *xPtr,
255 static void AdjustForSticky(Gridder *contentPtr, int *xPtr,
256256 int *yPtr, int *widthPtr, int *heightPtr);
257257 static int AdjustOffsets(int width, int elements,
258258 SlotInfo *slotPtr);
259259 static void ArrangeGrid(ClientData clientData);
260 static int CheckSlotData(Gridder *masterPtr, int slot,
260 static int CheckSlotData(Gridder *containerPtr, int slot,
261261 int slotType, int checkOnly);
262 static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin,
262 static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
263263 int objc, Tcl_Obj *const objv[]);
264264 static void DestroyGrid(void *memPtr);
265265 static Gridder * GetGrid(Tk_Window tkwin);
283283 Tcl_Obj *const objv[]);
284284 static int GridSizeCommand(Tk_Window tkwin, Tcl_Interp *interp,
285285 int objc, Tcl_Obj *const objv[]);
286 static int GridSlavesCommand(Tk_Window tkwin, Tcl_Interp *interp,
286 static int GridContentCommand(Tk_Window tkwin, Tcl_Interp *interp,
287287 int objc, Tcl_Obj *const objv[]);
288288 static void GridStructureProc(ClientData clientData,
289289 XEvent *eventPtr);
290 static void GridLostSlaveProc(ClientData clientData,
290 static void GridLostContentProc(ClientData clientData,
291291 Tk_Window tkwin);
292292 static void GridReqProc(ClientData clientData, Tk_Window tkwin);
293 static void InitMasterData(Gridder *masterPtr);
293 static void InitContainerData(Gridder *containerPtr);
294294 static Tcl_Obj * NewPairObj(int, int);
295295 static Tcl_Obj * NewQuadObj(int, int, int, int);
296296 static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn,
297297 int maxOffset);
298298 static void SetGridSize(Gridder *gridPtr);
299 static int SetSlaveColumn(Tcl_Interp *interp, Gridder *slavePtr,
299 static int SetContentColumn(Tcl_Interp *interp, Gridder *contentPtr,
300300 int column, int numCols);
301 static int SetSlaveRow(Tcl_Interp *interp, Gridder *slavePtr,
301 static int SetContentRow(Tcl_Interp *interp, Gridder *contentPtr,
302302 int row, int numRows);
303303 static Tcl_Obj * StickyToObj(int flags);
304304 static int StringToSticky(const char *string);
307307 static const Tk_GeomMgr gridMgrType = {
308308 "grid", /* name */
309309 GridReqProc, /* requestProc */
310 GridLostSlaveProc, /* lostSlaveProc */
310 GridLostContentProc, /* lostSlaveProc */
311311 };
312312
313313 /*
334334 int objc, /* Number of arguments. */
335335 Tcl_Obj *const objv[]) /* Argument objects. */
336336 {
337 Tk_Window tkwin = clientData;
337 Tk_Window tkwin = (Tk_Window)clientData;
338338 static const char *const optionStrings[] = {
339339 "anchor", "bbox", "columnconfigure", "configure",
340 "forget", "info", "location", "propagate", "remove",
341 "rowconfigure", "size", "slaves", NULL
340 "content", "forget", "info", "location", "propagate",
341 "remove", "rowconfigure", "size", "slaves", NULL
342342 };
343343 enum options {
344344 GRID_ANCHOR, GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE,
345 GRID_FORGET, GRID_INFO, GRID_LOCATION, GRID_PROPAGATE, GRID_REMOVE,
346 GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES
345 GRID_CONTENT, GRID_FORGET, GRID_INFO, GRID_LOCATION, GRID_PROPAGATE,
346 GRID_REMOVE, GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES
347347 };
348348 int index;
349349
352352
353353 if ((argv1[0] == '.') || (argv1[0] == REL_SKIP) ||
354354 (argv1[0] == REL_VERT)) {
355 return ConfigureSlaves(interp, tkwin, objc-1, objv+1);
355 return ConfigureContent(interp, tkwin, objc-1, objv+1);
356356 }
357357 }
358358 if (objc < 3) {
371371 case GRID_BBOX:
372372 return GridBboxCommand(tkwin, interp, objc, objv);
373373 case GRID_CONFIGURE:
374 return ConfigureSlaves(interp, tkwin, objc-2, objv+2);
374 return ConfigureContent(interp, tkwin, objc-2, objv+2);
375375 case GRID_FORGET:
376376 case GRID_REMOVE:
377377 return GridForgetRemoveCommand(tkwin, interp, objc, objv);
384384 case GRID_SIZE:
385385 return GridSizeCommand(tkwin, interp, objc, objv);
386386 case GRID_SLAVES:
387 return GridSlavesCommand(tkwin, interp, objc, objv);
387 case GRID_CONTENT:
388 return GridContentCommand(tkwin, interp, objc, objv);
388389
389390 /*
390391 * Sample argument combinations:
391 * grid columnconfigure <master> <index> -option
392 * grid columnconfigure <master> <index> -option value -option value
393 * grid rowconfigure <master> <index>
394 * grid rowconfigure <master> <index> -option
395 * grid rowconfigure <master> <index> -option value -option value.
392 * grid columnconfigure <container> <index> -option
393 * grid columnconfigure <container> <index> -option value -option value
394 * grid rowconfigure <container> <index>
395 * grid rowconfigure <container> <index> -option
396 * grid rowconfigure <container> <index> -option value -option value.
396397 */
397398
398399 case GRID_COLUMNCONFIGURE:
430431 int objc, /* Number of arguments. */
431432 Tcl_Obj *const objv[]) /* Argument objects. */
432433 {
433 Tk_Window master;
434 Gridder *masterPtr;
435 GridMaster *gridPtr;
434 Tk_Window container;
435 Gridder *containerPtr;
436 GridContainer *gridPtr;
436437 Tk_Anchor old;
437438
438439 if (objc > 4) {
440441 return TCL_ERROR;
441442 }
442443
443 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
444 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
444445 return TCL_ERROR;
445446 }
446 masterPtr = GetGrid(master);
447 containerPtr = GetGrid(container);
447448
448449 if (objc == 3) {
449 gridPtr = masterPtr->masterDataPtr;
450 gridPtr = containerPtr->containerDataPtr;
450451 Tcl_SetObjResult(interp, Tcl_NewStringObj(
451452 Tk_NameOfAnchor(gridPtr?gridPtr->anchor:GRID_DEFAULT_ANCHOR),
452453 -1));
453454 return TCL_OK;
454455 }
455456
456 InitMasterData(masterPtr);
457 gridPtr = masterPtr->masterDataPtr;
457 InitContainerData(containerPtr);
458 gridPtr = containerPtr->containerDataPtr;
458459 old = gridPtr->anchor;
459460 if (Tk_GetAnchorFromObj(interp, objv[3], &gridPtr->anchor) != TCL_OK) {
460461 return TCL_ERROR;
465466 */
466467
467468 if (old != gridPtr->anchor) {
468 if (masterPtr->abortPtr != NULL) {
469 *masterPtr->abortPtr = 1;
470 }
471 if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
472 masterPtr->flags |= REQUESTED_RELAYOUT;
473 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
469 if (containerPtr->abortPtr != NULL) {
470 *containerPtr->abortPtr = 1;
471 }
472 if (!(containerPtr->flags & REQUESTED_RELAYOUT)) {
473 containerPtr->flags |= REQUESTED_RELAYOUT;
474 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
474475 }
475476 }
476477 return TCL_OK;
499500 int objc, /* Number of arguments. */
500501 Tcl_Obj *const objv[]) /* Argument objects. */
501502 {
502 Tk_Window master;
503 Gridder *masterPtr; /* master grid record */
504 GridMaster *gridPtr; /* pointer to grid data */
503 Tk_Window container;
504 Gridder *containerPtr; /* container grid record */
505 GridContainer *gridPtr; /* pointer to grid data */
505506 int row, column; /* origin for bounding box */
506507 int row2, column2; /* end of bounding box */
507508 int endX, endY; /* last column/row in the layout */
513514 return TCL_ERROR;
514515 }
515516
516 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
517 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
517518 return TCL_ERROR;
518519 }
519 masterPtr = GetGrid(master);
520 containerPtr = GetGrid(container);
520521
521522 if (objc >= 5) {
522523 if (Tcl_GetIntFromObj(interp, objv[3], &column) != TCL_OK) {
538539 }
539540 }
540541
541 gridPtr = masterPtr->masterDataPtr;
542 gridPtr = containerPtr->containerDataPtr;
542543 if (gridPtr == NULL) {
543544 Tcl_SetObjResult(interp, NewQuadObj(0, 0, 0, 0));
544545 return TCL_OK;
545546 }
546547
547 SetGridSize(masterPtr);
548 SetGridSize(containerPtr);
548549 endX = MAX(gridPtr->columnEnd, gridPtr->columnMax);
549550 endY = MAX(gridPtr->rowEnd, gridPtr->rowMax);
550551
629630 int objc, /* Number of arguments. */
630631 Tcl_Obj *const objv[]) /* Argument objects. */
631632 {
632 Tk_Window slave;
633 Gridder *slavePtr;
633 Tk_Window content;
634 Gridder *contentPtr;
634635 int i;
635636 const char *string = Tcl_GetString(objv[1]);
636637 char c = string[0];
637638
638639 for (i = 2; i < objc; i++) {
639 if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) {
640 if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) {
640641 return TCL_ERROR;
641642 }
642643
643 slavePtr = GetGrid(slave);
644 if (slavePtr->masterPtr != NULL) {
644 contentPtr = GetGrid(content);
645 if (contentPtr->containerPtr != NULL) {
645646 /*
646647 * For "forget", reset all the settings to their defaults
647648 */
648649
649650 if (c == 'f') {
650 slavePtr->column = -1;
651 slavePtr->row = -1;
652 slavePtr->numCols = 1;
653 slavePtr->numRows = 1;
654 slavePtr->padX = 0;
655 slavePtr->padY = 0;
656 slavePtr->padLeft = 0;
657 slavePtr->padTop = 0;
658 slavePtr->iPadX = 0;
659 slavePtr->iPadY = 0;
660 if (slavePtr->in != NULL) {
661 Tcl_DecrRefCount(slavePtr->in);
662 slavePtr->in = NULL;
651 contentPtr->column = -1;
652 contentPtr->row = -1;
653 contentPtr->numCols = 1;
654 contentPtr->numRows = 1;
655 contentPtr->padX = 0;
656 contentPtr->padY = 0;
657 contentPtr->padLeft = 0;
658 contentPtr->padTop = 0;
659 contentPtr->iPadX = 0;
660 contentPtr->iPadY = 0;
661 if (contentPtr->in != NULL) {
662 Tcl_DecrRefCount(contentPtr->in);
663 contentPtr->in = NULL;
663664 }
664 slavePtr->doubleBw = 2*Tk_Changes(tkwin)->border_width;
665 if (slavePtr->flags & REQUESTED_RELAYOUT) {
666 Tcl_CancelIdleCall(ArrangeGrid, slavePtr);
665 contentPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width;
666 if (contentPtr->flags & REQUESTED_RELAYOUT) {
667 Tcl_CancelIdleCall(ArrangeGrid, contentPtr);
667668 }
668 slavePtr->flags = 0;
669 slavePtr->sticky = 0;
669 contentPtr->flags = 0;
670 contentPtr->sticky = 0;
670671 } else {
671672 /*
672 * When removing, store name of master to be able to
673 * restore it later, even if the master is recreated.
673 * When removing, store name of container to be able to
674 * restore it later, even if the container is recreated.
674675 */
675676
676 if (slavePtr->in != NULL) {
677 Tcl_DecrRefCount(slavePtr->in);
678 slavePtr->in = NULL;
677 if (contentPtr->in != NULL) {
678 Tcl_DecrRefCount(contentPtr->in);
679 contentPtr->in = NULL;
679680 }
680 if (slavePtr->masterPtr != NULL) {
681 slavePtr->in = Tcl_NewStringObj(
682 Tk_PathName(slavePtr->masterPtr->tkwin), -1);
683 Tcl_IncrRefCount(slavePtr->in);
681 if (contentPtr->containerPtr != NULL) {
682 contentPtr->in = Tcl_NewStringObj(
683 Tk_PathName(contentPtr->containerPtr->tkwin), -1);
684 Tcl_IncrRefCount(contentPtr->in);
684685 }
685686 }
686 Tk_ManageGeometry(slave, NULL, NULL);
687 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
688 Tk_UnmaintainGeometry(slavePtr->tkwin,
689 slavePtr->masterPtr->tkwin);
690 }
691 Unlink(slavePtr);
692 Tk_UnmapWindow(slavePtr->tkwin);
687 Tk_ManageGeometry(content, NULL, NULL);
688 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
689 Tk_UnmaintainGeometry(contentPtr->tkwin,
690 contentPtr->containerPtr->tkwin);
691 }
692 Unlink(contentPtr);
693 Tk_UnmapWindow(contentPtr->tkwin);
693694 }
694695 }
695696 return TCL_OK;
719720 int objc, /* Number of arguments. */
720721 Tcl_Obj *const objv[]) /* Argument objects. */
721722 {
722 register Gridder *slavePtr;
723 Tk_Window slave;
723 Gridder *contentPtr;
724 Tk_Window content;
724725 Tcl_Obj *infoObj;
725726
726727 if (objc != 3) {
727728 Tcl_WrongNumArgs(interp, 2, objv, "window");
728729 return TCL_ERROR;
729730 }
730 if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) {
731 if (TkGetWindowFromObj(interp, tkwin, objv[2], &content) != TCL_OK) {
731732 return TCL_ERROR;
732733 }
733 slavePtr = GetGrid(slave);
734 if (slavePtr->masterPtr == NULL) {
734 contentPtr = GetGrid(content);
735 if (contentPtr->containerPtr == NULL) {
735736 Tcl_ResetResult(interp);
736737 return TCL_OK;
737738 }
738739
739740 infoObj = Tcl_NewObj();
740741 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
741 TkNewWindowObj(slavePtr->masterPtr->tkwin));
742 TkNewWindowObj(contentPtr->containerPtr->tkwin));
742743 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1),
743 Tcl_NewIntObj(slavePtr->column));
744 Tcl_NewIntObj(contentPtr->column));
744745 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1),
745 Tcl_NewIntObj(slavePtr->row));
746 Tcl_NewIntObj(contentPtr->row));
746747 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1),
747 Tcl_NewIntObj(slavePtr->numCols));
748 Tcl_NewIntObj(contentPtr->numCols));
748749 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1),
749 Tcl_NewIntObj(slavePtr->numRows));
750 TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX);
751 TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY);
752 TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft, slavePtr->padX);
753 TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY);
750 Tcl_NewIntObj(contentPtr->numRows));
751 TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX);
752 TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY);
753 TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft, contentPtr->padX);
754 TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY);
754755 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-sticky", -1),
755 StickyToObj(slavePtr->sticky));
756 StickyToObj(contentPtr->sticky));
756757 Tcl_SetObjResult(interp, infoObj);
757758 return TCL_OK;
758759 }
781782 int objc, /* Number of arguments. */
782783 Tcl_Obj *const objv[]) /* Argument objects. */
783784 {
784 Tk_Window master;
785 Gridder *masterPtr; /* Master grid record. */
786 GridMaster *gridPtr; /* Pointer to grid data. */
787 register SlotInfo *slotPtr;
788 int x, y; /* Offset in pixels, from edge of master. */
785 Tk_Window container;
786 Gridder *containerPtr; /* Container grid record. */
787 GridContainer *gridPtr; /* Pointer to grid data. */
788 SlotInfo *slotPtr;
789 int x, y; /* Offset in pixels, from edge of container. */
789790 int i, j; /* Corresponding column and row indeces. */
790791 int endX, endY; /* End of grid. */
791792
794795 return TCL_ERROR;
795796 }
796797
797 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
798 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
798799 return TCL_ERROR;
799800 }
800801
801 if (Tk_GetPixelsFromObj(interp, master, objv[3], &x) != TCL_OK) {
802 if (Tk_GetPixelsFromObj(interp, container, objv[3], &x) != TCL_OK) {
802803 return TCL_ERROR;
803804 }
804 if (Tk_GetPixelsFromObj(interp, master, objv[4], &y) != TCL_OK) {
805 if (Tk_GetPixelsFromObj(interp, container, objv[4], &y) != TCL_OK) {
805806 return TCL_ERROR;
806807 }
807808
808 masterPtr = GetGrid(master);
809 if (masterPtr->masterDataPtr == NULL) {
809 containerPtr = GetGrid(container);
810 if (containerPtr->containerDataPtr == NULL) {
810811 Tcl_SetObjResult(interp, NewPairObj(-1, -1));
811812 return TCL_OK;
812813 }
813 gridPtr = masterPtr->masterDataPtr;
814 gridPtr = containerPtr->containerDataPtr;
814815
815816 /*
816817 * Update any pending requests. This is not always the steady state value,
818819 * its easy to get.
819820 */
820821
821 while (masterPtr->flags & REQUESTED_RELAYOUT) {
822 Tcl_CancelIdleCall(ArrangeGrid, masterPtr);
823 ArrangeGrid(masterPtr);
824 }
825 SetGridSize(masterPtr);
822 while (containerPtr->flags & REQUESTED_RELAYOUT) {
823 Tcl_CancelIdleCall(ArrangeGrid, containerPtr);
824 ArrangeGrid(containerPtr);
825 }
826 SetGridSize(containerPtr);
826827 endX = MAX(gridPtr->columnEnd, gridPtr->columnMax);
827828 endY = MAX(gridPtr->rowEnd, gridPtr->rowMax);
828829
829 slotPtr = masterPtr->masterDataPtr->columnPtr;
830 if (x < masterPtr->masterDataPtr->startX) {
830 slotPtr = containerPtr->containerDataPtr->columnPtr;
831 if (x < containerPtr->containerDataPtr->startX) {
831832 i = -1;
832833 } else {
833 x -= masterPtr->masterDataPtr->startX;
834 x -= containerPtr->containerDataPtr->startX;
834835 for (i = 0; slotPtr[i].offset < x && i < endX; i++) {
835836 /* null body */
836837 }
837838 }
838839
839 slotPtr = masterPtr->masterDataPtr->rowPtr;
840 if (y < masterPtr->masterDataPtr->startY) {
840 slotPtr = containerPtr->containerDataPtr->rowPtr;
841 if (y < containerPtr->containerDataPtr->startY) {
841842 j = -1;
842843 } else {
843 y -= masterPtr->masterDataPtr->startY;
844 y -= containerPtr->containerDataPtr->startY;
844845 for (j = 0; slotPtr[j].offset < y && j < endY; j++) {
845846 /* null body */
846847 }
874875 int objc, /* Number of arguments. */
875876 Tcl_Obj *const objv[]) /* Argument objects. */
876877 {
877 Tk_Window master;
878 Gridder *masterPtr;
878 Tk_Window container;
879 Gridder *containerPtr;
879880 int propagate, old;
880881
881882 if (objc > 4) {
883884 return TCL_ERROR;
884885 }
885886
886 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
887 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
887888 return TCL_ERROR;
888889 }
889 masterPtr = GetGrid(master);
890 containerPtr = GetGrid(container);
890891 if (objc == 3) {
891892 Tcl_SetObjResult(interp,
892 Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE)));
893 Tcl_NewBooleanObj(!(containerPtr->flags & DONT_PROPAGATE)));
893894 return TCL_OK;
894895 }
895896 if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) {
900901 * Only request a relayout if the propagation bit changes.
901902 */
902903
903 old = !(masterPtr->flags & DONT_PROPAGATE);
904 old = !(containerPtr->flags & DONT_PROPAGATE);
904905 if (propagate != old) {
905906 if (propagate) {
906907 /*
907 * If we have slaves, we need to register as geometry master.
908 * If we have content, we need to register as geometry container.
908909 */
909910
910 if (masterPtr->slavePtr != NULL) {
911 if (TkSetGeometryMaster(interp, master, "grid") != TCL_OK) {
911 if (containerPtr->contentPtr != NULL) {
912 if (TkSetGeometryContainer(interp, container, "grid") != TCL_OK) {
912913 return TCL_ERROR;
913914 }
914 masterPtr->flags |= ALLOCED_MASTER;
915 }
916 masterPtr->flags &= ~DONT_PROPAGATE;
915 containerPtr->flags |= ALLOCED_CONTAINER;
916 }
917 containerPtr->flags &= ~DONT_PROPAGATE;
917918 } else {
918 if (masterPtr->flags & ALLOCED_MASTER) {
919 TkFreeGeometryMaster(master, "grid");
920 masterPtr->flags &= ~ALLOCED_MASTER;
921 }
922 masterPtr->flags |= DONT_PROPAGATE;
919 if (containerPtr->flags & ALLOCED_CONTAINER) {
920 TkFreeGeometryContainer(container, "grid");
921 containerPtr->flags &= ~ALLOCED_CONTAINER;
922 }
923 containerPtr->flags |= DONT_PROPAGATE;
923924 }
924925
925926 /*
926 * Re-arrange the master to allow new geometry information to
927 * propagate upwards to the master's master.
927 * Re-arrange the container to allow new geometry information to
928 * propagate upwards to the container's container.
928929 */
929930
930 if (masterPtr->abortPtr != NULL) {
931 *masterPtr->abortPtr = 1;
932 }
933 if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
934 masterPtr->flags |= REQUESTED_RELAYOUT;
935 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
931 if (containerPtr->abortPtr != NULL) {
932 *containerPtr->abortPtr = 1;
933 }
934 if (!(containerPtr->flags & REQUESTED_RELAYOUT)) {
935 containerPtr->flags |= REQUESTED_RELAYOUT;
936 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
936937 }
937938 }
938939 return TCL_OK;
962963 int objc, /* Number of arguments. */
963964 Tcl_Obj *const objv[]) /* Argument objects. */
964965 {
965 Tk_Window master, slave;
966 Gridder *masterPtr, *slavePtr;
966 Tk_Window container, content;
967 Gridder *containerPtr, *contentPtr;
967968 SlotInfo *slotPtr = NULL;
968969 int slot; /* the column or row number */
969970 int slotType; /* COLUMN or ROW */
987988 return TCL_ERROR;
988989 }
989990
990 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
991 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
991992 return TCL_ERROR;
992993 }
993994
10081009 return TCL_ERROR;
10091010 }
10101011
1011 masterPtr = GetGrid(master);
1012 first = 0; /* lint */
1013 last = 0; /* lint */
1012 containerPtr = GetGrid(container);
1013 first = 0;
1014 last = 0;
10141015
10151016 if ((objc == 4) || (objc == 5)) {
10161017 if (lObjc != 1) {
10281029 Tcl_DecrRefCount(listCopy);
10291030 return TCL_ERROR;
10301031 }
1031 ok = CheckSlotData(masterPtr, slot, slotType, /* checkOnly */ 1);
1032 ok = CheckSlotData(containerPtr, slot, slotType, /* checkOnly */ 1);
10321033 if (ok == TCL_OK) {
10331034 slotPtr = (slotType == COLUMN) ?
1034 masterPtr->masterDataPtr->columnPtr :
1035 masterPtr->masterDataPtr->rowPtr;
1035 containerPtr->containerDataPtr->columnPtr :
1036 containerPtr->containerDataPtr->rowPtr;
10361037 }
10371038
10381039 /*
11001101 }
11011102
11021103 for (j = 0; j < lObjc; j++) {
1103 int allSlaves = 0;
1104 int allContent = 0;
11041105
11051106 if (Tcl_GetIntFromObj(NULL, lObjv[j], &slot) == TCL_OK) {
11061107 first = slot;
11071108 last = slot;
1108 slavePtr = NULL;
1109 contentPtr = NULL;
11091110 } else if (strcmp(Tcl_GetString(lObjv[j]), "all") == 0) {
11101111 /*
1111 * Make sure master is initialised.
1112 * Make sure container is initialised.
11121113 */
11131114
1114 InitMasterData(masterPtr);
1115
1116 slavePtr = masterPtr->slavePtr;
1117 if (slavePtr == NULL) {
1115 InitContainerData(containerPtr);
1116
1117 contentPtr = containerPtr->contentPtr;
1118 if (contentPtr == NULL) {
11181119 continue;
11191120 }
1120 allSlaves = 1;
1121 } else if (TkGetWindowFromObj(NULL, tkwin, lObjv[j], &slave)
1121 allContent = 1;
1122 } else if (TkGetWindowFromObj(NULL, tkwin, lObjv[j], &content)
11221123 == TCL_OK) {
11231124 /*
1124 * Is it gridded in this master?
1125 * Is it gridded in this container?
11251126 */
11261127
1127 slavePtr = GetGrid(slave);
1128 if (slavePtr->masterPtr != masterPtr) {
1128 contentPtr = GetGrid(content);
1129 if (contentPtr->containerPtr != containerPtr) {
11291130 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11301131 "the window \"%s\" is not managed by \"%s\"",
11311132 Tcl_GetString(lObjv[j]), Tcl_GetString(objv[2])));
11461147 */
11471148
11481149 do {
1149 if (slavePtr != NULL) {
1150 if (contentPtr != NULL) {
11501151 first = (slotType == COLUMN) ?
1151 slavePtr->column : slavePtr->row;
1152 contentPtr->column : contentPtr->row;
11521153 last = first - 1 + ((slotType == COLUMN) ?
1153 slavePtr->numCols : slavePtr->numRows);
1154 contentPtr->numCols : contentPtr->numRows);
11541155 }
11551156
11561157 for (slot = first; slot <= last; slot++) {
1157 ok = CheckSlotData(masterPtr, slot, slotType, /*checkOnly*/ 0);
1158 ok = CheckSlotData(containerPtr, slot, slotType, /*checkOnly*/ 0);
11581159 if (ok != TCL_OK) {
11591160 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11601161 "\"%s\" is out of range",
11651166 return TCL_ERROR;
11661167 }
11671168 slotPtr = (slotType == COLUMN) ?
1168 masterPtr->masterDataPtr->columnPtr :
1169 masterPtr->masterDataPtr->rowPtr;
1169 containerPtr->containerDataPtr->columnPtr :
1170 containerPtr->containerDataPtr->rowPtr;
11701171
11711172 /*
11721173 * Loop through each option value pair, setting the values as
11801181 return TCL_ERROR;
11811182 }
11821183 if (index == ROWCOL_MINSIZE) {
1183 if (Tk_GetPixelsFromObj(interp, master, objv[i+1],
1184 if (Tk_GetPixelsFromObj(interp, container, objv[i+1],
11841185 &size) != TCL_OK) {
11851186 Tcl_DecrRefCount(listCopy);
11861187 return TCL_ERROR;
12071208 slotPtr[slot].uniform = NULL;
12081209 }
12091210 } else if (index == ROWCOL_PAD) {
1210 if (Tk_GetPixelsFromObj(interp, master, objv[i+1],
1211 if (Tk_GetPixelsFromObj(interp, container, objv[i+1],
12111212 &size) != TCL_OK) {
12121213 Tcl_DecrRefCount(listCopy);
12131214 return TCL_ERROR;
12201221 }
12211222 }
12221223 }
1223 if (slavePtr != NULL) {
1224 slavePtr = slavePtr->nextPtr;
1225 }
1226 } while ((allSlaves == 1) && (slavePtr != NULL));
1224 if (contentPtr != NULL) {
1225 contentPtr = contentPtr->nextPtr;
1226 }
1227 } while ((allContent == 1) && (contentPtr != NULL));
12271228 }
12281229 Tcl_DecrRefCount(listCopy);
12291230
12341235
12351236 if (slotPtr != NULL) {
12361237 if (slotType == ROW) {
1237 int last = masterPtr->masterDataPtr->rowMax - 1;
1238 last = containerPtr->containerDataPtr->rowMax - 1;
12381239
12391240 while ((last >= 0) && (slotPtr[last].weight == 0)
12401241 && (slotPtr[last].pad == 0) && (slotPtr[last].minSize == 0)
12411242 && (slotPtr[last].uniform == NULL)) {
12421243 last--;
12431244 }
1244 masterPtr->masterDataPtr->rowMax = last+1;
1245 containerPtr->containerDataPtr->rowMax = last+1;
12451246 } else {
1246 int last = masterPtr->masterDataPtr->columnMax - 1;
1247 last = containerPtr->containerDataPtr->columnMax - 1;
12471248
12481249 while ((last >= 0) && (slotPtr[last].weight == 0)
12491250 && (slotPtr[last].pad == 0) && (slotPtr[last].minSize == 0)
12501251 && (slotPtr[last].uniform == NULL)) {
12511252 last--;
12521253 }
1253 masterPtr->masterDataPtr->columnMax = last + 1;
1254 }
1255 }
1256
1257 if (masterPtr->abortPtr != NULL) {
1258 *masterPtr->abortPtr = 1;
1259 }
1260 if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
1261 masterPtr->flags |= REQUESTED_RELAYOUT;
1262 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
1254 containerPtr->containerDataPtr->columnMax = last + 1;
1255 }
1256 }
1257
1258 if (containerPtr->abortPtr != NULL) {
1259 *containerPtr->abortPtr = 1;
1260 }
1261 if (!(containerPtr->flags & REQUESTED_RELAYOUT)) {
1262 containerPtr->flags |= REQUESTED_RELAYOUT;
1263 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
12631264 }
12641265 return TCL_OK;
12651266
12951296 int objc, /* Number of arguments. */
12961297 Tcl_Obj *const objv[]) /* Argument objects. */
12971298 {
1298 Tk_Window master;
1299 Gridder *masterPtr;
1300 GridMaster *gridPtr; /* pointer to grid data */
1299 Tk_Window container;
1300 Gridder *containerPtr;
1301 GridContainer *gridPtr; /* pointer to grid data */
13011302
13021303 if (objc != 3) {
13031304 Tcl_WrongNumArgs(interp, 2, objv, "window");
13041305 return TCL_ERROR;
13051306 }
13061307
1307 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
1308 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
13081309 return TCL_ERROR;
13091310 }
1310 masterPtr = GetGrid(master);
1311
1312 if (masterPtr->masterDataPtr != NULL) {
1313 SetGridSize(masterPtr);
1314 gridPtr = masterPtr->masterDataPtr;
1311 containerPtr = GetGrid(container);
1312
1313 if (containerPtr->containerDataPtr != NULL) {
1314 SetGridSize(containerPtr);
1315 gridPtr = containerPtr->containerDataPtr;
13151316 Tcl_SetObjResult(interp, NewPairObj(
13161317 MAX(gridPtr->columnEnd, gridPtr->columnMax),
13171318 MAX(gridPtr->rowEnd, gridPtr->rowMax)));
13241325 /*
13251326 *----------------------------------------------------------------------
13261327 *
1327 * GridSlavesCommand --
1328 *
1329 * Implementation of the [grid slaves] subcommand. See the user
1328 * GridContentCommand --
1329 *
1330 * Implementation of the [grid content] subcommand. See the user
13301331 * documentation for details on what it does.
13311332 *
13321333 * Results:
13331334 * Standard Tcl result.
13341335 *
13351336 * Side effects:
1336 * Places a list of slaves of the specified window in the interpreter's
1337 * result field.
1337 * Places a list of content windows of the specified window in the
1338 * interpreter's result field.
13381339 *
13391340 *----------------------------------------------------------------------
13401341 */
13411342
13421343 static int
1343 GridSlavesCommand(
1344 GridContentCommand(
13441345 Tk_Window tkwin, /* Main window of the application. */
13451346 Tcl_Interp *interp, /* Current interpreter. */
13461347 int objc, /* Number of arguments. */
13471348 Tcl_Obj *const objv[]) /* Argument objects. */
13481349 {
1349 Tk_Window master;
1350 Gridder *masterPtr; /* master grid record */
1351 Gridder *slavePtr;
1350 Tk_Window container;
1351 Gridder *containerPtr; /* container grid record */
1352 Gridder *contentPtr;
13521353 int i, value, index;
13531354 int row = -1, column = -1;
13541355 static const char *const optionStrings[] = {
13551356 "-column", "-row", NULL
13561357 };
1357 enum options { SLAVES_COLUMN, SLAVES_ROW };
1358 enum options { CONTENT_COLUMN, CONTENT_ROW };
13581359 Tcl_Obj *res;
13591360
13601361 if ((objc < 3) || ((objc % 2) == 0)) {
13761377 Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL);
13771378 return TCL_ERROR;
13781379 }
1379 if (index == SLAVES_COLUMN) {
1380 if (index == CONTENT_COLUMN) {
13801381 column = value;
13811382 } else {
13821383 row = value;
13831384 }
13841385 }
13851386
1386 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
1387 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
13871388 return TCL_ERROR;
13881389 }
1389 masterPtr = GetGrid(master);
1390 containerPtr = GetGrid(container);
13901391
13911392 res = Tcl_NewListObj(0, NULL);
1392 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
1393 slavePtr = slavePtr->nextPtr) {
1394 if ((column >= 0) && (slavePtr->column > column
1395 || slavePtr->column+slavePtr->numCols-1 < column)) {
1393 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
1394 contentPtr = contentPtr->nextPtr) {
1395 if ((column >= 0) && (contentPtr->column > column
1396 || contentPtr->column+contentPtr->numCols-1 < column)) {
13961397 continue;
13971398 }
1398 if ((row >= 0) && (slavePtr->row > row ||
1399 slavePtr->row+slavePtr->numRows-1 < row)) {
1399 if ((row >= 0) && (contentPtr->row > row ||
1400 contentPtr->row+contentPtr->numRows-1 < row)) {
14001401 continue;
14011402 }
1402 Tcl_ListObjAppendElement(interp,res, TkNewWindowObj(slavePtr->tkwin));
1403 Tcl_ListObjAppendElement(interp,res, TkNewWindowObj(contentPtr->tkwin));
14031404 }
14041405 Tcl_SetObjResult(interp, res);
14051406 return TCL_OK;
14271428 GridReqProc(
14281429 ClientData clientData, /* Grid's information about window that got
14291430 * new preferred geometry. */
1430 Tk_Window tkwin) /* Other Tk-related information about the
1431 TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
14311432 * window. */
14321433 {
1433 register Gridder *gridPtr = clientData;
1434
1435 gridPtr = gridPtr->masterPtr;
1434 Gridder *gridPtr = (Gridder *)clientData;
1435
1436 gridPtr = gridPtr->containerPtr;
14361437 if (gridPtr && !(gridPtr->flags & REQUESTED_RELAYOUT)) {
14371438 gridPtr->flags |= REQUESTED_RELAYOUT;
14381439 Tcl_DoWhenIdle(ArrangeGrid, gridPtr);
14421443 /*
14431444 *----------------------------------------------------------------------
14441445 *
1445 * GridLostSlaveProc --
1446 * GridLostContentProc --
14461447 *
14471448 * This procedure is invoked by Tk whenever some other geometry claims
1448 * control over a slave that used to be managed by us.
1449 * control over a content that used to be managed by us.
14491450 *
14501451 * Results:
14511452 * None.
14521453 *
14531454 * Side effects:
1454 * Forgets all grid-related information about the slave.
1455 * Forgets all grid-related information about the content.
14551456 *
14561457 *----------------------------------------------------------------------
14571458 */
14581459
14591460 static void
1460 GridLostSlaveProc(
1461 ClientData clientData, /* Grid structure for slave window that was
1461 GridLostContentProc(
1462 ClientData clientData, /* Grid structure for content window that was
14621463 * stolen away. */
1463 Tk_Window tkwin) /* Tk's handle for the slave window. */
1464 TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */
14641465 {
1465 register Gridder *slavePtr = clientData;
1466
1467 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
1468 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
1469 }
1470 Unlink(slavePtr);
1471 Tk_UnmapWindow(slavePtr->tkwin);
1466 Gridder *contentPtr = (Gridder *)clientData;
1467
1468 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
1469 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
1470 }
1471 Unlink(contentPtr);
1472 Tk_UnmapWindow(contentPtr->tkwin);
14721473 }
14731474
14741475 /*
14951496 AdjustOffsets(
14961497 int size, /* The total layout size (in pixels). */
14971498 int slots, /* Number of slots. */
1498 register SlotInfo *slotPtr) /* Pointer to slot array. */
1499 SlotInfo *slotPtr) /* Pointer to slot array. */
14991500 {
1500 register int slot; /* Current slot. */
1501 int slot; /* Current slot. */
15011502 int diff; /* Extra pixels needed to add to the layout. */
15021503 int totalWeight; /* Sum of the weights for all the slots. */
15031504 int weight; /* Sum of the weights so far. */
16421643 *
16431644 * AdjustForSticky --
16441645 *
1645 * This procedure adjusts the size of a slave in its cavity based on its
1646 * This procedure adjusts the size of a content in its cavity based on its
16461647 * "sticky" flags.
16471648 *
16481649 * Results:
16491650 * The input x, y, width, and height are changed to represent the desired
1650 * coordinates of the slave.
1651 * coordinates of the content.
16511652 *
16521653 * Side effects:
16531654 * None.
16571658
16581659 static void
16591660 AdjustForSticky(
1660 Gridder *slavePtr, /* Slave window to arrange in its cavity. */
1661 Gridder *contentPtr, /* Content window to arrange in its cavity. */
16611662 int *xPtr, /* Pixel location of the left edge of the cavity. */
16621663 int *yPtr, /* Pixel location of the top edge of the cavity. */
16631664 int *widthPtr, /* Width of the cavity (in pixels). */
16641665 int *heightPtr) /* Height of the cavity (in pixels). */
16651666 {
1666 int diffx = 0; /* Cavity width - slave width. */
1667 int diffy = 0; /* Cavity hight - slave height. */
1668 int sticky = slavePtr->sticky;
1669
1670 *xPtr += slavePtr->padLeft;
1671 *widthPtr -= slavePtr->padX;
1672 *yPtr += slavePtr->padTop;
1673 *heightPtr -= slavePtr->padY;
1674
1675 if (*widthPtr > (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX)) {
1676 diffx = *widthPtr - (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX);
1677 *widthPtr = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX;
1678 }
1679
1680 if (*heightPtr > (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY)) {
1681 diffy = *heightPtr - (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY);
1682 *heightPtr = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY;
1667 int diffx = 0; /* Cavity width - content width. */
1668 int diffy = 0; /* Cavity hight - content height. */
1669 int sticky = contentPtr->sticky;
1670
1671 *xPtr += contentPtr->padLeft;
1672 *widthPtr -= contentPtr->padX;
1673 *yPtr += contentPtr->padTop;
1674 *heightPtr -= contentPtr->padY;
1675
1676 if (*widthPtr > (Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX)) {
1677 diffx = *widthPtr - (Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX);
1678 *widthPtr = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX;
1679 }
1680
1681 if (*heightPtr > (Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY)) {
1682 diffy = *heightPtr - (Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY);
1683 *heightPtr = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY;
16831684 }
16841685
16851686 if (sticky&STICK_EAST && sticky&STICK_WEST) {
17101711 * None.
17111712 *
17121713 * Side effects:
1713 * The slaves of masterPtr may get resized or moved.
1714 * The content of containerPtr may get resized or moved.
17141715 *
17151716 *----------------------------------------------------------------------
17161717 */
17171718
17181719 static void
17191720 ArrangeGrid(
1720 ClientData clientData) /* Structure describing master whose slaves
1721 ClientData clientData) /* Structure describing container whose content
17211722 * are to be re-layed out. */
17221723 {
1723 register Gridder *masterPtr = clientData;
1724 register Gridder *slavePtr;
1725 GridMaster *slotPtr = masterPtr->masterDataPtr;
1724 Gridder *containerPtr = (Gridder *)clientData;
1725 Gridder *contentPtr;
1726 GridContainer *slotPtr = containerPtr->containerDataPtr;
17261727 int abort;
17271728 int width, height; /* Requested size of layout, in pixels. */
17281729 int realWidth, realHeight; /* Actual size layout should take-up. */
17291730 int usedX, usedY;
17301731
1731 masterPtr->flags &= ~REQUESTED_RELAYOUT;
1732
1733 /*
1734 * If the master has no slaves anymore, then don't do anything at all:
1735 * just leave the master's size as-is. Otherwise there is no way to
1736 * "relinquish" control over the master so another geometry manager can
1737 * take over.
1738 */
1739
1740 if (masterPtr->slavePtr == NULL) {
1732 containerPtr->flags &= ~REQUESTED_RELAYOUT;
1733
1734 /*
1735 * If the container has no content anymore, then don't change the container size.
1736 * Otherwise there is no way to "relinquish" control over the container
1737 * so another geometry manager can take over.
1738 */
1739
1740 if (containerPtr->contentPtr == NULL) {
17411741 return;
17421742 }
17431743
1744 if (masterPtr->masterDataPtr == NULL) {
1744 if (containerPtr->containerDataPtr == NULL) {
17451745 return;
17461746 }
17471747
17511751 * necessary.
17521752 */
17531753
1754 if (masterPtr->abortPtr != NULL) {
1755 *masterPtr->abortPtr = 1;
1756 }
1757 masterPtr->abortPtr = &abort;
1754 if (containerPtr->abortPtr != NULL) {
1755 *containerPtr->abortPtr = 1;
1756 }
1757 containerPtr->abortPtr = &abort;
17581758 abort = 0;
1759 Tcl_Preserve(masterPtr);
1759 Tcl_Preserve(containerPtr);
17601760
17611761 /*
17621762 * Call the constraint engine to fill in the row and column offsets.
17631763 */
17641764
1765 SetGridSize(masterPtr);
1766 width = ResolveConstraints(masterPtr, COLUMN, 0);
1767 height = ResolveConstraints(masterPtr, ROW, 0);
1768 width += Tk_InternalBorderLeft(masterPtr->tkwin) +
1769 Tk_InternalBorderRight(masterPtr->tkwin);
1770 height += Tk_InternalBorderTop(masterPtr->tkwin) +
1771 Tk_InternalBorderBottom(masterPtr->tkwin);
1772
1773 if (width < Tk_MinReqWidth(masterPtr->tkwin)) {
1774 width = Tk_MinReqWidth(masterPtr->tkwin);
1775 }
1776 if (height < Tk_MinReqHeight(masterPtr->tkwin)) {
1777 height = Tk_MinReqHeight(masterPtr->tkwin);
1778 }
1779
1780 if (((width != Tk_ReqWidth(masterPtr->tkwin))
1781 || (height != Tk_ReqHeight(masterPtr->tkwin)))
1782 && !(masterPtr->flags & DONT_PROPAGATE)) {
1783 Tk_GeometryRequest(masterPtr->tkwin, width, height);
1765 SetGridSize(containerPtr);
1766 width = ResolveConstraints(containerPtr, COLUMN, 0);
1767 height = ResolveConstraints(containerPtr, ROW, 0);
1768 width += Tk_InternalBorderLeft(containerPtr->tkwin) +
1769 Tk_InternalBorderRight(containerPtr->tkwin);
1770 height += Tk_InternalBorderTop(containerPtr->tkwin) +
1771 Tk_InternalBorderBottom(containerPtr->tkwin);
1772
1773 if (width < Tk_MinReqWidth(containerPtr->tkwin)) {
1774 width = Tk_MinReqWidth(containerPtr->tkwin);
1775 }
1776 if (height < Tk_MinReqHeight(containerPtr->tkwin)) {
1777 height = Tk_MinReqHeight(containerPtr->tkwin);
1778 }
1779
1780 if (((width != Tk_ReqWidth(containerPtr->tkwin))
1781 || (height != Tk_ReqHeight(containerPtr->tkwin)))
1782 && !(containerPtr->flags & DONT_PROPAGATE)) {
1783 Tk_GeometryRequest(containerPtr->tkwin, width, height);
17841784 if (width>1 && height>1) {
1785 masterPtr->flags |= REQUESTED_RELAYOUT;
1786 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
1787 }
1788 masterPtr->abortPtr = NULL;
1789 Tcl_Release(masterPtr);
1785 containerPtr->flags |= REQUESTED_RELAYOUT;
1786 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
1787 }
1788 containerPtr->abortPtr = NULL;
1789 Tcl_Release(containerPtr);
17901790 return;
17911791 }
17921792
17931793 /*
1794 * If the currently requested layout size doesn't match the master's
1794 * If the currently requested layout size doesn't match the container's
17951795 * window size, then adjust the slot offsets according to the weights. If
17961796 * all of the weights are zero, place the layout according to the anchor
17971797 * value.
17981798 */
17991799
1800 realWidth = Tk_Width(masterPtr->tkwin) -
1801 Tk_InternalBorderLeft(masterPtr->tkwin) -
1802 Tk_InternalBorderRight(masterPtr->tkwin);
1803 realHeight = Tk_Height(masterPtr->tkwin) -
1804 Tk_InternalBorderTop(masterPtr->tkwin) -
1805 Tk_InternalBorderBottom(masterPtr->tkwin);
1800 realWidth = Tk_Width(containerPtr->tkwin) -
1801 Tk_InternalBorderLeft(containerPtr->tkwin) -
1802 Tk_InternalBorderRight(containerPtr->tkwin);
1803 realHeight = Tk_Height(containerPtr->tkwin) -
1804 Tk_InternalBorderTop(containerPtr->tkwin) -
1805 Tk_InternalBorderBottom(containerPtr->tkwin);
18061806 usedX = AdjustOffsets(realWidth,
18071807 MAX(slotPtr->columnEnd, slotPtr->columnMax), slotPtr->columnPtr);
18081808 usedY = AdjustOffsets(realHeight, MAX(slotPtr->rowEnd, slotPtr->rowMax),
18091809 slotPtr->rowPtr);
1810 TkComputeAnchor(masterPtr->masterDataPtr->anchor, masterPtr->tkwin,
1810 TkComputeAnchor(containerPtr->containerDataPtr->anchor, containerPtr->tkwin,
18111811 0, 0, usedX, usedY, &slotPtr->startX, &slotPtr->startY);
18121812
18131813 /*
1814 * Now adjust the actual size of the slave to its cavity by computing the
1814 * Now adjust the actual size of the content to its cavity by computing the
18151815 * cavity size, and adjusting the widget according to its stickyness.
18161816 */
18171817
1818 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL && !abort;
1819 slavePtr = slavePtr->nextPtr) {
1818 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL && !abort;
1819 contentPtr = contentPtr->nextPtr) {
18201820 int x, y; /* Top left coordinate */
1821 int width, height; /* Slot or slave size */
1822 int col = slavePtr->column;
1823 int row = slavePtr->row;
1821 int col = contentPtr->column;
1822 int row = contentPtr->row;
18241823
18251824 x = (col>0) ? slotPtr->columnPtr[col-1].offset : 0;
18261825 y = (row>0) ? slotPtr->rowPtr[row-1].offset : 0;
18271826
1828 width = slotPtr->columnPtr[slavePtr->numCols+col-1].offset - x;
1829 height = slotPtr->rowPtr[slavePtr->numRows+row-1].offset - y;
1827 width = slotPtr->columnPtr[contentPtr->numCols+col-1].offset - x;
1828 height = slotPtr->rowPtr[contentPtr->numRows+row-1].offset - y;
18301829
18311830 x += slotPtr->startX;
18321831 y += slotPtr->startY;
18331832
1834 AdjustForSticky(slavePtr, &x, &y, &width, &height);
1833 AdjustForSticky(contentPtr, &x, &y, &width, &height);
18351834
18361835 /*
18371836 * Now put the window in the proper spot. (This was taken directly
1838 * from tkPack.c.) If the slave is a child of the master, then do this
1837 * from tkPack.c.) If the content is a child of the container, then do this
18391838 * here. Otherwise let Tk_MaintainGeometry do the work.
18401839 */
18411840
1842 if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
1841 if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) {
18431842 if ((width <= 0) || (height <= 0)) {
1844 Tk_UnmapWindow(slavePtr->tkwin);
1843 Tk_UnmapWindow(contentPtr->tkwin);
18451844 } else {
1846 if ((x != Tk_X(slavePtr->tkwin))
1847 || (y != Tk_Y(slavePtr->tkwin))
1848 || (width != Tk_Width(slavePtr->tkwin))
1849 || (height != Tk_Height(slavePtr->tkwin))) {
1850 Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
1845 if ((x != Tk_X(contentPtr->tkwin))
1846 || (y != Tk_Y(contentPtr->tkwin))
1847 || (width != Tk_Width(contentPtr->tkwin))
1848 || (height != Tk_Height(contentPtr->tkwin))) {
1849 Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height);
18511850 }
18521851 if (abort) {
18531852 break;
18541853 }
18551854
18561855 /*
1857 * Don't map the slave if the master isn't mapped: wait until
1858 * the master gets mapped later.
1856 * Don't map the content if the container isn't mapped: wait until
1857 * the container gets mapped later.
18591858 */
18601859
1861 if (Tk_IsMapped(masterPtr->tkwin)) {
1862 Tk_MapWindow(slavePtr->tkwin);
1860 if (Tk_IsMapped(containerPtr->tkwin)) {
1861 Tk_MapWindow(contentPtr->tkwin);
18631862 }
18641863 }
18651864 } else if ((width <= 0) || (height <= 0)) {
1866 Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
1867 Tk_UnmapWindow(slavePtr->tkwin);
1865 Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin);
1866 Tk_UnmapWindow(contentPtr->tkwin);
18681867 } else {
1869 Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin, x, y,
1868 Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin, x, y,
18701869 width, height);
18711870 }
18721871 }
18731872
1874 masterPtr->abortPtr = NULL;
1875 Tcl_Release(masterPtr);
1873 containerPtr->abortPtr = NULL;
1874 Tcl_Release(containerPtr);
18761875 }
18771876
18781877 /*
18901889 *
18911890 * Side effects:
18921891 * The slot offsets are copied into the SlotInfo structure for the
1893 * geometry master.
1892 * geometry container.
18941893 *
18951894 *----------------------------------------------------------------------
18961895 */
18971896
18981897 static int
18991898 ResolveConstraints(
1900 Gridder *masterPtr, /* The geometry master for this grid. */
1899 Gridder *containerPtr, /* The geometry container for this grid. */
19011900 int slotType, /* Either ROW or COLUMN. */
19021901 int maxOffset) /* The actual maximum size of this layout in
19031902 * pixels, or 0 (not currently used). */
19041903 {
1905 register SlotInfo *slotPtr; /* Pointer to row/col constraints. */
1906 register Gridder *slavePtr; /* List of slave windows in this grid. */
1904 SlotInfo *slotPtr; /* Pointer to row/col constraints. */
1905 Gridder *contentPtr; /* List of content windows in this grid. */
19071906 int constraintCount; /* Count of rows or columns that have
19081907 * constraints. */
19091908 int slotCount; /* Last occupied row or column. */
19121911 GridLayout *layoutPtr; /* Temporary layout structure. */
19131912 int requiredSize; /* The natural size of the grid (pixels).
19141913 * This is the minimum size needed to
1915 * accommodate all of the slaves at their
1914 * accommodate all of the content at their
19161915 * requested sizes. */
19171916 int offset; /* The pixel offset of the right edge of the
19181917 * current slot from the beginning of the
19291928 int uniformGroups; /* Number of currently used uniform groups. */
19301929 int uniformGroupsAlloced; /* Size of allocated space for uniform
19311930 * groups. */
1932 int weight, minSize;
1931 int minSize;
19331932 int prevGrow, accWeight, grow;
19341933
19351934 /*
19401939 GridLayout layoutData[TYPICAL_SIZE + 1];
19411940
19421941 if (slotType == COLUMN) {
1943 constraintCount = masterPtr->masterDataPtr->columnMax;
1944 slotCount = masterPtr->masterDataPtr->columnEnd;
1945 slotPtr = masterPtr->masterDataPtr->columnPtr;
1942 constraintCount = containerPtr->containerDataPtr->columnMax;
1943 slotCount = containerPtr->containerDataPtr->columnEnd;
1944 slotPtr = containerPtr->containerDataPtr->columnPtr;
19461945 } else {
1947 constraintCount = masterPtr->masterDataPtr->rowMax;
1948 slotCount = masterPtr->masterDataPtr->rowEnd;
1949 slotPtr = masterPtr->masterDataPtr->rowPtr;
1946 constraintCount = containerPtr->containerDataPtr->rowMax;
1947 slotCount = containerPtr->containerDataPtr->rowEnd;
1948 slotPtr = containerPtr->containerDataPtr->rowPtr;
19501949 }
19511950
19521951 /*
19551954
19561955 gridCount = MAX(constraintCount, slotCount);
19571956 if (gridCount >= TYPICAL_SIZE) {
1958 layoutPtr = ckalloc(sizeof(GridLayout) * (1+gridCount));
1957 layoutPtr = (GridLayout *)ckalloc(sizeof(GridLayout) * (1+gridCount));
19591958 } else {
19601959 layoutPtr = layoutData;
19611960 }
19961995
19971996 /*
19981997 * Step 2.
1999 * Slaves with a span of 1 are used to determine the minimum size of each
2000 * slot. Slaves whose span is two or more slots don't contribute to the
1998 * Content with a span of 1 are used to determine the minimum size of each
1999 * slot. Content whose span is two or more slots don't contribute to the
20012000 * minimum size of each slot directly, but can cause slots to grow if
20022001 * their size exceeds the the sizes of the slots they span.
20032002 *
2004 * Bin all slaves whose spans are > 1 by their right edges. This allows
2003 * Bin all content whose spans are > 1 by their right edges. This allows
20052004 * the computation on minimum and maximum possible layout sizes at each
2006 * slot boundary, without the need to re-sort the slaves.
2005 * slot boundary, without the need to re-sort the content.
20072006 */
20082007
20092008 switch (slotType) {
20102009 case COLUMN:
2011 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
2012 slavePtr = slavePtr->nextPtr) {
2013 int rightEdge = slavePtr->column + slavePtr->numCols - 1;
2014
2015 slavePtr->size = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->padX
2016 + slavePtr->iPadX + slavePtr->doubleBw;
2017 if (slavePtr->numCols > 1) {
2018 slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
2019 layoutPtr[rightEdge].binNextPtr = slavePtr;
2010 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
2011 contentPtr = contentPtr->nextPtr) {
2012 int rightEdge = contentPtr->column + contentPtr->numCols - 1;
2013
2014 contentPtr->size = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->padX
2015 + contentPtr->iPadX + contentPtr->doubleBw;
2016 if (contentPtr->numCols > 1) {
2017 contentPtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
2018 layoutPtr[rightEdge].binNextPtr = contentPtr;
20202019 } else if (rightEdge >= 0) {
2021 int size = slavePtr->size + layoutPtr[rightEdge].pad;
2020 int size = contentPtr->size + layoutPtr[rightEdge].pad;
20222021
20232022 if (size > layoutPtr[rightEdge].minSize) {
20242023 layoutPtr[rightEdge].minSize = size;
20272026 }
20282027 break;
20292028 case ROW:
2030 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
2031 slavePtr = slavePtr->nextPtr) {
2032 int rightEdge = slavePtr->row + slavePtr->numRows - 1;
2033
2034 slavePtr->size = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->padY
2035 + slavePtr->iPadY + slavePtr->doubleBw;
2036 if (slavePtr->numRows > 1) {
2037 slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
2038 layoutPtr[rightEdge].binNextPtr = slavePtr;
2029 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
2030 contentPtr = contentPtr->nextPtr) {
2031 int rightEdge = contentPtr->row + contentPtr->numRows - 1;
2032
2033 contentPtr->size = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->padY
2034 + contentPtr->iPadY + contentPtr->doubleBw;
2035 if (contentPtr->numRows > 1) {
2036 contentPtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
2037 layoutPtr[rightEdge].binNextPtr = contentPtr;
20392038 } else if (rightEdge >= 0) {
2040 int size = slavePtr->size + layoutPtr[rightEdge].pad;
2039 int size = contentPtr->size + layoutPtr[rightEdge].pad;
20412040
20422041 if (size > layoutPtr[rightEdge].minSize) {
20432042 layoutPtr[rightEdge].minSize = size;
20582057
20592058 for (slot = 0; slot < gridCount; slot++) {
20602059 if (layoutPtr[slot].uniform != NULL) {
2060 int weight;
20612061 for (start = 0; start < uniformGroups; start++) {
20622062 if (uniformGroupPtr[start].group == layoutPtr[slot].uniform) {
20632063 break;
20772077 * sizeof(UniformGroup);
20782078 size_t newSize = (uniformGroupsAlloced + UNIFORM_PREALLOC)
20792079 * sizeof(UniformGroup);
2080 UniformGroup *newUG = ckalloc(newSize);
2080 UniformGroup *newUG = (UniformGroup *)ckalloc(newSize);
20812081 UniformGroup *oldUG = uniformGroupPtr;
20822082
20832083 memcpy(newUG, oldUG, oldSize);
21102110 for (start = 0; start < uniformGroups; start++) {
21112111 if (uniformGroupPtr[start].group ==
21122112 layoutPtr[slot].uniform) {
2113 weight = layoutPtr[slot].weight;
2113 int weight = layoutPtr[slot].weight;
21142114 weight = weight > 0 ? weight : 1;
21152115 layoutPtr[slot].minSize =
21162116 uniformGroupPtr[start].minSize * weight;
21282128 /*
21292129 * Step 3.
21302130 * Determine the minimum slot offsets going from left to right that would
2131 * fit all of the slaves. This determines the minimum
2131 * fit all of the content. This determines the minimum
21322132 */
21332133
21342134 for (offset=0,slot=0; slot < gridCount; slot++) {
21352135 layoutPtr[slot].minOffset = layoutPtr[slot].minSize + offset;
2136 for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL;
2137 slavePtr = slavePtr->binNextPtr) {
2136 for (contentPtr = layoutPtr[slot].binNextPtr; contentPtr != NULL;
2137 contentPtr = contentPtr->binNextPtr) {
21382138 int span = (slotType == COLUMN) ?
2139 slavePtr->numCols : slavePtr->numRows;
2140 int required = slavePtr->size + layoutPtr[slot - span].minOffset;
2139 contentPtr->numCols : contentPtr->numRows;
2140 int required = contentPtr->size + layoutPtr[slot - span].minOffset;
21412141
21422142 if (required > layoutPtr[slot].minOffset) {
21432143 layoutPtr[slot].minOffset = required;
21482148
21492149 /*
21502150 * At this point, we know the minimum required size of the entire layout.
2151 * It might be prudent to stop here if our "master" will resize itself to
2151 * It might be prudent to stop here if our "container" will resize itself to
21522152 * this size.
21532153 */
21542154
21692169 layoutPtr[slot].maxOffset = offset;
21702170 }
21712171 for (slot=gridCount-1; slot > 0;) {
2172 for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL;
2173 slavePtr = slavePtr->binNextPtr) {
2172 for (contentPtr = layoutPtr[slot].binNextPtr; contentPtr != NULL;
2173 contentPtr = contentPtr->binNextPtr) {
21742174 int span = (slotType == COLUMN) ?
2175 slavePtr->numCols : slavePtr->numRows;
2176 int require = offset - slavePtr->size;
2175 contentPtr->numCols : contentPtr->numRows;
2176 int require = offset - contentPtr->size;
21772177 int startSlot = slot - span;
21782178
21792179 if (startSlot >=0 && require < layoutPtr[startSlot].maxOffset) {
23832383 /*
23842384 * Step 6.
23852385 * All of the space has been apportioned; copy the layout information back
2386 * into the master.
2386 * into the container.
23872387 */
23882388
23892389 for (slot=0; slot < gridCount; slot++) {
24212421 Tk_Window tkwin) /* Token for window for which grid structure
24222422 * is desired. */
24232423 {
2424 register Gridder *gridPtr;
2424 Gridder *gridPtr;
24252425 Tcl_HashEntry *hPtr;
24262426 int isNew;
24272427 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
24382438
24392439 hPtr = Tcl_CreateHashEntry(&dispPtr->gridHashTable, (char*) tkwin, &isNew);
24402440 if (!isNew) {
2441 return Tcl_GetHashValue(hPtr);
2442 }
2443 gridPtr = ckalloc(sizeof(Gridder));
2441 return (Gridder *)Tcl_GetHashValue(hPtr);
2442 }
2443 gridPtr = (Gridder *)ckalloc(sizeof(Gridder));
24442444 gridPtr->tkwin = tkwin;
2445 gridPtr->masterPtr = NULL;
2446 gridPtr->masterDataPtr = NULL;
2445 gridPtr->containerPtr = NULL;
2446 gridPtr->containerDataPtr = NULL;
24472447 gridPtr->nextPtr = NULL;
2448 gridPtr->slavePtr = NULL;
2448 gridPtr->contentPtr = NULL;
24492449 gridPtr->binNextPtr = NULL;
24502450
24512451 gridPtr->column = -1;
24652465 gridPtr->sticky = 0;
24662466 gridPtr->size = 0;
24672467 gridPtr->in = NULL;
2468 gridPtr->masterDataPtr = NULL;
2468 gridPtr->containerDataPtr = NULL;
24692469 Tcl_SetHashValue(hPtr, gridPtr);
24702470 Tk_CreateEventHandler(tkwin, StructureNotifyMask,
24712471 GridStructureProc, gridPtr);
24772477 *
24782478 * SetGridSize --
24792479 *
2480 * This internal procedure sets the size of the grid occupied by slaves.
2480 * This internal procedure sets the size of the grid occupied by content.
24812481 *
24822482 * Results:
24832483 * None
24842484 *
24852485 * Side effects:
2486 * The width and height arguments are filled in the master data
2486 * The width and height arguments are filled in the container data
24872487 * structure. Additional space is allocated for the constraints to
24882488 * accommodate the offsets.
24892489 *
24922492
24932493 static void
24942494 SetGridSize(
2495 Gridder *masterPtr) /* The geometry master for this grid. */
2495 Gridder *containerPtr) /* The geometry container for this grid. */
24962496 {
2497 register Gridder *slavePtr; /* Current slave window. */
2497 Gridder *contentPtr; /* Current content window. */
24982498 int maxX = 0, maxY = 0;
24992499
2500 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
2501 slavePtr = slavePtr->nextPtr) {
2502 maxX = MAX(maxX, slavePtr->numCols + slavePtr->column);
2503 maxY = MAX(maxY, slavePtr->numRows + slavePtr->row);
2504 }
2505 masterPtr->masterDataPtr->columnEnd = maxX;
2506 masterPtr->masterDataPtr->rowEnd = maxY;
2507 CheckSlotData(masterPtr, maxX, COLUMN, CHECK_SPACE);
2508 CheckSlotData(masterPtr, maxY, ROW, CHECK_SPACE);
2500 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
2501 contentPtr = contentPtr->nextPtr) {
2502 maxX = MAX(maxX, contentPtr->numCols + contentPtr->column);
2503 maxY = MAX(maxY, contentPtr->numRows + contentPtr->row);
2504 }
2505 containerPtr->containerDataPtr->columnEnd = maxX;
2506 containerPtr->containerDataPtr->rowEnd = maxY;
2507 CheckSlotData(containerPtr, maxX, COLUMN, CHECK_SPACE);
2508 CheckSlotData(containerPtr, maxY, ROW, CHECK_SPACE);
25092509 }
25102510
25112511 /*
25122512 *----------------------------------------------------------------------
25132513 *
2514 * SetSlaveColumn --
2515 *
2516 * Update column data for a slave, checking that MAX_ELEMENT bound
2514 * SetContentColumn --
2515 *
2516 * Update column data for a content, checking that MAX_ELEMENT bound
25172517 * is not passed.
25182518 *
25192519 * Results:
25202520 * TCL_ERROR if out of bounds, TCL_OK otherwise
25212521 *
25222522 * Side effects:
2523 * Slave fields are updated.
2523 * Content fields are updated.
25242524 *
25252525 *----------------------------------------------------------------------
25262526 */
25272527
25282528 static int
2529 SetSlaveColumn(
2529 SetContentColumn(
25302530 Tcl_Interp *interp, /* Interp for error message. */
2531 Gridder *slavePtr, /* Slave to be updated. */
2531 Gridder *contentPtr, /* Content to be updated. */
25322532 int column, /* New column or -1 to be unchanged. */
25332533 int numCols) /* New columnspan or -1 to be unchanged. */
25342534 {
25352535 int newColumn, newNumCols, lastCol;
25362536
2537 newColumn = (column >= 0) ? column : slavePtr->column;
2538 newNumCols = (numCols >= 1) ? numCols : slavePtr->numCols;
2537 newColumn = (column >= 0) ? column : contentPtr->column;
2538 newNumCols = (numCols >= 1) ? numCols : contentPtr->numCols;
25392539
25402540 lastCol = ((newColumn >= 0) ? newColumn : 0) + newNumCols;
25412541 if (lastCol >= MAX_ELEMENT) {
25442544 return TCL_ERROR;
25452545 }
25462546
2547 slavePtr->column = newColumn;
2548 slavePtr->numCols = newNumCols;
2547 contentPtr->column = newColumn;
2548 contentPtr->numCols = newNumCols;
25492549 return TCL_OK;
25502550 }
25512551
25522552 /*
25532553 *----------------------------------------------------------------------
25542554 *
2555 * SetSlaveRow --
2556 *
2557 * Update row data for a slave, checking that MAX_ELEMENT bound
2555 * SetContentRow --
2556 *
2557 * Update row data for a content, checking that MAX_ELEMENT bound
25582558 * is not passed.
25592559 *
25602560 * Results:
25612561 * TCL_ERROR if out of bounds, TCL_OK otherwise
25622562 *
25632563 * Side effects:
2564 * Slave fields are updated.
2564 * Content fields are updated.
25652565 *
25662566 *----------------------------------------------------------------------
25672567 */
25682568
25692569 static int
2570 SetSlaveRow(
2570 SetContentRow(
25712571 Tcl_Interp *interp, /* Interp for error message. */
2572 Gridder *slavePtr, /* Slave to be updated. */
2572 Gridder *contentPtr, /* Content to be updated. */
25732573 int row, /* New row or -1 to be unchanged. */
25742574 int numRows) /* New rowspan or -1 to be unchanged. */
25752575 {
25762576 int newRow, newNumRows, lastRow;
25772577
2578 newRow = (row >= 0) ? row : slavePtr->row;
2579 newNumRows = (numRows >= 1) ? numRows : slavePtr->numRows;
2578 newRow = (row >= 0) ? row : contentPtr->row;
2579 newNumRows = (numRows >= 1) ? numRows : contentPtr->numRows;
25802580
25812581 lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows;
25822582 if (lastRow >= MAX_ELEMENT) {
25852585 return TCL_ERROR;
25862586 }
25872587
2588 slavePtr->row = newRow;
2589 slavePtr->numRows = newNumRows;
2588 contentPtr->row = newRow;
2589 contentPtr->numRows = newNumRows;
25902590 return TCL_OK;
25912591 }
25922592
26022602 * TRUE if the index is OK, False otherwise.
26032603 *
26042604 * Side effects:
2605 * A new master grid structure may be created. If so, then it is
2605 * A new container grid structure may be created. If so, then it is
26062606 * initialized. In addition, additional storage for a row or column
26072607 * constraints may be allocated, and the constraint maximums are
26082608 * adjusted.
26122612
26132613 static int
26142614 CheckSlotData(
2615 Gridder *masterPtr, /* The geometry master for this grid. */
2615 Gridder *containerPtr, /* The geometry container for this grid. */
26162616 int slot, /* Which slot to look at. */
26172617 int slotType, /* ROW or COLUMN. */
26182618 int checkOnly) /* Don't allocate new space if true. */
26282628 return TCL_ERROR;
26292629 }
26302630
2631 if ((checkOnly == CHECK_ONLY) && (masterPtr->masterDataPtr == NULL)) {
2631 if ((checkOnly == CHECK_ONLY) && (containerPtr->containerDataPtr == NULL)) {
26322632 return TCL_ERROR;
26332633 }
26342634
26382638 * of the offsets as well.
26392639 */
26402640
2641 InitMasterData(masterPtr);
2642 end = (slotType == ROW) ? masterPtr->masterDataPtr->rowMax :
2643 masterPtr->masterDataPtr->columnMax;
2641 InitContainerData(containerPtr);
2642 end = (slotType == ROW) ? containerPtr->containerDataPtr->rowMax :
2643 containerPtr->containerDataPtr->columnMax;
26442644 if (checkOnly == CHECK_ONLY) {
26452645 return ((end < slot) ? TCL_ERROR : TCL_OK);
26462646 } else {
2647 numSlot = (slotType == ROW) ? masterPtr->masterDataPtr->rowSpace
2648 : masterPtr->masterDataPtr->columnSpace;
2647 numSlot = (slotType == ROW) ? containerPtr->containerDataPtr->rowSpace
2648 : containerPtr->containerDataPtr->columnSpace;
26492649 if (slot >= numSlot) {
26502650 int newNumSlot = slot + PREALLOC;
26512651 size_t oldSize = numSlot * sizeof(SlotInfo);
26522652 size_t newSize = newNumSlot * sizeof(SlotInfo);
2653 SlotInfo *newSI = ckalloc(newSize);
2653 SlotInfo *newSI = (SlotInfo *)ckalloc(newSize);
26542654 SlotInfo *oldSI = (slotType == ROW)
2655 ? masterPtr->masterDataPtr->rowPtr
2656 : masterPtr->masterDataPtr->columnPtr;
2655 ? containerPtr->containerDataPtr->rowPtr
2656 : containerPtr->containerDataPtr->columnPtr;
26572657
26582658 memcpy(newSI, oldSI, oldSize);
26592659 memset(newSI+numSlot, 0, newSize - oldSize);
26602660 ckfree(oldSI);
26612661 if (slotType == ROW) {
2662 masterPtr->masterDataPtr->rowPtr = newSI;
2663 masterPtr->masterDataPtr->rowSpace = newNumSlot;
2662 containerPtr->containerDataPtr->rowPtr = newSI;
2663 containerPtr->containerDataPtr->rowSpace = newNumSlot;
26642664 } else {
2665 masterPtr->masterDataPtr->columnPtr = newSI;
2666 masterPtr->masterDataPtr->columnSpace = newNumSlot;
2665 containerPtr->containerDataPtr->columnPtr = newSI;
2666 containerPtr->containerDataPtr->columnSpace = newNumSlot;
26672667 }
26682668 }
26692669 if (slot >= end && checkOnly != CHECK_SPACE) {
26702670 if (slotType == ROW) {
2671 masterPtr->masterDataPtr->rowMax = slot+1;
2671 containerPtr->containerDataPtr->rowMax = slot+1;
26722672 } else {
2673 masterPtr->masterDataPtr->columnMax = slot+1;
2673 containerPtr->containerDataPtr->columnMax = slot+1;
26742674 }
26752675 }
26762676 return TCL_OK;
26802680 /*
26812681 *----------------------------------------------------------------------
26822682 *
2683 * InitMasterData --
2683 * InitContainerData --
26842684 *
26852685 * This internal procedure is used to allocate and initialize the data
2686 * for a geometry master, if the data doesn't exist already.
2686 * for a geometry container, if the data doesn't exist already.
26872687 *
26882688 * Results:
26892689 * none
26902690 *
26912691 * Side effects:
2692 * A new master grid structure may be created. If so, then it is
2692 * A new container grid structure may be created. If so, then it is
26932693 * initialized.
26942694 *
26952695 *----------------------------------------------------------------------
26962696 */
26972697
26982698 static void
2699 InitMasterData(
2700 Gridder *masterPtr)
2699 InitContainerData(
2700 Gridder *containerPtr)
27012701 {
2702 if (masterPtr->masterDataPtr == NULL) {
2703 GridMaster *gridPtr = masterPtr->masterDataPtr =
2704 ckalloc(sizeof(GridMaster));
2702 if (containerPtr->containerDataPtr == NULL) {
2703 GridContainer *gridPtr = containerPtr->containerDataPtr = (GridContainer *)
2704 ckalloc(sizeof(GridContainer));
27052705 size_t size = sizeof(SlotInfo) * TYPICAL_SIZE;
27062706
27072707 gridPtr->columnEnd = 0;
27082708 gridPtr->columnMax = 0;
2709 gridPtr->columnPtr = ckalloc(size);
2709 gridPtr->columnPtr = (SlotInfo *)ckalloc(size);
27102710 gridPtr->columnSpace = TYPICAL_SIZE;
27112711 gridPtr->rowEnd = 0;
27122712 gridPtr->rowMax = 0;
2713 gridPtr->rowPtr = ckalloc(size);
2713 gridPtr->rowPtr = (SlotInfo *)ckalloc(size);
27142714 gridPtr->rowSpace = TYPICAL_SIZE;
27152715 gridPtr->startX = 0;
27162716 gridPtr->startY = 0;
27262726 *
27272727 * Unlink --
27282728 *
2729 * Remove a grid from its master's list of slaves.
2729 * Remove a grid from its container's list of content.
27302730 *
27312731 * Results:
27322732 * None.
27332733 *
27342734 * Side effects:
2735 * The master will be scheduled for re-arranging, and the size of the
2735 * The container will be scheduled for re-arranging, and the size of the
27362736 * grid will be adjusted accordingly
27372737 *
27382738 *----------------------------------------------------------------------
27402740
27412741 static void
27422742 Unlink(
2743 register Gridder *slavePtr) /* Window to unlink. */
2743 Gridder *contentPtr) /* Window to unlink. */
27442744 {
2745 register Gridder *masterPtr, *slavePtr2;
2746
2747 masterPtr = slavePtr->masterPtr;
2748 if (masterPtr == NULL) {
2745 Gridder *containerPtr, *contentPtr2;
2746
2747 containerPtr = contentPtr->containerPtr;
2748 if (containerPtr == NULL) {
27492749 return;
27502750 }
27512751
2752 if (masterPtr->slavePtr == slavePtr) {
2753 masterPtr->slavePtr = slavePtr->nextPtr;
2752 if (containerPtr->contentPtr == contentPtr) {
2753 containerPtr->contentPtr = contentPtr->nextPtr;
27542754 } else {
2755 for (slavePtr2=masterPtr->slavePtr ; ; slavePtr2=slavePtr2->nextPtr) {
2756 if (slavePtr2 == NULL) {
2755 for (contentPtr2=containerPtr->contentPtr ; ; contentPtr2=contentPtr2->nextPtr) {
2756 if (contentPtr2 == NULL) {
27572757 Tcl_Panic("Unlink couldn't find previous window");
27582758 }
2759 if (slavePtr2->nextPtr == slavePtr) {
2760 slavePtr2->nextPtr = slavePtr->nextPtr;
2759 if (contentPtr2->nextPtr == contentPtr) {
2760 contentPtr2->nextPtr = contentPtr->nextPtr;
27612761 break;
27622762 }
27632763 }
27642764 }
2765 if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
2766 masterPtr->flags |= REQUESTED_RELAYOUT;
2767 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
2768 }
2769 if (masterPtr->abortPtr != NULL) {
2770 *masterPtr->abortPtr = 1;
2771 }
2772
2773 SetGridSize(slavePtr->masterPtr);
2774 slavePtr->masterPtr = NULL;
2775
2776 /*
2777 * If we have emptied this master from slaves it means we are no longer
2765 if (!(containerPtr->flags & REQUESTED_RELAYOUT)) {
2766 containerPtr->flags |= REQUESTED_RELAYOUT;
2767 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
2768 }
2769 if (containerPtr->abortPtr != NULL) {
2770 *containerPtr->abortPtr = 1;
2771 }
2772
2773 SetGridSize(contentPtr->containerPtr);
2774 contentPtr->containerPtr = NULL;
2775
2776 /*
2777 * If we have emptied this container from content it means we are no longer
27782778 * handling it and should mark it as free.
27792779 */
27802780
2781 if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
2782 TkFreeGeometryMaster(masterPtr->tkwin, "grid");
2783 masterPtr->flags &= ~ALLOCED_MASTER;
2781 if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) {
2782 TkFreeGeometryContainer(containerPtr->tkwin, "grid");
2783 containerPtr->flags &= ~ALLOCED_CONTAINER;
27842784 }
27852785 }
27862786
27922792 * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release to
27932793 * clean up the internal structure of a grid at a safe time (when no-one
27942794 * is using it anymore). Cleaning up the grid involves freeing the main
2795 * structure for all windows and the master structure for geometry
2795 * structure for all windows and the container structure for geometry
27962796 * managers.
27972797 *
27982798 * Results:
28082808 DestroyGrid(
28092809 void *memPtr) /* Info about window that is now dead. */
28102810 {
2811 register Gridder *gridPtr = memPtr;
2812
2813 if (gridPtr->masterDataPtr != NULL) {
2814 if (gridPtr->masterDataPtr->rowPtr != NULL) {
2815 ckfree(gridPtr->masterDataPtr -> rowPtr);
2816 }
2817 if (gridPtr->masterDataPtr->columnPtr != NULL) {
2818 ckfree(gridPtr->masterDataPtr -> columnPtr);
2819 }
2820 ckfree(gridPtr->masterDataPtr);
2811 Gridder *gridPtr = (Gridder *)memPtr;
2812
2813 if (gridPtr->containerDataPtr != NULL) {
2814 if (gridPtr->containerDataPtr->rowPtr != NULL) {
2815 ckfree(gridPtr->containerDataPtr -> rowPtr);
2816 }
2817 if (gridPtr->containerDataPtr->columnPtr != NULL) {
2818 ckfree(gridPtr->containerDataPtr -> columnPtr);
2819 }
2820 ckfree(gridPtr->containerDataPtr);
28212821 }
28222822 if (gridPtr->in != NULL) {
28232823 Tcl_DecrRefCount(gridPtr->in);
28382838 *
28392839 * Side effects:
28402840 * If a window was just deleted, clean up all its grid-related
2841 * information. If it was just resized, re-configure its slaves, if any.
2841 * information. If it was just resized, re-configure its content, if any.
28422842 *
28432843 *----------------------------------------------------------------------
28442844 */
28492849 * eventPtr. */
28502850 XEvent *eventPtr) /* Describes what just happened. */
28512851 {
2852 register Gridder *gridPtr = clientData;
2852 Gridder *gridPtr = (Gridder *)clientData;
28532853 TkDisplay *dispPtr = ((TkWindow *) gridPtr->tkwin)->dispPtr;
28542854
28552855 if (eventPtr->type == ConfigureNotify) {
2856 if ((gridPtr->slavePtr != NULL)
2856 if ((gridPtr->contentPtr != NULL)
28572857 && !(gridPtr->flags & REQUESTED_RELAYOUT)) {
28582858 gridPtr->flags |= REQUESTED_RELAYOUT;
28592859 Tcl_DoWhenIdle(ArrangeGrid, gridPtr);
28602860 }
2861 if ((gridPtr->masterPtr != NULL) &&
2861 if ((gridPtr->containerPtr != NULL) &&
28622862 (gridPtr->doubleBw != 2*Tk_Changes(gridPtr->tkwin)->border_width)) {
2863 if (!(gridPtr->masterPtr->flags & REQUESTED_RELAYOUT)) {
2863 if (!(gridPtr->containerPtr->flags & REQUESTED_RELAYOUT)) {
28642864 gridPtr->doubleBw = 2*Tk_Changes(gridPtr->tkwin)->border_width;
2865 gridPtr->masterPtr->flags |= REQUESTED_RELAYOUT;
2866 Tcl_DoWhenIdle(ArrangeGrid, gridPtr->masterPtr);
2865 gridPtr->containerPtr->flags |= REQUESTED_RELAYOUT;
2866 Tcl_DoWhenIdle(ArrangeGrid, gridPtr->containerPtr);
28672867 }
28682868 }
28692869 } else if (eventPtr->type == DestroyNotify) {
2870 register Gridder *slavePtr, *nextPtr;
2871
2872 if (gridPtr->masterPtr != NULL) {
2870 Gridder *contentPtr, *nextPtr;
2871
2872 if (gridPtr->containerPtr != NULL) {
28732873 Unlink(gridPtr);
28742874 }
2875 for (slavePtr = gridPtr->slavePtr; slavePtr != NULL;
2876 slavePtr = nextPtr) {
2877 Tk_ManageGeometry(slavePtr->tkwin, NULL, NULL);
2878 Tk_UnmapWindow(slavePtr->tkwin);
2879 slavePtr->masterPtr = NULL;
2880 nextPtr = slavePtr->nextPtr;
2881 slavePtr->nextPtr = NULL;
2875 for (contentPtr = gridPtr->contentPtr; contentPtr != NULL;
2876 contentPtr = nextPtr) {
2877 Tk_ManageGeometry(contentPtr->tkwin, NULL, NULL);
2878 Tk_UnmapWindow(contentPtr->tkwin);
2879 contentPtr->containerPtr = NULL;
2880 nextPtr = contentPtr->nextPtr;
2881 contentPtr->nextPtr = NULL;
28822882 }
28832883 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->gridHashTable,
2884 (char *) gridPtr->tkwin));
2884 (char *)gridPtr->tkwin));
28852885 if (gridPtr->flags & REQUESTED_RELAYOUT) {
28862886 Tcl_CancelIdleCall(ArrangeGrid, gridPtr);
28872887 }
28882888 gridPtr->tkwin = NULL;
28892889 Tcl_EventuallyFree(gridPtr, (Tcl_FreeProc *)DestroyGrid);
28902890 } else if (eventPtr->type == MapNotify) {
2891 if ((gridPtr->slavePtr != NULL)
2891 if ((gridPtr->contentPtr != NULL)
28922892 && !(gridPtr->flags & REQUESTED_RELAYOUT)) {
28932893 gridPtr->flags |= REQUESTED_RELAYOUT;
28942894 Tcl_DoWhenIdle(ArrangeGrid, gridPtr);
28952895 }
28962896 } else if (eventPtr->type == UnmapNotify) {
2897 register Gridder *slavePtr;
2898
2899 for (slavePtr = gridPtr->slavePtr; slavePtr != NULL;
2900 slavePtr = slavePtr->nextPtr) {
2901 Tk_UnmapWindow(slavePtr->tkwin);
2897 Gridder *contentPtr;
2898
2899 for (contentPtr = gridPtr->contentPtr; contentPtr != NULL;
2900 contentPtr = contentPtr->nextPtr) {
2901 Tk_UnmapWindow(contentPtr->tkwin);
29022902 }
29032903 }
29042904 }
29062906 /*
29072907 *----------------------------------------------------------------------
29082908 *
2909 * ConfigureSlaves --
2909 * ConfigureContent --
29102910 *
29112911 * This implements the guts of the "grid configure" command. Given a list
2912 * of slaves and configuration options, it arranges for the grid to
2913 * manage the slaves and sets the specified options. Arguments consist
2912 * of content and configuration options, it arranges for the grid to
2913 * manage the content and sets the specified options. Arguments consist
29142914 * of windows or window shortcuts followed by "-option value" pairs.
29152915 *
29162916 * Results:
29182918 * and the interp's result is set to contain an error message.
29192919 *
29202920 * Side effects:
2921 * Slave windows get taken over by the grid.
2921 * Content windows get taken over by the grid.
29222922 *
29232923 *----------------------------------------------------------------------
29242924 */
29252925
29262926 static int
2927 ConfigureSlaves(
2927 ConfigureContent(
29282928 Tcl_Interp *interp, /* Interpreter for error reporting. */
29292929 Tk_Window tkwin, /* Any window in application containing
2930 * slaves. Used to look up slave names. */
2930 * content. Used to look up content names. */
29312931 int objc, /* Number of elements in argv. */
29322932 Tcl_Obj *const objv[]) /* Argument objects: contains one or more
29332933 * window names followed by any number of
29342934 * "option value" pairs. Caller must make sure
29352935 * that there is at least one window name. */
29362936 {
2937 Gridder *masterPtr = NULL;
2938 Gridder *slavePtr;
2939 Tk_Window other, slave, parent, ancestor;
2940 TkWindow *master;
2937 Gridder *containerPtr = NULL;
2938 Gridder *contentPtr;
2939 Tk_Window other, content, parent, ancestor;
2940 TkWindow *container;
29412941 int i, j, tmp;
29422942 int numWindows;
29432943 int width;
29732973
29742974 if (firstChar == '.') {
29752975 /*
2976 * Check that windows are valid, and locate the first slave's
2976 * Check that windows are valid, and locate the first content's
29772977 * parent window (default for -in).
29782978 */
29792979
2980 if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) {
2980 if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) {
29812981 return TCL_ERROR;
29822982 }
2983 if (masterPtr == NULL) {
2983 if (containerPtr == NULL) {
29842984 /*
2985 * Is there any saved -in from a removed slave?
2985 * Is there any saved -in from a removed content?
29862986 * If there is, it becomes default for -in.
2987 * If the stored master does not exist, just ignore it.
2987 * If the stored container does not exist, just ignore it.
29882988 */
29892989
2990 struct Gridder *slavePtr = GetGrid(slave);
2991 if (slavePtr->in != NULL) {
2992 if (TkGetWindowFromObj(interp, slave, slavePtr->in, &parent)
2990 contentPtr = GetGrid(content);
2991 if (contentPtr->in != NULL) {
2992 if (TkGetWindowFromObj(interp, content, contentPtr->in, &parent)
29932993 == TCL_OK) {
2994 masterPtr = GetGrid(parent);
2995 InitMasterData(masterPtr);
2994 containerPtr = GetGrid(parent);
2995 InitContainerData(containerPtr);
29962996 }
29972997 }
29982998 }
2999 if (masterPtr == NULL) {
3000 parent = Tk_Parent(slave);
2999 if (containerPtr == NULL) {
3000 parent = Tk_Parent(content);
30013001 if (parent != NULL) {
3002 masterPtr = GetGrid(parent);
3003 InitMasterData(masterPtr);
3002 containerPtr = GetGrid(parent);
3003 InitContainerData(containerPtr);
30043004 }
30053005 }
30063006 numWindows++;
30683068 TCL_OK) {
30693069 return TCL_ERROR;
30703070 }
3071 masterPtr = GetGrid(other);
3072 InitMasterData(masterPtr);
3071 containerPtr = GetGrid(other);
3072 InitContainerData(containerPtr);
30733073 } else if (index == CONF_ROW) {
30743074 if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK
30753075 || tmp < 0) {
30853085
30863086 /*
30873087 * If no -row is given, use the next row after the highest occupied row
3088 * of the master.
3088 * of the container.
30893089 */
30903090
30913091 if (defaultRow < 0) {
3092 if (masterPtr != NULL && masterPtr->masterDataPtr != NULL) {
3093 SetGridSize(masterPtr);
3094 defaultRow = masterPtr->masterDataPtr->rowEnd;
3092 if (containerPtr != NULL && containerPtr->containerDataPtr != NULL) {
3093 SetGridSize(containerPtr);
3094 defaultRow = containerPtr->containerDataPtr->rowEnd;
30953095 } else {
30963096 defaultRow = 0;
30973097 }
30983098 }
30993099
31003100 /*
3101 * Iterate over all of the slave windows and short-cuts, parsing options
3102 * for each slave. It's a bit wasteful to re-parse the options for each
3103 * slave, but things get too messy if we try to parse the arguments just
3104 * once at the beginning. For example, if a slave already is managed we
3101 * Iterate over all of the content windows and short-cuts, parsing options
3102 * for each content. It's a bit wasteful to re-parse the options for each
3103 * content, but things get too messy if we try to parse the arguments just
3104 * once at the beginning. For example, if a content already is managed we
31053105 * want to just change a few existing values without resetting everything.
31063106 * If there are multiple windows, the -in option only gets processed for
31073107 * the first window.
31143114
31153115 /*
31163116 * '^' and 'x' cause us to skip a column. '-' is processed as part of
3117 * its preceeding slave.
3117 * its preceeding content.
31183118 */
31193119
31203120 if ((firstChar == REL_VERT) || (firstChar == REL_SKIP)) {
31273127
31283128 for (defaultColumnSpan = 1; j + defaultColumnSpan < numWindows;
31293129 defaultColumnSpan++) {
3130 const char *string = Tcl_GetString(objv[j + defaultColumnSpan]);
3130 string = Tcl_GetString(objv[j + defaultColumnSpan]);
31313131
31323132 if (*string != REL_HORIZ) {
31333133 break;
31343134 }
31353135 }
31363136
3137 if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) {
3137 if (TkGetWindowFromObj(interp, tkwin, objv[j], &content) != TCL_OK) {
31383138 return TCL_ERROR;
31393139 }
31403140
3141 if (Tk_TopWinHierarchy(slave)) {
3141 if (Tk_TopWinHierarchy(content)) {
31423142 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
31433143 "can't manage \"%s\": it's a top-level window",
31443144 Tcl_GetString(objv[j])));
31453145 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL);
31463146 return TCL_ERROR;
31473147 }
3148 slavePtr = GetGrid(slave);
3148 contentPtr = GetGrid(content);
31493149
31503150 /*
31513151 * The following statement is taken from tkPack.c:
31523152 *
3153 * "If the slave isn't currently managed, reset all of its
3153 * "If the content isn't currently managed, reset all of its
31543154 * configuration information to default values (there could be old
31553155 * values left from a previous packer)."
31563156 *
3157 * I [D.S.] disagree with this statement. If a slave is disabled
3157 * I [D.S.] disagree with this statement. If a content is disabled
31583158 * (using "forget") and then re-enabled, I submit that 90% of the time
31593159 * the programmer will want it to retain its old configuration
31603160 * information. If the programmer doesn't want this behavior, then the
31753175 Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL);
31763176 return TCL_ERROR;
31773177 }
3178 if (SetSlaveColumn(interp, slavePtr, tmp, -1) != TCL_OK) {
3178 if (SetContentColumn(interp, contentPtr, tmp, -1) != TCL_OK) {
31793179 return TCL_ERROR;
31803180 }
31813181 break;
31883188 Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL);
31893189 return TCL_ERROR;
31903190 }
3191 if (SetSlaveColumn(interp, slavePtr, -1, tmp) != TCL_OK) {
3191 if (SetContentColumn(interp, contentPtr, -1, tmp) != TCL_OK) {
31923192 return TCL_ERROR;
31933193 }
31943194 break;
31973197 &other) != TCL_OK) {
31983198 return TCL_ERROR;
31993199 }
3200 if (other == slave) {
3200 if (other == content) {
32013201 Tcl_SetObjResult(interp, Tcl_NewStringObj(
32023202 "window can't be managed in itself", -1));
32033203 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
32043204 return TCL_ERROR;
32053205 }
32063206 positionGiven = 1;
3207 masterPtr = GetGrid(other);
3208 InitMasterData(masterPtr);
3207 containerPtr = GetGrid(other);
3208 InitContainerData(containerPtr);
32093209 break;
32103210 case CONF_STICKY: {
32113211 int sticky = StringToSticky(Tcl_GetString(objv[i+1]));
32183218 Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL);
32193219 return TCL_ERROR;
32203220 }
3221 slavePtr->sticky = sticky;
3221 contentPtr->sticky = sticky;
32223222 break;
32233223 }
32243224 case CONF_IPADX:
3225 if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1],
3225 if ((Tk_GetPixelsFromObj(NULL, content, objv[i+1],
32263226 &tmp) != TCL_OK) || (tmp < 0)) {
32273227 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
32283228 "bad ipadx value \"%s\": must be positive screen distance",
32303230 Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
32313231 return TCL_ERROR;
32323232 }
3233 slavePtr->iPadX = tmp * 2;
3233 contentPtr->iPadX = tmp * 2;
32343234 break;
32353235 case CONF_IPADY:
3236 if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1],
3236 if ((Tk_GetPixelsFromObj(NULL, content, objv[i+1],
32373237 &tmp) != TCL_OK) || (tmp < 0)) {
32383238 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
32393239 "bad ipady value \"%s\": must be positive screen distance",
32413241 Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
32423242 return TCL_ERROR;
32433243 }
3244 slavePtr->iPadY = tmp * 2;
3244 contentPtr->iPadY = tmp * 2;
32453245 break;
32463246 case CONF_PADX:
32473247 if (TkParsePadAmount(interp, tkwin, objv[i+1],
3248 &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) {
3248 &contentPtr->padLeft, &contentPtr->padX) != TCL_OK) {
32493249 return TCL_ERROR;
32503250 }
32513251 break;
32523252 case CONF_PADY:
32533253 if (TkParsePadAmount(interp, tkwin, objv[i+1],
3254 &slavePtr->padTop, &slavePtr->padY) != TCL_OK) {
3254 &contentPtr->padTop, &contentPtr->padY) != TCL_OK) {
32553255 return TCL_ERROR;
32563256 }
32573257 break;
32643264 Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL);
32653265 return TCL_ERROR;
32663266 }
3267 if (SetSlaveRow(interp, slavePtr, tmp, -1) != TCL_OK) {
3267 if (SetContentRow(interp, contentPtr, tmp, -1) != TCL_OK) {
32683268 return TCL_ERROR;
32693269 }
32703270 break;
32773277 Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL);
32783278 return TCL_ERROR;
32793279 }
3280 if (SetSlaveRow(interp, slavePtr, -1, tmp) != TCL_OK) {
3280 if (SetContentRow(interp, contentPtr, -1, tmp) != TCL_OK) {
32813281 return TCL_ERROR;
32823282 }
32833283 break;
32853285 }
32863286
32873287 /*
3288 * If no position was specified via -in and the slave is already
3288 * If no position was specified via -in and the content is already
32893289 * packed, then leave it in its current location.
32903290 */
32913291
3292 if (!positionGiven && (slavePtr->masterPtr != NULL)) {
3293 masterPtr = slavePtr->masterPtr;
3292 if (!positionGiven && (contentPtr->containerPtr != NULL)) {
3293 containerPtr = contentPtr->containerPtr;
32943294 goto scheduleLayout;
32953295 }
32963296
32993299 * its current location.
33003300 */
33013301
3302 if (positionGiven && (masterPtr == slavePtr->masterPtr)) {
3302 if (positionGiven && (containerPtr == contentPtr->containerPtr)) {
33033303 goto scheduleLayout;
33043304 }
33053305
33063306 /*
3307 * Make sure we have a geometry master. We look at:
3307 * Make sure we have a geometry container. We look at:
33083308 * 1) the -in flag
3309 * 2) the parent of the first slave.
3309 * 2) the parent of the first content.
33103310 */
33113311
3312 parent = Tk_Parent(slave);
3313 if (masterPtr == NULL) {
3314 masterPtr = GetGrid(parent);
3315 InitMasterData(masterPtr);
3312 parent = Tk_Parent(content);
3313 if (containerPtr == NULL) {
3314 containerPtr = GetGrid(parent);
3315 InitContainerData(containerPtr);
33163316 }
33173317
3318 if (slavePtr->masterPtr != NULL && slavePtr->masterPtr != masterPtr) {
3319 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
3320 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
3318 if (contentPtr->containerPtr != NULL && contentPtr->containerPtr != containerPtr) {
3319 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
3320 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
33213321 }
3322 Unlink(slavePtr);
3323 slavePtr->masterPtr = NULL;
3324 }
3325
3326 if (slavePtr->masterPtr == NULL) {
3327 Gridder *tempPtr = masterPtr->slavePtr;
3328
3329 slavePtr->masterPtr = masterPtr;
3330 masterPtr->slavePtr = slavePtr;
3331 slavePtr->nextPtr = tempPtr;
3322 Unlink(contentPtr);
3323 contentPtr->containerPtr = NULL;
3324 }
3325
3326 if (contentPtr->containerPtr == NULL) {
3327 Gridder *tempPtr = containerPtr->contentPtr;
3328
3329 contentPtr->containerPtr = containerPtr;
3330 containerPtr->contentPtr = contentPtr;
3331 contentPtr->nextPtr = tempPtr;
33323332 }
33333333
33343334 /*
3335 * Make sure that the slave's parent is either the master or an
3336 * ancestor of the master, and that the master and slave aren't the
3335 * Make sure that the content's parent is either the container or an
3336 * ancestor of the container, and that the container and content aren't the
33373337 * same.
33383338 */
33393339
3340 for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
3340 for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
33413341 if (ancestor == parent) {
33423342 break;
33433343 }
33443344 if (Tk_TopWinHierarchy(ancestor)) {
33453345 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
33463346 "can't put %s inside %s", Tcl_GetString(objv[j]),
3347 Tk_PathName(masterPtr->tkwin)));
3347 Tk_PathName(containerPtr->tkwin)));
33483348 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
3349 Unlink(slavePtr);
3349 Unlink(contentPtr);
33503350 return TCL_ERROR;
33513351 }
33523352 }
33553355 * Check for management loops.
33563356 */
33573357
3358 for (master = (TkWindow *)masterPtr->tkwin; master != NULL;
3359 master = (TkWindow *)TkGetGeomMaster(master)) {
3360 if (master == (TkWindow *)slave) {
3358 for (container = (TkWindow *)containerPtr->tkwin; container != NULL;
3359 container = (TkWindow *)TkGetContainer(container)) {
3360 if (container == (TkWindow *)content) {
33613361 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
33623362 "can't put %s inside %s, would cause management loop",
3363 Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin)));
3363 Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin)));
33643364 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
3365 Unlink(slavePtr);
3365 Unlink(contentPtr);
33663366 return TCL_ERROR;
33673367 }
33683368 }
3369 if (masterPtr->tkwin != Tk_Parent(slave)) {
3370 ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin;
3371 }
3372
3373 Tk_ManageGeometry(slave, &gridMgrType, slavePtr);
3374
3375 if (!(masterPtr->flags & DONT_PROPAGATE)) {
3376 if (TkSetGeometryMaster(interp, masterPtr->tkwin, "grid")
3369 if (containerPtr->tkwin != Tk_Parent(content)) {
3370 ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
3371 }
3372
3373 Tk_ManageGeometry(content, &gridMgrType, contentPtr);
3374
3375 if (!(containerPtr->flags & DONT_PROPAGATE)) {
3376 if (TkSetGeometryContainer(interp, containerPtr->tkwin, "grid")
33773377 != TCL_OK) {
3378 Tk_ManageGeometry(slave, NULL, NULL);
3379 Unlink(slavePtr);
3378 Tk_ManageGeometry(content, NULL, NULL);
3379 Unlink(contentPtr);
33803380 return TCL_ERROR;
33813381 }
3382 masterPtr->flags |= ALLOCED_MASTER;
3382 containerPtr->flags |= ALLOCED_CONTAINER;
33833383 }
33843384
33853385 /*
33863386 * Assign default position information.
33873387 */
33883388
3389 if (slavePtr->column == -1) {
3390 if (SetSlaveColumn(interp, slavePtr, defaultColumn,-1) != TCL_OK){
3389 if (contentPtr->column == -1) {
3390 if (SetContentColumn(interp, contentPtr, defaultColumn,-1) != TCL_OK){
33913391 return TCL_ERROR;
33923392 }
33933393 }
3394 if (SetSlaveColumn(interp, slavePtr, -1,
3395 slavePtr->numCols + defaultColumnSpan - 1) != TCL_OK) {
3394 if (SetContentColumn(interp, contentPtr, -1,
3395 contentPtr->numCols + defaultColumnSpan - 1) != TCL_OK) {
33963396 return TCL_ERROR;
33973397 }
3398 if (slavePtr->row == -1) {
3399 if (SetSlaveRow(interp, slavePtr, defaultRow, -1) != TCL_OK) {
3398 if (contentPtr->row == -1) {
3399 if (SetContentRow(interp, contentPtr, defaultRow, -1) != TCL_OK) {
34003400 return TCL_ERROR;
34013401 }
34023402 }
3403 defaultColumn += slavePtr->numCols;
3403 defaultColumn += contentPtr->numCols;
34043404 defaultColumnSpan = 1;
34053405
34063406 /*
3407 * Arrange for the master to be re-arranged at the first idle moment.
3407 * Arrange for the container to be re-arranged at the first idle moment.
34083408 */
34093409
34103410 scheduleLayout:
3411 if (masterPtr->abortPtr != NULL) {
3412 *masterPtr->abortPtr = 1;
3413 }
3414 if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
3415 masterPtr->flags |= REQUESTED_RELAYOUT;
3416 Tcl_DoWhenIdle(ArrangeGrid, masterPtr);
3411 if (containerPtr->abortPtr != NULL) {
3412 *containerPtr->abortPtr = 1;
3413 }
3414 if (!(containerPtr->flags & REQUESTED_RELAYOUT)) {
3415 containerPtr->flags |= REQUESTED_RELAYOUT;
3416 Tcl_DoWhenIdle(ArrangeGrid, containerPtr);
34173417 }
34183418 }
34193419
34293429 int lastRow, lastColumn; /* Implied end of table. */
34303430
34313431 string = Tcl_GetString(objv[j]);
3432 firstChar = string[0];
3433
3434 if (firstChar == '.') {
3432 firstChar = string[0];
3433
3434 if (firstChar == '.') {
34353435 lastWindow = string;
34363436 numSkip = 0;
34373437 }
34423442 continue;
34433443 }
34443444
3445 if (masterPtr == NULL) {
3445 if (containerPtr == NULL) {
34463446 Tcl_SetObjResult(interp, Tcl_NewStringObj(
34473447 "can't use '^', cant find master", -1));
34483448 Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
34543454 */
34553455
34563456 for (width = 1; width + j < numWindows; width++) {
3457 const char *string = Tcl_GetString(objv[j+width]);
3457 string = Tcl_GetString(objv[j+width]);
34583458
34593459 if (*string != REL_VERT) {
34603460 break;
34783478 lastColumn += numSkip;
34793479
34803480 match = 0;
3481 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
3482 slavePtr = slavePtr->nextPtr) {
3483
3484 if (slavePtr->column == lastColumn
3485 && slavePtr->row + slavePtr->numRows - 1 == lastRow) {
3486 if (slavePtr->numCols <= width) {
3487 if (SetSlaveRow(interp, slavePtr, -1,
3488 slavePtr->numRows + 1) != TCL_OK) {
3481 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
3482 contentPtr = contentPtr->nextPtr) {
3483
3484 if (contentPtr->column == lastColumn
3485 && contentPtr->row + contentPtr->numRows - 1 == lastRow) {
3486 if (contentPtr->numCols <= width) {
3487 if (SetContentRow(interp, contentPtr, -1,
3488 contentPtr->numRows + 1) != TCL_OK) {
34893489 return TCL_ERROR;
34903490 }
34913491 match++;
3492 j += slavePtr->numCols - 1;
3493 lastWindow = Tk_PathName(slavePtr->tkwin);
3492 j += contentPtr->numCols - 1;
3493 lastWindow = Tk_PathName(contentPtr->tkwin);
34943494 numSkip = 0;
34953495 break;
34963496 }
35043504 }
35053505 }
35063506
3507 if (masterPtr == NULL) {
3507 if (containerPtr == NULL) {
35083508 Tcl_SetObjResult(interp, Tcl_NewStringObj(
35093509 "can't determine master window", -1));
35103510 Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
35113511 return TCL_ERROR;
35123512 }
3513 SetGridSize(masterPtr);
3514
3515 /*
3516 * If we have emptied this master from slaves it means we are no longer
3513 SetGridSize(containerPtr);
3514
3515 /*
3516 * If we have emptied this container from content it means we are no longer
35173517 * handling it and should mark it as free.
35183518 */
35193519
3520 if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) {
3521 TkFreeGeometryMaster(masterPtr->tkwin, "grid");
3522 masterPtr->flags &= ~ALLOCED_MASTER;
3520 if (containerPtr->contentPtr == NULL && containerPtr->flags & ALLOCED_CONTAINER) {
3521 TkFreeGeometryContainer(containerPtr->tkwin, "grid");
3522 containerPtr->flags &= ~ALLOCED_CONTAINER;
35233523 }
35243524
35253525 return TCL_OK;
2525 Display *display; /* Display for tkwin. Needed because when the
2626 * image is eventually freed tkwin may not
2727 * exist anymore. */
28 struct ImageMaster *masterPtr;
29 /* Master for this image (identifiers image
28 struct ImageModel *modelPtr;
29 /* Model for this image (identifiers image
3030 * manager, for example). */
3131 ClientData instanceData; /* One word argument to pass to image manager
3232 * when dealing with this image instance. */
3939 } Image;
4040
4141 /*
42 * For each image master there is one of the following structures, which
42 * For each image model there is one of the following structures, which
4343 * represents a name in the image table and all of the images instantiated
4444 * from it. Entries in mainPtr->imageTable point to these structures.
4545 */
4646
47 typedef struct ImageMaster {
47 typedef struct ImageModel {
4848 Tk_ImageType *typePtr; /* Information about image type. NULL means
4949 * that no image manager owns this image: the
5050 * image was deleted. */
51 ClientData masterData; /* One-word argument to pass to image mgr when
52 * dealing with the master, as opposed to
51 ClientData modelData; /* One-word argument to pass to image mgr when
52 * dealing with the model, as opposed to
5353 * instances. */
5454 int width, height; /* Last known dimensions for image. */
5555 Tcl_HashTable *tablePtr; /* Pointer to hash table containing image (the
6363 int deleted; /* Flag set when image is being deleted. */
6464 TkWindow *winPtr; /* Main window of interpreter (used to detect
6565 * when the world is falling apart.) */
66 } ImageMaster;
66 } ImageModel;
6767
6868 typedef struct {
6969 Tk_ImageType *imageTypeList;/* First in a list of all known image
8181 */
8282
8383 static void ImageTypeThreadExitProc(ClientData clientData);
84 static void DeleteImage(ImageMaster *masterPtr);
85 static void EventuallyDeleteImage(ImageMaster *masterPtr,
84 static void DeleteImage(ImageModel *modelPtr);
85 static void EventuallyDeleteImage(ImageModel *modelPtr,
8686 int forgetImageHashNow);
8787
8888 /*
103103
104104 static void
105105 ImageTypeThreadExitProc(
106 ClientData clientData) /* not used */
106 TCL_UNUSED(void *))
107107 {
108108 Tk_ImageType *freePtr;
109 ThreadSpecificData *tsdPtr =
109 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
110110 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
111111
112112 while (tsdPtr->oldImageTypeList != NULL) {
148148 * by caller. */
149149 {
150150 Tk_ImageType *copyPtr;
151 ThreadSpecificData *tsdPtr =
151 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
152152 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
153153
154154 if (!tsdPtr->initialized) {
155155 tsdPtr->initialized = 1;
156156 Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL);
157157 }
158 copyPtr = ckalloc(sizeof(Tk_ImageType));
158 copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType));
159159 *copyPtr = *typePtr;
160160 copyPtr->nextPtr = tsdPtr->oldImageTypeList;
161161 tsdPtr->oldImageTypeList = copyPtr;
169169 * by caller. */
170170 {
171171 Tk_ImageType *copyPtr;
172 ThreadSpecificData *tsdPtr =
172 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
173173 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
174174
175175 if (!tsdPtr->initialized) {
176176 tsdPtr->initialized = 1;
177177 Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL);
178178 }
179 copyPtr = ckalloc(sizeof(Tk_ImageType));
179 copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType));
180180 *copyPtr = *typePtr;
181181 copyPtr->nextPtr = tsdPtr->imageTypeList;
182182 tsdPtr->imageTypeList = copyPtr;
214214 IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES,
215215 IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH
216216 };
217 TkWindow *winPtr = clientData;
217 TkWindow *winPtr = (TkWindow *)clientData;
218218 int i, isNew, firstOption, index;
219219 Tk_ImageType *typePtr;
220 ImageMaster *masterPtr;
220 ImageModel *modelPtr;
221221 Image *imagePtr;
222222 Tcl_HashEntry *hPtr;
223223 Tcl_HashSearch search;
225225 TkDisplay *dispPtr = winPtr->dispPtr;
226226 const char *arg, *name;
227227 Tcl_Obj *resultObj;
228 ThreadSpecificData *tsdPtr =
228 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
229229 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
230230
231231 if (objc < 2) {
296296
297297 /*
298298 * Need to check if the _command_ that we are about to create is
299 * the name of the current master widget command (normally "." but
299 * the name of the current model widget command (normally "." but
300300 * could have been renamed) and fail in that case before a really
301301 * nasty and hard to stop crash happens.
302302 */
317317
318318 hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew);
319319 if (isNew) {
320 masterPtr = ckalloc(sizeof(ImageMaster));
321 masterPtr->typePtr = NULL;
322 masterPtr->masterData = NULL;
323 masterPtr->width = masterPtr->height = 1;
324 masterPtr->tablePtr = &winPtr->mainPtr->imageTable;
325 masterPtr->hPtr = hPtr;
326 masterPtr->instancePtr = NULL;
327 masterPtr->deleted = 0;
328 masterPtr->winPtr = winPtr->mainPtr->winPtr;
329 Tcl_Preserve(masterPtr->winPtr);
330 Tcl_SetHashValue(hPtr, masterPtr);
320 modelPtr = (ImageModel *)ckalloc(sizeof(ImageModel));
321 modelPtr->typePtr = NULL;
322 modelPtr->modelData = NULL;
323 modelPtr->width = modelPtr->height = 1;
324 modelPtr->tablePtr = &winPtr->mainPtr->imageTable;
325 modelPtr->hPtr = hPtr;
326 modelPtr->instancePtr = NULL;
327 modelPtr->deleted = 0;
328 modelPtr->winPtr = winPtr->mainPtr->winPtr;
329 Tcl_Preserve(modelPtr->winPtr);
330 Tcl_SetHashValue(hPtr, modelPtr);
331331 } else {
332332 /*
333333 * An image already exists by this name. Disconnect the instances
334 * from the master.
334 * from the model.
335335 */
336336
337 masterPtr = Tcl_GetHashValue(hPtr);
338 if (masterPtr->typePtr != NULL) {
339 for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
337 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
338 if (modelPtr->typePtr != NULL) {
339 for (imagePtr = modelPtr->instancePtr; imagePtr != NULL;
340340 imagePtr = imagePtr->nextPtr) {
341 masterPtr->typePtr->freeProc(imagePtr->instanceData,
341 modelPtr->typePtr->freeProc(imagePtr->instanceData,
342342 imagePtr->display);
343343 imagePtr->changeProc(imagePtr->widgetClientData, 0, 0,
344 masterPtr->width, masterPtr->height,
345 masterPtr->width, masterPtr->height);
344 modelPtr->width, modelPtr->height,
345 modelPtr->width, modelPtr->height);
346346 }
347 masterPtr->typePtr->deleteProc(masterPtr->masterData);
348 masterPtr->typePtr = NULL;
347 modelPtr->typePtr->deleteProc(modelPtr->modelData);
348 modelPtr->typePtr = NULL;
349349 }
350 masterPtr->deleted = 0;
350 modelPtr->deleted = 0;
351351 }
352352
353353 /*
360360 objc -= firstOption;
361361 args = (Tcl_Obj **) objv;
362362 if (oldimage) {
363 int i;
364
365 args = ckalloc((objc+1) * sizeof(char *));
363 args = (Tcl_Obj **)ckalloc((objc+1) * sizeof(Tcl_Obj *));
366364 for (i = 0; i < objc; i++) {
367365 args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]);
368366 }
369367 args[objc] = NULL;
370368 }
371 Tcl_Preserve(masterPtr);
369 Tcl_Preserve(modelPtr);
372370 if (typePtr->createProc(interp, name, objc, args, typePtr,
373 (Tk_ImageMaster)masterPtr, &masterPtr->masterData) != TCL_OK){
374 EventuallyDeleteImage(masterPtr, 0);
375 Tcl_Release(masterPtr);
371 (Tk_ImageModel)modelPtr, &modelPtr->modelData) != TCL_OK){
372 EventuallyDeleteImage(modelPtr, 0);
373 Tcl_Release(modelPtr);
376374 if (oldimage) {
377375 ckfree(args);
378376 }
379377 return TCL_ERROR;
380378 }
381 Tcl_Release(masterPtr);
379 Tcl_Release(modelPtr);
382380 if (oldimage) {
383381 ckfree(args);
384382 }
385 masterPtr->typePtr = typePtr;
386 for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
383 modelPtr->typePtr = typePtr;
384 for (imagePtr = modelPtr->instancePtr; imagePtr != NULL;
387385 imagePtr = imagePtr->nextPtr) {
388386 imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin,
389 masterPtr->masterData);
387 modelPtr->modelData);
390388 }
391389 Tcl_SetObjResult(interp, Tcl_NewStringObj(
392 Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
390 (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
393391 break;
394392 }
395393 case IMAGE_DELETE:
399397 if (hPtr == NULL) {
400398 goto alreadyDeleted;
401399 }
402 masterPtr = Tcl_GetHashValue(hPtr);
403 if (masterPtr->deleted) {
400 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
401 if (modelPtr->deleted) {
404402 goto alreadyDeleted;
405403 }
406 DeleteImage(masterPtr);
404 DeleteImage(modelPtr);
407405 }
408406 break;
409407 case IMAGE_NAMES:
414412 hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
415413 resultObj = Tcl_NewObj();
416414 for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
417 masterPtr = Tcl_GetHashValue(hPtr);
418 if (masterPtr->deleted) {
415 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
416 if (modelPtr->deleted) {
419417 continue;
420418 }
421419 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
422 Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
420 (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
423421 }
424422 Tcl_SetObjResult(interp, resultObj);
425423 break;
448446 case IMAGE_WIDTH:
449447 /*
450448 * These operations all parse virtually identically. First check to
451 * see if three args are given. Then get a non-deleted master from the
449 * see if three args are given. Then get a non-deleted model from the
452450 * third arg.
453451 */
454452
462460 if (hPtr == NULL) {
463461 goto alreadyDeleted;
464462 }
465 masterPtr = Tcl_GetHashValue(hPtr);
466 if (masterPtr->deleted) {
463 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
464 if (modelPtr->deleted) {
467465 goto alreadyDeleted;
468466 }
469467
473471
474472 switch ((enum options) index) {
475473 case IMAGE_HEIGHT:
476 Tcl_SetObjResult(interp, Tcl_NewIntObj(masterPtr->height));
474 Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->height));
477475 break;
478476 case IMAGE_INUSE:
479477 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
480 masterPtr->typePtr && masterPtr->instancePtr));
478 modelPtr->typePtr && modelPtr->instancePtr));
481479 break;
482480 case IMAGE_TYPE:
483 if (masterPtr->typePtr != NULL) {
481 if (modelPtr->typePtr != NULL) {
484482 Tcl_SetObjResult(interp,
485 Tcl_NewStringObj(masterPtr->typePtr->name, -1));
483 Tcl_NewStringObj(modelPtr->typePtr->name, -1));
486484 }
487485 break;
488486 case IMAGE_WIDTH:
489 Tcl_SetObjResult(interp, Tcl_NewIntObj(masterPtr->width));
487 Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->width));
490488 break;
491489 default:
492490 Tcl_Panic("can't happen");
522520
523521 void
524522 Tk_ImageChanged(
525 Tk_ImageMaster imageMaster, /* Image that needs redisplay. */
523 Tk_ImageModel imageModel, /* Image that needs redisplay. */
526524 int x, int y, /* Coordinates of upper-left pixel of region
527525 * of image that needs to be redrawn. */
528526 int width, int height, /* Dimensions (in pixels) of region of image
533531 int imageWidth, int imageHeight)
534532 /* New dimensions of image. */
535533 {
536 ImageMaster *masterPtr = (ImageMaster *) imageMaster;
534 ImageModel *modelPtr = (ImageModel *) imageModel;
537535 Image *imagePtr;
538536
539 masterPtr->width = imageWidth;
540 masterPtr->height = imageHeight;
541 for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
537 modelPtr->width = imageWidth;
538 modelPtr->height = imageHeight;
539 for (imagePtr = modelPtr->instancePtr; imagePtr != NULL;
542540 imagePtr = imagePtr->nextPtr) {
543541 imagePtr->changeProc(imagePtr->widgetClientData, x, y, width, height,
544542 imageWidth, imageHeight);
550548 *
551549 * Tk_NameOfImage --
552550 *
553 * Given a token for an image master, this function returns the name of
551 * Given a token for an image model, this function returns the name of
554552 * the image.
555553 *
556554 * Results:
557 * The return value is the string name for imageMaster.
555 * The return value is the string name for imageModel.
558556 *
559557 * Side effects:
560558 * None.
564562
565563 const char *
566564 Tk_NameOfImage(
567 Tk_ImageMaster imageMaster) /* Token for image. */
568 {
569 ImageMaster *masterPtr = (ImageMaster *) imageMaster;
570
571 if (masterPtr->hPtr == NULL) {
565 Tk_ImageModel imageModel) /* Token for image. */
566 {
567 ImageModel *modelPtr = (ImageModel *) imageModel;
568
569 if (modelPtr->hPtr == NULL) {
572570 return NULL;
573571 }
574 return Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr);
572 return (const char *)Tcl_GetHashKey(modelPtr->tablePtr, modelPtr->hPtr);
575573 }
576574
577575 /*
609607 ClientData clientData) /* One-word argument to pass to damageProc. */
610608 {
611609 Tcl_HashEntry *hPtr;
612 ImageMaster *masterPtr;
610 ImageModel *modelPtr;
613611 Image *imagePtr;
614612
615613 hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name);
616614 if (hPtr == NULL) {
617615 goto noSuchImage;
618616 }
619 masterPtr = Tcl_GetHashValue(hPtr);
620 if (masterPtr->typePtr == NULL) {
617 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
618 if (modelPtr->typePtr == NULL) {
621619 goto noSuchImage;
622620 }
623 if (masterPtr->deleted) {
621 if (modelPtr->deleted) {
624622 goto noSuchImage;
625623 }
626 imagePtr = ckalloc(sizeof(Image));
624 imagePtr = (Image *)ckalloc(sizeof(Image));
627625 imagePtr->tkwin = tkwin;
628626 imagePtr->display = Tk_Display(tkwin);
629 imagePtr->masterPtr = masterPtr;
627 imagePtr->modelPtr = modelPtr;
630628 imagePtr->instanceData =
631 masterPtr->typePtr->getProc(tkwin, masterPtr->masterData);
629 modelPtr->typePtr->getProc(tkwin, modelPtr->modelData);
632630 imagePtr->changeProc = changeProc;
633631 imagePtr->widgetClientData = clientData;
634 imagePtr->nextPtr = masterPtr->instancePtr;
635 masterPtr->instancePtr = imagePtr;
632 imagePtr->nextPtr = modelPtr->instancePtr;
633 modelPtr->instancePtr = imagePtr;
636634 return (Tk_Image) imagePtr;
637635
638636 noSuchImage:
668666 * a widget. */
669667 {
670668 Image *imagePtr = (Image *) image;
671 ImageMaster *masterPtr = imagePtr->masterPtr;
669 ImageModel *modelPtr = imagePtr->modelPtr;
672670 Image *prevPtr;
673671
674672 /*
675673 * Clean up the particular instance.
676674 */
677675
678 if (masterPtr->typePtr != NULL) {
679 masterPtr->typePtr->freeProc(imagePtr->instanceData,
676 if (modelPtr->typePtr != NULL) {
677 modelPtr->typePtr->freeProc(imagePtr->instanceData,
680678 imagePtr->display);
681679 }
682 prevPtr = masterPtr->instancePtr;
680 prevPtr = modelPtr->instancePtr;
683681 if (prevPtr == imagePtr) {
684 masterPtr->instancePtr = imagePtr->nextPtr;
682 modelPtr->instancePtr = imagePtr->nextPtr;
685683 } else {
686684 while (prevPtr->nextPtr != imagePtr) {
687685 prevPtr = prevPtr->nextPtr;
691689 ckfree(imagePtr);
692690
693691 /*
694 * If there are no more instances left for the master, and if the master
695 * image has been deleted, then delete the master too.
692 * If there are no more instances left for the model, and if the model
693 * image has been deleted, then delete the model too.
696694 */
697695
698 if ((masterPtr->typePtr == NULL) && (masterPtr->instancePtr == NULL)) {
699 if (masterPtr->hPtr != NULL) {
700 Tcl_DeleteHashEntry(masterPtr->hPtr);
701 }
702 Tcl_Release(masterPtr->winPtr);
703 ckfree(masterPtr);
696 if ((modelPtr->typePtr == NULL) && (modelPtr->instancePtr == NULL)) {
697 if (modelPtr->hPtr != NULL) {
698 Tcl_DeleteHashEntry(modelPtr->hPtr);
699 }
700 Tcl_Release(modelPtr->winPtr);
701 ckfree(modelPtr);
704702 }
705703 }
706704
740738 GC newGC;
741739 XGCValues gcValues;
742740
743 if (imagePtr->masterPtr->typePtr == NULL) {
741 if (imagePtr->modelPtr->typePtr == NULL) {
744742 /*
745 * No master for image, so nothing to display on postscript.
743 * No model for image, so nothing to display on postscript.
746744 */
747745
748746 return TCL_OK;
753751 * otherwise go on with generic code.
754752 */
755753
756 if (imagePtr->masterPtr->typePtr->postscriptProc != NULL) {
757 return imagePtr->masterPtr->typePtr->postscriptProc(
758 imagePtr->masterPtr->masterData, interp, tkwin, psinfo,
754 if (imagePtr->modelPtr->typePtr->postscriptProc != NULL) {
755 return imagePtr->modelPtr->typePtr->postscriptProc(
756 imagePtr->modelPtr->modelData, interp, tkwin, psinfo,
759757 x, y, width, height, prepass);
760758 }
761759
836834 {
837835 Image *imagePtr = (Image *) image;
838836
839 if (imagePtr->masterPtr->typePtr == NULL) {
837 if (imagePtr->modelPtr->typePtr == NULL) {
840838 /*
841 * No master for image, so nothing to display.
839 * No model for image, so nothing to display.
842840 */
843841
844842 return;
858856 drawableY -= imageY;
859857 imageY = 0;
860858 }
861 if ((imageX + width) > imagePtr->masterPtr->width) {
862 width = imagePtr->masterPtr->width - imageX;
863 }
864 if ((imageY + height) > imagePtr->masterPtr->height) {
865 height = imagePtr->masterPtr->height - imageY;
866 }
867 imagePtr->masterPtr->typePtr->displayProc(imagePtr->instanceData,
859 if ((imageX + width) > imagePtr->modelPtr->width) {
860 width = imagePtr->modelPtr->width - imageX;
861 }
862 if ((imageY + height) > imagePtr->modelPtr->height) {
863 height = imagePtr->modelPtr->height - imageY;
864 }
865 imagePtr->modelPtr->typePtr->displayProc(imagePtr->instanceData,
868866 imagePtr->display, drawable, imageX, imageY, width, height,
869867 drawableX, drawableY);
870868 }
894892 {
895893 Image *imagePtr = (Image *) image;
896894
897 *widthPtr = imagePtr->masterPtr->width;
898 *heightPtr = imagePtr->masterPtr->height;
895 *widthPtr = imagePtr->modelPtr->width;
896 *heightPtr = imagePtr->modelPtr->height;
899897 }
900898
901899 /*
932930 if (hPtr == NULL) {
933931 return;
934932 }
935 DeleteImage(Tcl_GetHashValue(hPtr));
933 DeleteImage((ImageModel *)Tcl_GetHashValue(hPtr));
936934 }
937935
938936 /*
947945 *
948946 * Side effects:
949947 * The connection is dropped between instances of this image and an image
950 * master. Image instances will redisplay themselves as empty areas, but
948 * model. Image instances will redisplay themselves as empty areas, but
951949 * existing instances will not be deleted.
952950 *
953951 *----------------------------------------------------------------------
955953
956954 static void
957955 DeleteImage(
958 ImageMaster *masterPtr) /* Pointer to main data structure for image. */
956 ImageModel *modelPtr) /* Pointer to main data structure for image. */
959957 {
960958 Image *imagePtr;
961959 Tk_ImageType *typePtr;
962960
963 typePtr = masterPtr->typePtr;
964 masterPtr->typePtr = NULL;
961 typePtr = modelPtr->typePtr;
962 modelPtr->typePtr = NULL;
965963 if (typePtr != NULL) {
966 for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
964 for (imagePtr = modelPtr->instancePtr; imagePtr != NULL;
967965 imagePtr = imagePtr->nextPtr) {
968966 typePtr->freeProc(imagePtr->instanceData, imagePtr->display);
969967 imagePtr->changeProc(imagePtr->widgetClientData, 0, 0,
970 masterPtr->width, masterPtr->height, masterPtr->width,
971 masterPtr->height);
972 }
973 typePtr->deleteProc(masterPtr->masterData);
974 }
975 if (masterPtr->instancePtr == NULL) {
976 if (masterPtr->hPtr != NULL) {
977 Tcl_DeleteHashEntry(masterPtr->hPtr);
978 }
979 Tcl_Release(masterPtr->winPtr);
980 ckfree(masterPtr);
968 modelPtr->width, modelPtr->height, modelPtr->width,
969 modelPtr->height);
970 }
971 typePtr->deleteProc(modelPtr->modelData);
972 }
973 if (modelPtr->instancePtr == NULL) {
974 if (modelPtr->hPtr != NULL) {
975 Tcl_DeleteHashEntry(modelPtr->hPtr);
976 }
977 Tcl_Release(modelPtr->winPtr);
978 ckfree(modelPtr);
981979 } else {
982 masterPtr->deleted = 1;
980 modelPtr->deleted = 1;
983981 }
984982 }
985983
10031001
10041002 static void
10051003 EventuallyDeleteImage(
1006 ImageMaster *masterPtr, /* Pointer to main data structure for image. */
1004 ImageModel *modelPtr, /* Pointer to main data structure for image. */
10071005 int forgetImageHashNow) /* Flag to say whether the hash table is about
10081006 * to vanish. */
10091007 {
10101008 if (forgetImageHashNow) {
1011 masterPtr->hPtr = NULL;
1012 }
1013 if (!masterPtr->deleted) {
1014 masterPtr->deleted = 1;
1015 Tcl_EventuallyFree(masterPtr, (Tcl_FreeProc *) DeleteImage);
1009 modelPtr->hPtr = NULL;
1010 }
1011 if (!modelPtr->deleted) {
1012 modelPtr->deleted = 1;
1013 Tcl_EventuallyFree(modelPtr, (Tcl_FreeProc *) DeleteImage);
10161014 }
10171015 }
10181016
10441042
10451043 for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search);
10461044 hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
1047 EventuallyDeleteImage(Tcl_GetHashValue(hPtr), 1);
1045 EventuallyDeleteImage((ImageModel *)Tcl_GetHashValue(hPtr), 1);
10481046 }
10491047 Tcl_DeleteHashTable(&mainPtr->imageTable);
10501048 }
10521050 /*
10531051 *----------------------------------------------------------------------
10541052 *
1055 * Tk_GetImageMasterData --
1053 * Tk_GetImageModelData --
10561054 *
10571055 * Given the name of an image, this function returns the type of the
1058 * image and the clientData associated with its master.
1056 * image and the clientData associated with its model.
10591057 *
10601058 * Results:
10611059 * If there is no image by the given name, then NULL is returned and a
10701068 */
10711069
10721070 ClientData
1073 Tk_GetImageMasterData(
1071 Tk_GetImageModelData(
10741072 Tcl_Interp *interp, /* Interpreter in which the image was
10751073 * created. */
10761074 const char *name, /* Name of image. */
10801078 {
10811079 TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
10821080 Tcl_HashEntry *hPtr;
1083 ImageMaster *masterPtr;
1081 ImageModel *modelPtr;
10841082
10851083 hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
10861084 if (hPtr == NULL) {
10871085 *typePtrPtr = NULL;
10881086 return NULL;
10891087 }
1090 masterPtr = Tcl_GetHashValue(hPtr);
1091 if (masterPtr->deleted) {
1088 modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr);
1089 if (modelPtr->deleted) {
10921090 *typePtrPtr = NULL;
10931091 return NULL;
10941092 }
1095 *typePtrPtr = masterPtr->typePtr;
1096 return masterPtr->masterData;
1093 *typePtrPtr = modelPtr->typePtr;
1094 return modelPtr->modelData;
10971095 }
10981096
10991097 /*
11171115 *----------------------------------------------------------------------
11181116 */
11191117
1120 /*ARGSUSED*/
11211118 void
11221119 Tk_SetTSOrigin(
11231120 Tk_Window tkwin,
1313 #include "tkInt.h"
1414
1515 /*
16 * The following data structure represents the master for a bitmap
16 * The following data structure represents the model for a bitmap
1717 * image:
1818 */
1919
20 typedef struct BitmapMaster {
21 Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means the
20 typedef struct BitmapModel {
21 Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the
2222 * image is being deleted. */
2323 Tcl_Interp *interp; /* Interpreter for application that is using
2424 * image. */
3939 char *maskDataString; /* Value of -maskdata option (malloc'ed). */
4040 struct BitmapInstance *instancePtr;
4141 /* First in list of all instances associated
42 * with this master. */
43 } BitmapMaster;
42 * with this model. */
43 } BitmapModel;
4444
4545 /*
4646 * The following data structure represents all of the instances of an image
5050 typedef struct BitmapInstance {
5151 int refCount; /* Number of instances that share this data
5252 * structure. */
53 BitmapMaster *masterPtr; /* Pointer to master for image. */
53 BitmapModel *modelPtr; /* Pointer to model for image. */
5454 Tk_Window tkwin; /* Window in which the instances will be
5555 * displayed. */
5656 XColor *fg; /* Foreground color for displaying image. */
6464 * displayed. */
6565 struct BitmapInstance *nextPtr;
6666 /* Next in list of all instance structures
67 * associated with masterPtr (NULL means end
67 * associated with modelPtr (NULL means end
6868 * of list). */
6969 } BitmapInstance;
7070
7575 static int GetByte(Tcl_Channel chan);
7676 static int ImgBmapCreate(Tcl_Interp *interp,
7777 const char *name, int argc, Tcl_Obj *const objv[],
78 const Tk_ImageType *typePtr, Tk_ImageMaster master,
78 const Tk_ImageType *typePtr, Tk_ImageModel model,
7979 ClientData *clientDataPtr);
8080 static ClientData ImgBmapGet(Tk_Window tkwin, ClientData clientData);
8181 static void ImgBmapDisplay(ClientData clientData,
107107
108108 static const Tk_ConfigSpec configSpecs[] = {
109109 {TK_CONFIG_UID, "-background", NULL, NULL,
110 "", Tk_Offset(BitmapMaster, bgUid), 0, NULL},
110 "", Tk_Offset(BitmapModel, bgUid), 0, NULL},
111111 {TK_CONFIG_STRING, "-data", NULL, NULL,
112 NULL, Tk_Offset(BitmapMaster, dataString), TK_CONFIG_NULL_OK, NULL},
112 NULL, Tk_Offset(BitmapModel, dataString), TK_CONFIG_NULL_OK, NULL},
113113 {TK_CONFIG_STRING, "-file", NULL, NULL,
114 NULL, Tk_Offset(BitmapMaster, fileString), TK_CONFIG_NULL_OK, NULL},
114 NULL, Tk_Offset(BitmapModel, fileString), TK_CONFIG_NULL_OK, NULL},
115115 {TK_CONFIG_UID, "-foreground", NULL, NULL,
116 "#000000", Tk_Offset(BitmapMaster, fgUid), 0, NULL},
116 "#000000", Tk_Offset(BitmapModel, fgUid), 0, NULL},
117117 {TK_CONFIG_STRING, "-maskdata", NULL, NULL,
118 NULL, Tk_Offset(BitmapMaster, maskDataString), TK_CONFIG_NULL_OK, NULL},
118 NULL, Tk_Offset(BitmapModel, maskDataString), TK_CONFIG_NULL_OK, NULL},
119119 {TK_CONFIG_STRING, "-maskfile", NULL, NULL,
120 NULL, Tk_Offset(BitmapMaster, maskFileString), TK_CONFIG_NULL_OK, NULL},
120 NULL, Tk_Offset(BitmapModel, maskFileString), TK_CONFIG_NULL_OK, NULL},
121121 {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
122122 };
123123
148148 int argc, Tcl_Obj *const objv[]);
149149 static void ImgBmapCmdDeletedProc(ClientData clientData);
150150 static void ImgBmapConfigureInstance(BitmapInstance *instancePtr);
151 static int ImgBmapConfigureMaster(BitmapMaster *masterPtr,
151 static int ImgBmapConfigureModel(BitmapModel *modelPtr,
152152 int argc, Tcl_Obj *const objv[], int flags);
153153 static int NextBitmapWord(ParseInfo *parseInfoPtr);
154154
178178 Tcl_Obj *const argv[], /* Argument objects for options (doesn't
179179 * include image name or type). */
180180 const Tk_ImageType *typePtr,/* Pointer to our type record (not used). */
181 Tk_ImageMaster master, /* Token for image, to be used by us in later
181 Tk_ImageModel model, /* Token for image, to be used by us in later
182182 * callbacks. */
183183 ClientData *clientDataPtr) /* Store manager's token for image here; it
184184 * will be returned in later callbacks. */
185185 {
186 BitmapMaster *masterPtr = ckalloc(sizeof(BitmapMaster));
187
188 masterPtr->tkMaster = master;
189 masterPtr->interp = interp;
190 masterPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgBmapCmd,
191 masterPtr, ImgBmapCmdDeletedProc);
192 masterPtr->width = masterPtr->height = 0;
193 masterPtr->data = NULL;
194 masterPtr->maskData = NULL;
195 masterPtr->fgUid = NULL;
196 masterPtr->bgUid = NULL;
197 masterPtr->fileString = NULL;
198 masterPtr->dataString = NULL;
199 masterPtr->maskFileString = NULL;
200 masterPtr->maskDataString = NULL;
201 masterPtr->instancePtr = NULL;
202 if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) {
203 ImgBmapDelete(masterPtr);
186 BitmapModel *modelPtr = ckalloc(sizeof(BitmapModel));
187
188 modelPtr->tkModel = model;
189 modelPtr->interp = interp;
190 modelPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgBmapCmd,
191 modelPtr, ImgBmapCmdDeletedProc);
192 modelPtr->width = modelPtr->height = 0;
193 modelPtr->data = NULL;
194 modelPtr->maskData = NULL;
195 modelPtr->fgUid = NULL;
196 modelPtr->bgUid = NULL;
197 modelPtr->fileString = NULL;
198 modelPtr->dataString = NULL;
199 modelPtr->maskFileString = NULL;
200 modelPtr->maskDataString = NULL;
201 modelPtr->instancePtr = NULL;
202 if (ImgBmapConfigureModel(modelPtr, argc, argv, 0) != TCL_OK) {
203 ImgBmapDelete(modelPtr);
204204 return TCL_ERROR;
205205 }
206 *clientDataPtr = masterPtr;
206 *clientDataPtr = modelPtr;
207207 return TCL_OK;
208208 }
209209
210210 /*
211211 *----------------------------------------------------------------------
212212 *
213 * ImgBmapConfigureMaster --
213 * ImgBmapConfigureModel --
214214 *
215215 * This procedure is called when a bitmap image is created or
216216 * reconfigured. It process configuration options and resets any
218218 *
219219 * Results:
220220 * A standard Tcl return value. If TCL_ERROR is returned then an error
221 * message is left in the masterPtr->interp's result.
221 * message is left in the modelPtr->interp's result.
222222 *
223223 * Side effects:
224224 * Existing instances of the image will be redisplayed to match the new
228228 */
229229
230230 static int
231 ImgBmapConfigureMaster(
232 BitmapMaster *masterPtr, /* Pointer to data structure describing
231 ImgBmapConfigureModel(
232 BitmapModel *modelPtr, /* Pointer to data structure describing
233233 * overall bitmap image to (reconfigure). */
234234 int objc, /* Number of entries in objv. */
235235 Tcl_Obj *const objv[], /* Pairs of configuration options for image. */
245245 }
246246 argv[objc] = NULL;
247247
248 if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp),
249 configSpecs, objc, argv, (char *) masterPtr, flags) != TCL_OK) {
248 if (Tk_ConfigureWidget(modelPtr->interp, Tk_MainWindow(modelPtr->interp),
249 configSpecs, objc, argv, (char *) modelPtr, flags) != TCL_OK) {
250250 ckfree(argv);
251251 return TCL_ERROR;
252252 }
257257 * bitmap and mask have the same dimensions.
258258 */
259259
260 if (masterPtr->data != NULL) {
261 ckfree(masterPtr->data);
262 masterPtr->data = NULL;
263 }
264 if ((masterPtr->fileString != NULL) || (masterPtr->dataString != NULL)) {
265 masterPtr->data = TkGetBitmapData(masterPtr->interp,
266 masterPtr->dataString, masterPtr->fileString,
267 &masterPtr->width, &masterPtr->height, &dummy1, &dummy2);
268 if (masterPtr->data == NULL) {
260 if (modelPtr->data != NULL) {
261 ckfree(modelPtr->data);
262 modelPtr->data = NULL;
263 }
264 if ((modelPtr->fileString != NULL) || (modelPtr->dataString != NULL)) {
265 modelPtr->data = TkGetBitmapData(modelPtr->interp,
266 modelPtr->dataString, modelPtr->fileString,
267 &modelPtr->width, &modelPtr->height, &dummy1, &dummy2);
268 if (modelPtr->data == NULL) {
269269 return TCL_ERROR;
270270 }
271271 }
272 if (masterPtr->maskData != NULL) {
273 ckfree(masterPtr->maskData);
274 masterPtr->maskData = NULL;
275 }
276 if ((masterPtr->maskFileString != NULL)
277 || (masterPtr->maskDataString != NULL)) {
278 if (masterPtr->data == NULL) {
279 Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj(
272 if (modelPtr->maskData != NULL) {
273 ckfree(modelPtr->maskData);
274 modelPtr->maskData = NULL;
275 }
276 if ((modelPtr->maskFileString != NULL)
277 || (modelPtr->maskDataString != NULL)) {
278 if (modelPtr->data == NULL) {
279 Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj(
280280 "can't have mask without bitmap", -1));
281 Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP",
281 Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP",
282282 "NO_BITMAP", NULL);
283283 return TCL_ERROR;
284284 }
285 masterPtr->maskData = TkGetBitmapData(masterPtr->interp,
286 masterPtr->maskDataString, masterPtr->maskFileString,
285 modelPtr->maskData = TkGetBitmapData(modelPtr->interp,
286 modelPtr->maskDataString, modelPtr->maskFileString,
287287 &maskWidth, &maskHeight, &dummy1, &dummy2);
288 if (masterPtr->maskData == NULL) {
288 if (modelPtr->maskData == NULL) {
289289 return TCL_ERROR;
290290 }
291 if ((maskWidth != masterPtr->width)
292 || (maskHeight != masterPtr->height)) {
293 ckfree(masterPtr->maskData);
294 masterPtr->maskData = NULL;
295 Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj(
291 if ((maskWidth != modelPtr->width)
292 || (maskHeight != modelPtr->height)) {
293 ckfree(modelPtr->maskData);
294 modelPtr->maskData = NULL;
295 Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj(
296296 "bitmap and mask have different sizes", -1));
297 Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP",
297 Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP",
298298 "MASK_SIZE", NULL);
299299 return TCL_ERROR;
300300 }
306306 * everywhere that it is used.
307307 */
308308
309 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
309 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
310310 instancePtr = instancePtr->nextPtr) {
311311 ImgBmapConfigureInstance(instancePtr);
312312 }
313 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
314 masterPtr->height, masterPtr->width, masterPtr->height);
313 Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width,
314 modelPtr->height, modelPtr->width, modelPtr->height);
315315 return TCL_OK;
316316 }
317317
321321 * ImgBmapConfigureInstance --
322322 *
323323 * This procedure is called to create displaying information for a bitmap
324 * image instance based on the configuration information in the master.
325 * It is invoked both when new instances are created and when the master
324 * image instance based on the configuration information in the model.
325 * It is invoked both when new instances are created and when the model
326326 * is reconfigured.
327327 *
328328 * Results:
339339 ImgBmapConfigureInstance(
340340 BitmapInstance *instancePtr)/* Instance to reconfigure. */
341341 {
342 BitmapMaster *masterPtr = instancePtr->masterPtr;
342 BitmapModel *modelPtr = instancePtr->modelPtr;
343343 XColor *colorPtr;
344344 XGCValues gcValues;
345345 GC gc;
347347 Pixmap oldBitmap, oldMask;
348348
349349 /*
350 * For each of the options in masterPtr, translate the string form into an
350 * For each of the options in modelPtr, translate the string form into an
351351 * internal form appropriate for instancePtr.
352352 */
353353
354 if (*masterPtr->bgUid != 0) {
355 colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin,
356 masterPtr->bgUid);
354 if (*modelPtr->bgUid != 0) {
355 colorPtr = Tk_GetColor(modelPtr->interp, instancePtr->tkwin,
356 modelPtr->bgUid);
357357 if (colorPtr == NULL) {
358358 goto error;
359359 }
365365 }
366366 instancePtr->bg = colorPtr;
367367
368 colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin,
369 masterPtr->fgUid);
368 colorPtr = Tk_GetColor(modelPtr->interp, instancePtr->tkwin,
369 modelPtr->fgUid);
370370 if (colorPtr == NULL) {
371371 goto error;
372372 }
387387 oldMask = instancePtr->mask;
388388 instancePtr->mask = None;
389389
390 if (masterPtr->data != NULL) {
390 if (modelPtr->data != NULL) {
391391 instancePtr->bitmap = XCreateBitmapFromData(
392392 Tk_Display(instancePtr->tkwin),
393393 RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)),
394 masterPtr->data, (unsigned) masterPtr->width,
395 (unsigned) masterPtr->height);
396 }
397 if (masterPtr->maskData != NULL) {
394 modelPtr->data, (unsigned) modelPtr->width,
395 (unsigned) modelPtr->height);
396 }
397 if (modelPtr->maskData != NULL) {
398398 instancePtr->mask = XCreateBitmapFromData(
399399 Tk_Display(instancePtr->tkwin),
400400 RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)),
401 masterPtr->maskData, (unsigned) masterPtr->width,
402 (unsigned) masterPtr->height);
401 modelPtr->maskData, (unsigned) modelPtr->width,
402 (unsigned) modelPtr->height);
403403 }
404404
405405 if (oldMask != None) {
409409 Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap);
410410 }
411411
412 if (masterPtr->data != NULL) {
412 if (modelPtr->data != NULL) {
413413 gcValues.foreground = instancePtr->fg->pixel;
414414 gcValues.graphics_exposures = False;
415415 mask = GCForeground|GCGraphicsExposures;
444444 Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc);
445445 }
446446 instancePtr->gc = NULL;
447 Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf(
447 Tcl_AppendObjToErrorInfo(modelPtr->interp, Tcl_ObjPrintf(
448448 "\n (while configuring image \"%s\")", Tk_NameOfImage(
449 masterPtr->tkMaster)));
450 Tcl_BackgroundException(masterPtr->interp, TCL_ERROR);
449 modelPtr->tkModel)));
450 Tcl_BackgroundException(modelPtr->interp, TCL_ERROR);
451451 }
452452
453453 /*
750750
751751 static int
752752 ImgBmapCmd(
753 ClientData clientData, /* Information about the image master. */
753 ClientData clientData, /* Information about the image model. */
754754 Tcl_Interp *interp, /* Current interpreter. */
755755 int objc, /* Number of arguments. */
756756 Tcl_Obj *const objv[]) /* Argument objects. */
757757 {
758758 static const char *const bmapOptions[] = {"cget", "configure", NULL};
759 BitmapMaster *masterPtr = clientData;
759 BitmapModel *modelPtr = clientData;
760760 int index;
761761
762762 if (objc < 2) {
774774 return TCL_ERROR;
775775 }
776776 return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
777 (char *) masterPtr, Tcl_GetString(objv[2]), 0);
777 (char *) modelPtr, Tcl_GetString(objv[2]), 0);
778778 case 1: /* configure */
779779 if (objc == 2) {
780780 return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
781 configSpecs, (char *) masterPtr, NULL, 0);
781 configSpecs, (char *) modelPtr, NULL, 0);
782782 } else if (objc == 3) {
783783 return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
784 configSpecs, (char *) masterPtr,
784 configSpecs, (char *) modelPtr,
785785 Tcl_GetString(objv[2]), 0);
786786 } else {
787 return ImgBmapConfigureMaster(masterPtr, objc-2, objv+2,
787 return ImgBmapConfigureModel(modelPtr, objc-2, objv+2,
788788 TK_CONFIG_ARGV_ONLY);
789789 }
790790 default:
815815 ImgBmapGet(
816816 Tk_Window tkwin, /* Window in which the instance will be
817817 * used. */
818 ClientData masterData) /* Pointer to our master structure for the
818 ClientData modelData) /* Pointer to our model structure for the
819819 * image. */
820820 {
821 BitmapMaster *masterPtr = masterData;
821 BitmapModel *modelPtr = modelData;
822822 BitmapInstance *instancePtr;
823823
824824 /*
826826 * re-use it.
827827 */
828828
829 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
829 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
830830 instancePtr = instancePtr->nextPtr) {
831831 if (instancePtr->tkwin == tkwin) {
832832 instancePtr->refCount++;
841841
842842 instancePtr = ckalloc(sizeof(BitmapInstance));
843843 instancePtr->refCount = 1;
844 instancePtr->masterPtr = masterPtr;
844 instancePtr->modelPtr = modelPtr;
845845 instancePtr->tkwin = tkwin;
846846 instancePtr->fg = NULL;
847847 instancePtr->bg = NULL;
848848 instancePtr->bitmap = None;
849849 instancePtr->mask = None;
850850 instancePtr->gc = NULL;
851 instancePtr->nextPtr = masterPtr->instancePtr;
852 masterPtr->instancePtr = instancePtr;
851 instancePtr->nextPtr = modelPtr->instancePtr;
852 modelPtr->instancePtr = instancePtr;
853853 ImgBmapConfigureInstance(instancePtr);
854854
855855 /*
857857 */
858858
859859 if (instancePtr->nextPtr == NULL) {
860 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
861 masterPtr->height);
860 Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, modelPtr->width,
861 modelPtr->height);
862862 }
863863
864864 return instancePtr;
975975 if (instancePtr->gc != NULL) {
976976 Tk_FreeGC(display, instancePtr->gc);
977977 }
978 if (instancePtr->masterPtr->instancePtr == instancePtr) {
979 instancePtr->masterPtr->instancePtr = instancePtr->nextPtr;
978 if (instancePtr->modelPtr->instancePtr == instancePtr) {
979 instancePtr->modelPtr->instancePtr = instancePtr->nextPtr;
980980 } else {
981 for (prevPtr = instancePtr->masterPtr->instancePtr;
981 for (prevPtr = instancePtr->modelPtr->instancePtr;
982982 prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) {
983983 /* Empty loop body */
984984 }
992992 *
993993 * ImgBmapDelete --
994994 *
995 * This procedure is called by the image code to delete the master
995 * This procedure is called by the image code to delete the model
996996 * structure for an image.
997997 *
998998 * Results:
10061006
10071007 static void
10081008 ImgBmapDelete(
1009 ClientData masterData) /* Pointer to BitmapMaster structure for
1009 ClientData modelData) /* Pointer to BitmapModel structure for
10101010 * image. Must not have any more instances. */
10111011 {
1012 BitmapMaster *masterPtr = masterData;
1013
1014 if (masterPtr->instancePtr != NULL) {
1012 BitmapModel *modelPtr = modelData;
1013
1014 if (modelPtr->instancePtr != NULL) {
10151015 Tcl_Panic("tried to delete bitmap image when instances still exist");
10161016 }
1017 masterPtr->tkMaster = NULL;
1018 if (masterPtr->imageCmd != NULL) {
1019 Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd);
1020 }
1021 if (masterPtr->data != NULL) {
1022 ckfree(masterPtr->data);
1023 }
1024 if (masterPtr->maskData != NULL) {
1025 ckfree(masterPtr->maskData);
1026 }
1027 Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0);
1028 ckfree(masterPtr);
1017 modelPtr->tkModel = NULL;
1018 if (modelPtr->imageCmd != NULL) {
1019 Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd);
1020 }
1021 if (modelPtr->data != NULL) {
1022 ckfree(modelPtr->data);
1023 }
1024 if (modelPtr->maskData != NULL) {
1025 ckfree(modelPtr->maskData);
1026 }
1027 Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0);
1028 ckfree(modelPtr);
10291029 }
10301030
10311031 /*
10471047
10481048 static void
10491049 ImgBmapCmdDeletedProc(
1050 ClientData clientData) /* Pointer to BitmapMaster structure for
1050 ClientData clientData) /* Pointer to BitmapModel structure for
10511051 * image. */
10521052 {
1053 BitmapMaster *masterPtr = clientData;
1054
1055 masterPtr->imageCmd = NULL;
1056 if (masterPtr->tkMaster != NULL) {
1057 Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster));
1053 BitmapModel *modelPtr = clientData;
1054
1055 modelPtr->imageCmd = NULL;
1056 if (modelPtr->tkModel != NULL) {
1057 Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkModel));
10581058 }
10591059 }
10601060
10821082 int size;
10831083
10841084 size = Tcl_Read(chan, &buffer, 1);
1085 if (size <= 0) {
1085 if (size != 1) {
10861086 return EOF;
10871087 } else {
10881088 return buffer;
11971197 int x, int y, int width, int height,
11981198 int prepass)
11991199 {
1200 BitmapMaster *masterPtr = clientData;
1200 BitmapModel *modelPtr = clientData;
12011201 Tcl_InterpState interpState;
12021202 Tcl_Obj *psObj;
12031203
12091209 * There is nothing to do for bitmaps with zero width or height.
12101210 */
12111211
1212 if (width<=0 || height<=0 || masterPtr->width<=0 || masterPtr->height<=0){
1212 if (width<=0 || height<=0 || modelPtr->width<=0 || modelPtr->height<=0){
12131213 return TCL_OK;
12141214 }
12151215
12191219 * we bail out.
12201220 */
12211221
1222 if (masterPtr->width*masterPtr->height > 60000) {
1222 if (modelPtr->width*modelPtr->height > 60000) {
12231223 Tcl_SetObjResult(interp, Tcl_NewStringObj(
12241224 "unable to generate postscript for bitmaps larger than 60000"
12251225 " pixels", -1));
12581258 * color to the bits specified by the mask.
12591259 */
12601260
1261 if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) {
1261 if ((modelPtr->bgUid != NULL) && (modelPtr->bgUid[0] != '\000')) {
12621262 XColor color;
12631263
1264 TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid,
1264 TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), modelPtr->bgUid,
12651265 &color);
12661266 Tcl_ResetResult(interp);
12671267 if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
12691269 }
12701270 Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
12711271
1272 if (masterPtr->maskData == NULL) {
1272 if (modelPtr->maskData == NULL) {
12731273 Tcl_AppendToObj(psObj,
12741274 "0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto "
12751275 "closepath fill\n", -1);
12761276 } else {
1277 ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height,
1278 masterPtr->maskData);
1277 ImgBmapPsImagemask(psObj, modelPtr->width, modelPtr->height,
1278 modelPtr->maskData);
12791279 }
12801280 }
12811281
12831283 * Draw the bitmap foreground, assuming there is one.
12841284 */
12851285
1286 if ((masterPtr->fgUid != NULL) && (masterPtr->data != NULL)) {
1286 if ((modelPtr->fgUid != NULL) && (modelPtr->data != NULL)) {
12871287 XColor color;
12881288
1289 TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid,
1289 TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), modelPtr->fgUid,
12901290 &color);
12911291 Tcl_ResetResult(interp);
12921292 if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
12941294 }
12951295 Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
12961296
1297 ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height,
1298 masterPtr->data);
1297 ImgBmapPsImagemask(psObj, modelPtr->width, modelPtr->height,
1298 modelPtr->data);
12991299 }
13001300
13011301 /*
625625 int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
626626
627627 blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz);
628 if (blockSz < 0) {
628 if (blockSz == -1) {
629629 /* TODO: failure info... */
630630 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
631631 "channel read failed: %s", Tcl_PosixError(interp)));
28832883 }
28842884
28852885 memcpy(destPtr+objSz, srcPtr, srcSz);
2886 } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) < 0) {
2886 } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == -1) {
28872887 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
28882888 "write to channel failed: %s", Tcl_PosixError(interp)));
28892889 return TCL_ERROR;
9393 static int
9494 FileMatchPPM(
9595 Tcl_Channel chan, /* The image file, open for reading. */
96 const char *fileName, /* The name of the image file. */
97 Tcl_Obj *format, /* User-specified format string, or NULL. */
96 TCL_UNUSED(const char *), /* The name of the image file. */
97 TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */
9898 int *widthPtr, int *heightPtr,
9999 /* The dimensions of the image are returned
100100 * here if the file is a valid raw PPM
101101 * file. */
102 Tcl_Interp *interp) /* unused */
102 TCL_UNUSED(Tcl_Interp *)) /* unused */
103103 {
104104 int dummy;
105105
130130 Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
131131 Tcl_Channel chan, /* The image file, open for reading. */
132132 const char *fileName, /* The name of the image file. */
133 Tcl_Obj *format, /* User-specified format string, or NULL. */
133 TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */
134134 Tk_PhotoHandle imageHandle, /* The photo image to write into. */
135135 int destX, int destY, /* Coordinates of top-left pixel in photo
136136 * image to be written to. */
210210 nLines = 1;
211211 }
212212 nBytes = nLines * block.pitch;
213 pixelPtr = ckalloc(nBytes);
213 pixelPtr = (unsigned char *)ckalloc(nBytes);
214214 block.pixelPtr = pixelPtr + srcX * block.pixelSize;
215215
216216 for (h = height; h > 0; h -= nLines) {
280280 FileWritePPM(
281281 Tcl_Interp *interp,
282282 const char *fileName,
283 Tcl_Obj *format,
283 TCL_UNUSED(Tcl_Obj *),
284284 Tk_PhotoImageBlock *blockPtr)
285285 {
286286 Tcl_Channel chan;
322322 pixelPtr = pixLinePtr;
323323 for (w = blockPtr->width; w > 0; w--) {
324324 if ( Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 ||
325 Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1)==-1 ||
326 Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) ==-1) {
325 Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == -1 ||
326 Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == -1) {
327327 goto writeerror;
328328 }
329329 pixelPtr += blockPtr->pixelSize;
367367 static int
368368 StringWritePPM(
369369 Tcl_Interp *interp,
370 Tcl_Obj *format,
370 TCL_UNUSED(Tcl_Obj *),
371371 Tk_PhotoImageBlock *blockPtr)
372372 {
373373 int w, h, size, greenOffset, blueOffset;
443443 static int
444444 StringMatchPPM(
445445 Tcl_Obj *dataObj, /* The image data. */
446 Tcl_Obj *format, /* User-specified format string, or NULL. */
446 TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */
447447 int *widthPtr, int *heightPtr,
448448 /* The dimensions of the image are returned
449449 * here if the file is a valid raw PPM
450450 * file. */
451 Tcl_Interp *interp) /* unused */
451 TCL_UNUSED(Tcl_Interp *)) /* unused */
452452 {
453453 int dummy;
454454
478478 StringReadPPM(
479479 Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
480480 Tcl_Obj *dataObj, /* The image data. */
481 Tcl_Obj *format, /* User-specified format string, or NULL. */
481 TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */
482482 Tk_PhotoHandle imageHandle, /* The photo image to write into. */
483483 int destX, int destY, /* Coordinates of top-left pixel in photo
484484 * image to be written to. */
577577 nLines = 1;
578578 }
579579 nBytes = nLines * block.pitch;
580 pixelPtr = ckalloc(nBytes);
580 pixelPtr = (unsigned char *)ckalloc(nBytes);
581581 block.pixelPtr = pixelPtr + srcX * block.pixelSize;
582582
583583 for (h = height; h > 0; h -= nLines) {
599599 *p = (((int) *dataBuffer) * 255)/maxIntensity;
600600 }
601601 } else {
602 unsigned char *p;
603602 unsigned int value;
604603
605604 for (p = pixelPtr,count=nBytes; count > 1; count-=2, p += 2) {
1818 */
1919
2020 #include "tkImgPhoto.h"
21 #ifdef MAC_OSX_TK
22 #define TKPUTIMAGE_CAN_BLEND
23 #endif
21 #include "tkPort.h"
2422
2523 /*
2624 * Declaration for internal Xlib function used here:
6058 * TkImgPhotoConfigureInstance --
6159 *
6260 * This function is called to create displaying information for a photo
63 * image instance based on the configuration information in the master.
64 * It is invoked both when new instances are created and when the master
61 * image instance based on the configuration information in the model.
62 * It is invoked both when new instances are created and when the model
6563 * is reconfigured.
6664 *
6765 * Results:
7876 TkImgPhotoConfigureInstance(
7977 PhotoInstance *instancePtr) /* Instance to reconfigure. */
8078 {
81 PhotoMaster *masterPtr = instancePtr->masterPtr;
79 PhotoModel *modelPtr = instancePtr->masterPtr;
8280 XImage *imagePtr;
8381 int bitsPerPixel;
8482 ColorTable *colorTablePtr;
8583 XRectangle validBox;
8684
8785 /*
88 * If the -palette configuration option has been set for the master, use
86 * If the -palette configuration option has been set for the model, use
8987 * the value specified for our palette, but only if it is a valid palette
90 * for our windows. Use the gamma value specified the master.
91 */
92
93 if ((masterPtr->palette && masterPtr->palette[0])
94 && IsValidPalette(instancePtr, masterPtr->palette)) {
95 instancePtr->palette = masterPtr->palette;
88 * for our windows. Use the gamma value specified the model.
89 */
90
91 if ((modelPtr->palette && modelPtr->palette[0])
92 && IsValidPalette(instancePtr, modelPtr->palette)) {
93 instancePtr->palette = modelPtr->palette;
9694 } else {
9795 instancePtr->palette = instancePtr->defaultPalette;
9896 }
99 instancePtr->gamma = masterPtr->gamma;
97 instancePtr->gamma = modelPtr->gamma;
10098
10199 /*
102100 * If we don't currently have a color table, or if the one we have no
160158 }
161159
162160 /*
163 * If the user has specified a width and/or height for the master which is
161 * If the user has specified a width and/or height for the model which is
164162 * different from our current width/height, set the size to the values
165163 * specified by the user. If we have no pixmap, we do this also, since it
166164 * has the side effect of allocating a pixmap for us.
167165 */
168166
169167 if ((instancePtr->pixels == None) || (instancePtr->error == NULL)
170 || (instancePtr->width != masterPtr->width)
171 || (instancePtr->height != masterPtr->height)) {
168 || (instancePtr->width != modelPtr->width)
169 || (instancePtr->height != modelPtr->height)) {
172170 TkImgPhotoInstanceSetSize(instancePtr);
173171 }
174172
176174 * Redither this instance if necessary.
177175 */
178176
179 if ((masterPtr->flags & IMAGE_CHANGED)
177 if ((modelPtr->flags & IMAGE_CHANGED)
180178 || (instancePtr->colorTablePtr != colorTablePtr)) {
181 TkClipBox(masterPtr->validRegion, &validBox);
179 TkClipBox(modelPtr->validRegion, &validBox);
182180 if ((validBox.width > 0) && (validBox.height > 0)) {
183181 TkImgDitherInstance(instancePtr, validBox.x, validBox.y,
184182 validBox.width, validBox.height);
208206 TkImgPhotoGet(
209207 Tk_Window tkwin, /* Window in which the instance will be
210208 * used. */
211 ClientData masterData) /* Pointer to our master structure for the
209 ClientData modelData) /* Pointer to our model structure for the
212210 * image. */
213211 {
214 PhotoMaster *masterPtr = masterData;
212 PhotoModel *modelPtr = modelData;
215213 PhotoInstance *instancePtr;
216214 Colormap colormap;
217215 int mono, nRed, nGreen, nBlue, numVisuals;
248246 */
249247
250248 colormap = Tk_Colormap(tkwin);
251 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
249 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
252250 instancePtr = instancePtr->nextPtr) {
253251 if ((colormap == instancePtr->colormap)
254252 && (Tk_Display(tkwin) == instancePtr->display)) {
278276 */
279277
280278 instancePtr = ckalloc(sizeof(PhotoInstance));
281 instancePtr->masterPtr = masterPtr;
279 instancePtr->masterPtr = modelPtr;
282280 instancePtr->display = Tk_Display(tkwin);
283281 instancePtr->colormap = Tk_Colormap(tkwin);
284282 Tk_PreserveColormap(instancePtr->display, instancePtr->colormap);
289287 instancePtr->width = 0;
290288 instancePtr->height = 0;
291289 instancePtr->imagePtr = 0;
292 instancePtr->nextPtr = masterPtr->instancePtr;
293 masterPtr->instancePtr = instancePtr;
290 instancePtr->nextPtr = modelPtr->instancePtr;
291 modelPtr->instancePtr = instancePtr;
294292
295293 /*
296294 * Obtain information about the visual and decide on the default palette.
350348 * Make a GC with background = black and foreground = white.
351349 */
352350
353 white = Tk_GetColor(masterPtr->interp, tkwin, "white");
354 black = Tk_GetColor(masterPtr->interp, tkwin, "black");
351 white = Tk_GetColor(modelPtr->interp, tkwin, "white");
352 black = Tk_GetColor(modelPtr->interp, tkwin, "black");
355353 gcValues.foreground = (white != NULL)? white->pixel:
356354 WhitePixelOfScreen(Tk_Screen(tkwin));
357355 gcValues.background = (black != NULL)? black->pixel:
374372 */
375373
376374 if (instancePtr->nextPtr == NULL) {
377 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
378 masterPtr->width, masterPtr->height);
375 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
376 modelPtr->width, modelPtr->height);
379377 }
380378
381379 return instancePtr;
407405 * slower, so it's only used for 15bpp+.
408406 *
409407 * Note that Win32 pre-defines those operations that we really need.
410 *
411 * Note that on MacOS, if the background comes from a Retina display
412 * then it will be twice as wide and twice as high as the photoimage.
413408 *
414409 *----------------------------------------------------------------------
415410 */
438433 {
439434 int x, y, line;
440435 unsigned long pixel;
441 unsigned char r, g, b, alpha, unalpha, *masterPtr;
436 unsigned char r, g, b, alpha, unalpha, *modelPtr;
442437 unsigned char *alphaAr = iPtr->masterPtr->pix32;
443438
444439 /*
498493 for (y = 0; y < height; y++) {
499494 line = (y + yOffset) * iPtr->masterPtr->width;
500495 for (x = 0; x < width; x++) {
501 masterPtr = alphaAr + ((line + x + xOffset) * 4);
502 alpha = masterPtr[3];
496 modelPtr = alphaAr + ((line + x + xOffset) * 4);
497 alpha = modelPtr[3];
503498
504499 /*
505500 * Ignore pixels that are fully transparent
511506 * 24 and 32 bit displays, but this seems "fast enough".
512507 */
513508
514 r = masterPtr[0];
515 g = masterPtr[1];
516 b = masterPtr[2];
509 r = modelPtr[0];
510 g = modelPtr[1];
511 b = modelPtr[2];
517512 if (alpha != 255) {
518513 /*
519514 * Only blend pixels that have some transparency
541536 for (y = 0; y < height; y++) {
542537 line = (y + yOffset) * iPtr->masterPtr->width;
543538 for (x = 0; x < width; x++) {
544 masterPtr = alphaAr + ((line + x + xOffset) * 4);
545 alpha = masterPtr[3];
539 modelPtr = alphaAr + ((line + x + xOffset) * 4);
540 alpha = modelPtr[3];
546541
547542 /*
548543 * Ignore pixels that are fully transparent
554549 * and 32 bit displays, but this seems "fast enough".
555550 */
556551
557 r = masterPtr[0];
558 g = masterPtr[1];
559 b = masterPtr[2];
552 r = modelPtr[0];
553 g = modelPtr[1];
554 b = modelPtr[2];
560555 if (alpha != 255) {
561556 /*
562557 * Only blend pixels that have some transparency
683678 Tk_DeleteErrorHandler(handler);
684679 } else {
685680 /*
686 * masterPtr->region describes which parts of the image contain valid
681 * modelPtr->region describes which parts of the image contain valid
687682 * data. We set this region as the clip mask for the gc, setting its
688683 * origin appropriately, and use it when drawing the image.
689684 */
772767 TkImgPhotoInstanceSetSize(
773768 PhotoInstance *instancePtr) /* Instance whose size is to be changed. */
774769 {
775 PhotoMaster *masterPtr;
770 PhotoModel *modelPtr;
776771 schar *newError, *errSrcPtr, *errDestPtr;
777772 int h, offset;
778773 XRectangle validBox;
779774 Pixmap newPixmap;
780775
781 masterPtr = instancePtr->masterPtr;
782 TkClipBox(masterPtr->validRegion, &validBox);
783
784 if ((instancePtr->width != masterPtr->width)
785 || (instancePtr->height != masterPtr->height)
776 modelPtr = instancePtr->masterPtr;
777 TkClipBox(modelPtr->validRegion, &validBox);
778
779 if ((instancePtr->width != modelPtr->width)
780 || (instancePtr->height != modelPtr->height)
786781 || (instancePtr->pixels == None)) {
787782 newPixmap = Tk_GetPixmap(instancePtr->display,
788783 RootWindow(instancePtr->display,
789784 instancePtr->visualInfo.screen),
790 (masterPtr->width > 0) ? masterPtr->width: 1,
791 (masterPtr->height > 0) ? masterPtr->height: 1,
785 (modelPtr->width > 0) ? modelPtr->width: 1,
786 (modelPtr->height > 0) ? modelPtr->height: 1,
792787 instancePtr->visualInfo.depth);
793788 if (!newPixmap) {
794789 Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in TkImgPhotoInstanceSetSize");
818813 instancePtr->pixels = newPixmap;
819814 }
820815
821 if ((instancePtr->width != masterPtr->width)
822 || (instancePtr->height != masterPtr->height)
816 if ((instancePtr->width != modelPtr->width)
817 || (instancePtr->height != modelPtr->height)
823818 || (instancePtr->error == NULL)) {
824 if (masterPtr->height > 0 && masterPtr->width > 0) {
819 if (modelPtr->height > 0 && modelPtr->width > 0) {
825820 /*
826821 * TODO: use attemptckalloc() here once there is a strategy that
827822 * will allow us to recover from failure. Right now, there's no
828823 * such possibility.
829824 */
830825
831 newError = ckalloc(masterPtr->height * masterPtr->width
826 newError = ckalloc(modelPtr->height * modelPtr->width
832827 * 3 * sizeof(schar));
833828
834829 /*
837832 */
838833
839834 if ((instancePtr->error != NULL)
840 && ((instancePtr->width == masterPtr->width)
841 || (validBox.width == masterPtr->width))) {
835 && ((instancePtr->width == modelPtr->width)
836 || (validBox.width == modelPtr->width))) {
842837 if (validBox.y > 0) {
843838 memset(newError, 0, (size_t)
844 validBox.y * masterPtr->width * 3 * sizeof(schar));
839 validBox.y * modelPtr->width * 3 * sizeof(schar));
845840 }
846841 h = validBox.y + validBox.height;
847 if (h < masterPtr->height) {
848 memset(newError + h*masterPtr->width*3, 0,
849 (size_t) (masterPtr->height - h)
850 * masterPtr->width * 3 * sizeof(schar));
842 if (h < modelPtr->height) {
843 memset(newError + h*modelPtr->width*3, 0,
844 (size_t) (modelPtr->height - h)
845 * modelPtr->width * 3 * sizeof(schar));
851846 }
852847 } else {
853848 memset(newError, 0, (size_t)
854 masterPtr->height * masterPtr->width *3*sizeof(schar));
849 modelPtr->height * modelPtr->width *3*sizeof(schar));
855850 }
856851 } else {
857852 newError = NULL;
863858 * array.
864859 */
865860
866 if (masterPtr->width == instancePtr->width) {
867 offset = validBox.y * masterPtr->width * 3;
861 if (modelPtr->width == instancePtr->width) {
862 offset = validBox.y * modelPtr->width * 3;
868863 memcpy(newError + offset, instancePtr->error + offset,
869864 (size_t) (validBox.height
870 * masterPtr->width * 3 * sizeof(schar)));
865 * modelPtr->width * 3 * sizeof(schar)));
871866
872867 } else if (validBox.width > 0 && validBox.height > 0) {
873868 errDestPtr = newError +
874 (validBox.y * masterPtr->width + validBox.x) * 3;
869 (validBox.y * modelPtr->width + validBox.x) * 3;
875870 errSrcPtr = instancePtr->error +
876871 (validBox.y * instancePtr->width + validBox.x) * 3;
877872
878873 for (h = validBox.height; h > 0; --h) {
879874 memcpy(errDestPtr, errSrcPtr,
880875 validBox.width * 3 * sizeof(schar));
881 errDestPtr += masterPtr->width * 3;
876 errDestPtr += modelPtr->width * 3;
882877 errSrcPtr += instancePtr->width * 3;
883878 }
884879 }
888883 instancePtr->error = newError;
889884 }
890885
891 instancePtr->width = masterPtr->width;
892 instancePtr->height = masterPtr->height;
886 instancePtr->width = modelPtr->width;
887 instancePtr->height = modelPtr->height;
893888 }
894889
895890 /*
16211616 * TkImgDitherInstance --
16221617 *
16231618 * This function is called to update an area of an instance's pixmap by
1624 * dithering the corresponding area of the master.
1619 * dithering the corresponding area of the model.
16251620 *
16261621 * Results:
16271622 * None.
16391634 * block to be dithered. */
16401635 int width, int height) /* Dimensions of the block to be dithered. */
16411636 {
1642 PhotoMaster *masterPtr = instancePtr->masterPtr;
1637 PhotoModel *modelPtr = instancePtr->masterPtr;
16431638 ColorTable *colorPtr = instancePtr->colorTablePtr;
16441639 XImage *imagePtr;
16451640 int nLines, bigEndian, i, c, x, y, xEnd, doDithering = 1;
16971692 bigEndian = imagePtr->bitmap_bit_order == MSBFirst;
16981693 firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1;
16991694
1700 lineLength = masterPtr->width * 3;
1701 srcLinePtr = masterPtr->pix32 + (yStart * masterPtr->width + xStart) * 4;
1695 lineLength = modelPtr->width * 3;
1696 srcLinePtr = modelPtr->pix32 + (yStart * modelPtr->width + xStart) * 4;
17021697 errLinePtr = instancePtr->error + yStart * lineLength + xStart * 3;
17031698 xEnd = xStart + width;
17041699
17531748 c += errPtr[-lineLength-3];
17541749 }
17551750 c += errPtr[-lineLength] * 5;
1756 if ((x + 1) < masterPtr->width) {
1751 if ((x + 1) < modelPtr->width) {
17571752 c += errPtr[-lineLength+3] * 3;
17581753 }
17591754 }
18241819 /*
18251820 * Multibit monochrome window. The operation here is similar
18261821 * to the color window case above, except that there is only
1827 * one component. If the master image is in color, use the
1822 * one component. If the model image is in color, use the
18281823 * luminance computed as
18291824 * 0.344 * red + 0.5 * green + 0.156 * blue.
18301825 */
18361831 c += errPtr[-lineLength-1];
18371832 }
18381833 c += errPtr[-lineLength] * 5;
1839 if (x + 1 < masterPtr->width) {
1834 if (x + 1 < modelPtr->width) {
18401835 c += errPtr[-lineLength+1] * 3;
18411836 }
18421837 }
18431838 c = ((c + 2056) >> 4) - 128;
18441839
1845 if (masterPtr->flags & COLOR_IMAGE) {
1840 if (modelPtr->flags & COLOR_IMAGE) {
18461841 c += (unsigned) (srcPtr[0] * 11 + srcPtr[1] * 16
18471842 + srcPtr[2] * 5 + 16) >> 5;
18481843 } else {
19091904 c += errPtr[-lineLength-1];
19101905 }
19111906 c += errPtr[-lineLength] * 5;
1912 if (x + 1 < masterPtr->width) {
1907 if (x + 1 < modelPtr->width) {
19131908 c += errPtr[-lineLength+1] * 3;
19141909 }
19151910 }
19161911 c = ((c + 2056) >> 4) - 128;
19171912
1918 if (masterPtr->flags & COLOR_IMAGE) {
1913 if (modelPtr->flags & COLOR_IMAGE) {
19191914 c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16
19201915 + srcPtr[2] * 5 + 16) >> 5;
19211916 } else {
19381933 }
19391934 *destLongPtr = word;
19401935 }
1941 srcLinePtr += masterPtr->width * 4;
1936 srcLinePtr += modelPtr->width * 4;
19421937 errLinePtr += lineLength;
19431938 dstLinePtr += bytesPerLine;
19441939 }
100100
101101 static int ImgPhotoCreate(Tcl_Interp *interp, const char *name,
102102 int objc, Tcl_Obj *const objv[],
103 const Tk_ImageType *typePtr, Tk_ImageMaster master,
103 const Tk_ImageType *typePtr, Tk_ImageModel model,
104104 ClientData *clientDataPtr);
105105 static void ImgPhotoDelete(ClientData clientData);
106106 static int ImgPhotoPostscript(ClientData clientData,
151151
152152 static const Tk_ConfigSpec configSpecs[] = {
153153 {TK_CONFIG_STRING, "-file", NULL, NULL,
154 NULL, Tk_Offset(PhotoMaster, fileString), TK_CONFIG_NULL_OK, NULL},
154 NULL, Tk_Offset(PhotoModel, fileString), TK_CONFIG_NULL_OK, NULL},
155155 {TK_CONFIG_DOUBLE, "-gamma", NULL, NULL,
156 DEF_PHOTO_GAMMA, Tk_Offset(PhotoMaster, gamma), 0, NULL},
156 DEF_PHOTO_GAMMA, Tk_Offset(PhotoModel, gamma), 0, NULL},
157157 {TK_CONFIG_INT, "-height", NULL, NULL,
158 DEF_PHOTO_HEIGHT, Tk_Offset(PhotoMaster, userHeight), 0, NULL},
158 DEF_PHOTO_HEIGHT, Tk_Offset(PhotoModel, userHeight), 0, NULL},
159159 {TK_CONFIG_UID, "-palette", NULL, NULL,
160 DEF_PHOTO_PALETTE, Tk_Offset(PhotoMaster, palette), 0, NULL},
160 DEF_PHOTO_PALETTE, Tk_Offset(PhotoModel, palette), 0, NULL},
161161 {TK_CONFIG_INT, "-width", NULL, NULL,
162 DEF_PHOTO_WIDTH, Tk_Offset(PhotoMaster, userWidth), 0, NULL},
162 DEF_PHOTO_WIDTH, Tk_Offset(PhotoModel, userWidth), 0, NULL},
163163 {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
164164 };
165165
175175 Tcl_Interp *interp, int allowedOptions,
176176 int *indexPtr, int objc, Tcl_Obj *const objv[]);
177177 static void ImgPhotoCmdDeletedProc(ClientData clientData);
178 static int ImgPhotoConfigureMaster(Tcl_Interp *interp,
179 PhotoMaster *masterPtr, int objc,
178 static int ImgPhotoConfigureModel(Tcl_Interp *interp,
179 PhotoModel *modelPtr, int objc,
180180 Tcl_Obj *const objv[], int flags);
181 static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr);
182 static int ImgPhotoSetSize(PhotoMaster *masterPtr, int width,
181 static int ToggleComplexAlphaIfNeeded(PhotoModel *mPtr);
182 static int ImgPhotoSetSize(PhotoModel *modelPtr, int width,
183183 int height);
184184 static int ImgStringWrite(Tcl_Interp *interp,
185185 Tcl_Obj *formatString,
186186 Tk_PhotoImageBlock *blockPtr);
187 static char * ImgGetPhoto(PhotoMaster *masterPtr,
187 static char * ImgGetPhoto(PhotoModel *modelPtr,
188188 Tk_PhotoImageBlock *blockPtr,
189189 struct SubcommandOptions *optPtr);
190190 static int MatchFileFormat(Tcl_Interp *interp, Tcl_Channel chan,
215215
216216 static void
217217 PhotoFormatThreadExitProc(
218 ClientData clientData) /* not used */
218 TCL_UNUSED(void *)) /* not used */
219219 {
220220 Tk_PhotoImageFormat *freePtr;
221 ThreadSpecificData *tsdPtr =
221 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
222222 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
223223
224224 while (tsdPtr->oldFormatList != NULL) {
261261 * by caller. */
262262 {
263263 Tk_PhotoImageFormat *copyPtr;
264 ThreadSpecificData *tsdPtr =
264 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
265265 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
266266
267267 if (!tsdPtr->initialized) {
268268 tsdPtr->initialized = 1;
269269 Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
270270 }
271 copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat));
271 copyPtr = (Tk_PhotoImageFormat *)ckalloc(sizeof(Tk_PhotoImageFormat));
272272 *copyPtr = *formatPtr;
273273 copyPtr->nextPtr = tsdPtr->oldFormatList;
274274 tsdPtr->oldFormatList = copyPtr;
282282 * by caller. */
283283 {
284284 Tk_PhotoImageFormat *copyPtr;
285 ThreadSpecificData *tsdPtr =
285 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
286286 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
287287
288288 if (!tsdPtr->initialized) {
289289 tsdPtr->initialized = 1;
290290 Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
291291 }
292 copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat));
292 copyPtr = (Tk_PhotoImageFormat *)ckalloc(sizeof(Tk_PhotoImageFormat));
293293 *copyPtr = *formatPtr;
294294 if (isupper((unsigned char) *formatPtr->name)) {
295295 copyPtr->nextPtr = tsdPtr->oldFormatList;
296296 tsdPtr->oldFormatList = copyPtr;
297297 } else {
298298 /* for compatibility with aMSN: make a copy of formatPtr->name */
299 char *name = ckalloc(strlen(formatPtr->name) + 1);
299 char *name = (char *)ckalloc(strlen(formatPtr->name) + 1);
300300 strcpy(name, formatPtr->name);
301301 copyPtr->name = name;
302302 copyPtr->nextPtr = tsdPtr->formatList;
329329 int objc, /* Number of arguments. */
330330 Tcl_Obj *const objv[], /* Argument objects for options (doesn't
331331 * include image name or type). */
332 const Tk_ImageType *typePtr,/* Pointer to our type record (not used). */
333 Tk_ImageMaster master, /* Token for image, to be used by us in later
332 TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */
333 Tk_ImageModel model, /* Token for image, to be used by us in later
334334 * callbacks. */
335335 ClientData *clientDataPtr) /* Store manager's token for image here; it
336336 * will be returned in later callbacks. */
337337 {
338 PhotoMaster *masterPtr;
338 PhotoModel *modelPtr;
339339
340340 /*
341 * Allocate and initialize the photo image master record.
341 * Allocate and initialize the photo image model record.
342342 */
343343
344 masterPtr = ckalloc(sizeof(PhotoMaster));
345 memset(masterPtr, 0, sizeof(PhotoMaster));
346 masterPtr->tkMaster = master;
347 masterPtr->interp = interp;
348 masterPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgPhotoCmd,
349 masterPtr, ImgPhotoCmdDeletedProc);
350 masterPtr->palette = NULL;
351 masterPtr->pix32 = NULL;
352 masterPtr->instancePtr = NULL;
353 masterPtr->validRegion = TkCreateRegion();
344 modelPtr = (PhotoModel *)ckalloc(sizeof(PhotoModel));
345 memset(modelPtr, 0, sizeof(PhotoModel));
346 modelPtr->tkMaster = model;
347 modelPtr->interp = interp;
348 modelPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgPhotoCmd,
349 modelPtr, ImgPhotoCmdDeletedProc);
350 modelPtr->palette = NULL;
351 modelPtr->pix32 = NULL;
352 modelPtr->instancePtr = NULL;
353 modelPtr->validRegion = TkCreateRegion();
354354
355355 /*
356356 * Process configuration options given in the image create command.
357357 */
358358
359 if (ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, 0) != TCL_OK) {
360 ImgPhotoDelete(masterPtr);
359 if (ImgPhotoConfigureModel(interp, modelPtr, objc, objv, 0) != TCL_OK) {
360 ImgPhotoDelete(modelPtr);
361361 return TCL_ERROR;
362362 }
363363
364 *clientDataPtr = masterPtr;
364 *clientDataPtr = modelPtr;
365365 return TCL_OK;
366366 }
367367
385385
386386 static int
387387 ImgPhotoCmd(
388 ClientData clientData, /* Information about photo master. */
388 ClientData clientData, /* Information about photo model. */
389389 Tcl_Interp *interp, /* Current interpreter. */
390390 int objc, /* Number of arguments. */
391391 Tcl_Obj *const objv[]) /* Argument objects. */
400400 PHOTO_WRITE
401401 };
402402
403 PhotoMaster *masterPtr = clientData;
403 PhotoModel *modelPtr = clientData;
404404 int result, index, x, y, width, height, dataWidth, dataHeight, listObjc;
405405 struct SubcommandOptions options;
406406 Tcl_Obj **listObjv, **srcObjv;
412412 int imageWidth, imageHeight, matched, oldformat = 0;
413413 Tcl_Channel chan;
414414 Tk_PhotoHandle srcHandle;
415 ThreadSpecificData *tsdPtr =
415 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
416416 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
417417
418418 if (objc < 2) {
432432 */
433433
434434 if (objc == 2) {
435 Tk_PhotoBlank(masterPtr);
435 Tk_PhotoBlank(modelPtr);
436436 return TCL_OK;
437437 } else {
438438 Tcl_WrongNumArgs(interp, 2, objv, NULL);
449449 arg = Tcl_GetString(objv[2]);
450450 length = objv[2]->length;
451451 if (strncmp(arg,"-data", length) == 0) {
452 if (masterPtr->dataString) {
453 Tcl_SetObjResult(interp, masterPtr->dataString);
452 if (modelPtr->dataString) {
453 Tcl_SetObjResult(interp, modelPtr->dataString);
454454 }
455455 } else if (strncmp(arg,"-format", length) == 0) {
456 if (masterPtr->format) {
457 Tcl_SetObjResult(interp, masterPtr->format);
456 if (modelPtr->format) {
457 Tcl_SetObjResult(interp, modelPtr->format);
458458 }
459459 } else {
460460 Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
461 (char *) masterPtr, Tcl_GetString(objv[2]), 0);
461 (char *) modelPtr, Tcl_GetString(objv[2]), 0);
462462 }
463463 return TCL_OK;
464464 }
472472 Tcl_Obj *obj, *subobj;
473473
474474 result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
475 configSpecs, (char *) masterPtr, NULL, 0);
475 configSpecs, (char *) modelPtr, NULL, 0);
476476 if (result != TCL_OK) {
477477 return result;
478478 }
479479 obj = Tcl_NewObj();
480480 subobj = Tcl_NewStringObj("-data {} {} {}", 14);
481 if (masterPtr->dataString) {
482 Tcl_ListObjAppendElement(NULL, subobj, masterPtr->dataString);
481 if (modelPtr->dataString) {
482 Tcl_ListObjAppendElement(NULL, subobj, modelPtr->dataString);
483483 } else {
484484 Tcl_AppendStringsToObj(subobj, " {}", NULL);
485485 }
486486 Tcl_ListObjAppendElement(interp, obj, subobj);
487487 subobj = Tcl_NewStringObj("-format {} {} {}", 16);
488 if (masterPtr->format) {
489 Tcl_ListObjAppendElement(NULL, subobj, masterPtr->format);
488 if (modelPtr->format) {
489 Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format);
490490 } else {
491491 Tcl_AppendStringsToObj(subobj, " {}", NULL);
492492 }
501501 length = objv[2]->length;
502502 if (length > 1 && !strncmp(arg, "-data", length)) {
503503 Tcl_AppendResult(interp, "-data {} {} {}", NULL);
504 if (masterPtr->dataString) {
504 if (modelPtr->dataString) {
505505 /*
506506 * TODO: Modifying result is bad!
507507 */
508508
509509 Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
510 masterPtr->dataString);
510 modelPtr->dataString);
511511 } else {
512512 Tcl_AppendResult(interp, " {}", NULL);
513513 }
515515 } else if (length > 1 &&
516516 !strncmp(arg, "-format", length)) {
517517 Tcl_AppendResult(interp, "-format {} {} {}", NULL);
518 if (masterPtr->format) {
518 if (modelPtr->format) {
519519 /*
520520 * TODO: Modifying result is bad!
521521 */
522522
523523 Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
524 masterPtr->format);
524 modelPtr->format);
525525 } else {
526526 Tcl_AppendResult(interp, " {}", NULL);
527527 }
528528 return TCL_OK;
529529 } else {
530530 return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
531 configSpecs, (char *) masterPtr, arg, 0);
531 configSpecs, (char *) modelPtr, arg, 0);
532532 }
533533 } else {
534 return ImgPhotoConfigureMaster(interp, masterPtr, objc-2, objv+2,
534 return ImgPhotoConfigureModel(interp, modelPtr, objc-2, objv+2,
535535 TK_CONFIG_ARGV_ONLY);
536536 }
537537
590590 * has a simple alpha channel.
591591 */
592592
593 if (!(((PhotoMaster *) srcHandle)->flags & COMPLEX_ALPHA)) {
593 if (!(((PhotoModel *) srcHandle)->flags & COMPLEX_ALPHA)) {
594594 options.compositingRule |= SOURCE_IS_SIMPLE_ALPHA_PHOTO;
595595 }
596596
634634 + options.fromY * block.pitch;
635635 block.width = options.fromX2 - options.fromX;
636636 block.height = options.fromY2 - options.fromY;
637 result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) masterPtr,
637 result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) modelPtr,
638638 &block, options.toX, options.toY, options.toX2 - options.toX,
639639 options.toY2 - options.toY, options.zoomX, options.zoomY,
640640 options.subsampleX, options.subsampleY,
648648 */
649649
650650 if (options.options & OPT_SHRINK) {
651 if (ImgPhotoSetSize(masterPtr, options.toX2,
651 if (ImgPhotoSetSize(modelPtr, options.toX2,
652652 options.toY2) != TCL_OK) {
653653 if (options.background) {
654654 Tk_FreeColor(options.background);
659659 return TCL_ERROR;
660660 }
661661 }
662 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
663 masterPtr->width, masterPtr->height);
662 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
663 modelPtr->width, modelPtr->height);
664664 if (options.background) {
665665 Tk_FreeColor(options.background);
666666 }
690690 Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?");
691691 return TCL_ERROR;
692692 }
693 if ((options.fromX > masterPtr->width)
694 || (options.fromY > masterPtr->height)
695 || (options.fromX2 > masterPtr->width)
696 || (options.fromY2 > masterPtr->height)) {
693 if ((options.fromX > modelPtr->width)
694 || (options.fromY > modelPtr->height)
695 || (options.fromX2 > modelPtr->width)
696 || (options.fromY2 > modelPtr->height)) {
697697 Tcl_SetObjResult(interp, Tcl_NewStringObj(
698698 "coordinates for -from option extend outside image", -1));
699699 Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
705705 */
706706
707707 if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) {
708 options.fromX2 = masterPtr->width;
709 options.fromY2 = masterPtr->height;
708 options.fromX2 = modelPtr->width;
709 options.fromY2 = modelPtr->height;
710710 }
711711
712712 /*
758758 * Call the handler's string write function to write out the image.
759759 */
760760
761 data = ImgGetPhoto(masterPtr, &block, &options);
761 data = ImgGetPhoto(modelPtr, &block, &options);
762762
763763 if (oldformat) {
764764 Tcl_DString buffer;
767767 Tk_PhotoImageBlock *blockPtr);
768768
769769 Tcl_DStringInit(&buffer);
770 result = ((OldStringWriteProc) stringWriteProc)(interp, &buffer,
770 result = ((OldStringWriteProc)(void *)stringWriteProc)(interp, &buffer,
771771 Tcl_GetString(options.format), &block);
772772 if (result == TCL_OK) {
773773 Tcl_DStringResult(interp, &buffer);
779779 Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr,
780780 void *dummy);
781781
782 result = ((NewStringWriteProc) stringWriteProc)(interp,
782 result = ((NewStringWriteProc)(void *)stringWriteProc)(interp,
783783 options.format, &block, NULL);
784784 }
785785 if (options.background) {
806806 || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) {
807807 return TCL_ERROR;
808808 }
809 if ((x < 0) || (x >= masterPtr->width)
810 || (y < 0) || (y >= masterPtr->height)) {
809 if ((x < 0) || (x >= modelPtr->width)
810 || (y < 0) || (y >= modelPtr->height)) {
811811 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
812812 "%s get: coordinates out of range",
813813 Tcl_GetString(objv[0])));
817817 }
818818
819819 /*
820 * Extract the value of the desired pixel and format it as a string.
821 */
822
823 pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
820 * Extract the value of the desired pixel and format it as a list.
821 */
822
823 pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
824824 channels[0] = Tcl_NewIntObj(pixelPtr[0]);
825825 channels[1] = Tcl_NewIntObj(pixelPtr[1]);
826826 channels[2] = Tcl_NewIntObj(pixelPtr[2]);
869869 data = (Tcl_Obj *) Tcl_GetString(data);
870870 }
871871 if (imageFormat->stringReadProc(interp, data, format,
872 (Tk_PhotoHandle) masterPtr, options.toX, options.toY,
872 (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
873873 imageWidth, imageHeight, 0, 0) != TCL_OK) {
874874 return TCL_ERROR;
875875 }
876 masterPtr->flags |= IMAGE_CHANGED;
876 modelPtr->flags |= IMAGE_CHANGED;
877877 return TCL_OK;
878878 }
879879 if (options.options & OPT_FORMAT) {
10061006 block.offset[1] = 1;
10071007 block.offset[2] = 2;
10081008 block.offset[3] = 0;
1009 result = Tk_PhotoPutBlock(interp, masterPtr, &block,
1009 result = Tk_PhotoPutBlock(interp, modelPtr, &block,
10101010 options.toX, options.toY, options.toX2 - options.toX,
10111011 options.toY2 - options.toY,
10121012 TK_PHOTO_COMPOSITE_SET);
10991099 */
11001100
11011101 if (options.options & OPT_SHRINK) {
1102 if (ImgPhotoSetSize(masterPtr, options.toX + width,
1102 if (ImgPhotoSetSize(modelPtr, options.toX + width,
11031103 options.toY + height) != TCL_OK) {
11041104 Tcl_ResetResult(interp);
11051105 Tcl_SetObjResult(interp, Tcl_NewStringObj(
11061106 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
11071107 Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
1108 Tcl_Close(NULL, chan);
11081109 return TCL_ERROR;
11091110 }
11101111 }
11201121 }
11211122 result = imageFormat->fileReadProc(interp, chan,
11221123 Tcl_GetString(options.name),
1123 format, (Tk_PhotoHandle) masterPtr, options.toX,
1124 format, (Tk_PhotoHandle) modelPtr, options.toX,
11241125 options.toY, width, height, options.fromX, options.fromY);
11251126 if (chan != NULL) {
11261127 Tcl_Close(NULL, chan);
11391140 * present.
11401141 */
11411142
1142 x = masterPtr->ditherX;
1143 y = masterPtr->ditherY;
1144 if (masterPtr->ditherX != 0) {
1145 Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y,
1146 masterPtr->width - x, 1);
1147 }
1148 if (masterPtr->ditherY < masterPtr->height) {
1143 x = modelPtr->ditherX;
1144 y = modelPtr->ditherY;
1145 if (modelPtr->ditherX != 0) {
1146 Tk_DitherPhoto((Tk_PhotoHandle) modelPtr, x, y,
1147 modelPtr->width - x, 1);
1148 }
1149 if (modelPtr->ditherY < modelPtr->height) {
11491150 x = 0;
1150 Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, 0,
1151 masterPtr->ditherY, masterPtr->width,
1152 masterPtr->height - masterPtr->ditherY);
1153 }
1154
1155 if (y < masterPtr->height) {
1151 Tk_DitherPhoto((Tk_PhotoHandle)modelPtr, 0,
1152 modelPtr->ditherY, modelPtr->width,
1153 modelPtr->height - modelPtr->ditherY);
1154 }
1155
1156 if (y < modelPtr->height) {
11561157 /*
11571158 * Tell the core image code that part of the image has changed.
11581159 */
11591160
1160 Tk_ImageChanged(masterPtr->tkMaster, x, y,
1161 (masterPtr->width - x), (masterPtr->height - y),
1162 masterPtr->width, masterPtr->height);
1161 Tk_ImageChanged(modelPtr->tkMaster, x, y,
1162 (modelPtr->width - x), (modelPtr->height - y),
1163 modelPtr->width, modelPtr->height);
11631164 }
11641165 return TCL_OK;
11651166
11931194 || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) {
11941195 return TCL_ERROR;
11951196 }
1196 if ((x < 0) || (x >= masterPtr->width)
1197 || (y < 0) || (y >= masterPtr->height)) {
1197 if ((x < 0) || (x >= modelPtr->width)
1198 || (y < 0) || (y >= modelPtr->height)) {
11981199 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11991200 "%s transparency get: coordinates out of range",
12001201 Tcl_GetString(objv[0])));
12101211 /* What a way to do a test! */
12111212 testRegion = TkCreateRegion();
12121213 TkUnionRectWithRegion(&testBox, testRegion, testRegion);
1213 TkIntersectRegion(testRegion, masterPtr->validRegion, testRegion);
1214 TkIntersectRegion(testRegion, modelPtr->validRegion, testRegion);
12141215 TkClipBox(testRegion, &testBox);
12151216 TkDestroyRegion(testRegion);
12161217
12331234 &transFlag) != TCL_OK)) {
12341235 return TCL_ERROR;
12351236 }
1236 if ((x < 0) || (x >= masterPtr->width)
1237 || (y < 0) || (y >= masterPtr->height)) {
1237 if ((x < 0) || (x >= modelPtr->width)
1238 || (y < 0) || (y >= modelPtr->height)) {
12381239 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
12391240 "%s transparency set: coordinates out of range",
12401241 Tcl_GetString(objv[0])));
12471248 setBox.y = y;
12481249 setBox.width = 1;
12491250 setBox.height = 1;
1250 pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
1251 pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
12511252
12521253 if (transFlag) {
12531254 /*
12571258 TkRegion clearRegion = TkCreateRegion();
12581259
12591260 TkUnionRectWithRegion(&setBox, clearRegion, clearRegion);
1260 TkSubtractRegion(masterPtr->validRegion, clearRegion,
1261 masterPtr->validRegion);
1261 TkSubtractRegion(modelPtr->validRegion, clearRegion,
1262 modelPtr->validRegion);
12621263 TkDestroyRegion(clearRegion);
12631264
12641265 /*
12711272 * Make pixel opaque.
12721273 */
12731274
1274 TkUnionRectWithRegion(&setBox, masterPtr->validRegion,
1275 masterPtr->validRegion);
1275 TkUnionRectWithRegion(&setBox, modelPtr->validRegion,
1276 modelPtr->validRegion);
12761277 pixelPtr[3] = 255;
12771278 }
12781279
12811282 * has (potentially) changed.
12821283 */
12831284
1284 Tk_ImageChanged(masterPtr->tkMaster, x, y, 1, 1,
1285 masterPtr->width, masterPtr->height);
1286 masterPtr->flags &= ~IMAGE_CHANGED;
1285 Tk_ImageChanged(modelPtr->tkMaster, x, y, 1, 1,
1286 modelPtr->width, modelPtr->height);
1287 modelPtr->flags &= ~IMAGE_CHANGED;
12871288 return TCL_OK;
12881289 }
12891290
13251326 Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
13261327 return TCL_ERROR;
13271328 }
1328 if ((options.fromX > masterPtr->width)
1329 || (options.fromY > masterPtr->height)
1330 || (options.fromX2 > masterPtr->width)
1331 || (options.fromY2 > masterPtr->height)) {
1329 if ((options.fromX > modelPtr->width)
1330 || (options.fromY > modelPtr->height)
1331 || (options.fromX2 > modelPtr->width)
1332 || (options.fromY2 > modelPtr->height)) {
13321333 Tcl_SetObjResult(interp, Tcl_NewStringObj(
13331334 "coordinates for -from option extend outside image", -1));
13341335 Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
13421343 */
13431344
13441345 if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) {
1345 options.fromX2 = masterPtr->width;
1346 options.fromY2 = masterPtr->height;
1346 options.fromX2 = modelPtr->width;
1347 options.fromY2 = modelPtr->height;
13471348 }
13481349 if (options.format == NULL) {
13491350 fmtString = GetExtension(Tcl_GetString(options.name));
14181419 * Call the handler's file write function to write out the image.
14191420 */
14201421
1421 data = ImgGetPhoto(masterPtr, &block, &options);
1422 data = ImgGetPhoto(modelPtr, &block, &options);
14221423 format = options.format;
14231424 if (oldformat && format) {
14241425 format = (Tcl_Obj *) Tcl_GetString(options.format);
17571758 /*
17581759 *----------------------------------------------------------------------
17591760 *
1760 * ImgPhotoConfigureMaster --
1761 * ImgPhotoConfigureModel --
17611762 *
17621763 * This function is called when a photo image is created or reconfigured.
17631764 * It processes configuration options and resets any instances of the
17651766 *
17661767 * Results:
17671768 * A standard Tcl return value. If TCL_ERROR is returned then an error
1768 * message is left in the masterPtr->interp's result.
1769 * message is left in the modelPtr->interp's result.
17691770 *
17701771 * Side effects:
17711772 * Existing instances of the image will be redisplayed to match the new
17751776 */
17761777
17771778 static int
1778 ImgPhotoConfigureMaster(
1779 ImgPhotoConfigureModel(
17791780 Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
1780 PhotoMaster *masterPtr, /* Pointer to data structure describing
1781 PhotoModel *modelPtr, /* Pointer to data structure describing
17811782 * overall photo image to (re)configure. */
17821783 int objc, /* Number of entries in objv. */
17831784 Tcl_Obj *const objv[], /* Pairs of configuration options for image. */
17951796 Tk_PhotoImageFormat *imageFormat;
17961797 const char **args;
17971798
1798 args = ckalloc((objc + 1) * sizeof(char *));
1799 args = (const char **)ckalloc((objc + 1) * sizeof(char *));
17991800 for (i = 0, j = 0; i < objc; i++,j++) {
18001801 args[j] = Tcl_GetString(objv[i]);
18011802 length = objv[i]->length;
18371838 * the format string influences how "-data" or "-file" is interpreted.
18381839 */
18391840
1840 oldFileString = masterPtr->fileString;
1841 oldFileString = modelPtr->fileString;
18411842 if (oldFileString == NULL) {
1842 oldData = masterPtr->dataString;
1843 oldData = modelPtr->dataString;
18431844 if (oldData != NULL) {
18441845 Tcl_IncrRefCount(oldData);
18451846 }
18461847 } else {
18471848 oldData = NULL;
18481849 }
1849 oldFormat = masterPtr->format;
1850 oldFormat = modelPtr->format;
18501851 if (oldFormat != NULL) {
18511852 Tcl_IncrRefCount(oldFormat);
18521853 }
1853 oldPaletteString = masterPtr->palette;
1854 oldGamma = masterPtr->gamma;
1854 oldPaletteString = modelPtr->palette;
1855 oldGamma = modelPtr->gamma;
18551856
18561857 /*
18571858 * Process the configuration options specified.
18581859 */
18591860
18601861 if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs,
1861 j, args, (char *) masterPtr, flags) != TCL_OK) {
1862 j, args, (char *) modelPtr, flags) != TCL_OK) {
18621863 ckfree(args);
18631864 goto errorExit;
18641865 }
18681869 * Regard the empty string for -file, -data or -format as the null value.
18691870 */
18701871
1871 if ((masterPtr->fileString != NULL) && (masterPtr->fileString[0] == 0)) {
1872 ckfree(masterPtr->fileString);
1873 masterPtr->fileString = NULL;
1872 if ((modelPtr->fileString != NULL) && (modelPtr->fileString[0] == 0)) {
1873 ckfree(modelPtr->fileString);
1874 modelPtr->fileString = NULL;
18741875 }
18751876 if (data) {
18761877 /*
18851886 } else {
18861887 data = NULL;
18871888 }
1888 if (masterPtr->dataString) {
1889 Tcl_DecrRefCount(masterPtr->dataString);
1890 }
1891 masterPtr->dataString = data;
1889 if (modelPtr->dataString) {
1890 Tcl_DecrRefCount(modelPtr->dataString);
1891 }
1892 modelPtr->dataString = data;
18921893 }
18931894 if (format) {
18941895 /*
19021903 } else {
19031904 format = NULL;
19041905 }
1905 if (masterPtr->format) {
1906 Tcl_DecrRefCount(masterPtr->format);
1907 }
1908 masterPtr->format = format;
1906 if (modelPtr->format) {
1907 Tcl_DecrRefCount(modelPtr->format);
1908 }
1909 modelPtr->format = format;
19091910 }
19101911 /*
19111912 * Set the image to the user-requested size, if any, and make sure storage
19121913 * is correctly allocated for this image.
19131914 */
19141915
1915 if (ImgPhotoSetSize(masterPtr, masterPtr->width,
1916 masterPtr->height) != TCL_OK) {
1916 if (ImgPhotoSetSize(modelPtr, modelPtr->width,
1917 modelPtr->height) != TCL_OK) {
19171918 Tcl_SetObjResult(interp, Tcl_NewStringObj(
19181919 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
19191920 Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
19251926 * -file or -data option.
19261927 */
19271928
1928 if ((masterPtr->fileString != NULL)
1929 && ((masterPtr->fileString != oldFileString)
1930 || (masterPtr->format != oldFormat))) {
1929 if ((modelPtr->fileString != NULL)
1930 && ((modelPtr->fileString != oldFileString)
1931 || (modelPtr->format != oldFormat))) {
19311932 /*
19321933 * Prevent file system access in a safe interpreter.
19331934 */
19411942 goto errorExit;
19421943 }
19431944
1944 chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0);
1945 chan = Tcl_OpenFileChannel(interp, modelPtr->fileString, "r", 0);
19451946 if (chan == NULL) {
19461947 goto errorExit;
19471948 }
19521953
19531954 if ((Tcl_SetChannelOption(interp, chan,
19541955 "-translation", "binary") != TCL_OK) ||
1955 (MatchFileFormat(interp, chan, masterPtr->fileString,
1956 masterPtr->format, &imageFormat, &imageWidth,
1956 (MatchFileFormat(interp, chan, modelPtr->fileString,
1957 modelPtr->format, &imageFormat, &imageWidth,
19571958 &imageHeight, &oldformat) != TCL_OK)) {
19581959 Tcl_Close(NULL, chan);
19591960 goto errorExit;
19601961 }
1961 result = ImgPhotoSetSize(masterPtr, imageWidth, imageHeight);
1962 result = ImgPhotoSetSize(modelPtr, imageWidth, imageHeight);
19621963 if (result != TCL_OK) {
19631964 Tcl_Close(NULL, chan);
19641965 Tcl_SetObjResult(interp, Tcl_NewStringObj(
19661967 Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
19671968 goto errorExit;
19681969 }
1969 tempformat = masterPtr->format;
1970 tempformat = modelPtr->format;
19701971 if (oldformat && tempformat) {
19711972 tempformat = (Tcl_Obj *) Tcl_GetString(tempformat);
19721973 }
19731974 result = imageFormat->fileReadProc(interp, chan,
1974 masterPtr->fileString, tempformat, (Tk_PhotoHandle) masterPtr,
1975 modelPtr->fileString, tempformat, (Tk_PhotoHandle) modelPtr,
19751976 0, 0, imageWidth, imageHeight, 0, 0);
19761977 Tcl_Close(NULL, chan);
19771978 if (result != TCL_OK) {
19791980 }
19801981
19811982 Tcl_ResetResult(interp);
1982 masterPtr->flags |= IMAGE_CHANGED;
1983 }
1984
1985 if ((masterPtr->fileString == NULL) && (masterPtr->dataString != NULL)
1986 && ((masterPtr->dataString != oldData)
1987 || (masterPtr->format != oldFormat))) {
1988
1989 if (MatchStringFormat(interp, masterPtr->dataString,
1990 masterPtr->format, &imageFormat, &imageWidth,
1983 modelPtr->flags |= IMAGE_CHANGED;
1984 }
1985
1986 if ((modelPtr->fileString == NULL) && (modelPtr->dataString != NULL)
1987 && ((modelPtr->dataString != oldData)
1988 || (modelPtr->format != oldFormat))) {
1989
1990 if (MatchStringFormat(interp, modelPtr->dataString,
1991 modelPtr->format, &imageFormat, &imageWidth,
19911992 &imageHeight, &oldformat) != TCL_OK) {
19921993 goto errorExit;
19931994 }
1994 if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) {
1995 if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) {
19951996 Tcl_SetObjResult(interp, Tcl_NewStringObj(
19961997 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
19971998 Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
19981999 goto errorExit;
19992000 }
2000 tempformat = masterPtr->format;
2001 tempdata = masterPtr->dataString;
2001 tempformat = modelPtr->format;
2002 tempdata = modelPtr->dataString;
20022003 if (oldformat) {
20032004 if (tempformat) {
20042005 tempformat = (Tcl_Obj *) Tcl_GetString(tempformat);
20062007 tempdata = (Tcl_Obj *) Tcl_GetString(tempdata);
20072008 }
20082009 if (imageFormat->stringReadProc(interp, tempdata, tempformat,
2009 (Tk_PhotoHandle) masterPtr, 0, 0, imageWidth, imageHeight,
2010 (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight,
20102011 0, 0) != TCL_OK) {
20112012 goto errorExit;
20122013 }
20132014
20142015 Tcl_ResetResult(interp);
2015 masterPtr->flags |= IMAGE_CHANGED;
2016 modelPtr->flags |= IMAGE_CHANGED;
20162017 }
20172018
20182019 /*
20192020 * Enforce a reasonable value for gamma.
20202021 */
20212022
2022 if (masterPtr->gamma <= 0) {
2023 masterPtr->gamma = 1.0;
2024 }
2025
2026 if ((masterPtr->gamma != oldGamma)
2027 || (masterPtr->palette != oldPaletteString)) {
2028 masterPtr->flags |= IMAGE_CHANGED;
2023 if (modelPtr->gamma <= 0) {
2024 modelPtr->gamma = 1.0;
2025 }
2026
2027 if ((modelPtr->gamma != oldGamma)
2028 || (modelPtr->palette != oldPaletteString)) {
2029 modelPtr->flags |= IMAGE_CHANGED;
20292030 }
20302031
20312032 /*
20342035 * everywhere that it is used.
20352036 */
20362037
2037 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
2038 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
20382039 instancePtr = instancePtr->nextPtr) {
20392040 TkImgPhotoConfigureInstance(instancePtr);
20402041 }
20432044 * Inform the generic image code that the image has (potentially) changed.
20442045 */
20452046
2046 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
2047 masterPtr->height, masterPtr->width, masterPtr->height);
2048 masterPtr->flags &= ~IMAGE_CHANGED;
2047 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, modelPtr->width,
2048 modelPtr->height, modelPtr->width, modelPtr->height);
2049 modelPtr->flags &= ~IMAGE_CHANGED;
20492050
20502051 if (oldData != NULL) {
20512052 Tcl_DecrRefCount(oldData);
20542055 Tcl_DecrRefCount(oldFormat);
20552056 }
20562057
2057 ToggleComplexAlphaIfNeeded(masterPtr);
2058 ToggleComplexAlphaIfNeeded(modelPtr);
20582059
20592060 return TCL_OK;
20602061
20812082 * None.
20822083 *
20832084 * Side effects:
2084 * (Re)sets COMPLEX_ALPHA flag of master.
2085 * (Re)sets COMPLEX_ALPHA flag of model.
20852086 *
20862087 *----------------------------------------------------------------------
20872088 */
20882089
20892090 static int
20902091 ToggleComplexAlphaIfNeeded(
2091 PhotoMaster *mPtr)
2092 PhotoModel *mPtr)
20922093 {
20932094 size_t len = (size_t)MAX(mPtr->userWidth, mPtr->width) *
20942095 (size_t)MAX(mPtr->userHeight, mPtr->height) * 4;
21192120 *
21202121 * ImgPhotoDelete --
21212122 *
2122 * This function is called by the image code to delete the master
2123 * This function is called by the image code to delete the model
21232124 * structure for an image.
21242125 *
21252126 * Results:
21332134
21342135 static void
21352136 ImgPhotoDelete(
2136 ClientData masterData) /* Pointer to PhotoMaster structure for image.
2137 ClientData modelData) /* Pointer to PhotoModel structure for image.
21372138 * Must not have any more instances. */
21382139 {
2139 PhotoMaster *masterPtr = masterData;
2140 PhotoModel *modelPtr = (PhotoModel *)modelData;
21402141 PhotoInstance *instancePtr;
21412142
2142 while ((instancePtr = masterPtr->instancePtr) != NULL) {
2143 while ((instancePtr = modelPtr->instancePtr) != NULL) {
21432144 if (instancePtr->refCount > 0) {
21442145 Tcl_Panic("tried to delete photo image when instances still exist");
21452146 }
21462147 Tcl_CancelIdleCall(TkImgDisposeInstance, instancePtr);
21472148 TkImgDisposeInstance(instancePtr);
21482149 }
2149 masterPtr->tkMaster = NULL;
2150 if (masterPtr->imageCmd != NULL) {
2151 Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd);
2152 }
2153 if (masterPtr->pix32 != NULL) {
2154 ckfree(masterPtr->pix32);
2155 }
2156 if (masterPtr->validRegion != NULL) {
2157 TkDestroyRegion(masterPtr->validRegion);
2158 }
2159 if (masterPtr->dataString != NULL) {
2160 Tcl_DecrRefCount(masterPtr->dataString);
2161 }
2162 if (masterPtr->format != NULL) {
2163 Tcl_DecrRefCount(masterPtr->format);
2164 }
2165 Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0);
2166 ckfree(masterPtr);
2150 modelPtr->tkMaster = NULL;
2151 if (modelPtr->imageCmd != NULL) {
2152 Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd);
2153 }
2154 if (modelPtr->pix32 != NULL) {
2155 ckfree(modelPtr->pix32);
2156 }
2157 if (modelPtr->validRegion != NULL) {
2158 TkDestroyRegion(modelPtr->validRegion);
2159 }
2160 if (modelPtr->dataString != NULL) {
2161 Tcl_DecrRefCount(modelPtr->dataString);
2162 }
2163 if (modelPtr->format != NULL) {
2164 Tcl_DecrRefCount(modelPtr->format);
2165 }
2166 Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0);
2167 ckfree(modelPtr);
21672168 }
21682169
21692170 /*
21852186
21862187 static void
21872188 ImgPhotoCmdDeletedProc(
2188 ClientData clientData) /* Pointer to PhotoMaster structure for
2189 ClientData clientData) /* Pointer to PhotoModel structure for
21892190 * image. */
21902191 {
2191 PhotoMaster *masterPtr = clientData;
2192
2193 masterPtr->imageCmd = NULL;
2194 if (masterPtr->tkMaster != NULL) {
2195 Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster));
2192 PhotoModel *modelPtr = (PhotoModel *)clientData;
2193
2194 modelPtr->imageCmd = NULL;
2195 if (modelPtr->tkMaster != NULL) {
2196 Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkMaster));
21962197 }
21972198 }
21982199
22102211 * with memory allocation.)
22112212 *
22122213 * Side effects:
2213 * Storage gets reallocated, for the master and all its instances.
2214 * Storage gets reallocated, for the model and all its instances.
22142215 *
22152216 *----------------------------------------------------------------------
22162217 */
22172218
22182219 static int
22192220 ImgPhotoSetSize(
2220 PhotoMaster *masterPtr,
2221 PhotoModel *modelPtr,
22212222 int width, int height)
22222223 {
22232224 unsigned char *newPix32 = NULL;
22272228 TkRegion clipRegion;
22282229 PhotoInstance *instancePtr;
22292230
2230 if (masterPtr->userWidth > 0) {
2231 width = masterPtr->userWidth;
2232 }
2233 if (masterPtr->userHeight > 0) {
2234 height = masterPtr->userHeight;
2231 if (modelPtr->userWidth > 0) {
2232 width = modelPtr->userWidth;
2233 }
2234 if (modelPtr->userHeight > 0) {
2235 height = modelPtr->userHeight;
22352236 }
22362237
22372238 if (width > INT_MAX / 4) {
22452246 * failures will leave the photo unchanged.
22462247 */
22472248
2248 if ((width != masterPtr->width) || (height != masterPtr->height)
2249 || (masterPtr->pix32 == NULL)) {
2249 if ((width != modelPtr->width) || (height != modelPtr->height)
2250 || (modelPtr->pix32 == NULL)) {
22502251 unsigned newPixSize;
22512252
22522253 if (pitch && height > (int)(UINT_MAX / pitch)) {
22612262 if (newPixSize == 0) {
22622263 newPix32 = NULL;
22632264 } else {
2264 newPix32 = attemptckalloc(newPixSize);
2265 newPix32 = (unsigned char *)attemptckalloc(newPixSize);
22652266 if (newPix32 == NULL) {
22662267 return TCL_ERROR;
22672268 }
22732274 * image size.
22742275 */
22752276
2276 TkClipBox(masterPtr->validRegion, &validBox);
2277 TkClipBox(modelPtr->validRegion, &validBox);
22772278 if ((validBox.x + validBox.width > width)
22782279 || (validBox.y + validBox.height > height)) {
22792280 clipBox.x = 0;
22822283 clipBox.height = height;
22832284 clipRegion = TkCreateRegion();
22842285 TkUnionRectWithRegion(&clipBox, clipRegion, clipRegion);
2285 TkIntersectRegion(masterPtr->validRegion, clipRegion,
2286 masterPtr->validRegion);
2286 TkIntersectRegion(modelPtr->validRegion, clipRegion,
2287 modelPtr->validRegion);
22872288 TkDestroyRegion(clipRegion);
2288 TkClipBox(masterPtr->validRegion, &validBox);
2289 TkClipBox(modelPtr->validRegion, &validBox);
22892290 }
22902291
22912292 /*
23012302 * or written to a file.
23022303 */
23032304
2304 if ((masterPtr->pix32 != NULL)
2305 && ((width == masterPtr->width) || (width == validBox.width))) {
2305 if ((modelPtr->pix32 != NULL)
2306 && ((width == modelPtr->width) || (width == validBox.width))) {
23062307 if (validBox.y > 0) {
23072308 memset(newPix32, 0, ((size_t) validBox.y * pitch));
23082309 }
23142315 memset(newPix32, 0, ((size_t)height * pitch));
23152316 }
23162317
2317 if (masterPtr->pix32 != NULL) {
2318 if (modelPtr->pix32 != NULL) {
23182319 /*
23192320 * Copy the common area over to the new array array and free the
23202321 * old array.
23212322 */
23222323
2323 if (width == masterPtr->width) {
2324 if (width == modelPtr->width) {
23242325
23252326 /*
23262327 * The region to be copied is contiguous.
23272328 */
23282329
23292330 offset = validBox.y * pitch;
2330 memcpy(newPix32 + offset, masterPtr->pix32 + offset,
2331 memcpy(newPix32 + offset, modelPtr->pix32 + offset,
23312332 ((size_t)validBox.height * pitch));
23322333
23332334 } else if ((validBox.width > 0) && (validBox.height > 0)) {
23362337 */
23372338
23382339 destPtr = newPix32 + (validBox.y * width + validBox.x) * 4;
2339 srcPtr = masterPtr->pix32 + (validBox.y * masterPtr->width
2340 srcPtr = modelPtr->pix32 + (validBox.y * modelPtr->width
23402341 + validBox.x) * 4;
23412342 for (h = validBox.height; h > 0; h--) {
23422343 memcpy(destPtr, srcPtr, ((size_t)validBox.width * 4));
23432344 destPtr += width * 4;
2344 srcPtr += masterPtr->width * 4;
2345 srcPtr += modelPtr->width * 4;
23452346 }
23462347 }
23472348
2348 ckfree(masterPtr->pix32);
2349 }
2350
2351 masterPtr->pix32 = newPix32;
2352 masterPtr->width = width;
2353 masterPtr->height = height;
2349 ckfree(modelPtr->pix32);
2350 }
2351
2352 modelPtr->pix32 = newPix32;
2353 modelPtr->width = width;
2354 modelPtr->height = height;
23542355
23552356 /*
23562357 * Dithering will be correct up to the end of the last pre-existing
23582359 */
23592360
23602361 if ((validBox.x > 0) || (validBox.y > 0)) {
2361 masterPtr->ditherX = 0;
2362 masterPtr->ditherY = 0;
2362 modelPtr->ditherX = 0;
2363 modelPtr->ditherY = 0;
23632364 } else if (validBox.width == width) {
2364 if ((int) validBox.height < masterPtr->ditherY) {
2365 masterPtr->ditherX = 0;
2366 masterPtr->ditherY = validBox.height;
2367 }
2368 } else if ((masterPtr->ditherY > 0)
2369 || ((int) validBox.width < masterPtr->ditherX)) {
2370 masterPtr->ditherX = validBox.width;
2371 masterPtr->ditherY = 0;
2372 }
2373 }
2374
2375 ToggleComplexAlphaIfNeeded(masterPtr);
2365 if ((int) validBox.height < modelPtr->ditherY) {
2366 modelPtr->ditherX = 0;
2367 modelPtr->ditherY = validBox.height;
2368 }
2369 } else if ((modelPtr->ditherY > 0)
2370 || ((int) validBox.width < modelPtr->ditherX)) {
2371 modelPtr->ditherX = validBox.width;
2372 modelPtr->ditherY = 0;
2373 }
2374 }
2375
2376 ToggleComplexAlphaIfNeeded(modelPtr);
23762377
23772378 /*
23782379 * Now adjust the sizes of the pixmaps for all of the instances.
23792380 */
23802381
2381 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
2382 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
23822383 instancePtr = instancePtr->nextPtr) {
23832384 TkImgPhotoInstanceSetSize(instancePtr);
23842385 }
24242425 {
24252426 int matched = 0, useoldformat = 0;
24262427 Tk_PhotoImageFormat *formatPtr;
2427 ThreadSpecificData *tsdPtr =
2428 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
24282429 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
24292430 const char *formatString = NULL;
24302431
25642565 {
25652566 int matched = 0, useoldformat = 0;
25662567 Tk_PhotoImageFormat *formatPtr;
2567 ThreadSpecificData *tsdPtr =
2568 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
25682569 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
25692570 const char *formatString = NULL;
25702571
26572658 * Tk_FindPhoto --
26582659 *
26592660 * This function is called to get an opaque handle (actually a
2660 * PhotoMaster *) for a given image, which can be used in subsequent
2661 * PhotoModel *) for a given image, which can be used in subsequent
26612662 * calls to Tk_PhotoPutBlock, etc. The `name' parameter is the name of
26622663 * the image.
26632664 *
27222723 int compRule) /* Compositing rule to use when processing
27232724 * transparent pixels. */
27242725 {
2725 register PhotoMaster *masterPtr = (PhotoMaster *) handle;
2726 PhotoModel *modelPtr = (PhotoModel *) handle;
27262727 Tk_PhotoImageBlock sourceBlock;
27272728 unsigned char *memToFree;
27282729 int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
27412742
27422743 compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO;
27432744
2744 if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) {
2745 width = masterPtr->userWidth - x;
2746 }
2747 if ((masterPtr->userHeight != 0)
2748 && ((y + height) > masterPtr->userHeight)) {
2749 height = masterPtr->userHeight - y;
2745 if ((modelPtr->userWidth != 0) && ((x + width) > modelPtr->userWidth)) {
2746 width = modelPtr->userWidth - x;
2747 }
2748 if ((modelPtr->userHeight != 0)
2749 && ((y + height) > modelPtr->userHeight)) {
2750 height = modelPtr->userHeight - y;
27502751 }
27512752 if ((width <= 0) || (height <= 0)) {
27522753 return TCL_OK;
27672768 */
27682769 sourceBlock = *blockPtr;
27692770 memToFree = NULL;
2770 if (sourceBlock.pixelPtr >= masterPtr->pix32
2771 && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
2772 * masterPtr->height * 4) {
2773 sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
2774 * sourceBlock.pitch);
2771 if (sourceBlock.pixelPtr >= modelPtr->pix32
2772 && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width
2773 * modelPtr->height * 4) {
2774 /*
2775 * Fix 5c51be6411: avoid reading
2776 *
2777 * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
2778 *
2779 * bytes past the end of modelPtr->pix32[] when
2780 *
2781 * blockPtr->pixelPtr > (modelPtr->pix32 +
2782 * 4 * modelPtr->width * modelPtr->height -
2783 * sourceBlock.height * sourceBlock.pitch)
2784 */
2785 unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch +
2786 sourceBlock.width * sourceBlock.pixelSize;
2787
2788 sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(cpyLen);
27752789 if (sourceBlock.pixelPtr == NULL) {
27762790 if (interp != NULL) {
27772791 Tcl_SetObjResult(interp, Tcl_NewStringObj(
27812795 return TCL_ERROR;
27822796 }
27832797 memToFree = sourceBlock.pixelPtr;
2784 memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
2785 * sourceBlock.pitch);
2798 memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, cpyLen);
27862799 }
27872800
27882801
27892802 xEnd = x + width;
27902803 yEnd = y + height;
2791 if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
2792 if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
2793 MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
2804 if ((xEnd > modelPtr->width) || (yEnd > modelPtr->height)) {
2805 if (ImgPhotoSetSize(modelPtr, MAX(xEnd, modelPtr->width),
2806 MAX(yEnd, modelPtr->height)) == TCL_ERROR) {
27942807 if (interp != NULL) {
27952808 Tcl_SetObjResult(interp, Tcl_NewStringObj(
27962809 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
28002813 }
28012814 }
28022815
2803 if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
2804 && (x < masterPtr->ditherX))) {
2816 if ((y < modelPtr->ditherY) || ((y == modelPtr->ditherY)
2817 && (x < modelPtr->ditherX))) {
28052818 /*
28062819 * The dithering isn't correct past the start of this block.
28072820 */
28082821
2809 masterPtr->ditherX = x;
2810 masterPtr->ditherY = y;
2822 modelPtr->ditherX = x;
2823 modelPtr->ditherY = y;
28112824 }
28122825
28132826 /*
28252838 alphaOffset -= sourceBlock.offset[0];
28262839 }
28272840 if ((greenOffset != 0) || (blueOffset != 0)) {
2828 masterPtr->flags |= COLOR_IMAGE;
2841 modelPtr->flags |= COLOR_IMAGE;
28292842 }
28302843
28312844 /*
28332846 * single memmove, we do.
28342847 */
28352848
2836 destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
2837 pitch = masterPtr->width * 4;
2849 destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
2850 pitch = modelPtr->width * 4;
28382851
28392852 /*
28402853 * Test to see if we can do the whole write in a single copy. This test is
28452858 if ((sourceBlock.pixelSize == 4)
28462859 && (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3)
28472860 && (width <= sourceBlock.width) && (height <= sourceBlock.height)
2848 && ((height == 1) || ((x == 0) && (width == masterPtr->width)
2861 && ((height == 1) || ((x == 0) && (width == modelPtr->width)
28492862 && (sourceBlock.pitch == pitch)))
28502863 && (compRule == TK_PHOTO_COMPOSITE_SET)) {
28512864 memmove(destLinePtr, sourceBlock.pixelPtr + sourceBlock.offset[0],
30273040 rect.width = width;
30283041 rect.height = height;
30293042 TkUnionRectWithRegion(&rect, workRgn, workRgn);
3030 TkSubtractRegion(masterPtr->validRegion, workRgn,
3031 masterPtr->validRegion);
3043 TkSubtractRegion(modelPtr->validRegion, workRgn,
3044 modelPtr->validRegion);
30323045 TkDestroyRegion(workRgn);
30333046 }
30343047
30373050 * allow for more efficient per-platform implementations. [Bug 919066]
30383051 */
30393052
3040 TkpBuildRegionFromAlphaData(masterPtr->validRegion, (unsigned) x,
3053 TkpBuildRegionFromAlphaData(modelPtr->validRegion, (unsigned) x,
30413054 (unsigned) y, (unsigned) width, (unsigned) height,
3042 masterPtr->pix32 + (y * masterPtr->width + x) * 4 + 3,
3043 4, (unsigned) masterPtr->width * 4);
3055 modelPtr->pix32 + (y * modelPtr->width + x) * 4 + 3,
3056 4, (unsigned) modelPtr->width * 4);
30443057 } else {
30453058 rect.x = x;
30463059 rect.y = y;
30473060 rect.width = width;
30483061 rect.height = height;
3049 TkUnionRectWithRegion(&rect, masterPtr->validRegion,
3050 masterPtr->validRegion);
3062 TkUnionRectWithRegion(&rect, modelPtr->validRegion,
3063 modelPtr->validRegion);
30513064 }
30523065
30533066 /*
30623075 * [Patch 1539990]
30633076 */
30643077
3065 if (!(masterPtr->flags & COMPLEX_ALPHA)) {
3066 register int x1;
3078 if (!(modelPtr->flags & COMPLEX_ALPHA)) {
3079 int x1;
30673080
30683081 for (x1=x ; x1<x+width ; x1++) {
3069 register unsigned char newAlpha;
3070
3071 destLinePtr = masterPtr->pix32 + (y*masterPtr->width + x1)*4;
3082 unsigned char newAlpha;
3083
3084 destLinePtr = modelPtr->pix32 + (y*modelPtr->width + x1)*4;
30723085 newAlpha = destLinePtr[3];
30733086 if (newAlpha && newAlpha != 255) {
3074 masterPtr->flags |= COMPLEX_ALPHA;
3087 modelPtr->flags |= COMPLEX_ALPHA;
30753088 break;
30763089 }
30773090 }
30783091 }
3079 } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) {
3092 } else if ((alphaOffset != 0) || (modelPtr->flags & COMPLEX_ALPHA)) {
30803093 /*
30813094 * Check for partial transparency if alpha pixels are specified, or
30823095 * rescan if we already knew such pixels existed. To restrict this
30843097 * the alpha pixels are.
30853098 */
30863099
3087 ToggleComplexAlphaIfNeeded(masterPtr);
3100 ToggleComplexAlphaIfNeeded(modelPtr);
30883101 }
30893102
30903103 /*
30913104 * Update each instance.
30923105 */
30933106
3094 Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, x, y, width, height);
3107 Tk_DitherPhoto((Tk_PhotoHandle)modelPtr, x, y, width, height);
30953108
30963109 /*
30973110 * Tell the core image code that this image has changed.
30983111 */
30993112
3100 Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height,
3101 masterPtr->width, masterPtr->height);
3113 Tk_ImageChanged(modelPtr->tkMaster, x, y, width, height,
3114 modelPtr->width, modelPtr->height);
31023115
31033116 if (memToFree) ckfree(memToFree);
31043117
31483161 int compRule) /* Compositing rule to use when processing
31493162 * transparent pixels. */
31503163 {
3151 register PhotoMaster *masterPtr = (PhotoMaster *) handle;
3152 register Tk_PhotoImageBlock sourceBlock;
3164 PhotoModel *modelPtr = (PhotoModel *) handle;
3165 Tk_PhotoImageBlock sourceBlock;
31533166 unsigned char *memToFree;
31543167 int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
31553168 int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt;
31763189 if (zoomX <= 0 || zoomY <= 0) {
31773190 return TCL_OK;
31783191 }
3179 if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) {
3180 width = masterPtr->userWidth - x;
3181 }
3182 if ((masterPtr->userHeight != 0)
3183 && ((y + height) > masterPtr->userHeight)) {
3184 height = masterPtr->userHeight - y;
3192 if ((modelPtr->userWidth != 0) && ((x + width) > modelPtr->userWidth)) {
3193 width = modelPtr->userWidth - x;
3194 }
3195 if ((modelPtr->userHeight != 0)
3196 && ((y + height) > modelPtr->userHeight)) {
3197 height = modelPtr->userHeight - y;
31853198 }
31863199 if (width <= 0 || height <= 0) {
31873200 return TCL_OK;
32013214 */
32023215 sourceBlock = *blockPtr;
32033216 memToFree = NULL;
3204 if (sourceBlock.pixelPtr >= masterPtr->pix32
3205 && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
3206 * masterPtr->height * 4) {
3207 sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
3208 * sourceBlock.pitch);
3217 if (sourceBlock.pixelPtr >= modelPtr->pix32
3218 && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width
3219 * modelPtr->height * 4) {
3220 /*
3221 * Fix 5c51be6411: avoid reading
3222 *
3223 * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
3224 *
3225 * bytes past the end of modelPtr->pix32[] when
3226 *
3227 * blockPtr->pixelPtr > (modelPtr->pix32 +
3228 * 4 * modelPtr->width * modelPtr->height -
3229 * sourceBlock.height * sourceBlock.pitch)
3230 */
3231 unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch +
3232 sourceBlock.width * sourceBlock.pixelSize;
3233
3234 sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(cpyLen);
32093235 if (sourceBlock.pixelPtr == NULL) {
32103236 if (interp != NULL) {
32113237 Tcl_SetObjResult(interp, Tcl_NewStringObj(
32153241 return TCL_ERROR;
32163242 }
32173243 memToFree = sourceBlock.pixelPtr;
3218 memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
3219 * sourceBlock.pitch);
3244 memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, cpyLen);
32203245 }
32213246
32223247 xEnd = x + width;
32233248 yEnd = y + height;
3224 if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
3225 if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
3226 MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
3249 if ((xEnd > modelPtr->width) || (yEnd > modelPtr->height)) {
3250 if (ImgPhotoSetSize(modelPtr, MAX(xEnd, modelPtr->width),
3251 MAX(yEnd, modelPtr->height)) == TCL_ERROR) {
32273252 if (interp != NULL) {
32283253 Tcl_SetObjResult(interp, Tcl_NewStringObj(
32293254 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
32333258 }
32343259 }
32353260
3236 if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
3237 && (x < masterPtr->ditherX))) {
3261 if ((y < modelPtr->ditherY) || ((y == modelPtr->ditherY)
3262 && (x < modelPtr->ditherX))) {
32383263 /*
32393264 * The dithering isn't correct past the start of this block.
32403265 */
32413266
3242 masterPtr->ditherX = x;
3243 masterPtr->ditherY = y;
3267 modelPtr->ditherX = x;
3268 modelPtr->ditherY = y;
32443269 }
32453270
32463271 /*
32583283 alphaOffset -= sourceBlock.offset[0];
32593284 }
32603285 if ((greenOffset != 0) || (blueOffset != 0)) {
3261 masterPtr->flags |= COLOR_IMAGE;
3286 modelPtr->flags |= COLOR_IMAGE;
32623287 }
32633288
32643289 /*
32873312 * Copy the data into our local 32-bit/pixel array.
32883313 */
32893314
3290 destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
3315 destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
32913316 srcOrigPtr = sourceBlock.pixelPtr + sourceBlock.offset[0];
32923317 if (subsampleX < 0) {
32933318 srcOrigPtr += (sourceBlock.width - 1) * sourceBlock.pixelSize;
32963321 srcOrigPtr += (sourceBlock.height - 1) * sourceBlock.pitch;
32973322 }
32983323
3299 pitch = masterPtr->width * 4;
3324 pitch = modelPtr->width * 4;
33003325 for (hLeft = height; hLeft > 0; ) {
33013326 hCopy = MIN(hLeft, blockHt);
33023327 hLeft -= hCopy;
33833408 rect.width = width;
33843409 rect.height = 1;
33853410 TkUnionRectWithRegion(&rect, workRgn, workRgn);
3386 TkSubtractRegion(masterPtr->validRegion, workRgn,
3387 masterPtr->validRegion);
3411 TkSubtractRegion(modelPtr->validRegion, workRgn,
3412 modelPtr->validRegion);
33883413 TkDestroyRegion(workRgn);
33893414 }
33903415
3391 TkpBuildRegionFromAlphaData(masterPtr->validRegion,
3416 TkpBuildRegionFromAlphaData(modelPtr->validRegion,
33923417 (unsigned)x, (unsigned)y, (unsigned)width, (unsigned)height,
3393 &masterPtr->pix32[(y * masterPtr->width + x) * 4 + 3], 4,
3394 (unsigned) masterPtr->width * 4);
3418 &modelPtr->pix32[(y * modelPtr->width + x) * 4 + 3], 4,
3419 (unsigned) modelPtr->width * 4);
33953420 } else {
33963421 rect.x = x;
33973422 rect.y = y;
33983423 rect.width = width;
33993424 rect.height = height;
3400 TkUnionRectWithRegion(&rect, masterPtr->validRegion,
3401 masterPtr->validRegion);
3425 TkUnionRectWithRegion(&rect, modelPtr->validRegion,
3426 modelPtr->validRegion);
34023427 }
34033428
34043429 /*
34113436 * builds up large simple-alpha images by single pixels. We don't
34123437 * negate COMPLEX_ALPHA in this case. [Bug 1409140]
34133438 */
3414 if (!(masterPtr->flags & COMPLEX_ALPHA)) {
3439 if (!(modelPtr->flags & COMPLEX_ALPHA)) {
34153440 unsigned char newAlpha;
34163441
3417 destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
3442 destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
34183443 newAlpha = destLinePtr[3];
34193444
34203445 if (newAlpha && newAlpha != 255) {
3421 masterPtr->flags |= COMPLEX_ALPHA;
3422 }
3423 }
3424 } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) {
3446 modelPtr->flags |= COMPLEX_ALPHA;
3447 }
3448 }
3449 } else if ((alphaOffset != 0) || (modelPtr->flags & COMPLEX_ALPHA)) {
34253450 /*
34263451 * Check for partial transparency if alpha pixels are specified, or
34273452 * rescan if we already knew such pixels existed. To restrict this
34283453 * Toggle to only checking the changed pixels requires knowing where
34293454 * the alpha pixels are.
34303455 */
3431 ToggleComplexAlphaIfNeeded(masterPtr);
3456 ToggleComplexAlphaIfNeeded(modelPtr);
34323457 }
34333458
34343459 /*
34353460 * Update each instance.
34363461 */
34373462
3438 Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y, width, height);
3463 Tk_DitherPhoto((Tk_PhotoHandle) modelPtr, x, y, width, height);
34393464
34403465 /*
34413466 * Tell the core image code that this image has changed.
34423467 */
34433468
3444 Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width,
3445 masterPtr->height);
3469 Tk_ImageChanged(modelPtr->tkMaster, x, y, width, height, modelPtr->width,
3470 modelPtr->height);
34463471
34473472 if (memToFree) ckfree(memToFree);
34483473
34603485 * Tk_DitherPhoto --
34613486 *
34623487 * This function is called to update an area of each instance's pixmap by
3463 * dithering the corresponding area of the image master.
3488 * dithering the corresponding area of the image model.
34643489 *
34653490 * Results:
34663491 * None.
34673492 *
34683493 * Side effects:
34693494 * The pixmap of each instance of this image gets updated. The fields in
3470 * *masterPtr indicating which area of the image is correctly dithered
3495 * *modelPtr indicating which area of the image is correctly dithered
34713496 * get updated.
34723497 *
34733498 *----------------------------------------------------------------------
34753500
34763501 void
34773502 Tk_DitherPhoto(
3478 Tk_PhotoHandle photo, /* Image master whose instances are to be
3503 Tk_PhotoHandle photo, /* Image model whose instances are to be
34793504 * updated. */
34803505 int x, int y, /* Coordinates of the top-left pixel in the
34813506 * area to be dithered. */
34823507 int width, int height) /* Dimensions of the area to be dithered. */
34833508 {
3484 PhotoMaster *masterPtr = (PhotoMaster *) photo;
3509 PhotoModel *modelPtr = (PhotoModel *) photo;
34853510 PhotoInstance *instancePtr;
34863511
34873512 if ((width <= 0) || (height <= 0)) {
34883513 return;
34893514 }
34903515
3491 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
3516 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
34923517 instancePtr = instancePtr->nextPtr) {
34933518 TkImgDitherInstance(instancePtr, x, y, width, height);
34943519 }
34983523 * will extend the correctly dithered region.
34993524 */
35003525
3501 if (((y < masterPtr->ditherY)
3502 || ((y == masterPtr->ditherY) && (x <= masterPtr->ditherX)))
3503 && ((y + height) > (masterPtr->ditherY))) {
3526 if (((y < modelPtr->ditherY)
3527 || ((y == modelPtr->ditherY) && (x <= modelPtr->ditherX)))
3528 && ((y + height) > (modelPtr->ditherY))) {
35043529 /*
35053530 * This block starts inside (or immediately after) the correctly
35063531 * dithered region, so the first scan line at least will be right.
3507 * Furthermore this block extends into scanline masterPtr->ditherY.
3508 */
3509
3510 if ((x == 0) && (width == masterPtr->width)) {
3532 * Furthermore this block extends into scanline modelPtr->ditherY.
3533 */
3534
3535 if ((x == 0) && (width == modelPtr->width)) {
35113536 /*
35123537 * We are doing the full width, therefore the dithering will be
35133538 * correct to the end.
35143539 */
35153540
3516 masterPtr->ditherX = 0;
3517 masterPtr->ditherY = y + height;
3541 modelPtr->ditherX = 0;
3542 modelPtr->ditherY = y + height;
35183543 } else {
35193544 /*
35203545 * We are doing partial scanlines, therefore the
35223547 * line.
35233548 */
35243549
3525 if (x <= masterPtr->ditherX) {
3526 masterPtr->ditherX = x + width;
3527 if (masterPtr->ditherX >= masterPtr->width) {
3528 masterPtr->ditherX = 0;
3529 masterPtr->ditherY++;
3550 if (x <= modelPtr->ditherX) {
3551 modelPtr->ditherX = x + width;
3552 if (modelPtr->ditherX >= modelPtr->width) {
3553 modelPtr->ditherX = 0;
3554 modelPtr->ditherY++;
35303555 }
35313556 }
35323557 }
35543579 Tk_PhotoBlank(
35553580 Tk_PhotoHandle handle) /* Handle for the image to be blanked. */
35563581 {
3557 PhotoMaster *masterPtr = (PhotoMaster *) handle;
3582 PhotoModel *modelPtr = (PhotoModel *) handle;
35583583 PhotoInstance *instancePtr;
35593584
3560 masterPtr->ditherX = masterPtr->ditherY = 0;
3561 masterPtr->flags = 0;
3585 modelPtr->ditherX = modelPtr->ditherY = 0;
3586 modelPtr->flags = 0;
35623587
35633588 /*
35643589 * The image has valid data nowhere.
35653590 */
35663591
3567 if (masterPtr->validRegion != NULL) {
3568 TkDestroyRegion(masterPtr->validRegion);
3569 }
3570 masterPtr->validRegion = TkCreateRegion();
3592 if (modelPtr->validRegion != NULL) {
3593 TkDestroyRegion(modelPtr->validRegion);
3594 }
3595 modelPtr->validRegion = TkCreateRegion();
35713596
35723597 /*
35733598 * Clear out the 32-bit pixel storage array. Clear out the dithering error
35743599 * arrays for each instance.
35753600 */
35763601
3577 memset(masterPtr->pix32, 0,
3578 ((size_t)masterPtr->width * masterPtr->height * 4));
3579 for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
3602 memset(modelPtr->pix32, 0,
3603 ((size_t)modelPtr->width * modelPtr->height * 4));
3604 for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
35803605 instancePtr = instancePtr->nextPtr) {
35813606 TkImgResetDither(instancePtr);
35823607 }
35853610 * Tell the core image code that this image has changed.
35863611 */
35873612
3588 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
3589 masterPtr->height, masterPtr->width, masterPtr->height);
3613 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, modelPtr->width,
3614 modelPtr->height, modelPtr->width, modelPtr->height);
35903615 }
35913616
35923617 /*
36163641 Tk_PhotoHandle handle, /* Handle for the image to be expanded. */
36173642 int width, int height) /* Desired minimum dimensions of the image. */
36183643 {
3619 PhotoMaster *masterPtr = (PhotoMaster *) handle;
3620
3621 if (width <= masterPtr->width) {
3622 width = masterPtr->width;
3623 }
3624 if (height <= masterPtr->height) {
3625 height = masterPtr->height;
3626 }
3627 if ((width != masterPtr->width) || (height != masterPtr->height)) {
3628 if (ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width),
3629 MAX(height, masterPtr->height)) == TCL_ERROR) {
3644 PhotoModel *modelPtr = (PhotoModel *) handle;
3645
3646 if (width <= modelPtr->width) {
3647 width = modelPtr->width;
3648 }
3649 if (height <= modelPtr->height) {
3650 height = modelPtr->height;
3651 }
3652 if ((width != modelPtr->width) || (height != modelPtr->height)) {
3653 if (ImgPhotoSetSize(modelPtr, MAX(width, modelPtr->width),
3654 MAX(height, modelPtr->height)) == TCL_ERROR) {
36303655 if (interp != NULL) {
36313656 Tcl_SetObjResult(interp, Tcl_NewStringObj(
36323657 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
36343659 }
36353660 return TCL_ERROR;
36363661 }
3637 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
3638 masterPtr->height);
3662 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0, modelPtr->width,
3663 modelPtr->height);
36393664 }
36403665 return TCL_OK;
36413666 }
36643689 /* The dimensions of the image are returned
36653690 * here. */
36663691 {
3667 PhotoMaster *masterPtr = (PhotoMaster *) handle;
3668
3669 *widthPtr = masterPtr->width;
3670 *heightPtr = masterPtr->height;
3692 PhotoModel *modelPtr = (PhotoModel *) handle;
3693
3694 *widthPtr = modelPtr->width;
3695 *heightPtr = modelPtr->height;
36713696 }
36723697
36733698 /*
36963721 * set. */
36973722 int width, int height) /* New dimensions for the image. */
36983723 {
3699 PhotoMaster *masterPtr = (PhotoMaster *) handle;
3700
3701 masterPtr->userWidth = width;
3702 masterPtr->userHeight = height;
3703 if (ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width),
3704 ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) {
3724 PhotoModel *modelPtr = (PhotoModel *) handle;
3725
3726 modelPtr->userWidth = width;
3727 modelPtr->userHeight = height;
3728 if (ImgPhotoSetSize(modelPtr, ((width > 0) ? width: modelPtr->width),
3729 ((height > 0) ? height: modelPtr->height)) == TCL_ERROR) {
37053730 if (interp != NULL) {
37063731 Tcl_SetObjResult(interp, Tcl_NewStringObj(
37073732 TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
37093734 }
37103735 return TCL_ERROR;
37113736 }
3712 Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
3713 masterPtr->width, masterPtr->height);
3737 Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
3738 modelPtr->width, modelPtr->height);
37143739 return TCL_OK;
37153740 }
37163741
37393764 Tk_PhotoHandle handle) /* Handle for the image whose valid region is
37403765 * to obtained. */
37413766 {
3742 PhotoMaster *masterPtr = (PhotoMaster *) handle;
3743
3744 return masterPtr->validRegion;
3767 PhotoModel *modelPtr = (PhotoModel *) handle;
3768
3769 return modelPtr->validRegion;
37453770 }
37463771
37473772 /*
37673792
37683793 static char *
37693794 ImgGetPhoto(
3770 PhotoMaster *masterPtr, /* Handle for the photo image from which image
3795 PhotoModel *modelPtr, /* Handle for the photo image from which image
37713796 * data is desired. */
37723797 Tk_PhotoImageBlock *blockPtr,
37733798 /* Information about the address and layout of
37773802 unsigned char *pixelPtr;
37783803 int x, y, greenOffset, blueOffset, alphaOffset;
37793804
3780 Tk_PhotoGetImage((Tk_PhotoHandle) masterPtr, blockPtr);
3805 Tk_PhotoGetImage((Tk_PhotoHandle) modelPtr, blockPtr);
37813806 blockPtr->pixelPtr += optPtr->fromY * blockPtr->pitch
37823807 + optPtr->fromX * blockPtr->pixelSize;
37833808 blockPtr->width = optPtr->fromX2 - optPtr->fromX;
37843809 blockPtr->height = optPtr->fromY2 - optPtr->fromY;
37853810
3786 if (!(masterPtr->flags & COLOR_IMAGE) &&
3811 if (!(modelPtr->flags & COLOR_IMAGE) &&
37873812 (!(optPtr->options & OPT_BACKGROUND)
37883813 || ((optPtr->background->red == optPtr->background->green)
37893814 && (optPtr->background->red == optPtr->background->blue)))) {
38113836 blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
38123837 if (((optPtr->options & OPT_BACKGROUND) && alphaOffset) ||
38133838 ((optPtr->options & OPT_GRAYSCALE) && (greenOffset||blueOffset))) {
3814 int newPixelSize,x,y;
3839 int newPixelSize;
38153840 unsigned char *srcPtr, *destPtr;
38163841 char *data;
38173842
38243849 if (blockPtr->height > (int)((UINT_MAX/newPixelSize)/blockPtr->width)) {
38253850 return NULL;
38263851 }
3827 data = attemptckalloc(newPixelSize*blockPtr->width*blockPtr->height);
3852 data = (char *)attemptckalloc(newPixelSize*blockPtr->width*blockPtr->height);
38283853 if (data == NULL) {
38293854 return NULL;
38303855 }
40154040 /* Information about the address and layout of
40164041 * the image data is returned here. */
40174042 {
4018 PhotoMaster *masterPtr = (PhotoMaster *) handle;
4019
4020 blockPtr->pixelPtr = masterPtr->pix32;
4021 blockPtr->width = masterPtr->width;
4022 blockPtr->height = masterPtr->height;
4023 blockPtr->pitch = masterPtr->width * 4;
4043 PhotoModel *modelPtr = (PhotoModel *) handle;
4044
4045 blockPtr->pixelPtr = modelPtr->pix32;
4046 blockPtr->width = modelPtr->width;
4047 blockPtr->height = modelPtr->height;
4048 blockPtr->pitch = modelPtr->width * 4;
40244049 blockPtr->pixelSize = 4;
40254050 blockPtr->offset[0] = 0;
40264051 blockPtr->offset[1] = 1;
40324057 /*
40334058 *--------------------------------------------------------------
40344059 *
4035 * TkPostscriptPhoto --
4060 * ImgPostscriptPhoto --
40364061 *
40374062 * This function is called to output the contents of a photo image in
40384063 * Postscript by calling the Tk_PostscriptPhoto function.
40504075 ImgPhotoPostscript(
40514076 ClientData clientData, /* Handle for the photo image. */
40524077 Tcl_Interp *interp, /* Interpreter. */
4053 Tk_Window tkwin, /* (unused) */
4078 TCL_UNUSED(Tk_Window), /* (unused) */
40544079 Tk_PostscriptInfo psInfo, /* Postscript info. */
40554080 int x, int y, /* First pixel to output. */
40564081 int width, int height, /* Width and height of area. */
4057 int prepass) /* (unused) */
4082 TCL_UNUSED(int)) /* (unused) */
40584083 {
40594084 Tk_PhotoImageBlock block;
40604085
40694094 *
40704095 * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite --
40714096 *
4072 * These backward-compatability functions just exist to fill slots in stubs
4097 * These backward-compatibility functions just exist to fill slots in stubs
40734098 * table. For the behaviour of *_NoComposite, refer to the corresponding
40744099 * function without the extra suffix, except that the compositing rule is
40754100 * always "overlay" and the function always panics on memory-allocation
41104135 * Tk_PhotoExpand_Panic, Tk_PhotoPutBlock_Panic,
41114136 * Tk_PhotoPutZoomedBlock_Panic, Tk_PhotoSetSize_Panic
41124137 *
4113 * Backward compatability functions for preserving the old behaviour (i.e.
4138 * Backward compatibility functions for preserving the old behaviour (i.e.
41144139 * panic on memory allocation failure) so that extensions do not need to be
41154140 * significantly updated to take account of TIP #116. These call the new
41164141 * interface (i.e. the interface without the extra suffix), but panic if an
41694194 * mode: c
41704195 * c-basic-offset: 4
41714196 * fill-column: 78
4197 * tab-width: 8
41724198 * End:
41734199 */
2626 * Forward declarations of the structures we define.
2727 */
2828
29 #define PhotoModel PhotoMaster
2930 typedef struct ColorTableId ColorTableId;
3031 typedef struct ColorTable ColorTable;
3132 typedef struct PhotoInstance PhotoInstance;
136137 #define MAP_COLORS 8
137138
138139 /*
139 * Definition of the data associated with each photo image master.
140 * Definition of the data associated with each photo image model.
140141 */
141142
142143 struct PhotoMaster {
143 Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means the
144 Tk_ImageMaster tkMaster; /* Tk's token for image model. NULL means the
144145 * image is being deleted. */
145146 Tcl_Interp *interp; /* Interpreter associated with the application
146147 * using this image. */
163164 TkRegion validRegion; /* Tk region indicating which parts of the
164165 * image have valid image data. */
165166 PhotoInstance *instancePtr; /* First in the list of instances associated
166 * with this master. */
167 * with this model. */
167168 };
168169
169170 /*
194195 */
195196
196197 struct PhotoInstance {
197 PhotoMaster *masterPtr; /* Pointer to master for image. */
198 PhotoMaster *masterPtr; /* Pointer to model for image. */
198199 Display *display; /* Display for windows using this instance. */
199200 Colormap colormap; /* The image may only be used in windows with
200201 * this particular colormap. */
201202 PhotoInstance *nextPtr; /* Pointer to the next instance in the list of
202 * instances associated with this master. */
203 * instances associated with this model. */
203204 int refCount; /* Number of instances using this structure. */
204205 Tk_Uid palette; /* Palette for these particular instances. */
205206 double gamma; /* Gamma value for these instances. */
206207 Tk_Uid defaultPalette; /* Default palette to use if a palette is not
207 * specified for the master. */
208 * specified for the model. */
208209 ColorTable *colorTablePtr; /* Pointer to information about colors
209210 * allocated for image display in windows like
210211 * this one. */
633633 Tk_Font tkfont, const char *source, int numBytes, double x,
634634 double y, double angle)
635635 }
636
637 # Support for aqua's inability to draw outside [NSView drawRect:]
638 declare 185 macosx {
639 void TkpRedrawWidget(Tk_Window tkwin)
640 }
641 declare 186 macosx {
642 int TkpWillDrawWidget(Tk_Window tkwin)
643 }
644
636645
637646 ##############################################################################
638647
647656 declare 0 x11 {
648657 void TkCreateXEventSource(void)
649658 }
650 #
651 # Slot 1 unused (WAS: TkFreeWindowId)
652 # Slot 2 unused (WAS: TkInitXId)
653 #
659 declare 2 x11 {
660 void TkGenerateActivateEvents(TkWindow *winPtr, int active)
661 }
654662 declare 3 x11 {
655663 int TkpCmapStressed(Tk_Window tkwin, Colormap colormap)
656664 }
675683 declare 10 x11 {
676684 void TkSendCleanup(TkDisplay *dispPtr)
677685 }
678 #
679 # Slot 11 unused (WAS: TkFreeXId)
680 #
681686 declare 12 x11 {
682687 int TkpWmSetState(TkWindow *winPtr, int state)
683688 }
686691 int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc,
687692 Tcl_Obj *const objv[])
688693 }
694 declare 38 x11 {
695 int TkpCmapStressed_(Tk_Window tkwin, Colormap colormap)
696 }
697 declare 39 x11 {
698 void TkpSync_(Display *display)
699 }
700 declare 40 x11 {
701 Window TkUnixContainerId_(TkWindow *winPtr)
702 }
703 declare 41 x11 {
704 int TkUnixDoOneXEvent_(Tcl_Time *timePtr)
705 }
706 declare 42 x11 {
707 void TkUnixSetMenubar_(Tk_Window tkwin, Tk_Window menubar)
708 }
709 declare 43 x11 {
710 void TkWmCleanup_(TkDisplay *dispPtr)
711 }
712 declare 44 x11 {
713 void TkSendCleanup_(TkDisplay *dispPtr)
714 }
715 # only needed by tktest:
716 declare 45 x11 {
717 int TkpTestsendCmd_(ClientData clientData, Tcl_Interp *interp, int objc,
718 Tcl_Obj *const objv[])
719 }
689720
690721 ################################
691722 # Windows specific functions
853884 declare 0 aqua {
854885 void TkGenerateActivateEvents(TkWindow *winPtr, int active)
855886 }
856
857 # removed duplicates from tkInt table
858 #declare 1 aqua {
859 # Pixmap TkpCreateNativeBitmap(Display *display, const void *source)
860 #}
861 #
862 #declare 2 aqua {
863 # void TkpDefineNativeBitmaps(void)
864 #}
865
887 declare 2 aqua {
888 void TkGenerateActivateEvents_(TkWindow *winPtr, int active)
889 }
866890 declare 3 aqua {
867891 void TkPointerDeadWindow(TkWindow *winPtr)
868892 }
893917 declare 12 aqua {
894918 void TkMacOSXHandleTearoffMenu(void)
895919 }
896
897 # removed duplicate from tkPlat table(tk.decls)
898 #declare 13 aqua {
899 # void TkMacOSXInvalClipRgns(TkWindow *winPtr)
900 #}
901
902920 declare 14 aqua {
903921 int TkMacOSXDoHLEvent(void *theEvent)
904922 }
905
906 # removed duplicate from tkPlat table(tk.decls)
907 #declare 15 aqua {
908 # void *TkMacOSXGetDrawablePort(Drawable drawable)
909 #}
910
911923 declare 16 aqua {
912924 Window TkMacOSXGetXWindow(void *macWinPtr)
913925 }
943955 declare 25 aqua {
944956 void TkMacOSXMenuClick(void)
945957 }
946 declare 26 aqua {
947 void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr)
948 }
958 # The corresponding Unregister was not a stub, and this should be static.
959 #declare 26 aqua {
960 # void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr)
961 #}
949962 declare 27 aqua {
950963 int TkMacOSXResizable(TkWindow *winPtr)
951964 }
964977 declare 32 aqua {
965978 void TkMacOSXUpdateClipRgn(TkWindow *winPtr)
966979 }
967 declare 33 aqua {
968 void TkMacOSXUnregisterMacWindow(void *portPtr)
969 }
980 # This was not implemented. Perhaps meant to be OffScreen ?
981 #declare 33 aqua {
982 # void TkMacOSXUnregisterMacWindow(void *portPtr)
983 #}
970984 declare 34 aqua {
971985 int TkMacOSXUseMenuID(short macID)
972986 }
985999 declare 39 aqua {
9861000 void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid)
9871001 }
988 #
989 # Slot 40 unused (WAS: TkSuspendClipboard)
990 #
9911002 declare 41 aqua {
9921003 int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart)
9931004 }
10221033 declare 52 aqua {
10231034 void TkMacOSXSetDrawingEnabled(TkWindow *winPtr, int flag)
10241035 }
1025
1026 # removed duplicate from tkPlat table (tk.decls)
1027 #declare 52 aqua {
1028 # void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y,
1029 # int width, int height, int flags)
1030 #}
1031
10321036 declare 53 aqua {
10331037 unsigned long TkpGetMS(void)
10341038 }
1035
10361039 # For Canvas3d, requested by Sean Woods
10371040 declare 54 aqua {
10381041 void *TkMacOSXDrawable(Drawable drawable)
14951498 int sx, int sy, int dx, int dy,
14961499 unsigned int w, unsigned int h)
14971500 }
1501 declare 158 win {
1502 void TkUnusedStubEntry(void)
1503 }
14981504
14991505 ################################
15001506 # X functions for Aqua
18181824 declare 91 aqua {
18191825 int XSync(Display *display, Bool discard)
18201826 }
1827 declare 106 aqua {
1828 int XSetClipRectangles(Display *display, GC gc, int clip_x_origin,
1829 int clip_y_origin, XRectangle rectangles[], int n, int ordering)
1830 }
1831
18211832 declare 107 aqua {
18221833 int XFlush(Display *display)
18231834 }
18381849 }
18391850 declare 114 aqua {
18401851 VisualID XVisualIDFromVisual(Visual *visual)
1852 }
1853 declare 120 aqua {
1854 int XOffsetRegion(void *rgn, int dx, int dy)
1855 }
1856 declare 129 aqua {
1857 int XLowerWindow(Display *d, Window w)
18411858 }
18421859 declare 137 aqua {
18431860 int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
18441861 int sx, int sy, int dx, int dy,
18451862 unsigned int w, unsigned int h)
18461863 }
1864 declare 144 aqua {
1865 void XDestroyIC(XIC xic)
1866 }
1867 declare 145 aqua {
1868 Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
1869 XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2)
1870 }
1871 declare 146 aqua {
1872 Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
1873 unsigned int ui1, unsigned int ui2, XColor _Xconst *x1,
1874 XColor _Xconst *x2)
1875 }
1876 declare 157 aqua {
1877 KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g, int i)
1878 }
1879 declare 158 aqua {
1880 void TkUnusedStubEntry(void)
1881 }
18471882
18481883 # Local Variables:
18491884 # mode: tcl
5656 # else
5757 # define MODULE_SCOPE extern
5858 # endif
59 #endif
60
61 #ifndef JOIN
62 # define JOIN(a,b) JOIN1(a,b)
63 # define JOIN1(a,b) a##b
64 #endif
65
66 #ifndef TCL_UNUSED
67 # if defined(__cplusplus)
68 # define TCL_UNUSED(T) T
69 # elif defined(__GNUC__) && (__GNUC__ > 2)
70 # define TCL_UNUSED(T) T JOIN(dummy, __LINE__) __attribute__((unused))
71 # else
72 # define TCL_UNUSED(T) T JOIN(dummy, __LINE__)
73 # endif
74 #endif
75
76 #if defined(_WIN32) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
77 # if TCL_UTF_MAX > 3
78 # define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c)
79 # define Tcl_UtfToWCharDString(a,b,c) (WCHAR *)Tcl_WinUtfToTChar(a,b,c)
80 # else
81 # define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int len, Tcl_DString *))Tcl_UniCharToUtfDString)
82 # define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString)
83 # endif
84 #endif
85
86 #if defined(__GNUC__) && (__GNUC__ > 2)
87 # define TKFLEXARRAY 0
88 #else
89 # define TKFLEXARRAY 1
90 #endif
91
92 #ifndef Tcl_GetParent
93 # define Tcl_GetParent Tcl_GetMaster
5994 #endif
6095
6196 /*
327362 */
328363
329364 Tcl_HashTable maintainHashTable;
330 /* Hash table that maps from a master's
331 * Tk_Window token to a list of slaves managed
332 * by that master. */
365 /* Hash table that maps from a container's
366 * Tk_Window token to a list of windows managed
367 * by that container. */
333368 int geomInit;
334369
335 #define TkGetGeomMaster(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
370 #define TkGetContainer(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
336371 ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)
337372
338373 /*
634669 /* Top level of option hierarchy for this main
635670 * window. NULL means uninitialized. Managed
636671 * by tkOption.c. */
637 Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageMaster
672 Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageModel
638673 * structures. Managed by tkImage.c. */
639674 int strictMotif; /* This is linked to the tk_strictMotif global
640675 * variable. */
681716 Visual *visual; /* Visual to use for window. If not default,
682717 * MUST be set before X window is created. */
683718 int depth; /* Number of bits/pixel. */
684 Window window; /* X's id for window. NULL means window hasn't
719 Window window; /* X's id for window. None means window hasn't
685720 * actually been created yet, or it's been
686721 * deleted. */
687722 struct TkWindow *childList; /* First in list of child windows, or NULL if
829864 #endif /* TK_USE_INPUT_METHODS */
830865 char *geomMgrName; /* Records the name of the geometry manager. */
831866 struct TkWindow *maintainerPtr;
832 /* The geometry master for this window. The
833 * value is NULL if the window has no master or
834 * if its master is its parent. */
867 /* The geometry container for this window. The
868 * value is NULL if the window has no container or
869 * if its container is its parent. */
835870 } TkWindow;
836871
837872 /*
841876
842877 typedef struct {
843878 XKeyEvent keyEvent; /* The real event from X11. */
879 #ifdef _WIN32
880 char trans_chars[XMaxTransChars];
881 /* translated characters */
882 unsigned char nbytes;
883 #elif !defined(MAC_OSX_TK)
844884 char *charValuePtr; /* A pointer to a string that holds the key's
845885 * %A substitution text (before backslash
846886 * adding), or NULL if that has not been
850890 * is non-NULL. */
851891 KeySym keysym; /* Key symbol computed after input methods
852892 * have been invoked */
893 #endif
853894 } TkKeyEvent;
854895
855896 /*
949990 (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
950991
951992
952 MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int);
993 MODULE_SCOPE unsigned TkGetButtonMask(unsigned);
953994
954995 /*
955996 * Object types not declared in tkObj.c need to be mentioned here so they can
10241065
10251066 #include "tkIntDecls.h"
10261067
1068 #ifdef __cplusplus
1069 extern "C" {
1070 #endif
1071
10271072 /*
10281073 * Themed widget set init function:
10291074 */
11791224 MODULE_SCOPE int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp,
11801225 Tk_Window tkwin, Tcl_Obj *objPtr,
11811226 double *doublePtr);
1182 MODULE_SCOPE int TkSetGeometryMaster(Tcl_Interp *interp,
1183 Tk_Window tkwin, const char *master);
1184 MODULE_SCOPE void TkFreeGeometryMaster(Tk_Window tkwin,
1185 const char *master);
1227 #define TkSetGeometryContainer TkSetGeometryMaster
1228 MODULE_SCOPE int TkSetGeometryContainer(Tcl_Interp *interp,
1229 Tk_Window tkwin, const char *name);
1230 #define TkFreeGeometryContainer TkFreeGeometryMaster
1231 MODULE_SCOPE void TkFreeGeometryContainer(Tk_Window tkwin,
1232 const char *name);
11861233
11871234 MODULE_SCOPE void TkEventInit(void);
11881235 MODULE_SCOPE void TkRegisterObjTypes(void);
12201267 Drawable drawable, GC gc, Tk_Font tkfont,
12211268 const char *source, int numBytes, int rangeStart,
12221269 int rangeLength, int x, int y);
1270 MODULE_SCOPE void TkpDrawAngledCharsInContext(Display * display,
1271 Drawable drawable, GC gc, Tk_Font tkfont,
1272 const char *source, int numBytes, int rangeStart,
1273 int rangeLength, double x, double y, double angle);
12231274 MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont,
12241275 const char *source, int numBytes, int rangeStart,
12251276 int rangeLength, int maxLength, int flags,
12731324 #if TCL_UTF_MAX > 4
12741325 # define TkUtfToUniChar Tcl_UtfToUniChar
12751326 # define TkUniCharToUtf Tcl_UniCharToUtf
1327 # define TkUtfPrev Tcl_UtfPrev
1328 # define TkUtfAtIndex Tcl_UtfAtIndex
12761329 #else
12771330 MODULE_SCOPE int TkUtfToUniChar(const char *, int *);
12781331 MODULE_SCOPE int TkUniCharToUtf(int, char *);
1332 MODULE_SCOPE const char *TkUtfPrev(const char *, const char *);
1333 MODULE_SCOPE const char *TkUtfAtIndex(const char *src, int index);
12791334 #endif
12801335
12811336 /*
12991354 MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp);
13001355 #endif
13011356
1357 #ifdef __cplusplus
1358 }
1359 #endif
1360
13021361 #endif /* _TKINT */
13031362
13041363 /*
549549 Drawable drawable, GC gc, Tk_Font tkfont,
550550 const char *source, int numBytes, double x,
551551 double y, double angle);
552 #ifdef MAC_OSX_TCL /* MACOSX */
553 /* 185 */
554 EXTERN void TkpRedrawWidget(Tk_Window tkwin);
555 #endif /* MACOSX */
556 #ifdef MAC_OSX_TCL /* MACOSX */
557 /* 186 */
558 EXTERN int TkpWillDrawWidget(Tk_Window tkwin);
559 #endif /* MACOSX */
552560
553561 typedef struct TkIntStubs {
554562 int magic;
766774 void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */
767775 int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */
768776 void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 184 */
777 #if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
778 void (*reserved185)(void);
779 #endif /* UNIX */
780 #if defined(_WIN32) /* WIN */
781 void (*reserved185)(void);
782 #endif /* WIN */
783 #ifdef MAC_OSX_TCL /* MACOSX */
784 void (*tkpRedrawWidget) (Tk_Window tkwin); /* 185 */
785 #endif /* MACOSX */
786 #if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
787 void (*reserved186)(void);
788 #endif /* UNIX */
789 #if defined(_WIN32) /* WIN */
790 void (*reserved186)(void);
791 #endif /* WIN */
792 #ifdef MAC_OSX_TCL /* MACOSX */
793 int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */
794 #endif /* MACOSX */
769795 } TkIntStubs;
770796
771797 extern const TkIntStubs *tkIntStubsPtr;
11381164 (tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */
11391165 #define TkDrawAngledChars \
11401166 (tkIntStubsPtr->tkDrawAngledChars) /* 184 */
1167 #ifdef MAC_OSX_TCL /* MACOSX */
1168 #define TkpRedrawWidget \
1169 (tkIntStubsPtr->tkpRedrawWidget) /* 185 */
1170 #endif /* MACOSX */
1171 #ifdef MAC_OSX_TCL /* MACOSX */
1172 #define TkpWillDrawWidget \
1173 (tkIntStubsPtr->tkpWillDrawWidget) /* 186 */
1174 #endif /* MACOSX */
11411175
11421176 #endif /* defined(USE_TK_STUBS) */
11431177
11591193 #undef TkSetRegion
11601194 #undef TkSubtractRegion
11611195 #undef TkUnionRectWithRegion
1196 #undef TkpCmapStressed_
1197 #undef TkpSync_
1198 #undef TkUnixContainerId_
1199 #undef TkUnixDoOneXEvent_
1200 #undef TkUnixSetMenubar_
1201 #undef TkWmCleanup_
1202 #undef TkSendCleanup_
1203 #undef TkpTestsendCmd_
11621204
11631205 #define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect)
11641206 #define TkCreateRegion() (TkRegion) XCreateRegion()
11741216
11751217 #endif /* UNIX */
11761218
1219 #if !defined(MAC_OSX_TK)
1220 # undef TkpWillDrawWidget
1221 # undef TkpRedrawWidget
1222 # define TkpWillDrawWidget(w) 0
1223 # define TkpRedrawWidget(w)
1224 #endif
1225
11771226 #endif /* _TKINTDECLS */
11781227
150150 EXTERN void TkGenerateActivateEvents(TkWindow *winPtr,
151151 int active);
152152 /* Slot 1 is reserved */
153 /* Slot 2 is reserved */
153 /* 2 */
154 EXTERN void TkGenerateActivateEvents_(TkWindow *winPtr,
155 int active);
154156 /* 3 */
155157 EXTERN void TkPointerDeadWindow(TkWindow *winPtr);
156158 /* 4 */
196198 EXTERN void * TkMacOSXMakeStippleMap(Drawable d1, Drawable d2);
197199 /* 25 */
198200 EXTERN void TkMacOSXMenuClick(void);
199 /* 26 */
200 EXTERN void TkMacOSXRegisterOffScreenWindow(Window window,
201 void *portPtr);
201 /* Slot 26 is reserved */
202202 /* 27 */
203203 EXTERN int TkMacOSXResizable(TkWindow *winPtr);
204204 /* 28 */
211211 EXTERN void TkMacOSXSetUpGraphicsPort(GC gc, void *destPort);
212212 /* 32 */
213213 EXTERN void TkMacOSXUpdateClipRgn(TkWindow *winPtr);
214 /* 33 */
215 EXTERN void TkMacOSXUnregisterMacWindow(void *portPtr);
214 /* Slot 33 is reserved */
216215 /* 34 */
217216 EXTERN int TkMacOSXUseMenuID(short macID);
218217 /* 35 */
265264 /* 0 */
266265 EXTERN void TkCreateXEventSource(void);
267266 /* Slot 1 is reserved */
268 /* Slot 2 is reserved */
267 /* 2 */
268 EXTERN void TkGenerateActivateEvents(TkWindow *winPtr,
269 int active);
269270 /* 3 */
270271 EXTERN int TkpCmapStressed(Tk_Window tkwin, Colormap colormap);
271272 /* 4 */
288289 EXTERN int TkpWmSetState(TkWindow *winPtr, int state);
289290 /* 13 */
290291 EXTERN int TkpTestsendCmd(ClientData clientData,
292 Tcl_Interp *interp, int objc,
293 Tcl_Obj *const objv[]);
294 /* Slot 14 is reserved */
295 /* Slot 15 is reserved */
296 /* Slot 16 is reserved */
297 /* Slot 17 is reserved */
298 /* Slot 18 is reserved */
299 /* Slot 19 is reserved */
300 /* Slot 20 is reserved */
301 /* Slot 21 is reserved */
302 /* Slot 22 is reserved */
303 /* Slot 23 is reserved */
304 /* Slot 24 is reserved */
305 /* Slot 25 is reserved */
306 /* Slot 26 is reserved */
307 /* Slot 27 is reserved */
308 /* Slot 28 is reserved */
309 /* Slot 29 is reserved */
310 /* Slot 30 is reserved */
311 /* Slot 31 is reserved */
312 /* Slot 32 is reserved */
313 /* Slot 33 is reserved */
314 /* Slot 34 is reserved */
315 /* Slot 35 is reserved */
316 /* Slot 36 is reserved */
317 /* Slot 37 is reserved */
318 /* 38 */
319 EXTERN int TkpCmapStressed_(Tk_Window tkwin, Colormap colormap);
320 /* 39 */
321 EXTERN void TkpSync_(Display *display);
322 /* 40 */
323 EXTERN Window TkUnixContainerId_(TkWindow *winPtr);
324 /* 41 */
325 EXTERN int TkUnixDoOneXEvent_(Tcl_Time *timePtr);
326 /* 42 */
327 EXTERN void TkUnixSetMenubar_(Tk_Window tkwin, Tk_Window menubar);
328 /* 43 */
329 EXTERN void TkWmCleanup_(TkDisplay *dispPtr);
330 /* 44 */
331 EXTERN void TkSendCleanup_(TkDisplay *dispPtr);
332 /* 45 */
333 EXTERN int TkpTestsendCmd_(ClientData clientData,
291334 Tcl_Interp *interp, int objc,
292335 Tcl_Obj *const objv[]);
293336 #endif /* X11 */
349392 #ifdef MAC_OSX_TK /* AQUA */
350393 void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 0 */
351394 void (*reserved1)(void);
352 void (*reserved2)(void);
395 void (*tkGenerateActivateEvents_) (TkWindow *winPtr, int active); /* 2 */
353396 void (*tkPointerDeadWindow) (TkWindow *winPtr); /* 3 */
354397 void (*tkpSetCapture) (TkWindow *winPtr); /* 4 */
355398 void (*tkpSetCursor) (TkpCursor cursor); /* 5 */
373416 void (*tkMacOSXMakeRealWindowExist) (TkWindow *winPtr); /* 23 */
374417 void * (*tkMacOSXMakeStippleMap) (Drawable d1, Drawable d2); /* 24 */
375418 void (*tkMacOSXMenuClick) (void); /* 25 */
376 void (*tkMacOSXRegisterOffScreenWindow) (Window window, void *portPtr); /* 26 */
419 void (*reserved26)(void);
377420 int (*tkMacOSXResizable) (TkWindow *winPtr); /* 27 */
378421 void (*tkMacOSXSetHelpMenuItemCount) (void); /* 28 */
379422 void (*tkMacOSXSetScrollbarGrow) (TkWindow *winPtr, int flag); /* 29 */
380423 void (*tkMacOSXSetUpClippingRgn) (Drawable drawable); /* 30 */
381424 void (*tkMacOSXSetUpGraphicsPort) (GC gc, void *destPort); /* 31 */
382425 void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */
383 void (*tkMacOSXUnregisterMacWindow) (void *portPtr); /* 33 */
426 void (*reserved33)(void);
384427 int (*tkMacOSXUseMenuID) (short macID); /* 34 */
385428 TkRegion (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
386429 void (*tkMacOSXWinBounds) (TkWindow *winPtr, void *geometry); /* 36 */
407450 #if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
408451 void (*tkCreateXEventSource) (void); /* 0 */
409452 void (*reserved1)(void);
410 void (*reserved2)(void);
453 void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 2 */
411454 int (*tkpCmapStressed) (Tk_Window tkwin, Colormap colormap); /* 3 */
412455 void (*tkpSync) (Display *display); /* 4 */
413456 Window (*tkUnixContainerId) (TkWindow *winPtr); /* 5 */
419462 void (*reserved11)(void);
420463 int (*tkpWmSetState) (TkWindow *winPtr, int state); /* 12 */
421464 int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 13 */
465 void (*reserved14)(void);
466 void (*reserved15)(void);
467 void (*reserved16)(void);
468 void (*reserved17)(void);
469 void (*reserved18)(void);
470 void (*reserved19)(void);
471 void (*reserved20)(void);
472 void (*reserved21)(void);
473 void (*reserved22)(void);
474 void (*reserved23)(void);
475 void (*reserved24)(void);
476 void (*reserved25)(void);
477 void (*reserved26)(void);
478 void (*reserved27)(void);
479 void (*reserved28)(void);
480 void (*reserved29)(void);
481 void (*reserved30)(void);
482 void (*reserved31)(void);
483 void (*reserved32)(void);
484 void (*reserved33)(void);
485 void (*reserved34)(void);
486 void (*reserved35)(void);
487 void (*reserved36)(void);
488 void (*reserved37)(void);
489 int (*tkpCmapStressed_) (Tk_Window tkwin, Colormap colormap); /* 38 */
490 void (*tkpSync_) (Display *display); /* 39 */
491 Window (*tkUnixContainerId_) (TkWindow *winPtr); /* 40 */
492 int (*tkUnixDoOneXEvent_) (Tcl_Time *timePtr); /* 41 */
493 void (*tkUnixSetMenubar_) (Tk_Window tkwin, Tk_Window menubar); /* 42 */
494 void (*tkWmCleanup_) (TkDisplay *dispPtr); /* 43 */
495 void (*tkSendCleanup_) (TkDisplay *dispPtr); /* 44 */
496 int (*tkpTestsendCmd_) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */
422497 #endif /* X11 */
423498 } TkIntPlatStubs;
424499
534609 #define TkGenerateActivateEvents \
535610 (tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 0 */
536611 /* Slot 1 is reserved */
537 /* Slot 2 is reserved */
612 #define TkGenerateActivateEvents_ \
613 (tkIntPlatStubsPtr->tkGenerateActivateEvents_) /* 2 */
538614 #define TkPointerDeadWindow \
539615 (tkIntPlatStubsPtr->tkPointerDeadWindow) /* 3 */
540616 #define TkpSetCapture \
577653 (tkIntPlatStubsPtr->tkMacOSXMakeStippleMap) /* 24 */
578654 #define TkMacOSXMenuClick \
579655 (tkIntPlatStubsPtr->tkMacOSXMenuClick) /* 25 */
580 #define TkMacOSXRegisterOffScreenWindow \
581 (tkIntPlatStubsPtr->tkMacOSXRegisterOffScreenWindow) /* 26 */
656 /* Slot 26 is reserved */
582657 #define TkMacOSXResizable \
583658 (tkIntPlatStubsPtr->tkMacOSXResizable) /* 27 */
584659 #define TkMacOSXSetHelpMenuItemCount \
591666 (tkIntPlatStubsPtr->tkMacOSXSetUpGraphicsPort) /* 31 */
592667 #define TkMacOSXUpdateClipRgn \
593668 (tkIntPlatStubsPtr->tkMacOSXUpdateClipRgn) /* 32 */
594 #define TkMacOSXUnregisterMacWindow \
595 (tkIntPlatStubsPtr->tkMacOSXUnregisterMacWindow) /* 33 */
669 /* Slot 33 is reserved */
596670 #define TkMacOSXUseMenuID \
597671 (tkIntPlatStubsPtr->tkMacOSXUseMenuID) /* 34 */
598672 #define TkMacOSXVisableClipRgn \
640714 #define TkCreateXEventSource \
641715 (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */
642716 /* Slot 1 is reserved */
643 /* Slot 2 is reserved */
717 #define TkGenerateActivateEvents \
718 (tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 2 */
644719 #define TkpCmapStressed \
645720 (tkIntPlatStubsPtr->tkpCmapStressed) /* 3 */
646721 #define TkpSync \
662737 (tkIntPlatStubsPtr->tkpWmSetState) /* 12 */
663738 #define TkpTestsendCmd \
664739 (tkIntPlatStubsPtr->tkpTestsendCmd) /* 13 */
740 /* Slot 14 is reserved */
741 /* Slot 15 is reserved */
742 /* Slot 16 is reserved */
743 /* Slot 17 is reserved */
744 /* Slot 18 is reserved */
745 /* Slot 19 is reserved */
746 /* Slot 20 is reserved */
747 /* Slot 21 is reserved */
748 /* Slot 22 is reserved */
749 /* Slot 23 is reserved */
750 /* Slot 24 is reserved */
751 /* Slot 25 is reserved */
752 /* Slot 26 is reserved */
753 /* Slot 27 is reserved */
754 /* Slot 28 is reserved */
755 /* Slot 29 is reserved */
756 /* Slot 30 is reserved */
757 /* Slot 31 is reserved */
758 /* Slot 32 is reserved */
759 /* Slot 33 is reserved */
760 /* Slot 34 is reserved */
761 /* Slot 35 is reserved */
762 /* Slot 36 is reserved */
763 /* Slot 37 is reserved */
764 #define TkpCmapStressed_ \
765 (tkIntPlatStubsPtr->tkpCmapStressed_) /* 38 */
766 #define TkpSync_ \
767 (tkIntPlatStubsPtr->tkpSync_) /* 39 */
768 #define TkUnixContainerId_ \
769 (tkIntPlatStubsPtr->tkUnixContainerId_) /* 40 */
770 #define TkUnixDoOneXEvent_ \
771 (tkIntPlatStubsPtr->tkUnixDoOneXEvent_) /* 41 */
772 #define TkUnixSetMenubar_ \
773 (tkIntPlatStubsPtr->tkUnixSetMenubar_) /* 42 */
774 #define TkWmCleanup_ \
775 (tkIntPlatStubsPtr->tkWmCleanup_) /* 43 */
776 #define TkSendCleanup_ \
777 (tkIntPlatStubsPtr->tkSendCleanup_) /* 44 */
778 #define TkpTestsendCmd_ \
779 (tkIntPlatStubsPtr->tkpTestsendCmd_) /* 45 */
665780 #endif /* X11 */
666781
667782 #endif /* defined(USE_TK_STUBS) */
668783
669784 /* !END!: Do not edit above this line. */
785
786 #undef TkpCmapStressed_
787 #undef TkpSync_
788 #undef TkUnixContainerId_
789 #undef TkUnixDoOneXEvent_
790 #undef TkUnixSetMenubar_
791 #undef TkWmCleanup_
792 #undef TkSendCleanup_
793 #undef TkpTestsendCmd_
794 #undef TkGenerateActivateEvents_
795
796 #define TkMacOSXGetContainer TkGetTransientMaster
670797
671798 #undef TCL_STORAGE_CLASS
672799 #define TCL_STORAGE_CLASS DLLIMPORT
412412 EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
413413 int sx, int sy, int dx, int dy,
414414 unsigned int w, unsigned int h);
415 /* Slot 138 is reserved */
416 /* Slot 139 is reserved */
417 /* Slot 140 is reserved */
418 /* Slot 141 is reserved */
419 /* Slot 142 is reserved */
420 /* Slot 143 is reserved */
421 /* Slot 144 is reserved */
422 /* Slot 145 is reserved */
423 /* Slot 146 is reserved */
424 /* Slot 147 is reserved */
425 /* Slot 148 is reserved */
426 /* Slot 149 is reserved */
427 /* Slot 150 is reserved */
428 /* Slot 151 is reserved */
429 /* Slot 152 is reserved */
430 /* Slot 153 is reserved */
431 /* Slot 154 is reserved */
432 /* Slot 155 is reserved */
433 /* Slot 156 is reserved */
434 /* Slot 157 is reserved */
435 /* 158 */
436 EXTERN void TkUnusedStubEntry(void);
415437 #endif /* WIN */
416438 #ifdef MAC_OSX_TK /* AQUA */
417439 /* 0 */
690712 /* Slot 103 is reserved */
691713 /* Slot 104 is reserved */
692714 /* Slot 105 is reserved */
693 /* Slot 106 is reserved */
715 /* 106 */
716 EXTERN int XSetClipRectangles(Display *display, GC gc,
717 int clip_x_origin, int clip_y_origin,
718 XRectangle rectangles[], int n, int ordering);
694719 /* 107 */
695720 EXTERN int XFlush(Display *display);
696721 /* 108 */
711736 /* Slot 117 is reserved */
712737 /* Slot 118 is reserved */
713738 /* Slot 119 is reserved */
714 /* Slot 120 is reserved */
739 /* 120 */
740 EXTERN int XOffsetRegion(void *rgn, int dx, int dy);
715741 /* Slot 121 is reserved */
716742 /* Slot 122 is reserved */
717743 /* Slot 123 is reserved */
720746 /* Slot 126 is reserved */
721747 /* Slot 127 is reserved */
722748 /* Slot 128 is reserved */
723 /* Slot 129 is reserved */
749 /* 129 */
750 EXTERN int XLowerWindow(Display *d, Window w);
724751 /* Slot 130 is reserved */
725752 /* Slot 131 is reserved */
726753 /* Slot 132 is reserved */
732759 EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
733760 int sx, int sy, int dx, int dy,
734761 unsigned int w, unsigned int h);
762 /* Slot 138 is reserved */
763 /* Slot 139 is reserved */
764 /* Slot 140 is reserved */
765 /* Slot 141 is reserved */
766 /* Slot 142 is reserved */
767 /* Slot 143 is reserved */
768 /* 144 */
769 EXTERN void XDestroyIC(XIC xic);
770 /* 145 */
771 EXTERN Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
772 XColor *x1, XColor *x2, unsigned int ui1,
773 unsigned int ui2);
774 /* 146 */
775 EXTERN Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
776 unsigned int ui1, unsigned int ui2,
777 XColor _Xconst *x1, XColor _Xconst *x2);
778 /* Slot 147 is reserved */
779 /* Slot 148 is reserved */
780 /* Slot 149 is reserved */
781 /* Slot 150 is reserved */
782 /* Slot 151 is reserved */
783 /* Slot 152 is reserved */
784 /* Slot 153 is reserved */
785 /* Slot 154 is reserved */
786 /* Slot 155 is reserved */
787 /* Slot 156 is reserved */
788 /* 157 */
789 EXTERN KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g,
790 int i);
791 /* 158 */
792 EXTERN void TkUnusedStubEntry(void);
735793 #endif /* AQUA */
736794
737795 typedef struct TkIntXlibStubs {
877935 int (*xDrawPoints) (Display *d, Drawable dr, GC gc, XPoint *p, int n, int m); /* 135 */
878936 int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */
879937 int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
938 void (*reserved138)(void);
939 void (*reserved139)(void);
940 void (*reserved140)(void);
941 void (*reserved141)(void);
942 void (*reserved142)(void);
943 void (*reserved143)(void);
944 void (*reserved144)(void);
945 void (*reserved145)(void);
946 void (*reserved146)(void);
947 void (*reserved147)(void);
948 void (*reserved148)(void);
949 void (*reserved149)(void);
950 void (*reserved150)(void);
951 void (*reserved151)(void);
952 void (*reserved152)(void);
953 void (*reserved153)(void);
954 void (*reserved154)(void);
955 void (*reserved155)(void);
956 void (*reserved156)(void);
957 void (*reserved157)(void);
958 void (*tkUnusedStubEntry) (void); /* 158 */
880959 #endif /* WIN */
881960 #ifdef MAC_OSX_TK /* AQUA */
882961 int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */
9851064 void (*reserved103)(void);
9861065 void (*reserved104)(void);
9871066 void (*reserved105)(void);
988 void (*reserved106)(void);
1067 int (*xSetClipRectangles) (Display *display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 106 */
9891068 int (*xFlush) (Display *display); /* 107 */
9901069 int (*xGrabServer) (Display *display); /* 108 */
9911070 int (*xUngrabServer) (Display *display); /* 109 */
9991078 void (*reserved117)(void);
10001079 void (*reserved118)(void);
10011080 void (*reserved119)(void);
1002 void (*reserved120)(void);
1081 int (*xOffsetRegion) (void *rgn, int dx, int dy); /* 120 */
10031082 void (*reserved121)(void);
10041083 void (*reserved122)(void);
10051084 void (*reserved123)(void);
10081087 void (*reserved126)(void);
10091088 void (*reserved127)(void);
10101089 void (*reserved128)(void);
1011 void (*reserved129)(void);
1090 int (*xLowerWindow) (Display *d, Window w); /* 129 */
10121091 void (*reserved130)(void);
10131092 void (*reserved131)(void);
10141093 void (*reserved132)(void);
10171096 void (*reserved135)(void);
10181097 void (*reserved136)(void);
10191098 int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
1099 void (*reserved138)(void);
1100 void (*reserved139)(void);
1101 void (*reserved140)(void);
1102 void (*reserved141)(void);
1103 void (*reserved142)(void);
1104 void (*reserved143)(void);
1105 void (*xDestroyIC) (XIC xic); /* 144 */
1106 Cursor (*xCreatePixmapCursor) (Display *d, Pixmap p1, Pixmap p2, XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2); /* 145 */
1107 Cursor (*xCreateGlyphCursor) (Display *d, Font f1, Font f2, unsigned int ui1, unsigned int ui2, XColor _Xconst *x1, XColor _Xconst *x2); /* 146 */
1108 void (*reserved147)(void);
1109 void (*reserved148)(void);
1110 void (*reserved149)(void);
1111 void (*reserved150)(void);
1112 void (*reserved151)(void);
1113 void (*reserved152)(void);
1114 void (*reserved153)(void);
1115 void (*reserved154)(void);
1116 void (*reserved155)(void);
1117 void (*reserved156)(void);
1118 KeySym (*xkbKeycodeToKeysym) (Display *d, unsigned int k, int g, int i); /* 157 */
1119 void (*tkUnusedStubEntry) (void); /* 158 */
10201120 #endif /* AQUA */
10211121 } TkIntXlibStubs;
10221122
12971397 (tkIntXlibStubsPtr->xReparentWindow) /* 136 */
12981398 #define XPutImage \
12991399 (tkIntXlibStubsPtr->xPutImage) /* 137 */
1400 /* Slot 138 is reserved */
1401 /* Slot 139 is reserved */
1402 /* Slot 140 is reserved */
1403 /* Slot 141 is reserved */
1404 /* Slot 142 is reserved */
1405 /* Slot 143 is reserved */
1406 /* Slot 144 is reserved */
1407 /* Slot 145 is reserved */
1408 /* Slot 146 is reserved */
1409 /* Slot 147 is reserved */
1410 /* Slot 148 is reserved */
1411 /* Slot 149 is reserved */
1412 /* Slot 150 is reserved */
1413 /* Slot 151 is reserved */
1414 /* Slot 152 is reserved */
1415 /* Slot 153 is reserved */
1416 /* Slot 154 is reserved */
1417 /* Slot 155 is reserved */
1418 /* Slot 156 is reserved */
1419 /* Slot 157 is reserved */
1420 #define TkUnusedStubEntry \
1421 (tkIntXlibStubsPtr->tkUnusedStubEntry) /* 158 */
13001422 #endif /* WIN */
13011423 #ifdef MAC_OSX_TK /* AQUA */
13021424 #define XSetDashes \
14971619 /* Slot 103 is reserved */
14981620 /* Slot 104 is reserved */
14991621 /* Slot 105 is reserved */
1500 /* Slot 106 is reserved */
1622 #define XSetClipRectangles \
1623 (tkIntXlibStubsPtr->xSetClipRectangles) /* 106 */
15011624 #define XFlush \
15021625 (tkIntXlibStubsPtr->xFlush) /* 107 */
15031626 #define XGrabServer \
15181641 /* Slot 117 is reserved */
15191642 /* Slot 118 is reserved */
15201643 /* Slot 119 is reserved */
1521 /* Slot 120 is reserved */
1644 #define XOffsetRegion \
1645 (tkIntXlibStubsPtr->xOffsetRegion) /* 120 */
15221646 /* Slot 121 is reserved */
15231647 /* Slot 122 is reserved */
15241648 /* Slot 123 is reserved */
15271651 /* Slot 126 is reserved */
15281652 /* Slot 127 is reserved */
15291653 /* Slot 128 is reserved */
1530 /* Slot 129 is reserved */
1654 #define XLowerWindow \
1655 (tkIntXlibStubsPtr->xLowerWindow) /* 129 */
15311656 /* Slot 130 is reserved */
15321657 /* Slot 131 is reserved */
15331658 /* Slot 132 is reserved */
15371662 /* Slot 136 is reserved */
15381663 #define XPutImage \
15391664 (tkIntXlibStubsPtr->xPutImage) /* 137 */
1665 /* Slot 138 is reserved */
1666 /* Slot 139 is reserved */
1667 /* Slot 140 is reserved */
1668 /* Slot 141 is reserved */
1669 /* Slot 142 is reserved */
1670 /* Slot 143 is reserved */
1671 #define XDestroyIC \
1672 (tkIntXlibStubsPtr->xDestroyIC) /* 144 */
1673 #define XCreatePixmapCursor \
1674 (tkIntXlibStubsPtr->xCreatePixmapCursor) /* 145 */
1675 #define XCreateGlyphCursor \
1676 (tkIntXlibStubsPtr->xCreateGlyphCursor) /* 146 */
1677 /* Slot 147 is reserved */
1678 /* Slot 148 is reserved */
1679 /* Slot 149 is reserved */
1680 /* Slot 150 is reserved */
1681 /* Slot 151 is reserved */
1682 /* Slot 152 is reserved */
1683 /* Slot 153 is reserved */
1684 /* Slot 154 is reserved */
1685 /* Slot 155 is reserved */
1686 /* Slot 156 is reserved */
1687 #define XkbKeycodeToKeysym \
1688 (tkIntXlibStubsPtr->xkbKeycodeToKeysym) /* 157 */
1689 #define TkUnusedStubEntry \
1690 (tkIntXlibStubsPtr->tkUnusedStubEntry) /* 158 */
15401691 #endif /* AQUA */
15411692
15421693 #endif /* defined(USE_TK_STUBS) */
15461697 #undef TCL_STORAGE_CLASS
15471698 #define TCL_STORAGE_CLASS DLLIMPORT
15481699
1700 #undef TkUnusedStubEntry
1701
15491702 #endif /* _TKINTXLIBDECLS */
33173317
33183318 /*
33193319 * We must hold onto the interpreter from the listPtr because the data at
3320 * listPtr might be freed as a result of the Tcl_VarEval.
3320 * listPtr might be freed as a result of the Tcl_EvalEx.
33213321 */
33223322
33233323 interp = listPtr->interp;
33283328 Tcl_DStringAppend(&buf, firstStr, -1);
33293329 Tcl_DStringAppend(&buf, " ", -1);
33303330 Tcl_DStringAppend(&buf, lastStr, -1);
3331 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
3331 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
33323332 Tcl_DStringFree(&buf);
33333333 if (result != TCL_OK) {
33343334 Tcl_AddErrorInfo(interp,
33893389
33903390 /*
33913391 * We must hold onto the interpreter because the data referred to at
3392 * listPtr might be freed as a result of the call to Tcl_VarEval.
3392 * listPtr might be freed as a result of the call to Tcl_EvalEx.
33933393 */
33943394
33953395 interp = listPtr->interp;
34003400 Tcl_DStringAppend(&buf, firstStr, -1);
34013401 Tcl_DStringAppend(&buf, " ", -1);
34023402 Tcl_DStringAppend(&buf, lastStr, -1);
3403 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
3403 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
34043404 Tcl_DStringFree(&buf);
34053405 if (result != TCL_OK) {
34063406 Tcl_AddErrorInfo(interp,
1313 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1414 */
1515
16 /**
17 * On Windows, this file needs to be compiled twice, once with
18 * TK_ASCII_MAIN defined. This way both Tk_MainEx and Tk_MainExW
19 * can be implemented, sharing the same source code.
20 */
21 #if defined(TK_ASCII_MAIN)
22 # ifdef UNICODE
23 # undef UNICODE
24 # undef _UNICODE
25 # else
26 # define UNICODE
27 # define _UNICODE
28 # endif
29 #endif
30
3116 #include "tkInt.h"
32 #include <ctype.h>
33 #include <stdio.h>
34 #include <string.h>
35 #ifdef NO_STDLIB_H
36 # include "../compat/stdlib.h"
37 #else
38 # include <stdlib.h>
39 #endif
4017
4118 extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
4219
5431 * to strcmp here.
5532 */
5633 #ifdef _WIN32
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
5737 /* Little hack to eliminate the need for "tclInt.h" here:
5838 Just copy a small portion of TclIntPlatStubs, just
5939 enough to make it work. See [600b72bfbc] */
6444 int (*tclpIsAtty) (int fd); /* 16 */
6545 } TclIntPlatStubs;
6646 extern const TclIntPlatStubs *tclIntPlatStubsPtr;
47 #ifdef __cplusplus
48 }
49 #endif
6750 # include "tkWinInt.h"
6851 #else
6952 # define TCHAR char
7760 #include "tkMacOSXInt.h"
7861 #endif
7962
80 /*
81 * Further on, in UNICODE mode we just use Tcl_NewUnicodeObj, otherwise
82 * NewNativeObj is needed (which provides proper conversion from native
83 * encoding to UTF-8).
84 */
85
8663 static inline Tcl_Obj *
8764 NewNativeObj(
8865 TCHAR *string)
9067 Tcl_Obj *obj;
9168 Tcl_DString ds;
9269
93 #ifdef UNICODE
94 Tcl_WinTCharToUtf(string, -1, &ds);
70 #if defined(_WIN32) && defined(UNICODE)
71 Tcl_DStringInit(&ds);
72 Tcl_WCharToUtfDString(string, wcslen(string), &ds);
9573 #else
9674 Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
9775 #endif
421399 *----------------------------------------------------------------------
422400 */
423401
424 /* ARGSUSED */
425402 static void
426403 StdinProc(
427404 ClientData clientData, /* The state of interactive cmd line */
428405 int mask) /* Not used. */
429406 {
430407 char *cmd;
431 int code, count;
432 InteractiveState *isPtr = clientData;
408 int code;
409 int count;
410 InteractiveState *isPtr = (InteractiveState *)clientData;
433411 Tcl_Channel chan = isPtr->input;
434412 Tcl_Interp *interp = isPtr->interp;
413 (void)mask;
435414
436415 count = Tcl_Gets(chan, &isPtr->line);
437416
438 if (count == -1 && !isPtr->gotPartial) {
417 if ((count == -1) && !isPtr->gotPartial) {
439418 if (isPtr->tty) {
440419 Tcl_Exit(0);
441420 } else {
3838 * right; they have a Tk window and pathname associated with them; they have a
3939 * TkMenu structure and array of entries. However, they are linked with the
4040 * original menu that they were cloned from. The reflect the attributes of the
41 * original, or "master", menu. So if an item is added to a menu, and that
41 * original, or "main", menu. So if an item is added to a menu, and that
4242 * menu has clones, then the item must be added to all of its clones also.
4343 * Menus are cloned when a menu is torn-off or when a menu is assigned as a
4444 * menubar using the "-menu" option of the toplevel's pathname configure
4545 * subcommand. When a clone is destroyed, only the clone is destroyed, but
46 * when the master menu is destroyed, all clones are also destroyed. This
46 * when the main menu is destroyed, all clones are also destroyed. This
4747 * allows the developer to just deal with one set of menus when creating and
4848 * destroying.
4949 *
512512 nextCascadePtr = cascadeListPtr->nextCascadePtr;
513513
514514 /*
515 * If we have a new master menu, and an existing cloned menu
515 * If we have a new main menu, and an existing cloned menu
516516 * points to this menu in a cascade entry, we have to clone the
517517 * new menu and point the entry to the clone instead of the menu
518518 * we are creating. Otherwise, ConfigureMenuEntry will hook up the
10181018 Tcl_DStringInit(&ds);
10191019 Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1);
10201020 Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1);
1021 result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, 0);
1021 result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, TCL_EVAL_GLOBAL);
10221022 Tcl_DStringFree(&ds);
10231023 } else if ((mePtr->type == CHECK_BUTTON_ENTRY)
10241024 && (mePtr->namePtr != NULL)) {
10991099 TkMenu *menuInstancePtr;
11001100 TkMenuEntry *cascadePtr, *nextCascadePtr;
11011101 Tcl_Obj *newObjv[2];
1102 TkMenu *parentMasterMenuPtr;
1103 TkMenuEntry *parentMasterEntryPtr;
1102 TkMenu *parentMainMenuPtr;
1103 TkMenuEntry *parentMainEntryPtr;
11041104 ThreadSpecificData *tsdPtr =
11051105 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
11061106
11091109 * entries need to be told that the menu is going away. We need to clear
11101110 * the menu ptr field in the menu reference at this point in the code so
11111111 * that everything else can forget about this menu properly. We also need
1112 * to reset -menu field of all entries that are not master menus back to
1113 * this entry name if this is a master menu pointed to by another master
1112 * to reset -menu field of all entries that are not main menus back to
1113 * this entry name if this is a main menu pointed to by another main
11141114 * menu. If there is a clone menu that points to this menu, then this menu
11151115 * is itself a clone, so when this menu goes away, the -menu field of the
1116 * pointing entry must be set back to this menu's master menu name so that
1116 * pointing entry must be set back to this menu's main menu name so that
11171117 * later if another menu is created the cascade hierarchy can be
11181118 * maintained.
11191119 */
11341134 if (menuPtr->masterMenuPtr != menuPtr) {
11351135 Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1);
11361136
1137 parentMasterMenuPtr = cascadePtr->menuPtr->masterMenuPtr;
1138 parentMasterEntryPtr =
1139 parentMasterMenuPtr->entries[cascadePtr->index];
1137 parentMainMenuPtr = cascadePtr->menuPtr->masterMenuPtr;
1138 parentMainEntryPtr =
1139 parentMainMenuPtr->entries[cascadePtr->index];
11401140 newObjv[0] = menuNamePtr;
1141 newObjv[1] = parentMasterEntryPtr->namePtr;
1141 newObjv[1] = parentMainEntryPtr->namePtr;
11421142
11431143 /*
11441144 * It is possible that the menu info is out of sync, and these
11681168 }
11691169 }
11701170 } else if (menuPtr->nextInstancePtr != NULL) {
1171 Tcl_Panic("Attempting to delete master menu when there are still clones");
1171 Tcl_Panic("Attempting to delete main menu when there are still clones");
11721172 }
11731173
11741174 /*
12081208 *
12091209 * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean
12101210 * up the internal structure of a menu at a safe time (when no-one is
1211 * using it anymore). If called on a master instance, destroys all of the
1212 * slave instances. If called on a non-master instance, just destroys
1211 * using it anymore). If called on a main instance, destroys all of the
1212 * instances. If called on a non-main instance, just destroys
12131213 * that instance.
12141214 *
12151215 * Results:
15701570 * menuTypeName field to tell that this is a menu bar.
15711571 */
15721572
1573 if (menuListPtr->menuType == MASTER_MENU) {
1573 if (menuListPtr->menuType == MAIN_MENU) {
15741574 int typeFlag = TK_MAKE_MENU_POPUP;
15751575 Tk_Window tkwin = menuPtr->tkwin;
15761576
16221622 }
16231623 } else if ((menuListPtr->numEntries > 0)
16241624 && (menuListPtr->entries[0]->type == TEAROFF_ENTRY)) {
1625 int i;
16261625
16271626 Tcl_EventuallyFree(menuListPtr->entries[0], (Tcl_FreeProc *) DestroyMenuEntry);
16281627
18181817 if ((mePtr->type == CHECK_BUTTON_ENTRY)
18191818 || (mePtr->type == RADIO_BUTTON_ENTRY)) {
18201819 Tcl_Obj *valuePtr;
1821 const char *name;
18221820
18231821 if (mePtr->namePtr == NULL) {
18241822 if (mePtr->labelPtr == NULL) {
19811979
19821980 /*
19831981 * Cascades are kind of tricky here. This is special case #3 in the
1984 * comment at the top of this file. Basically, if a menu is the master
1982 * comment at the top of this file. Basically, if a menu is the main
19851983 * menu of a clone chain, and has an entry with a cascade menu, the clones
19861984 * of the menu will point to clones of the cascade menu. We have to
19871985 * destroy the clones of the cascades, clone the new cascade menu, and
21432141 }
21442142
21452143 if (isdigit(UCHAR(string[0]))) {
2146 if (Tcl_GetInt(interp, string, &i) == TCL_OK) {
2144 if (Tcl_GetIntFromObj(interp, objPtr, &i) == TCL_OK) {
21472145 if (i >= menuPtr->numEntries) {
21482146 if (lastOK) {
21492147 i = menuPtr->numEntries;
24152413 * If a menu has cascades, then every instance of the menu has to have
24162414 * its own parallel cascade structure. So adding an entry to a menu
24172415 * with clones means that the menu that the entry points to has to be
2418 * cloned for every clone the master menu has. This is special case #2
2416 * cloned for every clone the main menu has. This is special case #2
24192417 * in the comment at the top of this file.
24202418 */
24212419
26962694 Tcl_Obj *menuDupCommandArray[4];
26972695
26982696 if (newMenuTypePtr == NULL) {
2699 menuType = MASTER_MENU;
2697 menuType = MAIN_MENU;
27002698 } else {
27012699 if (Tcl_GetIndexFromObjStruct(menuPtr->interp, newMenuTypePtr,
27022700 menuTypeStrings, sizeof(char *), "menu type", 0, &menuType) != TCL_OK) {
27312729 && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) {
27322730 TkMenu *newMenuPtr = menuRefPtr->menuPtr;
27332731 Tcl_Obj *newObjv[3];
2734 int i, numElements;
2732 int numElements;
27352733
27362734 /*
27372735 * Now put this newly created menu into the parent menu's instance
27512749 }
27522750
27532751 /*
2754 * Add the master menu's window to the bind tags for this window after
2752 * Add the main menu's window to the bind tags for this window after
27552753 * this window's tag. This is so the user can bind to either this
27562754 * clone (which may not be easy to do) or the entire menu clone
27572755 * structure.
1111
1212 #ifndef _TKMENU
1313 #define _TKMENU
14
15 #ifndef _TK
16 #include "tk.h"
17 #endif
1814
1915 #ifndef _TKINT
2016 #include "tkInt.h"
188184 * the menu. */
189185
190186 /*
191 * Bookeeping for master menus and cascade menus.
187 * Bookeeping for main menus and cascade menus.
192188 */
193189
194190 struct TkMenuReferences *childMenuRefPtr;
269265 int numEntries; /* Number of elements in entries. */
270266 int active; /* Index of active entry. -1 means nothing
271267 * active. */
272 int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See
268 int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See
273269 * below for definitions. */
274270 Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
275271 * toplevel or not. "normal", "menubar", or
357353 struct TkMenu *masterMenuPtr;
358354 /* A pointer to the original menu for this
359355 * clone chain. Points back to this structure
360 * if this menu is a master menu. */
356 * if this menu is a main menu. */
361357 void *reserved1; /* not used any more. */
362358 Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the
363359 * toplevel that owns the menu. Only
436432 * MENU_DELETION_PENDING Non-zero means that we are currently
437433 * destroying this menu's internal structures.
438434 * This is useful when we are in the middle of
439 * cleaning this master menu's chain of menus up
435 * cleaning this main menu's chain of menus up
440436 * when TkDestroyMenu was called again on this
441437 * menu (via a destroy binding or somesuch).
442438 * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of
454450 #define MENU_PLATFORM_FLAG3 (1 << 28)
455451
456452 /*
457 * Each menu created by the user is a MASTER_MENU. When a menu is torn off, a
453 * Each menu created by the user is a MAIN_MENU. When a menu is torn off, a
458454 * TEAROFF_MENU instance is created. When a menu is assigned to a toplevel as
459455 * a menu bar, a MENUBAR instance is created. All instances have the same
460 * configuration information. If the master instance is deleted, all instances
456 * configuration information. If the main instance is deleted, all instances
461457 * are deleted. If one of the other instances is deleted, only that instance
462458 * is deleted.
463459 */
464460
465461 #define UNKNOWN_TYPE -1
462 #define MAIN_MENU 0
466463 #define MASTER_MENU 0
467464 #define TEAROFF_MENU 1
468465 #define MENUBAR 2
667667 TkpDrawMenuEntry(mePtr, Tk_WindowId(menuPtr->tkwin), tkfont,
668668 &menuMetrics, mePtr->x, mePtr->y, mePtr->width,
669669 mePtr->height, strictMotif, 1);
670
671 if (mePtr->entryFlags & ENTRY_LAST_COLUMN) {
672
673 /*
674 * Paint the area at the right of an entry in the last column.
675 * This has zero width except after menu resizing.
676 */
677
678 Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border,
679 mePtr->x + mePtr->width, mePtr->y,
680 Tk_Width(tkwin) - mePtr->x - mePtr->width - borderWidth,
681 mePtr->height, 0, TK_RELIEF_FLAT);
682 }
683
670684 if ((index > 0) && (menuPtr->menuType != MENUBAR)
671685 && mePtr->columnBreak) {
686
687 /*
688 * Paint the area under the last entry in a column.
689 */
690
672691 mePtr = menuPtr->entries[index - 1];
673692 Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border,
674693 mePtr->x, mePtr->y + mePtr->height, mePtr->width,
686705 height = Tk_Height(tkwin) - 2 * borderWidth;
687706 } else {
688707 mePtr = menuPtr->entries[menuPtr->numEntries - 1];
708
709 /*
710 * Paint the area under the last entry of the menu.
711 */
712
689713 Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
690714 border, mePtr->x, mePtr->y + mePtr->height, mePtr->width,
691715 Tk_Height(tkwin) - mePtr->y - mePtr->height - borderWidth,
695719 width = Tk_Width(tkwin) - x - borderWidth;
696720 height = Tk_Height(tkwin) - y - borderWidth;
697721 }
722
723 /*
724 * Paint the area at the bottom right of the last entry.
725 * This has zero width except after menu resizing.
726 */
727
698728 Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, x, y,
699729 width, height, 0, TK_RELIEF_FLAT);
700730 }
148148 static ThreadSpecificData *
149149 GetTypeCache(void)
150150 {
151 ThreadSpecificData *tsdPtr =
151 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
152152 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
153153
154154 if (tsdPtr->doubleTypePtr == NULL) {
407407
408408 static void
409409 DupPixelInternalRep(
410 register Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
411 register Tcl_Obj *copyPtr) /* Object with internal rep to set. */
410 Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
411 Tcl_Obj *copyPtr) /* Object with internal rep to set. */
412412 {
413413 copyPtr->typePtr = srcPtr->typePtr;
414414
418418 PixelRep *oldPtr, *newPtr;
419419
420420 oldPtr = GET_COMPLEXPIXEL(srcPtr);
421 newPtr = ckalloc(sizeof(PixelRep));
421 newPtr = (PixelRep *)ckalloc(sizeof(PixelRep));
422422 newPtr->value = oldPtr->value;
423423 newPtr->units = oldPtr->units;
424424 newPtr->tkwin = oldPtr->tkwin;
502502 if ((units < 0) && (i == d)) {
503503 SET_SIMPLEPIXEL(objPtr, i);
504504 } else {
505 PixelRep *pixelPtr = ckalloc(sizeof(PixelRep));
505 PixelRep *pixelPtr = (PixelRep *)ckalloc(sizeof(PixelRep));
506506
507507 pixelPtr->value = d;
508508 pixelPtr->units = units;
563563 }
564564 }
565565
566 mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
566 mmPtr = (MMRep *)objPtr->internalRep.twoPtrValue.ptr1;
567567 if (mmPtr->tkwin != tkwin) {
568568 d = mmPtr->value;
569569 if (mmPtr->units == -1) {
627627
628628 static void
629629 DupMMInternalRep(
630 register Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
631 register Tcl_Obj *copyPtr) /* Object with internal rep to set. */
630 Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
631 Tcl_Obj *copyPtr) /* Object with internal rep to set. */
632632 {
633633 MMRep *oldPtr, *newPtr;
634634
635635 copyPtr->typePtr = srcPtr->typePtr;
636 oldPtr = srcPtr->internalRep.twoPtrValue.ptr1;
637 newPtr = ckalloc(sizeof(MMRep));
636 oldPtr = (MMRep *)srcPtr->internalRep.twoPtrValue.ptr1;
637 newPtr = (MMRep *)ckalloc(sizeof(MMRep));
638638 newPtr->value = oldPtr->value;
639639 newPtr->units = oldPtr->units;
640640 newPtr->tkwin = oldPtr->tkwin;
663663
664664 static void
665665 UpdateStringOfMM(
666 register Tcl_Obj *objPtr) /* pixel obj with string rep to update. */
666 Tcl_Obj *objPtr) /* pixel obj with string rep to update. */
667667 {
668668 MMRep *mmPtr;
669669 char buffer[TCL_DOUBLE_SPACE];
670670 size_t len;
671671
672 mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
672 mmPtr = (MMRep *)objPtr->internalRep.twoPtrValue.ptr1;
673673 /* assert( mmPtr->units == -1 && objPtr->bytes == NULL ); */
674674 if ((mmPtr->units != -1) || (objPtr->bytes != NULL)) {
675675 Tcl_Panic("UpdateStringOfMM: false precondition");
678678 Tcl_PrintDouble(NULL, mmPtr->value, buffer);
679679 len = strlen(buffer);
680680
681 objPtr->bytes = ckalloc(len + 1);
681 objPtr->bytes = (char *)ckalloc(len + 1);
682682 strcpy(objPtr->bytes, buffer);
683683 objPtr->length = len;
684684 }
786786
787787 objPtr->typePtr = &mmObjType;
788788
789 mmPtr = ckalloc(sizeof(MMRep));
789 mmPtr = (MMRep *)ckalloc(sizeof(MMRep));
790790 mmPtr->value = d;
791791 mmPtr->units = units;
792792 mmPtr->tkwin = NULL;
826826 Tk_Window *windowPtr) /* Place to store resulting window. */
827827 {
828828 TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
829 register WindowRep *winPtr;
829 WindowRep *winPtr;
830830
831831 if (objPtr->typePtr != &windowObjType) {
832832 int result = SetWindowFromAny(interp, objPtr);
835835 }
836836 }
837837
838 winPtr = objPtr->internalRep.twoPtrValue.ptr1;
838 winPtr = (WindowRep *)objPtr->internalRep.twoPtrValue.ptr1;
839839 if (winPtr->tkwin == NULL
840840 || winPtr->mainPtr == NULL
841841 || winPtr->mainPtr != mainPtr
881881
882882 static int
883883 SetWindowFromAny(
884 Tcl_Interp *interp, /* Used for error reporting if not NULL. */
885 register Tcl_Obj *objPtr) /* The object to convert. */
884 TCL_UNUSED(Tcl_Interp *),
885 Tcl_Obj *objPtr) /* The object to convert. */
886886 {
887887 const Tcl_ObjType *typePtr;
888888 WindowRep *winPtr;
897897 typePtr->freeIntRepProc(objPtr);
898898 }
899899
900 winPtr = ckalloc(sizeof(WindowRep));
900 winPtr = (WindowRep *)ckalloc(sizeof(WindowRep));
901901 winPtr->tkwin = NULL;
902902 winPtr->mainPtr = NULL;
903903 winPtr->epoch = 0;
992992 {
993993 Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
994994 TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
995 register WindowRep *winPtr;
995 WindowRep *winPtr;
996996
997997 SetWindowFromAny(NULL, objPtr);
998998
8181 * considered. Also, may have
8282 * TK_CONFIG_ARGV_ONLY set. */
8383 {
84 register Tk_ConfigSpec *specPtr, *staticSpecs;
84 Tk_ConfigSpec *specPtr, *staticSpecs;
8585 Tk_Uid value; /* Value of option from database. */
8686 int needFlags; /* Specs must contain this set of flags or
8787 * else they are not considered. */
244244 int hateFlags) /* Flags that must NOT be present in matching
245245 * entry. */
246246 {
247 register Tk_ConfigSpec *specPtr;
248 register char c; /* First character of current argument. */
247 Tk_ConfigSpec *specPtr;
248 char c; /* First character of current argument. */
249249 Tk_ConfigSpec *matchPtr; /* Matching spec, or NULL. */
250250 size_t length;
251251
375375 if (nullValue) {
376376 newStr = NULL;
377377 } else {
378 newStr = ckalloc(strlen(value) + 1);
378 newStr = (char *)ckalloc(strlen(value) + 1);
379379 strcpy(newStr, value);
380380 }
381381 oldStr = *((char **) ptr);
602602 * be present in config specs for them to be
603603 * considered. */
604604 {
605 register Tk_ConfigSpec *specPtr, *staticSpecs;
605 Tk_ConfigSpec *specPtr, *staticSpecs;
606606 int needFlags, hateFlags;
607607 char *list;
608608 const char *leader = "{";
685685 Tcl_Interp *interp, /* Interpreter to use for things like
686686 * floating-point precision. */
687687 Tk_Window tkwin, /* Window corresponding to widget. */
688 register const Tk_ConfigSpec *specPtr,
688 const Tk_ConfigSpec *specPtr,
689689 /* Pointer to information describing
690690 * option. */
691691 char *widgRec) /* Pointer to record holding current values of
862862 result = buffer;
863863 break;
864864 case TK_CONFIG_WINDOW: {
865 Tk_Window tkwin;
866
867865 tkwin = *((Tk_Window *) ptr);
868866 if (tkwin != NULL) {
869867 result = Tk_PathName(tkwin);
970968 *----------------------------------------------------------------------
971969 */
972970
973 /* ARGSUSED */
974971 void
975972 Tk_FreeOptions(
976973 const Tk_ConfigSpec *specs, /* Describes legal options. */
982979 * be present in config specs for them to be
983980 * considered. */
984981 {
985 register const Tk_ConfigSpec *specPtr;
982 const Tk_ConfigSpec *specPtr;
986983 char *ptr;
987984
988985 for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
10701067 * self-initializing code.
10711068 */
10721069
1073 specCacheTablePtr =
1070 specCacheTablePtr = (Tcl_HashTable *)
10741071 Tcl_GetAssocData(interp, "tkConfigSpec.threadTable", NULL);
10751072 if (specCacheTablePtr == NULL) {
1076 specCacheTablePtr = ckalloc(sizeof(Tcl_HashTable));
1073 specCacheTablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
10771074 Tcl_InitHashTable(specCacheTablePtr, TCL_ONE_WORD_KEYS);
10781075 Tcl_SetAssocData(interp, "tkConfigSpec.threadTable",
10791076 DeleteSpecCacheTable, specCacheTablePtr);
10871084 entryPtr = Tcl_CreateHashEntry(specCacheTablePtr, (char *) staticSpecs,
10881085 &isNew);
10891086 if (isNew) {
1090 unsigned int entrySpace = sizeof(Tk_ConfigSpec);
1087 size_t entrySpace = sizeof(Tk_ConfigSpec);
10911088 const Tk_ConfigSpec *staticSpecPtr;
10921089 Tk_ConfigSpec *specPtr;
10931090
11031100
11041101 /*
11051102 * Now allocate our working copy's space and copy over the contents
1106 * from the master copy.
1103 * from the origin.
11071104 */
11081105
1109 cachedSpecs = ckalloc(entrySpace);
1106 cachedSpecs = (Tk_ConfigSpec *)ckalloc(entrySpace);
11101107 memcpy(cachedSpecs, staticSpecs, entrySpace);
11111108 Tcl_SetHashValue(entryPtr, cachedSpecs);
11121109
11301127 }
11311128 }
11321129 } else {
1133 cachedSpecs = Tcl_GetHashValue(entryPtr);
1130 cachedSpecs = (Tk_ConfigSpec *)Tcl_GetHashValue(entryPtr);
11341131 }
11351132
11361133 return cachedSpecs;
11561153 static void
11571154 DeleteSpecCacheTable(
11581155 ClientData clientData,
1159 Tcl_Interp *interp)
1156 TCL_UNUSED(Tcl_Interp *))
11601157 {
1161 Tcl_HashTable *tablePtr = clientData;
1158 Tcl_HashTable *tablePtr = (Tcl_HashTable *)clientData;
11621159 Tcl_HashEntry *entryPtr;
11631160 Tcl_HashSearch search;
11641161
2424 #include "tkInt.h"
2525
2626 /*
27 * The following data structure represents the master for a test image:
28 */
29
30 typedef struct TImageMaster {
31 Tk_ImageMaster master; /* Tk's token for image master. */
27 * The following data structure represents the model for a test image:
28 */
29
30 typedef struct TImageModel {
31 Tk_ImageModel model; /* Tk's token for image model. */
3232 Tcl_Interp *interp; /* Interpreter for application. */
3333 int width, height; /* Dimensions of image. */
3434 char *imageName; /* Name of image (malloc-ed). */
3535 char *varName; /* Name of variable in which to log events for
3636 * image (malloc-ed). */
37 } TImageMaster;
37 } TImageModel;
3838
3939 /*
4040 * The following data structure represents a particular use of a particular
4242 */
4343
4444 typedef struct TImageInstance {
45 TImageMaster *masterPtr; /* Pointer to master for image. */
45 TImageModel *modelPtr; /* Pointer to model for image. */
4646 XColor *fg; /* Foreground color for drawing in image. */
4747 GC gc; /* Graphics context for drawing in image. */
4848 } TImageInstance;
5353
5454 static int ImageCreate(Tcl_Interp *interp,
5555 char *name, int argc, char **argv,
56 Tk_ImageType *typePtr, Tk_ImageMaster master,
56 Tk_ImageType *typePtr, Tk_ImageModel model,
5757 ClientData *clientDataPtr);
5858 static ClientData ImageGet(Tk_Window tkwin, ClientData clientData);
5959 static void ImageDisplay(ClientData clientData,
142142 char **argv, /* Argument strings for options (doesn't
143143 * include image name or type). */
144144 Tk_ImageType *typePtr, /* Pointer to our type record (not used). */
145 Tk_ImageMaster master, /* Token for image, to be used by us in later
145 Tk_ImageModel model, /* Token for image, to be used by us in later
146146 * callbacks. */
147147 ClientData *clientDataPtr) /* Store manager's token for image here; it
148148 * will be returned in later callbacks. */
149149 {
150 TImageMaster *timPtr;
150 TImageModel *timPtr;
151151 const char *varName;
152152 int i;
153153
166166 varName = argv[i+1];
167167 }
168168
169 timPtr = ckalloc(sizeof(TImageMaster));
170 timPtr->master = master;
169 timPtr = ckalloc(sizeof(TImageModel));
170 timPtr->model = model;
171171 timPtr->interp = interp;
172172 timPtr->width = 30;
173173 timPtr->height = 15;
177177 strcpy(timPtr->varName, varName);
178178 Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL);
179179 *clientDataPtr = timPtr;
180 Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15);
180 Tk_ImageChanged(model, 0, 0, 30, 15, 30, 15);
181181 return TCL_OK;
182182 }
183183
206206 int objc, /* Number of arguments. */
207207 Tcl_Obj *const objv[]) /* Argument strings. */
208208 {
209 TImageMaster *timPtr = clientData;
209 TImageModel *timPtr = clientData;
210210 int x, y, width, height;
211211
212212 if (objc < 2) {
227227 || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) {
228228 return TCL_ERROR;
229229 }
230 Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width,
230 Tk_ImageChanged(timPtr->model, x, y, width, height, timPtr->width,
231231 timPtr->height);
232232 } else {
233233 Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]),
259259 ImageGet(
260260 Tk_Window tkwin, /* Token for window in which image will be
261261 * used. */
262 ClientData clientData) /* Pointer to TImageMaster for image. */
263 {
264 TImageMaster *timPtr = clientData;
262 ClientData clientData) /* Pointer to TImageModel for image. */
263 {
264 TImageModel *timPtr = clientData;
265265 TImageInstance *instPtr;
266266 char buffer[100];
267267 XGCValues gcValues;
271271 TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
272272
273273 instPtr = ckalloc(sizeof(TImageInstance));
274 instPtr->masterPtr = timPtr;
274 instPtr->modelPtr = timPtr;
275275 instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
276276 gcValues.foreground = instPtr->fg->pixel;
277277 instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues);
312312 char buffer[200 + TCL_INTEGER_SPACE * 6];
313313
314314 sprintf(buffer, "%s display %d %d %d %d %d %d",
315 instPtr->masterPtr->imageName, imageX, imageY, width, height,
315 instPtr->modelPtr->imageName, imageX, imageY, width, height,
316316 drawableX, drawableY);
317 Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL,
317 Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL,
318318 buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
319 if (width > (instPtr->masterPtr->width - imageX)) {
320 width = instPtr->masterPtr->width - imageX;
321 }
322 if (height > (instPtr->masterPtr->height - imageY)) {
323 height = instPtr->masterPtr->height - imageY;
319 if (width > (instPtr->modelPtr->width - imageX)) {
320 width = instPtr->modelPtr->width - imageX;
321 }
322 if (height > (instPtr->modelPtr->height - imageY)) {
323 height = instPtr->modelPtr->height - imageY;
324324 }
325325 XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY,
326326 (unsigned) (width-1), (unsigned) (height-1));
356356 TImageInstance *instPtr = clientData;
357357 char buffer[200];
358358
359 sprintf(buffer, "%s free", instPtr->masterPtr->imageName);
360 Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL,
359 sprintf(buffer, "%s free", instPtr->modelPtr->imageName);
360 Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL,
361361 buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
362362 Tk_FreeColor(instPtr->fg);
363363 Tk_FreeGC(display, instPtr->gc);
383383
384384 static void
385385 ImageDelete(
386 ClientData clientData) /* Pointer to TImageMaster for image. When
386 ClientData clientData) /* Pointer to TImageModel for image. When
387387 * this function is called, no more instances
388388 * exist. */
389389 {
390 TImageMaster *timPtr = clientData;
390 TImageModel *timPtr = clientData;
391391 char buffer[100];
392392
393393 sprintf(buffer, "%s delete", timPtr->imageName);
253253 * TK_MAX_PRIO. */
254254 {
255255 TkWindow *winPtr = ((TkWindow *) tkwin)->mainPtr->winPtr;
256 register ElArray **arrayPtrPtr;
257 register Element *elPtr;
256 ElArray **arrayPtrPtr;
257 Element *elPtr;
258258 Element newEl;
259 register const char *p;
259 const char *p;
260260 const char *field;
261261 int count, firstField;
262 ptrdiff_t length;
262 size_t length;
263263 #define TMP_SIZE 100
264264 char tmp[TMP_SIZE+1];
265 ThreadSpecificData *tsdPtr =
265 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
266266 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
267267
268268 if (winPtr->mainPtr->optionRootPtr == NULL) {
310310 if (length > TMP_SIZE) {
311311 length = TMP_SIZE;
312312 }
313 strncpy(tmp, field, (size_t) length);
313 strncpy(tmp, field, length);
314314 tmp[length] = 0;
315315 newEl.nameUid = Tk_GetUid(tmp);
316316 if (isupper(UCHAR(*field))) {
405405 * name. */
406406 {
407407 Tk_Uid nameId, classId = NULL;
408 char *masqName;
409 register Element *elPtr, *bestPtr;
410 register int count;
408 const char *masqName;
409 Element *elPtr, *bestPtr;
410 int count;
411411 StackLevel *levelPtr;
412412 int stackDepth[NUM_STACKS];
413 ThreadSpecificData *tsdPtr =
413 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
414414 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
415415
416416 /*
520520 if (masqName != NULL) {
521521 char *masqClass;
522522 Tk_Uid nodeId, winClassId, winNameId;
523 unsigned int classNameLength;
524 register Element *nodePtr, *leafPtr;
523 size_t classNameLength;
524 Element *nodePtr, *leafPtr;
525525 static const int searchOrder[] = {
526526 EXACT_NODE_NAME, WILDCARD_NODE_NAME, EXACT_NODE_CLASS,
527527 WILDCARD_NODE_CLASS, -1
533533 * Extract the masquerade class name from the name field.
534534 */
535535
536 classNameLength = (unsigned) (masqName - name);
537 masqClass = ckalloc(classNameLength + 1);
536 classNameLength = (size_t) (masqName - name);
537 masqClass = (char *)ckalloc(classNameLength + 1);
538538 strncpy(masqClass, name, classNameLength);
539539 masqClass[classNameLength] = '\0';
540540
614614 int objc, /* Number of Tcl_Obj arguments. */
615615 Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */
616616 {
617 Tk_Window tkwin = clientData;
617 Tk_Window tkwin = (Tk_Window)clientData;
618618 int index, result;
619 ThreadSpecificData *tsdPtr =
619 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
620620 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
621621 static const char *const optionCmds[] = {
622622 "add", "clear", "get", "readfile", NULL
737737
738738 void
739739 TkOptionDeadWindow(
740 register TkWindow *winPtr) /* Window to be cleaned up. */
740 TkWindow *winPtr) /* Window to be cleaned up. */
741741 {
742 ThreadSpecificData *tsdPtr =
742 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
743743 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
744744
745745 /*
795795 {
796796 int i, j, *basePtr;
797797 ElArray *arrayPtr;
798 ThreadSpecificData *tsdPtr =
798 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
799799 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
800800
801801 if (winPtr->optionLevel == -1) {
921921 * TK_INTERACTIVE_PRIO. Must be between 0 and
922922 * TK_MAX_PRIO. */
923923 {
924 register char *src, *dst;
924 char *src, *dst;
925925 char *name, *value;
926926 int lineNum;
927927
11141114 Tcl_IncrRefCount(buffer);
11151115 Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
11161116 bufferSize = Tcl_ReadChars(chan, buffer, -1, 0);
1117 if (bufferSize < 0) {
1117 if (bufferSize == -1) {
11181118 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11191119 "error reading file \"%s\": %s",
11201120 fileName, Tcl_PosixError(interp)));
11481148 NewArray(
11491149 int numEls) /* How many elements of space to allocate. */
11501150 {
1151 register ElArray *arrayPtr = ckalloc(EL_ARRAY_SIZE(numEls));
1151 ElArray *arrayPtr = (ElArray *)ckalloc(EL_ARRAY_SIZE(numEls));
11521152
11531153 arrayPtr->arraySize = numEls;
11541154 arrayPtr->numUsed = 0;
11751175
11761176 static ElArray *
11771177 ExtendArray(
1178 register ElArray *arrayPtr, /* Array to be extended. */
1179 register Element *elPtr) /* Element to be copied into array. */
1178 ElArray *arrayPtr, /* Array to be extended. */
1179 Element *elPtr) /* Element to be copied into array. */
11801180 {
11811181 /*
11821182 * If the current array has filled up, make it bigger.
11831183 */
11841184
11851185 if (arrayPtr->numUsed >= arrayPtr->arraySize) {
1186 register int newSize = 2*arrayPtr->arraySize;
1187
1188 arrayPtr = ckrealloc(arrayPtr, EL_ARRAY_SIZE(newSize));
1186 int newSize = 2*arrayPtr->arraySize;
1187
1188 arrayPtr = (ElArray *)ckrealloc(arrayPtr, EL_ARRAY_SIZE(newSize));
11891189 arrayPtr->arraySize = newSize;
11901190 arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed];
11911191 }
12241224 {
12251225 int level, i;
12261226 const int *iPtr;
1227 register StackLevel *levelPtr;
1228 register ElArray *arrayPtr;
1229 ThreadSpecificData *tsdPtr =
1227 StackLevel *levelPtr;
1228 ElArray *arrayPtr;
1229 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
12301230 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
12311231
12321232 /*
13031303 */
13041304
13051305 if (tsdPtr->curLevel >= tsdPtr->numLevels) {
1306 StackLevel *newLevels =
1306 StackLevel *newLevels = (StackLevel *)
13071307 ckalloc(tsdPtr->numLevels * 2 * sizeof(StackLevel));
13081308
13091309 memcpy(newLevels, tsdPtr->levels,
13301330 */
13311331
13321332 for (iPtr = searchOrder; *iPtr != -1; iPtr++) {
1333 register Element *elPtr;
1333 Element *elPtr;
13341334 int count;
13351335 Tk_Uid id;
13361336
13851385 int leaf) /* If zero, then don't copy exact leaf
13861386 * elements. */
13871387 {
1388 register int count;
1389 register Element *elPtr;
1390 ThreadSpecificData *tsdPtr =
1388 int count;
1389 Element *elPtr;
1390 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
13911391 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
13921392
13931393 for (elPtr = arrayPtr->els, count = arrayPtr->numUsed;
14181418
14191419 static void
14201420 OptionThreadExitProc(
1421 ClientData clientData) /* not used */
1421 TCL_UNUSED(void *))
14221422 {
1423 ThreadSpecificData *tsdPtr =
1423 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
14241424 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
14251425
14261426 if (tsdPtr->initialized) {
14521452
14531453 static void
14541454 OptionInit(
1455 register TkMainInfo *mainPtr)
1455 TkMainInfo *mainPtr)
14561456 /* Top-level information about window that
14571457 * isn't initialized yet. */
14581458 {
14591459 int i;
14601460 Tcl_Interp *interp;
1461 ThreadSpecificData *tsdPtr =
1461 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
14621462 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
14631463 Element *defaultMatchPtr = &tsdPtr->defaultMatch;
14641464
14731473 tsdPtr->curLevel = -1;
14741474 tsdPtr->serial = 0;
14751475
1476 tsdPtr->levels = ckalloc(5 * sizeof(StackLevel));
1476 tsdPtr->levels = (StackLevel *)ckalloc(5 * sizeof(StackLevel));
14771477 for (i = 0; i < NUM_STACKS; i++) {
14781478 tsdPtr->stacks[i] = NewArray(10);
14791479 tsdPtr->levels[0].bases[i] = 0;
15201520 ElArray *arrayPtr) /* Array of options; delete everything
15211521 * referred to recursively by this. */
15221522 {
1523 register Element *elPtr;
1523 Element *elPtr;
15241524 int count;
15251525
15261526 for (count = arrayPtr->numUsed, elPtr = arrayPtr->els; count > 0;
1919
2020 /*
2121 * For each window that the packer cares about (either because the window is
22 * managed by the packer or because the window has slaves that are managed by
22 * managed by the packer or because the window has content managed by
2323 * the packer), there is a structure of the following type:
2424 */
2525
2828 * window has been deleted, but the packet
2929 * hasn't had a chance to clean up yet because
3030 * the structure is still in use. */
31 struct Packer *masterPtr; /* Master window within which this window is
31 struct Packer *containerPtr; /* Container window within which this window is
3232 * packed (NULL means this window isn't
3333 * managed by the packer). */
34 struct Packer *nextPtr; /* Next window packed within same master. List
34 struct Packer *nextPtr; /* Next window packed within same container. List
3535 * is priority-ordered: first on list gets
3636 * packed first. */
37 struct Packer *slavePtr; /* First in list of slaves packed inside this
38 * window (NULL means no packed slaves). */
39 Side side; /* Side of master against which this window is
37 struct Packer *contentPtr; /* First in list of content packed inside this
38 * window (NULL means no packed content). */
39 Side side; /* Side of container against which this window is
4040 * packed. */
4141 Tk_Anchor anchor; /* If frame allocated for window is larger
4242 * than window needs, this indicates how where
5454 * each side). */
5555 int doubleBw; /* Twice the window's last known border width.
5656 * If this changes, the window must be
57 * repacked within its master. */
57 * repacked within its container. */
5858 int *abortPtr; /* If non-NULL, it means that there is a
5959 * nested call to ArrangePacking already
6060 * working on this window. *abortPtr may be
6161 * set to 1 to abort that nested call. This
6262 * happens, for example, if tkwin or any of
63 * its slaves is deleted. */
63 * its content is deleted. */
6464 int flags; /* Miscellaneous flags; see below for
6565 * definitions. */
6666 } Packer;
6969 * Flag values for Packer structures:
7070 *
7171 * REQUESTED_REPACK: 1 means a Tcl_DoWhenIdle request has already
72 * been made to repack all the slaves of this
72 * been made to repack all the content of this
7373 * window.
7474 * FILLX: 1 means if frame allocated for window is wider
7575 * than window needs, expand window to fill
7777 * than needed.
7878 * FILLY: Same as FILLX, except for height.
7979 * EXPAND: 1 means this window's frame will absorb any
80 * extra space in the master window.
80 * extra space in the container window.
8181 * OLD_STYLE: 1 means this window is being managed with the
8282 * old-style packer algorithms (before Tk version
8383 * 3.3). The main difference is that padding and
8484 * filling are done differently.
8585 * DONT_PROPAGATE: 1 means don't set this window's requested
86 * size. 0 means if this window is a master then
86 * size. 0 means if this window is a container then
8787 * Tk will set its requested size to fit the
88 * needs of its slaves.
89 * ALLOCED_MASTER 1 means that Pack has allocated itself as
90 * geometry master for this window.
88 * needs of its content.
89 * ALLOCED_CONTAINER 1 means that Pack has allocated itself as
90 * geometry container for this window.
9191 */
9292
9393 #define REQUESTED_REPACK 1
9696 #define EXPAND 8
9797 #define OLD_STYLE 16
9898 #define DONT_PROPAGATE 32
99 #define ALLOCED_MASTER 64
99 #define ALLOCED_CONTAINER 64
100100
101101 /*
102102 * The following structure is the official type record for the packer:
103103 */
104104
105105 static void PackReqProc(ClientData clientData, Tk_Window tkwin);
106 static void PackLostSlaveProc(ClientData clientData,
106 static void PackLostContentProc(ClientData clientData,
107107 Tk_Window tkwin);
108108
109109 static const Tk_GeomMgr packerType = {
110110 "pack", /* name */
111111 PackReqProc, /* requestProc */
112 PackLostSlaveProc, /* lostSlaveProc */
112 PackLostContentProc, /* lostContentProc */
113113 };
114114
115115 /*
117117 */
118118
119119 static void ArrangePacking(ClientData clientData);
120 static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin,
120 static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
121121 int objc, Tcl_Obj *const objv[]);
122122 static void DestroyPacker(void *memPtr);
123123 static Packer * GetPacker(Tk_Window tkwin);
124124 static int PackAfter(Tcl_Interp *interp, Packer *prevPtr,
125 Packer *masterPtr, int objc,Tcl_Obj *const objv[]);
125 Packer *containerPtr, int objc,Tcl_Obj *const objv[]);
126126 static void PackStructureProc(ClientData clientData,
127127 XEvent *eventPtr);
128128 static void Unlink(Packer *packPtr);
129 static int XExpansion(Packer *slavePtr, int cavityWidth);
130 static int YExpansion(Packer *slavePtr, int cavityHeight);
129 static int XExpansion(Packer *contentPtr, int cavityWidth);
130 static int YExpansion(Packer *contentPtr, int cavityHeight);
131131
132132 /*
133133 *------------------------------------------------------------------------
193193 int objc, /* Number of arguments. */
194194 Tcl_Obj *const objv[]) /* Argument objects. */
195195 {
196 Tk_Window tkwin = clientData;
196 Tk_Window tkwin = (Tk_Window)clientData;
197197 const char *argv2;
198198 static const char *const optionStrings[] = {
199199 /* after, append, before and unpack are deprecated */
200 "after", "append", "before", "unpack",
201 "configure", "forget", "info", "propagate", "slaves", NULL };
200 "after", "append", "before", "unpack", "configure",
201 "content", "forget", "info", "propagate", "slaves", NULL };
202202 enum options {
203 PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK,
204 PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES };
203 PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, PACK_CONFIGURE,
204 PACK_CONTENT, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES };
205205 int index;
206206
207207 if (objc >= 2) {
208208 const char *string = Tcl_GetString(objv[1]);
209209
210210 if (string[0] == '.') {
211 return ConfigureSlaves(interp, tkwin, objc-1, objv+1);
211 return ConfigureContent(interp, tkwin, objc-1, objv+1);
212212 }
213213 }
214214 if (objc < 3) {
240240 return TCL_ERROR;
241241 }
242242 prevPtr = GetPacker(tkwin2);
243 if (prevPtr->masterPtr == NULL) {
243 if (prevPtr->containerPtr == NULL) {
244244 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
245245 "window \"%s\" isn't packed", argv2));
246246 Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
247247 return TCL_ERROR;
248248 }
249 return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3);
249 return PackAfter(interp, prevPtr, prevPtr->containerPtr, objc-3, objv+3);
250250 }
251251 case PACK_APPEND: {
252 Packer *masterPtr;
253 register Packer *prevPtr;
252 Packer *containerPtr;
253 Packer *prevPtr;
254254 Tk_Window tkwin2;
255255
256256 if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
257257 return TCL_ERROR;
258258 }
259 masterPtr = GetPacker(tkwin2);
260 prevPtr = masterPtr->slavePtr;
259 containerPtr = GetPacker(tkwin2);
260 prevPtr = containerPtr->contentPtr;
261261 if (prevPtr != NULL) {
262262 while (prevPtr->nextPtr != NULL) {
263263 prevPtr = prevPtr->nextPtr;
264264 }
265265 }
266 return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3);
266 return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3);
267267 }
268268 case PACK_BEFORE: {
269 Packer *packPtr, *masterPtr;
270 register Packer *prevPtr;
269 Packer *packPtr, *containerPtr;
270 Packer *prevPtr;
271271 Tk_Window tkwin2;
272272
273273 if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
274274 return TCL_ERROR;
275275 }
276276 packPtr = GetPacker(tkwin2);
277 if (packPtr->masterPtr == NULL) {
277 if (packPtr->containerPtr == NULL) {
278278 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
279279 "window \"%s\" isn't packed", argv2));
280280 Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
281281 return TCL_ERROR;
282282 }
283 masterPtr = packPtr->masterPtr;
284 prevPtr = masterPtr->slavePtr;
283 containerPtr = packPtr->containerPtr;
284 prevPtr = containerPtr->contentPtr;
285285 if (prevPtr == packPtr) {
286286 prevPtr = NULL;
287287 } else {
294294 }
295295 }
296296 }
297 return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3);
297 return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3);
298298 }
299299 case PACK_CONFIGURE:
300300 if (argv2[0] != '.') {
303303 Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL);
304304 return TCL_ERROR;
305305 }
306 return ConfigureSlaves(interp, tkwin, objc-2, objv+2);
306 return ConfigureContent(interp, tkwin, objc-2, objv+2);
307307 case PACK_FORGET: {
308 Tk_Window slave;
309 Packer *slavePtr;
308 Tk_Window content;
309 Packer *contentPtr;
310310 int i;
311311
312312 for (i = 2; i < objc; i++) {
313 if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) {
313 if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) {
314314 continue;
315315 }
316 slavePtr = GetPacker(slave);
317 if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) {
318 Tk_ManageGeometry(slave, NULL, NULL);
319 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
320 Tk_UnmaintainGeometry(slavePtr->tkwin,
321 slavePtr->masterPtr->tkwin);
322 }
323 Unlink(slavePtr);
324 Tk_UnmapWindow(slavePtr->tkwin);
316 contentPtr = GetPacker(content);
317 if ((contentPtr != NULL) && (contentPtr->containerPtr != NULL)) {
318 Tk_ManageGeometry(content, NULL, NULL);
319 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
320 Tk_UnmaintainGeometry(contentPtr->tkwin,
321 contentPtr->containerPtr->tkwin);
322 }
323 Unlink(contentPtr);
324 Tk_UnmapWindow(contentPtr->tkwin);
325325 }
326326 }
327327 break;
328328 }
329329 case PACK_INFO: {
330 register Packer *slavePtr;
331 Tk_Window slave;
330 Packer *contentPtr;
331 Tk_Window content;
332332 Tcl_Obj *infoObj;
333333
334334 if (objc != 3) {
335335 Tcl_WrongNumArgs(interp, 2, objv, "window");
336336 return TCL_ERROR;
337337 }
338 if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) {
339 return TCL_ERROR;
340 }
341 slavePtr = GetPacker(slave);
342 if (slavePtr->masterPtr == NULL) {
338 if (TkGetWindowFromObj(interp, tkwin, objv[2], &content) != TCL_OK) {
339 return TCL_ERROR;
340 }
341 contentPtr = GetPacker(content);
342 if (contentPtr->containerPtr == NULL) {
343343 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
344344 "window \"%s\" isn't packed", argv2));
345345 Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
348348
349349 infoObj = Tcl_NewObj();
350350 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
351 TkNewWindowObj(slavePtr->masterPtr->tkwin));
351 TkNewWindowObj(contentPtr->containerPtr->tkwin));
352352 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", -1),
353 Tcl_NewStringObj(Tk_NameOfAnchor(slavePtr->anchor), -1));
353 Tcl_NewStringObj(Tk_NameOfAnchor(contentPtr->anchor), -1));
354354 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", -1),
355 Tcl_NewBooleanObj(slavePtr->flags & EXPAND));
356 switch (slavePtr->flags & (FILLX|FILLY)) {
355 Tcl_NewBooleanObj(contentPtr->flags & EXPAND));
356 switch (contentPtr->flags & (FILLX|FILLY)) {
357357 case 0:
358358 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1),
359359 Tcl_NewStringObj("none", -1));
371371 Tcl_NewStringObj("both", -1));
372372 break;
373373 }
374 TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX);
375 TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY);
376 TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft,slavePtr->padX);
377 TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY);
374 TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX);
375 TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY);
376 TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft,contentPtr->padX);
377 TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY);
378378 Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", -1),
379 Tcl_NewStringObj(sideNames[slavePtr->side], -1));
379 Tcl_NewStringObj(sideNames[contentPtr->side], -1));
380380 Tcl_SetObjResult(interp, infoObj);
381381 break;
382382 }
383383 case PACK_PROPAGATE: {
384 Tk_Window master;
385 Packer *masterPtr;
384 Tk_Window container;
385 Packer *containerPtr;
386386 int propagate;
387387
388388 if (objc > 4) {
389389 Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
390390 return TCL_ERROR;
391391 }
392 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
393 return TCL_ERROR;
394 }
395 masterPtr = GetPacker(master);
392 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
393 return TCL_ERROR;
394 }
395 containerPtr = GetPacker(container);
396396 if (objc == 3) {
397397 Tcl_SetObjResult(interp,
398 Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE)));
398 Tcl_NewBooleanObj(!(containerPtr->flags & DONT_PROPAGATE)));
399399 return TCL_OK;
400400 }
401401 if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) {
403403 }
404404 if (propagate) {
405405 /*
406 * If we have slaves, we need to register as geometry master.
406 * If we have content windows, we need to register as geometry container.
407407 */
408408
409 if (masterPtr->slavePtr != NULL) {
410 if (TkSetGeometryMaster(interp, master, "pack") != TCL_OK) {
409 if (containerPtr->contentPtr != NULL) {
410 if (TkSetGeometryContainer(interp, container, "pack") != TCL_OK) {
411411 return TCL_ERROR;
412412 }
413 masterPtr->flags |= ALLOCED_MASTER;
414 }
415 masterPtr->flags &= ~DONT_PROPAGATE;
413 containerPtr->flags |= ALLOCED_CONTAINER;
414 }
415 containerPtr->flags &= ~DONT_PROPAGATE;
416416
417417 /*
418 * Repack the master to allow new geometry information to
419 * propagate upwards to the master's master.
418 * Repack the container to allow new geometry information to
419 * propagate upwards to the container's container.
420420 */
421421
422 if (masterPtr->abortPtr != NULL) {
423 *masterPtr->abortPtr = 1;
424 }
425 if (!(masterPtr->flags & REQUESTED_REPACK)) {
426 masterPtr->flags |= REQUESTED_REPACK;
427 Tcl_DoWhenIdle(ArrangePacking, masterPtr);
422 if (containerPtr->abortPtr != NULL) {
423 *containerPtr->abortPtr = 1;
424 }
425 if (!(containerPtr->flags & REQUESTED_REPACK)) {
426 containerPtr->flags |= REQUESTED_REPACK;
427 Tcl_DoWhenIdle(ArrangePacking, containerPtr);
428428 }
429429 } else {
430 if (masterPtr->flags & ALLOCED_MASTER) {
431 TkFreeGeometryMaster(master, "pack");
432 masterPtr->flags &= ~ALLOCED_MASTER;
433 }
434 masterPtr->flags |= DONT_PROPAGATE;
430 if (containerPtr->flags & ALLOCED_CONTAINER) {
431 TkFreeGeometryContainer(container, "pack");
432 containerPtr->flags &= ~ALLOCED_CONTAINER;
433 }
434 containerPtr->flags |= DONT_PROPAGATE;
435435 }
436436 break;
437437 }
438 case PACK_CONTENT:
438439 case PACK_SLAVES: {
439 Tk_Window master;
440 Packer *masterPtr, *slavePtr;
440 Tk_Window container;
441 Packer *containerPtr, *contentPtr;
441442 Tcl_Obj *resultObj;
442443
443444 if (objc != 3) {
444445 Tcl_WrongNumArgs(interp, 2, objv, "window");
445446 return TCL_ERROR;
446447 }
447 if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) {
448 if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) {
448449 return TCL_ERROR;
449450 }
450451 resultObj = Tcl_NewObj();
451 masterPtr = GetPacker(master);
452 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
453 slavePtr = slavePtr->nextPtr) {
452 containerPtr = GetPacker(container);
453 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
454 contentPtr = contentPtr->nextPtr) {
454455 Tcl_ListObjAppendElement(NULL, resultObj,
455 TkNewWindowObj(slavePtr->tkwin));
456 TkNewWindowObj(contentPtr->tkwin));
456457 }
457458 Tcl_SetObjResult(interp, resultObj);
458459 break;
469470 return TCL_ERROR;
470471 }
471472 packPtr = GetPacker(tkwin2);
472 if ((packPtr != NULL) && (packPtr->masterPtr != NULL)) {
473 if ((packPtr != NULL) && (packPtr->containerPtr != NULL)) {
473474 Tk_ManageGeometry(tkwin2, NULL, NULL);
474 if (packPtr->masterPtr->tkwin != Tk_Parent(packPtr->tkwin)) {
475 if (packPtr->containerPtr->tkwin != Tk_Parent(packPtr->tkwin)) {
475476 Tk_UnmaintainGeometry(packPtr->tkwin,
476 packPtr->masterPtr->tkwin);
477 packPtr->containerPtr->tkwin);
477478 }
478479 Unlink(packPtr);
479480 Tk_UnmapWindow(packPtr->tkwin);
503504 *------------------------------------------------------------------------
504505 */
505506
506 /* ARGSUSED */
507507 static void
508508 PackReqProc(
509509 ClientData clientData, /* Packer's information about window that got
510510 * new preferred geometry. */
511 Tk_Window tkwin) /* Other Tk-related information about the
511 TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
512512 * window. */
513513 {
514 register Packer *packPtr = clientData;
515
516 packPtr = packPtr->masterPtr;
514 Packer *packPtr = (Packer *)clientData;
515
516 packPtr = packPtr->containerPtr;
517517 if (!(packPtr->flags & REQUESTED_REPACK)) {
518518 packPtr->flags |= REQUESTED_REPACK;
519519 Tcl_DoWhenIdle(ArrangePacking, packPtr);
523523 /*
524524 *------------------------------------------------------------------------
525525 *
526 * PackLostSlaveProc --
526 * PackLostContentProc --
527527 *
528528 * This function is invoked by Tk whenever some other geometry claims
529 * control over a slave that used to be managed by us.
529 * control over a content window that used to be managed by us.
530530 *
531531 * Results:
532532 * None.
533533 *
534534 * Side effects:
535 * Forgets all packer-related information about the slave.
535 * Forgets all packer-related information about the content.
536536 *
537537 *------------------------------------------------------------------------
538538 */
539539
540 /* ARGSUSED */
541540 static void
542 PackLostSlaveProc(
543 ClientData clientData, /* Packer structure for slave window that was
541 PackLostContentProc(
542 void *clientData, /* Packer structure for content window that was
544543 * stolen away. */
545 Tk_Window tkwin) /* Tk's handle for the slave window. */
544 TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */
546545 {
547 register Packer *slavePtr = clientData;
548
549 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
550 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
551 }
552 Unlink(slavePtr);
553 Tk_UnmapWindow(slavePtr->tkwin);
546 Packer *contentPtr = (Packer *)clientData;
547
548 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
549 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
550 }
551 Unlink(contentPtr);
552 Tk_UnmapWindow(contentPtr->tkwin);
554553 }
555554
556555 /*
567566 * None.
568567 *
569568 * Side effects:
570 * The packed slaves of masterPtr may get resized or moved.
569 * The packed content of containerPtr may get resized or moved.
571570 *
572571 *------------------------------------------------------------------------
573572 */
574573
575574 static void
576575 ArrangePacking(
577 ClientData clientData) /* Structure describing master whose slaves
576 ClientData clientData) /* Structure describing container whose content
578577 * are to be re-layed out. */
579578 {
580 register Packer *masterPtr = clientData;
581 register Packer *slavePtr;
579 Packer *containerPtr = (Packer *)clientData;
580 Packer *contentPtr;
582581 int cavityX, cavityY, cavityWidth, cavityHeight;
583582 /* These variables keep track of the
584583 * as-yet-unallocated space remaining in the
585 * middle of the master window. */
584 * middle of the container window. */
586585 int frameX, frameY, frameWidth, frameHeight;
587586 /* These variables keep track of the frame
588587 * allocated to the current window. */
595594 int borderLeft, borderRight;
596595 int maxWidth, maxHeight, tmp;
597596
598 masterPtr->flags &= ~REQUESTED_REPACK;
597 containerPtr->flags &= ~REQUESTED_REPACK;
599598
600599 /*
601 * If the master has no slaves anymore, then don't do anything at all:
602 * just leave the master's size as-is.
600 * If the container has no content anymore, then leave the container size as-is.
601 * Otherwise there is no way to "relinquish" control over the container
602 * so another geometry manager can take over.
603603 */
604604
605 if (masterPtr->slavePtr == NULL) {
605 if (containerPtr->contentPtr == NULL) {
606606 return;
607607 }
608608
612612 * necessary.
613613 */
614614
615 if (masterPtr->abortPtr != NULL) {
616 *masterPtr->abortPtr = 1;
617 }
618 masterPtr->abortPtr = &abort;
615 if (containerPtr->abortPtr != NULL) {
616 *containerPtr->abortPtr = 1;
617 }
618 containerPtr->abortPtr = &abort;
619619 abort = 0;
620 Tcl_Preserve(masterPtr);
620 Tcl_Preserve(containerPtr);
621621
622622 /*
623 * Pass #1: scan all the slaves to figure out the total amount of space
623 * Pass #1: scan all the content to figure out the total amount of space
624624 * needed. Two separate width and height values are computed:
625625 *
626626 * width - Holds the sum of the widths (plus padding) of all the
627 * slaves seen so far that were packed LEFT or RIGHT.
627 * content seen so far that were packed LEFT or RIGHT.
628628 * height - Holds the sum of the heights (plus padding) of all the
629 * slaves seen so far that were packed TOP or BOTTOM.
629 * content seen so far that were packed TOP or BOTTOM.
630630 *
631 * maxWidth - Gradually builds up the width needed by the master to
632 * just barely satisfy all the slave's needs. For each
633 * slave, the code computes the width needed for all the
634 * slaves so far and updates maxWidth if the new value is
631 * maxWidth - Gradually builds up the width needed by the container to
632 * just barely satisfy all the content's needs. For each
633 * content, the code computes the width needed for all the
634 * content so far and updates maxWidth if the new value is
635635 * greater.
636636 * maxHeight - Same as maxWidth, except keeps height info.
637637 */
638638
639 width = maxWidth = Tk_InternalBorderLeft(masterPtr->tkwin) +
640 Tk_InternalBorderRight(masterPtr->tkwin);
641 height = maxHeight = Tk_InternalBorderTop(masterPtr->tkwin) +
642 Tk_InternalBorderBottom(masterPtr->tkwin);
643 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
644 slavePtr = slavePtr->nextPtr) {
645 if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
646 tmp = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
647 + slavePtr->padX + slavePtr->iPadX + width;
639 width = maxWidth = Tk_InternalBorderLeft(containerPtr->tkwin) +
640 Tk_InternalBorderRight(containerPtr->tkwin);
641 height = maxHeight = Tk_InternalBorderTop(containerPtr->tkwin) +
642 Tk_InternalBorderBottom(containerPtr->tkwin);
643 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
644 contentPtr = contentPtr->nextPtr) {
645 if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) {
646 tmp = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw
647 + contentPtr->padX + contentPtr->iPadX + width;
648648 if (tmp > maxWidth) {
649649 maxWidth = tmp;
650650 }
651 height += Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
652 + slavePtr->padY + slavePtr->iPadY;
651 height += Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw
652 + contentPtr->padY + contentPtr->iPadY;
653653 } else {
654 tmp = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
655 + slavePtr->padY + slavePtr->iPadY + height;
654 tmp = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw
655 + contentPtr->padY + contentPtr->iPadY + height;
656656 if (tmp > maxHeight) {
657657 maxHeight = tmp;
658658 }
659 width += Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
660 + slavePtr->padX + slavePtr->iPadX;
659 width += Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw
660 + contentPtr->padX + contentPtr->iPadX;
661661 }
662662 }
663663 if (width > maxWidth) {
667667 maxHeight = height;
668668 }
669669
670 if (maxWidth < Tk_MinReqWidth(masterPtr->tkwin)) {
671 maxWidth = Tk_MinReqWidth(masterPtr->tkwin);
672 }
673 if (maxHeight < Tk_MinReqHeight(masterPtr->tkwin)) {
674 maxHeight = Tk_MinReqHeight(masterPtr->tkwin);
670 if (maxWidth < Tk_MinReqWidth(containerPtr->tkwin)) {
671 maxWidth = Tk_MinReqWidth(containerPtr->tkwin);
672 }
673 if (maxHeight < Tk_MinReqHeight(containerPtr->tkwin)) {
674 maxHeight = Tk_MinReqHeight(containerPtr->tkwin);
675675 }
676676
677677 /*
678 * If the total amount of space needed in the master window has changed,
678 * If the total amount of space needed in the container window has changed,
679679 * and if we're propagating geometry information, then notify the next
680680 * geometry manager up and requeue ourselves to start again after the
681 * master has had a chance to resize us.
681 * container has had a chance to resize us.
682682 */
683683
684 if (((maxWidth != Tk_ReqWidth(masterPtr->tkwin))
685 || (maxHeight != Tk_ReqHeight(masterPtr->tkwin)))
686 && !(masterPtr->flags & DONT_PROPAGATE)) {
687 Tk_GeometryRequest(masterPtr->tkwin, maxWidth, maxHeight);
688 masterPtr->flags |= REQUESTED_REPACK;
689 Tcl_DoWhenIdle(ArrangePacking, masterPtr);
684 if (((maxWidth != Tk_ReqWidth(containerPtr->tkwin))
685 || (maxHeight != Tk_ReqHeight(containerPtr->tkwin)))
686 && !(containerPtr->flags & DONT_PROPAGATE)) {
687 Tk_GeometryRequest(containerPtr->tkwin, maxWidth, maxHeight);
688 containerPtr->flags |= REQUESTED_REPACK;
689 Tcl_DoWhenIdle(ArrangePacking, containerPtr);
690690 goto done;
691691 }
692692
693693 /*
694 * Pass #2: scan the slaves a second time assigning new sizes. The
694 * Pass #2: scan the content a second time assigning new sizes. The
695695 * "cavity" variables keep track of the unclaimed space in the cavity of
696696 * the window; this shrinks inward as we allocate windows around the
697697 * edges. The "frame" variables keep track of the space allocated to the
699699 * somewhere inside the frame, depending on anchor.
700700 */
701701
702 cavityX = x = Tk_InternalBorderLeft(masterPtr->tkwin);
703 cavityY = y = Tk_InternalBorderTop(masterPtr->tkwin);
704 cavityWidth = Tk_Width(masterPtr->tkwin) -
705 Tk_InternalBorderLeft(masterPtr->tkwin) -
706 Tk_InternalBorderRight(masterPtr->tkwin);
707 cavityHeight = Tk_Height(masterPtr->tkwin) -
708 Tk_InternalBorderTop(masterPtr->tkwin) -
709 Tk_InternalBorderBottom(masterPtr->tkwin);
710 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
711 slavePtr = slavePtr->nextPtr) {
712 if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
702 cavityX = x = Tk_InternalBorderLeft(containerPtr->tkwin);
703 cavityY = y = Tk_InternalBorderTop(containerPtr->tkwin);
704 cavityWidth = Tk_Width(containerPtr->tkwin) -
705 Tk_InternalBorderLeft(containerPtr->tkwin) -
706 Tk_InternalBorderRight(containerPtr->tkwin);
707 cavityHeight = Tk_Height(containerPtr->tkwin) -
708 Tk_InternalBorderTop(containerPtr->tkwin) -
709 Tk_InternalBorderBottom(containerPtr->tkwin);
710 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
711 contentPtr = contentPtr->nextPtr) {
712 if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) {
713713 frameWidth = cavityWidth;
714 frameHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
715 + slavePtr->padY + slavePtr->iPadY;
716 if (slavePtr->flags & EXPAND) {
717 frameHeight += YExpansion(slavePtr, cavityHeight);
714 frameHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw
715 + contentPtr->padY + contentPtr->iPadY;
716 if (contentPtr->flags & EXPAND) {
717 frameHeight += YExpansion(contentPtr, cavityHeight);
718718 }
719719 cavityHeight -= frameHeight;
720720 if (cavityHeight < 0) {
722722 cavityHeight = 0;
723723 }
724724 frameX = cavityX;
725 if (slavePtr->side == TOP) {
725 if (contentPtr->side == TOP) {
726726 frameY = cavityY;
727727 cavityY += frameHeight;
728728 } else {
730730 }
731731 } else {
732732 frameHeight = cavityHeight;
733 frameWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
734 + slavePtr->padX + slavePtr->iPadX;
735 if (slavePtr->flags & EXPAND) {
736 frameWidth += XExpansion(slavePtr, cavityWidth);
733 frameWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw
734 + contentPtr->padX + contentPtr->iPadX;
735 if (contentPtr->flags & EXPAND) {
736 frameWidth += XExpansion(contentPtr, cavityWidth);
737737 }
738738 cavityWidth -= frameWidth;
739739 if (cavityWidth < 0) {
741741 cavityWidth = 0;
742742 }
743743 frameY = cavityY;
744 if (slavePtr->side == LEFT) {
744 if (contentPtr->side == LEFT) {
745745 frameX = cavityX;
746746 cavityX += frameWidth;
747747 } else {
758758 * completely ignored except when computing frame size).
759759 */
760760
761 if (slavePtr->flags & OLD_STYLE) {
761 if (contentPtr->flags & OLD_STYLE) {
762762 borderX = borderY = 0;
763763 borderTop = borderBtm = 0;
764764 borderLeft = borderRight = 0;
765765 } else {
766 borderX = slavePtr->padX;
767 borderY = slavePtr->padY;
768 borderLeft = slavePtr->padLeft;
766 borderX = contentPtr->padX;
767 borderY = contentPtr->padY;
768 borderLeft = contentPtr->padLeft;
769769 borderRight = borderX - borderLeft;
770 borderTop = slavePtr->padTop;
770 borderTop = contentPtr->padTop;
771771 borderBtm = borderY - borderTop;
772772 }
773 width = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
774 + slavePtr->iPadX;
775 if ((slavePtr->flags & FILLX)
773 width = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw
774 + contentPtr->iPadX;
775 if ((contentPtr->flags & FILLX)
776776 || (width > (frameWidth - borderX))) {
777777 width = frameWidth - borderX;
778778 }
779 height = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
780 + slavePtr->iPadY;
781 if ((slavePtr->flags & FILLY)
779 height = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw
780 + contentPtr->iPadY;
781 if ((contentPtr->flags & FILLY)
782782 || (height > (frameHeight - borderY))) {
783783 height = frameHeight - borderY;
784784 }
785 switch (slavePtr->anchor) {
785 switch (contentPtr->anchor) {
786786 case TK_ANCHOR_N:
787787 x = frameX + (borderLeft + frameWidth - width - borderRight)/2;
788788 y = frameY + borderTop;
822822 default:
823823 Tcl_Panic("bad frame factor in ArrangePacking");
824824 }
825 width -= slavePtr->doubleBw;
826 height -= slavePtr->doubleBw;
825 width -= contentPtr->doubleBw;
826 height -= contentPtr->doubleBw;
827827
828828 /*
829829 * The final step is to set the position, size, and mapped/unmapped
830 * state of the slave. If the slave is a child of the master, then do
830 * state of the content. If the content is a child of the container, then do
831831 * this here. Otherwise let Tk_MaintainGeometry do the work.
832832 */
833833
834 if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
834 if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) {
835835 if ((width <= 0) || (height <= 0)) {
836 Tk_UnmapWindow(slavePtr->tkwin);
836 Tk_UnmapWindow(contentPtr->tkwin);
837837 } else {
838 if ((x != Tk_X(slavePtr->tkwin))
839 || (y != Tk_Y(slavePtr->tkwin))
840 || (width != Tk_Width(slavePtr->tkwin))
841 || (height != Tk_Height(slavePtr->tkwin))) {
842 Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
838 if ((x != Tk_X(contentPtr->tkwin))
839 || (y != Tk_Y(contentPtr->tkwin))
840 || (width != Tk_Width(contentPtr->tkwin))
841 || (height != Tk_Height(contentPtr->tkwin))) {
842 Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height);
843843 }
844844 if (abort) {
845845 goto done;
846846 }
847847
848848 /*
849 * Don't map the slave if the master isn't mapped: wait until
850 * the master gets mapped later.
849 * Don't map the content if the container isn't mapped: wait until
850 * the container gets mapped later.
851851 */
852852
853 if (Tk_IsMapped(masterPtr->tkwin)) {
854 Tk_MapWindow(slavePtr->tkwin);
853 if (Tk_IsMapped(containerPtr->tkwin)) {
854 Tk_MapWindow(contentPtr->tkwin);
855855 }
856856 }
857857 } else {
858858 if ((width <= 0) || (height <= 0)) {
859 Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
860 Tk_UnmapWindow(slavePtr->tkwin);
859 Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin);
860 Tk_UnmapWindow(contentPtr->tkwin);
861861 } else {
862 Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin,
862 Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin,
863863 x, y, width, height);
864864 }
865865 }
876876 }
877877
878878 done:
879 masterPtr->abortPtr = NULL;
880 Tcl_Release(masterPtr);
879 containerPtr->abortPtr = NULL;
880 Tcl_Release(containerPtr);
881881 }
882882
883883 /*
885885 *
886886 * XExpansion --
887887 *
888 * Given a list of packed slaves, the first of which is packed on the
888 * Given a list of packed content, the first of which is packed on the
889889 * left or right and is expandable, compute how much to expand the child.
890890 *
891891 * Results:
900900
901901 static int
902902 XExpansion(
903 register Packer *slavePtr, /* First in list of remaining slaves. */
903 Packer *contentPtr, /* First in list of remaining content. */
904904 int cavityWidth) /* Horizontal space left for all remaining
905 * slaves. */
905 * content. */
906906 {
907907 int numExpand, minExpand, curExpand;
908908 int childWidth;
920920
921921 minExpand = cavityWidth;
922922 numExpand = 0;
923 for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) {
924 childWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
925 + slavePtr->padX + slavePtr->iPadX;
926 if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
923 for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) {
924 childWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw
925 + contentPtr->padX + contentPtr->iPadX;
926 if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) {
927927 if (numExpand) {
928928 curExpand = (cavityWidth - childWidth)/numExpand;
929929 if (curExpand < minExpand) {
932932 }
933933 } else {
934934 cavityWidth -= childWidth;
935 if (slavePtr->flags & EXPAND) {
935 if (contentPtr->flags & EXPAND) {
936936 numExpand++;
937937 }
938938 }
951951 *
952952 * YExpansion --
953953 *
954 * Given a list of packed slaves, the first of which is packed on the top
954 * Given a list of packed content, the first of which is packed on the top
955955 * or bottom and is expandable, compute how much to expand the child.
956956 *
957957 * Results:
966966
967967 static int
968968 YExpansion(
969 register Packer *slavePtr, /* First in list of remaining slaves. */
969 Packer *contentPtr, /* First in list of remaining content. */
970970 int cavityHeight) /* Vertical space left for all remaining
971 * slaves. */
971 * content. */
972972 {
973973 int numExpand, minExpand, curExpand;
974974 int childHeight;
979979
980980 minExpand = cavityHeight;
981981 numExpand = 0;
982 for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) {
983 childHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
984 + slavePtr->padY + slavePtr->iPadY;
985 if ((slavePtr->side == LEFT) || (slavePtr->side == RIGHT)) {
982 for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) {
983 childHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw
984 + contentPtr->padY + contentPtr->iPadY;
985 if ((contentPtr->side == LEFT) || (contentPtr->side == RIGHT)) {
986986 if (numExpand) {
987987 curExpand = (cavityHeight - childHeight)/numExpand;
988988 if (curExpand < minExpand) {
991991 }
992992 } else {
993993 cavityHeight -= childHeight;
994 if (slavePtr->flags & EXPAND) {
994 if (contentPtr->flags & EXPAND) {
995995 numExpand++;
996996 }
997997 }
10291029 Tk_Window tkwin) /* Token for window for which packer structure
10301030 * is desired. */
10311031 {
1032 register Packer *packPtr;
1032 Packer *packPtr;
10331033 Tcl_HashEntry *hPtr;
10341034 int isNew;
10351035 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
10471047 hPtr = Tcl_CreateHashEntry(&dispPtr->packerHashTable, (char *) tkwin,
10481048 &isNew);
10491049 if (!isNew) {
1050 return Tcl_GetHashValue(hPtr);
1051 }
1052 packPtr = ckalloc(sizeof(Packer));
1050 return (Packer *)Tcl_GetHashValue(hPtr);
1051 }
1052 packPtr = (Packer *)ckalloc(sizeof(Packer));
10531053 packPtr->tkwin = tkwin;
1054 packPtr->masterPtr = NULL;
1054 packPtr->containerPtr = NULL;
10551055 packPtr->nextPtr = NULL;
1056 packPtr->slavePtr = NULL;
1056 packPtr->contentPtr = NULL;
10571057 packPtr->side = TOP;
10581058 packPtr->anchor = TK_ANCHOR_CENTER;
10591059 packPtr->padX = packPtr->padY = 0;
10741074 * PackAfter --
10751075 *
10761076 * This function does most of the real work of adding one or more windows
1077 * into the packing order for its master.
1077 * into the packing order for its container.
10781078 *
10791079 * Results:
10801080 * A standard Tcl return value.
10911091 Tcl_Interp *interp, /* Interpreter for error reporting. */
10921092 Packer *prevPtr, /* Pack windows in argv just after this
10931093 * window; NULL means pack as first child of
1094 * masterPtr. */
1095 Packer *masterPtr, /* Master in which to pack windows. */
1094 * containerPtr. */
1095 Packer *containerPtr, /* Container in which to pack windows. */
10961096 int objc, /* Number of elements in objv. */
10971097 Tcl_Obj *const objv[]) /* Array of lists, each containing 2 elements:
10981098 * window name and side against which to
10991099 * pack. */
11001100 {
1101 register Packer *packPtr;
1101 Packer *packPtr;
11021102 Tk_Window tkwin, ancestor, parent;
11031103 Tcl_Obj **options;
11041104 int index, optionCount, c;
11241124 * its parent.
11251125 */
11261126
1127 if (TkGetWindowFromObj(interp, masterPtr->tkwin, objv[0], &tkwin)
1127 if (TkGetWindowFromObj(interp, containerPtr->tkwin, objv[0], &tkwin)
11281128 != TCL_OK) {
11291129 return TCL_ERROR;
11301130 }
11311131
11321132 parent = Tk_Parent(tkwin);
1133 for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
1133 for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
11341134 if (ancestor == parent) {
11351135 break;
11361136 }
11381138 badWindow:
11391139 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11401140 "can't pack %s inside %s", Tcl_GetString(objv[0]),
1141 Tk_PathName(masterPtr->tkwin)));
1141 Tk_PathName(containerPtr->tkwin)));
11421142 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
11431143 return TCL_ERROR;
11441144 }
11461146 if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) {
11471147 goto badWindow;
11481148 }
1149 if (tkwin == masterPtr->tkwin) {
1149 if (tkwin == containerPtr->tkwin) {
11501150 goto badWindow;
11511151 }
11521152 packPtr = GetPacker(tkwin);
11681168 packPtr->flags |= OLD_STYLE;
11691169 for (index = 0 ; index < optionCount; index++) {
11701170 Tcl_Obj *curOptPtr = options[index];
1171 const char *curOpt = Tcl_GetString(curOptPtr);
1172 size_t length = curOptPtr->length;
1171 int length;
1172 const char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length);
11731173
11741174 c = curOpt[0];
11751175
12261226 packPtr->iPadY = 0;
12271227 index++;
12281228 } else if ((c == 'f') && (length > 1)
1229 && (strncmp(curOpt, "frame", (size_t) length) == 0)) {
1229 && (strncmp(curOpt, "frame", length) == 0)) {
12301230 if (optionCount < (index+2)) {
12311231 Tcl_SetObjResult(interp, Tcl_NewStringObj(
12321232 "wrong # args: \"frame\""
12561256 * Unpack this window if it's currently packed.
12571257 */
12581258
1259 if (packPtr->masterPtr != NULL) {
1260 if ((packPtr->masterPtr != masterPtr) &&
1261 (packPtr->masterPtr->tkwin
1259 if (packPtr->containerPtr != NULL) {
1260 if ((packPtr->containerPtr != containerPtr) &&
1261 (packPtr->containerPtr->tkwin
12621262 != Tk_Parent(packPtr->tkwin))) {
12631263 Tk_UnmaintainGeometry(packPtr->tkwin,
1264 packPtr->masterPtr->tkwin);
1264 packPtr->containerPtr->tkwin);
12651265 }
12661266 Unlink(packPtr);
12671267 }
12681268
12691269 /*
1270 * Add the window in the correct place in its master's packing
1270 * Add the window in the correct place in its container's packing
12711271 * order, then make sure that the window is managed by us.
12721272 */
12731273
1274 packPtr->masterPtr = masterPtr;
1274 packPtr->containerPtr = containerPtr;
12751275 if (prevPtr == NULL) {
1276 packPtr->nextPtr = masterPtr->slavePtr;
1277 masterPtr->slavePtr = packPtr;
1276 packPtr->nextPtr = containerPtr->contentPtr;
1277 containerPtr->contentPtr = packPtr;
12781278 } else {
12791279 packPtr->nextPtr = prevPtr->nextPtr;
12801280 prevPtr->nextPtr = packPtr;
12811281 }
12821282 Tk_ManageGeometry(tkwin, &packerType, packPtr);
12831283
1284 if (!(masterPtr->flags & DONT_PROPAGATE)) {
1285 if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack")
1284 if (!(containerPtr->flags & DONT_PROPAGATE)) {
1285 if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack")
12861286 != TCL_OK) {
12871287 Tk_ManageGeometry(tkwin, NULL, NULL);
12881288 Unlink(packPtr);
12891289 return TCL_ERROR;
12901290 }
1291 masterPtr->flags |= ALLOCED_MASTER;
1291 containerPtr->flags |= ALLOCED_CONTAINER;
12921292 }
12931293 }
12941294 }
12951295
12961296 /*
1297 * Arrange for the master to be re-packed at the first idle moment.
1297 * Arrange for the container to be re-packed at the first idle moment.
12981298 */
12991299
1300 if (masterPtr->abortPtr != NULL) {
1301 *masterPtr->abortPtr = 1;
1302 }
1303 if (!(masterPtr->flags & REQUESTED_REPACK)) {
1304 masterPtr->flags |= REQUESTED_REPACK;
1305 Tcl_DoWhenIdle(ArrangePacking, masterPtr);
1300 if (containerPtr->abortPtr != NULL) {
1301 *containerPtr->abortPtr = 1;
1302 }
1303 if (!(containerPtr->flags & REQUESTED_REPACK)) {
1304 containerPtr->flags |= REQUESTED_REPACK;
1305 Tcl_DoWhenIdle(ArrangePacking, containerPtr);
13061306 }
13071307 return TCL_OK;
13081308 }
13121312 *
13131313 * Unlink --
13141314 *
1315 * Remove a packer from its master's list of slaves.
1315 * Remove a packer from its container's list of content.
13161316 *
13171317 * Results:
13181318 * None.
13191319 *
13201320 * Side effects:
1321 * The master will be scheduled for repacking.
1321 * The container will be scheduled for repacking.
13221322 *
13231323 *----------------------------------------------------------------------
13241324 */
13251325
13261326 static void
13271327 Unlink(
1328 register Packer *packPtr) /* Window to unlink. */
1328 Packer *packPtr) /* Window to unlink. */
13291329 {
1330 register Packer *masterPtr, *packPtr2;
1331
1332 masterPtr = packPtr->masterPtr;
1333 if (masterPtr == NULL) {
1330 Packer *containerPtr, *packPtr2;
1331
1332 containerPtr = packPtr->containerPtr;
1333 if (containerPtr == NULL) {
13341334 return;
13351335 }
1336 if (masterPtr->slavePtr == packPtr) {
1337 masterPtr->slavePtr = packPtr->nextPtr;
1336 if (containerPtr->contentPtr == packPtr) {
1337 containerPtr->contentPtr = packPtr->nextPtr;
13381338 } else {
1339 for (packPtr2 = masterPtr->slavePtr; ; packPtr2 = packPtr2->nextPtr) {
1339 for (packPtr2 = containerPtr->contentPtr; ; packPtr2 = packPtr2->nextPtr) {
13401340 if (packPtr2 == NULL) {
13411341 Tcl_Panic("Unlink couldn't find previous window");
13421342 }
13461346 }
13471347 }
13481348 }
1349 if (!(masterPtr->flags & REQUESTED_REPACK)) {
1350 masterPtr->flags |= REQUESTED_REPACK;
1351 Tcl_DoWhenIdle(ArrangePacking, masterPtr);
1352 }
1353 if (masterPtr->abortPtr != NULL) {
1354 *masterPtr->abortPtr = 1;
1355 }
1356
1357 packPtr->masterPtr = NULL;
1349 if (!(containerPtr->flags & REQUESTED_REPACK)) {
1350 containerPtr->flags |= REQUESTED_REPACK;
1351 Tcl_DoWhenIdle(ArrangePacking, containerPtr);
1352 }
1353 if (containerPtr->abortPtr != NULL) {
1354 *containerPtr->abortPtr = 1;
1355 }
1356
1357 packPtr->containerPtr = NULL;
13581358
13591359 /*
1360 * If we have emptied this master from slaves it means we are no longer
1360 * If we have emptied this container from content it means we are no longer
13611361 * handling it and should mark it as free.
13621362 */
13631363
1364 if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
1365 TkFreeGeometryMaster(masterPtr->tkwin, "pack");
1366 masterPtr->flags &= ~ALLOCED_MASTER;
1364 if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) {
1365 TkFreeGeometryContainer(containerPtr->tkwin, "pack");
1366 containerPtr->flags &= ~ALLOCED_CONTAINER;
13671367 }
13681368
13691369 }
13911391 void *memPtr) /* Info about packed window that is now
13921392 * dead. */
13931393 {
1394 register Packer *packPtr = memPtr;
1394 Packer *packPtr = (Packer *)memPtr;
13951395
13961396 ckfree(packPtr);
13971397 }
14091409 *
14101410 * Side effects:
14111411 * If a window was just deleted, clean up all its packer-related
1412 * information. If it was just resized, repack its slaves, if any.
1412 * information. If it was just resized, repack its content, if any.
14131413 *
14141414 *----------------------------------------------------------------------
14151415 */
14201420 * eventPtr. */
14211421 XEvent *eventPtr) /* Describes what just happened. */
14221422 {
1423 register Packer *packPtr = clientData;
1423 Packer *packPtr = (Packer *)clientData;
14241424
14251425 if (eventPtr->type == ConfigureNotify) {
1426 if ((packPtr->slavePtr != NULL)
1426 if ((packPtr->contentPtr != NULL)
14271427 && !(packPtr->flags & REQUESTED_REPACK)) {
14281428 packPtr->flags |= REQUESTED_REPACK;
14291429 Tcl_DoWhenIdle(ArrangePacking, packPtr);
14301430 }
1431 if ((packPtr->masterPtr != NULL)
1431 if ((packPtr->containerPtr != NULL)
14321432 && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) {
1433 if (!(packPtr->masterPtr->flags & REQUESTED_REPACK)) {
1433 if (!(packPtr->containerPtr->flags & REQUESTED_REPACK)) {
14341434 packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width;
1435 packPtr->masterPtr->flags |= REQUESTED_REPACK;
1436 Tcl_DoWhenIdle(ArrangePacking, packPtr->masterPtr);
1435 packPtr->containerPtr->flags |= REQUESTED_REPACK;
1436 Tcl_DoWhenIdle(ArrangePacking, packPtr->containerPtr);
14371437 }
14381438 }
14391439 } else if (eventPtr->type == DestroyNotify) {
1440 register Packer *slavePtr, *nextPtr;
1441
1442 if (packPtr->masterPtr != NULL) {
1440 Packer *contentPtr, *nextPtr;
1441
1442 if (packPtr->containerPtr != NULL) {
14431443 Unlink(packPtr);
14441444 }
14451445
1446 for (slavePtr = packPtr->slavePtr; slavePtr != NULL;
1447 slavePtr = nextPtr) {
1448 Tk_ManageGeometry(slavePtr->tkwin, NULL, NULL);
1449 Tk_UnmapWindow(slavePtr->tkwin);
1450 slavePtr->masterPtr = NULL;
1451 nextPtr = slavePtr->nextPtr;
1452 slavePtr->nextPtr = NULL;
1446 for (contentPtr = packPtr->contentPtr; contentPtr != NULL;
1447 contentPtr = nextPtr) {
1448 Tk_ManageGeometry(contentPtr->tkwin, NULL, NULL);
1449 Tk_UnmapWindow(contentPtr->tkwin);
1450 contentPtr->containerPtr = NULL;
1451 nextPtr = contentPtr->nextPtr;
1452 contentPtr->nextPtr = NULL;
14531453 }
14541454
14551455 if (packPtr->tkwin != NULL) {
14561456 TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr;
14571457 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable,
1458 (char *) packPtr->tkwin));
1458 (void *)packPtr->tkwin));
14591459 }
14601460
14611461 if (packPtr->flags & REQUESTED_REPACK) {
14651465 Tcl_EventuallyFree(packPtr, (Tcl_FreeProc *) DestroyPacker);
14661466 } else if (eventPtr->type == MapNotify) {
14671467 /*
1468 * When a master gets mapped, must redo the geometry computation so
1469 * that all of its slaves get remapped.
1468 * When a container gets mapped, must redo the geometry computation so
1469 * that all of its content get remapped.
14701470 */
14711471
1472 if ((packPtr->slavePtr != NULL)
1472 if ((packPtr->contentPtr != NULL)
14731473 && !(packPtr->flags & REQUESTED_REPACK)) {
14741474 packPtr->flags |= REQUESTED_REPACK;
14751475 Tcl_DoWhenIdle(ArrangePacking, packPtr);
14761476 }
14771477 } else if (eventPtr->type == UnmapNotify) {
1478 register Packer *packPtr2;
1478 Packer *packPtr2;
14791479
14801480 /*
1481 * Unmap all of the slaves when the master gets unmapped, so that they
1481 * Unmap all of the content when the container gets unmapped, so that they
14821482 * don't bother to keep redisplaying themselves.
14831483 */
14841484
1485 for (packPtr2 = packPtr->slavePtr; packPtr2 != NULL;
1485 for (packPtr2 = packPtr->contentPtr; packPtr2 != NULL;
14861486 packPtr2 = packPtr2->nextPtr) {
14871487 Tk_UnmapWindow(packPtr2->tkwin);
14881488 }
14921492 /*
14931493 *----------------------------------------------------------------------
14941494 *
1495 * ConfigureSlaves --
1495 * ConfigureContent --
14961496 *
14971497 * This implements the guts of the "pack configure" command. Given a list
1498 * of slaves and configuration options, it arranges for the packer to
1499 * manage the slaves and sets the specified options.
1498 * of content and configuration options, it arranges for the packer to
1499 * manage the content and sets the specified options.
15001500 *
15011501 * Results:
15021502 * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is returned
15031503 * and the interp's result is set to contain an error message.
15041504 *
15051505 * Side effects:
1506 * Slave windows get taken over by the packer.
1506 * Content windows get taken over by the packer.
15071507 *
15081508 *----------------------------------------------------------------------
15091509 */
15101510
15111511 static int
1512 ConfigureSlaves(
1512 ConfigureContent(
15131513 Tcl_Interp *interp, /* Interpreter for error reporting. */
15141514 Tk_Window tkwin, /* Any window in application containing
1515 * slaves. Used to look up slave names. */
1515 * content. Used to look up content names. */
15161516 int objc, /* Number of elements in argv. */
15171517 Tcl_Obj *const objv[]) /* Argument objects: contains one or more
15181518 * window names followed by any number of
15191519 * "option value" pairs. Caller must make sure
15201520 * that there is at least one window name. */
15211521 {
1522 Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr;
1523 Tk_Window other, slave, parent, ancestor;
1524 TkWindow *master;
1522 Packer *containerPtr, *contentPtr, *prevPtr, *otherPtr;
1523 Tk_Window other, content, parent, ancestor;
1524 TkWindow *container;
15251525 int i, j, numWindows, tmp, positionGiven;
15261526 const char *string;
15271527 static const char *const optionStrings[] = {
15441544 }
15451545
15461546 /*
1547 * Iterate over all of the slave windows, parsing the configuration
1548 * options for each slave. It's a bit wasteful to re-parse the options for
1549 * each slave, but things get too messy if we try to parse the arguments
1550 * just once at the beginning. For example, if a slave already is packed
1547 * Iterate over all of the content windows, parsing the configuration
1548 * options for each content. It's a bit wasteful to re-parse the options for
1549 * each content, but things get too messy if we try to parse the arguments
1550 * just once at the beginning. For example, if a content already is packed
15511551 * we want to just change a few existing values without resetting
15521552 * everything. If there are multiple windows, the -after, -before, and -in
15531553 * options only get processed for the first window.
15541554 */
15551555
1556 masterPtr = NULL;
1556 containerPtr = NULL;
15571557 prevPtr = NULL;
15581558 positionGiven = 0;
15591559 for (j = 0; j < numWindows; j++) {
1560 if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) {
1561 return TCL_ERROR;
1562 }
1563 if (Tk_TopWinHierarchy(slave)) {
1560 if (TkGetWindowFromObj(interp, tkwin, objv[j], &content) != TCL_OK) {
1561 return TCL_ERROR;
1562 }
1563 if (Tk_TopWinHierarchy(content)) {
15641564 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
15651565 "can't pack \"%s\": it's a top-level window",
15661566 Tcl_GetString(objv[j])));
15671567 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL);
15681568 return TCL_ERROR;
15691569 }
1570 slavePtr = GetPacker(slave);
1571 slavePtr->flags &= ~OLD_STYLE;
1570 contentPtr = GetPacker(content);
1571 contentPtr->flags &= ~OLD_STYLE;
15721572
15731573 /*
1574 * If the slave isn't currently packed, reset all of its configuration
1574 * If the content isn't currently packed, reset all of its configuration
15751575 * information to default values (there could be old values left from
15761576 * a previous packing).
15771577 */
15781578
1579 if (slavePtr->masterPtr == NULL) {
1580 slavePtr->side = TOP;
1581 slavePtr->anchor = TK_ANCHOR_CENTER;
1582 slavePtr->padX = slavePtr->padY = 0;
1583 slavePtr->padLeft = slavePtr->padTop = 0;
1584 slavePtr->iPadX = slavePtr->iPadY = 0;
1585 slavePtr->flags &= ~(FILLX|FILLY|EXPAND);
1579 if (contentPtr->containerPtr == NULL) {
1580 contentPtr->side = TOP;
1581 contentPtr->anchor = TK_ANCHOR_CENTER;
1582 contentPtr->padX = contentPtr->padY = 0;
1583 contentPtr->padLeft = contentPtr->padTop = 0;
1584 contentPtr->iPadX = contentPtr->iPadY = 0;
1585 contentPtr->flags &= ~(FILLX|FILLY|EXPAND);
15861586 }
15871587
15881588 for (i = numWindows; i < objc; i+=2) {
16061606 return TCL_ERROR;
16071607 }
16081608 prevPtr = GetPacker(other);
1609 if (prevPtr->masterPtr == NULL) {
1609 if (prevPtr->containerPtr == NULL) {
16101610 notPacked:
16111611 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
16121612 "window \"%s\" isn't packed",
16151615 NULL);
16161616 return TCL_ERROR;
16171617 }
1618 masterPtr = prevPtr->masterPtr;
1618 containerPtr = prevPtr->containerPtr;
16191619 positionGiven = 1;
16201620 }
16211621 break;
16221622 case CONF_ANCHOR:
1623 if (Tk_GetAnchorFromObj(interp, objv[i+1], &slavePtr->anchor)
1623 if (Tk_GetAnchorFromObj(interp, objv[i+1], &contentPtr->anchor)
16241624 != TCL_OK) {
16251625 return TCL_ERROR;
16261626 }
16321632 return TCL_ERROR;
16331633 }
16341634 otherPtr = GetPacker(other);
1635 if (otherPtr->masterPtr == NULL) {
1635 if (otherPtr->containerPtr == NULL) {
16361636 goto notPacked;
16371637 }
1638 masterPtr = otherPtr->masterPtr;
1639 prevPtr = masterPtr->slavePtr;
1638 containerPtr = otherPtr->containerPtr;
1639 prevPtr = containerPtr->contentPtr;
16401640 if (prevPtr == otherPtr) {
16411641 prevPtr = NULL;
16421642 } else {
16511651 if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
16521652 return TCL_ERROR;
16531653 }
1654 slavePtr->flags &= ~EXPAND;
1654 contentPtr->flags &= ~EXPAND;
16551655 if (tmp) {
1656 slavePtr->flags |= EXPAND;
1656 contentPtr->flags |= EXPAND;
16571657 }
16581658 break;
16591659 case CONF_FILL:
16601660 string = Tcl_GetString(objv[i+1]);
16611661 if (strcmp(string, "none") == 0) {
1662 slavePtr->flags &= ~(FILLX|FILLY);
1662 contentPtr->flags &= ~(FILLX|FILLY);
16631663 } else if (strcmp(string, "x") == 0) {
1664 slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX;
1664 contentPtr->flags = (contentPtr->flags & ~FILLY) | FILLX;
16651665 } else if (strcmp(string, "y") == 0) {
1666 slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY;
1666 contentPtr->flags = (contentPtr->flags & ~FILLX) | FILLY;
16671667 } else if (strcmp(string, "both") == 0) {
1668 slavePtr->flags |= FILLX|FILLY;
1668 contentPtr->flags |= FILLX|FILLY;
16691669 } else {
16701670 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
16711671 "bad fill style \"%s\": must be "
16801680 != TCL_OK) {
16811681 return TCL_ERROR;
16821682 }
1683 masterPtr = GetPacker(other);
1684 prevPtr = masterPtr->slavePtr;
1683 containerPtr = GetPacker(other);
1684 prevPtr = containerPtr->contentPtr;
16851685 if (prevPtr != NULL) {
16861686 while (prevPtr->nextPtr != NULL) {
16871687 prevPtr = prevPtr->nextPtr;
16911691 }
16921692 break;
16931693 case CONF_IPADX:
1694 if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp)
1694 if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp)
16951695 != TCL_OK) || (tmp < 0)) {
16961696 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
16971697 "bad ipadx value \"%s\": must be positive screen"
16991699 Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
17001700 return TCL_ERROR;
17011701 }
1702 slavePtr->iPadX = tmp * 2;
1702 contentPtr->iPadX = tmp * 2;
17031703 break;
17041704 case CONF_IPADY:
1705 if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp)
1705 if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp)
17061706 != TCL_OK) || (tmp < 0)) {
17071707 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
17081708 "bad ipady value \"%s\": must be positive screen"
17101710 Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
17111711 return TCL_ERROR;
17121712 }
1713 slavePtr->iPadY = tmp * 2;
1713 contentPtr->iPadY = tmp * 2;
17141714 break;
17151715 case CONF_PADX:
1716 if (TkParsePadAmount(interp, slave, objv[i+1],
1717 &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) {
1716 if (TkParsePadAmount(interp, content, objv[i+1],
1717 &contentPtr->padLeft, &contentPtr->padX) != TCL_OK) {
17181718 return TCL_ERROR;
17191719 }
17201720 break;
17211721 case CONF_PADY:
1722 if (TkParsePadAmount(interp, slave, objv[i+1],
1723 &slavePtr->padTop, &slavePtr->padY) != TCL_OK) {
1722 if (TkParsePadAmount(interp, content, objv[i+1],
1723 &contentPtr->padTop, &contentPtr->padY) != TCL_OK) {
17241724 return TCL_ERROR;
17251725 }
17261726 break;
17291729 sizeof(char *), "side", TCL_EXACT, &side) != TCL_OK) {
17301730 return TCL_ERROR;
17311731 }
1732 slavePtr->side = (Side) side;
1732 contentPtr->side = (Side) side;
17331733 break;
17341734 }
17351735 }
17361736
17371737 /*
1738 * If no position in a packing list was specified and the slave is
1738 * If no position in a packing list was specified and the content is
17391739 * already packed, then leave it in its current location in its
17401740 * current packing list.
17411741 */
17421742
1743 if (!positionGiven && (slavePtr->masterPtr != NULL)) {
1744 masterPtr = slavePtr->masterPtr;
1743 if (!positionGiven && (contentPtr->containerPtr != NULL)) {
1744 containerPtr = contentPtr->containerPtr;
17451745 goto scheduleLayout;
17461746 }
17471747
17481748 /*
1749 * If the slave is going to be put back after itself or the same -in
1749 * If the content is going to be put back after itself or the same -in
17501750 * window is passed in again, then just skip the whole operation,
17511751 * since it won't work anyway.
17521752 */
17531753
1754 if (prevPtr == slavePtr) {
1755 masterPtr = slavePtr->masterPtr;
1754 if (prevPtr == contentPtr) {
1755 containerPtr = contentPtr->containerPtr;
17561756 goto scheduleLayout;
17571757 }
17581758
17591759 /*
17601760 * If none of the "-in", "-before", or "-after" options has been
1761 * specified, arrange for the slave to go at the end of the order for
1761 * specified, arrange for the content to go at the end of the order for
17621762 * its parent.
17631763 */
17641764
17651765 if (!positionGiven) {
1766 masterPtr = GetPacker(Tk_Parent(slave));
1767 prevPtr = masterPtr->slavePtr;
1766 containerPtr = GetPacker(Tk_Parent(content));
1767 prevPtr = containerPtr->contentPtr;
17681768 if (prevPtr != NULL) {
17691769 while (prevPtr->nextPtr != NULL) {
17701770 prevPtr = prevPtr->nextPtr;
17731773 }
17741774
17751775 /*
1776 * Make sure that the slave's parent is either the master or an
1777 * ancestor of the master, and that the master and slave aren't the
1776 * Make sure that the content's parent is either the container or an
1777 * ancestor of the container, and that the container and content aren't the
17781778 * same.
17791779 */
17801780
1781 parent = Tk_Parent(slave);
1782 for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
1781 parent = Tk_Parent(content);
1782 for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
17831783 if (ancestor == parent) {
17841784 break;
17851785 }
17861786 if (Tk_TopWinHierarchy(ancestor)) {
17871787 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
17881788 "can't pack %s inside %s", Tcl_GetString(objv[j]),
1789 Tk_PathName(masterPtr->tkwin)));
1789 Tk_PathName(containerPtr->tkwin)));
17901790 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
17911791 return TCL_ERROR;
17921792 }
17931793 }
1794 if (slave == masterPtr->tkwin) {
1794 if (content == containerPtr->tkwin) {
17951795 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
17961796 "can't pack %s inside itself", Tcl_GetString(objv[j])));
17971797 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
18021802 * Check for management loops.
18031803 */
18041804
1805 for (master = (TkWindow *)masterPtr->tkwin; master != NULL;
1806 master = (TkWindow *)TkGetGeomMaster(master)) {
1807 if (master == (TkWindow *)slave) {
1805 for (container = (TkWindow *)containerPtr->tkwin; container != NULL;
1806 container = (TkWindow *)TkGetContainer(container)) {
1807 if (container == (TkWindow *)content) {
18081808 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
18091809 "can't put %s inside %s, would cause management loop",
1810 Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin)));
1810 Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin)));
18111811 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
18121812 return TCL_ERROR;
18131813 }
18141814 }
1815 if (masterPtr->tkwin != Tk_Parent(slave)) {
1816 ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin;
1815 if (containerPtr->tkwin != Tk_Parent(content)) {
1816 ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
18171817 }
18181818
18191819 /*
1820 * Unpack the slave if it's currently packed, then position it after
1820 * Unpack the content if it's currently packed, then position it after
18211821 * prevPtr.
18221822 */
18231823
1824 if (slavePtr->masterPtr != NULL) {
1825 if ((slavePtr->masterPtr != masterPtr) &&
1826 (slavePtr->masterPtr->tkwin
1827 != Tk_Parent(slavePtr->tkwin))) {
1828 Tk_UnmaintainGeometry(slavePtr->tkwin,
1829 slavePtr->masterPtr->tkwin);
1830 }
1831 Unlink(slavePtr);
1832 }
1833
1834 slavePtr->masterPtr = masterPtr;
1824 if (contentPtr->containerPtr != NULL) {
1825 if ((contentPtr->containerPtr != containerPtr) &&
1826 (contentPtr->containerPtr->tkwin
1827 != Tk_Parent(contentPtr->tkwin))) {
1828 Tk_UnmaintainGeometry(contentPtr->tkwin,
1829 contentPtr->containerPtr->tkwin);
1830 }
1831 Unlink(contentPtr);
1832 }
1833
1834 contentPtr->containerPtr = containerPtr;
18351835 if (prevPtr == NULL) {
1836 slavePtr->nextPtr = masterPtr->slavePtr;
1837 masterPtr->slavePtr = slavePtr;
1836 contentPtr->nextPtr = containerPtr->contentPtr;
1837 containerPtr->contentPtr = contentPtr;
18381838 } else {
1839 slavePtr->nextPtr = prevPtr->nextPtr;
1840 prevPtr->nextPtr = slavePtr;
1841 }
1842 Tk_ManageGeometry(slave, &packerType, slavePtr);
1843 prevPtr = slavePtr;
1844
1845 if (!(masterPtr->flags & DONT_PROPAGATE)) {
1846 if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack")
1839 contentPtr->nextPtr = prevPtr->nextPtr;
1840 prevPtr->nextPtr = contentPtr;
1841 }
1842 Tk_ManageGeometry(content, &packerType, contentPtr);
1843 prevPtr = contentPtr;
1844
1845 if (!(containerPtr->flags & DONT_PROPAGATE)) {
1846 if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack")
18471847 != TCL_OK) {
1848 Tk_ManageGeometry(slave, NULL, NULL);
1849 Unlink(slavePtr);
1848 Tk_ManageGeometry(content, NULL, NULL);
1849 Unlink(contentPtr);
18501850 return TCL_ERROR;
18511851 }
1852 masterPtr->flags |= ALLOCED_MASTER;
1852 containerPtr->flags |= ALLOCED_CONTAINER;
18531853 }
18541854
18551855 /*
1856 * Arrange for the master to be re-packed at the first idle moment.
1856 * Arrange for the container to be re-packed at the first idle moment.
18571857 */
18581858
18591859 scheduleLayout:
1860 if (masterPtr->abortPtr != NULL) {
1861 *masterPtr->abortPtr = 1;
1862 }
1863 if (!(masterPtr->flags & REQUESTED_REPACK)) {
1864 masterPtr->flags |= REQUESTED_REPACK;
1865 Tcl_DoWhenIdle(ArrangePacking, masterPtr);
1860 if (containerPtr->abortPtr != NULL) {
1861 *containerPtr->abortPtr = 1;
1862 }
1863 if (!(containerPtr->flags & REQUESTED_REPACK)) {
1864 containerPtr->flags |= REQUESTED_REPACK;
1865 Tcl_DoWhenIdle(ArrangePacking, containerPtr);
18661866 }
18671867 }
18681868 return TCL_OK;
1212 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1313 */
1414
15 #include "tkInt.h"
1516 #include "default.h"
16 #include "tkInt.h"
1717
1818 /*
1919 * Flag values for "sticky"ness. The 16 combinations subsume the packer's
6969
7070 typedef struct {
7171 Tk_OptionTable pwOptions; /* Token for paned window option table. */
72 Tk_OptionTable slaveOpts; /* Token for slave cget option table. */
72 Tk_OptionTable paneOpts; /* Token for pane cget option table. */
7373 } OptionTables;
7474
7575 /*
7777 * managed by a paned window widget.
7878 */
7979
80 typedef struct Slave {
80 typedef struct Pane {
8181 Tk_Window tkwin; /* Window being managed. */
8282 int minSize; /* Minimum size of this pane, on the relevant
8383 * axis, in pixels. */
84 int padx; /* Additional padding requested for slave, in
84 int padx; /* Additional padding requested for pane, in
8585 * the x dimension. */
86 int pady; /* Additional padding requested for slave, in
86 int pady; /* Additional padding requested for pane, in
8787 * the y dimension. */
8888 Tcl_Obj *widthPtr, *heightPtr;
89 /* Tcl_Obj rep's of slave width/height, to
89 /* Tcl_Obj rep's of pane width/height, to
9090 * allow for null values. */
91 int width; /* Slave width. */
92 int height; /* Slave height. */
91 int width; /* Pane width. */
92 int height; /* Pane height. */
9393 int sticky; /* Sticky string. */
9494 int x, y; /* Coordinates of the widget. */
9595 int paneWidth, paneHeight; /* Pane dimensions (may be different from
96 * slave width/height). */
96 * pane width/height). */
9797 int sashx, sashy; /* Coordinates of the sash of the right or
9898 * bottom of this pane. */
9999 int markx, marky; /* Coordinates of the last mark set for the
100100 * sash. */
101101 int handlex, handley; /* Coordinates of the sash handle. */
102 enum stretch stretch; /* Controls how slave grows/shrinks */
102 enum stretch stretch; /* Controls how pane grows/shrinks */
103103 int hide; /* Controls visibility of pane */
104 struct PanedWindow *masterPtr;
104 struct PanedWindow *containerPtr;
105105 /* Paned window managing the window. */
106106 Tk_Window after; /* Placeholder for parsing options. */
107107 Tk_Window before; /* Placeholder for parsing options. */
108 } Slave;
108 } Pane;
109109
110110 /*
111111 * A data structure of the following type is kept for each paned window widget
120120 Tcl_Command widgetCmd; /* Token for square's widget command. */
121121 Tk_OptionTable optionTable; /* Token representing the configuration
122122 * specifications. */
123 Tk_OptionTable slaveOpts; /* Token for slave cget table. */
123 Tk_OptionTable paneOpts; /* Token for pane cget table. */
124124 Tk_3DBorder background; /* Background color. */
125125 int borderWidth; /* Value of -borderwidth option. */
126126 int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */
150150 Tcl_Obj *proxyBorderWidthPtr; /* Tcl_Obj rep for proxyBorderWidth */
151151 int proxyBorderWidth; /* Borderwidth used to draw proxy. */
152152 int proxyRelief; /* Relief used to draw proxy, if TK_RELIEF_NULL then use relief. */
153 Slave **slaves; /* Pointer to array of Slaves. */
154 int numSlaves; /* Number of slaves. */
155 int sizeofSlaves; /* Number of elements in the slaves array. */
153 Pane **panes; /* Pointer to array of Panes. */
154 int numPanes; /* Number of panes. */
155 int sizeofPanes; /* Number of elements in the panes array. */
156156 int flags; /* Flags for widget; see below. */
157157 } PanedWindow;
158158
199199 static void PanedWindowWorldChanged(ClientData instanceData);
200200 static int PanedWindowWidgetObjCmd(ClientData clientData,
201201 Tcl_Interp *, int objc, Tcl_Obj * const objv[]);
202 static void PanedWindowLostSlaveProc(ClientData clientData,
202 static void PanedWindowLostPaneProc(ClientData clientData,
203203 Tk_Window tkwin);
204204 static void PanedWindowReqProc(ClientData clientData,
205205 Tk_Window tkwin);
206206 static void ArrangePanes(ClientData clientData);
207 static void Unlink(Slave *slavePtr);
208 static Slave * GetPane(PanedWindow *pwPtr, Tk_Window tkwin);
207 static void Unlink(Pane *panePtr);
208 static Pane * GetPane(PanedWindow *pwPtr, Tk_Window tkwin);
209209 static void GetFirstLastVisiblePane(PanedWindow *pwPtr,
210210 int *firstPtr, int *lastPtr);
211 static void SlaveStructureProc(ClientData clientData,
211 static void PaneStructureProc(ClientData clientData,
212212 XEvent *eventPtr);
213213 static int PanedWindowSashCommand(PanedWindow *pwPtr,
214214 Tcl_Interp *interp, int objc,
217217 Tcl_Interp *interp, int objc,
218218 Tcl_Obj * const objv[]);
219219 static void ComputeGeometry(PanedWindow *pwPtr);
220 static int ConfigureSlaves(PanedWindow *pwPtr,
220 static int ConfigurePanes(PanedWindow *pwPtr,
221221 Tcl_Interp *interp, int objc,
222222 Tcl_Obj * const objv[]);
223223 static void DestroyOptionTables(ClientData clientData,
232232 char *internalPtr, char *oldInternalPtr);
233233 static void AdjustForSticky(int sticky, int cavityWidth,
234234 int cavityHeight, int *xPtr, int *yPtr,
235 int *slaveWidthPtr, int *slaveHeightPtr);
235 int *paneWidthPtr, int *paneHeightPtr);
236236 static void MoveSash(PanedWindow *pwPtr, int sash, int diff);
237237 static int ObjectIsEmpty(Tcl_Obj *objPtr);
238238 static char * ComputeSlotAddress(char *recordPtr, int offset);
240240 Tcl_Interp *interp, int x, int y);
241241
242242 /*
243 * Sashes are between panes only, so there is one less sash than slaves
243 * Sashes are between panes only, so there is one less sash than panes
244244 */
245245
246246 #define ValidSashIndex(pwPtr, sash) \
247 (((sash) >= 0) && ((sash) < ((pwPtr)->numSlaves-1)))
247 (((sash) >= 0) && ((sash) < ((pwPtr)->numPanes-1)))
248248
249249 static const Tk_GeomMgr panedWindowMgrType = {
250250 "panedwindow", /* name */
251251 PanedWindowReqProc, /* requestProc */
252 PanedWindowLostSlaveProc, /* lostSlaveProc */
252 PanedWindowLostPaneProc, /* lostPaneProc */
253253 };
254254
255255 /*
260260
261261 /*
262262 * The following structure contains pointers to functions used for processing
263 * the custom "-sticky" option for slave windows.
263 * the custom "-sticky" option for panes.
264264 */
265265
266266 static const Tk_ObjCustomOption stickyOption = {
333333 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
334334 };
335335
336 static const Tk_OptionSpec slaveOptionSpecs[] = {
336 static const Tk_OptionSpec paneOptionSpecs[] = {
337337 {TK_OPTION_WINDOW, "-after", NULL, NULL,
338 DEF_PANEDWINDOW_PANE_AFTER, -1, Tk_Offset(Slave, after),
338 DEF_PANEDWINDOW_PANE_AFTER, -1, Tk_Offset(Pane, after),
339339 TK_OPTION_NULL_OK, 0, 0},
340340 {TK_OPTION_WINDOW, "-before", NULL, NULL,
341 DEF_PANEDWINDOW_PANE_BEFORE, -1, Tk_Offset(Slave, before),
341 DEF_PANEDWINDOW_PANE_BEFORE, -1, Tk_Offset(Pane, before),
342342 TK_OPTION_NULL_OK, 0, 0},
343343 {TK_OPTION_PIXELS, "-height", NULL, NULL,
344 DEF_PANEDWINDOW_PANE_HEIGHT, Tk_Offset(Slave, heightPtr),
345 Tk_Offset(Slave, height), TK_OPTION_NULL_OK, 0, 0},
344 DEF_PANEDWINDOW_PANE_HEIGHT, Tk_Offset(Pane, heightPtr),
345 Tk_Offset(Pane, height), TK_OPTION_NULL_OK, 0, 0},
346346 {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
347 DEF_PANEDWINDOW_PANE_HIDE, -1, Tk_Offset(Slave, hide), 0,0,GEOMETRY},
347 DEF_PANEDWINDOW_PANE_HIDE, -1, Tk_Offset(Pane, hide), 0,0,GEOMETRY},
348348 {TK_OPTION_PIXELS, "-minsize", NULL, NULL,
349 DEF_PANEDWINDOW_PANE_MINSIZE, -1, Tk_Offset(Slave, minSize), 0, 0, 0},
349 DEF_PANEDWINDOW_PANE_MINSIZE, -1, Tk_Offset(Pane, minSize), 0, 0, 0},
350350 {TK_OPTION_PIXELS, "-padx", NULL, NULL,
351 DEF_PANEDWINDOW_PANE_PADX, -1, Tk_Offset(Slave, padx), 0, 0, 0},
351 DEF_PANEDWINDOW_PANE_PADX, -1, Tk_Offset(Pane, padx), 0, 0, 0},
352352 {TK_OPTION_PIXELS, "-pady", NULL, NULL,
353 DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Slave, pady), 0, 0, 0},
353 DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Pane, pady), 0, 0, 0},
354354 {TK_OPTION_CUSTOM, "-sticky", NULL, NULL,
355 DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Slave, sticky), 0,
355 DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Pane, sticky), 0,
356356 &stickyOption, 0},
357357 {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch",
358 DEF_PANEDWINDOW_PANE_STRETCH, -1, Tk_Offset(Slave, stretch), 0,
358 DEF_PANEDWINDOW_PANE_STRETCH, -1, Tk_Offset(Pane, stretch), 0,
359359 (ClientData) stretchStrings, 0},
360360 {TK_OPTION_PIXELS, "-width", NULL, NULL,
361 DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Slave, widthPtr),
362 Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0},
361 DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Pane, widthPtr),
362 Tk_Offset(Pane, width), TK_OPTION_NULL_OK, 0, 0},
363363 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
364364 };
365365
382382
383383 int
384384 Tk_PanedWindowObjCmd(
385 ClientData clientData, /* NULL. */
385 TCL_UNUSED(ClientData), /* NULL. */
386386 Tcl_Interp *interp, /* Current interpreter. */
387387 int objc, /* Number of arguments. */
388388 Tcl_Obj * const objv[]) /* Argument objects. */
427427 */
428428
429429 pwOpts->pwOptions = Tk_CreateOptionTable(interp, optionSpecs);
430 pwOpts->slaveOpts = Tk_CreateOptionTable(interp, slaveOptionSpecs);
430 pwOpts->paneOpts = Tk_CreateOptionTable(interp, paneOptionSpecs);
431431 }
432432
433433 Tk_SetClass(tkwin, "Panedwindow");
436436 * Allocate and initialize the widget record.
437437 */
438438
439 pwPtr = ckalloc(sizeof(PanedWindow));
439 pwPtr = (PanedWindow *)ckalloc(sizeof(PanedWindow));
440440 memset((void *)pwPtr, 0, (sizeof(PanedWindow)));
441441 pwPtr->tkwin = tkwin;
442442 pwPtr->display = Tk_Display(tkwin);
445445 Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, pwPtr,
446446 PanedWindowCmdDeletedProc);
447447 pwPtr->optionTable = pwOpts->pwOptions;
448 pwPtr->slaveOpts = pwOpts->slaveOpts;
448 pwPtr->paneOpts = pwOpts->paneOpts;
449449 pwPtr->relief = TK_RELIEF_RAISED;
450450 pwPtr->gc = NULL;
451451 pwPtr->cursor = NULL;
470470 /*
471471 * Find the toplevel ancestor of the panedwindow, and make a proxy win as
472472 * a child of that window; this way the proxy can always float above
473 * slaves in the panedwindow.
473 * panes in the panedwindow.
474474 */
475475
476476 parent = Tk_Parent(pwPtr->tkwin);
534534 int objc, /* Number of arguments. */
535535 Tcl_Obj * const objv[]) /* Argument objects. */
536536 {
537 PanedWindow *pwPtr = clientData;
537 PanedWindow *pwPtr = (PanedWindow *)clientData;
538538 int result = TCL_OK;
539539 static const char *const optionStrings[] = {
540540 "add", "cget", "configure", "forget", "identify", "panecget",
547547 Tcl_Obj *resultObj;
548548 int index, count, i, x, y;
549549 Tk_Window tkwin;
550 Slave *slavePtr;
550 Pane *panePtr;
551551
552552 if (objc < 2) {
553553 Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?");
568568 result = TCL_ERROR;
569569 break;
570570 }
571 result = ConfigureSlaves(pwPtr, interp, objc, objv);
571 result = ConfigurePanes(pwPtr, interp, objc, objv);
572572 break;
573573
574574 case PW_CGET:
603603 break;
604604
605605 case PW_FORGET: {
606 int i;
607606
608607 if (objc < 3) {
609608 Tcl_WrongNumArgs(interp, 2, objv, "widget ?widget ...?");
615614 * Clean up each window named in the arg list.
616615 */
617616 for (count = 0, i = 2; i < objc; i++) {
618 Tk_Window slave = Tk_NameToWindow(interp, Tcl_GetString(objv[i]),
617 Tk_Window pane = Tk_NameToWindow(interp, Tcl_GetString(objv[i]),
619618 pwPtr->tkwin);
620619
621 if (slave == NULL) {
620 if (pane == NULL) {
622621 continue;
623622 }
624 slavePtr = GetPane(pwPtr, slave);
625 if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) {
623 panePtr = GetPane(pwPtr, pane);
624 if ((panePtr != NULL) && (panePtr->containerPtr != NULL)) {
626625 count++;
627 Tk_ManageGeometry(slave, NULL, NULL);
628 Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin);
629 Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask,
630 SlaveStructureProc, slavePtr);
631 Tk_UnmapWindow(slavePtr->tkwin);
632 Unlink(slavePtr);
626 Tk_ManageGeometry(pane, NULL, NULL);
627 Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin);
628 Tk_DeleteEventHandler(panePtr->tkwin, StructureNotifyMask,
629 PaneStructureProc, panePtr);
630 Tk_UnmapWindow(panePtr->tkwin);
631 Unlink(panePtr);
633632 }
634633 if (count != 0) {
635634 ComputeGeometry(pwPtr);
665664 break;
666665 }
667666 resultObj = NULL;
668 for (i = 0; i < pwPtr->numSlaves; i++) {
669 if (pwPtr->slaves[i]->tkwin == tkwin) {
667 for (i = 0; i < pwPtr->numPanes; i++) {
668 if (pwPtr->panes[i]->tkwin == tkwin) {
670669 resultObj = Tk_GetOptionValue(interp,
671 (char *) pwPtr->slaves[i], pwPtr->slaveOpts,
670 (char *) pwPtr->panes[i], pwPtr->paneOpts,
672671 objv[3], tkwin);
673672 }
674673 }
675674 if (resultObj == NULL) {
676 if (i == pwPtr->numSlaves) {
675 if (i == pwPtr->numPanes) {
677676 Tcl_SetObjResult(interp, Tcl_NewStringObj(
678677 "not managed by this window", -1));
679678 Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED",
705704 result = TCL_ERROR;
706705 break;
707706 }
708 for (i = 0; i < pwPtr->numSlaves; i++) {
709 if (pwPtr->slaves[i]->tkwin == tkwin) {
707 for (i = 0; i < pwPtr->numPanes; i++) {
708 if (pwPtr->panes[i]->tkwin == tkwin) {
710709 resultObj = Tk_GetOptionInfo(interp,
711 (char *) pwPtr->slaves[i], pwPtr->slaveOpts,
710 (char *) pwPtr->panes[i], pwPtr->paneOpts,
712711 (objc == 4) ? objv[3] : NULL,
713712 pwPtr->tkwin);
714713 if (resultObj == NULL) {
720719 }
721720 }
722721 } else {
723 result = ConfigureSlaves(pwPtr, interp, objc, objv);
722 result = ConfigurePanes(pwPtr, interp, objc, objv);
724723 }
725724 break;
726725
727726 case PW_PANES:
728727 resultObj = Tcl_NewObj();
729 for (i = 0; i < pwPtr->numSlaves; i++) {
728 for (i = 0; i < pwPtr->numPanes; i++) {
730729 Tcl_ListObjAppendElement(NULL, resultObj,
731 TkNewWindowObj(pwPtr->slaves[i]->tkwin));
730 TkNewWindowObj(pwPtr->panes[i]->tkwin));
732731 }
733732 Tcl_SetObjResult(interp, resultObj);
734733 break;
748747 /*
749748 *----------------------------------------------------------------------
750749 *
751 * ConfigureSlaves --
752 *
753 * Add or alter the configuration options of a slave in a paned window.
750 * ConfigurePanes --
751 *
752 * Add or alter the configuration options of a pane in a paned window.
754753 *
755754 * Results:
756755 * Standard Tcl result.
757756 *
758757 * Side effects:
759 * Depends on options; may add a slave to the paned window, may alter the
760 * geometry management options of a slave.
758 * Depends on options; may add a pane to the paned window, may alter the
759 * geometry management options of a pane.
761760 *
762761 *----------------------------------------------------------------------
763762 */
764763
765764 static int
766 ConfigureSlaves(
765 ConfigurePanes(
767766 PanedWindow *pwPtr, /* Information about paned window. */
768767 Tcl_Interp *interp, /* Current interpreter. */
769768 int objc, /* Number of arguments. */
770769 Tcl_Obj *const objv[]) /* Argument objects. */
771770 {
772 int i, firstOptionArg, j, found, doubleBw, index, numNewSlaves, haveLoc;
771 int i, firstOptionArg, j, found, doubleBw, index, numNewPanes, haveLoc;
773772 int insertIndex;
774773 Tk_Window tkwin = NULL, ancestor, parent;
775 Slave *slavePtr, **inserts, **newSlaves;
776 Slave options;
774 Pane *panePtr, **inserts, **newPanes;
775 Pane options;
777776 const char *arg;
778777
779778 /*
780779 * Find the non-window name arguments; these are the configure options for
781 * the slaves. Also validate that the window names given are legitimate
780 * the panes. Also validate that the window names given are legitimate
782781 * (ie, they are real windows, they are not the panedwindow itself, etc.).
783782 */
784783
816815 return TCL_ERROR;
817816 } else {
818817 /*
819 * Make sure the panedwindow is the parent of the slave,
820 * or a descendant of the slave's parent.
818 * Make sure the panedwindow is the parent of the pane,
819 * or a descendant of the pane's parent.
821820 */
822821
823822 parent = Tk_Parent(tkwin);
846845 * extra testing in the for loop below.
847846 */
848847
849 memset((void *)&options, 0, sizeof(Slave));
850 if (Tk_SetOptions(interp, (char *) &options, pwPtr->slaveOpts,
848 memset((void *)&options, 0, sizeof(Pane));
849 if (Tk_SetOptions(interp, (char *) &options, pwPtr->paneOpts,
851850 objc - firstOptionArg, objv + firstOptionArg,
852851 pwPtr->tkwin, NULL, NULL) != TCL_OK) {
853852 return TCL_ERROR;
864863 if (options.after != NULL) {
865864 tkwin = options.after;
866865 haveLoc = 1;
867 for (i = 0; i < pwPtr->numSlaves; i++) {
868 if (options.after == pwPtr->slaves[i]->tkwin) {
866 for (i = 0; i < pwPtr->numPanes; i++) {
867 if (options.after == pwPtr->panes[i]->tkwin) {
869868 index = i + 1;
870869 break;
871870 }
873872 } else if (options.before != NULL) {
874873 tkwin = options.before;
875874 haveLoc = 1;
876 for (i = 0; i < pwPtr->numSlaves; i++) {
877 if (options.before == pwPtr->slaves[i]->tkwin) {
875 for (i = 0; i < pwPtr->numPanes; i++) {
876 if (options.before == pwPtr->panes[i]->tkwin) {
878877 index = i;
879878 break;
880879 }
891890 "window \"%s\" is not managed by %s",
892891 Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin)));
893892 Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL);
894 Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts,
893 Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts,
895894 pwPtr->tkwin);
896895 return TCL_ERROR;
897896 }
898897
899898 /*
900 * Allocate an array to hold, in order, the pointers to the slave
899 * Allocate an array to hold, in order, the pointers to the pane
901900 * structures corresponding to the windows specified. Some of those
902901 * structures may already have existed, some may be new.
903902 */
904903
905 inserts = ckalloc(sizeof(Slave *) * (firstOptionArg - 2));
904 inserts = (Pane **)ckalloc(sizeof(Pane *) * (firstOptionArg - 2));
906905 insertIndex = 0;
907906
908907 /*
909 * Populate the inserts array, creating new slave structures as necessary,
908 * Populate the inserts array, creating new pane structures as necessary,
910909 * applying the options to each structure as we go, and, if necessary,
911 * marking the spot in the original slaves array as empty (for
912 * pre-existing slave structures).
913 */
914
915 for (i = 0, numNewSlaves = 0; i < firstOptionArg - 2; i++) {
910 * marking the spot in the original panes array as empty (for
911 * pre-existing pane structures).
912 */
913
914 for (i = 0, numNewPanes = 0; i < firstOptionArg - 2; i++) {
916915 /*
917916 * We don't check that tkwin is NULL here, because the pre-pass above
918917 * guarantees that the input at this stage is good.
922921 pwPtr->tkwin);
923922
924923 found = 0;
925 for (j = 0; j < pwPtr->numSlaves; j++) {
926 if (pwPtr->slaves[j] != NULL && pwPtr->slaves[j]->tkwin == tkwin) {
927 Tk_SetOptions(interp, (char *) pwPtr->slaves[j],
928 pwPtr->slaveOpts, objc - firstOptionArg,
924 for (j = 0; j < pwPtr->numPanes; j++) {
925 if (pwPtr->panes[j] != NULL && pwPtr->panes[j]->tkwin == tkwin) {
926 Tk_SetOptions(interp, (char *) pwPtr->panes[j],
927 pwPtr->paneOpts, objc - firstOptionArg,
929928 objv + firstOptionArg, pwPtr->tkwin, NULL, NULL);
930 if (pwPtr->slaves[j]->minSize < 0) {
931 pwPtr->slaves[j]->minSize = 0;
929 if (pwPtr->panes[j]->minSize < 0) {
930 pwPtr->panes[j]->minSize = 0;
932931 }
933932 found = 1;
934933
935934 /*
936 * If the slave is supposed to move, add it to the inserts
935 * If the pane is supposed to move, add it to the inserts
937936 * array now; otherwise, leave it where it is.
938937 */
939938
940939 if (index != -1) {
941 inserts[insertIndex++] = pwPtr->slaves[j];
942 pwPtr->slaves[j] = NULL;
940 inserts[insertIndex++] = pwPtr->panes[j];
941 pwPtr->panes[j] = NULL;
943942 }
944943 break;
945944 }
950949 }
951950
952951 /*
953 * Make sure this slave wasn't already put into the inserts array,
952 * Make sure this pane wasn't already put into the inserts array,
954953 * i.e., when the user specifies the same window multiple times in a
955954 * single add commaned.
956955 */
965964 }
966965
967966 /*
968 * Create a new slave structure and initialize it. All slaves start
967 * Create a new pane structure and initialize it. All panes start
969968 * out with their "natural" dimensions.
970969 */
971970
972 slavePtr = ckalloc(sizeof(Slave));
973 memset(slavePtr, 0, sizeof(Slave));
974 Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts,
971 panePtr = (Pane *)ckalloc(sizeof(Pane));
972 memset(panePtr, 0, sizeof(Pane));
973 Tk_InitOptions(interp, (char *)panePtr, pwPtr->paneOpts,
975974 pwPtr->tkwin);
976 Tk_SetOptions(interp, (char *)slavePtr, pwPtr->slaveOpts,
975 Tk_SetOptions(interp, (char *)panePtr, pwPtr->paneOpts,
977976 objc - firstOptionArg, objv + firstOptionArg,
978977 pwPtr->tkwin, NULL, NULL);
979 slavePtr->tkwin = tkwin;
980 slavePtr->masterPtr = pwPtr;
981 doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width;
982 if (slavePtr->width > 0) {
983 slavePtr->paneWidth = slavePtr->width;
978 panePtr->tkwin = tkwin;
979 panePtr->containerPtr = pwPtr;
980 doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width;
981 if (panePtr->width > 0) {
982 panePtr->paneWidth = panePtr->width;
984983 } else {
985 slavePtr->paneWidth = Tk_ReqWidth(tkwin) + doubleBw;
986 }
987 if (slavePtr->height > 0) {
988 slavePtr->paneHeight = slavePtr->height;
984 panePtr->paneWidth = Tk_ReqWidth(tkwin) + doubleBw;
985 }
986 if (panePtr->height > 0) {
987 panePtr->paneHeight = panePtr->height;
989988 } else {
990 slavePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw;
991 }
992 if (slavePtr->minSize < 0) {
993 slavePtr->minSize = 0;
989 panePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw;
990 }
991 if (panePtr->minSize < 0) {
992 panePtr->minSize = 0;
994993 }
995994
996995 /*
997 * Set up the geometry management callbacks for this slave.
996 * Set up the geometry management callbacks for this pane.
998997 */
999998
1000 Tk_CreateEventHandler(slavePtr->tkwin, StructureNotifyMask,
1001 SlaveStructureProc, slavePtr);
1002 Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, slavePtr);
1003 inserts[insertIndex++] = slavePtr;
1004 numNewSlaves++;
1005 }
1006
1007 /*
1008 * Allocate the new slaves array, then copy the slaves into it, in order.
1009 */
1010
1011 i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves);
1012 newSlaves = ckalloc(i);
1013 memset(newSlaves, 0, (size_t) i);
999 Tk_CreateEventHandler(panePtr->tkwin, StructureNotifyMask,
1000 PaneStructureProc, panePtr);
1001 Tk_ManageGeometry(panePtr->tkwin, &panedWindowMgrType, panePtr);
1002 inserts[insertIndex++] = panePtr;
1003 numNewPanes++;
1004 }
1005
1006 /*
1007 * Allocate the new panes array, then copy the panes into it, in order.
1008 */
1009
1010 i = sizeof(Pane *) * (pwPtr->numPanes + numNewPanes);
1011 newPanes = (Pane **)ckalloc(i);
1012 memset(newPanes, 0, i);
10141013 if (index == -1) {
10151014 /*
1016 * If none of the existing slaves have to be moved, just copy the old
1015 * If none of the existing panes have to be moved, just copy the old
10171016 * and append the new.
10181017 */
1019 memcpy((void *)&(newSlaves[0]), pwPtr->slaves,
1020 sizeof(Slave *) * pwPtr->numSlaves);
1021 memcpy((void *)&(newSlaves[pwPtr->numSlaves]), inserts,
1022 sizeof(Slave *) * numNewSlaves);
1018 memcpy((void *)&(newPanes[0]), pwPtr->panes,
1019 sizeof(Pane *) * pwPtr->numPanes);
1020 memcpy((void *)&(newPanes[pwPtr->numPanes]), inserts,
1021 sizeof(Pane *) * numNewPanes);
10231022 } else {
10241023 /*
1025 * If some of the existing slaves were moved, the old slaves array
1024 * If some of the existing panes were moved, the old panes array
10261025 * will be partially populated, with some valid and some invalid
1027 * entries. Walk through it, copying valid entries to the new slaves
1026 * entries. Walk through it, copying valid entries to the new panes
10281027 * array as we go; when we get to the insert location for the new
1029 * slaves, copy the inserts array over, then finish off the old slaves
1028 * panes, copy the inserts array over, then finish off the old panes
10301029 * array.
10311030 */
10321031
10331032 for (i = 0, j = 0; i < index; i++) {
1034 if (pwPtr->slaves[i] != NULL) {
1035 newSlaves[j] = pwPtr->slaves[i];
1033 if (pwPtr->panes[i] != NULL) {
1034 newPanes[j] = pwPtr->panes[i];
10361035 j++;
10371036 }
10381037 }
10391038
1040 memcpy((void *)&(newSlaves[j]), inserts, sizeof(Slave *)*insertIndex);
1039 memcpy((void *)&(newPanes[j]), inserts, sizeof(Pane *)*insertIndex);
10411040 j += firstOptionArg - 2;
10421041
1043 for (i = index; i < pwPtr->numSlaves; i++) {
1044 if (pwPtr->slaves[i] != NULL) {
1045 newSlaves[j] = pwPtr->slaves[i];
1042 for (i = index; i < pwPtr->numPanes; i++) {
1043 if (pwPtr->panes[i] != NULL) {
1044 newPanes[j] = pwPtr->panes[i];
10461045 j++;
10471046 }
10481047 }
10491048 }
10501049
10511050 /*
1052 * Make the new slaves array the paned window's slave array, and clean up.
1053 */
1054
1055 ckfree(pwPtr->slaves);
1051 * Make the new panes array the paned window's pane array, and clean up.
1052 */
1053
1054 ckfree(pwPtr->panes);
10561055 ckfree(inserts);
1057 pwPtr->slaves = newSlaves;
1058
1059 /*
1060 * Set the paned window's slave count to the new value.
1061 */
1062
1063 pwPtr->numSlaves += numNewSlaves;
1064
1065 Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin);
1056 pwPtr->panes = newPanes;
1057
1058 /*
1059 * Set the paned window's pane count to the new value.
1060 */
1061
1062 pwPtr->numPanes += numNewPanes;
1063
1064 Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts, pwPtr->tkwin);
10661065
10671066 ComputeGeometry(pwPtr);
10681067 return TCL_OK;
11001099 };
11011100 int index, sash, x, y, diff;
11021101 Tcl_Obj *coords[2];
1103 Slave *slavePtr;
1102 Pane *panePtr;
11041103
11051104 if (objc < 3) {
11061105 Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?");
11291128 Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL);
11301129 return TCL_ERROR;
11311130 }
1132 slavePtr = pwPtr->slaves[sash];
1133
1134 coords[0] = Tcl_NewIntObj(slavePtr->sashx);
1135 coords[1] = Tcl_NewIntObj(slavePtr->sashy);
1131 panePtr = pwPtr->panes[sash];
1132
1133 coords[0] = Tcl_NewIntObj(panePtr->sashx);
1134 coords[1] = Tcl_NewIntObj(panePtr->sashy);
11361135 Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
11371136 break;
11381137
11621161 return TCL_ERROR;
11631162 }
11641163
1165 pwPtr->slaves[sash]->markx = x;
1166 pwPtr->slaves[sash]->marky = y;
1164 pwPtr->panes[sash]->markx = x;
1165 pwPtr->panes[sash]->marky = y;
11671166 } else {
1168 coords[0] = Tcl_NewIntObj(pwPtr->slaves[sash]->markx);
1169 coords[1] = Tcl_NewIntObj(pwPtr->slaves[sash]->marky);
1167 coords[0] = Tcl_NewIntObj(pwPtr->panes[sash]->markx);
1168 coords[1] = Tcl_NewIntObj(pwPtr->panes[sash]->marky);
11701169 Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
11711170 }
11721171 break;
11971196 return TCL_ERROR;
11981197 }
11991198
1200 slavePtr = pwPtr->slaves[sash];
1199 panePtr = pwPtr->panes[sash];
12011200 if (pwPtr->orient == ORIENT_HORIZONTAL) {
12021201 if (index == SASH_PLACE) {
1203 diff = x - pwPtr->slaves[sash]->sashx;
1202 diff = x - pwPtr->panes[sash]->sashx;
12041203 } else {
1205 diff = x - pwPtr->slaves[sash]->markx;
1204 diff = x - pwPtr->panes[sash]->markx;
12061205 }
12071206 } else {
12081207 if (index == SASH_PLACE) {
1209 diff = y - pwPtr->slaves[sash]->sashy;
1208 diff = y - pwPtr->panes[sash]->sashy;
12101209 } else {
1211 diff = y - pwPtr->slaves[sash]->marky;
1210 diff = y - pwPtr->panes[sash]->marky;
12121211 }
12131212 }
12141213
12481247 Tk_SavedOptions savedOptions;
12491248 int typemask = 0;
12501249
1251 if (Tk_SetOptions(interp, (char *) pwPtr, pwPtr->optionTable, objc, objv,
1250 if (Tk_SetOptions(interp, (char *)pwPtr, pwPtr->optionTable, objc, objv,
12521251 pwPtr->tkwin, &savedOptions, &typemask) != TCL_OK) {
12531252 Tk_RestoreSavedOptions(&savedOptions);
12541253 return TCL_ERROR;
12941293 {
12951294 XGCValues gcValues;
12961295 GC newGC;
1297 PanedWindow *pwPtr = instanceData;
1296 PanedWindow *pwPtr = (PanedWindow *)instanceData;
12981297
12991298 /*
13001299 * Allocated a graphics context for drawing the paned window widget
13511350 ClientData clientData, /* Information about window. */
13521351 XEvent *eventPtr) /* Information about event. */
13531352 {
1354 PanedWindow *pwPtr = clientData;
1353 PanedWindow *pwPtr = (PanedWindow *)clientData;
13551354 int i;
13561355
13571356 if (eventPtr->type == Expose) {
13681367 } else if (eventPtr->type == DestroyNotify) {
13691368 DestroyPanedWindow(pwPtr);
13701369 } else if (eventPtr->type == UnmapNotify) {
1371 for (i = 0; i < pwPtr->numSlaves; i++) {
1372 if (!pwPtr->slaves[i]->hide) {
1373 Tk_UnmapWindow(pwPtr->slaves[i]->tkwin);
1370 for (i = 0; i < pwPtr->numPanes; i++) {
1371 if (!pwPtr->panes[i]->hide) {
1372 Tk_UnmapWindow(pwPtr->panes[i]->tkwin);
13741373 }
13751374 }
13761375 } else if (eventPtr->type == MapNotify) {
1377 for (i = 0; i < pwPtr->numSlaves; i++) {
1378 if (!pwPtr->slaves[i]->hide) {
1379 Tk_MapWindow(pwPtr->slaves[i]->tkwin);
1376 for (i = 0; i < pwPtr->numPanes; i++) {
1377 if (!pwPtr->panes[i]->hide) {
1378 Tk_MapWindow(pwPtr->panes[i]->tkwin);
13801379 }
13811380 }
13821381 }
14041403 PanedWindowCmdDeletedProc(
14051404 ClientData clientData) /* Pointer to widget record for widget. */
14061405 {
1407 PanedWindow *pwPtr = clientData;
1406 PanedWindow *pwPtr = (PanedWindow *)clientData;
14081407
14091408 /*
14101409 * This function could be invoked either because the window was destroyed
14411440 DisplayPanedWindow(
14421441 ClientData clientData) /* Information about window. */
14431442 {
1444 PanedWindow *pwPtr = clientData;
1445 Slave *slavePtr;
1443 PanedWindow *pwPtr = (PanedWindow *)clientData;
1444 Pane *panePtr;
14461445 Pixmap pixmap;
14471446 Tk_Window tkwin = pwPtr->tkwin;
14481447 int i, sashWidth, sashHeight;
14831482 */
14841483
14851484 if (horizontal) {
1486 sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderWidth(tkwin));
1485 sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderLeft(tkwin));
14871486 sashWidth = pwPtr->sashWidth;
14881487 } else {
1489 sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderWidth(tkwin));
1488 sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderLeft(tkwin));
14901489 sashHeight = pwPtr->sashWidth;
14911490 }
14921491
14951494 */
14961495
14971496 GetFirstLastVisiblePane(pwPtr, &first, &last);
1498 for (i = 0; i < pwPtr->numSlaves - 1; i++) {
1499 slavePtr = pwPtr->slaves[i];
1500 if (slavePtr->hide || i == last) {
1497 for (i = 0; i < pwPtr->numPanes - 1; i++) {
1498 panePtr = pwPtr->panes[i];
1499 if (panePtr->hide || i == last) {
15011500 continue;
15021501 }
15031502 if (sashWidth > 0 && sashHeight > 0) {
15041503 Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background,
1505 slavePtr->sashx, slavePtr->sashy, sashWidth, sashHeight,
1504 panePtr->sashx, panePtr->sashy, sashWidth, sashHeight,
15061505 1, pwPtr->sashRelief);
15071506 }
15081507 if (pwPtr->showHandle) {
15091508 Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background,
1510 slavePtr->handlex, slavePtr->handley,
1509 panePtr->handlex, panePtr->handley,
15111510 pwPtr->handleSize, pwPtr->handleSize, 1,
15121511 TK_RELIEF_RAISED);
15131512 }
15681567 }
15691568
15701569 /*
1571 * Clean up the slave list; foreach slave:
1572 * o Cancel the slave's structure notification callback
1573 * o Cancel geometry management for the slave.
1574 * o Free memory for the slave
1575 */
1576
1577 for (i = 0; i < pwPtr->numSlaves; i++) {
1578 Tk_DeleteEventHandler(pwPtr->slaves[i]->tkwin, StructureNotifyMask,
1579 SlaveStructureProc, pwPtr->slaves[i]);
1580 Tk_ManageGeometry(pwPtr->slaves[i]->tkwin, NULL, NULL);
1581 Tk_FreeConfigOptions((char *) pwPtr->slaves[i], pwPtr->slaveOpts,
1570 * Clean up the pane list; foreach pane:
1571 * o Cancel the pane's structure notification callback
1572 * o Cancel geometry management for the pane.
1573 * o Free memory for the pane
1574 */
1575
1576 for (i = 0; i < pwPtr->numPanes; i++) {
1577 Tk_DeleteEventHandler(pwPtr->panes[i]->tkwin, StructureNotifyMask,
1578 PaneStructureProc, pwPtr->panes[i]);
1579 Tk_ManageGeometry(pwPtr->panes[i]->tkwin, NULL, NULL);
1580 Tk_FreeConfigOptions((char *) pwPtr->panes[i], pwPtr->paneOpts,
15821581 pwPtr->tkwin);
1583 ckfree(pwPtr->slaves[i]);
1584 pwPtr->slaves[i] = NULL;
1585 }
1586 if (pwPtr->slaves) {
1587 ckfree(pwPtr->slaves);
1582 ckfree(pwPtr->panes[i]);
1583 pwPtr->panes[i] = NULL;
1584 }
1585 if (pwPtr->panes) {
1586 ckfree(pwPtr->panes);
15881587 }
15891588
15901589 /*
16261625 PanedWindowReqProc(
16271626 ClientData clientData, /* Paned window's information about window
16281627 * that got new preferred geometry. */
1629 Tk_Window tkwin) /* Other Tk-related information about the
1628 TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
16301629 * window. */
16311630 {
1632 Slave *slavePtr = clientData;
1633 PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr;
1631 Pane *panePtr = (Pane *)clientData;
1632 PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr;
16341633
16351634 if (Tk_IsMapped(pwPtr->tkwin)) {
16361635 if (!(pwPtr->flags & RESIZE_PENDING)) {
16381637 Tcl_DoWhenIdle(ArrangePanes, pwPtr);
16391638 }
16401639 } else {
1641 int doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width;
1642
1643 if (slavePtr->width <= 0) {
1644 slavePtr->paneWidth = Tk_ReqWidth(slavePtr->tkwin) + doubleBw;
1645 }
1646 if (slavePtr->height <= 0) {
1647 slavePtr->paneHeight = Tk_ReqHeight(slavePtr->tkwin) + doubleBw;
1640 int doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width;
1641
1642 if (panePtr->width <= 0) {
1643 panePtr->paneWidth = Tk_ReqWidth(panePtr->tkwin) + doubleBw;
1644 }
1645 if (panePtr->height <= 0) {
1646 panePtr->paneHeight = Tk_ReqHeight(panePtr->tkwin) + doubleBw;
16481647 }
16491648 ComputeGeometry(pwPtr);
16501649 }
16531652 /*
16541653 *--------------------------------------------------------------
16551654 *
1656 * PanedWindowLostSlaveProc --
1655 * PanedWindowLostPaneProc --
16571656 *
16581657 * This function is invoked by Tk whenever some other geometry claims
1659 * control over a slave that used to be managed by us.
1658 * control over a pane that used to be managed by us.
16601659 *
16611660 * Results:
16621661 * None.
16631662 *
16641663 * Side effects:
1665 * Forgets all information about the slave. Causes geometry to be
1664 * Forgets all information about the pane. Causes geometry to be
16661665 * recomputed for the panedwindow.
16671666 *
16681667 *--------------------------------------------------------------
16691668 */
16701669
16711670 static void
1672 PanedWindowLostSlaveProc(
1673 ClientData clientData, /* Grid structure for slave window that was
1671 PanedWindowLostPaneProc(
1672 ClientData clientData, /* Grid structure for the pane that was
16741673 * stolen away. */
1675 Tk_Window tkwin) /* Tk's handle for the slave window. */
1674 TCL_UNUSED(Tk_Window)) /* Tk's handle for the pane. */
16761675 {
1677 register Slave *slavePtr = clientData;
1678 PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr;
1679
1680 if (pwPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
1681 Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin);
1682 }
1683 Unlink(slavePtr);
1684 Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask,
1685 SlaveStructureProc, slavePtr);
1686 Tk_UnmapWindow(slavePtr->tkwin);
1687 slavePtr->tkwin = NULL;
1688 ckfree(slavePtr);
1676 Pane *panePtr = (Pane *)clientData;
1677 PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr;
1678
1679 if (pwPtr->tkwin != Tk_Parent(panePtr->tkwin)) {
1680 Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin);
1681 }
1682 Unlink(panePtr);
1683 Tk_DeleteEventHandler(panePtr->tkwin, StructureNotifyMask,
1684 PaneStructureProc, panePtr);
1685 Tk_UnmapWindow(panePtr->tkwin);
1686 panePtr->tkwin = NULL;
1687 ckfree(panePtr);
16891688 ComputeGeometry(pwPtr);
16901689 }
16911690
17031702 * None.
17041703 *
17051704 * Side effects:
1706 * The slaves of masterPtr may get resized or moved.
1705 * The panes of containerPtr may get resized or moved.
17071706 *
17081707 *--------------------------------------------------------------
17091708 */
17101709
17111710 static void
17121711 ArrangePanes(
1713 ClientData clientData) /* Structure describing parent whose slaves
1712 ClientData clientData) /* Structure describing parent whose panes
17141713 * are to be re-layed out. */
17151714 {
1716 register PanedWindow *pwPtr = clientData;
1717 register Slave *slavePtr;
1718 int i, slaveWidth, slaveHeight, slaveX, slaveY;
1715 PanedWindow *pwPtr = (PanedWindow *)clientData;
1716 Pane *panePtr;
1717 int i, newPaneWidth, newPaneHeight, paneX, paneY;
17191718 int paneWidth, paneHeight, paneSize, paneMinSize;
17201719 int doubleBw;
17211720 int x, y;
17301729 pwPtr->flags &= ~(REQUESTED_RELAYOUT|RESIZE_PENDING);
17311730
17321731 /*
1733 * If the parent has no slaves anymore, then don't do anything at all:
1732 * If the parent has no panes anymore, then don't do anything at all:
17341733 * just leave the parent's size as-is. Otherwise there is no way to
17351734 * "relinquish" control over the parent so another geometry manager can
17361735 * take over.
17371736 */
17381737
1739 if (pwPtr->numSlaves == 0) {
1738 if (pwPtr->numPanes == 0) {
17401739 return;
17411740 }
17421741
17531752 */
17541753
17551754 paneDynSize = paneDynMinSize = 0;
1756 internalBW = Tk_InternalBorderWidth(pwPtr->tkwin);
1755 internalBW = Tk_InternalBorderLeft(pwPtr->tkwin);
17571756 pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW);
17581757 pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW);
17591758 x = y = internalBW;
17751774 + pwPtr->sashPad;
17761775 }
17771776
1778 for (i = sashCount = 0; i < pwPtr->numSlaves; i++) {
1779 slavePtr = pwPtr->slaves[i];
1780
1781 if (slavePtr->hide) {
1777 for (i = sashCount = 0; i < pwPtr->numPanes; i++) {
1778 panePtr = pwPtr->panes[i];
1779
1780 if (panePtr->hide) {
17821781 continue;
17831782 }
17841783
17851784 /*
1786 * Compute the total size needed by all the slaves and the left-over,
1785 * Compute the total size needed by all the panes and the left-over,
17871786 * or shortage of space available.
17881787 */
17891788
17901789 if (horizontal) {
1791 if (slavePtr->width > 0) {
1792 paneSize = slavePtr->width;
1790 if (panePtr->width > 0) {
1791 paneSize = panePtr->width;
17931792 } else {
1794 paneSize = slavePtr->paneWidth;
1793 paneSize = panePtr->paneWidth;
17951794 }
1796 stretchReserve -= paneSize + (2 * slavePtr->padx);
1795 stretchReserve -= paneSize + (2 * panePtr->padx);
17971796 } else {
1798 if (slavePtr->height > 0) {
1799 paneSize = slavePtr->height;
1797 if (panePtr->height > 0) {
1798 paneSize = panePtr->height;
18001799 } else {
1801 paneSize = slavePtr->paneHeight;
1800 paneSize = panePtr->paneHeight;
18021801 }
1803 stretchReserve -= paneSize + (2 * slavePtr->pady);
1804 }
1805 if (IsStretchable(slavePtr->stretch,i,first,last)
1802 stretchReserve -= paneSize + (2 * panePtr->pady);
1803 }
1804 if (IsStretchable(panePtr->stretch,i,first,last)
18061805 && Tk_IsMapped(pwPtr->tkwin)) {
18071806 paneDynSize += paneSize;
1808 paneDynMinSize += slavePtr->minSize;
1807 paneDynMinSize += panePtr->minSize;
18091808 }
18101809 if (i != last) {
18111810 stretchReserve -= sashWidth;
18171816 * Second pass; adjust/arrange panes.
18181817 */
18191818
1820 for (i = 0; i < pwPtr->numSlaves; i++) {
1821 slavePtr = pwPtr->slaves[i];
1822
1823 if (slavePtr->hide) {
1824 Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin);
1825 Tk_UnmapWindow(slavePtr->tkwin);
1819 for (i = 0; i < pwPtr->numPanes; i++) {
1820 panePtr = pwPtr->panes[i];
1821
1822 if (panePtr->hide) {
1823 Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin);
1824 Tk_UnmapWindow(panePtr->tkwin);
18261825 continue;
18271826 }
18281827
18291828 /*
1830 * Compute the size of this slave. The algorithm (assuming a
1829 * Compute the size of this pane. The algorithm (assuming a
18311830 * horizontal paned window) is:
18321831 *
18331832 * 1. Get "base" dimensions. If a width or height is specified for
1834 * this slave, use those values; else use the ReqWidth/ReqHeight.
1833 * this pane, use those values; else use the ReqWidth/ReqHeight.
18351834 * 2. Using base dimensions, pane dimensions, and sticky values,
18361835 * determine the x and y, and actual width and height of the
18371836 * widget.
18381837 */
18391838
1840 doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width;
1841 slaveWidth = (slavePtr->width > 0 ? slavePtr->width :
1842 Tk_ReqWidth(slavePtr->tkwin) + doubleBw);
1843 slaveHeight = (slavePtr->height > 0 ? slavePtr->height :
1844 Tk_ReqHeight(slavePtr->tkwin) + doubleBw);
1845 paneMinSize = slavePtr->minSize;
1839 doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width;
1840 newPaneWidth = (panePtr->width > 0 ? panePtr->width :
1841 Tk_ReqWidth(panePtr->tkwin) + doubleBw);
1842 newPaneHeight = (panePtr->height > 0 ? panePtr->height :
1843 Tk_ReqHeight(panePtr->tkwin) + doubleBw);
1844 paneMinSize = panePtr->minSize;
18461845
18471846 /*
18481847 * Calculate pane width and height.
18491848 */
18501849
18511850 if (horizontal) {
1852 if (slavePtr->width > 0) {
1853 paneSize = slavePtr->width;
1851 if (panePtr->width > 0) {
1852 paneSize = panePtr->width;
18541853 } else {
1855 paneSize = slavePtr->paneWidth;
1854 paneSize = panePtr->paneWidth;
18561855 }
18571856 pwSize = pwWidth;
18581857 } else {
1859 if (slavePtr->height > 0) {
1860 paneSize = slavePtr->height;
1858 if (panePtr->height > 0) {
1859 paneSize = panePtr->height;
18611860 } else {
1862 paneSize = slavePtr->paneHeight;
1861 paneSize = panePtr->paneHeight;
18631862 }
18641863 pwSize = pwHeight;
18651864 }
1866 if (IsStretchable(slavePtr->stretch, i, first, last)) {
1865 if (IsStretchable(panePtr->stretch, i, first, last)) {
18671866 double frac;
18681867
18691868 if (paneDynSize > 0) {
18731872 }
18741873
18751874 paneDynSize -= paneSize;
1876 paneDynMinSize -= slavePtr->minSize;
1875 paneDynMinSize -= panePtr->minSize;
18771876 stretchAmount = (int) (frac * stretchReserve);
18781877 if (paneSize + stretchAmount >= paneMinSize) {
18791878 stretchReserve -= stretchAmount;
18981897 }
18991898 if (horizontal) {
19001899 paneWidth = paneSize;
1901 paneHeight = pwHeight - (2 * slavePtr->pady);
1900 paneHeight = pwHeight - (2 * panePtr->pady);
19021901 } else {
1903 paneWidth = pwWidth - (2 * slavePtr->padx);
1902 paneWidth = pwWidth - (2 * panePtr->padx);
19041903 paneHeight = paneSize;
19051904 }
19061905
19281927 paneHeight = pwHeight - syReserve - y + internalBW;
19291928 }
19301929
1931 if (slaveWidth > paneWidth) {
1932 slaveWidth = paneWidth;
1933 }
1934 if (slaveHeight > paneHeight) {
1935 slaveHeight = paneHeight;
1936 }
1937
1938 slavePtr->x = x;
1939 slavePtr->y = y;
1930 if (newPaneWidth > paneWidth) {
1931 newPaneWidth = paneWidth;
1932 }
1933 if (newPaneHeight > paneHeight) {
1934 newPaneHeight = paneHeight;
1935 }
1936
1937 panePtr->x = x;
1938 panePtr->y = y;
19401939
19411940 /*
19421941 * Compute the location of the sash at the right or bottom of the
19441943 */
19451944
19461945 if (horizontal) {
1947 x += paneWidth + (2 * slavePtr->padx);
1946 x += paneWidth + (2 * panePtr->padx);
19481947 if (x < internalBW) {
19491948 x = internalBW;
19501949 }
1951 slavePtr->sashx = x + sashOffset;
1952 slavePtr->sashy = y;
1953 slavePtr->handlex = x + handleOffset;
1954 slavePtr->handley = y + pwPtr->handlePad;
1950 panePtr->sashx = x + sashOffset;
1951 panePtr->sashy = y;
1952 panePtr->handlex = x + handleOffset;
1953 panePtr->handley = y + pwPtr->handlePad;
19551954 x += sashWidth;
19561955 } else {
1957 y += paneHeight + (2 * slavePtr->pady);
1956 y += paneHeight + (2 * panePtr->pady);
19581957 if (y < internalBW) {
19591958 y = internalBW;
19601959 }
1961 slavePtr->sashx = x;
1962 slavePtr->sashy = y + sashOffset;
1963 slavePtr->handlex = x + pwPtr->handlePad;
1964 slavePtr->handley = y + handleOffset;
1960 panePtr->sashx = x;
1961 panePtr->sashy = y + sashOffset;
1962 panePtr->handlex = x + pwPtr->handlePad;
1963 panePtr->handley = y + handleOffset;
19651964 y += sashWidth;
19661965 }
19671966
19681967 /*
1969 * Compute the actual dimensions of the slave in the pane.
1968 * Compute the actual dimensions of the pane in the pane.
19701969 */
19711970
1972 slaveX = slavePtr->x;
1973 slaveY = slavePtr->y;
1974 AdjustForSticky(slavePtr->sticky, paneWidth, paneHeight,
1975 &slaveX, &slaveY, &slaveWidth, &slaveHeight);
1976
1977 slaveX += slavePtr->padx;
1978 slaveY += slavePtr->pady;
1971 paneX = panePtr->x;
1972 paneY = panePtr->y;
1973 AdjustForSticky(panePtr->sticky, paneWidth, paneHeight,
1974 &paneX, &paneY, &newPaneWidth, &newPaneHeight);
1975
1976 paneX += panePtr->padx;
1977 paneY += panePtr->pady;
19791978
19801979 /*
19811980 * Now put the window in the proper spot.
19821981 */
19831982
1984 if (slaveWidth <= 0 || slaveHeight <= 0 ||
1985 (horizontal ? slaveX - internalBW > pwWidth :
1986 slaveY - internalBW > pwHeight)) {
1987 Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin);
1988 Tk_UnmapWindow(slavePtr->tkwin);
1983 if (newPaneWidth <= 0 || newPaneHeight <= 0 ||
1984 (horizontal ? paneX - internalBW > pwWidth :
1985 paneY - internalBW > pwHeight)) {
1986 Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin);
1987 Tk_UnmapWindow(panePtr->tkwin);
19891988 } else {
1990 Tk_MaintainGeometry(slavePtr->tkwin, pwPtr->tkwin,
1991 slaveX, slaveY, slaveWidth, slaveHeight);
1989 Tk_MaintainGeometry(panePtr->tkwin, pwPtr->tkwin,
1990 paneX, paneY, newPaneWidth, newPaneHeight);
19921991 }
19931992 sashCount--;
19941993 }
20001999 *
20012000 * Unlink --
20022001 *
2003 * Remove a slave from a paned window.
2002 * Remove a pane from a paned window.
20042003 *
20052004 * Results:
20062005 * None.
20132012
20142013 static void
20152014 Unlink(
2016 register Slave *slavePtr) /* Window to unlink. */
2015 Pane *panePtr) /* Window to unlink. */
20172016 {
2018 register PanedWindow *masterPtr;
2017 PanedWindow *containerPtr;
20192018 int i, j;
20202019
2021 masterPtr = slavePtr->masterPtr;
2022 if (masterPtr == NULL) {
2020 containerPtr = panePtr->containerPtr;
2021 if (containerPtr == NULL) {
20232022 return;
20242023 }
20252024
20262025 /*
2027 * Find the specified slave in the panedwindow's list of slaves, then
2026 * Find the specified pane in the panedwindow's list of panes, then
20282027 * remove it from that list.
20292028 */
20302029
2031 for (i = 0; i < masterPtr->numSlaves; i++) {
2032 if (masterPtr->slaves[i] == slavePtr) {
2033 for (j = i; j < masterPtr->numSlaves - 1; j++) {
2034 masterPtr->slaves[j] = masterPtr->slaves[j + 1];
2030 for (i = 0; i < containerPtr->numPanes; i++) {
2031 if (containerPtr->panes[i] == panePtr) {
2032 for (j = i; j < containerPtr->numPanes - 1; j++) {
2033 containerPtr->panes[j] = containerPtr->panes[j + 1];
20352034 }
20362035 break;
20372036 }
20382037 }
20392038
20402039 /*
2041 * Clean out any -after or -before references to this slave
2042 */
2043
2044 for (i = 0; i < masterPtr->numSlaves; i++) {
2045 if (masterPtr->slaves[i]->before == slavePtr->tkwin) {
2046 masterPtr->slaves[i]->before = NULL;
2047 }
2048 if (masterPtr->slaves[i]->after == slavePtr->tkwin) {
2049 masterPtr->slaves[i]->after = NULL;
2050 }
2051 }
2052
2053 masterPtr->flags |= REQUESTED_RELAYOUT;
2054 if (!(masterPtr->flags & REDRAW_PENDING)) {
2055 masterPtr->flags |= REDRAW_PENDING;
2056 Tcl_DoWhenIdle(DisplayPanedWindow, masterPtr);
2057 }
2058
2059 /*
2060 * Set the slave's masterPtr to NULL, so that we can tell that the slave
2040 * Clean out any -after or -before references to this pane
2041 */
2042
2043 for (i = 0; i < containerPtr->numPanes; i++) {
2044 if (containerPtr->panes[i]->before == panePtr->tkwin) {
2045 containerPtr->panes[i]->before = NULL;
2046 }
2047 if (containerPtr->panes[i]->after == panePtr->tkwin) {
2048 containerPtr->panes[i]->after = NULL;
2049 }
2050 }
2051
2052 containerPtr->flags |= REQUESTED_RELAYOUT;
2053 if (!(containerPtr->flags & REDRAW_PENDING)) {
2054 containerPtr->flags |= REDRAW_PENDING;
2055 Tcl_DoWhenIdle(DisplayPanedWindow, containerPtr);
2056 }
2057
2058 /*
2059 * Set the pane's containerPtr to NULL, so that we can tell that the pane
20612060 * is no longer attached to any panedwindow.
20622061 */
20632062
2064 slavePtr->masterPtr = NULL;
2065
2066 masterPtr->numSlaves--;
2063 panePtr->containerPtr = NULL;
2064
2065 containerPtr->numPanes--;
20672066 }
20682067
20692068 /*
20752074 * token in a given paned window.
20762075 *
20772076 * Results:
2078 * Pointer to the slave structure, or NULL if the window is not managed
2077 * Pointer to the pane structure, or NULL if the window is not managed
20792078 * by this paned window.
20802079 *
20812080 * Side effects:
20842083 *----------------------------------------------------------------------
20852084 */
20862085
2087 static Slave *
2086 static Pane *
20882087 GetPane(
20892088 PanedWindow *pwPtr, /* Pointer to the paned window info. */
20902089 Tk_Window tkwin) /* Window to search for. */
20912090 {
20922091 int i;
20932092
2094 for (i = 0; i < pwPtr->numSlaves; i++) {
2095 if (pwPtr->slaves[i]->tkwin == tkwin) {
2096 return pwPtr->slaves[i];
2093 for (i = 0; i < pwPtr->numPanes; i++) {
2094 if (pwPtr->panes[i]->tkwin == tkwin) {
2095 return pwPtr->panes[i];
20972096 }
20982097 }
20992098 return NULL;
21242123 {
21252124 int i;
21262125
2127 for (i = 0, *lastPtr = 0, *firstPtr = -1; i < pwPtr->numSlaves; i++) {
2128 if (pwPtr->slaves[i]->hide == 0) {
2126 for (i = 0, *lastPtr = 0, *firstPtr = -1; i < pwPtr->numPanes; i++) {
2127 if (pwPtr->panes[i]->hide == 0) {
21292128 if (*firstPtr < 0) {
21302129 *firstPtr = i;
21312130 }
21372136 /*
21382137 *--------------------------------------------------------------
21392138 *
2140 * SlaveStructureProc --
2139 * PaneStructureProc --
21412140 *
21422141 * This function is invoked whenever StructureNotify events occur for a
21432142 * window that's managed by a paned window. This function's only purpose
21472146 * None.
21482147 *
21492148 * Side effects:
2150 * The paned window slave structure associated with the window
2151 * is freed, and the slave is disassociated from the paned
2149 * The paned window pane structure associated with the window
2150 * is freed, and the pane is disassociated from the paned
21522151 * window which managed it.
21532152 *
21542153 *--------------------------------------------------------------
21552154 */
21562155
21572156 static void
2158 SlaveStructureProc(
2157 PaneStructureProc(
21592158 ClientData clientData, /* Pointer to record describing window item. */
21602159 XEvent *eventPtr) /* Describes what just happened. */
21612160 {
2162 Slave *slavePtr = clientData;
2163 PanedWindow *pwPtr = slavePtr->masterPtr;
2161 Pane *panePtr = (Pane *)clientData;
2162 PanedWindow *pwPtr = panePtr->containerPtr;
21642163
21652164 if (eventPtr->type == DestroyNotify) {
2166 Unlink(slavePtr);
2167 slavePtr->tkwin = NULL;
2168 ckfree(slavePtr);
2165 Unlink(panePtr);
2166 panePtr->tkwin = NULL;
2167 ckfree(panePtr);
21692168 ComputeGeometry(pwPtr);
21702169 }
21712170 }
21762175 * ComputeGeometry --
21772176 *
21782177 * Compute geometry for the paned window, including coordinates of all
2179 * slave windows and each sash.
2178 * panes and each sash.
21802179 *
21812180 * Results:
21822181 * None.
21942193 int i, x, y, doubleBw, internalBw;
21952194 int sashWidth, sashOffset, handleOffset;
21962195 int reqWidth, reqHeight, dim;
2197 Slave *slavePtr;
2196 Pane *panePtr;
21982197 const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL);
21992198
22002199 pwPtr->flags |= REQUESTED_RELAYOUT;
22012200
2202 x = y = internalBw = Tk_InternalBorderWidth(pwPtr->tkwin);
2201 x = y = internalBw = Tk_InternalBorderLeft(pwPtr->tkwin);
22032202 reqWidth = reqHeight = 0;
22042203
22052204 /*
22202219 + pwPtr->sashPad;
22212220 }
22222221
2223 for (i = 0; i < pwPtr->numSlaves; i++) {
2224 slavePtr = pwPtr->slaves[i];
2225
2226 if (slavePtr->hide) {
2222 for (i = 0; i < pwPtr->numPanes; i++) {
2223 panePtr = pwPtr->panes[i];
2224
2225 if (panePtr->hide) {
22272226 continue;
22282227 }
22292228
22302229 /*
2231 * First set the coordinates for the top left corner of the slave's
2230 * First set the coordinates for the top left corner of the pane's
22322231 * parcel.
22332232 */
22342233
2235 slavePtr->x = x;
2236 slavePtr->y = y;
2234 panePtr->x = x;
2235 panePtr->y = y;
22372236
22382237 /*
22392238 * Make sure the pane's paned dimension is at least minsize. This
22422241 */
22432242
22442243 if (horizontal) {
2245 if (slavePtr->paneWidth < slavePtr->minSize) {
2246 slavePtr->paneWidth = slavePtr->minSize;
2244 if (panePtr->paneWidth < panePtr->minSize) {
2245 panePtr->paneWidth = panePtr->minSize;
22472246 }
22482247 } else {
2249 if (slavePtr->paneHeight < slavePtr->minSize) {
2250 slavePtr->paneHeight = slavePtr->minSize;
2248 if (panePtr->paneHeight < panePtr->minSize) {
2249 panePtr->paneHeight = panePtr->minSize;
22512250 }
22522251 }
22532252
22572256 */
22582257
22592258 if (horizontal) {
2260 x += slavePtr->paneWidth + (2 * slavePtr->padx);
2261 slavePtr->sashx = x + sashOffset;
2262 slavePtr->sashy = y;
2263 slavePtr->handlex = x + handleOffset;
2264 slavePtr->handley = y + pwPtr->handlePad;
2259 x += panePtr->paneWidth + (2 * panePtr->padx);
2260 panePtr->sashx = x + sashOffset;
2261 panePtr->sashy = y;
2262 panePtr->handlex = x + handleOffset;
2263 panePtr->handley = y + pwPtr->handlePad;
22652264 x += sashWidth;
22662265 } else {
2267 y += slavePtr->paneHeight + (2 * slavePtr->pady);
2268 slavePtr->sashx = x;
2269 slavePtr->sashy = y + sashOffset;
2270 slavePtr->handlex = x + pwPtr->handlePad;
2271 slavePtr->handley = y + handleOffset;
2266 y += panePtr->paneHeight + (2 * panePtr->pady);
2267 panePtr->sashx = x;
2268 panePtr->sashy = y + sashOffset;
2269 panePtr->handlex = x + pwPtr->handlePad;
2270 panePtr->handley = y + handleOffset;
22722271 y += sashWidth;
22732272 }
22742273
22752274 /*
2276 * Find the maximum height/width of the slaves, for computing the
2275 * Find the maximum height/width of the panes, for computing the
22772276 * requested height/width of the paned window.
22782277 */
22792278
22802279 if (horizontal) {
22812280 /*
2282 * If the slave has an explicit height set, use that; otherwise,
2283 * use the slave's requested height.
2281 * If the pane has an explicit height set, use that; otherwise,
2282 * use the pane's requested height.
22842283 */
22852284
2286 if (slavePtr->height > 0) {
2287 dim = slavePtr->height;
2285 if (panePtr->height > 0) {
2286 dim = panePtr->height;
22882287 } else {
2289 doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width;
2290 dim = Tk_ReqHeight(slavePtr->tkwin) + doubleBw;
2291 }
2292 dim += 2 * slavePtr->pady;
2288 doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width;
2289 dim = Tk_ReqHeight(panePtr->tkwin) + doubleBw;
2290 }
2291 dim += 2 * panePtr->pady;
22932292 if (dim > reqHeight) {
22942293 reqHeight = dim;
22952294 }
22962295 } else {
22972296 /*
2298 * If the slave has an explicit width set use that; otherwise, use
2299 * the slave's requested width.
2297 * If the pane has an explicit width set use that; otherwise, use
2298 * the pane's requested width.
23002299 */
23012300
2302 if (slavePtr->width > 0) {
2303 dim = slavePtr->width;
2301 if (panePtr->width > 0) {
2302 dim = panePtr->width;
23042303 } else {
2305 doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width;
2306 dim = Tk_ReqWidth(slavePtr->tkwin) + doubleBw;
2307 }
2308 dim += 2 * slavePtr->padx;
2304 doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width;
2305 dim = Tk_ReqWidth(panePtr->tkwin) + doubleBw;
2306 }
2307 dim += 2 * panePtr->padx;
23092308 if (dim > reqWidth) {
23102309 reqWidth = dim;
23112310 }
23232322 * the paned window.
23242323 *
23252324 * The height (or width) is equal to the maximum height (or width) of the
2326 * slaves, plus the width of the border of the top and bottom (or left and
2325 * panes, plus the width of the border of the top and bottom (or left and
23272326 * right) of the paned window.
23282327 *
23292328 * If the panedwindow has an explicit width/height set use that;
23692368 static void
23702369 DestroyOptionTables(
23712370 ClientData clientData, /* Pointer to the OptionTables struct */
2372 Tcl_Interp *interp) /* Pointer to the calling interp */
2371 TCL_UNUSED(Tcl_Interp *)) /* Pointer to the calling interp */
23732372 {
23742373 ckfree(clientData);
23752374 }
23932392
23942393 static Tcl_Obj *
23952394 GetSticky(
2396 ClientData clientData,
2397 Tk_Window tkwin,
2395 TCL_UNUSED(void *),
2396 TCL_UNUSED(Tk_Window),
23982397 char *recordPtr, /* Pointer to widget record. */
23992398 int internalOffset) /* Offset within *recordPtr containing the
24002399 * sticky value. */
24412440
24422441 static int
24432442 SetSticky(
2444 ClientData clientData,
2443 TCL_UNUSED(void *),
24452444 Tcl_Interp *interp, /* Current interp; may be used for errors. */
2446 Tk_Window tkwin, /* Window for which option is being set. */
2445 TCL_UNUSED(Tk_Window), /* Window for which option is being set. */
24472446 Tcl_Obj **value, /* Pointer to the pointer to the value object.
24482447 * We use a pointer to the pointer because we
24492448 * may need to return a value (NULL). */
25202519
25212520 static void
25222521 RestoreSticky(
2523 ClientData clientData,
2524 Tk_Window tkwin,
2522 TCL_UNUSED(void *),
2523 TCL_UNUSED(Tk_Window),
25252524 char *internalPtr, /* Pointer to storage for value. */
25262525 char *oldInternalPtr) /* Pointer to old value. */
25272526 {
25342533 * AdjustForSticky --
25352534 *
25362535 * Given the x,y coords of the top-left corner of a pane, the dimensions
2537 * of that pane, and the dimensions of a slave, compute the x,y coords
2538 * and actual dimensions of the slave based on the slave's sticky value.
2536 * of that pane, and the dimensions of a pane, compute the x,y coords
2537 * and actual dimensions of the pane based on the pane's sticky value.
25392538 *
25402539 * Results:
2541 * No direct return; sets the x, y, slaveWidth and slaveHeight to correct
2540 * No direct return; sets the x, y, paneWidth and paneHeight to correct
25422541 * values.
25432542 *
25442543 * Side effects:
25552554 int cavityHeight, /* Height of the cavity. */
25562555 int *xPtr, int *yPtr, /* Initially, coordinates of the top-left
25572556 * corner of cavity; also return values for
2558 * actual x, y coords of slave. */
2559 int *slaveWidthPtr, /* Slave width. */
2560 int *slaveHeightPtr) /* Slave height. */
2557 * actual x, y coords of pane. */
2558 int *paneWidthPtr, /* Pane width. */
2559 int *paneHeightPtr) /* Pane height. */
25612560 {
2562 int diffx = 0; /* Cavity width - slave width. */
2563 int diffy = 0; /* Cavity hight - slave height. */
2564
2565 if (cavityWidth > *slaveWidthPtr) {
2566 diffx = cavityWidth - *slaveWidthPtr;
2567 }
2568
2569 if (cavityHeight > *slaveHeightPtr) {
2570 diffy = cavityHeight - *slaveHeightPtr;
2561 int diffx = 0; /* Cavity width - pane width. */
2562 int diffy = 0; /* Cavity hight - pane height. */
2563
2564 if (cavityWidth > *paneWidthPtr) {
2565 diffx = cavityWidth - *paneWidthPtr;
2566 }
2567
2568 if (cavityHeight > *paneHeightPtr) {
2569 diffy = cavityHeight - *paneHeightPtr;
25712570 }
25722571
25732572 if ((sticky & STICK_EAST) && (sticky & STICK_WEST)) {
2574 *slaveWidthPtr += diffx;
2573 *paneWidthPtr += diffx;
25752574 }
25762575 if ((sticky & STICK_NORTH) && (sticky & STICK_SOUTH)) {
2577 *slaveHeightPtr += diffy;
2576 *paneHeightPtr += diffy;
25782577 }
25792578 if (!(sticky & STICK_WEST)) {
25802579 *xPtr += (sticky & STICK_EAST) ? diffx : diffx/2;
26072606 int diff)
26082607 {
26092608 int i;
2610 int expandPane, reduceFirst, reduceLast, reduceIncr, slaveSize, sashOffset;
2611 Slave *slavePtr;
2609 int expandPane, reduceFirst, reduceLast, reduceIncr, paneSize, sashOffset;
2610 Pane *panePtr;
26122611 int stretchReserve = 0;
26132612 int nextSash = sash + 1;
26142613 const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL);
26172616 return;
26182617
26192618 /*
2620 * Update the slave sizes with their real sizes.
2619 * Update the pane sizes with their real sizes.
26212620 */
26222621
26232622 if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) {
26262625 } else {
26272626 sashOffset = pwPtr->sashPad;
26282627 }
2629 for (i = 0; i < pwPtr->numSlaves; i++) {
2630 slavePtr = pwPtr->slaves[i];
2631 if (slavePtr->hide) {
2628 for (i = 0; i < pwPtr->numPanes; i++) {
2629 panePtr = pwPtr->panes[i];
2630 if (panePtr->hide) {
26322631 continue;
26332632 }
26342633 if (horizontal) {
2635 slavePtr->paneWidth = slavePtr->width = slavePtr->sashx
2636 - sashOffset - slavePtr->x - (2 * slavePtr->padx);
2634 panePtr->paneWidth = panePtr->width = panePtr->sashx
2635 - sashOffset - panePtr->x - (2 * panePtr->padx);
26372636 } else {
2638 slavePtr->paneHeight = slavePtr->height = slavePtr->sashy
2639 - sashOffset - slavePtr->y - (2 * slavePtr->pady);
2637 panePtr->paneHeight = panePtr->height = panePtr->sashy
2638 - sashOffset - panePtr->y - (2 * panePtr->pady);
26402639 }
26412640 }
26422641
26462645 * pane to either side of the sash.
26472646 */
26482647
2649 while (nextSash < pwPtr->numSlaves-1 && pwPtr->slaves[nextSash]->hide) {
2648 while (nextSash < pwPtr->numPanes-1 && pwPtr->panes[nextSash]->hide) {
26502649 nextSash++;
26512650 }
26522651
26572656 if (diff > 0) {
26582657 expandPane = sash;
26592658 reduceFirst = nextSash;
2660 reduceLast = pwPtr->numSlaves;
2659 reduceLast = pwPtr->numPanes;
26612660 reduceIncr = 1;
26622661 } else {
26632662 diff = abs(diff);
26732672 */
26742673
26752674 for (i = reduceFirst; i != reduceLast; i += reduceIncr) {
2676 slavePtr = pwPtr->slaves[i];
2677 if (slavePtr->hide) {
2675 panePtr = pwPtr->panes[i];
2676 if (panePtr->hide) {
26782677 continue;
26792678 }
26802679 if (horizontal) {
2681 stretchReserve += slavePtr->width - slavePtr->minSize;
2680 stretchReserve += panePtr->width - panePtr->minSize;
26822681 } else {
2683 stretchReserve += slavePtr->height - slavePtr->minSize;
2682 stretchReserve += panePtr->height - panePtr->minSize;
26842683 }
26852684 }
26862685 if (stretchReserve <= 0) {
26942693 * Expand pane by diff amount.
26952694 */
26962695
2697 slavePtr = pwPtr->slaves[expandPane];
2696 panePtr = pwPtr->panes[expandPane];
26982697 if (horizontal) {
2699 slavePtr->paneWidth = slavePtr->width += diff;
2698 panePtr->paneWidth = panePtr->width += diff;
27002699 } else {
2701 slavePtr->paneHeight = slavePtr->height += diff;
2700 panePtr->paneHeight = panePtr->height += diff;
27022701 }
27032702
27042703 /*
27062705 */
27072706
27082707 for (i = reduceFirst; i != reduceLast; i += reduceIncr) {
2709 slavePtr = pwPtr->slaves[i];
2710 if (slavePtr->hide) {
2708 panePtr = pwPtr->panes[i];
2709 if (panePtr->hide) {
27112710 continue;
27122711 }
27132712 if (horizontal) {
2714 slaveSize = slavePtr->width;
2713 paneSize = panePtr->width;
27152714 } else {
2716 slaveSize = slavePtr->height;
2717 }
2718 if (diff > (slaveSize - slavePtr->minSize)) {
2719 diff -= slaveSize - slavePtr->minSize;
2720 slaveSize = slavePtr->minSize;
2715 paneSize = panePtr->height;
2716 }
2717 if (diff > (paneSize - panePtr->minSize)) {
2718 diff -= paneSize - panePtr->minSize;
2719 paneSize = panePtr->minSize;
27212720 } else {
2722 slaveSize -= diff;
2721 paneSize -= diff;
27232722 i = reduceLast - reduceIncr;
27242723 }
27252724 if (horizontal) {
2726 slavePtr->paneWidth = slavePtr->width = slaveSize;
2725 panePtr->paneWidth = panePtr->width = paneSize;
27272726 } else {
2728 slavePtr->paneHeight = slavePtr->height = slaveSize;
2727 panePtr->paneHeight = panePtr->height = paneSize;
27292728 }
27302729 }
27312730 }
27532752 ClientData clientData, /* Information about window. */
27542753 XEvent *eventPtr) /* Information about event. */
27552754 {
2756 PanedWindow *pwPtr = clientData;
2755 PanedWindow *pwPtr = (PanedWindow *)clientData;
27572756
27582757 if (eventPtr->type == Expose) {
27592758 if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) {
27852784 DisplayProxyWindow(
27862785 ClientData clientData) /* Information about window. */
27872786 {
2788 PanedWindow *pwPtr = clientData;
2787 PanedWindow *pwPtr = (PanedWindow *)clientData;
27892788 Pixmap pixmap;
27902789 Tk_Window tkwin = pwPtr->proxywin;
27912790 pwPtr->flags &= ~PROXY_REDRAW_PENDING;
29052904 return TCL_ERROR;
29062905 }
29072906
2908 internalBW = Tk_InternalBorderWidth(pwPtr->tkwin);
2907 internalBW = Tk_InternalBorderLeft(pwPtr->tkwin);
29092908 if (pwPtr->orient == ORIENT_HORIZONTAL) {
29102909 if (x < 0) {
29112910 x = 0;
29142913 if (x > pwWidth) {
29152914 x = pwWidth;
29162915 }
2917 y = Tk_InternalBorderWidth(pwPtr->tkwin);
2916 y = Tk_InternalBorderLeft(pwPtr->tkwin);
29182917 sashWidth = pwPtr->sashWidth;
29192918 sashHeight = Tk_Height(pwPtr->tkwin) -
2920 (2 * Tk_InternalBorderWidth(pwPtr->tkwin));
2919 (2 * Tk_InternalBorderLeft(pwPtr->tkwin));
29212920 } else {
29222921 if (y < 0) {
29232922 y = 0;
29262925 if (y > pwHeight) {
29272926 y = pwHeight;
29282927 }
2929 x = Tk_InternalBorderWidth(pwPtr->tkwin);
2928 x = Tk_InternalBorderLeft(pwPtr->tkwin);
29302929 sashHeight = pwPtr->sashWidth;
29312930 sashWidth = Tk_Width(pwPtr->tkwin) -
2932 (2 * Tk_InternalBorderWidth(pwPtr->tkwin));
2931 (2 * Tk_InternalBorderLeft(pwPtr->tkwin));
29332932 }
29342933
29352934 if (sashWidth < 1) {
29482947
29492948 /*
29502949 * Make sure the proxy window is higher in the stacking order than the
2951 * slaves, so that it will be visible when drawn. It would be more
2950 * panes, so that it will be visible when drawn. It would be more
29522951 * correct to push the proxy window just high enough to appear above
2953 * the highest slave, but it's much easier to just force it all the
2952 * the highest pane, but it's much easier to just force it all the
29542953 * way to the top of the stacking order.
29552954 */
29562955
30653064 } else {
30663065 sashHeight = Tk_ReqHeight(pwPtr->tkwin);
30673066 }
3068 sashHeight -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin);
3067 sashHeight -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin);
30693068 if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) {
30703069 sashWidth = pwPtr->handleSize;
30713070 lpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2;
30933092 } else {
30943093 sashWidth = Tk_ReqWidth(pwPtr->tkwin);
30953094 }
3096 sashWidth -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin);
3095 sashWidth -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin);
30973096 lpad = rpad = 0;
30983097 }
30993098
31003099 GetFirstLastVisiblePane(pwPtr, &first, &last);
31013100 isHandle = 0;
31023101 found = -1;
3103 for (i = 0; i < pwPtr->numSlaves - 1; i++) {
3104 if (pwPtr->slaves[i]->hide || i == last) {
3102 for (i = 0; i < pwPtr->numPanes - 1; i++) {
3103 if (pwPtr->panes[i]->hide || i == last) {
31053104 continue;
31063105 }
3107 thisx = pwPtr->slaves[i]->sashx;
3108 thisy = pwPtr->slaves[i]->sashy;
3106 thisx = pwPtr->panes[i]->sashx;
3107 thisy = pwPtr->panes[i]->sashy;
31093108
31103109 if (((thisx - lpad) <= x && x <= (thisx + rpad + sashWidth)) &&
31113110 ((thisy - tpad) <= y && y <= (thisy + bpad + sashHeight))) {
31163115 */
31173116
31183117 if (pwPtr->showHandle) {
3119 thisx = pwPtr->slaves[i]->handlex;
3120 thisy = pwPtr->slaves[i]->handley;
3118 thisx = pwPtr->panes[i]->handlex;
3119 thisy = pwPtr->panes[i]->handley;
31213120 if (pwPtr->orient == ORIENT_HORIZONTAL) {
31223121 if (thisy <= y && y <= (thisy + pwPtr->handleSize)) {
31233122 isHandle = 1;
1616 * Border modes for relative placement:
1717 *
1818 * BM_INSIDE: relative distances computed using area inside all
19 * borders of master window.
19 * borders of container window.
2020 * BM_OUTSIDE: relative distances computed using outside area that
21 * includes all borders of master.
22 * BM_IGNORE: border issues are ignored: place relative to master's
21 * includes all borders of container.
22 * BM_IGNORE: border issues are ignored: place relative to container's
2323 * actual window size.
2424 */
2525
3434 * structure of the following type:
3535 */
3636
37 typedef struct Slave {
37 typedef struct Content {
3838 Tk_Window tkwin; /* Tk's token for window. */
3939 Tk_Window inTkwin; /* Token for the -in window. */
40 struct Master *masterPtr; /* Pointer to information for window relative
40 struct Container *containerPtr; /* Pointer to information for window relative
4141 * to which tkwin is placed. This isn't
4242 * necessarily the logical parent of tkwin.
43 * NULL means the master was deleted or never
43 * NULL means the container was deleted or never
4444 * assigned. */
45 struct Slave *nextPtr; /* Next in list of windows placed relative to
46 * same master (NULL for end of list). */
45 struct Content *nextPtr; /* Next in list of windows placed relative to
46 * same container (NULL for end of list). */
4747 Tk_OptionTable optionTable; /* Table that defines configuration options
4848 * available for this command. */
4949 /*
5656 Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel
5757 * spec. information. */
5858 double relX, relY; /* X and Y coordinates relative to size of
59 * master. */
59 * container. */
6060 int width, height; /* Absolute dimensions for tkwin. */
6161 Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel
6262 * spec. */
6363 Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel
6464 * spec. */
6565 double relWidth, relHeight; /* Dimensions for tkwin relative to size of
66 * master. */
66 * container. */
6767 Tcl_Obj *relWidthPtr;
6868 Tcl_Obj *relHeightPtr;
6969 Tk_Anchor anchor; /* Which point on tkwin is placed at the given
7070 * position. */
71 BorderMode borderMode; /* How to treat borders of master window. */
71 BorderMode borderMode; /* How to treat borders of container window. */
7272 int flags; /* Various flags; see below for bit
7373 * definitions. */
74 } Slave;
74 } Content;
7575
7676 /*
7777 * Type masks for options:
8181
8282 static const Tk_OptionSpec optionSpecs[] = {
8383 {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", -1,
84 Tk_Offset(Slave, anchor), 0, 0, 0},
84 Tk_Offset(Content, anchor), 0, 0, 0},
8585 {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", -1,
86 Tk_Offset(Slave, borderMode), 0, borderModeStrings, 0},
87 {TK_OPTION_PIXELS, "-height", NULL, NULL, "", Tk_Offset(Slave, heightPtr),
88 Tk_Offset(Slave, height), TK_OPTION_NULL_OK, 0, 0},
89 {TK_OPTION_WINDOW, "-in", NULL, NULL, "", -1, Tk_Offset(Slave, inTkwin),
86 Tk_Offset(Content, borderMode), 0, borderModeStrings, 0},
87 {TK_OPTION_PIXELS, "-height", NULL, NULL, "", Tk_Offset(Content, heightPtr),
88 Tk_Offset(Content, height), TK_OPTION_NULL_OK, 0, 0},
89 {TK_OPTION_WINDOW, "-in", NULL, NULL, "", -1, Tk_Offset(Content, inTkwin),
9090 0, 0, IN_MASK},
9191 {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "",
92 Tk_Offset(Slave, relHeightPtr), Tk_Offset(Slave, relHeight),
92 Tk_Offset(Content, relHeightPtr), Tk_Offset(Content, relHeight),
9393 TK_OPTION_NULL_OK, 0, 0},
9494 {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "",
95 Tk_Offset(Slave, relWidthPtr), Tk_Offset(Slave, relWidth),
95 Tk_Offset(Content, relWidthPtr), Tk_Offset(Content, relWidth),
9696 TK_OPTION_NULL_OK, 0, 0},
9797 {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0", -1,
98 Tk_Offset(Slave, relX), 0, 0, 0},
98 Tk_Offset(Content, relX), 0, 0, 0},
9999 {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", -1,
100 Tk_Offset(Slave, relY), 0, 0, 0},
101 {TK_OPTION_PIXELS, "-width", NULL, NULL, "", Tk_Offset(Slave, widthPtr),
102 Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0},
103 {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", Tk_Offset(Slave, xPtr),
104 Tk_Offset(Slave, x), TK_OPTION_NULL_OK, 0, 0},
105 {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", Tk_Offset(Slave, yPtr),
106 Tk_Offset(Slave, y), TK_OPTION_NULL_OK, 0, 0},
100 Tk_Offset(Content, relY), 0, 0, 0},
101 {TK_OPTION_PIXELS, "-width", NULL, NULL, "", Tk_Offset(Content, widthPtr),
102 Tk_Offset(Content, width), TK_OPTION_NULL_OK, 0, 0},
103 {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", Tk_Offset(Content, xPtr),
104 Tk_Offset(Content, x), TK_OPTION_NULL_OK, 0, 0},
105 {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", Tk_Offset(Content, yPtr),
106 Tk_Offset(Content, y), TK_OPTION_NULL_OK, 0, 0},
107107 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
108108 };
109109
110110 /*
111 * Flag definitions for Slave structures:
111 * Flag definitions for Content structures:
112112 *
113113 * CHILD_WIDTH - 1 means -width was specified;
114114 * CHILD_REL_WIDTH - 1 means -relwidth was specified.
122122 #define CHILD_REL_HEIGHT 8
123123
124124 /*
125 * For each master window that has a slave managed by the placer there is a
125 * For each container window that has a content managed by the placer there is a
126126 * structure of the following form:
127127 */
128128
129 typedef struct Master {
130 Tk_Window tkwin; /* Tk's token for master window. */
131 struct Slave *slavePtr; /* First in linked list of slaves placed
132 * relative to this master. */
129 typedef struct Container {
130 Tk_Window tkwin; /* Tk's token for container window. */
131 struct Content *contentPtr; /* First in linked list of content placed
132 * relative to this container. */
133133 int *abortPtr; /* If non-NULL, it means that there is a nested
134134 * call to RecomputePlacement already working on
135135 * this window. *abortPtr may be set to 1 to
136136 * abort that nested call. This happens, for
137 * example, if tkwin or any of its slaves
137 * example, if tkwin or any of its content
138138 * is deleted. */
139139 int flags; /* See below for bit definitions. */
140 } Master;
141
142 /*
143 * Flag definitions for masters:
140 } Container;
141
142 /*
143 * Flag definitions for containers:
144144 *
145145 * PARENT_RECONFIG_PENDING - 1 means that a call to RecomputePlacement is
146146 * already pending via a Do_When_Idle handler.
154154
155155 static void PlaceRequestProc(ClientData clientData,
156156 Tk_Window tkwin);
157 static void PlaceLostSlaveProc(ClientData clientData,
157 static void PlaceLostContentProc(ClientData clientData,
158158 Tk_Window tkwin);
159159
160160 static const Tk_GeomMgr placerType = {
161161 "place", /* name */
162162 PlaceRequestProc, /* requestProc */
163 PlaceLostSlaveProc, /* lostSlaveProc */
163 PlaceLostContentProc, /* lostContentProc */
164164 };
165165
166166 /*
167167 * Forward declarations for functions defined later in this file:
168168 */
169169
170 static void SlaveStructureProc(ClientData clientData,
170 static void ContentStructureProc(ClientData clientData,
171171 XEvent *eventPtr);
172 static int ConfigureSlave(Tcl_Interp *interp, Tk_Window tkwin,
172 static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
173173 Tk_OptionTable table, int objc,
174174 Tcl_Obj *const objv[]);
175175 static int PlaceInfoCommand(Tcl_Interp *interp, Tk_Window tkwin);
176 static Slave * CreateSlave(Tk_Window tkwin, Tk_OptionTable table);
177 static void FreeSlave(Slave *slavePtr);
178 static Slave * FindSlave(Tk_Window tkwin);
179 static Master * CreateMaster(Tk_Window tkwin);
180 static Master * FindMaster(Tk_Window tkwin);
181 static void MasterStructureProc(ClientData clientData,
176 static Content * CreateContent(Tk_Window tkwin, Tk_OptionTable table);
177 static void FreeContent(Content *contentPtr);
178 static Content * FindContent(Tk_Window tkwin);
179 static Container * CreateContainer(Tk_Window tkwin);
180 static Container * FindContainer(Tk_Window tkwin);
181 static void PlaceStructureProc(ClientData clientData,
182182 XEvent *eventPtr);
183183 static void RecomputePlacement(ClientData clientData);
184 static void UnlinkSlave(Slave *slavePtr);
184 static void UnlinkContent(Content *contentPtr);
185185
186186 /*
187187 *--------------------------------------------------------------
207207 int objc, /* Number of arguments. */
208208 Tcl_Obj *const objv[]) /* Argument objects. */
209209 {
210 Tk_Window main_win = clientData;
210 Tk_Window main_win = (Tk_Window)clientData;
211211 Tk_Window tkwin;
212 Slave *slavePtr;
212 Content *contentPtr;
213213 TkDisplay *dispPtr;
214214 Tk_OptionTable optionTable;
215215 static const char *const optionStrings[] = {
216 "configure", "forget", "info", "slaves", NULL
216 "configure", "content", "forget", "info", "slaves", NULL
217217 };
218 enum options { PLACE_CONFIGURE, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES };
218 enum options { PLACE_CONFIGURE, PLACE_CONTENT, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES };
219219 int index;
220220
221221 if (objc < 3) {
251251 dispPtr->placeInit = 1;
252252 }
253253
254 return ConfigureSlave(interp, tkwin, optionTable, objc-2, objv+2);
254 return ConfigureContent(interp, tkwin, optionTable, objc-2, objv+2);
255255 }
256256
257257 /*
285285 if (objc == 3 || objc == 4) {
286286 Tcl_Obj *objPtr;
287287
288 slavePtr = FindSlave(tkwin);
289 if (slavePtr == NULL) {
288 contentPtr = FindContent(tkwin);
289 if (contentPtr == NULL) {
290290 return TCL_OK;
291291 }
292 objPtr = Tk_GetOptionInfo(interp, (char *) slavePtr, optionTable,
292 objPtr = Tk_GetOptionInfo(interp, (char *)contentPtr, optionTable,
293293 (objc == 4) ? objv[3] : NULL, tkwin);
294294 if (objPtr == NULL) {
295295 return TCL_ERROR;
297297 Tcl_SetObjResult(interp, objPtr);
298298 return TCL_OK;
299299 }
300 return ConfigureSlave(interp, tkwin, optionTable, objc-3, objv+3);
300 return ConfigureContent(interp, tkwin, optionTable, objc-3, objv+3);
301301
302302 case PLACE_FORGET:
303303 if (objc != 3) {
304304 Tcl_WrongNumArgs(interp, 2, objv, "pathName");
305305 return TCL_ERROR;
306306 }
307 slavePtr = FindSlave(tkwin);
308 if (slavePtr == NULL) {
307 contentPtr = FindContent(tkwin);
308 if (contentPtr == NULL) {
309309 return TCL_OK;
310310 }
311 if ((slavePtr->masterPtr != NULL) &&
312 (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) {
313 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
314 }
315 UnlinkSlave(slavePtr);
311 if ((contentPtr->containerPtr != NULL) &&
312 (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin))) {
313 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
314 }
315 UnlinkContent(contentPtr);
316316 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
317 (char *) tkwin));
318 Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
319 slavePtr);
317 (void *)tkwin));
318 Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
319 contentPtr);
320320 Tk_ManageGeometry(tkwin, NULL, NULL);
321321 Tk_UnmapWindow(tkwin);
322 FreeSlave(slavePtr);
322 FreeContent(contentPtr);
323323 break;
324324
325325 case PLACE_INFO:
329329 }
330330 return PlaceInfoCommand(interp, tkwin);
331331
332 case PLACE_CONTENT:
332333 case PLACE_SLAVES: {
333 Master *masterPtr;
334 Container *containerPtr;
334335
335336 if (objc != 3) {
336337 Tcl_WrongNumArgs(interp, 2, objv, "pathName");
337338 return TCL_ERROR;
338339 }
339 masterPtr = FindMaster(tkwin);
340 if (masterPtr != NULL) {
340 containerPtr = FindContainer(tkwin);
341 if (containerPtr != NULL) {
341342 Tcl_Obj *listPtr = Tcl_NewObj();
342343
343 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
344 slavePtr = slavePtr->nextPtr) {
344 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
345 contentPtr = contentPtr->nextPtr) {
345346 Tcl_ListObjAppendElement(NULL, listPtr,
346 TkNewWindowObj(slavePtr->tkwin));
347 TkNewWindowObj(contentPtr->tkwin));
347348 }
348349 Tcl_SetObjResult(interp, listPtr);
349350 }
357358 /*
358359 *----------------------------------------------------------------------
359360 *
360 * CreateSlave --
361 *
362 * Given a Tk_Window token, find the Slave structure corresponding to
361 * CreateContent --
362 *
363 * Given a Tk_Window token, find the Content structure corresponding to
363364 * that token, creating a new one if necessary.
364365 *
365366 * Results:
366 * Pointer to the Slave structure.
367 *
368 * Side effects:
369 * A new Slave structure may be created.
370 *
371 *----------------------------------------------------------------------
372 */
373
374 static Slave *
375 CreateSlave(
376 Tk_Window tkwin, /* Token for desired slave. */
367 * Pointer to the Content structure.
368 *
369 * Side effects:
370 * A new Content structure may be created.
371 *
372 *----------------------------------------------------------------------
373 */
374
375 static Content *
376 CreateContent(
377 Tk_Window tkwin, /* Token for desired content. */
377378 Tk_OptionTable table)
378379 {
379380 Tcl_HashEntry *hPtr;
380 register Slave *slavePtr;
381 Content *contentPtr;
381382 int isNew;
382383 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
383384
384385 hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew);
385386 if (!isNew) {
386 return Tcl_GetHashValue(hPtr);
387 return (Content *)Tcl_GetHashValue(hPtr);
387388 }
388389
389390 /*
390 * No preexisting slave structure for that window, so make a new one and
391 * No preexisting content structure for that window, so make a new one and
391392 * populate it with some default values.
392393 */
393394
394 slavePtr = ckalloc(sizeof(Slave));
395 memset(slavePtr, 0, sizeof(Slave));
396 slavePtr->tkwin = tkwin;
397 slavePtr->inTkwin = NULL;
398 slavePtr->anchor = TK_ANCHOR_NW;
399 slavePtr->borderMode = BM_INSIDE;
400 slavePtr->optionTable = table;
401 Tcl_SetHashValue(hPtr, slavePtr);
402 Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
403 slavePtr);
404 return slavePtr;
405 }
406
407 /*
408 *----------------------------------------------------------------------
409 *
410 * FreeSlave --
411 *
412 * Frees the resources held by a Slave structure.
395 contentPtr = (Content *)ckalloc(sizeof(Content));
396 memset(contentPtr, 0, sizeof(Content));
397 contentPtr->tkwin = tkwin;
398 contentPtr->inTkwin = NULL;
399 contentPtr->anchor = TK_ANCHOR_NW;
400 contentPtr->borderMode = BM_INSIDE;
401 contentPtr->optionTable = table;
402 Tcl_SetHashValue(hPtr, contentPtr);
403 Tk_CreateEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
404 contentPtr);
405 return contentPtr;
406 }
407
408 /*
409 *----------------------------------------------------------------------
410 *
411 * FreeContent --
412 *
413 * Frees the resources held by a Content structure.
413414 *
414415 * Results:
415416 * None
421422 */
422423
423424 static void
424 FreeSlave(
425 Slave *slavePtr)
426 {
427 Tk_FreeConfigOptions((char *) slavePtr, slavePtr->optionTable,
428 slavePtr->tkwin);
429 ckfree(slavePtr);
430 }
431
432 /*
433 *----------------------------------------------------------------------
434 *
435 * FindSlave --
436 *
437 * Given a Tk_Window token, find the Slave structure corresponding to
425 FreeContent(
426 Content *contentPtr)
427 {
428 Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable,
429 contentPtr->tkwin);
430 ckfree(contentPtr);
431 }
432
433 /*
434 *----------------------------------------------------------------------
435 *
436 * FindContent --
437 *
438 * Given a Tk_Window token, find the Content structure corresponding to
438439 * that token. This is purely a lookup function; it will not create a
439440 * record if one does not yet exist.
440441 *
441442 * Results:
442 * Pointer to Slave structure; NULL if none exists.
443 * Pointer to Content structure; NULL if none exists.
443444 *
444445 * Side effects:
445446 * None.
447448 *----------------------------------------------------------------------
448449 */
449450
450 static Slave *
451 FindSlave(
452 Tk_Window tkwin) /* Token for desired slave. */
453 {
454 register Tcl_HashEntry *hPtr;
451 static Content *
452 FindContent(
453 Tk_Window tkwin) /* Token for desired content. */
454 {
455 Tcl_HashEntry *hPtr;
455456 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
456457
457458 hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin);
458459 if (hPtr == NULL) {
459460 return NULL;
460461 }
461 return Tcl_GetHashValue(hPtr);
462 }
463
464 /*
465 *----------------------------------------------------------------------
466 *
467 * UnlinkSlave --
468 *
469 * This function removes a slave window from the chain of slaves in its
470 * master.
462 return (Content *)Tcl_GetHashValue(hPtr);
463 }
464
465 /*
466 *----------------------------------------------------------------------
467 *
468 * UnlinkContent --
469 *
470 * This function removes a content window from the chain of content in its
471 * container.
471472 *
472473 * Results:
473474 * None.
474475 *
475476 * Side effects:
476 * The slave list of slavePtr's master changes.
477 * The content list of contentPtr's container changes.
477478 *
478479 *----------------------------------------------------------------------
479480 */
480481
481482 static void
482 UnlinkSlave(
483 Slave *slavePtr) /* Slave structure to be unlinked. */
484 {
485 register Master *masterPtr;
486 register Slave *prevPtr;
487
488 masterPtr = slavePtr->masterPtr;
489 if (masterPtr == NULL) {
483 UnlinkContent(
484 Content *contentPtr) /* Content structure to be unlinked. */
485 {
486 Container *containerPtr;
487 Content *prevPtr;
488
489 containerPtr = contentPtr->containerPtr;
490 if (containerPtr == NULL) {
490491 return;
491492 }
492 if (masterPtr->slavePtr == slavePtr) {
493 masterPtr->slavePtr = slavePtr->nextPtr;
493 if (containerPtr->contentPtr == contentPtr) {
494 containerPtr->contentPtr = contentPtr->nextPtr;
494495 } else {
495 for (prevPtr = masterPtr->slavePtr; ; prevPtr = prevPtr->nextPtr) {
496 for (prevPtr = containerPtr->contentPtr; ; prevPtr = prevPtr->nextPtr) {
496497 if (prevPtr == NULL) {
497 Tcl_Panic("UnlinkSlave couldn't find slave to unlink");
498 }
499 if (prevPtr->nextPtr == slavePtr) {
500 prevPtr->nextPtr = slavePtr->nextPtr;
498 Tcl_Panic("UnlinkContent couldn't find slave to unlink");
499 }
500 if (prevPtr->nextPtr == contentPtr) {
501 prevPtr->nextPtr = contentPtr->nextPtr;
501502 break;
502503 }
503504 }
504505 }
505506
506 if (masterPtr->abortPtr != NULL) {
507 *masterPtr->abortPtr = 1;
508 }
509 slavePtr->masterPtr = NULL;
510 }
511
512 /*
513 *----------------------------------------------------------------------
514 *
515 * CreateMaster --
516 *
517 * Given a Tk_Window token, find the Master structure corresponding to
507 if (containerPtr->abortPtr != NULL) {
508 *containerPtr->abortPtr = 1;
509 }
510 contentPtr->containerPtr = NULL;
511 }
512
513 /*
514 *----------------------------------------------------------------------
515 *
516 * CreateContainer --
517 *
518 * Given a Tk_Window token, find the Container structure corresponding to
518519 * that token, creating a new one if necessary.
519520 *
520521 * Results:
521 * Pointer to the Master structure.
522 *
523 * Side effects:
524 * A new Master structure may be created.
525 *
526 *----------------------------------------------------------------------
527 */
528
529 static Master *
530 CreateMaster(
531 Tk_Window tkwin) /* Token for desired master. */
522 * Pointer to the Container structure.
523 *
524 * Side effects:
525 * A new Container structure may be created.
526 *
527 *----------------------------------------------------------------------
528 */
529
530 static Container *
531 CreateContainer(
532 Tk_Window tkwin) /* Token for desired container. */
532533 {
533534 Tcl_HashEntry *hPtr;
534 register Master *masterPtr;
535 Container *containerPtr;
535536 int isNew;
536537 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
537538
538 hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew);
539 hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *)tkwin, &isNew);
539540 if (isNew) {
540 masterPtr = ckalloc(sizeof(Master));
541 masterPtr->tkwin = tkwin;
542 masterPtr->slavePtr = NULL;
543 masterPtr->abortPtr = NULL;
544 masterPtr->flags = 0;
545 Tcl_SetHashValue(hPtr, masterPtr);
546 Tk_CreateEventHandler(masterPtr->tkwin, StructureNotifyMask,
547 MasterStructureProc, masterPtr);
541 containerPtr = (Container *)ckalloc(sizeof(Container));
542 containerPtr->tkwin = tkwin;
543 containerPtr->contentPtr = NULL;
544 containerPtr->abortPtr = NULL;
545 containerPtr->flags = 0;
546 Tcl_SetHashValue(hPtr, containerPtr);
547 Tk_CreateEventHandler(containerPtr->tkwin, StructureNotifyMask,
548 PlaceStructureProc, containerPtr);
548549 } else {
549 masterPtr = Tcl_GetHashValue(hPtr);
550 }
551 return masterPtr;
552 }
553
554 /*
555 *----------------------------------------------------------------------
556 *
557 * FindMaster --
558 *
559 * Given a Tk_Window token, find the Master structure corresponding to
550 containerPtr = (Container *)Tcl_GetHashValue(hPtr);
551 }
552 return containerPtr;
553 }
554
555 /*
556 *----------------------------------------------------------------------
557 *
558 * FindContainer --
559 *
560 * Given a Tk_Window token, find the Container structure corresponding to
560561 * that token. This is simply a lookup function; a new record will not be
561562 * created if one does not already exist.
562563 *
563564 * Results:
564 * Pointer to the Master structure; NULL if one does not exist for the
565 * Pointer to the Container structure; NULL if one does not exist for the
565566 * given Tk_Window token.
566567 *
567568 * Side effects:
570571 *----------------------------------------------------------------------
571572 */
572573
573 static Master *
574 FindMaster(
575 Tk_Window tkwin) /* Token for desired master. */
576 {
577 register Tcl_HashEntry *hPtr;
574 static Container *
575 FindContainer(
576 Tk_Window tkwin) /* Token for desired container. */
577 {
578 Tcl_HashEntry *hPtr;
578579 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
579580
580581 hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin);
581582 if (hPtr == NULL) {
582583 return NULL;
583584 }
584 return Tcl_GetHashValue(hPtr);
585 }
586
587 /*
588 *----------------------------------------------------------------------
589 *
590 * ConfigureSlave --
585 return (Container *)Tcl_GetHashValue(hPtr);
586 }
587
588 /*
589 *----------------------------------------------------------------------
590 *
591 * ConfigureContent --
591592 *
592593 * This function is called to process an argv/argc list to reconfigure
593594 * the placement of a window.
597598 * the interp's result.
598599 *
599600 * Side effects:
600 * Information in slavePtr may change, and slavePtr's master is scheduled
601 * Information in contentPtr may change, and contentPtr's container is scheduled
601602 * for reconfiguration.
602603 *
603604 *----------------------------------------------------------------------
604605 */
605606
606607 static int
607 ConfigureSlave(
608 ConfigureContent(
608609 Tcl_Interp *interp, /* Used for error reporting. */
609610 Tk_Window tkwin, /* Token for the window to manipulate. */
610611 Tk_OptionTable table, /* Token for option table. */
611612 int objc, /* Number of config arguments. */
612613 Tcl_Obj *const objv[]) /* Object values for arguments. */
613614 {
614 register Master *masterPtr;
615 Container *containerPtr;
615616 Tk_SavedOptions savedOptions;
616617 int mask;
617 Slave *slavePtr;
618 Tk_Window masterWin = NULL;
619 TkWindow *master;
618 Content *contentPtr;
619 Tk_Window containerWin = NULL;
620 TkWindow *container;
620621
621622 if (Tk_TopWinHierarchy(tkwin)) {
622623 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
626627 return TCL_ERROR;
627628 }
628629
629 slavePtr = CreateSlave(tkwin, table);
630
631 if (Tk_SetOptions(interp, (char *) slavePtr, table, objc, objv,
632 slavePtr->tkwin, &savedOptions, &mask) != TCL_OK) {
630 contentPtr = CreateContent(tkwin, table);
631
632 if (Tk_SetOptions(interp, (char *)contentPtr, table, objc, objv,
633 contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) {
633634 goto error;
634635 }
635636
636637 /*
637 * Set slave flags. First clear the field, then add bits as needed.
638 * Set content flags. First clear the field, then add bits as needed.
638639 */
639640
640 slavePtr->flags = 0;
641 if (slavePtr->heightPtr) {
642 slavePtr->flags |= CHILD_HEIGHT;
643 }
644
645 if (slavePtr->relHeightPtr) {
646 slavePtr->flags |= CHILD_REL_HEIGHT;
647 }
648
649 if (slavePtr->relWidthPtr) {
650 slavePtr->flags |= CHILD_REL_WIDTH;
651 }
652
653 if (slavePtr->widthPtr) {
654 slavePtr->flags |= CHILD_WIDTH;
655 }
656
657 if (!(mask & IN_MASK) && (slavePtr->masterPtr != NULL)) {
641 contentPtr->flags = 0;
642 if (contentPtr->heightPtr) {
643 contentPtr->flags |= CHILD_HEIGHT;
644 }
645
646 if (contentPtr->relHeightPtr) {
647 contentPtr->flags |= CHILD_REL_HEIGHT;
648 }
649
650 if (contentPtr->relWidthPtr) {
651 contentPtr->flags |= CHILD_REL_WIDTH;
652 }
653
654 if (contentPtr->widthPtr) {
655 contentPtr->flags |= CHILD_WIDTH;
656 }
657
658 if (!(mask & IN_MASK) && (contentPtr->containerPtr != NULL)) {
658659 /*
659 * If no -in option was passed and the slave is already placed then
660 * If no -in option was passed and the content is already placed then
660661 * just recompute the placement.
661662 */
662663
663 masterPtr = slavePtr->masterPtr;
664 containerPtr = contentPtr->containerPtr;
664665 goto scheduleLayout;
665666 } else if (mask & IN_MASK) {
666667 /* -in changed */
667 Tk_Window tkwin;
668 Tk_Window win;
668669 Tk_Window ancestor;
669670
670 tkwin = slavePtr->inTkwin;
671 win = contentPtr->inTkwin;
671672
672673 /*
673 * Make sure that the new master is either the logical parent of the
674 * slave or a descendant of that window, and that the master and slave
674 * Make sure that the new container is either the logical parent of the
675 * content or a descendant of that window, and that the container and content
675676 * aren't the same.
676677 */
677678
678 for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) {
679 if (ancestor == Tk_Parent(slavePtr->tkwin)) {
679 for (ancestor = win; ; ancestor = Tk_Parent(ancestor)) {
680 if (ancestor == Tk_Parent(contentPtr->tkwin)) {
680681 break;
681682 }
682683 if (Tk_TopWinHierarchy(ancestor)) {
683684 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
684685 "can't place %s relative to %s",
685 Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin)));
686 Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
686687 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
687688 goto error;
688689 }
689690 }
690 if (slavePtr->tkwin == tkwin) {
691 if (contentPtr->tkwin == win) {
691692 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
692693 "can't place %s relative to itself",
693 Tk_PathName(slavePtr->tkwin)));
694 Tk_PathName(contentPtr->tkwin)));
694695 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
695696 goto error;
696697 }
699700 * Check for management loops.
700701 */
701702
702 for (master = (TkWindow *)tkwin; master != NULL;
703 master = (TkWindow *)TkGetGeomMaster(master)) {
704 if (master == (TkWindow *)slavePtr->tkwin) {
703 for (container = (TkWindow *)win; container != NULL;
704 container = (TkWindow *)TkGetContainer(container)) {
705 if (container == (TkWindow *)contentPtr->tkwin) {
705706 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
706707 "can't put %s inside %s, would cause management loop",
707 Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin)));
708 Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
708709 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
709710 goto error;
710711 }
711712 }
712 if (tkwin != Tk_Parent(slavePtr->tkwin)) {
713 ((TkWindow *)slavePtr->tkwin)->maintainerPtr = (TkWindow *)tkwin;
714 }
715
716 if ((slavePtr->masterPtr != NULL)
717 && (slavePtr->masterPtr->tkwin == tkwin)) {
713 if (win != Tk_Parent(contentPtr->tkwin)) {
714 ((TkWindow *)contentPtr->tkwin)->maintainerPtr = (TkWindow *)win;
715 }
716
717 if ((contentPtr->containerPtr != NULL)
718 && (contentPtr->containerPtr->tkwin == win)) {
718719 /*
719 * Re-using same old master. Nothing to do.
720 * Re-using same old container. Nothing to do.
720721 */
721722
722 masterPtr = slavePtr->masterPtr;
723 containerPtr = contentPtr->containerPtr;
723724 goto scheduleLayout;
724725 }
725 if ((slavePtr->masterPtr != NULL) &&
726 (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) {
727 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
728 }
729 UnlinkSlave(slavePtr);
730 masterWin = tkwin;
726 if ((contentPtr->containerPtr != NULL) &&
727 (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin))) {
728 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
729 }
730 UnlinkContent(contentPtr);
731 containerWin = win;
731732 }
732733
733734 /*
734 * If there's no master specified for this slave, use its Tk_Parent.
735 * If there's no container specified for this content, use its Tk_Parent.
735736 */
736737
737 if (masterWin == NULL) {
738 masterWin = Tk_Parent(slavePtr->tkwin);
739 slavePtr->inTkwin = masterWin;
738 if (containerWin == NULL) {
739 containerWin = Tk_Parent(contentPtr->tkwin);
740 contentPtr->inTkwin = containerWin;
740741 }
741742
742743 /*
743 * Manage the slave window in this master.
744 * Manage the content window in this container.
744745 */
745746
746 masterPtr = CreateMaster(masterWin);
747 slavePtr->masterPtr = masterPtr;
748 slavePtr->nextPtr = masterPtr->slavePtr;
749 masterPtr->slavePtr = slavePtr;
750 Tk_ManageGeometry(slavePtr->tkwin, &placerType, slavePtr);
747 containerPtr = CreateContainer(containerWin);
748 contentPtr->containerPtr = containerPtr;
749 contentPtr->nextPtr = containerPtr->contentPtr;
750 containerPtr->contentPtr = contentPtr;
751 Tk_ManageGeometry(contentPtr->tkwin, &placerType, contentPtr);
751752
752753 /*
753 * Arrange for the master to be re-arranged at the first idle moment.
754 * Arrange for the container to be re-arranged at the first idle moment.
754755 */
755756
756757 scheduleLayout:
757758 Tk_FreeSavedOptions(&savedOptions);
758759
759 if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
760 masterPtr->flags |= PARENT_RECONFIG_PENDING;
761 Tcl_DoWhenIdle(RecomputePlacement, masterPtr);
760 if (!(containerPtr->flags & PARENT_RECONFIG_PENDING)) {
761 containerPtr->flags |= PARENT_RECONFIG_PENDING;
762 Tcl_DoWhenIdle(RecomputePlacement, containerPtr);
762763 }
763764 return TCL_OK;
764765
794795 Tcl_Interp *interp, /* Interp into which to place result. */
795796 Tk_Window tkwin) /* Token for the window to get info on. */
796797 {
797 Slave *slavePtr;
798 Content *contentPtr;
798799 Tcl_Obj *infoObj;
799800
800 slavePtr = FindSlave(tkwin);
801 if (slavePtr == NULL) {
801 contentPtr = FindContent(tkwin);
802 if (contentPtr == NULL) {
802803 return TCL_OK;
803804 }
804805 infoObj = Tcl_NewObj();
805 if (slavePtr->masterPtr != NULL) {
806 if (contentPtr->containerPtr != NULL) {
806807 Tcl_AppendToObj(infoObj, "-in", -1);
807808 Tcl_ListObjAppendElement(NULL, infoObj,
808 TkNewWindowObj(slavePtr->masterPtr->tkwin));
809 TkNewWindowObj(contentPtr->containerPtr->tkwin));
809810 Tcl_AppendToObj(infoObj, " ", -1);
810811 }
811812 Tcl_AppendPrintfToObj(infoObj,
812813 "-x %d -relx %.4g -y %d -rely %.4g",
813 slavePtr->x, slavePtr->relX, slavePtr->y, slavePtr->relY);
814 if (slavePtr->flags & CHILD_WIDTH) {
815 Tcl_AppendPrintfToObj(infoObj, " -width %d", slavePtr->width);
814 contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY);
815 if (contentPtr->flags & CHILD_WIDTH) {
816 Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width);
816817 } else {
817818 Tcl_AppendToObj(infoObj, " -width {}", -1);
818819 }
819 if (slavePtr->flags & CHILD_REL_WIDTH) {
820 if (contentPtr->flags & CHILD_REL_WIDTH) {
820821 Tcl_AppendPrintfToObj(infoObj,
821 " -relwidth %.4g", slavePtr->relWidth);
822 " -relwidth %.4g", contentPtr->relWidth);
822823 } else {
823824 Tcl_AppendToObj(infoObj, " -relwidth {}", -1);
824825 }
825 if (slavePtr->flags & CHILD_HEIGHT) {
826 Tcl_AppendPrintfToObj(infoObj, " -height %d", slavePtr->height);
826 if (contentPtr->flags & CHILD_HEIGHT) {
827 Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height);
827828 } else {
828829 Tcl_AppendToObj(infoObj, " -height {}", -1);
829830 }
830 if (slavePtr->flags & CHILD_REL_HEIGHT) {
831 if (contentPtr->flags & CHILD_REL_HEIGHT) {
831832 Tcl_AppendPrintfToObj(infoObj,
832 " -relheight %.4g", slavePtr->relHeight);
833 " -relheight %.4g", contentPtr->relHeight);
833834 } else {
834835 Tcl_AppendToObj(infoObj, " -relheight {}", -1);
835836 }
836837
837838 Tcl_AppendPrintfToObj(infoObj, " -anchor %s -bordermode %s",
838 Tk_NameOfAnchor(slavePtr->anchor),
839 borderModeStrings[slavePtr->borderMode]);
839 Tk_NameOfAnchor(contentPtr->anchor),
840 borderModeStrings[contentPtr->borderMode]);
840841 Tcl_SetObjResult(interp, infoObj);
841842 return TCL_OK;
842843 }
847848 * RecomputePlacement --
848849 *
849850 * This function is called as a when-idle handler. It recomputes the
850 * geometries of all the slaves of a given master.
851 * geometries of all the content of a given container.
851852 *
852853 * Results:
853854 * None.
860861
861862 static void
862863 RecomputePlacement(
863 ClientData clientData) /* Pointer to Master record. */
864 {
865 register Master *masterPtr = clientData;
866 register Slave *slavePtr;
864 ClientData clientData) /* Pointer to Container record. */
865 {
866 Container *containerPtr = (Container *)clientData;
867 Content *contentPtr;
867868 int x, y, width, height, tmp;
868 int masterWidth, masterHeight, masterX, masterY;
869 int containerWidth, containerHeight, containerX, containerY;
869870 double x1, y1, x2, y2;
870871 int abort; /* May get set to non-zero to abort this
871872 * placement operation. */
872873
873 masterPtr->flags &= ~PARENT_RECONFIG_PENDING;
874 containerPtr->flags &= ~PARENT_RECONFIG_PENDING;
874875
875876 /*
876877 * Abort any nested call to RecomputePlacement for this window, since
878879 * aborted if necessary.
879880 */
880881
881 if (masterPtr->abortPtr != NULL) {
882 *masterPtr->abortPtr = 1;
883 }
884 masterPtr->abortPtr = &abort;
882 if (containerPtr->abortPtr != NULL) {
883 *containerPtr->abortPtr = 1;
884 }
885 containerPtr->abortPtr = &abort;
885886 abort = 0;
886 Tcl_Preserve(masterPtr);
887 Tcl_Preserve(containerPtr);
887888
888889 /*
889 * Iterate over all the slaves for the master. Each slave's geometry can
890 * be computed independently of the other slaves. Changes to the window's
890 * Iterate over all the content for the container. Each content's geometry can
891 * be computed independently of the other content. Changes to the window's
891892 * structure could cause almost anything to happen, including deleting the
892893 * parent or child. If this happens, we'll be told to abort.
893894 */
894895
895 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL && !abort;
896 slavePtr = slavePtr->nextPtr) {
896 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL && !abort;
897 contentPtr = contentPtr->nextPtr) {
897898 /*
898 * Step 1: compute size and borderwidth of master, taking into account
899 * Step 1: compute size and borderwidth of container, taking into account
899900 * desired border mode.
900901 */
901902
902 masterX = masterY = 0;
903 masterWidth = Tk_Width(masterPtr->tkwin);
904 masterHeight = Tk_Height(masterPtr->tkwin);
905 if (slavePtr->borderMode == BM_INSIDE) {
906 masterX = Tk_InternalBorderLeft(masterPtr->tkwin);
907 masterY = Tk_InternalBorderTop(masterPtr->tkwin);
908 masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin);
909 masterHeight -= masterY +
910 Tk_InternalBorderBottom(masterPtr->tkwin);
911 } else if (slavePtr->borderMode == BM_OUTSIDE) {
912 masterX = masterY = -Tk_Changes(masterPtr->tkwin)->border_width;
913 masterWidth -= 2 * masterX;
914 masterHeight -= 2 * masterY;
903 containerX = containerY = 0;
904 containerWidth = Tk_Width(containerPtr->tkwin);
905 containerHeight = Tk_Height(containerPtr->tkwin);
906 if (contentPtr->borderMode == BM_INSIDE) {
907 containerX = Tk_InternalBorderLeft(containerPtr->tkwin);
908 containerY = Tk_InternalBorderTop(containerPtr->tkwin);
909 containerWidth -= containerX + Tk_InternalBorderRight(containerPtr->tkwin);
910 containerHeight -= containerY +
911 Tk_InternalBorderBottom(containerPtr->tkwin);
912 } else if (contentPtr->borderMode == BM_OUTSIDE) {
913 containerX = containerY = -Tk_Changes(containerPtr->tkwin)->border_width;
914 containerWidth -= 2 * containerX;
915 containerHeight -= 2 * containerY;
915916 }
916917
917918 /*
918 * Step 2: compute size of slave (outside dimensions including border)
919 * and location of anchor point within master.
919 * Step 2: compute size of content (outside dimensions including border)
920 * and location of anchor point within container.
920921 */
921922
922 x1 = slavePtr->x + masterX + (slavePtr->relX*masterWidth);
923 x1 = contentPtr->x + containerX + (contentPtr->relX*containerWidth);
923924 x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5));
924 y1 = slavePtr->y + masterY + (slavePtr->relY*masterHeight);
925 y1 = contentPtr->y + containerY + (contentPtr->relY*containerHeight);
925926 y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5));
926 if (slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) {
927 if (contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) {
927928 width = 0;
928 if (slavePtr->flags & CHILD_WIDTH) {
929 width += slavePtr->width;
930 }
931 if (slavePtr->flags & CHILD_REL_WIDTH) {
929 if (contentPtr->flags & CHILD_WIDTH) {
930 width += contentPtr->width;
931 }
932 if (contentPtr->flags & CHILD_REL_WIDTH) {
932933 /*
933934 * The code below is a bit tricky. In order to round correctly
934935 * when both relX and relWidth are specified, compute the
937938 * errors in relX and relWidth accumulate.
938939 */
939940
940 x2 = x1 + (slavePtr->relWidth*masterWidth);
941 x2 = x1 + (contentPtr->relWidth*containerWidth);
941942 tmp = (int) (x2 + ((x2 > 0) ? 0.5 : -0.5));
942943 width += tmp - x;
943944 }
944945 } else {
945 width = Tk_ReqWidth(slavePtr->tkwin)
946 + 2*Tk_Changes(slavePtr->tkwin)->border_width;
947 }
948 if (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) {
946 width = Tk_ReqWidth(contentPtr->tkwin)
947 + 2*Tk_Changes(contentPtr->tkwin)->border_width;
948 }
949 if (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) {
949950 height = 0;
950 if (slavePtr->flags & CHILD_HEIGHT) {
951 height += slavePtr->height;
952 }
953 if (slavePtr->flags & CHILD_REL_HEIGHT) {
951 if (contentPtr->flags & CHILD_HEIGHT) {
952 height += contentPtr->height;
953 }
954 if (contentPtr->flags & CHILD_REL_HEIGHT) {
954955 /*
955956 * See note above for rounding errors in width computation.
956957 */
957958
958 y2 = y1 + (slavePtr->relHeight*masterHeight);
959 y2 = y1 + (contentPtr->relHeight*containerHeight);
959960 tmp = (int) (y2 + ((y2 > 0) ? 0.5 : -0.5));
960961 height += tmp - y;
961962 }
962963 } else {
963 height = Tk_ReqHeight(slavePtr->tkwin)
964 + 2*Tk_Changes(slavePtr->tkwin)->border_width;
964 height = Tk_ReqHeight(contentPtr->tkwin)
965 + 2*Tk_Changes(contentPtr->tkwin)->border_width;
965966 }
966967
967968 /*
968969 * Step 3: adjust the x and y positions so that the desired anchor
969 * point on the slave appears at that position. Also adjust for the
970 * border mode and master's border.
970 * point on the content appears at that position. Also adjust for the
971 * border mode and container's border.
971972 */
972973
973 switch (slavePtr->anchor) {
974 switch (contentPtr->anchor) {
974975 case TK_ANCHOR_N:
975976 x -= width/2;
976977 break;
10091010 * height aren't zero.
10101011 */
10111012
1012 width -= 2*Tk_Changes(slavePtr->tkwin)->border_width;
1013 height -= 2*Tk_Changes(slavePtr->tkwin)->border_width;
1013 width -= 2*Tk_Changes(contentPtr->tkwin)->border_width;
1014 height -= 2*Tk_Changes(contentPtr->tkwin)->border_width;
10141015 if (width <= 0) {
10151016 width = 1;
10161017 }
10191020 }
10201021
10211022 /*
1022 * Step 5: reconfigure the window and map it if needed. If the slave
1023 * is a child of the master, we do this ourselves. If the slave isn't
1024 * a child of the master, let Tk_MaintainGeometry do the work (it will
1023 * Step 5: reconfigure the window and map it if needed. If the content
1024 * is a child of the container, we do this ourselves. If the content isn't
1025 * a child of the container, let Tk_MaintainGeometry do the work (it will
10251026 * re-adjust things as relevant windows map, unmap, and move).
10261027 */
10271028
1028 if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
1029 if ((x != Tk_X(slavePtr->tkwin))
1030 || (y != Tk_Y(slavePtr->tkwin))
1031 || (width != Tk_Width(slavePtr->tkwin))
1032 || (height != Tk_Height(slavePtr->tkwin))) {
1033 Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
1029 if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) {
1030 if ((x != Tk_X(contentPtr->tkwin))
1031 || (y != Tk_Y(contentPtr->tkwin))
1032 || (width != Tk_Width(contentPtr->tkwin))
1033 || (height != Tk_Height(contentPtr->tkwin))) {
1034 Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height);
10341035 }
10351036 if (abort) {
10361037 break;
10371038 }
10381039
10391040 /*
1040 * Don't map the slave unless the master is mapped: the slave will
1041 * get mapped later, when the master is mapped.
1041 * Don't map the content unless the container is mapped: the content will
1042 * get mapped later, when the container is mapped.
10421043 */
10431044
1044 if (Tk_IsMapped(masterPtr->tkwin)) {
1045 Tk_MapWindow(slavePtr->tkwin);
1045 if (Tk_IsMapped(containerPtr->tkwin)) {
1046 Tk_MapWindow(contentPtr->tkwin);
10461047 }
10471048 } else {
10481049 if ((width <= 0) || (height <= 0)) {
1049 Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
1050 Tk_UnmapWindow(slavePtr->tkwin);
1050 Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin);
1051 Tk_UnmapWindow(contentPtr->tkwin);
10511052 } else {
1052 Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin,
1053 Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin,
10531054 x, y, width, height);
10541055 }
10551056 }
10561057 }
10571058
1058 masterPtr->abortPtr = NULL;
1059 Tcl_Release(masterPtr);
1060 }
1061
1062 /*
1063 *----------------------------------------------------------------------
1064 *
1065 * MasterStructureProc --
1059 containerPtr->abortPtr = NULL;
1060 Tcl_Release(containerPtr);
1061 }
1062
1063 /*
1064 *----------------------------------------------------------------------
1065 *
1066 * PlaceStructureProc --
10661067 *
10671068 * This function is invoked by the Tk event handler when StructureNotify
1068 * events occur for a master window.
1069 * events occur for a container window.
10691070 *
10701071 * Results:
10711072 * None.
10721073 *
10731074 * Side effects:
10741075 * Structures get cleaned up if the window was deleted. If the window was
1075 * resized then slave geometries get recomputed.
1076 * resized then content geometries get recomputed.
10761077 *
10771078 *----------------------------------------------------------------------
10781079 */
10791080
10801081 static void
1081 MasterStructureProc(
1082 ClientData clientData, /* Pointer to Master structure for window
1082 PlaceStructureProc(
1083 ClientData clientData, /* Pointer to Container structure for window
10831084 * referred to by eventPtr. */
10841085 XEvent *eventPtr) /* Describes what just happened. */
10851086 {
1086 register Master *masterPtr = clientData;
1087 register Slave *slavePtr, *nextPtr;
1088 TkDisplay *dispPtr = ((TkWindow *) masterPtr->tkwin)->dispPtr;
1087 Container *containerPtr = (Container *)clientData;
1088 Content *contentPtr, *nextPtr;
1089 TkDisplay *dispPtr = ((TkWindow *) containerPtr->tkwin)->dispPtr;
10891090
10901091 switch (eventPtr->type) {
10911092 case ConfigureNotify:
1092 if ((masterPtr->slavePtr != NULL)
1093 && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
1094 masterPtr->flags |= PARENT_RECONFIG_PENDING;
1095 Tcl_DoWhenIdle(RecomputePlacement, masterPtr);
1093 if ((containerPtr->contentPtr != NULL)
1094 && !(containerPtr->flags & PARENT_RECONFIG_PENDING)) {
1095 containerPtr->flags |= PARENT_RECONFIG_PENDING;
1096 Tcl_DoWhenIdle(RecomputePlacement, containerPtr);
10961097 }
10971098 return;
10981099 case DestroyNotify:
1099 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
1100 slavePtr = nextPtr) {
1101 slavePtr->masterPtr = NULL;
1102 nextPtr = slavePtr->nextPtr;
1103 slavePtr->nextPtr = NULL;
1100 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
1101 contentPtr = nextPtr) {
1102 contentPtr->containerPtr = NULL;
1103 nextPtr = contentPtr->nextPtr;
1104 contentPtr->nextPtr = NULL;
11041105 }
11051106 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->masterTable,
1106 (char *) masterPtr->tkwin));
1107 if (masterPtr->flags & PARENT_RECONFIG_PENDING) {
1108 Tcl_CancelIdleCall(RecomputePlacement, masterPtr);
1109 }
1110 masterPtr->tkwin = NULL;
1111 if (masterPtr->abortPtr != NULL) {
1112 *masterPtr->abortPtr = 1;
1113 }
1114 Tcl_EventuallyFree(masterPtr, TCL_DYNAMIC);
1107 (char *) containerPtr->tkwin));
1108 if (containerPtr->flags & PARENT_RECONFIG_PENDING) {
1109 Tcl_CancelIdleCall(RecomputePlacement, containerPtr);
1110 }
1111 containerPtr->tkwin = NULL;
1112 if (containerPtr->abortPtr != NULL) {
1113 *containerPtr->abortPtr = 1;
1114 }
1115 Tcl_EventuallyFree(containerPtr, TCL_DYNAMIC);
11151116 return;
11161117 case MapNotify:
11171118 /*
1118 * When a master gets mapped, must redo the geometry computation so
1119 * that all of its slaves get remapped.
1119 * When a container gets mapped, must redo the geometry computation so
1120 * that all of its content get remapped.
11201121 */
11211122
1122 if ((masterPtr->slavePtr != NULL)
1123 && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
1124 masterPtr->flags |= PARENT_RECONFIG_PENDING;
1125 Tcl_DoWhenIdle(RecomputePlacement, masterPtr);
1123 if ((containerPtr->contentPtr != NULL)
1124 && !(containerPtr->flags & PARENT_RECONFIG_PENDING)) {
1125 containerPtr->flags |= PARENT_RECONFIG_PENDING;
1126 Tcl_DoWhenIdle(RecomputePlacement, containerPtr);
11261127 }
11271128 return;
11281129 case UnmapNotify:
11291130 /*
1130 * Unmap all of the slaves when the master gets unmapped, so that they
1131 * Unmap all of the content when the container gets unmapped, so that they
11311132 * don't keep redisplaying themselves.
11321133 */
11331134
1134 for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
1135 slavePtr = slavePtr->nextPtr) {
1136 Tk_UnmapWindow(slavePtr->tkwin);
1135 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
1136 contentPtr = contentPtr->nextPtr) {
1137 Tk_UnmapWindow(contentPtr->tkwin);
11371138 }
11381139 return;
11391140 }
11421143 /*
11431144 *----------------------------------------------------------------------
11441145 *
1145 * SlaveStructureProc --
1146 * ContentStructureProc --
11461147 *
11471148 * This function is invoked by the Tk event handler when StructureNotify
1148 * events occur for a slave window.
1149 * events occur for a content window.
11491150 *
11501151 * Results:
11511152 * None.
11571158 */
11581159
11591160 static void
1160 SlaveStructureProc(
1161 ClientData clientData, /* Pointer to Slave structure for window
1161 ContentStructureProc(
1162 ClientData clientData, /* Pointer to Content structure for window
11621163 * referred to by eventPtr. */
11631164 XEvent *eventPtr) /* Describes what just happened. */
11641165 {
1165 register Slave *slavePtr = clientData;
1166 TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr;
1166 Content *contentPtr = (Content *)clientData;
1167 TkDisplay *dispPtr = ((TkWindow *) contentPtr->tkwin)->dispPtr;
11671168
11681169 if (eventPtr->type == DestroyNotify) {
1169 if (slavePtr->masterPtr != NULL) {
1170 UnlinkSlave(slavePtr);
1170 if (contentPtr->containerPtr != NULL) {
1171 UnlinkContent(contentPtr);
11711172 }
11721173 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
1173 (char *) slavePtr->tkwin));
1174 FreeSlave(slavePtr);
1174 (char *) contentPtr->tkwin));
1175 FreeContent(contentPtr);
11751176 }
11761177 }
11771178
11801181 *
11811182 * PlaceRequestProc --
11821183 *
1183 * This function is invoked by Tk whenever a slave managed by us changes
1184 * This function is invoked by Tk whenever a content managed by us changes
11841185 * its requested geometry.
11851186 *
11861187 * Results:
11931194 *----------------------------------------------------------------------
11941195 */
11951196
1196 /* ARGSUSED */
11971197 static void
11981198 PlaceRequestProc(
1199 ClientData clientData, /* Pointer to our record for slave. */
1200 Tk_Window tkwin) /* Window that changed its desired size. */
1201 {
1202 Slave *slavePtr = clientData;
1203 Master *masterPtr;
1204
1205 if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
1206 && (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
1199 ClientData clientData, /* Pointer to our record for content. */
1200 TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
1201 {
1202 Content *contentPtr = (Content *)clientData;
1203 Container *containerPtr;
1204
1205 if ((contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
1206 && (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
12071207 /*
12081208 * Send a ConfigureNotify to indicate that the size change
12091209 * request was rejected.
12101210 */
12111211
1212 TkDoConfigureNotify((TkWindow *)(slavePtr->tkwin));
1212 TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin));
12131213 return;
12141214 }
1215 masterPtr = slavePtr->masterPtr;
1216 if (masterPtr == NULL) {
1215 containerPtr = contentPtr->containerPtr;
1216 if (containerPtr == NULL) {
12171217 return;
12181218 }
1219 if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
1220 masterPtr->flags |= PARENT_RECONFIG_PENDING;
1221 Tcl_DoWhenIdle(RecomputePlacement, masterPtr);
1219 if (!(containerPtr->flags & PARENT_RECONFIG_PENDING)) {
1220 containerPtr->flags |= PARENT_RECONFIG_PENDING;
1221 Tcl_DoWhenIdle(RecomputePlacement, containerPtr);
12221222 }
12231223 }
12241224
12251225 /*
12261226 *--------------------------------------------------------------
12271227 *
1228 * PlaceLostSlaveProc --
1228 * PlaceLostContentProc --
12291229 *
12301230 * This function is invoked by Tk whenever some other geometry claims
1231 * control over a slave that used to be managed by us.
1231 * control over a content window that used to be managed by us.
12321232 *
12331233 * Results:
12341234 * None.
12351235 *
12361236 * Side effects:
1237 * Forgets all placer-related information about the slave.
1237 * Forgets all placer-related information about the content window.
12381238 *
12391239 *--------------------------------------------------------------
12401240 */
12411241
1242 /* ARGSUSED */
12431242 static void
1244 PlaceLostSlaveProc(
1245 ClientData clientData, /* Slave structure for slave window that was
1243 PlaceLostContentProc(
1244 ClientData clientData, /* Content structure for content window that was
12461245 * stolen away. */
1247 Tk_Window tkwin) /* Tk's handle for the slave window. */
1248 {
1249 register Slave *slavePtr = clientData;
1250 TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr;
1251
1252 if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
1253 Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
1246 Tk_Window tkwin) /* Tk's handle for the content window. */
1247 {
1248 Content *contentPtr = (Content *)clientData;
1249 TkDisplay *dispPtr = ((TkWindow *) contentPtr->tkwin)->dispPtr;
1250
1251 if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) {
1252 Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
12541253 }
12551254 Tk_UnmapWindow(tkwin);
1256 UnlinkSlave(slavePtr);
1255 UnlinkContent(contentPtr);
12571256 Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
12581257 (char *) tkwin));
1259 Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
1260 slavePtr);
1261 FreeSlave(slavePtr);
1258 Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
1259 contentPtr);
1260 FreeContent(contentPtr);
12621261 }
12631262
12641263 /*
8181 EXTERN void Tk_MacOSXSetupTkNotifier(void);
8282 /* 10 */
8383 EXTERN int Tk_MacOSXIsAppInFront(void);
84 /* 11 */
85 EXTERN Tk_Window Tk_MacOSXGetTkWindow(void *w);
86 /* 12 */
87 EXTERN void * Tk_MacOSXGetCGContextForDrawable(Drawable drawable);
88 /* 13 */
89 EXTERN void * Tk_MacOSXGetNSWindowForDrawable(Drawable drawable);
90 /* Slot 14 is reserved */
91 /* Slot 15 is reserved */
92 /* 16 */
93 EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y,
94 int width, int height, int flags);
8495 #endif /* AQUA */
8596
8697 typedef struct TkPlatStubs {
107118 void * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */
108119 void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */
109120 int (*tk_MacOSXIsAppInFront) (void); /* 10 */
121 Tk_Window (*tk_MacOSXGetTkWindow) (void *w); /* 11 */
122 void * (*tk_MacOSXGetCGContextForDrawable) (Drawable drawable); /* 12 */
123 void * (*tk_MacOSXGetNSWindowForDrawable) (Drawable drawable); /* 13 */
124 void (*reserved14)(void);
125 void (*reserved15)(void);
126 void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */
110127 #endif /* AQUA */
111128 } TkPlatStubs;
112129
159176 (tkPlatStubsPtr->tk_MacOSXSetupTkNotifier) /* 9 */
160177 #define Tk_MacOSXIsAppInFront \
161178 (tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */
179 #define Tk_MacOSXGetTkWindow \
180 (tkPlatStubsPtr->tk_MacOSXGetTkWindow) /* 11 */
181 #define Tk_MacOSXGetCGContextForDrawable \
182 (tkPlatStubsPtr->tk_MacOSXGetCGContextForDrawable) /* 12 */
183 #define Tk_MacOSXGetNSWindowForDrawable \
184 (tkPlatStubsPtr->tk_MacOSXGetNSWindowForDrawable) /* 13 */
185 /* Slot 14 is reserved */
186 /* Slot 15 is reserved */
187 #define TkGenWMConfigureEvent_ \
188 (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */
162189 #endif /* AQUA */
163190
164191 #endif /* defined(USE_TK_STUBS) */
172199 #undef TCL_STORAGE_CLASS
173200 #define TCL_STORAGE_CLASS DLLIMPORT
174201
202 #undef TkGenWMConfigureEvent_
203 #define Tk_MacOSXGetNSViewForDrawable TkMacOSXGetRootControl
204
175205 #endif /* _TKPLATDECLS */
2525 typedef struct {
2626 TkWindow *grabWinPtr; /* Window that defines the top of the grab
2727 * tree in a global grab. */
28 int lastState; /* Last known state flags. */
28 unsigned lastState; /* Last known state flags. */
2929 XPoint lastPos; /* Last reported mouse position. */
3030 TkWindow *lastWinPtr; /* Last reported mouse window. */
3131 TkWindow *restrictWinPtr; /* Window to which all mouse events will be
224224 TkWindow *targetWinPtr;
225225 XPoint pos;
226226 XEvent event;
227 int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS;
228 int type, b, mask;
227 unsigned changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS;
228 int type, b;
229 unsigned mask;
229230
230231 pos.x = x;
231232 pos.y = y;
593594 }
594595
595596 /*
596 *----------------------------------------------------------------------
597 *
598 * TkGenerateActivateEvents --
599 *
600 * This function is called by the Mac and Windows window manager routines
601 * when a toplevel window is activated or deactivated.
602 * Activate/Deactivate events will be sent to every subwindow of the
603 * toplevel followed by a FocusIn/FocusOut message.
604 *
605 * Results:
606 * None.
607 *
608 * Side effects:
609 * Generates X events.
610 *
611 *----------------------------------------------------------------------
612 */
613
614 void
615 TkGenerateActivateEvents(
616 TkWindow *winPtr, /* Toplevel to activate. */
617 int active) /* Non-zero if the window is being activated,
618 * else 0.*/
619 {
620 XEvent event;
621
622 /*
623 * Generate Activate and Deactivate events. This event is sent to every
624 * subwindow in a toplevel window.
625 */
626
627 event.xany.serial = winPtr->display->request++;
628 event.xany.send_event = False;
629 event.xany.display = winPtr->display;
630 event.xany.window = winPtr->window;
631
632 event.xany.type = active ? ActivateNotify : DeactivateNotify;
633 TkQueueEventForAllChildren(winPtr, &event);
634 }
635
636 /*
637597 * Local Variables:
638598 * mode: c
639599 * c-basic-offset: 4
657657 }
658658 }
659659
660 /*
661 * Several options need special processing, such as parsing the
662 * orientation and creating GCs.
663 */
664
665 scalePtr->fromValue = TkRoundValueToResolution(scalePtr,
666 scalePtr->fromValue);
660 /*
661 * The fromValue shall not be rounded to the resolution, but the
662 * toValue and tickInterval do.
663 */
664
667665 scalePtr->toValue = TkRoundValueToResolution(scalePtr, scalePtr->toValue);
668666 scalePtr->tickInterval = TkRoundIntervalToResolution(scalePtr,
669667 scalePtr->tickInterval);
126126 int objc, /* Number of arguments. */
127127 Tcl_Obj *const objv[]) /* Argument strings. */
128128 {
129 Tk_Window tkwin = clientData;
130 register TkScrollbar *scrollPtr;
129 Tk_Window tkwin = (Tk_Window)clientData;
130 TkScrollbar *scrollPtr;
131131 Tk_Window newWin;
132132
133133 if (objc < 2) {
222222 int objc, /* Number of arguments. */
223223 Tcl_Obj *const objv[]) /* Argument strings. */
224224 {
225 register TkScrollbar *scrollPtr = clientData;
225 TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
226226 int result = TCL_OK;
227227 int length, cmdIndex;
228228 static const char *const commandNames[] = {
307307 break;
308308 }
309309 case COMMAND_DELTA: {
310 int xDelta, yDelta, pixels, length;
310 int xDelta, yDelta, pixels;
311311 double fraction;
312312
313313 if (objc != 4) {
336336 break;
337337 }
338338 case COMMAND_FRACTION: {
339 int x, y, pos, length;
339 int x, y, pos;
340340 double fraction;
341341
342342 if (objc != 4) {
520520 static int
521521 ConfigureScrollbar(
522522 Tcl_Interp *interp, /* Used for error reporting. */
523 register TkScrollbar *scrollPtr,
523 TkScrollbar *scrollPtr,
524524 /* Information about widget; may or may not
525525 * already have values for some fields. */
526526 int objc, /* Number of valid entries in argv. */
583583 ClientData clientData, /* Information about window. */
584584 XEvent *eventPtr) /* Information about event. */
585585 {
586 TkScrollbar *scrollPtr = clientData;
586 TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
587587
588588 if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
589589 TkScrollbarEventuallyRedraw(scrollPtr);
648648 ScrollbarCmdDeletedProc(
649649 ClientData clientData) /* Pointer to widget record for widget. */
650650 {
651 TkScrollbar *scrollPtr = clientData;
651 TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
652652 Tk_Window tkwin = scrollPtr->tkwin;
653653
654654 /*
2727 * chunk. */
2828 char buffer[4]; /* A buffer to hold part of a UTF character
2929 * that is split across chunks. */
30 char command[1]; /* Command to invoke. Actual space is
30 char command[TKFLEXARRAY]; /* Command to invoke. Actual space is
3131 * allocated as large as necessary. This must
3232 * be the last entry in the structure. */
3333 } CommandInfo;
124124 * listed in the ICCCM will be tolerated
125125 * (blech). */
126126 {
127 register TkSelHandler *selPtr;
127 TkSelHandler *selPtr;
128128 TkWindow *winPtr = (TkWindow *) tkwin;
129129
130130 if (winPtr->dispPtr->multipleAtom == None) {
138138
139139 for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) {
140140 if (selPtr == NULL) {
141 selPtr = ckalloc(sizeof(TkSelHandler));
141 selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler));
142142 selPtr->nextPtr = winPtr->selHandlerList;
143143 winPtr->selHandlerList = selPtr;
144144 break;
176176 target = winPtr->dispPtr->utf8Atom;
177177 for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) {
178178 if (selPtr == NULL) {
179 selPtr = ckalloc(sizeof(TkSelHandler));
179 selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler));
180180 selPtr->nextPtr = winPtr->selHandlerList;
181181 winPtr->selHandlerList = selPtr;
182182 selPtr->selection = selection;
238238 * removed. */
239239 {
240240 TkWindow *winPtr = (TkWindow *) tkwin;
241 register TkSelHandler *selPtr, *prevPtr;
242 register TkSelInProgress *ipPtr;
243 ThreadSpecificData *tsdPtr =
241 TkSelHandler *selPtr, *prevPtr;
242 TkSelInProgress *ipPtr;
243 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
244244 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
245245
246246 /*
352352 ClientData clientData) /* Arbitrary one-word argument to pass to
353353 * proc. */
354354 {
355 register TkWindow *winPtr = (TkWindow *) tkwin;
355 TkWindow *winPtr = (TkWindow *) tkwin;
356356 TkDisplay *dispPtr = winPtr->dispPtr;
357357 TkSelectionInfo *infoPtr;
358358 Tk_LostSelProc *clearProc = NULL;
381381 }
382382 }
383383 if (infoPtr == NULL) {
384 infoPtr = ckalloc(sizeof(TkSelectionInfo));
384 infoPtr = (TkSelectionInfo *)ckalloc(sizeof(TkSelectionInfo));
385385 infoPtr->selection = selection;
386386 infoPtr->nextPtr = dispPtr->selectionInfoPtr;
387387 dispPtr->selectionInfoPtr = infoPtr;
459459 Tk_Window tkwin, /* Window that selects a display. */
460460 Atom selection) /* Selection to be cancelled. */
461461 {
462 register TkWindow *winPtr = (TkWindow *) tkwin;
462 TkWindow *winPtr = (TkWindow *) tkwin;
463463 TkDisplay *dispPtr = winPtr->dispPtr;
464464 TkSelectionInfo *infoPtr;
465465 TkSelectionInfo *prevPtr;
555555 TkWindow *winPtr = (TkWindow *) tkwin;
556556 TkDisplay *dispPtr = winPtr->dispPtr;
557557 TkSelectionInfo *infoPtr;
558 ThreadSpecificData *tsdPtr =
558 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
559559 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
560560
561561 if (dispPtr->multipleAtom == None) {
576576 }
577577 }
578578 if (infoPtr != NULL) {
579 register TkSelHandler *selPtr;
579 TkSelHandler *selPtr;
580580 int offset, result, count;
581581 char buffer[TK_SEL_BYTES_AT_ONCE+1];
582582 TkSelInProgress ip;
669669 int objc, /* Number of arguments. */
670670 Tcl_Obj *const objv[]) /* Argument objects. */
671671 {
672 Tk_Window tkwin = clientData;
672 Tk_Window tkwin = (Tk_Window)clientData;
673673 const char *path = NULL;
674674 Atom selection;
675675 const char *selName = NULL;
829829 Atom target, format;
830830 const char *targetName = NULL;
831831 const char *formatName = NULL;
832 register CommandInfo *cmdInfoPtr;
832 CommandInfo *cmdInfoPtr;
833833 int cmdLength;
834834 static const char *const handleOptionStrings[] = {
835835 "-format", "-selection", "-type", NULL
903903 if (cmdLength == 0) {
904904 Tk_DeleteSelHandler(tkwin, selection, target);
905905 } else {
906 cmdInfoPtr = ckalloc(Tk_Offset(CommandInfo, command)
906 cmdInfoPtr = (CommandInfo *)ckalloc(Tk_Offset(CommandInfo, command)
907907 + 1 + cmdLength);
908908 cmdInfoPtr->interp = interp;
909909 cmdInfoPtr->charOffset = 0;
918918 }
919919
920920 case SELECTION_OWN: {
921 register LostCommand *lostPtr;
921 LostCommand *lostPtr;
922922 Tcl_Obj *commandObj = NULL;
923923 static const char *const ownOptionStrings[] = {
924924 "-command", "-displayof", "-selection", NULL
10071007 Tk_OwnSelection(tkwin, selection, NULL, NULL);
10081008 return TCL_OK;
10091009 }
1010 lostPtr = ckalloc(sizeof(LostCommand));
1010 lostPtr = (LostCommand *)ckalloc(sizeof(LostCommand));
10111011 lostPtr->interp = interp;
10121012 lostPtr->cmdObj = commandObj;
10131013 Tcl_IncrRefCount(commandObj);
10391039 TkSelInProgress *
10401040 TkSelGetInProgress(void)
10411041 {
1042 ThreadSpecificData *tsdPtr =
1042 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
10431043 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
10441044
10451045 return tsdPtr->pendingPtr;
10661066 TkSelSetInProgress(
10671067 TkSelInProgress *pendingPtr)
10681068 {
1069 ThreadSpecificData *tsdPtr =
1069 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
10701070 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
10711071
10721072 tsdPtr->pendingPtr = pendingPtr;
10911091
10921092 void
10931093 TkSelDeadWindow(
1094 register TkWindow *winPtr) /* Window that's being deleted. */
1094 TkWindow *winPtr) /* Window that's being deleted. */
10951095 {
1096 register TkSelHandler *selPtr;
1097 register TkSelInProgress *ipPtr;
1096 TkSelHandler *selPtr;
1097 TkSelInProgress *ipPtr;
10981098 TkSelectionInfo *infoPtr, *prevPtr, *nextPtr;
1099 ThreadSpecificData *tsdPtr =
1099 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
11001100 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
11011101
11021102 /*
11691169 Tk_Window tkwin) /* Window token (used to find display to
11701170 * initialize). */
11711171 {
1172 register TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
1172 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
11731173
11741174 /*
11751175 * Fetch commonly-used atoms.
12201220 void
12211221 TkSelClearSelection(
12221222 Tk_Window tkwin, /* Window for which event was targeted. */
1223 register XEvent *eventPtr) /* X SelectionClear event. */
1223 XEvent *eventPtr) /* X SelectionClear event. */
12241224 {
1225 register TkWindow *winPtr = (TkWindow *) tkwin;
1225 TkWindow *winPtr = (TkWindow *) tkwin;
12261226 TkDisplay *dispPtr = winPtr->dispPtr;
12271227 TkSelectionInfo *infoPtr;
12281228 TkSelectionInfo *prevPtr;
12841284 *--------------------------------------------------------------
12851285 */
12861286
1287 /* ARGSUSED */
12881287 static int
12891288 SelGetProc(
12901289 ClientData clientData, /* Dynamic string holding partially assembled
12911290 * selection. */
1292 Tcl_Interp *interp, /* Interpreter used for error reporting (not
1291 TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not
12931292 * used). */
12941293 const char *portion) /* New information to be appended. */
12951294 {
1296 Tcl_DStringAppend(clientData, portion, -1);
1295 Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
12971296 return TCL_OK;
12981297 }
12991298
13991398 cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
14001399 cmdInfoPtr->buffer[0] = '\0';
14011400 } else {
1401 int ch;
14021402 p = string;
14031403 string += count;
14041404 numChars = 0;
14051405 while (p < string) {
1406 p = Tcl_UtfNext(p);
1406 p += TkUtfToUniChar(p, &ch);
14071407 numChars++;
14081408 }
14091409 cmdInfoPtr->charOffset += numChars;
14101410 length = p - string;
14111411 if (length > 0) {
1412 strncpy(cmdInfoPtr->buffer, string, (size_t) length);
1412 strncpy(cmdInfoPtr->buffer, string, length);
14131413 }
14141414 cmdInfoPtr->buffer[length] = '\0';
14151415 }
14681468 Atom *typePtr) /* Store here the type of the selection, for
14691469 * use in converting to proper X format. */
14701470 {
1471 register TkWindow *winPtr = (TkWindow *) infoPtr->owner;
1471 TkWindow *winPtr = (TkWindow *) infoPtr->owner;
14721472 TkDisplay *dispPtr = winPtr->dispPtr;
14731473
14741474 if (target == dispPtr->timestampAtom) {
14811481 }
14821482
14831483 if (target == dispPtr->targetsAtom) {
1484 register TkSelHandler *selPtr;
1484 TkSelHandler *selPtr;
14851485 int length;
14861486 Tcl_DString ds;
14871487
15071507 Tcl_DStringFree(&ds);
15081508 return -1;
15091509 }
1510 memcpy(buffer, Tcl_DStringValue(&ds), (unsigned) (1+length));
1510 memcpy(buffer, Tcl_DStringValue(&ds), length + 1);
15111511 Tcl_DStringFree(&ds);
15121512 *typePtr = XA_ATOM;
15131513 return length;
15641564 LostSelection(
15651565 ClientData clientData) /* Pointer to LostCommand structure. */
15661566 {
1567 LostCommand *lostPtr = clientData;
1567 LostCommand *lostPtr = (LostCommand *)clientData;
15681568 Tcl_Interp *interp = lostPtr->interp;
15691569 Tcl_InterpState savedState;
15701570 int code;
2323 #if defined(MAC_OSX_TK)
2424 /* we could have used _TKMACINT */
2525 #include "tkMacOSXInt.h"
26 #include "tkMacOSXPrivate.h"
2627 #endif
2728
2829 /* TODO: These ought to come in some other way */
4445 #undef XGrabServer
4546 #undef XFree
4647 #undef XFlush
48 #define TkUnusedStubEntry 0
49
50 #define TkpCmapStressed_ TkpCmapStressed
51 #define TkpSync_ TkpSync
52 #define TkUnixContainerId_ TkUnixContainerId
53 #define TkUnixDoOneXEvent_ TkUnixDoOneXEvent
54 #define TkUnixSetMenubar_ TkUnixSetMenubar
55 #define TkWmCleanup_ TkWmCleanup
56 #define TkSendCleanup_ TkSendCleanup
57 #define TkpTestsendCmd_ TkpTestsendCmd
58 #define TkGenWMConfigureEvent_ TkGenWMConfigureEvent
59 #define TkGenerateActivateEvents_ TkGenerateActivateEvents
60
61 #if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL)
62 # undef TkpWillDrawWidget
63 # undef TkpRedrawWidget
64 static int
65 doNothing(void)
66 {
67 /* dummy implementation, no need to do anything */
68 return 0;
69 }
70 # define TkpWillDrawWidget ((int (*)(Tk_Window))(void *)doNothing)
71 # define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing)
72 #endif
73
74 #if defined(MAC_OSX_TK)
75 # define Tk_MacOSXGetNSWindowForDrawable TkMacOSXDrawable
76 # define Tk_MacOSXGetCGContextForDrawable GetCGContextForDrawable
77 static void *GetCGContextForDrawable(Drawable d) {
78 return TkMacOSXGetCGContextForDrawable(d);
79 }
80 #endif
4781
4882 #ifdef _WIN32
4983
182216 # define Tk_PointerEvent 0
183217 # define Tk_TranslateWinEvent 0
184218 # define TkAlignImageData 0
185 # define TkGenerateActivateEvents 0
186219 # define TkpGetMS 0
187220 # define TkpGetCapture 0
188221 # define TkPointerDeadWindow 0
243276 * below should be made in the generic/tk.decls script.
244277 */
245278
279 #ifdef __GNUC__
280 /*
281 * The rest of this file shouldn't warn about deprecated functions; they're
282 * there because we intend them to be so and know that this file is OK to
283 * touch those fields.
284 */
285 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
286 #endif
246287 /* !BEGIN!: Do not edit below this line. */
247288
248289 static const TkIntStubs tkIntStubs = {
460501 TkUnderlineAngledTextLayout, /* 182 */
461502 TkIntersectAngledTextLayout, /* 183 */
462503 TkDrawAngledChars, /* 184 */
504 #if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
505 0, /* 185 */
506 #endif /* UNIX */
507 #if defined(_WIN32) /* WIN */
508 0, /* 185 */
509 #endif /* WIN */
510 #ifdef MAC_OSX_TCL /* MACOSX */
511 TkpRedrawWidget, /* 185 */
512 #endif /* MACOSX */
513 #if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
514 0, /* 186 */
515 #endif /* UNIX */
516 #if defined(_WIN32) /* WIN */
517 0, /* 186 */
518 #endif /* WIN */
519 #ifdef MAC_OSX_TCL /* MACOSX */
520 TkpWillDrawWidget, /* 186 */
521 #endif /* MACOSX */
463522 };
464523
465524 static const TkIntPlatStubs tkIntPlatStubs = {
518577 #ifdef MAC_OSX_TK /* AQUA */
519578 TkGenerateActivateEvents, /* 0 */
520579 0, /* 1 */
521 0, /* 2 */
580 TkGenerateActivateEvents_, /* 2 */
522581 TkPointerDeadWindow, /* 3 */
523582 TkpSetCapture, /* 4 */
524583 TkpSetCursor, /* 5 */
542601 TkMacOSXMakeRealWindowExist, /* 23 */
543602 TkMacOSXMakeStippleMap, /* 24 */
544603 TkMacOSXMenuClick, /* 25 */
545 TkMacOSXRegisterOffScreenWindow, /* 26 */
604 0, /* 26 */
546605 TkMacOSXResizable, /* 27 */
547606 TkMacOSXSetHelpMenuItemCount, /* 28 */
548607 TkMacOSXSetScrollbarGrow, /* 29 */
549608 TkMacOSXSetUpClippingRgn, /* 30 */
550609 TkMacOSXSetUpGraphicsPort, /* 31 */
551610 TkMacOSXUpdateClipRgn, /* 32 */
552 TkMacOSXUnregisterMacWindow, /* 33 */
611 0, /* 33 */
553612 TkMacOSXUseMenuID, /* 34 */
554613 TkMacOSXVisableClipRgn, /* 35 */
555614 TkMacOSXWinBounds, /* 36 */
576635 #if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
577636 TkCreateXEventSource, /* 0 */
578637 0, /* 1 */
579 0, /* 2 */
638 TkGenerateActivateEvents, /* 2 */
580639 TkpCmapStressed, /* 3 */
581640 TkpSync, /* 4 */
582641 TkUnixContainerId, /* 5 */
588647 0, /* 11 */
589648 TkpWmSetState, /* 12 */
590649 TkpTestsendCmd, /* 13 */
650 0, /* 14 */
651 0, /* 15 */
652 0, /* 16 */
653 0, /* 17 */
654 0, /* 18 */
655 0, /* 19 */
656 0, /* 20 */
657 0, /* 21 */
658 0, /* 22 */
659 0, /* 23 */
660 0, /* 24 */
661 0, /* 25 */
662 0, /* 26 */
663 0, /* 27 */
664 0, /* 28 */
665 0, /* 29 */
666 0, /* 30 */
667 0, /* 31 */
668 0, /* 32 */
669 0, /* 33 */
670 0, /* 34 */
671 0, /* 35 */
672 0, /* 36 */
673 0, /* 37 */
674 TkpCmapStressed_, /* 38 */
675 TkpSync_, /* 39 */
676 TkUnixContainerId_, /* 40 */
677 TkUnixDoOneXEvent_, /* 41 */
678 TkUnixSetMenubar_, /* 42 */
679 TkWmCleanup_, /* 43 */
680 TkSendCleanup_, /* 44 */
681 TkpTestsendCmd_, /* 45 */
591682 #endif /* X11 */
592683 };
593684
733824 XDrawPoints, /* 135 */
734825 XReparentWindow, /* 136 */
735826 XPutImage, /* 137 */
827 0, /* 138 */
828 0, /* 139 */
829 0, /* 140 */
830 0, /* 141 */
831 0, /* 142 */
832 0, /* 143 */
833 0, /* 144 */
834 0, /* 145 */
835 0, /* 146 */
836 0, /* 147 */
837 0, /* 148 */
838 0, /* 149 */
839 0, /* 150 */
840 0, /* 151 */
841 0, /* 152 */
842 0, /* 153 */
843 0, /* 154 */
844 0, /* 155 */
845 0, /* 156 */
846 0, /* 157 */
847 TkUnusedStubEntry, /* 158 */
736848 #endif /* WIN */
737849 #ifdef MAC_OSX_TK /* AQUA */
738850 XSetDashes, /* 0 */
841953 0, /* 103 */
842954 0, /* 104 */
843955 0, /* 105 */
844 0, /* 106 */
956 XSetClipRectangles, /* 106 */
845957 XFlush, /* 107 */
846958 XGrabServer, /* 108 */
847959 XUngrabServer, /* 109 */
855967 0, /* 117 */
856968 0, /* 118 */
857969 0, /* 119 */
858 0, /* 120 */
970 XOffsetRegion, /* 120 */
859971 0, /* 121 */
860972 0, /* 122 */
861973 0, /* 123 */
864976 0, /* 126 */
865977 0, /* 127 */
866978 0, /* 128 */
867 0, /* 129 */
979 XLowerWindow, /* 129 */
868980 0, /* 130 */
869981 0, /* 131 */
870982 0, /* 132 */
873985 0, /* 135 */
874986 0, /* 136 */
875987 XPutImage, /* 137 */
988 0, /* 138 */
989 0, /* 139 */
990 0, /* 140 */
991 0, /* 141 */
992 0, /* 142 */
993 0, /* 143 */
994 XDestroyIC, /* 144 */
995 XCreatePixmapCursor, /* 145 */
996 XCreateGlyphCursor, /* 146 */
997 0, /* 147 */
998 0, /* 148 */
999 0, /* 149 */
1000 0, /* 150 */
1001 0, /* 151 */
1002 0, /* 152 */
1003 0, /* 153 */
1004 0, /* 154 */
1005 0, /* 155 */
1006 0, /* 156 */
1007 XkbKeycodeToKeysym, /* 157 */
1008 TkUnusedStubEntry, /* 158 */
8761009 #endif /* AQUA */
8771010 };
8781011
8991032 TkMacOSXGetRootControl, /* 8 */
9001033 Tk_MacOSXSetupTkNotifier, /* 9 */
9011034 Tk_MacOSXIsAppInFront, /* 10 */
1035 Tk_MacOSXGetTkWindow, /* 11 */
1036 Tk_MacOSXGetCGContextForDrawable, /* 12 */
1037 Tk_MacOSXGetNSWindowForDrawable, /* 13 */
1038 0, /* 14 */
1039 0, /* 15 */
1040 TkGenWMConfigureEvent_, /* 16 */
9021041 #endif /* AQUA */
9031042 };
9041043
11861325 Tk_Interp, /* 271 */
11871326 Tk_CreateOldImageType, /* 272 */
11881327 Tk_CreateOldPhotoImageFormat, /* 273 */
1328 0, /* 274 */
1329 0, /* 275 */
1330 0, /* 276 */
1331 0, /* 277 */
1332 0, /* 278 */
1333 0, /* 279 */
1334 TkUnusedStubEntry, /* 280 */
11891335 };
11901336
11911337 /* !END!: Do not edit above this line. */
177177
178178 void
179179 TkStylePkgInit(
180 TkMainInfo *mainPtr) /* The application being created. */
181 {
182 ThreadSpecificData *tsdPtr =
180 TCL_UNUSED(TkMainInfo *)) /* The application being created. */
181 {
182 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
183183 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
184184
185185 if (tsdPtr->nbInit != 0) {
232232
233233 void
234234 TkStylePkgFree(
235 TkMainInfo *mainPtr) /* The application being deleted. */
236 {
237 ThreadSpecificData *tsdPtr =
235 TCL_UNUSED(TkMainInfo *)) /* The application being deleted. */
236 {
237 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
238238 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
239239 Tcl_HashSearch search;
240240 Tcl_HashEntry *entryPtr;
263263
264264 entryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
265265 while (entryPtr != NULL) {
266 enginePtr = Tcl_GetHashValue(entryPtr);
266 enginePtr = (StyleEngine *)Tcl_GetHashValue(entryPtr);
267267 FreeStyleEngine(enginePtr);
268268 ckfree(enginePtr);
269269 entryPtr = Tcl_NextHashEntry(&search);
306306 Tk_StyleEngine parent) /* The engine's parent. NULL means the default
307307 * system engine. */
308308 {
309 ThreadSpecificData *tsdPtr =
309 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
310310 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
311311 Tcl_HashEntry *entryPtr;
312312 int newEntry;
330330 * Allocate and intitialize a new engine.
331331 */
332332
333 enginePtr = ckalloc(sizeof(StyleEngine));
334 InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
333 enginePtr = (StyleEngine *)ckalloc(sizeof(StyleEngine));
334 InitStyleEngine(enginePtr, (const char *)Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
335335 (StyleEngine *) parent);
336336 Tcl_SetHashValue(entryPtr, enginePtr);
337337
363363 StyleEngine *parentPtr) /* The engine's parent. NULL means the default
364364 * system engine. */
365365 {
366 ThreadSpecificData *tsdPtr =
366 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
367367 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
368368 int elementId;
369369
388388 */
389389
390390 if (tsdPtr->nbElements > 0) {
391 enginePtr->elements = ckalloc(
391 enginePtr->elements = (StyledElement *)ckalloc(
392392 sizeof(StyledElement) * tsdPtr->nbElements);
393393 for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) {
394394 InitStyledElement(enginePtr->elements+elementId);
418418 FreeStyleEngine(
419419 StyleEngine *enginePtr) /* The style engine to free. */
420420 {
421 ThreadSpecificData *tsdPtr =
421 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
422422 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
423423 int elementId;
424424
453453 const char *name) /* Name of the engine to retrieve. NULL or
454454 * empty means the default system engine. */
455455 {
456 ThreadSpecificData *tsdPtr =
456 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
457457 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
458458 Tcl_HashEntry *entryPtr;
459459
466466 return NULL;
467467 }
468468
469 return Tcl_GetHashValue(entryPtr);
469 return (Tk_StyleEngine)Tcl_GetHashValue(entryPtr);
470470 }
471471
472472 /*
520520
521521 static void
522522 FreeElement(
523 Element *elementPtr) /* The element to free. */
523 TCL_UNUSED(Element *)) /* The element to free. */
524524 {
525525 /* Nothing to do. */
526526 }
603603 * created explicitly (being registered) or
604604 * implicitly (by a derived element). */
605605 {
606 ThreadSpecificData *tsdPtr =
606 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
607607 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
608608 Tcl_HashEntry *entryPtr, *engineEntryPtr;
609609 Tcl_HashSearch search;
610610 int newEntry, elementId, genericId = -1;
611 char *dot;
611 const char *dot;
612612 StyleEngine *enginePtr;
613613
614614 /*
641641 * Reallocate element table.
642642 */
643643
644 tsdPtr->elements = ckrealloc(tsdPtr->elements,
644 tsdPtr->elements = (Element *)ckrealloc(tsdPtr->elements,
645645 sizeof(Element) * tsdPtr->nbElements);
646646 InitElement(tsdPtr->elements+elementId,
647 Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId,
647 (const char *)Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId,
648648 genericId, create);
649649
650650 /*
653653
654654 engineEntryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
655655 while (engineEntryPtr != NULL) {
656 enginePtr = Tcl_GetHashValue(engineEntryPtr);
657
658 enginePtr->elements = ckrealloc(enginePtr->elements,
656 enginePtr = (StyleEngine *)Tcl_GetHashValue(engineEntryPtr);
657
658 enginePtr->elements = (StyledElement *)ckrealloc(enginePtr->elements,
659659 sizeof(StyledElement) * tsdPtr->nbElements);
660660 InitStyledElement(enginePtr->elements+elementId);
661661
685685 Tk_GetElementId(
686686 const char *name) /* Name of the element. */
687687 {
688 ThreadSpecificData *tsdPtr =
688 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
689689 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
690690 Tcl_HashEntry *entryPtr;
691691 int genericId = -1;
692 char *dot;
692 const char *dot;
693693
694694 /*
695695 * Find the element Id.
758758 StyledElement *elementPtr;
759759 Tk_ElementSpec *specPtr;
760760 int nbOptions;
761 register Tk_ElementOptionSpec *srcOptions, *dstOptions;
761 Tk_ElementOptionSpec *srcOptions, *dstOptions;
762762
763763 if (templatePtr->version != TK_STYLE_VERSION_1) {
764764 /*
785785
786786 elementPtr = ((StyleEngine *) engine)->elements+elementId;
787787
788 specPtr = ckalloc(sizeof(Tk_ElementSpec));
788 specPtr = (Tk_ElementSpec *)ckalloc(sizeof(Tk_ElementSpec));
789789 specPtr->version = templatePtr->version;
790 specPtr->name = ckalloc(strlen(templatePtr->name)+1);
790 specPtr->name = (char *)ckalloc(strlen(templatePtr->name)+1);
791791 strcpy(specPtr->name, templatePtr->name);
792792 nbOptions = 0;
793793 for (nbOptions = 0, srcOptions = templatePtr->options;
794794 srcOptions->name != NULL; nbOptions++, srcOptions++) {
795795 /* empty body */
796796 }
797 specPtr->options =
797 specPtr->options = (Tk_ElementOptionSpec *)
798798 ckalloc(sizeof(Tk_ElementOptionSpec) * (nbOptions+1));
799799 for (srcOptions = templatePtr->options, dstOptions = specPtr->options;
800800 /* End condition within loop */; srcOptions++, dstOptions++) {
803803 break;
804804 }
805805
806 dstOptions->name = ckalloc(strlen(srcOptions->name)+1);
806 dstOptions->name = (char *)ckalloc(strlen(srcOptions->name)+1);
807807 strcpy(dstOptions->name, srcOptions->name);
808808 dstOptions->type = srcOptions->type;
809809 }
843843 int elementId) /* Unique element ID */
844844 {
845845 StyledElement *elementPtr;
846 ThreadSpecificData *tsdPtr =
846 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
847847 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
848848 StyleEngine *enginePtr2;
849849
923923 */
924924
925925 widgetSpecPtr->optionsPtr =
926 ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
926 (const Tk_OptionSpec **)ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
927927 for (i = 0, elementOptionPtr = elementPtr->specPtr->options;
928928 i < nbOptions; i++, elementOptionPtr++) {
929929 widgetOptionPtr = TkGetOptionSpec(elementOptionPtr->name, optionTable);
10071007 */
10081008
10091009 i = elementPtr->nbWidgetSpecs++;
1010 elementPtr->widgetSpecs = ckrealloc(elementPtr->widgetSpecs,
1010 elementPtr->widgetSpecs = (StyledWidgetSpec *)ckrealloc(elementPtr->widgetSpecs,
10111011 sizeof(StyledWidgetSpec) * elementPtr->nbWidgetSpecs);
10121012 widgetSpecPtr = elementPtr->widgetSpecs+i;
10131013 InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable);
12281228 Tk_StyleEngine engine, /* The style engine. */
12291229 ClientData clientData) /* Private data passed as is to engine code. */
12301230 {
1231 ThreadSpecificData *tsdPtr =
1231 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
12321232 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
12331233 Tcl_HashEntry *entryPtr;
12341234 int newEntry;
12521252 * Allocate and intitialize a new style.
12531253 */
12541254
1255 stylePtr = ckalloc(sizeof(Style));
1256 InitStyle(stylePtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
1255 stylePtr = (Style *)ckalloc(sizeof(Style));
1256 InitStyle(stylePtr, (const char *)Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
12571257 (engine!=NULL ? (StyleEngine*) engine : tsdPtr->defaultEnginePtr),
12581258 clientData);
12591259 Tcl_SetHashValue(entryPtr, stylePtr);
13431343 const char *name) /* Name of the style to retrieve. NULL or empty
13441344 * means the default system style. */
13451345 {
1346 ThreadSpecificData *tsdPtr =
1346 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
13471347 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
13481348 Tcl_HashEntry *entryPtr;
1349 Style *stylePtr;
13501349
13511350 /*
13521351 * Search for a corresponding entry in the style table.
13611360 }
13621361 return NULL;
13631362 }
1364 stylePtr = Tcl_GetHashValue(entryPtr);
1365
1366 return (Tk_Style) stylePtr;
1363 return (Tk_Style)Tcl_GetHashValue(entryPtr);
13671364 }
13681365
13691366 /*
13781375
13791376 void
13801377 Tk_FreeStyle(
1381 Tk_Style style)
1378 TCL_UNUSED(Tk_Style))
13821379 {
13831380 }
13841381
14551452 */
14561453 void
14571454 Tk_FreeStyleFromObj(
1458 Tcl_Obj *objPtr)
1455 TCL_UNUSED(Tcl_Obj *))
14591456 {
14601457 }
14611458
3030 #if defined(MAC_OSX_TK)
3131 #include "tkMacOSXInt.h"
3232 #include "tkScrollbar.h"
33 #define LOG_DISPLAY TkTestLogDisplay()
33 #define LOG_DISPLAY(drawable) TkTestLogDisplay(drawable)
3434 #else
35 #define LOG_DISPLAY 1
35 #define LOG_DISPLAY(drawable) 1
3636 #endif
3737
3838 #ifdef __UNIX__
4949 #define TCL_STORAGE_CLASS DLLEXPORT
5050 EXTERN int Tktest_Init(Tcl_Interp *interp);
5151 /*
52 * The following data structure represents the master for a test image:
53 */
54
55 typedef struct TImageMaster {
56 Tk_ImageMaster master; /* Tk's token for image master. */
52 * The following data structure represents the model for a test image:
53 */
54
55 typedef struct TImageModel {
56 Tk_ImageModel model; /* Tk's token for image model. */
5757 Tcl_Interp *interp; /* Interpreter for application. */
5858 int width, height; /* Dimensions of image. */
5959 char *imageName; /* Name of image (malloc-ed). */
6060 char *varName; /* Name of variable in which to log events for
6161 * image (malloc-ed). */
62 } TImageMaster;
62 } TImageModel;
6363
6464 /*
6565 * The following data structure represents a particular use of a particular
6767 */
6868
6969 typedef struct TImageInstance {
70 TImageMaster *masterPtr; /* Pointer to master for image. */
70 TImageModel *modelPtr; /* Pointer to model for image. */
7171 XColor *fg; /* Foreground color for drawing in image. */
7272 GC gc; /* Graphics context for drawing in image. */
73 Bool displayFailed; /* macOS display attempted out of drawRect. */
74 char buffer[200 + TCL_INTEGER_SPACE * 6]; /* message to log on display. */
7375 } TImageInstance;
7476
7577 /*
7880
7981 static int ImageCreate(Tcl_Interp *interp,
8082 const char *name, int argc, Tcl_Obj *const objv[],
81 const Tk_ImageType *typePtr, Tk_ImageMaster master,
83 const Tk_ImageType *typePtr, Tk_ImageModel model,
8284 ClientData *clientDataPtr);
8385 static ClientData ImageGet(Tk_Window tkwin, ClientData clientData);
8486 static void ImageDisplay(ClientData clientData,
241243 */
242244
243245 if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
244 return TCL_ERROR;
246 return TCL_ERROR;
245247 }
246248
247249 Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL);
321323 *----------------------------------------------------------------------
322324 */
323325
324 /* ARGSUSED */
325326 static int
326327 TestbitmapObjCmd(
327 ClientData clientData, /* Main window for application. */
328 TCL_UNUSED(void *), /* Main window for application. */
328329 Tcl_Interp *interp, /* Current interpreter. */
329330 int objc, /* Number of arguments. */
330331 Tcl_Obj *const objv[]) /* Argument objects. */
356357 *----------------------------------------------------------------------
357358 */
358359
359 /* ARGSUSED */
360360 static int
361361 TestborderObjCmd(
362 ClientData clientData, /* Main window for application. */
362 TCL_UNUSED(ClientData), /* Main window for application. */
363363 Tcl_Interp *interp, /* Current interpreter. */
364364 int objc, /* Number of arguments. */
365365 Tcl_Obj *const objv[]) /* Argument objects. */
391391 *----------------------------------------------------------------------
392392 */
393393
394 /* ARGSUSED */
395394 static int
396395 TestcolorObjCmd(
397 ClientData clientData, /* Main window for application. */
396 TCL_UNUSED(void *), /* Main window for application. */
398397 Tcl_Interp *interp, /* Current interpreter. */
399398 int objc, /* Number of arguments. */
400399 Tcl_Obj *const objv[]) /* Argument objects. */
425424 *----------------------------------------------------------------------
426425 */
427426
428 /* ARGSUSED */
429427 static int
430428 TestcursorObjCmd(
431 ClientData clientData, /* Main window for application. */
429 TCL_UNUSED(void *), /* Main window for application. */
432430 Tcl_Interp *interp, /* Current interpreter. */
433431 int objc, /* Number of arguments. */
434432 Tcl_Obj *const objv[]) /* Argument objects. */
454452 * A standard Tcl result.
455453 *
456454 * Side effects:
457 * All the intepreters created by previous calls to "testnewapp" get
455 * All the interpreters created by previous calls to "testnewapp" get
458456 * deleted.
459457 *
460458 *----------------------------------------------------------------------
461459 */
462460
463 /* ARGSUSED */
464461 static int
465462 TestdeleteappsObjCmd(
466 ClientData clientData, /* Main window for application. */
467 Tcl_Interp *interp, /* Current interpreter. */
468 int objc, /* Number of arguments. */
469 Tcl_Obj *const objv[]) /* Argument strings. */
463 TCL_UNUSED(void *), /* Main window for application. */
464 TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */
465 TCL_UNUSED(int), /* Number of arguments. */
466 TCL_UNUSED(Tcl_Obj *const *)) /* Argument strings. */
470467 {
471468 NewApp *nextPtr;
472469
497494 *----------------------------------------------------------------------
498495 */
499496
500 /* ARGSUSED */
501497 static int
502498 TestobjconfigObjCmd(
503499 ClientData clientData, /* Main window for application. */
636632 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
637633 };
638634 Tk_OptionTable optionTable;
639 Tk_Window tkwin;
640635
641636 optionTable = Tk_CreateOptionTable(interp, typesSpecs);
642637 tables[index] = optionTable;
647642 }
648643 Tk_SetClass(tkwin, "Test");
649644
650 recordPtr = ckalloc(sizeof(TypesRecord));
645 recordPtr = (TypesRecord *)ckalloc(sizeof(TypesRecord));
651646 recordPtr->header.interp = interp;
652647 recordPtr->header.optionTable = optionTable;
653648 recordPtr->header.tkwin = tkwin;
692687
693688 case CHAIN1: {
694689 ExtensionWidgetRecord *recordPtr;
695 Tk_Window tkwin;
696690 Tk_OptionTable optionTable;
697691
698692 tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
704698 optionTable = Tk_CreateOptionTable(interp, baseSpecs);
705699 tables[index] = optionTable;
706700
707 recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
701 recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
708702 recordPtr->header.interp = interp;
709703 recordPtr->header.optionTable = optionTable;
710704 recordPtr->header.tkwin = tkwin;
745739 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0,
746740 (ClientData) baseSpecs, 0}
747741 };
748 Tk_Window tkwin;
749742 Tk_OptionTable optionTable;
750743
751744 tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
757750 optionTable = Tk_CreateOptionTable(interp, extensionSpecs);
758751 tables[index] = optionTable;
759752
760 recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
753 recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
761754 recordPtr->header.interp = interp;
762755 recordPtr->header.optionTable = optionTable;
763756 recordPtr->header.tkwin = tkwin;
914907 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
915908 };
916909 Tk_OptionTable optionTable;
917 Tk_Window tkwin;
918910
919911 optionTable = Tk_CreateOptionTable(interp, internalSpecs);
920912 tables[index] = optionTable;
10591051 }
10601052
10611053 case TWO_WINDOWS: {
1062 typedef struct SlaveRecord {
1054 typedef struct ContentRecord {
10631055 TrivialCommandHeader header;
10641056 Tcl_Obj *windowPtr;
1065 } SlaveRecord;
1066 SlaveRecord *recordPtr;
1067 static const Tk_OptionSpec slaveSpecs[] = {
1057 } ContentRecord;
1058 ContentRecord *recordPtr;
1059 static const Tk_OptionSpec contentSpecs[] = {
10681060 {TK_OPTION_WINDOW, "-window", "window", "Window", ".bar",
1069 Tk_Offset(SlaveRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
1061 Tk_Offset(ContentRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
10701062 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
10711063 };
1072 Tk_Window tkwin = Tk_CreateWindowFromPath(interp,
1064 tkwin = Tk_CreateWindowFromPath(interp,
10731065 (Tk_Window) clientData, Tcl_GetString(objv[2]), NULL);
10741066
10751067 if (tkwin == NULL) {
10771069 }
10781070 Tk_SetClass(tkwin, "Test");
10791071
1080 recordPtr = ckalloc(sizeof(SlaveRecord));
1072 recordPtr = (ContentRecord *)ckalloc(sizeof(ContentRecord));
10811073 recordPtr->header.interp = interp;
10821074 recordPtr->header.optionTable = Tk_CreateOptionTable(interp,
1083 slaveSpecs);
1075 contentSpecs);
10841076 tables[index] = recordPtr->header.optionTable;
10851077 recordPtr->header.tkwin = tkwin;
10861078 recordPtr->windowPtr = NULL;
11301122 *----------------------------------------------------------------------
11311123 */
11321124
1133 /* ARGSUSED */
11341125 static int
11351126 TrivialConfigObjCmd(
11361127 ClientData clientData, /* Main window for application. */
12421233 TrivialCmdDeletedProc(
12431234 ClientData clientData) /* Pointer to widget record for widget. */
12441235 {
1245 TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
1236 TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
12461237 Tk_Window tkwin = headerPtr->tkwin;
12471238
12481239 if (tkwin != NULL) {
12541245 * here.
12551246 */
12561247
1257 Tk_FreeConfigOptions((char *) clientData,
1258 headerPtr->optionTable, (Tk_Window) NULL);
1248 Tk_FreeConfigOptions((char *)clientData,
1249 headerPtr->optionTable, NULL);
12591250 Tcl_EventuallyFree(clientData, TCL_DYNAMIC);
12601251 }
12611252 }
12811272 ClientData clientData, /* Information about window. */
12821273 XEvent *eventPtr) /* Information about event. */
12831274 {
1284 TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
1275 TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
12851276
12861277 if (eventPtr->type == DestroyNotify) {
12871278 if (headerPtr->tkwin != NULL) {
1288 Tk_FreeConfigOptions((char *) clientData,
1279 Tk_FreeConfigOptions((char *)clientData,
12891280 headerPtr->optionTable, headerPtr->tkwin);
12901281 headerPtr->optionTable = NULL;
12911282 headerPtr->tkwin = NULL;
13131304 *----------------------------------------------------------------------
13141305 */
13151306
1316 /* ARGSUSED */
13171307 static int
13181308 TestfontObjCmd(
13191309 ClientData clientData, /* Main window for application. */
13271317 Tk_Window tkwin;
13281318 Tk_Font tkfont;
13291319
1330 tkwin = (Tk_Window) clientData;
1320 tkwin = (Tk_Window)clientData;
13311321
13321322 if (objc < 3) {
13331323 Tcl_WrongNumArgs(interp, 1, objv, "option fontName");
13731363 *----------------------------------------------------------------------
13741364 */
13751365
1376 /* ARGSUSED */
13771366 static int
13781367 ImageCreate(
13791368 Tcl_Interp *interp, /* Interpreter for application containing
13821371 int objc, /* Number of arguments. */
13831372 Tcl_Obj *const objv[], /* Argument strings for options (doesn't
13841373 * include image name or type). */
1385 const Tk_ImageType *typePtr, /* Pointer to our type record (not used). */
1386 Tk_ImageMaster master, /* Token for image, to be used by us in later
1374 TCL_UNUSED(const Tk_ImageType *), /* Pointer to our type record (not used). */
1375 Tk_ImageModel model, /* Token for image, to be used by us in later
13871376 * callbacks. */
13881377 ClientData *clientDataPtr) /* Store manager's token for image here; it
13891378 * will be returned in later callbacks. */
13901379 {
1391 TImageMaster *timPtr;
1380 TImageModel *timPtr;
13921381 const char *varName;
13931382 int i;
13941383
14071396 varName = Tcl_GetString(objv[i+1]);
14081397 }
14091398
1410 timPtr = ckalloc(sizeof(TImageMaster));
1411 timPtr->master = master;
1399 timPtr = (TImageModel *)ckalloc(sizeof(TImageModel));
1400 timPtr->model = model;
14121401 timPtr->interp = interp;
14131402 timPtr->width = 30;
14141403 timPtr->height = 15;
1415 timPtr->imageName = ckalloc(strlen(name) + 1);
1404 timPtr->imageName = (char *)ckalloc(strlen(name) + 1);
14161405 strcpy(timPtr->imageName, name);
1417 timPtr->varName = ckalloc(strlen(varName) + 1);
1406 timPtr->varName = (char *)ckalloc(strlen(varName) + 1);
14181407 strcpy(timPtr->varName, varName);
14191408 Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL);
14201409 *clientDataPtr = timPtr;
1421 Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15);
1410 Tk_ImageChanged(model, 0, 0, 30, 15, 30, 15);
14221411 return TCL_OK;
14231412 }
14241413
14391428 *----------------------------------------------------------------------
14401429 */
14411430
1442 /* ARGSUSED */
14431431 static int
14441432 ImageObjCmd(
14451433 ClientData clientData, /* Main window for application. */
14471435 int objc, /* Number of arguments. */
14481436 Tcl_Obj *const objv[]) /* Argument strings. */
14491437 {
1450 TImageMaster *timPtr = (TImageMaster *) clientData;
1438 TImageModel *timPtr = (TImageModel *)clientData;
14511439 int x, y, width, height;
14521440
14531441 if (objc < 2) {
14681456 || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) {
14691457 return TCL_ERROR;
14701458 }
1471 Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width,
1459 Tk_ImageChanged(timPtr->model, x, y, width, height, timPtr->width,
14721460 timPtr->height);
14731461 } else {
14741462 Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]),
15001488 ImageGet(
15011489 Tk_Window tkwin, /* Token for window in which image will be
15021490 * used. */
1503 ClientData clientData) /* Pointer to TImageMaster for image. */
1504 {
1505 TImageMaster *timPtr = (TImageMaster *) clientData;
1491 ClientData clientData) /* Pointer to TImageModel for image. */
1492 {
1493 TImageModel *timPtr = (TImageModel *)clientData;
15061494 TImageInstance *instPtr;
15071495 char buffer[100];
15081496 XGCValues gcValues;
15111499 Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer,
15121500 TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
15131501
1514 instPtr = ckalloc(sizeof(TImageInstance));
1515 instPtr->masterPtr = timPtr;
1502 instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance));
1503 instPtr->modelPtr = timPtr;
15161504 instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
15171505 gcValues.foreground = instPtr->fg->pixel;
15181506 instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues);
1507 instPtr->displayFailed = False;
15191508 return instPtr;
15201509 }
15211510
15491538 /* Coordinates in drawable corresponding to
15501539 * imageX and imageY. */
15511540 {
1552 TImageInstance *instPtr = (TImageInstance *) clientData;
1553 char buffer[200 + TCL_INTEGER_SPACE * 6];
1541 TImageInstance *instPtr = (TImageInstance *)clientData;
15541542
15551543 /*
15561544 * The purpose of the test image type is to track the calls to an image
1557 * display proc and record the parameters passed in each call. On macOS
1558 * a display proc must be run inside of the drawRect method of an NSView
1559 * in order for the graphics operations to have any effect. To deal with
1545 * display proc and record the parameters passed in each call. On macOS a
1546 * display proc must be run inside of the drawRect method of an NSView in
1547 * order for the graphics operations to have any effect. To deal with
15601548 * this, whenever a display proc is called outside of any drawRect method
1561 * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES].
1562 * This will trigger a later call to the view's drawRect method which will
1563 * run the display proc a second time.
1549 * it schedules a redraw of the NSView.
15641550 *
1565 * This complicates testing, since it can result in more calls to the display
1566 * proc than are expected by the test. It can also result in an inconsistent
1567 * number of calls unless the test waits until the call to drawRect actually
1568 * occurs before validating its results.
1569 *
1570 * In an attempt to work around this, this display proc only logs those
1571 * calls which occur within a drawRect method. This means that tests must
1572 * be written so as to ensure that the drawRect method is run before
1573 * results are validated. In practice it usually suffices to run update
1574 * idletasks (to run the display proc the first time) followed by update
1575 * (to run the display proc in drawRect).
1576 *
1577 * This also has the consequence that the image changed command will log
1578 * different results on Aqua than on other systems, because when the image
1579 * is redisplayed in the drawRect method the entire image will be drawn,
1580 * not just the changed portion. Tests must account for this.
1551 * In an attempt to work around this, each image instance maintains it own
1552 * copy of the log message which gets written on the first call to the
1553 * display proc. This usually means that the message created on macOS is
1554 * the same as that created on other platforms. However it is possible
1555 * for the messages to differ for other reasons, namely differences in
1556 * how damage regions are computed.
15811557 */
15821558
1583 if (LOG_DISPLAY) {
1584 sprintf(buffer, "%s display %d %d %d %d",
1585 instPtr->masterPtr->imageName, imageX, imageY, width, height);
1586 Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName,
1587 NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
1588 }
1589 if (width > (instPtr->masterPtr->width - imageX)) {
1590 width = instPtr->masterPtr->width - imageX;
1591 }
1592 if (height > (instPtr->masterPtr->height - imageY)) {
1593 height = instPtr->masterPtr->height - imageY;
1559 if (LOG_DISPLAY(drawable)) {
1560 if (instPtr->displayFailed == False) {
1561
1562 /*
1563 * Drawing is possible on the first call to DisplayImage.
1564 * Log the message.
1565 */
1566
1567 sprintf(instPtr->buffer, "%s display %d %d %d %d",
1568 instPtr->modelPtr->imageName, imageX, imageY, width, height);
1569 }
1570 Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName,
1571 NULL, instPtr->buffer,
1572 TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
1573 instPtr->displayFailed = False;
1574 } else {
1575
1576 /*
1577 * Drawing is not possible on the first call to DisplayImage.
1578 * Save the message, but do not log it until the actual display.
1579 */
1580
1581 if (instPtr->displayFailed == False) {
1582 sprintf(instPtr->buffer, "%s display %d %d %d %d",
1583 instPtr->modelPtr->imageName, imageX, imageY, width, height);
1584 }
1585 instPtr->displayFailed = True;
1586 }
1587 if (width > (instPtr->modelPtr->width - imageX)) {
1588 width = instPtr->modelPtr->width - imageX;
1589 }
1590 if (height > (instPtr->modelPtr->height - imageY)) {
1591 height = instPtr->modelPtr->height - imageY;
15941592 }
15951593
15961594 XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY,
16241622 ClientData clientData, /* Pointer to TImageInstance for instance. */
16251623 Display *display) /* Display where image was to be drawn. */
16261624 {
1627 TImageInstance *instPtr = (TImageInstance *) clientData;
1625 TImageInstance *instPtr = (TImageInstance *)clientData;
16281626 char buffer[200];
16291627
1630 sprintf(buffer, "%s free", instPtr->masterPtr->imageName);
1631 Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL,
1628 sprintf(buffer, "%s free", instPtr->modelPtr->imageName);
1629 Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL,
16321630 buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
16331631 Tk_FreeColor(instPtr->fg);
16341632 Tk_FreeGC(display, instPtr->gc);
16541652
16551653 static void
16561654 ImageDelete(
1657 ClientData clientData) /* Pointer to TImageMaster for image. When
1655 ClientData clientData) /* Pointer to TImageModel for image. When
16581656 * this function is called, no more instances
16591657 * exist. */
16601658 {
1661 TImageMaster *timPtr = (TImageMaster *) clientData;
1659 TImageModel *timPtr = (TImageModel *)clientData;
16621660 char buffer[100];
16631661
16641662 sprintf(buffer, "%s delete", timPtr->imageName);
16891687 *----------------------------------------------------------------------
16901688 */
16911689
1692 /* ARGSUSED */
16931690 static int
16941691 TestmakeexistObjCmd(
16951692 ClientData clientData, /* Main window for application. */
16971694 int objc, /* Number of arguments. */
16981695 Tcl_Obj *const objv[]) /* Argument strings. */
16991696 {
1700 Tk_Window mainWin = (Tk_Window) clientData;
1697 Tk_Window mainWin = (Tk_Window)clientData;
17011698 int i;
17021699 Tk_Window tkwin;
17031700
17301727 *----------------------------------------------------------------------
17311728 */
17321729
1733 /* ARGSUSED */
17341730 #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
17351731 static int
17361732 TestmenubarObjCmd(
17401736 Tcl_Obj *const objv[]) /* Argument strings. */
17411737 {
17421738 #ifdef __UNIX__
1743 Tk_Window mainWin = (Tk_Window) clientData;
1739 Tk_Window mainWin = (Tk_Window)clientData;
17441740 Tk_Window tkwin, menubar;
17451741
17461742 if (objc < 2) {
18001796 #if defined(_WIN32)
18011797 static int
18021798 TestmetricsObjCmd(
1803 ClientData clientData, /* Main window for application. */
1799 TCL_UNUSED(void *), /* Main window for application. */
18041800 Tcl_Interp *interp, /* Current interpreter. */
18051801 int objc, /* Number of arguments. */
18061802 Tcl_Obj *const objv[]) /* Argument strings. */
18451841 *----------------------------------------------------------------------
18461842 */
18471843
1848 /* ARGSUSED */
18491844 static int
18501845 TestpropObjCmd(
18511846 ClientData clientData, /* Main window for application. */
18531848 int objc, /* Number of arguments. */
18541849 Tcl_Obj *const objv[]) /* Argument strings. */
18551850 {
1856 Tk_Window mainWin = (Tk_Window) clientData;
1851 Tk_Window mainWin = (Tk_Window)clientData;
18571852 int result, actualFormat;
18581853 unsigned long bytesAfter, length, value;
18591854 Atom actualType, propName;
19241919 *----------------------------------------------------------------------
19251920 */
19261921
1927 /* ARGSUSED */
19281922 static int
19291923 TestwrapperObjCmd(
19301924 ClientData clientData, /* Main window for application. */
19401934 return TCL_ERROR;
19411935 }
19421936
1943 tkwin = (Tk_Window) clientData;
1937 tkwin = (Tk_Window)clientData;
19441938 winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin);
19451939 if (winPtr == NULL) {
19461940 return TCL_ERROR;
19771971 * CustomOptionSet Sets option value to new setting.
19781972 * CustomOptionGet Creates a new Tcl_Obj.
19791973 * CustomOptionRestore Resets option value to original value.
1980 * CustomOptionFree Free storage for internal rep of
1981 * option.
1974 * CustomOptionFree Free storage for internal rep of option.
19821975 *
19831976 *----------------------------------------------------------------------
19841977 */
19851978
19861979 static int
19871980 CustomOptionSet(
1988 ClientData clientData,
1981 TCL_UNUSED(void *),
19891982 Tcl_Interp *interp,
1990 Tk_Window tkwin,
1983 TCL_UNUSED(Tk_Window),
19911984 Tcl_Obj **value,
19921985 char *recordPtr,
19931986 int internalOffset,
20322025 if (internalPtr != NULL) {
20332026 if (*value != NULL) {
20342027 string = Tcl_GetString(*value);
2035 newStr = ckalloc((*value)->length + 1);
2028 newStr = (char *)ckalloc((*value)->length + 1);
20362029 strcpy(newStr, string);
20372030 } else {
20382031 newStr = NULL;
20462039
20472040 static Tcl_Obj *
20482041 CustomOptionGet(
2049 ClientData clientData,
2050 Tk_Window tkwin,
2042 TCL_UNUSED(void *),
2043 TCL_UNUSED(Tk_Window),
20512044 char *recordPtr,
20522045 int internalOffset)
20532046 {
1313 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1414 */
1515
16 #include "default.h"
1716 #include "tkInt.h"
1817 #include "tkUndo.h"
18 #include "default.h"
1919
2020 #if defined(MAC_OSX_TK)
2121 #define Style TkStyle
460460 int objc, /* Number of arguments. */
461461 Tcl_Obj *const objv[]) /* Argument objects. */
462462 {
463 Tk_Window tkwin = clientData;
463 Tk_Window tkwin = (Tk_Window)clientData;
464464
465465 if (objc < 2) {
466466 Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
501501 int objc, /* Number of arguments. */
502502 Tcl_Obj *const objv[]) /* Argument objects. */
503503 {
504 register TkText *textPtr;
504 TkText *textPtr;
505505 Tk_OptionTable optionTable;
506506 TkTextIndex startIndex;
507507 Tk_Window newWin;
522522 * and 'insert', 'current' mark pointers are all NULL to start.
523523 */
524524
525 textPtr = ckalloc(sizeof(TkText));
525 textPtr = (TkText *)ckalloc(sizeof(TkText));
526526 memset(textPtr, 0, sizeof(TkText));
527527
528528 textPtr->tkwin = newWin;
533533 textPtr, TextCmdDeletedProc);
534534
535535 if (sharedPtr == NULL) {
536 sharedPtr = ckalloc(sizeof(TkSharedText));
536 sharedPtr = (TkSharedText *)ckalloc(sizeof(TkSharedText));
537537 memset(sharedPtr, 0, sizeof(TkSharedText));
538538
539539 sharedPtr->refCount = 0;
631631 */
632632
633633 textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL);
634 textPtr->selTagPtr->reliefString =
634 textPtr->selTagPtr->reliefString = (char *)
635635 ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF));
636636 strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF);
637637 Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief);
698698 int objc, /* Number of arguments. */
699699 Tcl_Obj *const objv[]) /* Argument objects. */
700700 {
701 register TkText *textPtr = clientData;
701 TkText *textPtr = (TkText *)clientData;
702702 int result = TCL_OK;
703 int index;
703 int idx;
704704
705705 static const char *const optionStrings[] = {
706706 "bbox", "cget", "compare", "configure", "count", "debug", "delete",
723723 }
724724
725725 if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
726 sizeof(char *), "option", 0, &index) != TCL_OK) {
726 sizeof(char *), "option", 0, &idx) != TCL_OK) {
727727 return TCL_ERROR;
728728 }
729729 textPtr->refCount++;
730730
731 switch ((enum options) index) {
731 switch ((enum options) idx) {
732732 case TEXT_BBOX: {
733733 int x, y, width, height;
734734 const TkTextIndex *indexPtr;
863863
864864 for (i = 2; i < objc-2; i++) {
865865 int value;
866 size_t length;
867 const char *option = Tcl_GetString(objv[i]);
866 int length;
867 const char *option = Tcl_GetStringFromObj(objv[i], &length);
868868 char c;
869869
870 length = objv[i]->length;
871870 if (length < 2 || option[0] != '-') {
872871 goto badOption;
873872 }
11251124
11261125 objc -= 2;
11271126 objv += 2;
1128 indices = ckalloc((objc + 1) * sizeof(TkTextIndex));
1127 indices = (TkTextIndex *)ckalloc((objc + 1) * sizeof(TkTextIndex));
11291128
11301129 /*
11311130 * First pass verifies that all indices are valid.
11531152 COUNT_INDICES);
11541153 objc++;
11551154 }
1156 useIdx = ckalloc(objc);
1157 memset(useIdx, 0, (size_t) objc);
1155 useIdx = (char *)ckalloc(objc);
1156 memset(useIdx, 0, objc);
11581157
11591158 /*
11601159 * Do a decreasing order sort so that we delete the end ranges
12591258 Tcl_Obj *objPtr = NULL;
12601259 int i, found = 0, visible = 0;
12611260 const char *name;
1262 size_t length;
1261 int length;
12631262
12641263 if (objc < 3) {
12651264 Tcl_WrongNumArgs(interp, 2, objv,
12751274
12761275 i = 2;
12771276 if (objc > 3) {
1278 name = Tcl_GetString(objv[i]);
1279 length = objv[i]->length;
1277 name = Tcl_GetStringFromObj(objv[i], &length);
12801278 if (length > 1 && name[0] == '-') {
12811279 if (strncmp("-displaychars", name, length) == 0) {
12821280 i++;
12831281 visible = 1;
1284 name = Tcl_GetString(objv[i]);
1285 length = objv[i]->length;
1282 name = Tcl_GetStringFromObj(objv[i], &length);
12861283 }
12871284 if ((i < objc-1) && (length == 2) && !strcmp("--", name)) {
12881285 i++;
16091606 int objc, /* Number of arguments. */
16101607 Tcl_Obj *const objv[]) /* Argument objects. */
16111608 {
1612 register TkSharedText *sharedPtr = clientData;
1609 TkSharedText *sharedPtr = (TkSharedText *)clientData;
16131610 int result = TCL_OK;
16141611 int index;
16151612
19791976 for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search);
19801977 hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
19811978 TkTextEmbWindowClient *loop;
1982 TkTextSegment *ewPtr = Tcl_GetHashValue(hPtr);
1979 TkTextSegment *ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
19831980
19841981 loop = ewPtr->body.ew.clients;
19851982 if (loop->textPtr == textPtr) {
20112008
20122009 for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
20132010 hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
2014 tagPtr = Tcl_GetHashValue(hPtr);
2011 tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
20152012
20162013 /*
20172014 * No need to use 'TkTextDeleteTag' since we've already removed
20772074 static int
20782075 ConfigureText(
20792076 Tcl_Interp *interp, /* Used for error reporting. */
2080 register TkText *textPtr, /* Information about widget; may or may not
2077 TkText *textPtr, /* Information about widget; may or may not
20812078 * already have values for some fields. */
20822079 int objc, /* Number of arguments. */
20832080 Tcl_Obj *const objv[]) /* Argument objects. */
23802377 TextWorldChangedCallback(
23812378 ClientData instanceData) /* Information about widget. */
23822379 {
2383 TkText *textPtr = instanceData;
2380 TkText *textPtr = (TkText *)instanceData;
23842381
23852382 TextWorldChanged(textPtr, TK_TEXT_LINE_GEOMETRY);
23862383 }
24692466 static void
24702467 TextEventProc(
24712468 ClientData clientData, /* Information about window. */
2472 register XEvent *eventPtr) /* Information about event. */
2469 XEvent *eventPtr) /* Information about event. */
24732470 {
2474 register TkText *textPtr = clientData;
2471 TkText *textPtr = (TkText *)clientData;
24752472 TkTextIndex index, index2;
24762473
24772474 if (eventPtr->type == Expose) {
25802577 TextCmdDeletedProc(
25812578 ClientData clientData) /* Pointer to widget record for widget. */
25822579 {
2583 TkText *textPtr = clientData;
2580 TkText *textPtr = (TkText *)clientData;
25842581 Tk_Window tkwin = textPtr->tkwin;
25852582
25862583 /*
26332630 int viewUpdate) /* Update the view if set. */
26342631 {
26352632 int lineIndex;
2636 size_t length;
2633 int length;
26372634 TkText *tPtr;
26382635 int *lineAndByteIndex;
26392636 int resetViewCount;
26402637 int pixels[2*PIXEL_CLIENTS];
2641 const char *string = Tcl_GetString(stringPtr);
2642
2643 length = stringPtr->length;
2638 const char *string = Tcl_GetStringFromObj(stringPtr, &length);
2639
26442640 if (sharedTextPtr == NULL) {
26452641 sharedTextPtr = textPtr->sharedTextPtr;
26462642 }
26662662
26672663 resetViewCount = 0;
26682664 if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
2669 lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
2665 lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
26702666 } else {
26712667 lineAndByteIndex = pixels;
26722668 }
29152911 Tcl_Obj *objPtr) /* Arguments of a command to be handled by the
29162912 * shared text data structure. */
29172913 {
2918 TkSharedText *sharedPtr = clientData;
2914 TkSharedText *sharedPtr = (TkSharedText *)clientData;
29192915 int res, objc;
29202916 Tcl_Obj **objv;
29212917 TkText *textPtr;
31273123 line2 = TkBTreeLinesTo(textPtr, index2.linePtr);
31283124 if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) {
31293125 TkTextTag **arrayPtr;
3130 int arraySize, i;
3126 int arraySize;
31313127 TkTextIndex oldIndex2;
31323128
31333129 oldIndex2 = index2;
31543150
31553151 for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
31563152 hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
3157 TkTextTag *tagPtr = Tcl_GetHashValue(hPtr);
3158
3159 TkBTreeTag(&index1, &index2, tagPtr, 0);
3153 TkBTreeTag(&index1, &index2, (TkTextTag *)Tcl_GetHashValue(hPtr), 0);
31603154 }
31613155
31623156 /*
31903184
31913185 resetViewCount = 0;
31923186 if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
3193 lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
3187 lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
31943188 } else {
31953189 lineAndByteIndex = pixels;
31963190 }
33793373 * not including terminating NULL
33803374 * character. */
33813375 {
3382 register TkText *textPtr = clientData;
3376 TkText *textPtr = (TkText *)clientData;
33833377 TkTextIndex eof;
33843378 int count, chunkSize, offsetInSeg;
33853379 TkTextSearch search;
34633457 if ((segPtr->typePtr == &tkTextCharType)
34643458 && !TkTextIsElided(textPtr, &textPtr->selIndex, NULL)) {
34653459 memcpy(buffer, segPtr->body.chars + offsetInSeg,
3466 (size_t) chunkSize);
3460 chunkSize);
34673461 buffer += chunkSize;
34683462 maxBytes -= chunkSize;
34693463 count += chunkSize;
35103504 TkTextLostSelection(
35113505 ClientData clientData) /* Information about text widget. */
35123506 {
3513 register TkText *textPtr = clientData;
3507 TkText *textPtr = (TkText *)clientData;
35143508
35153509 if (TkpAlwaysShowSelection(textPtr->tkwin)) {
35163510 TkTextIndex start, end;
35953589 TextBlinkProc(
35963590 ClientData clientData) /* Pointer to record describing text. */
35973591 {
3598 register TkText *textPtr = clientData;
3592 TkText *textPtr = (TkText *)clientData;
35993593 TkTextIndex index;
36003594 int x, y, w, h, charWidth;
36013595
39753969 {
39763970 const TkTextIndex *indexPtr;
39773971 int line;
3978 TkText *textPtr = searchSpecPtr->clientData;
3972 TkText *textPtr = (TkText *)searchSpecPtr->clientData;
39793973
39803974 indexPtr = TkTextGetIndexFromObj(interp, textPtr, objPtr);
39813975 if (indexPtr == NULL) {
40404034 TkTextSegment *segPtr;
40414035 TkTextIndex curIndex;
40424036 int index, leftToScan;
4043 TkText *textPtr = searchSpecPtr->clientData;
4037 TkText *textPtr = (TkText *)searchSpecPtr->clientData;
40444038
40454039 index = 0;
40464040 curIndex.tree = textPtr->sharedTextPtr->tree;
41104104 TkTextLine *linePtr, *thisLinePtr;
41114105 TkTextIndex curIndex;
41124106 TkTextSegment *segPtr;
4113 TkText *textPtr = searchSpecPtr->clientData;
4107 TkText *textPtr = (TkText *)searchSpecPtr->clientData;
41144108 int nothingYet = 1;
41154109
41164110 /*
42324226 TkTextIndex curIndex, foundIndex;
42334227 TkTextSegment *segPtr;
42344228 TkTextLine *linePtr;
4235 TkText *textPtr = searchSpecPtr->clientData;
4229 TkText *textPtr = (TkText *)searchSpecPtr->clientData;
42364230
42374231 if (lineNum == searchSpecPtr->stopLine) {
42384232 /*
42834277 * reached the end of the match or we have reached the end of the line.
42844278 */
42854279
4286 linePtr = clientData;
4280 linePtr = (TkTextLine *)clientData;
42874281 if (linePtr == NULL) {
42884282 linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr,
42894283 lineNum);
44934487 * Parse the elements of the list one at a time to fill in the array.
44944488 */
44954489
4496 tabArrayPtr = ckalloc(sizeof(TkTextTabArray)
4497 + (count - 1) * sizeof(TkTextTab));
4490 tabArrayPtr = (TkTextTabArray *)ckalloc(Tk_Offset(TkTextTabArray, tabs)
4491 + count * sizeof(TkTextTab));
44984492 tabArrayPtr->numTabs = 0;
44994493 prevStop = 0.0;
45004494 lastStop = 0.0;
46204614
46214615 static int
46224616 TextDumpCmd(
4623 register TkText *textPtr, /* Information about text widget. */
4617 TkText *textPtr, /* Information about text widget. */
46244618 Tcl_Interp *interp, /* Current interpreter. */
46254619 int objc, /* Number of arguments. */
46264620 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
47074701 if (objc == arg) {
47084702 TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES);
47094703 } else {
4710 size_t length;
4704 int length;
47114705 const char *str;
47124706
47134707 if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
47144708 return TCL_ERROR;
47154709 }
4716 str = Tcl_GetString(objv[arg]);
4717 length = objv[arg]->length;
4710 str = Tcl_GetStringFromObj(objv[arg], &length);
47184711 if (strncmp(str, "end", length) == 0) {
47194712 atEnd = 1;
47204713 }
48584851 */
48594852
48604853 int length = last - first;
4861 char *range = ckalloc(length + 1);
4854 char *range = (char *)ckalloc(length + 1);
48624855
48634856 memcpy(range, segPtr->body.chars + first, length);
48644857 range[length] = '\0';
48894882 name = NULL;
48904883 lineChanged = 0;
48914884 } else {
4892 name = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
4885 name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
48934886 markPtr->hPtr);
48944887 }
48954888 if (name != NULL) {
50155008 const char *value, /* Segment value. */
50165009 Tcl_Obj *command, /* Script callback. */
50175010 const TkTextIndex *index, /* index with line/byte position info. */
5018 int what) /* Look for TK_DUMP_INDEX bit. */
5011 TCL_UNUSED(int)) /* Look for TK_DUMP_INDEX bit. */
50195012 {
50205013 char buffer[TK_POS_CHARS];
50215014 Tcl_Obj *values[3], *tuple;
50385031 Tcl_DStringAppend(&buf, Tcl_GetString(command), -1);
50395032 Tcl_DStringAppend(&buf, " ", -1);
50405033 Tcl_DStringAppend(&buf, Tcl_GetString(tuple), -1);
5041 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
5034 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
50425035 Tcl_DStringFree(&buf);
50435036 if (code != TCL_OK) {
50445037 Tcl_AddErrorInfo(interp,
53195312 * Tcl_AppendToObj more carefully (e.g. if we know we are going to be
53205313 * appending several thousand lines, we could attempt to pre-allocate a
53215314 * larger space).
5322 *
5323 * Also the result is built up as a utf-8 string, but, if we knew we
5324 * wanted it as Unicode, we could potentially save a huge conversion by
5325 * building it up as Unicode directly. This could be as simple as
5326 * replacing Tcl_NewObj by Tcl_NewUnicodeObj.
53275315 *
53285316 * Results:
53295317 * Tcl_Obj of string type containing the specified text. If the
55225510 TkTextRunAfterSyncCmd(
55235511 ClientData clientData) /* Information about text widget. */
55245512 {
5525 register TkText *textPtr = (TkText *) clientData;
5513 TkText *textPtr = (TkText *)clientData;
55265514 int code;
55275515
55285516 if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
55965584
55975585 if (toPtr != NULL) {
55985586 const TkTextIndex *indexToPtr, *indexFromPtr;
5599 TkText *textPtr = searchSpecPtr->clientData;
5587 TkText *textPtr = (TkText *)searchSpecPtr->clientData;
56005588
56015589 indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr);
56025590 if (indexToPtr == NULL) {
56775665 * they are Unicode char offsets.
56785666 */
56795667
5680 int firstOffset, lastOffset, matchOffset, matchLength;
5668 int firstOffset, lastOffset;
5669 int matchOffset, matchLength;
56815670 int passes;
56825671 int lineNum = searchSpecPtr->startLine;
56835672 int code = TCL_OK;
57505739 * it has dual purpose.
57515740 */
57525741
5753 pattern = Tcl_GetString(patObj);
5754 matchLength = patObj->length;
5742 pattern = Tcl_GetStringFromObj(patObj, &matchLength);
57555743 nl = strchr(pattern, '\n');
57565744
57575745 /*
59205908 }
59215909 while (p >= startOfLine + firstOffset) {
59225910 if (matchLength == 0 || (p[0] == c && !strncmp(
5923 p, pattern, (size_t) matchLength))) {
5911 p, pattern, matchLength))) {
59245912 goto backwardsMatch;
59255913 }
59265914 p--;
59495937 */
59505938
59515939 p = startOfLine + lastOffset - firstNewLine - 1;
5952 if (strncmp(p, pattern, (unsigned) firstNewLine + 1)) {
5940 if (strncmp(p, pattern, firstNewLine + 1)) {
59535941 /*
59545942 * No match.
59555943 */
60156003 * result.
60166004 */
60176005
6018 if (strncmp(p,pattern,(size_t)matchLength)) {
6006 if (strncmp(p, pattern, matchLength)) {
60196007 p = NULL;
60206008 }
60216009 break;
62636251 */
62646252
62656253 if ((match &&
6266 firstOffset+info.matches[0].end != lastTotal &&
6267 firstOffset+info.matches[0].end < prevFullLine)
6254 firstOffset + info.matches[0].end != lastTotal &&
6255 firstOffset + info.matches[0].end < prevFullLine)
62686256 || info.extendStart < 0) {
62696257 break;
62706258 }
63336321 * Possible overlap or enclosure.
63346322 */
63356323
6336 if (thisOffset-lastNonOverlap >=
6337 lastBackwardsMatchOffset+matchLength){
6324 if (thisOffset - lastNonOverlap >=
6325 lastBackwardsMatchOffset + matchLength){
63386326 /*
63396327 * Totally encloses previous match, so
63406328 * forget the previous match.
64386426 * matches on the heap.
64396427 */
64406428
6441 int *newArray =
6429 int *newArray = (int *)
64426430 ckalloc(4 * matchNum * sizeof(int));
64436431 memcpy(newArray, storeMatch, matchNum*sizeof(int));
64446432 memcpy(newArray + 2*matchNum, storeLength,
66996687
67006688 static Tcl_Obj *
67016689 GetLineStartEnd(
6702 ClientData clientData,
6703 Tk_Window tkwin,
6690 TCL_UNUSED(void *),
6691 TCL_UNUSED(Tk_Window),
67046692 char *recordPtr, /* Pointer to widget record. */
67056693 int internalOffset) /* Offset within *recordPtr containing the
67066694 * line value. */
67346722
67356723 static int
67366724 SetLineStartEnd(
6737 ClientData clientData,
6725 TCL_UNUSED(void *),
67386726 Tcl_Interp *interp, /* Current interp; may be used for errors. */
6739 Tk_Window tkwin, /* Window for which option is being set. */
6727 TCL_UNUSED(Tk_Window), /* Window for which option is being set. */
67406728 Tcl_Obj **value, /* Pointer to the pointer to the value object.
67416729 * We use a pointer to the pointer because we
67426730 * may need to return a value (NULL). */
67936781
67946782 static void
67956783 RestoreLineStartEnd(
6796 ClientData clientData,
6797 Tk_Window tkwin,
6784 TCL_UNUSED(void *),
6785 TCL_UNUSED(Tk_Window),
67986786 char *internalPtr, /* Pointer to storage for value. */
67996787 char *oldInternalPtr) /* Pointer to old value. */
68006788 {
68526840
68536841 int
68546842 TkpTesttextCmd(
6855 ClientData clientData, /* Main window for application. */
6843 TCL_UNUSED(void *), /* Main window for application. */
68566844 Tcl_Interp *interp, /* Current interpreter. */
68576845 int objc, /* Number of arguments. */
68586846 Tcl_Obj *const objv[]) /* Argument strings. */
68716859 if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) {
68726860 return TCL_ERROR;
68736861 }
6874 textPtr = info.objClientData;
6862 textPtr = (TkText *)info.objClientData;
68756863 len = strlen(Tcl_GetString(objv[2]));
68766864 if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) {
68776865 if (objc != 5) {
167167 int size; /* Size of this segment (# of bytes of index
168168 * space it occupies). */
169169 union {
170 char chars[2]; /* Characters that make up character info.
170 char chars[TKFLEXARRAY]; /* Characters that make up character info.
171171 * Actual length varies to hold as many
172172 * characters as needed.*/
173173 TkTextToggle toggle; /* Information about tag toggle. */
488488 double tabIncrement; /* The accurate fractional pixel increment
489489 * between interpolated tabs we have to create
490490 * when we exceed numTabs. */
491 TkTextTab tabs[1]; /* Array of tabs. The actual size will be
491 TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be
492492 * numTabs. THIS FIELD MUST BE THE LAST IN THE
493493 * STRUCTURE. */
494494 } TkTextTabArray;
139139 * Macros that determine how much space to allocate for new segments:
140140 */
141141
142 #define CSEG_SIZE(chars) ((unsigned) (Tk_Offset(TkTextSegment, body) \
142 #define CSEG_SIZE(chars) ((unsigned)(Tk_Offset(TkTextSegment, body) \
143143 + 1 + (chars)))
144 #define TSEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \
144 #define TSEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
145145 + sizeof(TkTextToggle)))
146146
147147 /*
260260 TkBTreeCreate(
261261 TkSharedText *sharedTextPtr)
262262 {
263 register BTree *treePtr;
264 register Node *rootPtr;
265 register TkTextLine *linePtr, *linePtr2;
266 register TkTextSegment *segPtr;
263 BTree *treePtr;
264 Node *rootPtr;
265 TkTextLine *linePtr, *linePtr2;
266 TkTextSegment *segPtr;
267267
268268 /*
269269 * The tree will initially have two empty lines. The second line isn't
272272 * of the tree.
273273 */
274274
275 rootPtr = ckalloc(sizeof(Node));
276 linePtr = ckalloc(sizeof(TkTextLine));
277 linePtr2 = ckalloc(sizeof(TkTextLine));
275 rootPtr = (Node *)ckalloc(sizeof(Node));
276 linePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
277 linePtr2 = (TkTextLine *)ckalloc(sizeof(TkTextLine));
278278
279279 rootPtr->parentPtr = NULL;
280280 rootPtr->nextPtr = NULL;
295295
296296 linePtr->parentPtr = rootPtr;
297297 linePtr->nextPtr = linePtr2;
298 segPtr = ckalloc(CSEG_SIZE(1));
298 segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
299299 linePtr->segPtr = segPtr;
300300 segPtr->typePtr = &tkTextCharType;
301301 segPtr->nextPtr = NULL;
305305
306306 linePtr2->parentPtr = rootPtr;
307307 linePtr2->nextPtr = NULL;
308 segPtr = ckalloc(CSEG_SIZE(1));
308 segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
309309 linePtr2->segPtr = segPtr;
310310 segPtr->typePtr = &tkTextCharType;
311311 segPtr->nextPtr = NULL;
313313 segPtr->body.chars[0] = '\n';
314314 segPtr->body.chars[1] = 0;
315315
316 treePtr = ckalloc(sizeof(BTree));
316 treePtr = (BTree *)ckalloc(sizeof(BTree));
317317 treePtr->sharedTextPtr = sharedTextPtr;
318318 treePtr->rootPtr = rootPtr;
319319 treePtr->clients = 0;
365365 int defaultHeight) /* Default line height for the new client, or
366366 * -1 if no pixel heights are to be kept. */
367367 {
368 register BTree *treePtr = (BTree *) tree;
368 BTree *treePtr = (BTree *) tree;
369369
370370 if (treePtr == NULL) {
371371 Tcl_Panic("NULL treePtr in TkBTreeAddClient");
631631 i++;
632632 }
633633 treePtr->startEndCount = count;
634 treePtr->startEnd = ckrealloc(treePtr->startEnd,
634 treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
635635 sizeof(TkTextLine *) * count);
636 treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
636 treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
637637 sizeof(TkText *) * count);
638638 }
639639 if ((action & TEXT_ADD_REFS)
649649
650650 count = treePtr->startEndCount;
651651
652 treePtr->startEnd = ckrealloc(treePtr->startEnd,
652 treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
653653 sizeof(TkTextLine *) * count);
654 treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
654 treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
655655 sizeof(TkText *) * count);
656656
657657 if (textPtr->start != NULL) {
724724 loopPtr = loopPtr->nextPtr;
725725 }
726726 } else {
727 register TkTextLine *linePtr = nodePtr->children.linePtr;
727 TkTextLine *linePtr = nodePtr->children.linePtr;
728728
729729 while (linePtr != NULL) {
730730 if (!*counting && (linePtr == start)) {
734734 *counting = 0;
735735 }
736736 if (newPixelReferences != treePtr->pixelReferences) {
737 linePtr->pixels = ckrealloc(linePtr->pixels,
737 linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
738738 sizeof(int) * 2 * newPixelReferences);
739739 }
740740
751751 }
752752 }
753753 if (newPixelReferences != treePtr->pixelReferences) {
754 nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
754 nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
755755 sizeof(int) * newPixelReferences);
756756 }
757757 nodePtr->numPixels[useReference] = pixelCount;
801801 ckfree(nodePtr->numPixels);
802802 nodePtr->numPixels = NULL;
803803 } else {
804 nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
804 nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
805805 sizeof(int) * (treePtr->pixelReferences - 1));
806806 }
807807 if (nodePtr->level != 0) {
811811 nodePtr = nodePtr->nextPtr;
812812 }
813813 } else {
814 register TkTextLine *linePtr = nodePtr->children.linePtr;
814 TkTextLine *linePtr = nodePtr->children.linePtr;
815815 while (linePtr != NULL) {
816816 if (overwriteWithLast != -1) {
817817 linePtr->pixels[2*overwriteWithLast] =
822822 if (treePtr->pixelReferences == 1) {
823823 linePtr->pixels = NULL;
824824 } else {
825 linePtr->pixels = ckrealloc(linePtr->pixels,
825 linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
826826 sizeof(int) * 2 * (treePtr->pixelReferences-1));
827827 }
828828 linePtr = linePtr->nextPtr;
849849
850850 static void
851851 DestroyNode(
852 register Node *nodePtr) /* Destroy from this node downwards. */
852 Node *nodePtr) /* Destroy from this node downwards. */
853853 {
854854 if (nodePtr->level == 0) {
855855 TkTextLine *linePtr;
867867 ckfree(linePtr);
868868 }
869869 } else {
870 register Node *childPtr;
870 Node *childPtr;
871871
872872 while (nodePtr->children.nodePtr != NULL) {
873873 childPtr = nodePtr->children.nodePtr;
899899
900900 static void
901901 DeleteSummaries(
902 register Summary *summaryPtr)
902 Summary *summaryPtr)
903903 /* First in list of node's tag summaries. */
904904 {
905 register Summary *nextPtr;
905 Summary *nextPtr;
906906
907907 while (summaryPtr != NULL) {
908908 nextPtr = summaryPtr->nextPtr;
931931 int
932932 TkBTreeAdjustPixelHeight(
933933 const TkText *textPtr, /* Client of the B-tree. */
934 register TkTextLine *linePtr,
934 TkTextLine *linePtr,
935935 /* The logical line to update. */
936936 int newPixelHeight, /* The line's known height in pixels. */
937937 int mergedLogicalLines) /* The number of extra logical lines which
941941 * height associated with the given
942942 * linePtr. */
943943 {
944 register Node *nodePtr;
944 Node *nodePtr;
945945 int changeToPixelCount; /* Counts change to total number of pixels in
946946 * file. */
947947 int pixelReference = textPtr->pixelReference;
10001000 void
10011001 TkBTreeInsertChars(
10021002 TkTextBTree tree, /* Tree to insert into. */
1003 register TkTextIndex *indexPtr,
1003 TkTextIndex *indexPtr,
10041004 /* Indicates where to insert text. When the
10051005 * function returns, this index is no longer
10061006 * valid because of changes to the segment
10081008 const char *string) /* Pointer to bytes to insert (may contain
10091009 * newlines, must be null-terminated). */
10101010 {
1011 register Node *nodePtr;
1012 register TkTextSegment *prevPtr;
1011 Node *nodePtr;
1012 TkTextSegment *prevPtr;
10131013 /* The segment just before the first new
10141014 * segment (NULL means new segment is at
10151015 * beginning of line). */
10181018 * insert at beginning of line. */
10191019 TkTextLine *linePtr; /* Current line (new segments are added to
10201020 * this line). */
1021 register TkTextSegment *segPtr;
1021 TkTextSegment *segPtr;
10221022 TkTextLine *newLinePtr;
10231023 int chunkSize; /* # characters in current chunk. */
1024 register const char *eol; /* Pointer to character just after last one in
1024 const char *eol; /* Pointer to character just after last one in
10251025 * current chunk. */
10261026 int changeToLineCount; /* Counts change to total number of lines in
10271027 * file. */
10431043
10441044 changeToLineCount = 0;
10451045 if (treePtr->pixelReferences > PIXEL_CLIENTS) {
1046 changeToPixelCount = ckalloc(sizeof(int) * treePtr->pixelReferences);
1046 changeToPixelCount = (int *)ckalloc(sizeof(int) * treePtr->pixelReferences);
10471047 } else {
10481048 changeToPixelCount = pixels;
10491049 }
10591059 }
10601060 }
10611061 chunkSize = eol-string;
1062 segPtr = ckalloc(CSEG_SIZE(chunkSize));
1062 segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(chunkSize));
10631063 segPtr->typePtr = &tkTextCharType;
10641064 if (curPtr == NULL) {
10651065 segPtr->nextPtr = linePtr->segPtr;
10691069 curPtr->nextPtr = segPtr;
10701070 }
10711071 segPtr->size = chunkSize;
1072 memcpy(segPtr->body.chars, string, (size_t) chunkSize);
1072 memcpy(segPtr->body.chars, string, chunkSize);
10731073 segPtr->body.chars[chunkSize] = 0;
10741074
10751075 if (eol[-1] != '\n') {
10811081 * the remainder of the old line to it.
10821082 */
10831083
1084 newLinePtr = ckalloc(sizeof(TkTextLine));
1085 newLinePtr->pixels =
1084 newLinePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
1085 newLinePtr->pixels = (int *)
10861086 ckalloc(sizeof(int) * 2 * treePtr->pixelReferences);
10871087
10881088 newLinePtr->parentPtr = linePtr->parentPtr;
13111311 void
13121312 TkBTreeDeleteIndexRange(
13131313 TkTextBTree tree, /* Tree to delete from. */
1314 register TkTextIndex *index1Ptr,
1314 TkTextIndex *index1Ptr,
13151315 /* Indicates first character that is to be
13161316 * deleted. */
1317 register TkTextIndex *index2Ptr)
1317 TkTextIndex *index2Ptr)
13181318 /* Indicates character just after the last one
13191319 * that is to be deleted. */
13201320 {
15951595 int line) /* Index of desired line. */
15961596 {
15971597 BTree *treePtr = (BTree *) tree;
1598 register Node *nodePtr;
1599 register TkTextLine *linePtr;
1598 Node *nodePtr;
1599 TkTextLine *linePtr;
16001600
16011601 if (treePtr == NULL) {
16021602 treePtr = (BTree *) textPtr->sharedTextPtr->tree;
16851685 int *pixelOffset) /* Used to return offset. */
16861686 {
16871687 BTree *treePtr = (BTree *) tree;
1688 register Node *nodePtr;
1689 register TkTextLine *linePtr;
1688 Node *nodePtr;
1689 TkTextLine *linePtr;
16901690 int pixelReference = textPtr->pixelReference;
16911691
16921692 nodePtr = treePtr->rootPtr;
17541754 TkTextLine *
17551755 TkBTreeNextLine(
17561756 const TkText *textPtr, /* Next line in the context of this client. */
1757 register TkTextLine *linePtr)
1757 TkTextLine *linePtr)
17581758 /* Pointer to existing line in B-tree. */
17591759 {
1760 register Node *nodePtr;
1760 Node *nodePtr;
17611761
17621762 if (linePtr->nextPtr != NULL) {
17631763 if (textPtr != NULL && (linePtr == textPtr->end)) {
18101810 TkTextLine *
18111811 TkBTreePreviousLine(
18121812 TkText *textPtr, /* Relative to this client of the B-tree. */
1813 register TkTextLine *linePtr)
1813 TkTextLine *linePtr)
18141814 /* Pointer to existing line in B-tree. */
18151815 {
1816 register Node *nodePtr;
1817 register Node *node2Ptr;
1818 register TkTextLine *prevPtr;
1816 Node *nodePtr;
1817 Node *node2Ptr;
1818 TkTextLine *prevPtr;
18191819
18201820 if (textPtr != NULL && textPtr->start == linePtr) {
18211821 return NULL;
18941894 const TkText *textPtr, /* Relative to this client of the B-tree. */
18951895 TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
18961896 {
1897 register TkTextLine *linePtr2;
1898 register Node *nodePtr, *parentPtr;
1897 TkTextLine *linePtr2;
1898 Node *nodePtr, *parentPtr;
18991899 int index;
19001900 int pixelReference = textPtr->pixelReference;
19011901
19201920
19211921 for (parentPtr = nodePtr->parentPtr ; parentPtr != NULL;
19221922 nodePtr = parentPtr, parentPtr = parentPtr->parentPtr) {
1923 register Node *nodePtr2;
1923 Node *nodePtr2;
19241924
19251925 for (nodePtr2 = parentPtr->children.nodePtr; nodePtr2 != nodePtr;
19261926 nodePtr2 = nodePtr2->nextPtr) {
19561956 const TkText *textPtr, /* Relative to this client of the B-tree. */
19571957 TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
19581958 {
1959 register TkTextLine *linePtr2;
1960 register Node *nodePtr, *parentPtr, *nodePtr2;
1959 TkTextLine *linePtr2;
1960 Node *nodePtr, *parentPtr, *nodePtr2;
19611961 int index;
19621962
19631963 /*
20362036 *----------------------------------------------------------------------
20372037 */
20382038
2039 /* ARGSUSED */
20402039 void
20412040 TkBTreeLinkSegment(
20422041 TkTextSegment *segPtr, /* Pointer to new segment to be added to
20452044 TkTextIndex *indexPtr) /* Where to add segment: it gets linked in
20462045 * just before the segment indicated here. */
20472046 {
2048 register TkTextSegment *prevPtr;
2047 TkTextSegment *prevPtr;
20492048
20502049 prevPtr = SplitSeg(indexPtr);
20512050 if (prevPtr == NULL) {
20792078 *----------------------------------------------------------------------
20802079 */
20812080
2082 /* ARGSUSED */
20832081 void
20842082 TkBTreeUnlinkSegment(
20852083 TkTextSegment *segPtr, /* Segment to be unlinked. */
20862084 TkTextLine *linePtr) /* Line that currently contains segment. */
20872085 {
2088 register TkTextSegment *prevPtr;
2086 TkTextSegment *prevPtr;
20892087
20902088 if (linePtr->segPtr == segPtr) {
20912089 linePtr->segPtr = segPtr->nextPtr;
21342132
21352133 int
21362134 TkBTreeTag(
2137 register TkTextIndex *index1Ptr,
2135 TkTextIndex *index1Ptr,
21382136 /* Indicates first character in range. */
2139 register TkTextIndex *index2Ptr,
2137 TkTextIndex *index2Ptr,
21402138 /* Indicates character just after the last one
21412139 * in range. */
21422140 TkTextTag *tagPtr, /* Tag to add or remove. */
21562154
21572155 oldState = TkBTreeCharTagged(index1Ptr, tagPtr);
21582156 if ((add != 0) ^ oldState) {
2159 segPtr = ckalloc(TSEG_SIZE);
2157 segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
21602158 segPtr->typePtr = (add) ? &tkTextToggleOnType : &tkTextToggleOffType;
21612159 prevPtr = SplitSeg(index1Ptr);
21622160 if (prevPtr == NULL) {
22272225 }
22282226 }
22292227 if ((add != 0) ^ oldState) {
2230 segPtr = ckalloc(TSEG_SIZE);
2228 segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
22312229 segPtr->typePtr = (add) ? &tkTextToggleOffType : &tkTextToggleOnType;
22322230 prevPtr = SplitSeg(index2Ptr);
22332231 if (prevPtr == NULL) {
22842282
22852283 static void
22862284 ChangeNodeToggleCount(
2287 register Node *nodePtr, /* Node whose toggle count for a tag must be
2285 Node *nodePtr, /* Node whose toggle count for a tag must be
22882286 * changed. */
22892287 TkTextTag *tagPtr, /* Information about tag. */
22902288 int delta) /* Amount to add to current toggle count for
22912289 * tag (may be negative). */
22922290 {
2293 register Summary *summaryPtr, *prevPtr;
2294 register Node *node2Ptr;
2291 Summary *summaryPtr, *prevPtr;
2292 Node *node2Ptr;
22952293 int rootLevel; /* Level of original tag root. */
22962294
22972295 tagPtr->toggleCount += delta;
23712369
23722370 Node *rootNodePtr = tagPtr->tagRootPtr;
23732371
2374 summaryPtr = ckalloc(sizeof(Summary));
2372 summaryPtr = (Summary *)ckalloc(sizeof(Summary));
23752373 summaryPtr->tagPtr = tagPtr;
23762374 summaryPtr->toggleCount = tagPtr->toggleCount - delta;
23772375 summaryPtr->nextPtr = rootNodePtr->summaryPtr;
23802378 rootLevel = rootNodePtr->level;
23812379 tagPtr->tagRootPtr = rootNodePtr;
23822380 }
2383 summaryPtr = ckalloc(sizeof(Summary));
2381 summaryPtr = (Summary *)ckalloc(sizeof(Summary));
23842382 summaryPtr->tagPtr = tagPtr;
23852383 summaryPtr->toggleCount = delta;
23862384 summaryPtr->nextPtr = nodePtr->summaryPtr;
24702468 TkTextTag *tagPtr, /* Tag to search for. */
24712469 TkTextIndex *indexPtr) /* Return - index information. */
24722470 {
2473 register Node *nodePtr;
2474 register TkTextLine *linePtr;
2475 register TkTextSegment *segPtr;
2476 register Summary *summaryPtr;
2471 Node *nodePtr;
2472 TkTextLine *linePtr;
2473 TkTextSegment *segPtr;
2474 Summary *summaryPtr;
24772475 int offset;
24782476
24792477 nodePtr = tagPtr->tagRootPtr;
25552553 TkTextTag *tagPtr, /* Tag to search for. */
25562554 TkTextIndex *indexPtr) /* Return - index information. */
25572555 {
2558 register Node *nodePtr, *lastNodePtr;
2559 register TkTextLine *linePtr ,*lastLinePtr;
2560 register TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
2561 register Summary *summaryPtr;
2556 Node *nodePtr, *lastNodePtr;
2557 TkTextLine *linePtr ,*lastLinePtr;
2558 TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
2559 Summary *summaryPtr;
25622560 int lastoffset, lastoffset2, offset;
25632561
25642562 nodePtr = tagPtr->tagRootPtr;
26512649 * position *will* be returned. */
26522650 TkTextTag *tagPtr, /* Tag to search for. NULL means search for
26532651 * any tag. */
2654 register TkTextSearch *searchPtr)
2652 TkTextSearch *searchPtr)
26552653 /* Where to store information about search's
26562654 * progress. */
26572655 {
27472745 * position *will* be returned. */
27482746 TkTextTag *tagPtr, /* Tag to search for. NULL means search for
27492747 * any tag. */
2750 register TkTextSearch *searchPtr)
2748 TkTextSearch *searchPtr)
27512749 /* Where to store information about search's
27522750 * progress. */
27532751 {
28482846
28492847 int
28502848 TkBTreeNextTag(
2851 register TkTextSearch *searchPtr)
2849 TkTextSearch *searchPtr)
28522850 /* Information about search in progress; must
28532851 * have been set up by call to
28542852 * TkBTreeStartSearch. */
28552853 {
2856 register TkTextSegment *segPtr;
2857 register Node *nodePtr;
2858 register Summary *summaryPtr;
2854 TkTextSegment *segPtr;
2855 Node *nodePtr;
2856 Summary *summaryPtr;
28592857
28602858 if (searchPtr->linesLeft <= 0) {
28612859 goto searchOver;
30133011
30143012 int
30153013 TkBTreePrevTag(
3016 register TkTextSearch *searchPtr)
3014 TkTextSearch *searchPtr)
30173015 /* Information about search in progress; must
30183016 * have been set up by call to
30193017 * TkBTreeStartSearch. */
30203018 {
3021 register TkTextSegment *segPtr, *prevPtr;
3022 register TkTextLine *linePtr, *prevLinePtr;
3023 register Node *nodePtr, *node2Ptr, *prevNodePtr;
3024 register Summary *summaryPtr;
3019 TkTextSegment *segPtr, *prevPtr;
3020 TkTextLine *linePtr, *prevLinePtr;
3021 Node *nodePtr, *node2Ptr, *prevNodePtr;
3022 Summary *summaryPtr;
30253023 int byteIndex, linesSkipped;
30263024 int pastLast; /* Saw last marker during scan. */
30273025
32313229 * check for a tag. */
32323230 TkTextTag *tagPtr) /* Tag of interest. */
32333231 {
3234 register Node *nodePtr;
3235 register TkTextLine *siblingLinePtr;
3236 register TkTextSegment *segPtr;
3232 Node *nodePtr;
3233 TkTextLine *siblingLinePtr;
3234 TkTextSegment *segPtr;
32373235 TkTextSegment *toggleSegPtr;
32383236 int toggles, index;
32393237
32873285 toggles = 0;
32883286 for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
32893287 nodePtr = nodePtr->parentPtr) {
3290 register Node *siblingPtr;
3291 register Summary *summaryPtr;
3288 Node *siblingPtr;
3289 Summary *summaryPtr;
32923290
32933291 for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
32943292 siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
33353333 *----------------------------------------------------------------------
33363334 */
33373335
3338 /* ARGSUSED */
33393336 TkTextTag **
33403337 TkBTreeGetTags(
33413338 const TkTextIndex *indexPtr,/* Indicates a particular position in the
33463343 int *numTagsPtr) /* Store number of tags found at this
33473344 * location. */
33483345 {
3349 register Node *nodePtr;
3350 register TkTextLine *siblingLinePtr;
3351 register TkTextSegment *segPtr;
3346 Node *nodePtr;
3347 TkTextLine *siblingLinePtr;
3348 TkTextSegment *segPtr;
33523349 TkTextLine *linePtr;
33533350 int src, dst, index;
33543351 TagInfo tagInfo;
33563353
33573354 tagInfo.numTags = 0;
33583355 tagInfo.arraySize = NUM_TAG_INFOS;
3359 tagInfo.tagPtrs = ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
3360 tagInfo.counts = ckalloc(NUM_TAG_INFOS * sizeof(int));
3356 tagInfo.tagPtrs = (TkTextTag **)ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
3357 tagInfo.counts = (int *)ckalloc(NUM_TAG_INFOS * sizeof(int));
33613358
33623359 /*
33633360 * Record tag toggles within the line of indexPtr but preceding indexPtr.
34093406
34103407 for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
34113408 nodePtr = nodePtr->parentPtr) {
3412 register Node *siblingPtr;
3413 register Summary *summaryPtr;
3409 Node *siblingPtr;
3410 Summary *summaryPtr;
34143411
34153412 for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
34163413 siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
34813478 *----------------------------------------------------------------------
34823479 */
34833480
3484 /* ARGSUSED */
34853481 int
34863482 TkTextIsElided(
34873483 const TkText *textPtr, /* Overall information about text widget. */
34913487 * indexPtr's elide state will be stored and
34923488 * returned. */
34933489 {
3494 register Node *nodePtr;
3495 register TkTextLine *siblingLinePtr;
3496 register TkTextSegment *segPtr;
3497 register TkTextTag *tagPtr = NULL;
3498 register int i, index;
3499 register TkTextElideInfo *infoPtr;
3490 Node *nodePtr;
3491 TkTextLine *siblingLinePtr;
3492 TkTextSegment *segPtr;
3493 TkTextTag *tagPtr = NULL;
3494 int i, index;
3495 TkTextElideInfo *infoPtr;
35003496 TkTextLine *linePtr;
35013497 int elide;
35023498
35033499 if (elideInfo == NULL) {
3504 infoPtr = ckalloc(sizeof(TkTextElideInfo));
3500 infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
35053501 } else {
35063502 infoPtr = elideInfo;
35073503 }
35163512 */
35173513
35183514 if (LOTSA_TAGS < infoPtr->numTags) {
3519 infoPtr->tagCnts = ckalloc(sizeof(int) * infoPtr->numTags);
3520 infoPtr->tagPtrs = ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
3515 infoPtr->tagCnts = (int *)ckalloc(sizeof(int) * infoPtr->numTags);
3516 infoPtr->tagPtrs = (TkTextTag **)ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
35213517 }
35223518
35233519 for (i=0; i<infoPtr->numTags; i++) {
35903586
35913587 for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
35923588 nodePtr = nodePtr->parentPtr) {
3593 register Node *siblingPtr;
3594 register Summary *summaryPtr;
3589 Node *siblingPtr;
3590 Summary *summaryPtr;
35953591
35963592 for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
35973593 siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
36963692 TagInfo *tagInfoPtr) /* Holds cumulative information about tags;
36973693 * increment count here. */
36983694 {
3699 register TkTextTag **tagPtrPtr;
3695 TkTextTag **tagPtrPtr;
37003696 int count;
37013697
37023698 for (tagPtrPtr = tagInfoPtr->tagPtrs, count = tagInfoPtr->numTags;
37173713 int *newCounts, newSize;
37183714
37193715 newSize = 2 * tagInfoPtr->arraySize;
3720 newTags = ckalloc(newSize * sizeof(TkTextTag *));
3716 newTags = (TkTextTag **)ckalloc(newSize * sizeof(TkTextTag *));
37213717 memcpy(newTags, tagInfoPtr->tagPtrs,
37223718 tagInfoPtr->arraySize * sizeof(TkTextTag *));
37233719 ckfree(tagInfoPtr->tagPtrs);
37243720 tagInfoPtr->tagPtrs = newTags;
3725 newCounts = ckalloc(newSize * sizeof(int));
3721 newCounts = (int *)ckalloc(newSize * sizeof(int));
37263722 memcpy(newCounts, tagInfoPtr->counts,
37273723 tagInfoPtr->arraySize * sizeof(int));
37283724 ckfree(tagInfoPtr->counts);
37583754 TkTextBTree tree) /* Tree to check. */
37593755 {
37603756 BTree *treePtr = (BTree *) tree;
3761 register Summary *summaryPtr;
3762 register Node *nodePtr;
3763 register TkTextLine *linePtr;
3764 register TkTextSegment *segPtr;
3765 register TkTextTag *tagPtr;
3757 Summary *summaryPtr;
3758 Node *nodePtr;
3759 TkTextLine *linePtr;
3760 TkTextSegment *segPtr;
3761 TkTextTag *tagPtr;
37663762 Tcl_HashEntry *entryPtr;
37673763 Tcl_HashSearch search;
37683764 int count;
37733769
37743770 for (entryPtr=Tcl_FirstHashEntry(&treePtr->sharedTextPtr->tagTable,&search);
37753771 entryPtr != NULL ; entryPtr = Tcl_NextHashEntry(&search)) {
3776 tagPtr = Tcl_GetHashValue(entryPtr);
3772 tagPtr = (TkTextTag *)Tcl_GetHashValue(entryPtr);
37773773 nodePtr = tagPtr->tagRootPtr;
37783774 if (nodePtr == NULL) {
37793775 if (tagPtr->toggleCount != 0) {
38973893
38983894 static void
38993895 CheckNodeConsistency(
3900 register Node *nodePtr, /* Node whose subtree should be checked. */
3896 Node *nodePtr, /* Node whose subtree should be checked. */
39013897 int references) /* Number of referring widgets which have
39023898 * pixel counts. */
39033899 {
3904 register Node *childNodePtr;
3905 register Summary *summaryPtr, *summaryPtr2;
3906 register TkTextLine *linePtr;
3907 register TkTextSegment *segPtr;
3900 Node *childNodePtr;
3901 Summary *summaryPtr, *summaryPtr2;
3902 TkTextLine *linePtr;
3903 TkTextSegment *segPtr;
39083904 int numChildren, numLines, toggleCount, minChildren, i;
39093905 int *numPixels;
39103906 int pixels[PIXEL_CLIENTS];
39253921 numChildren = 0;
39263922 numLines = 0;
39273923 if (references > PIXEL_CLIENTS) {
3928 numPixels = ckalloc(sizeof(int) * references);
3924 numPixels = (int *)ckalloc(sizeof(int) * references);
39293925 } else {
39303926 numPixels = pixels;
39313927 }
40864082 static void
40874083 Rebalance(
40884084 BTree *treePtr, /* Tree that is being rebalanced. */
4089 register Node *nodePtr) /* Node that may be out of balance. */
4085 Node *nodePtr) /* Node that may be out of balance. */
40904086 {
40914087 /*
40924088 * Loop over the entire ancestral chain of the node, working up through
40944090 */
40954091
40964092 for ( ; nodePtr != NULL; nodePtr = nodePtr->parentPtr) {
4097 register Node *newPtr, *childPtr;
4098 register TkTextLine *linePtr;
4093 Node *newPtr, *childPtr;
4094 TkTextLine *linePtr;
40994095 int i;
41004096
41014097 /*
41134109 */
41144110
41154111 if (nodePtr->parentPtr == NULL) {
4116 newPtr = ckalloc(sizeof(Node));
4112 newPtr = (Node *)ckalloc(sizeof(Node));
41174113 newPtr->parentPtr = NULL;
41184114 newPtr->nextPtr = NULL;
41194115 newPtr->summaryPtr = NULL;
41214117 newPtr->children.nodePtr = nodePtr;
41224118 newPtr->numChildren = 1;
41234119 newPtr->numLines = nodePtr->numLines;
4124 newPtr->numPixels =
4120 newPtr->numPixels = (int *)
41254121 ckalloc(sizeof(int) * treePtr->pixelReferences);
41264122 for (i=0; i<treePtr->pixelReferences; i++) {
41274123 newPtr->numPixels[i] = nodePtr->numPixels[i];
41294125 RecomputeNodeCounts(treePtr, newPtr);
41304126 treePtr->rootPtr = newPtr;
41314127 }
4132 newPtr = ckalloc(sizeof(Node));
4133 newPtr->numPixels =
4128 newPtr = (Node *)ckalloc(sizeof(Node));
4129 newPtr->numPixels = (int *)
41344130 ckalloc(sizeof(int) * treePtr->pixelReferences);
41354131 for (i=0; i<treePtr->pixelReferences; i++) {
41364132 newPtr->numPixels[i] = 0;
41694165 }
41704166
41714167 while (nodePtr->numChildren < MIN_CHILDREN) {
4172 register Node *otherPtr;
4168 Node *otherPtr;
41734169 Node *halfwayNodePtr = NULL; /* Initialization needed only */
41744170 TkTextLine *halfwayLinePtr = NULL; /* to prevent cc warnings. */
4175 int totalChildren, firstChildren, i;
4171 int totalChildren, firstChildren;
41764172
41774173 /*
41784174 * Too few children for this node. If this is the root then, it's
42334229 otherPtr->children.linePtr = NULL;
42344230 }
42354231 if (nodePtr->level == 0) {
4236 register TkTextLine *linePtr;
4237
42384232 for (linePtr = nodePtr->children.linePtr, i = 1;
42394233 linePtr->nextPtr != NULL;
42404234 linePtr = linePtr->nextPtr, i++) {
42494243 i++;
42504244 }
42514245 } else {
4252 register Node *childPtr;
4253
42544246 for (childPtr = nodePtr->children.nodePtr, i = 1;
42554247 childPtr->nextPtr != NULL;
42564248 childPtr = childPtr->nextPtr, i++) {
43254317
43264318 static void
43274319 RecomputeNodeCounts(
4328 register BTree *treePtr, /* The whole B-tree. */
4329 register Node *nodePtr) /* Node whose tag summary information must be
4320 BTree *treePtr, /* The whole B-tree. */
4321 Node *nodePtr) /* Node whose tag summary information must be
43304322 * recomputed. */
43314323 {
4332 register Summary *summaryPtr, *summaryPtr2;
4333 register Node *childPtr;
4334 register TkTextLine *linePtr;
4335 register TkTextSegment *segPtr;
4324 Summary *summaryPtr, *summaryPtr2;
4325 Node *childPtr;
4326 TkTextLine *linePtr;
4327 TkTextSegment *segPtr;
43364328 TkTextTag *tagPtr;
43374329 int ref;
43384330
43764368 for (summaryPtr = nodePtr->summaryPtr; ;
43774369 summaryPtr = summaryPtr->nextPtr) {
43784370 if (summaryPtr == NULL) {
4379 summaryPtr = ckalloc(sizeof(Summary));
4371 summaryPtr = (Summary *)ckalloc(sizeof(Summary));
43804372 summaryPtr->tagPtr = tagPtr;
43814373 summaryPtr->toggleCount = 1;
43824374 summaryPtr->nextPtr = nodePtr->summaryPtr;
44044396 for (summaryPtr = nodePtr->summaryPtr; ;
44054397 summaryPtr = summaryPtr->nextPtr) {
44064398 if (summaryPtr == NULL) {
4407 summaryPtr = ckalloc(sizeof(Summary));
4399 summaryPtr = (Summary *)ckalloc(sizeof(Summary));
44084400 summaryPtr->tagPtr = summaryPtr2->tagPtr;
44094401 summaryPtr->toggleCount = summaryPtr2->toggleCount;
44104402 summaryPtr->nextPtr = nodePtr->summaryPtr;
45574549 {
45584550 TkTextSegment *newPtr1, *newPtr2;
45594551
4560 newPtr1 = ckalloc(CSEG_SIZE(index));
4561 newPtr2 = ckalloc(CSEG_SIZE(segPtr->size - index));
4552 newPtr1 = (TkTextSegment *)ckalloc(CSEG_SIZE(index));
4553 newPtr2 = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size - index));
45624554 newPtr1->typePtr = &tkTextCharType;
45634555 newPtr1->nextPtr = newPtr2;
45644556 newPtr1->size = index;
4565 memcpy(newPtr1->body.chars, segPtr->body.chars, (size_t) index);
4557 memcpy(newPtr1->body.chars, segPtr->body.chars, index);
45664558 newPtr1->body.chars[index] = 0;
45674559 newPtr2->typePtr = &tkTextCharType;
45684560 newPtr2->nextPtr = segPtr->nextPtr;
45914583 *--------------------------------------------------------------
45924584 */
45934585
4594 /* ARGSUSED */
45954586 static TkTextSegment *
45964587 CharCleanupProc(
45974588 TkTextSegment *segPtr, /* Pointer to first of two adjacent segments
45984589 * to join. */
4599 TkTextLine *linePtr) /* Line containing segments (not used). */
4590 TCL_UNUSED(TkTextLine *)) /* Line containing segments (not used). */
46004591 {
46014592 TkTextSegment *segPtr2, *newPtr;
46024593
46044595 if ((segPtr2 == NULL) || (segPtr2->typePtr != &tkTextCharType)) {
46054596 return segPtr;
46064597 }
4607 newPtr = ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
4598 newPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
46084599 newPtr->typePtr = &tkTextCharType;
46094600 newPtr->nextPtr = segPtr2->nextPtr;
46104601 newPtr->size = segPtr->size + segPtr2->size;
46324623 *--------------------------------------------------------------
46334624 */
46344625
4635 /* ARGSUSED */
46364626 static int
46374627 CharDeleteProc(
46384628 TkTextSegment *segPtr, /* Segment to delete. */
4639 TkTextLine *linePtr, /* Line containing segment. */
4640 int treeGone) /* Non-zero means the entire tree is being
4629 TCL_UNUSED(TkTextLine *), /* Line containing segment. */
4630 TCL_UNUSED(int)) /* Non-zero means the entire tree is being
46414631 * deleted, so everything must get cleaned
46424632 * up. */
46434633 {
46624652 *--------------------------------------------------------------
46634653 */
46644654
4665 /* ARGSUSED */
46664655 static void
46674656 CharCheckProc(
46684657 TkTextSegment *segPtr, /* Segment to check. */
4669 TkTextLine *linePtr) /* Line containing segment. */
4658 TCL_UNUSED(TkTextLine *)) /* Line containing segment. */
46704659 {
46714660 /*
46724661 * Make sure that the segment contains the number of characters indicated
46784667 if (segPtr->size <= 0) {
46794668 Tcl_Panic("CharCheckProc: segment has size <= 0");
46804669 }
4681 if (strlen(segPtr->body.chars) != (size_t) segPtr->size) {
4670 if (strlen(segPtr->body.chars) != (size_t)segPtr->size) {
46824671 Tcl_Panic("CharCheckProc: segment has wrong size");
46834672 }
46844673 if (segPtr->nextPtr == NULL) {
48574846 TkTextSegment *segPtr, /* Segment to check. */
48584847 TkTextLine *linePtr) /* Line containing segment. */
48594848 {
4860 register Summary *summaryPtr;
4849 Summary *summaryPtr;
48614850 int needSummary;
48624851
48634852 if (segPtr->size != 0) {
1919 #include "tkWinInt.h"
2020 #elif defined(__CYGWIN__)
2121 #include "tkUnixInt.h"
22 #elif defined(MAC_OSX_TK)
23 #include "tkMacOSXInt.h"
24 #define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
2225 #endif
2326
24 #ifdef MAC_OSX_TK
25 #include "tkMacOSXInt.h"
26 #define OK_TO_LOG (!TkpAppIsDrawing())
27 #define FORCE_DISPLAY(winPtr) TkpDisplayWindow(winPtr)
28 #else
27 #if !defined(MAC_OSX_TK)
2928 #define OK_TO_LOG 1
30 #define FORCE_DISPLAY(winPtr)
3129 #endif
3230
3331 /*
445443
446444 typedef struct CharInfo {
447445 int numBytes; /* Number of bytes to display. */
448 char chars[1]; /* UTF characters to display. Actual size will
449 * be numBytes, not 1. THIS MUST BE THE LAST
446 char chars[TKFLEXARRAY]; /* UTF characters to display.
447 * Allocated as large as necessary. THIS MUST BE THE LAST
450448 * FIELD IN THE STRUCTURE. */
451449 } CharInfo;
452450
659657 TkTextCreateDInfo(
660658 TkText *textPtr) /* Overall information for text widget. */
661659 {
662 register TextDInfo *dInfoPtr;
660 TextDInfo *dInfoPtr;
663661 XGCValues gcValues;
664662
665 dInfoPtr = ckalloc(sizeof(TextDInfo));
663 dInfoPtr = (TextDInfo *)ckalloc(sizeof(TextDInfo));
666664 Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int));
667665 dInfoPtr->dLinePtr = NULL;
668666 dInfoPtr->copyGC = NULL;
718716 TkTextFreeDInfo(
719717 TkText *textPtr) /* Overall information for text widget. */
720718 {
721 register TextDInfo *dInfoPtr = textPtr->dInfoPtr;
719 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
722720
723721 /*
724722 * Be careful to free up styleTable *after* freeing up all the DLines, so
774772 * information is wanted. */
775773 {
776774 TkTextTag **tagPtrs;
777 register TkTextTag *tagPtr;
775 TkTextTag *tagPtr;
778776 StyleValues styleValues;
779777 TextStyle *stylePtr;
780778 Tcl_HashEntry *hPtr;
10031001 hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable,
10041002 (char *) &styleValues, &isNew);
10051003 if (!isNew) {
1006 stylePtr = Tcl_GetHashValue(hPtr);
1004 stylePtr = (TextStyle *)Tcl_GetHashValue(hPtr);
10071005 stylePtr->refCount++;
10081006 return stylePtr;
10091007 }
10121010 * No existing style matched. Make a new one.
10131011 */
10141012
1015 stylePtr = ckalloc(sizeof(TextStyle));
1013 stylePtr = (TextStyle *)ckalloc(sizeof(TextStyle));
10161014 stylePtr->refCount = 1;
10171015 if (styleValues.border != NULL) {
10181016 gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel;
10701068 static void
10711069 FreeStyle(
10721070 TkText *textPtr, /* Information about overall widget. */
1073 register TextStyle *stylePtr)
1071 TextStyle *stylePtr)
10741072 /* Information about style to free. */
10751073 {
1076 stylePtr->refCount--;
1077 if (stylePtr->refCount == 0) {
1074 if (stylePtr->refCount-- <= 1) {
10781075 if (stylePtr->bgGC != NULL) {
10791076 Tk_FreeGC(textPtr->display, stylePtr->bgGC);
10801077 }
11331130 * necessarily point to a character
11341131 * segment. */
11351132 {
1136 register DLine *dlPtr; /* New display line. */
1133 DLine *dlPtr; /* New display line. */
11371134 TkTextSegment *segPtr; /* Current segment in text. */
11381135 TkTextDispChunk *lastChunkPtr;
11391136 /* Last chunk allocated so far for line. */
11871184 * Create and initialize a new DLine structure.
11881185 */
11891186
1190 dlPtr = ckalloc(sizeof(DLine));
1187 dlPtr = (DLine *)ckalloc(sizeof(DLine));
11911188 dlPtr->index = *indexPtr;
11921189 dlPtr->byteCount = 0;
11931190 dlPtr->y = 0;
13681365 * expectations in the rest of the code, but we are able to skip
13691366 * elided portions of the line quickly.
13701367 *
1371 * If current chunk is elided and last chunk was too, coalese.
1368 * If current chunk is elided and last chunk was too, coalesce.
13721369 *
13731370 * This also means that each logical line which is entirely elided
13741371 * still gets laid out into a DLine, but with zero height. This isn't
14361433 continue;
14371434 }
14381435 if (chunkPtr == NULL) {
1439 chunkPtr = ckalloc(sizeof(TkTextDispChunk));
1436 chunkPtr = (TkTextDispChunk *)ckalloc(sizeof(TkTextDispChunk));
14401437 chunkPtr->nextPtr = NULL;
14411438 chunkPtr->clientData = NULL;
14421439 }
18341831 UpdateDisplayInfo(
18351832 TkText *textPtr) /* Text widget to update. */
18361833 {
1837 register TextDInfo *dInfoPtr = textPtr->dInfoPtr;
1838 register DLine *dlPtr, *prevPtr;
1834 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
1835 DLine *dlPtr, *prevPtr;
18391836 TkTextIndex index;
18401837 TkTextLine *lastLinePtr;
18411838 int y, maxY, xPixelOffset, maxOffset, lineHeight;
18721869 y = dInfoPtr->y - dInfoPtr->newTopPixelOffset;
18731870 maxY = dInfoPtr->maxY;
18741871 while (1) {
1875 register DLine *newPtr;
1872 DLine *newPtr;
18761873
18771874 if (index.linePtr == lastLinePtr) {
18781875 break;
19831980 */
19841981
19851982 if (index.linePtr != prevPtr->index.linePtr) {
1986 register DLine *nextPtr;
1983 DLine *nextPtr;
19871984
19881985 nextPtr = dlPtr;
19891986 while ((nextPtr != NULL)
23522349 static void
23532350 FreeDLines(
23542351 TkText *textPtr, /* Information about overall text widget. */
2355 register DLine *firstPtr, /* Pointer to first DLine to free up. */
2352 DLine *firstPtr, /* Pointer to first DLine to free up. */
23562353 DLine *lastPtr, /* Pointer to DLine just after last one to
23572354 * free (NULL means everything starting with
23582355 * firstPtr). */
23652362 * we shouldn't invalidate anything for the
23662363 * overall widget. */
23672364 {
2368 register TkTextDispChunk *chunkPtr, *nextChunkPtr;
2369 register DLine *nextDLinePtr;
2365 TkTextDispChunk *chunkPtr, *nextChunkPtr;
2366 DLine *nextDLinePtr;
23702367
23712368 if (action == DLINE_FREE_TEMP) {
23722369 lineHeightsRecalculated++;
23852382 if (textPtr->dInfoPtr->dLinePtr == firstPtr) {
23862383 textPtr->dInfoPtr->dLinePtr = lastPtr;
23872384 } else {
2388 register DLine *prevPtr;
2385 DLine *prevPtr;
23892386
23902387 for (prevPtr = textPtr->dInfoPtr->dLinePtr;
23912388 prevPtr->nextPtr != firstPtr; prevPtr = prevPtr->nextPtr) {
24332430 static void
24342431 DisplayDLine(
24352432 TkText *textPtr, /* Text widget in which to draw line. */
2436 register DLine *dlPtr, /* Information about line to draw. */
2433 DLine *dlPtr, /* Information about line to draw. */
24372434 DLine *prevPtr, /* Line just before one to draw, or NULL if
24382435 * dlPtr is the top line. */
24392436 Pixmap pixmap) /* Pixmap to use for double-buffering. Caller
24402437 * must make sure it's large enough to hold
24412438 * line. */
24422439 {
2443 register TkTextDispChunk *chunkPtr;
2440 TkTextDispChunk *chunkPtr;
24442441 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
24452442 Display *display;
24462443 int height, y_off;
26122609 static void
26132610 DisplayLineBackground(
26142611 TkText *textPtr, /* Text widget containing line. */
2615 register DLine *dlPtr, /* Information about line to draw. */
2612 DLine *dlPtr, /* Information about line to draw. */
26162613 DLine *prevPtr, /* Line just above dlPtr, or NULL if dlPtr is
26172614 * the top-most line in the window. */
26182615 Pixmap pixmap) /* Pixmap to use for double-buffering. Caller
30083005 AsyncUpdateLineMetrics(
30093006 ClientData clientData) /* Information about widget. */
30103007 {
3011 register TkText *textPtr = clientData;
3008 TkText *textPtr = (TkText *)clientData;
30123009 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
30133010 int lineNum;
30143011
31563153 */
31573154
31583155 if (!tkTextDebug) {
3159 FORCE_DISPLAY(textPtr->tkwin);
3156 TkpRedrawWidget(textPtr->tkwin);
31603157 }
31613158
31623159 if (NewSyncState != OldSyncState) {
31653162 } else {
31663163 textPtr->dInfoPtr->flags |= OUT_OF_SYNC;
31673164 }
3168 TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
3169 Tcl_NewBooleanObj(NewSyncState));
3165 TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
3166 Tcl_NewBooleanObj(NewSyncState));
31703167 }
31713168 }
31723169
41654162 DisplayText(
41664163 ClientData clientData) /* Information about widget. */
41674164 {
4168 register TkText *textPtr = clientData;
4165 TkText *textPtr = (TkText *)clientData;
41694166 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
4170 register DLine *dlPtr;
4167 DLine *dlPtr;
41714168 DLine *prevPtr;
41724169 Pixmap pixmap;
41734170 int maxHeight, borders;
41754172 * warnings. */
41764173 Tcl_Interp *interp;
41774174
4175
4176 if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
4177 /*
4178 * The widget has been deleted. Don't do anything.
4179 */
4180
4181 return;
4182 }
4183
41784184 #ifdef MAC_OSX_TK
41794185 /*
4180 * If drawing is disabled, all we need to do is
4181 * clear the REDRAW_PENDING flag.
4182 */
4186 * If the toplevel is being resized it would be dangerous to try redrawing
4187 * the widget. But we can just clear the REDRAW_PENDING flag and return.
4188 * This display proc will be called again after the widget has been
4189 * reconfigured.
4190 */
4191
41834192 TkWindow *winPtr = (TkWindow *)(textPtr->tkwin);
41844193 MacDrawable *macWin = winPtr->privatePtr;
41854194 if (macWin && (macWin->flags & TK_DO_NOT_DRAW)){
41884197 }
41894198 #endif
41904199
4191 if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
4192 /*
4193 * The widget has been deleted. Don't do anything.
4194 */
4195
4196 return;
4197 }
4198
41994200 interp = textPtr->interp;
42004201 Tcl_Preserve(interp);
42014202
42514252 */
42524253
42534254 for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) {
4254 register DLine *dlPtr2;
4255 DLine *dlPtr2;
42554256 int offset, height, y, oldY;
42564257 TkRegion damageRgn;
42574258
45494550 * proc of embedded windows only.
45504551 */
45514552 #endif
4552 register TkTextDispChunk *chunkPtr;
4553 TkTextDispChunk *chunkPtr;
45534554
45544555 for (chunkPtr = dlPtr->chunkPtr; (chunkPtr != NULL);
45554556 chunkPtr = chunkPtr->nextPtr) {
47514752 TkText *textPtr, /* Widget record for text widget. */
47524753 TkRegion region) /* Region of area to redraw. */
47534754 {
4754 register DLine *dlPtr;
4755 DLine *dlPtr;
47554756 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
47564757 int maxY, inset;
47574758 XRectangle rect;
50095010 int withTag) /* 1 means redraw characters that have the
50105011 * tag, 0 means redraw those without. */
50115012 {
5012 register DLine *dlPtr;
5013 DLine *dlPtr;
50135014 DLine *endPtr;
50145015 int tagOn;
50155016 TkTextSearch search;
52725273
52735274 /*
52745275 * Invalidate cached scrollbar positions, so that scrollbars sliders will
5275 * be udpated.
5276 * be updated.
52765277 */
52775278
52785279 dInfoPtr->xScrollFirst = dInfoPtr->xScrollLast = -1;
53495350 * are to be off the top of the screen. */
53505351 {
53515352 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
5352 register DLine *dlPtr;
5353 DLine *dlPtr;
53535354 int bottomY, close, lineIndex;
53545355 TkTextIndex tmpIndex, rounded;
53555356 int lineHeight;
61776178
61786179 pickPlace = 0;
61796180 if (Tcl_GetString(objv[2])[0] == '-') {
6180 register const char *switchStr =
6181 const char *switchStr =
61816182 Tcl_GetStringFromObj(objv[2], &switchLength);
61826183
61836184 if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace",
63556356
63566357 int
63576358 TkTextScanCmd(
6358 register TkText *textPtr, /* Information about text widget. */
6359 TkText *textPtr, /* Information about text widget. */
63596360 Tcl_Interp *interp, /* Current interpreter. */
63606361 int objc, /* Number of arguments. */
63616362 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
65246525 Tcl_DStringAppend(&buf, textPtr->xScrollCmd, -1);
65256526 Tcl_DStringAppend(&buf, buf1, -1);
65266527 Tcl_DStringAppend(&buf, buf2, -1);
6527 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
6528 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
65286529 Tcl_DStringFree(&buf);
65296530 if (code != TCL_OK) {
65306531 Tcl_AddErrorInfo(interp,
68096810 Tcl_DStringAppend(&buf, textPtr->yScrollCmd, -1);
68106811 Tcl_DStringAppend(&buf, buf1, -1);
68116812 Tcl_DStringAppend(&buf, buf2, -1);
6812 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
6813 code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
68136814 Tcl_DStringFree(&buf);
68146815 if (code != TCL_OK) {
68156816 Tcl_AddErrorInfo(interp,
68416842 AsyncUpdateYScrollbar(
68426843 ClientData clientData) /* Information about widget. */
68436844 {
6844 register TkText *textPtr = clientData;
6845 TkText *textPtr = (TkText *)clientData;
68456846
68466847 textPtr->dInfoPtr->scrollbarTimer = NULL;
68476848
68766877 static DLine *
68776878 FindDLine(
68786879 TkText *textPtr, /* Widget record for text widget. */
6879 register DLine *dlPtr, /* Pointer to first in list of DLines to
6880 DLine *dlPtr, /* Pointer to first in list of DLines to
68806881 * search. */
68816882 const TkTextIndex *indexPtr)/* Index of desired character. */
68826883 {
70467047 * border of the widget). */
70477048 {
70487049 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
7049 register DLine *dlPtr, *validDlPtr;
7050 DLine *dlPtr, *validDlPtr;
70507051 int nearby = 0;
70517052
70527053 /*
71487149 * the character nearest to x. */
71497150 {
71507151 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
7151 register TkTextDispChunk *chunkPtr;
7152 TkTextDispChunk *chunkPtr;
71527153
71537154 /*
71547155 * Scan through the line's chunks to find the one that contains the
72767277 int byteIndex) /* The byte index for which we want the
72777278 * coordinate. */
72787279 {
7279 register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
7280 TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
72807281 int x = 0;
72817282
72827283 if (byteIndex == 0 || chunkPtr == NULL) {
73467347 {
73477348 TextDInfo *dInfoPtr = textPtr->dInfoPtr;
73487349 DLine *dlPtr;
7349 register TkTextDispChunk *chunkPtr;
7350 TkTextDispChunk *chunkPtr;
73507351 int byteCount;
73517352
73527353 /*
75387539
75397540 static void
75407541 ElideBboxProc(
7541 TkText *textPtr,
7542 TCL_UNUSED(TkText *),
75427543 TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
7543 int index, /* Index of desired character within the
7544 TCL_UNUSED(int), /* Index of desired character within the
75447545 * chunk. */
75457546 int y, /* Topmost pixel in area allocated for this
75467547 * line. */
7547 int lineHeight, /* Height of line, in pixels. */
7548 int baseline, /* Location of line's baseline, in pixels
7548 TCL_UNUSED(int), /* Height of line, in pixels. */
7549 TCL_UNUSED(int), /* Location of line's baseline, in pixels
75497550 * measured down from y. */
75507551 int *xPtr, int *yPtr, /* Gets filled in with coords of character's
75517552 * upper-left pixel. X-coord is in same
75667567
75677568 static int
75687569 ElideMeasureProc(
7569 TkTextDispChunk *chunkPtr, /* Chunk containing desired coord. */
7570 int x) /* X-coordinate, in same coordinate system as
7570 TCL_UNUSED(TkTextDispChunk *), /* Chunk containing desired coord. */
7571 TCL_UNUSED(int)) /* X-coordinate, in same coordinate system as
75717572 * chunkPtr->x. */
75727573 {
75737574 return 0 /*chunkPtr->numBytes - 1*/;
75967597
75977598 int
75987599 TkTextCharLayoutProc(
7599 TkText *textPtr, /* Text widget being layed out. */
7600 TkTextIndex *indexPtr, /* Index of first character to lay out
7600 TCL_UNUSED(TkText *), /* Text widget being layed out. */
7601 TCL_UNUSED(TkTextIndex *), /* Index of first character to lay out
76017602 * (corresponds to segPtr and offset). */
76027603 TkTextSegment *segPtr, /* Segment being layed out. */
76037604 int byteOffset, /* Byte offset within segment of first
76117612 TkWrapMode wrapMode, /* How to handle line wrapping:
76127613 * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
76137614 * TEXT_WRAPMODE_WORD. */
7614 register TkTextDispChunk *chunkPtr)
7615 TkTextDispChunk *chunkPtr)
76157616 /* Structure to fill in with information about
76167617 * this chunk. The x field has already been
76177618 * set by the caller. */
77627763 chunkPtr->breakIndex = -1;
77637764
77647765 #if !TK_LAYOUT_WITH_BASE_CHUNKS
7765 ciPtr = ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit);
7766 ciPtr = (CharInfo *)ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit);
77667767 chunkPtr->clientData = ciPtr;
7767 memcpy(ciPtr->chars, p, (unsigned) bytesThatFit);
7768 memcpy(ciPtr->chars, p, bytesThatFit);
77687769 #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
77697770
77707771 ciPtr->numBytes = bytesThatFit;
78757876 * here. */
78767877 {
78777878 Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont;
7878 CharInfo *ciPtr = chunkPtr->clientData;
7879 CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
78797880
78807881 #if !TK_LAYOUT_WITH_BASE_CHUNKS
78817882 if (chars == NULL) {
79507951
79517952 static void
79527953 CharDisplayProc(
7953 TkText *textPtr,
7954 TCL_UNUSED(TkText *),
79547955 TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */
79557956 int x, /* X-position in dst at which to draw this
79567957 * chunk (may differ from the x-position in
79577958 * the chunk because of scrolling). */
79587959 int y, /* Y-position at which to draw this chunk in
79597960 * dst. */
7960 int height, /* Total height of line. */
7961 TCL_UNUSED(int), /* Total height of line. */
79617962 int baseline, /* Offset of baseline from y. */
79627963 Display *display, /* Display to use for drawing. */
79637964 Drawable dst, /* Pixmap or window in which to draw chunk. */
7964 int screenY) /* Y-coordinate in text window that
7965 TCL_UNUSED(int)) /* Y-coordinate in text window that
79657966 * corresponds to y. */
79667967 {
7967 CharInfo *ciPtr = chunkPtr->clientData;
7968 CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
79687969 const char *string;
79697970 TextStyle *stylePtr;
79707971 StyleValues *sValuePtr;
81128113
81138114 static void
81148115 CharUndisplayProc(
8115 TkText *textPtr, /* Overall information about text widget. */
8116 TCL_UNUSED(TkText *), /* Overall information about text widget. */
81168117 TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
81178118 {
8118 CharInfo *ciPtr = chunkPtr->clientData;
8119 CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
81198120
81208121 if (ciPtr) {
81218122 #if TK_LAYOUT_WITH_BASE_CHUNKS
82018202
82028203 static void
82038204 CharBboxProc(
8204 TkText *textPtr,
8205 TCL_UNUSED(TkText *),
82058206 TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
82068207 int byteIndex, /* Byte offset of desired character within the
82078208 * chunk. */
82088209 int y, /* Topmost pixel in area allocated for this
82098210 * line. */
8210 int lineHeight, /* Height of line, in pixels. */
8211 TCL_UNUSED(int), /* Height of line, in pixels. */
82118212 int baseline, /* Location of line's baseline, in pixels
82128213 * measured down from y. */
82138214 int *xPtr, int *yPtr, /* Gets filled in with coords of character's
82188219 int *heightPtr) /* Gets filled in with height of character, in
82198220 * pixels. */
82208221 {
8221 CharInfo *ciPtr = chunkPtr->clientData;
8222 CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
82228223 int maxX;
82238224
82248225 maxX = chunkPtr->width + chunkPtr->x;
83818382 if (chunkPtr2->displayProc != CharDisplayProc) {
83828383 continue;
83838384 }
8384 ciPtr = chunkPtr2->clientData;
8385 ciPtr = (CharInfo *)chunkPtr2->clientData;
83858386 for (p = ciPtr->chars, i = 0; i < ciPtr->numBytes; p++, i++) {
83868387 if (isdigit(UCHAR(*p))) {
83878388 gotDigit = 1;
84028403 if (decimalChunkPtr != NULL) {
84038404 int curX;
84048405
8405 ciPtr = decimalChunkPtr->clientData;
8406 ciPtr = (CharInfo *)decimalChunkPtr->clientData;
84068407 CharChunkMeasureChars(decimalChunkPtr, NULL, 0, 0, decimal,
84078408 decimalChunkPtr->x, -1, 0, &curX);
84088409 desired = tabX - (curX - x);
86738674 int curX, width, ch;
86748675 const char *special, *end, *start;
86758676
8676 ch = 0; /* lint. */
8677 ch = 0;
86778678 curX = startX;
86788679 start = source + rangeStart;
86798680 end = start + rangeLength;
88088809 }
88098810 switch ((enum viewUnits) index) {
88108811 case VIEW_SCROLL_PAGES:
8811 if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) {
8812 return TKTEXT_SCROLL_ERROR;
8813 }
8814 return TKTEXT_SCROLL_PAGES;
8812 if (Tcl_GetIntFromObj(interp, objv[3], intPtr) == TCL_OK) {
8813 return TKTEXT_SCROLL_PAGES;
8814 }
8815 break;
88158816 case VIEW_SCROLL_PIXELS:
88168817 if (Tk_GetPixelsFromObj(interp, textPtr->tkwin, objv[3],
8817 intPtr) != TCL_OK) {
8818 return TKTEXT_SCROLL_ERROR;
8819 }
8820 return TKTEXT_SCROLL_PIXELS;
8818 intPtr) == TCL_OK) {
8819 return TKTEXT_SCROLL_PIXELS;
8820 }
8821 break;
88218822 case VIEW_SCROLL_UNITS:
8822 if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) {
8823 return TKTEXT_SCROLL_ERROR;
8824 }
8825 return TKTEXT_SCROLL_UNITS;
8826 }
8827 }
8828 Tcl_Panic("unexpected switch fallthrough");
8823 if (Tcl_GetIntFromObj(interp, objv[3], intPtr) == TCL_OK) {
8824 return TKTEXT_SCROLL_UNITS;
8825 }
8826 break;
8827 default:
8828 Tcl_Panic("unexpected switch fallthrough");
8829 }
8830 }
88298831 return TKTEXT_SCROLL_ERROR;
88308832 }
88318833
1717 */
1818
1919 #define EI_SEG_SIZE \
20 ((unsigned) (Tk_Offset(TkTextSegment, body) + sizeof(TkTextEmbImage)))
20 ((unsigned)(Tk_Offset(TkTextSegment, body) + sizeof(TkTextEmbImage)))
2121
2222 /*
2323 * Prototypes for functions defined in this file:
116116
117117 int
118118 TkTextImageCmd(
119 register TkText *textPtr, /* Information about text widget. */
119 TkText *textPtr, /* Information about text widget. */
120120 Tcl_Interp *interp, /* Current interpreter. */
121121 int objc, /* Number of arguments. */
122122 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
124124 * objv[1] is "image". */
125125 {
126126 int idx;
127 register TkTextSegment *eiPtr;
127 TkTextSegment *eiPtr;
128128 TkTextIndex index;
129129 static const char *const optionStrings[] = {
130130 "cget", "configure", "create", "names", NULL
160160 Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL);
161161 return TCL_ERROR;
162162 }
163 objPtr = Tk_GetOptionValue(interp, (char *) &eiPtr->body.ei,
163 objPtr = Tk_GetOptionValue(interp, (char *)&eiPtr->body.ei,
164164 eiPtr->body.ei.optionTable, objv[4], textPtr->tkwin);
165165 if (objPtr == NULL) {
166166 return TCL_ERROR;
187187 }
188188 if (objc <= 5) {
189189 Tcl_Obj *objPtr = Tk_GetOptionInfo(interp,
190 (char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable,
190 (char *)&eiPtr->body.ei, eiPtr->body.ei.optionTable,
191191 (objc == 5) ? objv[4] : NULL, textPtr->tkwin);
192192
193193 if (objPtr == NULL) {
241241 * Create the new image segment and initialize it.
242242 */
243243
244 eiPtr = ckalloc(EI_SEG_SIZE);
244 eiPtr = (TkTextSegment *)ckalloc(EI_SEG_SIZE);
245245 eiPtr->typePtr = &tkTextEmbImageType;
246246 eiPtr->size = 1;
247247 eiPtr->body.ei.sharedTextPtr = textPtr->sharedTextPtr;
278278 Tcl_HashEntry *hPtr;
279279 Tcl_Obj *resultObj;
280280
281 if (objc != 3) {
282 Tcl_WrongNumArgs(interp, 3, objv, NULL);
283 return TCL_ERROR;
284 }
285 resultObj = Tcl_NewObj();
286 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
287 &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
288 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
289 Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
290 -1));
291 }
292 Tcl_SetObjResult(interp, resultObj);
293 return TCL_OK;
281 if (objc == 3) {
282 resultObj = Tcl_NewObj();
283 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
284 &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
285 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
286 Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1));
287 }
288 Tcl_SetObjResult(interp, resultObj);
289 return TCL_OK;
290 }
291 Tcl_WrongNumArgs(interp, 3, objv, NULL);
292 break;
294293 }
295294 default:
296295 Tcl_Panic("unexpected switch fallthrough");
336335 int conflict = 0; /* True if we have a name conflict */
337336 size_t len; /* length of image name */
338337
339 if (Tk_SetOptions(textPtr->interp, (char *) &eiPtr->body.ei,
338 if (Tk_SetOptions(textPtr->interp, (char *)&eiPtr->body.ei,
340339 eiPtr->body.ei.optionTable,
341340 objc, objv, textPtr->tkwin, NULL, NULL) != TCL_OK) {
342341 return TCL_ERROR;
388387 len = strlen(name);
389388 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
390389 &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
391 char *haveName =
390 char *haveName = (char *)
392391 Tcl_GetHashKey(&textPtr->sharedTextPtr->imageTable, hPtr);
393392
394393 if (strncmp(name, haveName, len) == 0) {
418417 &dummy);
419418 Tcl_SetHashValue(hPtr, eiPtr);
420419 Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(name, -1));
421 eiPtr->body.ei.name = ckalloc(Tcl_DStringLength(&newName) + 1);
420 eiPtr->body.ei.name = (char *)ckalloc(Tcl_DStringLength(&newName) + 1);
422421 strcpy(eiPtr->body.ei.name, name);
423422 Tcl_DStringFree(&newName);
424423
443442 *--------------------------------------------------------------
444443 */
445444
446 /* ARGSUSED */
447445 static int
448446 EmbImageDeleteProc(
449447 TkTextSegment *eiPtr, /* Segment being deleted. */
450 TkTextLine *linePtr, /* Line containing segment. */
451 int treeGone) /* Non-zero means the entire tree is being
448 TCL_UNUSED(TkTextLine *), /* Line containing segment. */
449 TCL_UNUSED(int)) /* Non-zero means the entire tree is being
452450 * deleted, so everything must get cleaned
453451 * up. */
454452 {
526524 *--------------------------------------------------------------
527525 */
528526
529 /*ARGSUSED*/
530527 static int
531528 EmbImageLayoutProc(
532529 TkText *textPtr, /* Text widget being layed out. */
533 TkTextIndex *indexPtr, /* Identifies first character in chunk. */
530 TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
534531 TkTextSegment *eiPtr, /* Segment corresponding to indexPtr. */
535532 int offset, /* Offset within segPtr corresponding to
536533 * indexPtr (always 0). */
537534 int maxX, /* Chunk must not occupy pixels at this
538535 * position or higher. */
539 int maxChars, /* Chunk must not include more than this many
536 TCL_UNUSED(int), /* Chunk must not include more than this many
540537 * characters. */
541538 int noCharsYet, /* Non-zero means no characters have been
542539 * assigned to this line yet. */
543 TkWrapMode wrapMode, /* Wrap mode to use for line:
540 TCL_UNUSED(TkWrapMode), /* Wrap mode to use for line:
544541 * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
545542 * TEXT_WRAPMODE_WORD. */
546 register TkTextDispChunk *chunkPtr)
543 TkTextDispChunk *chunkPtr)
547544 /* Structure to fill in with information about
548545 * this chunk. The x field has already been
549546 * set by the caller. */
618615 static void
619616 EmbImageCheckProc(
620617 TkTextSegment *eiPtr, /* Segment to check. */
621 TkTextLine *linePtr) /* Line containing segment. */
618 TCL_UNUSED(TkTextLine *)) /* Line containing segment. */
622619 {
623620 if (eiPtr->nextPtr == NULL) {
624621 Tcl_Panic("EmbImageCheckProc: embedded image is last segment in line");
659656 * (x-position is in the chunk itself). */
660657 int lineHeight, /* Total height of line. */
661658 int baseline, /* Offset of baseline from y. */
662 Display *display, /* Display to use for drawing. */
659 TCL_UNUSED(Display *), /* Display to use for drawing. */
663660 Drawable dst, /* Pixmap or window in which to draw */
664 int screenY) /* Y-coordinate in text window that
661 TCL_UNUSED(int)) /* Y-coordinate in text window that
665662 * corresponds to y. */
666663 {
667 TkTextSegment *eiPtr = chunkPtr->clientData;
664 TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData;
668665 int lineX, imageX, imageY, width, height;
669666 Tk_Image image;
670667
712709
713710 static void
714711 EmbImageBboxProc(
715 TkText *textPtr,
712 TCL_UNUSED(TkText *),
716713 TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
717 int index, /* Index of desired character within the
714 TCL_UNUSED(int), /* Index of desired character within the
718715 * chunk. */
719716 int y, /* Topmost pixel in area allocated for this
720717 * line. */
728725 int *heightPtr) /* Gets filled in with height of image, in
729726 * pixels. */
730727 {
731 TkTextSegment *eiPtr = chunkPtr->clientData;
728 TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData;
732729 Tk_Image image;
733730
734731 image = eiPtr->body.ei.image;
793790 if (hPtr == NULL) {
794791 return 0;
795792 }
796 eiPtr = Tcl_GetHashValue(hPtr);
793 eiPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
797794 indexPtr->tree = textPtr->sharedTextPtr->tree;
798795 indexPtr->linePtr = eiPtr->body.ei.linePtr;
799796 indexPtr->byteIndex = TkTextSegToOffset(eiPtr, indexPtr->linePtr);
820817 static void
821818 EmbImageProc(
822819 ClientData clientData, /* Pointer to widget record. */
823 int x, int y, /* Upper left pixel (within image) that must
820 TCL_UNUSED(int), /* Upper left pixel (within image) that must
824821 * be redisplayed. */
825 int width, int height, /* Dimensions of area to redisplay (may be
822 TCL_UNUSED(int),
823 TCL_UNUSED(int), /* Dimensions of area to redisplay (may be
826824 * <= 0). */
827 int imgWidth, int imgHeight)/* New dimensions of image. */
828
829 {
830 TkTextSegment *eiPtr = clientData;
825 TCL_UNUSED(int),
826 TCL_UNUSED(int),/* New dimensions of image. */
827 TCL_UNUSED(int))
828
829 {
830 TkTextSegment *eiPtr = (TkTextSegment *)clientData;
831831 TkTextIndex index;
832832
833833 index.tree = eiPtr->body.ei.sharedTextPtr->tree;
1010 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1111 */
1212
13 #include "default.h"
1413 #include "tkInt.h"
1514 #include "tkText.h"
15 #include "default.h"
1616
1717 /*
1818 * Index to use to select last character in line (very large integer):
6161 #define GET_INDEXEPOCH(objPtr) \
6262 (PTR2INT((objPtr)->internalRep.twoPtrValue.ptr2))
6363 #define SET_TEXTINDEX(objPtr, indexPtr) \
64 ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (indexPtr))
64 ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(indexPtr))
6565 #define SET_INDEXEPOCH(objPtr, epoch) \
6666 ((objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(epoch))
6767
106106 int epoch;
107107 TkTextIndex *dupIndexPtr, *indexPtr;
108108
109 dupIndexPtr = ckalloc(sizeof(TkTextIndex));
109 dupIndexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
110110 indexPtr = GET_TEXTINDEX(srcPtr);
111111 epoch = GET_INDEXEPOCH(srcPtr);
112112
138138
139139 len = TkTextPrintIndex(indexPtr->textPtr, indexPtr, buffer);
140140
141 objPtr->bytes = ckalloc(len + 1);
141 objPtr->bytes = (char *)ckalloc(len + 1);
142142 strcpy(objPtr->bytes, buffer);
143143 objPtr->length = len;
144144 }
175175 * position. */
176176 const TkTextIndex *origPtr) /* Pointer to index. */
177177 {
178 TkTextIndex *indexPtr = ckalloc(sizeof(TkTextIndex));
178 TkTextIndex *indexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
179179
180180 indexPtr->tree = origPtr->tree;
181181 indexPtr->linePtr = origPtr->linePtr;
435435 */
436436
437437 start = segPtr->body.chars + (byteIndex - index);
438 p = Tcl_UtfPrev(start, segPtr->body.chars);
438 p = TkUtfPrev(start, segPtr->body.chars);
439439 p += TkUtfToUniChar(p, &ch);
440440 indexPtr->byteIndex += p - start;
441441 }
476476 int charIndex, /* Index of desired character. */
477477 TkTextIndex *indexPtr) /* Structure to fill in. */
478478 {
479 register TkTextSegment *segPtr;
479 TkTextSegment *segPtr;
480480 char *p, *start, *end;
481481 int index, offset;
482482 int ch;
815815 hPtr = Tcl_FindHashEntry(&sharedPtr->tagTable, tagName);
816816 *p = '.';
817817 if (hPtr != NULL) {
818 tagPtr = Tcl_GetHashValue(hPtr);
818 tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
819819 }
820820 }
821821
831831 if (tagPtr == textPtr->selTagPtr) {
832832 tagName = "sel";
833833 } else if (hPtr != NULL) {
834 tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr);
834 tagName = (const char *)Tcl_GetHashKey(&sharedPtr->tagTable, hPtr);
835835 }
836836 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
837837 "text doesn't contain any characters tagged with \"%s\"",
922922 }
923923 if ((string[0] == 'e')
924924 && (strncmp(string, "end",
925 (size_t) (endOfBase-Tcl_DStringValue(&copy))) == 0)) {
925 endOfBase-Tcl_DStringValue(&copy)) == 0)) {
926926 /*
927927 * Base position is end of text.
928928 */
11501150 * or "-" that starts modifier. */
11511151 TkTextIndex *indexPtr) /* Index to update as specified in string. */
11521152 {
1153 register const char *p, *units;
1153 const char *p, *units;
11541154 char *end;
11551155 int count, lineIndex, modifier;
11561156 size_t length;
14981498 return;
14991499 }
15001500 if (checkElided) {
1501 infoPtr = ckalloc(sizeof(TkTextElideInfo));
1501 infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
15021502 elide = TkTextIsElided(textPtr, srcPtr, infoPtr);
15031503 }
15041504
15961596 charCount--;
15971597 }
15981598 } else if (type & COUNT_INDICES) {
1599 if (charCount < segPtr->size - byteOffset) {
1599 if (charCount + byteOffset < segPtr->size) {
16001600 dstPtr->byteIndex += charCount;
16011601 goto forwardCharDone;
16021602 }
17661766 seg2Ptr = TkTextIndexToSeg(indexPtr2, &maxBytes);
17671767
17681768 if (checkElided) {
1769 infoPtr = ckalloc(sizeof(TkTextElideInfo));
1769 infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
17701770 elide = TkTextIsElided(textPtr, indexPtr1, infoPtr);
17711771 }
17721772
18431843
18441844 if (segPtr->typePtr == &tkTextCharType) {
18451845 int byteLen = segPtr->size - byteOffset;
1846 register unsigned char *str = (unsigned char *)
1846 unsigned char *str = (unsigned char *)
18471847 segPtr->body.chars + byteOffset;
1848 register int i;
1848 int i;
18491849
18501850 if (segPtr == seg2Ptr) {
1851 if (byteLen > (maxBytes - byteOffset)) {
1851 if (byteLen + byteOffset > maxBytes) {
18521852 byteLen = maxBytes - byteOffset;
18531853 }
18541854 }
18781878 int byteLen = segPtr->size - byteOffset;
18791879
18801880 if (segPtr == seg2Ptr) {
1881 if (byteLen > (maxBytes - byteOffset)) {
1881 if (byteLen + byteOffset > maxBytes) {
18821882 byteLen = maxBytes - byteOffset;
18831883 }
18841884 }
20242024 return;
20252025 }
20262026 if (checkElided) {
2027 infoPtr = ckalloc(sizeof(TkTextElideInfo));
2027 infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
20282028 elide = TkTextIsElided(textPtr, srcPtr, infoPtr);
20292029 }
20302030
21242124 if (segPtr->typePtr == &tkTextCharType) {
21252125 start = segPtr->body.chars;
21262126 end = segPtr->body.chars + segSize;
2127 for (p = end; ; p = Tcl_UtfPrev(p, start)) {
2127 for (p = end; ; p = TkUtfPrev(p, start)) {
21282128 if (charCount == 0) {
21292129 dstPtr->byteIndex -= (end - p);
21302130 goto backwardCharDone;
22242224 {
22252225 const char *p;
22262226 size_t length;
2227 register TkTextSegment *segPtr;
2227 TkTextSegment *segPtr;
22282228 int modifier;
22292229
22302230 /*
23652365 }
23662366 if (offset > 0) {
23672367 chSize = (segPtr->body.chars + offset
2368 - Tcl_UtfPrev(segPtr->body.chars + offset,
2368 - TkUtfPrev(segPtr->body.chars + offset,
23692369 segPtr->body.chars));
23702370 }
23712371 firstChar = 0;
1818 * Macro that determines the size of a mark segment:
1919 */
2020
21 #define MSEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \
21 #define MSEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
2222 + sizeof(TkTextMark)))
2323
2424 /*
9292
9393 int
9494 TkTextMarkCmd(
95 register TkText *textPtr, /* Information about text widget. */
95 TkText *textPtr, /* Information about text widget. */
9696 Tcl_Interp *interp, /* Current interpreter. */
9797 int objc, /* Number of arguments. */
9898 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
146146 NULL);
147147 return TCL_ERROR;
148148 }
149 markPtr = Tcl_GetHashValue(hPtr);
149 markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
150150 }
151151 if (objc == 4) {
152152 const char *typeStr;
161161 }
162162 str = Tcl_GetStringFromObj(objv[4],&length);
163163 c = str[0];
164 if ((c == 'l') && (strncmp(str, "left", (unsigned) length) == 0)) {
164 if ((c == 'l') && (strncmp(str, "left", length) == 0)) {
165165 newTypePtr = &tkTextLeftMarkType;
166166 } else if ((c == 'r') &&
167 (strncmp(str, "right", (unsigned) length) == 0)) {
167 (strncmp(str, "right", length) == 0)) {
168168 newTypePtr = &tkTextRightMarkType;
169169 } else {
170170 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
193193 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->markTable,
194194 &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
195195 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
196 Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
196 (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
197197 -1));
198198 }
199199 Tcl_SetObjResult(interp, resultObj);
228228 hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable,
229229 Tcl_GetString(objv[i]));
230230 if (hPtr != NULL) {
231 markPtr = Tcl_GetHashValue(hPtr);
231 markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
232232
233233 /*
234234 * Special case not needed with peer widgets.
289289 widgetSpecific = 0;
290290 hPtr = Tcl_CreateHashEntry(&textPtr->sharedTextPtr->markTable, name,
291291 &isNew);
292 markPtr = Tcl_GetHashValue(hPtr);
292 markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
293293 }
294294 if (!isNew) {
295295 /*
329329 }
330330 TkBTreeUnlinkSegment(markPtr, markPtr->body.mark.linePtr);
331331 } else {
332 markPtr = ckalloc(MSEG_SIZE);
332 markPtr = (TkTextSegment *)ckalloc(MSEG_SIZE);
333333 markPtr->typePtr = &tkTextRightMarkType;
334334 markPtr->size = 0;
335335 markPtr->body.mark.textPtr = textPtr;
451451 if (hPtr == NULL) {
452452 return TCL_ERROR;
453453 }
454 segPtr = Tcl_GetHashValue(hPtr);
454 segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
455455 }
456456 TkTextMarkSegToIndex(textPtr, segPtr, indexPtr);
457457
498498 *--------------------------------------------------------------
499499 */
500500
501 /* ARGSUSED */
502501 static int
503502 MarkDeleteProc(
504 TkTextSegment *segPtr, /* Segment being deleted. */
505 TkTextLine *linePtr, /* Line containing segment. */
506 int treeGone) /* Non-zero means the entire tree is being
503 TCL_UNUSED(TkTextSegment *), /* Segment being deleted. */
504 TCL_UNUSED(TkTextLine *), /* Line containing segment. */
505 TCL_UNUSED(int)) /* Non-zero means the entire tree is being
507506 * deleted, so everything must get cleaned
508507 * up. */
509508 {
558557 static int
559558 MarkLayoutProc(
560559 TkText *textPtr, /* Text widget being layed out. */
561 TkTextIndex *indexPtr, /* Identifies first character in chunk. */
560 TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
562561 TkTextSegment *segPtr, /* Segment corresponding to indexPtr. */
563 int offset, /* Offset within segPtr corresponding to
562 TCL_UNUSED(int), /* Offset within segPtr corresponding to
564563 * indexPtr (always 0). */
565 int maxX, /* Chunk must not occupy pixels at this
564 TCL_UNUSED(int), /* Chunk must not occupy pixels at this
566565 * position or higher. */
567 int maxChars, /* Chunk must not include more than this many
566 TCL_UNUSED(int), /* Chunk must not include more than this many
568567 * characters. */
569 int noCharsYet, /* Non-zero means no characters have been
568 TCL_UNUSED(int), /* Non-zero means no characters have been
570569 * assigned to this line yet. */
571 TkWrapMode wrapMode, /* Not used. */
572 register TkTextDispChunk *chunkPtr)
570 TCL_UNUSED(TkWrapMode), /* Not used. */
571 TkTextDispChunk *chunkPtr)
573572 /* Structure to fill in with information about
574573 * this chunk. The x field has already been
575574 * set by the caller. */
614613 *--------------------------------------------------------------
615614 */
616615
617 /* ARGSUSED */
618616 void
619617 TkTextInsertDisplayProc(
620618 TkText *textPtr, /* The current text widget. */
621 TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */
619 TCL_UNUSED(TkTextDispChunk *), /* Chunk that is to be drawn. */
622620 int x, /* X-position in dst at which to draw this
623621 * chunk (may differ from the x-position in
624622 * the chunk because of scrolling). */
625623 int y, /* Y-position at which to draw this chunk in
626624 * dst (x-position is in the chunk itself). */
627625 int height, /* Total height of line. */
628 int baseline, /* Offset of baseline from y. */
629 Display *display, /* Display to use for drawing. */
626 TCL_UNUSED(int), /* Offset of baseline from y. */
627 TCL_UNUSED(Display *), /* Display to use for drawing. */
630628 Drawable dst, /* Pixmap or window in which to draw chunk. */
631629 int screenY) /* Y-coordinate in text window that
632630 * corresponds to y. */
720718 *--------------------------------------------------------------
721719 */
722720
723 /* ARGSUSED */
724721 static void
725722 InsertUndisplayProc(
726 TkText *textPtr, /* Overall information about text widget. */
727 TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
723 TCL_UNUSED(TkText *), /* Overall information about text widget. */
724 TCL_UNUSED(TkTextDispChunk *)) /* Chunk that is about to be freed. */
728725 {
729726 return;
730727 }
808805 {
809806 TkTextIndex index;
810807 Tcl_HashEntry *hPtr;
811 register TkTextSegment *segPtr;
808 TkTextSegment *segPtr;
812809 int offset;
813810 const char *string = Tcl_GetString(obj);
814811
829826 * position.
830827 */
831828
832 segPtr = Tcl_GetHashValue(hPtr);
829 segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
833830 TkTextMarkSegToIndex(textPtr, segPtr, &index);
834831 segPtr = segPtr->nextPtr;
835832 } else {
899896 {
900897 TkTextIndex index;
901898 Tcl_HashEntry *hPtr;
902 register TkTextSegment *segPtr, *seg2Ptr, *prevPtr;
899 TkTextSegment *segPtr, *seg2Ptr, *prevPtr;
903900 int offset;
904901 const char *string = Tcl_GetString(obj);
905902
918915 * position.
919916 */
920917
921 segPtr = Tcl_GetHashValue(hPtr);
918 segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
922919 TkTextMarkSegToIndex(textPtr, segPtr, &index);
923920 } else {
924921 /*
10111008
10121009 return NULL;
10131010 } else {
1014 markName = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
1011 markName = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
10151012 segPtr->body.mark.hPtr);
10161013 }
10171014 return Tcl_NewStringObj(markName, -1);
1111 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1212 */
1313
14 #include "default.h"
1514 #include "tkInt.h"
1615 #include "tkText.h"
16 #include "default.h"
1717
1818 /*
1919 * The 'TkWrapMode' enum in tkText.h is used to define a type for the -wrap
136136
137137 int
138138 TkTextTagCmd(
139 register TkText *textPtr, /* Information about text widget. */
139 TkText *textPtr, /* Information about text widget. */
140140 Tcl_Interp *interp, /* Current interpreter. */
141141 int objc, /* Number of arguments. */
142142 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
153153 TAG_REMOVE
154154 };
155155 int optionIndex, i;
156 register TkTextTag *tagPtr;
156 TkTextTag *tagPtr;
157157 TkTextIndex index1, index2;
158158
159159 if (objc < 3) {
342342 if (tagPtr == NULL) {
343343 return TCL_ERROR;
344344 }
345 objPtr = Tk_GetOptionValue(interp, (char *) tagPtr,
345 objPtr = Tk_GetOptionValue(interp, (char *)tagPtr,
346346 tagPtr->optionTable, objv[4], textPtr->tkwin);
347347 if (objPtr == NULL) {
348348 return TCL_ERROR;
361361 }
362362 tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag);
363363 if (objc <= 5) {
364 Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) tagPtr,
364 Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *)tagPtr,
365365 tagPtr->optionTable,
366366 (objc == 5) ? objv[4] : NULL, textPtr->tkwin);
367367
373373 } else {
374374 int result = TCL_OK;
375375
376 if (Tk_SetOptions(interp, (char *) tagPtr, tagPtr->optionTable,
376 if (Tk_SetOptions(interp, (char *)tagPtr, tagPtr->optionTable,
377377 objc-4, objv+4, textPtr->tkwin, NULL, NULL) != TCL_OK) {
378378 return TCL_ERROR;
379379 }
583583
584584 continue;
585585 }
586 tagPtr = Tcl_GetHashValue(hPtr);
586 tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
587587 if (tagPtr == textPtr->selTagPtr) {
588588 continue;
589589 }
644644 Tcl_HashSearch search;
645645 Tcl_HashEntry *hPtr;
646646
647 arrayPtr = ckalloc(textPtr->sharedTextPtr->numTags
647 arrayPtr = (TkTextTag **)ckalloc(textPtr->sharedTextPtr->numTags
648648 * sizeof(TkTextTag *));
649649 for (i=0, hPtr = Tcl_FirstHashEntry(
650650 &textPtr->sharedTextPtr->tagTable, &search);
651651 hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
652 arrayPtr[i] = Tcl_GetHashValue(hPtr);
652 arrayPtr[i] = (TkTextTag *)Tcl_GetHashValue(hPtr);
653653 }
654654
655655 /*
985985 int *newTag) /* If non-NULL, then return 1 if new, or 0 if
986986 * already exists. */
987987 {
988 register TkTextTag *tagPtr;
988 TkTextTag *tagPtr;
989989 Tcl_HashEntry *hPtr = NULL;
990990 int isNew;
991991 const char *name;
10081008 *newTag = isNew;
10091009 }
10101010 if (!isNew) {
1011 return Tcl_GetHashValue(hPtr);
1012 }
1013 name = Tcl_GetHashKey(&textPtr->sharedTextPtr->tagTable, hPtr);
1011 return (TkTextTag *)Tcl_GetHashValue(hPtr);
1012 }
1013 name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->tagTable, hPtr);
10141014 }
10151015
10161016 /*
10181018 * to it to the hash table entry.
10191019 */
10201020
1021 tagPtr = ckalloc(sizeof(TkTextTag));
1021 tagPtr = (TkTextTag *)ckalloc(sizeof(TkTextTag));
10221022 tagPtr->name = name;
10231023 tagPtr->textPtr = NULL;
10241024 tagPtr->toggleCount = 0;
11171117 hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable,
11181118 Tcl_GetString(tagName));
11191119 if (hPtr != NULL) {
1120 return Tcl_GetHashValue(hPtr);
1120 return (TkTextTag *)Tcl_GetHashValue(hPtr);
11211121 }
11221122 if (interp != NULL) {
11231123 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
11571157 void
11581158 TkTextDeleteTag(
11591159 TkText *textPtr, /* Info about overall widget. */
1160 register TkTextTag *tagPtr) /* Tag being deleted. */
1160 TkTextTag *tagPtr) /* Tag being deleted. */
11611161 {
11621162 TkTextIndex first, last;
11631163
12151215 void
12161216 TkTextFreeTag(
12171217 TkText *textPtr, /* Info about overall widget. */
1218 register TkTextTag *tagPtr) /* Tag being deleted. */
1218 TkTextTag *tagPtr) /* Tag being deleted. */
12191219 {
12201220 int i;
12211221
12941294 TkTextTag **tagArrayPtr) /* Pointer to array of pointers. */
12951295 {
12961296 int i, j, prio;
1297 register TkTextTag **tagPtrPtr;
1297 TkTextTag **tagPtrPtr;
12981298 TkTextTag **maxPtrPtr, *tmp;
12991299
13001300 if (numTags < 2) {
13781378 int prio) /* New priority for tag. */
13791379 {
13801380 int low, high, delta;
1381 register TkTextTag *tagPtr2;
1381 TkTextTag *tagPtr2;
13821382 Tcl_HashEntry *hPtr;
13831383 Tcl_HashSearch search;
13841384
14111411 }
14121412 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->tagTable, &search);
14131413 hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
1414 tagPtr2 = Tcl_GetHashValue(hPtr);
1414 tagPtr2 = (TkTextTag *)Tcl_GetHashValue(hPtr);
14151415 if ((tagPtr2->priority >= low) && (tagPtr2->priority <= high)) {
14161416 tagPtr2->priority += delta;
14171417 }
14391439
14401440 void
14411441 TkTextBindProc(
1442 ClientData clientData, /* Pointer to canvas structure. */
1442 ClientData clientData, /* Pointer to text widget structure. */
14431443 XEvent *eventPtr) /* Pointer to X event that just happened. */
14441444 {
1445 TkText *textPtr = clientData;
1445 TkText *textPtr = (TkText *)clientData;
14461446 int repick = 0;
14471447
14481448 textPtr->refCount++;
15281528
15291529 void
15301530 TkTextPickCurrent(
1531 register TkText *textPtr, /* Text widget in which to select current
1531 TkText *textPtr, /* Text widget in which to select current
15321532 * character. */
15331533 XEvent *eventPtr) /* Event describing location of mouse cursor.
15341534 * Must be EnterWindow, LeaveWindow,
16311631 SortTags(textPtr->numCurTags, textPtr->curTagArrayPtr);
16321632 if (numNewTags > 0) {
16331633 size = numNewTags * sizeof(TkTextTag *);
1634 copyArrayPtr = ckalloc(size);
1635 memcpy(copyArrayPtr, newArrayPtr, (size_t) size);
1634 copyArrayPtr = (TkTextTag **)ckalloc(size);
1635 memcpy(copyArrayPtr, newArrayPtr, size);
16361636 for (i = 0; i < textPtr->numCurTags; i++) {
16371637 for (j = 0; j < numNewTags; j++) {
16381638 if (textPtr->curTagArrayPtr[i] == copyArrayPtr[j]) {
17351735 */
17361736
17371737 if (numTags > NUM_BIND_TAGS) {
1738 nameArrPtr = ckalloc(numTags * sizeof(const char *));
1738 nameArrPtr = (const char **)ckalloc(numTags * sizeof(const char *));
17391739 } else {
17401740 nameArrPtr = nameArray;
17411741 }
2121
2222 static void EmbWinRequestProc(ClientData clientData,
2323 Tk_Window tkwin);
24 static void EmbWinLostSlaveProc(ClientData clientData,
24 static void EmbWinLostContentProc(ClientData clientData,
2525 Tk_Window tkwin);
2626
2727 static const Tk_GeomMgr textGeomType = {
2828 "text", /* name */
2929 EmbWinRequestProc, /* requestProc */
30 EmbWinLostSlaveProc, /* lostSlaveProc */
30 EmbWinLostContentProc, /* lostSlaveProc */
3131 };
3232
3333 /*
3434 * Macro that determines the size of an embedded window segment:
3535 */
3636
37 #define EW_SEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \
37 #define EW_SEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
3838 + sizeof(TkTextEmbWindow)))
3939
4040 /*
132132
133133 int
134134 TkTextWindowCmd(
135 register TkText *textPtr, /* Information about text widget. */
135 TkText *textPtr, /* Information about text widget. */
136136 Tcl_Interp *interp, /* Current interpreter. */
137137 int objc, /* Number of arguments. */
138138 Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
146146 enum windOptions {
147147 WIND_CGET, WIND_CONFIGURE, WIND_CREATE, WIND_NAMES
148148 };
149 register TkTextSegment *ewPtr;
149 TkTextSegment *ewPtr;
150150
151151 if (objc < 3) {
152152 Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?");
159159 switch ((enum windOptions) optionIndex) {
160160 case WIND_CGET: {
161161 TkTextIndex index;
162 TkTextSegment *ewPtr;
163162 Tcl_Obj *objPtr;
164163 TkTextEmbWindowClient *client;
165164
190189 ewPtr->body.ew.tkwin = NULL;
191190 }
192191
193 objPtr = Tk_GetOptionValue(interp, (char *) &ewPtr->body.ew,
192 objPtr = Tk_GetOptionValue(interp, (char *)&ewPtr->body.ew,
194193 ewPtr->body.ew.optionTable, objv[4], textPtr->tkwin);
195194 if (objPtr == NULL) {
196195 return TCL_ERROR;
200199 }
201200 case WIND_CONFIGURE: {
202201 TkTextIndex index;
203 TkTextSegment *ewPtr;
204202
205203 if (objc < 4) {
206204 Tcl_WrongNumArgs(interp, 3, objv, "index ?-option value ...?");
232230 ewPtr->body.ew.tkwin = NULL;
233231 }
234232
235 objPtr = Tk_GetOptionInfo(interp, (char *) &ewPtr->body.ew,
233 objPtr = Tk_GetOptionInfo(interp, (char *)&ewPtr->body.ew,
236234 ewPtr->body.ew.optionTable, (objc == 5) ? objv[4] : NULL,
237235 textPtr->tkwin);
238236 if (objPtr == NULL) {
289287 * Create the new window segment and initialize it.
290288 */
291289
292 ewPtr = ckalloc(EW_SEG_SIZE);
290 ewPtr = (TkTextSegment *)ckalloc(EW_SEG_SIZE);
293291 ewPtr->typePtr = &tkTextEmbWindowType;
294292 ewPtr->size = 1;
295293 ewPtr->body.ew.sharedTextPtr = textPtr->sharedTextPtr;
301299 ewPtr->body.ew.stretch = 0;
302300 ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
303301
304 client = ckalloc(sizeof(TkTextEmbWindowClient));
302 client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
305303 client->next = NULL;
306304 client->textPtr = textPtr;
307305 client->tkwin = NULL;
344342 for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->windowTable,
345343 &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
346344 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
347 Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
345 (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
348346 -1));
349347 }
350348 Tcl_SetObjResult(interp, resultObj);
402400 }
403401
404402 oldWindow = ewPtr->body.ew.tkwin;
405 if (Tk_SetOptions(textPtr->interp, (char *) &ewPtr->body.ew,
403 if (Tk_SetOptions(textPtr->interp, (char *)&ewPtr->body.ew,
406404 ewPtr->body.ew.optionTable, objc, objv, textPtr->tkwin, NULL,
407405 NULL) != TCL_OK) {
408406 return TCL_ERROR;
442440 break;
443441 }
444442 if (Tk_TopWinHierarchy(ancestor)) {
445 badMaster:
443 badContainer:
446444 Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf(
447445 "can't embed %s in %s",
448446 Tk_PathName(ewPtr->body.ew.tkwin),
458456 }
459457 if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin)
460458 || (ewPtr->body.ew.tkwin == textPtr->tkwin)) {
461 goto badMaster;
459 goto badContainer;
462460 }
463461
464462 if (client == NULL) {
466464 * Have to make the new client.
467465 */
468466
469 client = ckalloc(sizeof(TkTextEmbWindowClient));
467 client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
470468 client->next = ewPtr->body.ew.clients;
471469 client->textPtr = textPtr;
472470 client->tkwin = NULL;
525523 ClientData clientData, /* Pointer to record describing window item. */
526524 XEvent *eventPtr) /* Describes what just happened. */
527525 {
528 TkTextEmbWindowClient *client = clientData;
526 TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
529527 TkTextSegment *ewPtr = client->parent;
530528 TkTextIndex index;
531529 Tcl_HashEntry *hPtr;
572570 *--------------------------------------------------------------
573571 */
574572
575 /* ARGSUSED */
576573 static void
577574 EmbWinRequestProc(
578575 ClientData clientData, /* Pointer to record for window item. */
579 Tk_Window tkwin) /* Window that changed its desired size. */
580 {
581 TkTextEmbWindowClient *client = clientData;
576 TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
577 {
578 TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
582579 TkTextSegment *ewPtr = client->parent;
583580 TkTextIndex index;
584581
593590 /*
594591 *--------------------------------------------------------------
595592 *
596 * EmbWinLostSlaveProc --
597 *
598 * This function is invoked by the Tk geometry manager when a slave
593 * EmbWinLostContentProc --
594 *
595 * This function is invoked by the Tk geometry manager when a content
599596 * window managed by a text widget is claimed away by another geometry
600597 * manager.
601598 *
610607 */
611608
612609 static void
613 EmbWinLostSlaveProc(
610 EmbWinLostContentProc(
614611 ClientData clientData, /* Pointer to record describing window item. */
615612 Tk_Window tkwin) /* Window that was claimed away by another
616613 * geometry manager. */
617614 {
618 TkTextEmbWindowClient *client = clientData;
615 TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
619616 TkTextSegment *ewPtr = client->parent;
620617 TkTextIndex index;
621618 Tcl_HashEntry *hPtr;
735732 *--------------------------------------------------------------
736733 */
737734
738 /* ARGSUSED */
739735 static int
740736 EmbWinDeleteProc(
741737 TkTextSegment *ewPtr, /* Segment being deleted. */
742 TkTextLine *linePtr, /* Line containing segment. */
743 int treeGone) /* Non-zero means the entire tree is being
738 TCL_UNUSED(TkTextLine *), /* Line containing segment. */
739 TCL_UNUSED(int)) /* Non-zero means the entire tree is being
744740 * deleted, so everything must get cleaned
745741 * up. */
746742 {
815811 *--------------------------------------------------------------
816812 */
817813
818 /*ARGSUSED*/
819814 static int
820815 EmbWinLayoutProc(
821816 TkText *textPtr, /* Text widget being layed out. */
822 TkTextIndex *indexPtr, /* Identifies first character in chunk. */
817 TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
823818 TkTextSegment *ewPtr, /* Segment corresponding to indexPtr. */
824819 int offset, /* Offset within segPtr corresponding to
825820 * indexPtr (always 0). */
826821 int maxX, /* Chunk must not occupy pixels at this
827822 * position or higher. */
828 int maxChars, /* Chunk must not include more than this many
823 TCL_UNUSED(int), /* Chunk must not include more than this many
829824 * characters. */
830825 int noCharsYet, /* Non-zero means no characters have been
831826 * assigned to this line yet. */
832 TkWrapMode wrapMode, /* Wrap mode to use for line:
827 TCL_UNUSED(TkWrapMode), /* Wrap mode to use for line:
833828 * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
834829 * TEXT_WRAPMODE_WORD. */
835 register TkTextDispChunk *chunkPtr)
830 TkTextDispChunk *chunkPtr)
836831 /* Structure to fill in with information about
837832 * this chunk. The x field has already been
838833 * set by the caller. */
935930 break;
936931 }
937932 if (Tk_TopWinHierarchy(ancestor)) {
938 goto badMaster;
933 goto badContainer;
939934 }
940935 }
941936 if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin)
942937 || (textPtr->tkwin == ewPtr->body.ew.tkwin)) {
943 badMaster:
938 badContainer:
944939 Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf(
945940 "can't embed %s relative to %s",
946941 Tk_PathName(ewPtr->body.ew.tkwin),
958953 * now need to add to our client list.
959954 */
960955
961 client = ckalloc(sizeof(TkTextEmbWindowClient));
956 client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
962957 client->next = ewPtr->body.ew.clients;
963958 client->textPtr = textPtr;
964959 client->tkwin = NULL;
10511046 static void
10521047 EmbWinCheckProc(
10531048 TkTextSegment *ewPtr, /* Segment to check. */
1054 TkTextLine *linePtr) /* Line containing segment. */
1049 TCL_UNUSED(TkTextLine *)) /* Line containing segment. */
10551050 {
10561051 if (ewPtr->nextPtr == NULL) {
10571052 Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line");
10861081 int x, /* X-position in dst at which to draw this
10871082 * chunk (differs from the x-position in the
10881083 * chunk because of scrolling). */
1089 int y, /* Top of rectangular bounding box for line:
1084 TCL_UNUSED(int), /* Top of rectangular bounding box for line:
10901085 * tells where to draw this chunk in dst
10911086 * (x-position is in the chunk itself). */
10921087 int lineHeight, /* Total height of line. */
10931088 int baseline, /* Offset of baseline from y. */
1094 Display *display, /* Display to use for drawing (unused). */
1095 Drawable dst, /* Pixmap or window in which to draw
1089 TCL_UNUSED(Display *), /* Display to use for drawing (unused). */
1090 TCL_UNUSED(Drawable), /* Pixmap or window in which to draw
10961091 * (unused). */
10971092 int screenY) /* Y-coordinate in text window that
10981093 * corresponds to y. */
10991094 {
11001095 int lineX, windowX, windowY, width, height;
11011096 Tk_Window tkwin;
1102 TkTextSegment *ewPtr = chunkPtr->clientData;
1097 TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
11031098 TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
11041099
11051100 if (client == NULL) {
11791174 TkText *textPtr, /* Overall information about text widget. */
11801175 TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
11811176 {
1182 TkTextSegment *ewPtr = chunkPtr->clientData;
1177 TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
11831178 TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
11841179
11851180 if (client == NULL) {
12271222 EmbWinBboxProc(
12281223 TkText *textPtr, /* Information about text widget. */
12291224 TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
1230 int index, /* Index of desired character within the
1225 TCL_UNUSED(int), /* Index of desired character within the
12311226 * chunk. */
12321227 int y, /* Topmost pixel in area allocated for this
12331228 * line. */
12421237 * pixels. */
12431238 {
12441239 Tk_Window tkwin;
1245 TkTextSegment *ewPtr = chunkPtr->clientData;
1240 TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
12461241 TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
12471242
12481243 if (client == NULL) {
13041299 EmbWinDelayedUnmap(
13051300 ClientData clientData) /* Token for the window to be unmapped. */
13061301 {
1307 TkTextEmbWindowClient *client = clientData;
1302 TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
13081303
13091304 if (!client->displayed && (client->tkwin != NULL)) {
13101305 if (client->textPtr->tkwin != Tk_Parent(client->tkwin)) {
13521347 return 0;
13531348 }
13541349
1355 ewPtr = Tcl_GetHashValue(hPtr);
1350 ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
13561351 indexPtr->tree = textPtr->sharedTextPtr->tree;
13571352 indexPtr->linePtr = ewPtr->body.ew.linePtr;
13581353 indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr);
298298 tsoffset.flags = INT_MAX;
299299 goto goodTSOffset;
300300 }
301 break;
301302 case 'w':
302303 if (value[1] != '\0') {goto badTSOffset;}
303304 tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE;
11311132
11321133 dictObj = Tcl_NewObj();
11331134 for (i = 0; map[i].name != NULL ; ++i) {
1134 Tcl_Obj *nameObj, *fqdnObj;
1135 Tcl_Obj *fqdnObj;
11351136
11361137 nameObj = Tcl_NewStringObj(map[i].name, -1);
11371138 fqdnObj = Tcl_NewStringObj(Tcl_DStringValue(&ds),
11761177 const char *eventName,
11771178 Tcl_Obj *detail)
11781179 {
1179 union {XEvent general; XVirtualEvent virtual;} event;
1180 union {XEvent general; XVirtualEvent virt;} event;
11801181
11811182 memset(&event, 0, sizeof(event));
11821183 event.general.xany.type = VirtualEvent;
11841185 event.general.xany.send_event = False;
11851186 event.general.xany.window = Tk_WindowId(target);
11861187 event.general.xany.display = Tk_Display(target);
1187 event.virtual.name = Tk_GetUid(eventName);
1188 if (detail != NULL) {
1189 event.virtual.user_data = detail;
1190 }
1188 event.virt.name = Tk_GetUid(eventName);
1189 event.virt.user_data = detail;
11911190
11921191 Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
11931192 }
12151214 int
12161215 TkUtfToUniChar(
12171216 const char *src, /* The UTF-8 string. */
1218 int *chPtr) /* Filled with the Tcl_UniChar represented by
1217 int *chPtr) /* Filled with the Unicode value represented by
12191218 * the UTF-8 string. */
12201219 {
12211220 Tcl_UniChar uniChar = 0;
12221221
12231222 int len = Tcl_UtfToUniChar(src, &uniChar);
1224 if ((uniChar & 0xfc00) == 0xd800) {
1225 Tcl_UniChar high = uniChar;
1223 if ((sizeof(Tcl_UniChar) == 2) && ((uniChar & 0xFC00) == 0xD800)) {
1224 Tcl_UniChar low = uniChar;
12261225 /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4,
12271226 * or when a high surrogate character is detected in UTF-8 form */
1228 int len2 = Tcl_UtfToUniChar(src+len, &uniChar);
1229 if ((uniChar & 0xfc00) == 0xdc00) {
1230 *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000;
1231 len += len2;
1232 } else {
1233 *chPtr = high;
1234 }
1235 } else {
1236 *chPtr = uniChar;
1237 }
1227 int len2 = Tcl_UtfToUniChar(src+len, &low);
1228 if ((low & 0xFC00) == 0xDC00) {
1229 *chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000;
1230 return len + len2;
1231 }
1232 }
1233 *chPtr = uniChar;
12381234 return len;
12391235 }
12401236
12431239 *
12441240 * TkUniCharToUtf --
12451241 *
1246 * Almost the same as Tcl_UniCharToUtf but producing 4-byte UTF-8
1247 * sequences even when TCL_UTF_MAX==3. So, up to 4 bytes might be produced.
1242 * Almost the same as Tcl_UniCharToUtf but producing 2 x 3-byte UTF-8
1243 * sequences for out-of-bmp characters when TCL_UTF_MAX==3.
1244 * So, up to 6 bytes might be produced.
12481245 *
12491246 * Results:
12501247 * *buf is filled with the UTF-8 string, and the return value is the
12581255
12591256 int TkUniCharToUtf(int ch, char *buf)
12601257 {
1261 int size = Tcl_UniCharToUtf(ch, buf);
1262 if ((((unsigned)(ch - 0x10000) <= 0xFFFFF)) && (size < 4)) {
1263 /* Hey, this is wrong, we must be running TCL_UTF_MAX==3
1264 * The best thing we can do is spit out a 4-byte UTF-8 character */
1265 buf[3] = (char) ((ch | 0x80) & 0xBF);
1266 buf[2] = (char) (((ch >> 6) | 0x80) & 0xBF);
1267 buf[1] = (char) (((ch >> 12) | 0x80) & 0xBF);
1268 buf[0] = (char) ((ch >> 18) | 0xF0);
1269 size = 4;
1270 }
1271 return size;
1272 }
1273
1274
1258 if ((sizeof(Tcl_UniChar) == 2) && (((unsigned)(ch - 0x10000) <= 0xFFFFF))) {
1259 /* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl
1260 * version and/or TCL_UTF_MAX build value */
1261 int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf);
1262 return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len);
1263 }
1264 return Tcl_UniCharToUtf(ch, buf);
1265 }
1266 /*
1267 *---------------------------------------------------------------------------
1268 *
1269 * TkUtfPrev --
1270 *
1271 * Almost the same as Tcl_UtfPrev.
1272 * This function is capable of jumping over a upper/lower surrogate pair.
1273 * So, might jump back up to 6 bytes.
1274 *
1275 * Results:
1276 * pointer to the first byte of the current UTF-8 character. A surrogate
1277 * pair is also handled as being a single entity.
1278 *
1279 * Side effects:
1280 * None.
1281 *
1282 *---------------------------------------------------------------------------
1283 */
1284
1285 const char *
1286 TkUtfPrev(
1287 const char *src, /* The UTF-8 string. */
1288 const char *start) /* Start position of string */
1289 {
1290 const char *p = Tcl_UtfPrev(src, start);
1291 const char *first = Tcl_UtfPrev(p, start);
1292 int ch;
1293
1294 #if TCL_UTF_MAX == 3
1295 if ((src - start > 3) && ((src[-1] & 0xC0) == 0x80) && ((src[-2] & 0xC0) == 0x80)
1296 && ((src[-3] & 0xC0) == 0x80) && (UCHAR(src[-4]) >= 0xF0)) {
1297 return src - 4;
1298 }
12751299 #endif
1300
1301 return (first + TkUtfToUniChar(first, &ch) >= src) ? first : p ;
1302 }
1303
1304 /*
1305 *---------------------------------------------------------------------------
1306 *
1307 * TkUtfAtIndex --
1308 *
1309 * Returns a pointer to the specified character (not byte) position in
1310 * a CESU-8 string. This will never point at a low surrogate.
1311 *
1312 * Results:
1313 * As above.
1314 *
1315 * Side effects:
1316 * None.
1317 *
1318 *---------------------------------------------------------------------------
1319 */
1320
1321 const char *
1322 TkUtfAtIndex(
1323 const char *src, /* The UTF-8 string. */
1324 int index) /* The position of the desired character. */
1325 {
1326 int ch;
1327 const char *p = Tcl_UtfAtIndex(src, index);
1328 if ((p > src) && (UCHAR(p[-1]) >= 0xF0)) {
1329 --p;
1330 return p + TkUtfToUniChar(p, &ch);
1331 }
1332 return p;
1333 }
1334 #endif
1335
12761336 /*
12771337 * Local Variables:
12781338 * mode: c
1212 */
1313
1414 #include "tkInt.h"
15
15 #include "tkPort.h"
1616 #ifdef _WIN32
1717 #include "tkWinInt.h"
1818 #elif !defined(MAC_OSX_TK)
123123 {"place", Tk_PlaceObjCmd, PASSMAINWINDOW|ISSAFE},
124124 {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE},
125125 {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW},
126 {"tk", (Tcl_ObjCmdProc *) TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE},
126 {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE},
127127 {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE},
128128 {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE},
129129 {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE},
938938 clientData = NULL;
939939 }
940940 if (cmdPtr->flags & USEINITPROC) {
941 ((TkInitProc *) cmdPtr->objProc)(interp, clientData);
941 ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData);
942942 } else {
943943 Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc,
944944 clientData, NULL);
16471647 event.xmap.event = winPtr->window;
16481648 event.xmap.window = winPtr->window;
16491649 event.xmap.override_redirect = winPtr->atts.override_redirect;
1650 Tk_HandleEvent(&event);
1650 TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
16511651 }
16521652
16531653 /*
18091809 event.xunmap.event = winPtr->window;
18101810 event.xunmap.window = winPtr->window;
18111811 event.xunmap.from_configure = False;
1812 Tk_HandleEvent(&event);
1812 TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
18131813 }
18141814 }
18151815
28652865 return 0;
28662866 }
28672867 tkmainex = (void (*)(int, char **, Tcl_AppInitProc *, Tcl_Interp *))
2868 GetProcAddress(tkcygwindll, "Tk_MainEx");
2868 (void *)GetProcAddress(tkcygwindll, "Tk_MainEx");
28692869 if (!tkmainex) {
28702870 return 0;
28712871 }
29052905 if (tkcygwindll) {
29062906 int (*tkinit)(Tcl_Interp *);
29072907
2908 tkinit = (int(*)(Tcl_Interp *)) GetProcAddress(tkcygwindll,"Tk_Init");
2908 tkinit = (int(*)(Tcl_Interp *))(void *)GetProcAddress(tkcygwindll,"Tk_Init");
29092909 if (tkinit) {
29102910 return tkinit(interp);
29112911 }
29682968 * Current risks:
29692969 *
29702970 * - No CPU time limit, no memory allocation limits, no color limits.
2971 * CPU time limits can be imposed by an unsafe master interpreter.
2971 * CPU time limits can be imposed by an unsafe parent interpreter.
29722972 *
29732973 * The actual code called is the same as Tk_Init but Tcl_IsSafe() is
29742974 * checked at several places to differentiate the two initialisations.
29792979 int (*tksafeinit)(Tcl_Interp *);
29802980
29812981 tksafeinit = (int (*)(Tcl_Interp *))
2982 GetProcAddress(tkcygwindll, "Tk_SafeInit");
2982 (void *)GetProcAddress(tkcygwindll, "Tk_SafeInit");
29832983 if (tksafeinit) {
29842984 return tksafeinit(interp);
29852985 }
30803080 if (Tcl_IsSafe(interp)) {
30813081 /*
30823082 * Get the clearance to start Tk and the "argv" parameters from the
3083 * master.
3083 * parent.
30843084 */
30853085
30863086 /*
3087 * Step 1 : find the master and construct the interp name (could be a
3087 * Step 1 : find the parent and construct the interp name (could be a
30883088 * function if new APIs were ok). We could also construct the path
30893089 * while walking, but there is no API to get the name of an interp
30903090 * either.
30913091 */
30923092
3093 Tcl_Interp *master = interp;
3094
3095 while (Tcl_IsSafe(master)) {
3096 master = Tcl_GetMaster(master);
3097 if (master == NULL) {
3093 Tcl_Interp *parent = interp;
3094
3095 while (Tcl_IsSafe(parent)) {
3096 parent = Tcl_GetParent(parent);
3097 if (parent == NULL) {
30983098 Tcl_SetObjResult(interp, Tcl_NewStringObj(
3099 "no controlling master interpreter", -1));
3099 "no controlling parent interpreter", -1));
31003100 Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL);
31013101 return TCL_ERROR;
31023102 }
31063106 * Construct the name (rewalk...)
31073107 */
31083108
3109 code = Tcl_GetInterpPath(master, interp);
3109 code = Tcl_GetInterpPath(parent, interp);
31103110 if (code != TCL_OK) {
31113111 Tcl_Panic("Tcl_GetInterpPath broken!");
31123112 }
31133113
31143114 /*
3115 * Build the command to eval in trusted master.
3115 * Build the command to eval in trusted parent.
31163116 */
31173117
31183118 cmd = Tcl_NewListObj(2, NULL);
31193119 Tcl_ListObjAppendElement(NULL, cmd,
31203120 Tcl_NewStringObj("::safe::TkInit", -1));
3121 Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(master));
3121 Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(parent));
31223122
31233123 /*
3124 * Step 2 : Eval in the master. The argument is the *reversed* interp
3125 * path of the slave.
3124 * Step 2 : Eval in the parent. The argument is the *reversed* interp
3125 * path of the child.
31263126 */
31273127
31283128 Tcl_IncrRefCount(cmd);
3129 code = Tcl_EvalObjEx(master, cmd, 0);
3129 code = Tcl_EvalObjEx(parent, cmd, 0);
31303130 Tcl_DecrRefCount(cmd);
3131 Tcl_TransferResult(master, code, interp);
3131 Tcl_TransferResult(parent, code, interp);
31323132 if (code != TCL_OK) {
31333133 return code;
31343134 }
31353135
31363136 /*
3137 * Use the master's result as argv. Note: We don't use the Obj
3137 * Use the parent's result as argv. Note: We don't use the Obj
31383138 * interfaces to avoid dealing with cross interp refcounting and
31393139 * changing the code below.
31403140 */
33383338 tcl_findLibrary tk $tk_version $tk_patchLevel tk.tcl TK_LIBRARY tk_library\n\
33393339 }\n\
33403340 }\n\
3341 tkInit", -1, 0);
3341 tkInit", -1, TCL_EVAL_GLOBAL);
33423342 }
33433343 if (code == TCL_OK) {
33443344 /*
1313 * Add script-level access to configure application-wide blink rate.
1414 */
1515
16 #include <tk.h>
16 #include "tkInt.h"
1717 #include "ttkTheme.h"
1818 #include "ttkWidget.h"
1919
5656 cm->owner = 0;
5757 cm->onTime = DEF_CURSOR_ON_TIME;
5858 cm->offTime = DEF_CURSOR_OFF_TIME;
59 Tcl_SetAssocData(interp,cm_key,CursorManagerDeleteProc,(ClientData)cm);
59 Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm);
6060 }
6161 return cm;
6262 }
33 * label, button, checkbutton, radiobutton, and menubutton widgets.
44 */
55
6 #include <string.h>
7 #include <tk.h>
6 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
109
8079 * Compound base/image options
8180 */
8281 {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
83 NULL, Tk_Offset(Base,base.compoundObj), -1,
84 TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings,
85 GEOMETRY_CHANGED },
82 NULL, Tk_Offset(Base,base.compoundObj), -1,
83 TK_OPTION_NULL_OK, (void *)ttkCompoundStrings,
84 GEOMETRY_CHANGED },
8685 {TK_OPTION_STRING, "-padding", "padding", "Pad",
8786 NULL, Tk_Offset(Base,base.paddingObj), -1,
8887 TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
102101 */
103102 static void TextVariableChanged(void *clientData, const char *value)
104103 {
105 Base *basePtr = clientData;
104 Base *basePtr = (Base *)clientData;
106105 Tcl_Obj *newText;
107106
108107 if (WidgetDestroyed(&basePtr->core)) {
119118 }
120119
121120 static void
122 BaseInitialize(Tcl_Interp *interp, void *recordPtr)
123 {
124 Base *basePtr = recordPtr;
121 BaseInitialize(Tcl_Interp *dummy, void *recordPtr)
122 {
123 Base *basePtr = (Base *)recordPtr;
124 (void)dummy;
125
125126 basePtr->base.textVariableTrace = 0;
126127 basePtr->base.imageSpec = NULL;
127128 }
129130 static void
130131 BaseCleanup(void *recordPtr)
131132 {
132 Base *basePtr = recordPtr;
133 Base *basePtr = (Base *)recordPtr;
133134 if (basePtr->base.textVariableTrace)
134135 Ttk_UntraceVariable(basePtr->base.textVariableTrace);
135136 if (basePtr->base.imageSpec)
142143 int imageWidth, int imageHeight)
143144 {
144145 Base *basePtr = (Base *)clientData;
146 (void)x;
147 (void)y;
148 (void)width;
149 (void)height;
150 (void)imageWidth;
151 (void)imageHeight;
152
145153 TtkResizeWidget(&basePtr->core);
146154 }
147155
148156 static int BaseConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
149157 {
150 Base *basePtr = recordPtr;
158 Base *basePtr = (Base *)recordPtr;
151159 Tcl_Obj *textVarName = basePtr->base.textVariableObj;
152160 Ttk_TraceHandle *vt = 0;
153161 Ttk_ImageSpec *imageSpec = NULL;
190198 }
191199
192200 static int
193 BasePostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
194 {
195 Base *basePtr = recordPtr;
201 BasePostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask)
202 {
203 Base *basePtr = (Base *)recordPtr;
196204 int status = TCL_OK;
205 (void)dummy;
206 (void)mask;
197207
198208 if (basePtr->base.textVariableTrace) {
199209 status = Ttk_FireTrace(basePtr->base.textVariableTrace);
315325 "", Tk_Offset(Button, button.commandObj), -1, 0,0,0},
316326 {TK_OPTION_STRING_TABLE, "-default", "default", "Default",
317327 "normal", Tk_Offset(Button, button.defaultStateObj), -1,
318 0, (ClientData) ttkDefaultStrings, DEFAULTSTATE_CHANGED},
328 0, (void *)ttkDefaultStrings, DEFAULTSTATE_CHANGED},
319329
320330 WIDGET_TAKEFOCUS_TRUE,
321331 WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
323333
324334 static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
325335 {
326 Button *buttonPtr = recordPtr;
336 Button *buttonPtr = (Button *)recordPtr;
327337
328338 if (BaseConfigure(interp, recordPtr, mask) != TCL_OK) {
329339 return TCL_ERROR;
351361 ButtonInvokeCommand(
352362 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
353363 {
354 Button *buttonPtr = recordPtr;
364 Button *buttonPtr = (Button *)recordPtr;
355365 if (objc > 2) {
356366 Tcl_WrongNumArgs(interp, 1, objv, "invoke");
357367 return TCL_ERROR;
443453 */
444454 static void CheckbuttonVariableChanged(void *clientData, const char *value)
445455 {
446 Checkbutton *checkPtr = clientData;
456 Checkbutton *checkPtr = (Checkbutton *)clientData;
447457
448458 if (WidgetDestroyed(&checkPtr->core)) {
449459 return;
465475 static void
466476 CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
467477 {
468 Checkbutton *checkPtr = recordPtr;
478 Checkbutton *checkPtr = (Checkbutton *)recordPtr;
469479 Tcl_Obj *variableObj;
470480
471481 /* default -variable is the widget name:
479489 static void
480490 CheckbuttonCleanup(void *recordPtr)
481491 {
482 Checkbutton *checkPtr = recordPtr;
492 Checkbutton *checkPtr = (Checkbutton *)recordPtr;
483493 Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
484494 checkPtr->checkbutton.variableTrace = 0;
485495 BaseCleanup(recordPtr);
488498 static int
489499 CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
490500 {
491 Checkbutton *checkPtr = recordPtr;
501 Checkbutton *checkPtr = (Checkbutton *)recordPtr;
492502 Tcl_Obj *varName = checkPtr->checkbutton.variableObj;
493503 Ttk_TraceHandle *vt = NULL;
494
504
495505 if (varName != NULL && *Tcl_GetString(varName) != '\0') {
496506 vt = Ttk_TraceVariable(interp, varName,
497507 CheckbuttonVariableChanged, checkPtr);
516526 static int
517527 CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
518528 {
519 Checkbutton *checkPtr = recordPtr;
529 Checkbutton *checkPtr = (Checkbutton *)recordPtr;
520530 int status = TCL_OK;
521531
522532 if (checkPtr->checkbutton.variableTrace)
534544 CheckbuttonInvokeCommand(
535545 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
536546 {
537 Checkbutton *checkPtr = recordPtr;
547 Checkbutton *checkPtr = (Checkbutton *)recordPtr;
538548 WidgetCore *corePtr = &checkPtr->core;
539549 Tcl_Obj *newValue;
540550
649659 static void
650660 RadiobuttonVariableChanged(void *clientData, const char *value)
651661 {
652 Radiobutton *radioPtr = clientData;
662 Radiobutton *radioPtr = (Radiobutton *)clientData;
653663
654664 if (WidgetDestroyed(&radioPtr->core)) {
655665 return;
671681 static void
672682 RadiobuttonCleanup(void *recordPtr)
673683 {
674 Radiobutton *radioPtr = recordPtr;
684 Radiobutton *radioPtr = (Radiobutton *)recordPtr;
675685 Ttk_UntraceVariable(radioPtr->radiobutton.variableTrace);
676686 radioPtr->radiobutton.variableTrace = 0;
677687 BaseCleanup(recordPtr);
680690 static int
681691 RadiobuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
682692 {
683 Radiobutton *radioPtr = recordPtr;
693 Radiobutton *radioPtr = (Radiobutton *)recordPtr;
684694 Ttk_TraceHandle *vt = Ttk_TraceVariable(
685695 interp, radioPtr->radiobutton.variableObj,
686696 RadiobuttonVariableChanged, radioPtr);
703713 static int
704714 RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
705715 {
706 Radiobutton *radioPtr = recordPtr;
716 Radiobutton *radioPtr = (Radiobutton *)recordPtr;
707717 int status = TCL_OK;
708718
709719 if (radioPtr->radiobutton.variableTrace)
721731 RadiobuttonInvokeCommand(
722732 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
723733 {
724 Radiobutton *radioPtr = recordPtr;
734 Radiobutton *radioPtr = (Radiobutton *)recordPtr;
725735 WidgetCore *corePtr = &radioPtr->core;
726736
727737 if (objc > 2) {
808818 "", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
809819 {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
810820 "below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
811 0,(ClientData)directionStrings,GEOMETRY_CHANGED},
821 0, (void *)directionStrings, GEOMETRY_CHANGED},
812822
813823 WIDGET_TAKEFOCUS_TRUE,
814824 WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
843853 TTK_GROUP("Menubutton.border", TTK_FILL_BOTH,
844854 TTK_GROUP("Menubutton.focus", TTK_FILL_BOTH,
845855 TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT)
846 TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X,
856 TTK_GROUP("Menubutton.padding", TTK_FILL_X,
847857 TTK_NODE("Menubutton.label", TTK_PACK_LEFT))))
848858 TTK_END_LAYOUT
849859
2727 * but this will be a transient effect.
2828 */
2929
30 #include <stdio.h> /* for sprintf */
31 #include <tk.h>
30 #include "tkInt.h"
3231 #include "ttkTheme.h"
3332
3433 struct Ttk_ResourceCache_ {
33 * "clam" theme; inspired by the XFCE family of Gnome themes.
44 */
55
6 #include <tk.h>
6 #include "tkInt.h"
77 #include "ttkTheme.h"
88
9 /*
10 * Under windows, the Tk-provided XDrawLine and XDrawArc have an
9 /*
10 * Under windows, the Tk-provided XDrawLine and XDrawArc have an
1111 * off-by-one error in the end point. This is especially apparent with this
1212 * theme. Defining this macro as true handles this case.
1313 */
116116 Tk_Offset(BorderElement,reliefObj), "flat" },
117117 { "-borderwidth", TK_OPTION_PIXELS,
118118 Tk_Offset(BorderElement,borderWidthObj), "2" },
119 { NULL, 0, 0, NULL }
119 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
120120 };
121121
122122 /*
123123 * <<NOTE-BORDERWIDTH>>: -borderwidth is only partially supported:
124124 * in this theme, borders are always exactly 2 pixels thick.
125 * With -borderwidth 0, border is not drawn at all;
126 * otherwise a 2-pixel border is used. For -borderwidth > 2,
125 * With -borderwidth 0, border is not drawn at all;
126 * otherwise a 2-pixel border is used. For -borderwidth > 2,
127127 * the excess is used as padding.
128128 */
129129
130130 static void BorderElementSize(
131 void *clientData, void *elementRecord, Tk_Window tkwin,
131 void *dummy, void *elementRecord, Tk_Window tkwin,
132132 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
133133 {
134134 BorderElement *border = (BorderElement*)elementRecord;
135135 int borderWidth = 2;
136 (void)dummy;
137 (void)widthPtr;
138 (void)heightPtr;
139
136140 Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
137141 if (borderWidth == 1) ++borderWidth;
138142 *paddingPtr = Ttk_UniformPadding((short)borderWidth);
139143 }
140144
141145 static void BorderElementDraw(
142 void *clientData, void *elementRecord, Tk_Window tkwin,
146 void *dummy, void *elementRecord, Tk_Window tkwin,
143147 Drawable d, Ttk_Box b, unsigned state)
144148 {
145 BorderElement *border = elementRecord;
149 BorderElement *border = (BorderElement *)elementRecord;
146150 int relief = TK_RELIEF_FLAT;
147151 int borderWidth = 2;
148152 Tcl_Obj *outer = 0, *upper = 0, *lower = 0;
153 (void)dummy;
154 (void)state;
149155
150156 Tk_GetReliefFromObj(NULL, border->reliefObj, &relief);
151157 Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
204210 Tk_Offset(FieldElement,darkColorObj), DARK_COLOR },
205211 { "-fieldbackground", TK_OPTION_BORDER,
206212 Tk_Offset(FieldElement,backgroundObj), "white" },
207 { NULL, 0, 0, NULL }
213 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
208214 };
209215
210216 static void FieldElementSize(
211 void *clientData, void *elementRecord, Tk_Window tkwin,
217 void *dummy, void *elementRecord, Tk_Window tkwin,
212218 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
213219 {
220 (void)dummy;
221 (void)elementRecord;
222 (void)tkwin;
223 (void)widthPtr;
224 (void)heightPtr;
225
214226 *paddingPtr = Ttk_UniformPadding(2);
215227 }
216228
217229 static void FieldElementDraw(
218 void *clientData, void *elementRecord, Tk_Window tkwin,
230 void *dummy, void *elementRecord, Tk_Window tkwin,
219231 Drawable d, Ttk_Box b, unsigned state)
220232 {
221 FieldElement *field = elementRecord;
233 FieldElement *field = (FieldElement *)elementRecord;
222234 Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj);
223235 Ttk_Box f = Ttk_PadBox(b, Ttk_UniformPadding(2));
224236 Tcl_Obj *outer = field->borderColorObj,
225237 *inner = field->lightColorObj;
238 (void)dummy;
239 (void)state;
226240
227241 DrawSmoothBorder(tkwin, d, b, outer, inner, inner);
228242 Tk_Fill3DRectangle(
245259 void *clientData, void *elementRecord, Tk_Window tkwin,
246260 Drawable d, Ttk_Box b, unsigned state)
247261 {
248 FieldElement *field = elementRecord;
262 FieldElement *field = (FieldElement *)elementRecord;
249263 GC gc = Ttk_GCForColor(tkwin,field->borderColorObj,d);
250264
251265 ++b.width;
290304 Tk_Offset(IndicatorElement,upperColorObj), DARKEST_COLOR },
291305 { "-lowerbordercolor", TK_OPTION_COLOR,
292306 Tk_Offset(IndicatorElement,lowerColorObj), DARK_COLOR },
293 { NULL, 0, 0, NULL }
307 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
294308 };
295309
296310 static void IndicatorElementSize(
297 void *clientData, void *elementRecord, Tk_Window tkwin,
311 void *dummy, void *elementRecord, Tk_Window tkwin,
298312 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
299313 {
300 IndicatorElement *indicator = elementRecord;
314 IndicatorElement *indicator = (IndicatorElement *)elementRecord;
301315 Ttk_Padding margins;
302316 int size = 10;
317 (void)dummy;
318 (void)paddingPtr;
319
303320 Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
304321 Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
305322 *widthPtr = size + Ttk_PaddingWidth(margins);
307324 }
308325
309326 static void RadioIndicatorElementDraw(
310 void *clientData, void *elementRecord, Tk_Window tkwin,
327 void *dummy, void *elementRecord, Tk_Window tkwin,
311328 Drawable d, Ttk_Box b, unsigned state)
312329 {
313 IndicatorElement *indicator = elementRecord;
330 IndicatorElement *indicator = (IndicatorElement *)elementRecord;
314331 GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
315332 GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
316333 GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
317334 GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
318335 Ttk_Padding padding;
336 (void)dummy;
319337
320338 Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
321339 b = Ttk_PadBox(b, padding);
335353 }
336354
337355 static void CheckIndicatorElementDraw(
338 void *clientData, void *elementRecord, Tk_Window tkwin,
356 void *dummy, void *elementRecord, Tk_Window tkwin,
339357 Drawable d, Ttk_Box b, unsigned state)
340358 {
341359 Display *display = Tk_Display(tkwin);
342 IndicatorElement *indicator = elementRecord;
360 IndicatorElement *indicator = (IndicatorElement *)elementRecord;
361
343362 GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
344363 GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
345364 GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
346365 GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
347366 Ttk_Padding padding;
348367 const int w = WIN32_XDRAWLINE_HACK;
368 (void)dummy;
349369
350370 Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
351371 b = Ttk_PadBox(b, padding);
401421 static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
402422 {
403423 { "-arrowsize", TK_OPTION_PIXELS,
404 Tk_Offset(MenuIndicatorElement,sizeObj),
424 Tk_Offset(MenuIndicatorElement,sizeObj),
405425 STR(MENUBUTTON_ARROW_SIZE)},
406426 { "-arrowcolor",TK_OPTION_COLOR,
407427 Tk_Offset(MenuIndicatorElement,colorObj),
409429 { "-arrowpadding",TK_OPTION_STRING,
410430 Tk_Offset(MenuIndicatorElement,paddingObj),
411431 "3" },
412 { NULL, 0, 0, NULL }
432 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
413433 };
414434
415435 static void MenuIndicatorElementSize(
416 void *clientData, void *elementRecord, Tk_Window tkwin,
436 void *dummy, void *elementRecord, Tk_Window tkwin,
417437 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
418438 {
419 MenuIndicatorElement *indicator = elementRecord;
439 MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
420440 Ttk_Padding margins;
421441 int size = MENUBUTTON_ARROW_SIZE;
442 (void)dummy;
443 (void)paddingPtr;
444
422445 Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
423446 Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
424447 TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
427450 }
428451
429452 static void MenuIndicatorElementDraw(
430 void *clientData, void *elementRecord, Tk_Window tkwin,
453 void *dummy, void *elementRecord, Tk_Window tkwin,
431454 Drawable d, Ttk_Box b, unsigned int state)
432455 {
433 MenuIndicatorElement *indicator = elementRecord;
456 MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
434457 XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
435458 GC gc = Tk_GCForColor(arrowColor, d);
436459 int size = MENUBUTTON_ARROW_SIZE;
437460 int width, height;
461 (void)dummy;
462 (void)state;
438463
439464 Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
440465
475500 Tk_Offset(GripElement,borderColorObj), DARKEST_COLOR },
476501 { "-gripcount", TK_OPTION_INT,
477502 Tk_Offset(GripElement,gripCountObj), "5" },
478 { NULL, 0, 0, NULL }
503 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
479504 };
480505
481506 static void GripElementSize(
483508 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
484509 {
485510 int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
486 GripElement *grip = elementRecord;
511 GripElement *grip = (GripElement *)elementRecord;
487512 int gripCount = 0;
513 (void)tkwin;
514 (void)paddingPtr;
488515
489516 Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
490517 if (horizontal) {
500527 {
501528 const int w = WIN32_XDRAWLINE_HACK;
502529 int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
503 GripElement *grip = elementRecord;
530 GripElement *grip = (GripElement *)elementRecord;
504531 GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
505532 GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
506533 int gripPad = 1, gripCount = 0;
574601 Tk_Offset(ScrollbarElement,gripCountObj), "5" },
575602 { "-sliderlength", TK_OPTION_INT,
576603 Tk_Offset(ScrollbarElement,sliderlengthObj), "30" },
577 { NULL, 0, 0, NULL }
604 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
578605 };
579606
580607 static void TroughElementDraw(
581 void *clientData, void *elementRecord, Tk_Window tkwin,
608 void *dummy, void *elementRecord, Tk_Window tkwin,
582609 Drawable d, Ttk_Box b, unsigned state)
583610 {
584 ScrollbarElement *sb = elementRecord;
611 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
585612 GC gcb = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
586613 GC gct = Ttk_GCForColor(tkwin,sb->troughColorObj,d);
614 (void)dummy;
615 (void)state;
616
587617 XFillRectangle(Tk_Display(tkwin), d, gct, b.x, b.y, b.width-1, b.height-1);
588618 XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1);
589619 }
597627 };
598628
599629 static void ThumbElementSize(
600 void *clientData, void *elementRecord, Tk_Window tkwin,
630 void *dummy, void *elementRecord, Tk_Window tkwin,
601631 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
602632 {
603 ScrollbarElement *sb = elementRecord;
633 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
604634 int size = SCROLLBAR_THICKNESS;
635 (void)dummy;
636 (void)tkwin;
637 (void)paddingPtr;
638
605639 Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
606640 *widthPtr = *heightPtr = size;
607641 }
608642
609643 static void ThumbElementDraw(
610 void *clientData, void *elementRecord, Tk_Window tkwin,
644 void *dummy, void *elementRecord, Tk_Window tkwin,
611645 Drawable d, Ttk_Box b, unsigned state)
612646 {
613 ScrollbarElement *sb = elementRecord;
614 int gripCount = 0, orient = TTK_ORIENT_HORIZONTAL;
647 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
648 int gripCount = 0;
649 int orient = TTK_ORIENT_HORIZONTAL;
615650 GC lightGC, darkGC;
616651 int x1, y1, x2, y2, dx, dy, i;
617652 const int w = WIN32_XDRAWLINE_HACK;
653 (void)dummy;
654 (void)state;
618655
619656 DrawSmoothBorder(tkwin, d, b,
620657 sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
629666 Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount);
630667 lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
631668 darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
632
669
633670 if (orient == TTK_ORIENT_HORIZONTAL) {
634671 dx = 1; dy = 0;
635672 x1 = x2 = b.x + b.width / 2 - gripCount;
662699 * +++ Slider element.
663700 */
664701 static void SliderElementSize(
665 void *clientData, void *elementRecord, Tk_Window tkwin,
702 void *dummy, void *elementRecord, Tk_Window tkwin,
666703 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
667704 {
668 ScrollbarElement *sb = elementRecord;
669 int length, thickness, orient;
705 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
706 int length, thickness;
707 int orient;
708 (void)dummy;
709 (void)paddingPtr;
670710
671711 length = thickness = SCROLLBAR_THICKNESS;
672712 Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
705745 }
706746
707747 static void PbarElementDraw(
708 void *clientData, void *elementRecord, Tk_Window tkwin,
748 void *dummy, void *elementRecord, Tk_Window tkwin,
709749 Drawable d, Ttk_Box b, unsigned state)
710750 {
711 ScrollbarElement *sb = elementRecord;
712
751 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
752 (void)dummy;
753 (void)state;
754
713755 b = Ttk_PadBox(b, Ttk_UniformPadding(2));
714756 if (b.width > 4 && b.height > 4) {
715757 DrawSmoothBorder(tkwin, d, b,
716758 sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
717 XFillRectangle(Tk_Display(tkwin), d,
759 XFillRectangle(Tk_Display(tkwin), d,
718760 BackgroundGC(tkwin, sb->backgroundObj),
719761 b.x+2, b.y+2, b.width-4, b.height-4);
720762 }
735777 static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
736778
737779 static void ArrowElementSize(
738 void *clientData, void *elementRecord, Tk_Window tkwin,
780 void *dummy, void *elementRecord, Tk_Window tkwin,
739781 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
740782 {
741 ScrollbarElement *sb = elementRecord;
783 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
742784 int size = SCROLLBAR_THICKNESS;
785 (void)dummy;
786 (void)tkwin;
787 (void)paddingPtr;
788
743789 Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
744790 *widthPtr = *heightPtr = size;
745791 }
748794 void *clientData, void *elementRecord, Tk_Window tkwin,
749795 Drawable d, Ttk_Box b, unsigned state)
750796 {
751 ArrowDirection dir = *(ArrowDirection*)clientData;
752 ScrollbarElement *sb = elementRecord;
797 ArrowDirection direction = *(ArrowDirection*)clientData;
798 ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
753799 GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d);
754800 int h, cx, cy;
755801
762808
763809 b = Ttk_PadBox(b, Ttk_UniformPadding(3));
764810 h = b.width < b.height ? b.width : b.height;
765 TtkArrowSize(h/2, dir, &cx, &cy);
811 TtkArrowSize(h/2, direction, &cx, &cy);
766812 b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
767813
768 TtkFillArrow(Tk_Display(tkwin), d, gc, b, dir);
814 TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
769815 }
770816
771817 static Ttk_ElementSpec ArrowElementSpec = {
779825
780826 /*------------------------------------------------------------------------
781827 * +++ Notebook elements.
782 *
783 * Note: Tabs, except for the rightmost, overlap the neighbor to
828 *
829 * Note: Tabs, except for the rightmost, overlap the neighbor to
784830 * their right by one pixel.
785831 */
786832
800846 Tk_Offset(NotebookElement,lightColorObj), LIGHT_COLOR },
801847 { "-darkcolor", TK_OPTION_COLOR,
802848 Tk_Offset(NotebookElement,darkColorObj), DARK_COLOR },
803 { NULL, 0, 0, NULL }
849 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
804850 };
805851
806852 static void TabElementSize(
807 void *clientData, void *elementRecord, Tk_Window tkwin,
853 void *dummy, void *elementRecord, Tk_Window tkwin,
808854 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
809855 {
810856 int borderWidth = 2;
857 (void)dummy;
858 (void)elementRecord;
859 (void)tkwin;
860 (void)widthPtr;
861 (void)heightPtr;
862
811863 paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
812864 paddingPtr->bottom = 0;
813865 }
814866
815867 static void TabElementDraw(
816 void *clientData, void *elementRecord, Tk_Window tkwin,
868 void *dummy, void *elementRecord, Tk_Window tkwin,
817869 Drawable d, Ttk_Box b, unsigned int state)
818870 {
819 NotebookElement *tab = elementRecord;
871 NotebookElement *tab = (NotebookElement *)elementRecord;
820872 Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
821873 Display *display = Tk_Display(tkwin);
822874 int borderWidth = 2, dh = 0;
823875 int x1,y1,x2,y2;
824876 GC gc;
825877 const int w = WIN32_XDRAWLINE_HACK;
878 (void)dummy;
826879
827880 if (state & TTK_STATE_SELECTED) {
828881 dh = borderWidth;
859912 };
860913
861914 static void ClientElementSize(
862 void *clientData, void *elementRecord, Tk_Window tkwin,
915 void *dummy, void *elementRecord, Tk_Window tkwin,
863916 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
864917 {
865918 int borderWidth = 2;
919 (void)dummy;
920 (void)elementRecord;
921 (void)tkwin;
922 (void)widthPtr;
923 (void)heightPtr;
924
866925 *paddingPtr = Ttk_UniformPadding((short)borderWidth);
867926 }
868927
869928 static void ClientElementDraw(
870 void *clientData, void *elementRecord, Tk_Window tkwin,
929 void *dummy, void *elementRecord, Tk_Window tkwin,
871930 Drawable d, Ttk_Box b, unsigned int state)
872931 {
873 NotebookElement *ce = elementRecord;
932 NotebookElement *ce = (NotebookElement *)elementRecord;
874933 Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
875934 int borderWidth = 2;
935 (void)dummy;
936 (void)state;
876937
877938 Tk_Fill3DRectangle(tkwin, d, border,
878939 b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_FLAT);
897958
898959 TTK_LAYOUT("TCombobox",
899960 TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y)
900 TTK_GROUP("Combobox.field", TTK_PACK_LEFT|TTK_FILL_BOTH|TTK_EXPAND,
961 TTK_GROUP("Combobox.field", TTK_FILL_BOTH,
901962 TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
902963 TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))
903964
2525 Tk_Offset(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
2626 { "-highlightthickness",TK_OPTION_PIXELS,
2727 Tk_Offset(HighlightElement,highlightThicknessObj), "0" },
28 { NULL, 0, 0, NULL }
28 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
2929 };
3030
3131 static void HighlightElementSize(
32 void *clientData, void *elementRecord, Tk_Window tkwin,
32 void *dummy, void *elementRecord, Tk_Window tkwin,
3333 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
3434 {
35 HighlightElement *hl = elementRecord;
35 HighlightElement *hl = (HighlightElement *)elementRecord;
3636 int highlightThickness = 0;
37 (void)dummy;
38 (void)tkwin;
39 (void)widthPtr;
40 (void)heightPtr;
3741
3842 Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness);
3943 *paddingPtr = Ttk_UniformPadding((short)highlightThickness);
4044 }
4145
4246 static void HighlightElementDraw(
43 void *clientData, void *elementRecord, Tk_Window tkwin,
47 void *dummy, void *elementRecord, Tk_Window tkwin,
4448 Drawable d, Ttk_Box b, unsigned int state)
4549 {
46 HighlightElement *hl = elementRecord;
50 HighlightElement *hl = (HighlightElement *)elementRecord;
4751 int highlightThickness = 0;
4852 XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj);
53 (void)dummy;
54 (void)b;
55 (void)state;
4956
5057 Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness);
5158 if (highlightColor && highlightThickness > 0) {
6572
6673 /*------------------------------------------------------------------------
6774 * +++ Button Border element:
68 *
75 *
6976 * The Motif-style button border on X11 consists of (from outside-in):
7077 *
7178 * + focus indicator (controlled by -highlightcolor and -highlightthickness),
8289
8390 static Ttk_ElementOptionSpec ButtonBorderElementOptions[] =
8491 {
85 { "-background", TK_OPTION_BORDER,
92 { "-background", TK_OPTION_BORDER,
8693 Tk_Offset(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND },
87 { "-borderwidth", TK_OPTION_PIXELS,
94 { "-borderwidth", TK_OPTION_PIXELS,
8895 Tk_Offset(ButtonBorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
89 { "-relief", TK_OPTION_RELIEF,
96 { "-relief", TK_OPTION_RELIEF,
9097 Tk_Offset(ButtonBorderElement,reliefObj), "flat" },
91 { "-default", TK_OPTION_ANY,
98 { "-default", TK_OPTION_ANY,
9299 Tk_Offset(ButtonBorderElement,defaultStateObj), "disabled" },
93 { NULL, 0, 0, NULL }
100 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
94101 };
95102
96103 static void ButtonBorderElementSize(
97 void *clientData, void *elementRecord, Tk_Window tkwin,
104 void *dummy, void *elementRecord, Tk_Window tkwin,
98105 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
99106 {
100 ButtonBorderElement *bd = elementRecord;
107 ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
101108 int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
102109 int borderWidth = 0;
110 (void)dummy;
111 (void)tkwin;
112 (void)widthPtr;
113 (void)heightPtr;
103114
104115 Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
105116 Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
112123
113124 /*
114125 * (@@@ Note: ButtonBorderElement still still still buggy:
115 * padding for default ring is drawn in the wrong color
126 * padding for default ring is drawn in the wrong color
116127 * when the button is active.)
117128 */
118129 static void ButtonBorderElementDraw(
119 void *clientData, void *elementRecord, Tk_Window tkwin,
130 void *dummy, void *elementRecord, Tk_Window tkwin,
120131 Drawable d, Ttk_Box b, unsigned int state)
121132 {
122 ButtonBorderElement *bd = elementRecord;
133 ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
123134 Tk_3DBorder border = NULL;
124135 int borderWidth = 1, relief = TK_RELIEF_FLAT;
125136 int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
126137 int inset = 0;
138 (void)dummy;
139 (void)state;
127140
128141 /*
129142 * Get option values.
203216 { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,borderWidthObj),
204217 DEFAULT_BORDERWIDTH },
205218 { "-relief", TK_OPTION_RELIEF, Tk_Offset(ArrowElement,reliefObj),"raised" },
206 { NULL, 0, 0, NULL }
219 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
207220 };
208221
209222 static void ArrowElementSize(
210 void *clientData, void *elementRecord, Tk_Window tkwin,
223 void *dummy, void *elementRecord, Tk_Window tkwin,
211224 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
212225 {
213 ArrowElement *arrow = elementRecord;
226 ArrowElement *arrow = (ArrowElement *)elementRecord;
214227 int size = 12;
228 (void)dummy;
229 (void)paddingPtr;
215230
216231 Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
217232 *widthPtr = *heightPtr = size;
222237 Drawable d, Ttk_Box b, unsigned int state)
223238 {
224239 int direction = *(int *)clientData;
225 ArrowElement *arrow = elementRecord;
240 ArrowElement *arrow = (ArrowElement *)elementRecord;
226241 Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
227242 int borderWidth = 2;
228243 int relief = TK_RELIEF_RAISED;
229244 int size = b.width < b.height ? b.width : b.height;
230245 XPoint points[3];
246 (void)state;
231247
232248 Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth);
233249 Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
278294 /*------------------------------------------------------------------------
279295 * +++ Sash element (for ttk::panedwindow)
280296 *
281 * NOTES:
297 * NOTES:
282298 *
283299 * panedwindows with -orient horizontal use vertical sashes, and vice versa.
284300 *
285301 * Interpretation of -sashrelief 'groove' and 'ridge' are
286302 * swapped wrt. the core panedwindow, which (I think) has them backwards.
287303 *
288 * Default -sashrelief is sunken; the core panedwindow has default
304 * Default -sashrelief is sunken; the core panedwindow has default
289305 * -sashrelief raised, but that looks wrong to me.
290306 */
291307
292308 static Ttk_Orient SashClientData[] = {
293 TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
309 TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
294310 };
295311
296312 typedef struct {
303319 } SashElement;
304320
305321 static Ttk_ElementOptionSpec SashOptions[] = {
306 { "-background", TK_OPTION_BORDER,
322 { "-background", TK_OPTION_BORDER,
307323 Tk_Offset(SashElement,borderObj), DEFAULT_BACKGROUND },
308 { "-sashrelief", TK_OPTION_RELIEF,
324 { "-sashrelief", TK_OPTION_RELIEF,
309325 Tk_Offset(SashElement,sashReliefObj), "sunken" },
310326 { "-sashthickness", TK_OPTION_PIXELS,
311327 Tk_Offset(SashElement,sashThicknessObj), "6" },
312 { "-sashpad", TK_OPTION_PIXELS,
328 { "-sashpad", TK_OPTION_PIXELS,
313329 Tk_Offset(SashElement,sashPadObj), "2" },
314330 { "-handlesize", TK_OPTION_PIXELS,
315331 Tk_Offset(SashElement,handleSizeObj), "8" },
316332 { "-handlepad", TK_OPTION_PIXELS,
317333 Tk_Offset(SashElement,handlePadObj), "8" },
318 { NULL, 0, 0, NULL }
334 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
319335 };
320336
321337 static void SashElementSize(
322338 void *clientData, void *elementRecord, Tk_Window tkwin,
323339 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
324340 {
325 SashElement *sash = elementRecord;
341 SashElement *sash = (SashElement *)elementRecord;
326342 int sashPad = 2, sashThickness = 6, handleSize = 8;
327343 int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
344 (void)paddingPtr;
328345
329346 Tk_GetPixelsFromObj(NULL, tkwin, sash->sashThicknessObj, &sashThickness);
330347 Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
343360 void *clientData, void *elementRecord, Tk_Window tkwin,
344361 Drawable d, Ttk_Box b, Ttk_State state)
345362 {
346 SashElement *sash = elementRecord;
363 SashElement *sash = (SashElement *)elementRecord;
347364 Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, sash->borderObj);
348365 GC gc1,gc2;
349366 int relief = TK_RELIEF_RAISED;
350367 int handleSize = 8, handlePad = 8;
351368 int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
352369 Ttk_Box hb;
370 (void)state;
353371
354372 Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
355373 Tk_GetPixelsFromObj(NULL, tkwin, sash->handlePadObj, &handlePad);
364382 gc1 = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
365383 gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
366384 break;
367 case TK_RELIEF_SOLID:
385 case TK_RELIEF_SOLID:
368386 gc1 = gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
369387 break;
370 case TK_RELIEF_FLAT:
388 case TK_RELIEF_FLAT:
371389 default:
372390 gc1 = gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
373391 break;
395413 hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_N);
396414 hb.y += handlePad;
397415 }
398 Tk_Fill3DRectangle(tkwin, d, border,
416 Tk_Fill3DRectangle(tkwin, d, border,
399417 hb.x, hb.y, hb.width, hb.height, 1, TK_RELIEF_RAISED);
400418 }
401419 }
438456 TTK_GROUP("Menubutton.highlight", TTK_FILL_BOTH,
439457 TTK_GROUP("Menubutton.border", TTK_FILL_BOTH,
440458 TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT)
441 TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X,
459 TTK_GROUP("Menubutton.padding", TTK_FILL_X,
442460 TTK_NODE("Menubutton.label", 0)))))
443461
444462 /* "classic" entry, includes highlight border */
492510 Ttk_RegisterElement(interp, theme, "arrow",
493511 &ArrowElementSpec, &ArrowElements[0]);
494512
495 Ttk_RegisterElement(interp, theme, "hsash",
513 Ttk_RegisterElement(interp, theme, "hsash",
496514 &SashElementSpec, &SashClientData[0]);
497515 Ttk_RegisterElement(interp, theme, "vsash",
498516 &SashElementSpec, &SashClientData[1]);
44 *
55 */
66
7 #include <tcl.h>
8 #include <tk.h>
9 #include <string.h>
7 #include "tkInt.h"
108 #include "ttkTheme.h"
119 #include "ttkWidget.h"
1210
338338 }
339339 string = entryPtr->entry.displayString;
340340
341 selStart = Tcl_UtfAtIndex(string, entryPtr->entry.selectFirst);
342 selEnd = Tcl_UtfAtIndex(selStart,
341 selStart = TkUtfAtIndex(string, entryPtr->entry.selectFirst);
342 selEnd = TkUtfAtIndex(selStart,
343343 entryPtr->entry.selectLast - entryPtr->entry.selectFirst);
344344 byteCount = selEnd - selStart - offset;
345345 if (byteCount > maxBytes) {
457457 break;
458458 case 'S': /* string to be inserted/deleted, if any */
459459 if (reason == VALIDATE_INSERT) {
460 string = Tcl_UtfAtIndex(new, index);
461 stringLength = Tcl_UtfAtIndex(string, count) - string;
460 string = TkUtfAtIndex(new, index);
461 stringLength = TkUtfAtIndex(string, count) - string;
462462 } else if (reason == VALIDATE_DELETE) {
463 string = Tcl_UtfAtIndex(entryPtr->entry.string, index);
464 stringLength = Tcl_UtfAtIndex(string, count) - string;
463 string = TkUtfAtIndex(entryPtr->entry.string, index);
464 stringLength = TkUtfAtIndex(string, count) - string;
465465 } else {
466466 string = "";
467467 stringLength = 0;
556556 * Returns:
557557 * TCL_OK if the change is accepted
558558 * TCL_BREAK if the change is rejected
559 * TCL_ERROR if any errors occured
559 * TCL_ERROR if any errors occurred
560560 *
561561 * The change will be rejected if -validatecommand returns 0,
562562 * or if -validatecommand or -invalidcommand modifies the value.
649649 static void EntryRevalidateBG(Entry *entryPtr, VREASON reason)
650650 {
651651 Tcl_Interp *interp = entryPtr->core.interp;
652 if (EntryRevalidate(interp, entryPtr, reason) == TCL_ERROR) {
653 Tcl_BackgroundException(interp, TCL_ERROR);
652 VMODE vmode = entryPtr->entry.validate;
653
654 if (EntryNeedsValidation(vmode, reason)) {
655 if (EntryRevalidate(interp, entryPtr, reason) == TCL_ERROR) {
656 Tcl_BackgroundException(interp, TCL_ERROR);
657 }
654658 }
655659 }
656660
807811 const char *value) /* New characters to add */
808812 {
809813 char *string = entryPtr->entry.string;
810 size_t byteIndex = Tcl_UtfAtIndex(string, index) - string;
814 size_t byteIndex = TkUtfAtIndex(string, index) - string;
811815 size_t byteCount = strlen(value);
812816 int charsAdded = Tcl_NumUtfChars(value, byteCount);
813817 size_t newByteCount = entryPtr->entry.numBytes + byteCount + 1;
861865 return TCL_OK;
862866 }
863867
864 byteIndex = Tcl_UtfAtIndex(string, index) - string;
865 byteCount = Tcl_UtfAtIndex(string+byteIndex, count) - (string+byteIndex);
868 byteIndex = TkUtfAtIndex(string, index) - string;
869 byteCount = TkUtfAtIndex(string+byteIndex, count) - (string+byteIndex);
866870
867871 newByteCount = entryPtr->entry.numBytes + 1 - byteCount;
868872 new = ckalloc(newByteCount);
12691273 /* Draw the text:
12701274 */
12711275 gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion);
1272 Tk_DrawTextLayout(
1273 Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
1274 entryPtr->entry.layoutX, entryPtr->entry.layoutY,
1275 leftIndex, rightIndex);
1276 XSetClipMask(Tk_Display(tkwin), gc, None);
1277 Tk_FreeGC(Tk_Display(tkwin), gc);
1278
1279 /* Overwrite the selected portion (if any) in the -selectforeground color:
1280 */
12811276 if (showSelection) {
1277
1278 /* Draw the selected and unselected portions separately.
1279 */
1280 if (leftIndex < selFirst) {
1281 Tk_DrawTextLayout(
1282 Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
1283 entryPtr->entry.layoutX, entryPtr->entry.layoutY,
1284 leftIndex, selFirst);
1285 }
1286 if (selLast < rightIndex) {
1287 Tk_DrawTextLayout(
1288 Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
1289 entryPtr->entry.layoutX, entryPtr->entry.layoutY,
1290 selLast, rightIndex);
1291 }
1292 XSetClipMask(Tk_Display(tkwin), gc, None);
1293 Tk_FreeGC(Tk_Display(tkwin), gc);
1294
1295 /* Draw the selected portion in the -selectforeground color:
1296 */
12821297 gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion);
12831298 Tk_DrawTextLayout(
12841299 Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
12851300 entryPtr->entry.layoutX, entryPtr->entry.layoutY,
12861301 selFirst, selLast);
1302 XSetClipMask(Tk_Display(tkwin), gc, None);
1303 Tk_FreeGC(Tk_Display(tkwin), gc);
1304 } else {
1305
1306 /* Draw the entire visible text
1307 */
1308 Tk_DrawTextLayout(
1309 Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
1310 entryPtr->entry.layoutX, entryPtr->entry.layoutY,
1311 leftIndex, rightIndex);
12871312 XSetClipMask(Tk_Display(tkwin), gc, None);
12881313 Tk_FreeGC(Tk_Display(tkwin), gc);
12891314 }
13771402 *indexPtr += 1;
13781403 }
13791404 } else {
1380 if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) {
1405 if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) != TCL_OK) {
13811406 goto badIndex;
13821407 }
13831408 if (*indexPtr < 0) {
20672092 TTK_BEGIN_LAYOUT(ComboboxLayout)
20682093 TTK_GROUP("Combobox.field", TTK_FILL_BOTH,
20692094 TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y)
2070 TTK_GROUP("Combobox.padding", TTK_FILL_BOTH|TTK_PACK_LEFT|TTK_EXPAND,
2095 TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
20712096 TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))
20722097 TTK_END_LAYOUT
20732098
33 * ttk::frame and ttk::labelframe widgets.
44 */
55
6 #include <tk.h>
7
6 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
109 #include "ttkManager.h"
8887 * The frame doesn't request a size of its own by default,
8988 * but it does have an internal border. See also <<NOTE-SIZE>>
9089 */
91 static int FrameSize(void *recordPtr, int *widthPtr, int *heightPtr)
92 {
93 Frame *framePtr = recordPtr;
90 static int FrameSize(
91 void *recordPtr,
92 TCL_UNUSED(int *),
93 TCL_UNUSED(int *))
94 {
95 Frame *framePtr = (Frame *)recordPtr;
9496 Ttk_SetMargins(framePtr->core.tkwin, FrameMargins(framePtr));
9597 return 0;
9698 }
111113
112114 static int FrameConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
113115 {
114 Frame *framePtr = recordPtr;
116 Frame *framePtr = (Frame *)recordPtr;
115117 int width, height;
116118
117119 /*
337339 * Like the frame, this doesn't request a size of its own
338340 * but it does have internal padding and a minimum size.
339341 */
340 static int LabelframeSize(void *recordPtr, int *widthPtr, int *heightPtr)
341 {
342 Labelframe *lframePtr = recordPtr;
342 static int LabelframeSize(
343 void *recordPtr,
344 TCL_UNUSED(int *),
345 TCL_UNUSED(int *))
346 {
347 Labelframe *lframePtr = (Labelframe *)recordPtr;
343348 WidgetCore *corePtr = &lframePtr->core;
344349 Ttk_Padding margins;
345350 LabelframeStyle style;
384389 static Ttk_Layout LabelframeGetLayout(
385390 Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
386391 {
387 Labelframe *lf = recordPtr;
392 Labelframe *lf = (Labelframe *)recordPtr;
388393 Ttk_Layout frameLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
389394 Ttk_Layout labelLayout;
390395
415420
416421 static void LabelframeDoLayout(void *recordPtr)
417422 {
418 Labelframe *lframePtr = recordPtr;
423 Labelframe *lframePtr = (Labelframe *)recordPtr;
419424 WidgetCore *corePtr = &lframePtr->core;
420425 int lw, lh; /* Label width and height */
421426 LabelframeStyle style;
455460 Ttk_PlaceLayout(
456461 lframePtr->label.labelLayout, corePtr->state, labelParcel);
457462 }
458 /* labelWidget placed in LabelframePlaceSlaves GM hook */
463 /* labelWidget placed in LabelframePlaceContent GM hook */
459464 lframePtr->label.labelParcel = labelParcel;
460465 }
461466
462467 static void LabelframeDisplay(void *recordPtr, Drawable d)
463468 {
464 Labelframe *lframePtr = recordPtr;
469 Labelframe *lframePtr = (Labelframe *)recordPtr;
465470 Ttk_DrawLayout(lframePtr->core.layout, lframePtr->core.state, d);
466471 if (lframePtr->label.labelLayout) {
467472 Ttk_DrawLayout(lframePtr->label.labelLayout, lframePtr->core.state, d);
471476 /* +++ Labelframe geometry manager hooks.
472477 */
473478
474 /* LabelframePlaceSlaves --
479 /* LabelframePlaceContent --
475480 * Sets the position and size of the labelwidget.
476481 */
477 static void LabelframePlaceSlaves(void *recordPtr)
478 {
479 Labelframe *lframe = recordPtr;
480
481 if (Ttk_NumberSlaves(lframe->label.mgr) == 1) {
482 static void LabelframePlaceContent(void *recordPtr)
483 {
484 Labelframe *lframe = (Labelframe *)recordPtr;
485
486 if (Ttk_NumberContent(lframe->label.mgr) == 1) {
482487 Ttk_Box b;
483488 LabelframeDoLayout(recordPtr);
484489 b = lframe->label.labelParcel;
485 /* ASSERT: slave #0 is lframe->label.labelWidget */
486 Ttk_PlaceSlave(lframe->label.mgr, 0, b.x,b.y,b.width,b.height);
487 }
488 }
489
490 static int LabelRequest(void *managerData, int index, int width, int height)
490 /* ASSERT: content #0 is lframe->label.labelWidget */
491 Ttk_PlaceContent(lframe->label.mgr, 0, b.x,b.y,b.width,b.height);
492 }
493 }
494
495 static int LabelRequest(
496 TCL_UNUSED(void *),
497 TCL_UNUSED(int),
498 TCL_UNUSED(int),
499 TCL_UNUSED(int))
491500 {
492501 return 1;
493502 }
497506 *
498507 * <<NOTE-LABELREMOVED>>:
499508 * This routine is also called when the widget voluntarily forgets
500 * the slave in LabelframeConfigure.
501 */
502 static void LabelRemoved(void *managerData, int slaveIndex)
503 {
504 Labelframe *lframe = managerData;
509 * the window in LabelframeConfigure.
510 */
511 static void LabelRemoved(
512 void *managerData,
513 TCL_UNUSED(int))
514 {
515 Labelframe *lframe = (Labelframe *)managerData;
516
505517 lframe->label.labelWidget = 0;
506518 }
507519
508520 static Ttk_ManagerSpec LabelframeManagerSpec = {
509 { "labelframe", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
521 { "labelframe", Ttk_GeometryRequestProc, Ttk_LostContentProc },
510522 LabelframeSize,
511 LabelframePlaceSlaves,
523 LabelframePlaceContent,
512524 LabelRequest,
513525 LabelRemoved
514526 };
516528 /* LabelframeInitialize --
517529 * Initialization hook.
518530 */
519 static void LabelframeInitialize(Tcl_Interp *interp, void *recordPtr)
520 {
521 Labelframe *lframe = recordPtr;
531 static void LabelframeInitialize(
532 TCL_UNUSED(Tcl_Interp *),
533 void *recordPtr)
534 {
535 Labelframe *lframe = (Labelframe *)recordPtr;
522536
523537 lframe->label.mgr = Ttk_CreateManager(
524538 &LabelframeManagerSpec, lframe, lframe->core.tkwin);
532546 */
533547 static void LabelframeCleanup(void *recordPtr)
534548 {
535 Labelframe *lframe = recordPtr;
549 Labelframe *lframe = (Labelframe *)recordPtr;
536550 Ttk_DeleteManager(lframe->label.mgr);
537551 if (lframe->label.labelLayout) {
538552 Ttk_FreeLayout(lframe->label.labelLayout);
563577 */
564578 static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask)
565579 {
566 Labelframe *lframePtr = recordPtr;
580 Labelframe *lframePtr = (Labelframe *)recordPtr;
567581 Tk_Window labelWidget = lframePtr->label.labelWidget;
568582 Ttk_PositionSpec unused;
569583
590604 /* Update -labelwidget changes, if any:
591605 */
592606 if (mask & LABELWIDGET_CHANGED) {
593 if (Ttk_NumberSlaves(lframePtr->label.mgr) == 1) {
594 Ttk_ForgetSlave(lframePtr->label.mgr, 0);
607 if (Ttk_NumberContent(lframePtr->label.mgr) == 1) {
608 Ttk_ForgetContent(lframePtr->label.mgr, 0);
595609 /* Restore labelWidget field (see <<NOTE-LABELREMOVED>>)
596610 */
597611 lframePtr->label.labelWidget = labelWidget;
598612 }
599613
600614 if (labelWidget) {
601 Ttk_InsertSlave(lframePtr->label.mgr, 0, labelWidget, NULL);
615 Ttk_InsertContent(lframePtr->label.mgr, 0, labelWidget, NULL);
602616 RaiseLabelWidget(lframePtr);
603617 }
604618 }
283283 # Results:
284284 # Returns the original text inside an appropriate #ifdef.
285285
286 proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} {
286 proc genStubs::addPlatformGuard {plat iftxt {eltxt {}} {withCygwin 0}} {
287287 set text ""
288288 switch $plat {
289289 win {
290 append text "#ifdef _WIN32 /* WIN */\n${iftxt}"
290 append text "#if defined(_WIN32)"
291 if {$withCygwin} {
292 append text " || defined(__CYGWIN__)"
293 }
294 append text " /* WIN */\n${iftxt}"
291295 if {$eltxt ne ""} {
292296 append text "#else /* WIN */\n${eltxt}"
293297 }
294298 append text "#endif /* WIN */\n"
295299 }
296300 unix {
297 append text "#if !defined(_WIN32) && !defined(MAC_OSX_TCL)\
301 append text "#if !defined(_WIN32)"
302 if {$withCygwin} {
303 append text " && !defined(__CYGWIN__)"
304 }
305 append text " && !defined(MAC_OSX_TCL)\
298306 /* UNIX */\n${iftxt}"
299307 if {$eltxt ne ""} {
300308 append text "#else /* UNIX */\n${eltxt}"
316324 append text "#endif /* AQUA */\n"
317325 }
318326 x11 {
319 append text "#if !(defined(_WIN32) || defined(MAC_OSX_TK))\
327 append text "#if !(defined(_WIN32)"
328 if {$withCygwin} {
329 append text " || defined(__CYGWIN__)"
330 }
331 append text " || defined(MAC_OSX_TK))\
320332 /* X11 */\n${iftxt}"
321333 if {$eltxt ne ""} {
322334 append text "#else /* X11 */\n${eltxt}"
449461
450462 proc genStubs::makeDecl {name decl index} {
451463 variable scspec
464 variable stubs
465 variable libraryName
452466 lassign $decl rtype fname args
453467
454468 append text "/* $index */\n"
455 set line "$scspec $rtype"
469 if {[info exists stubs($name,deprecated,$index)]} {
470 append text "[string toupper $libraryName]_DEPRECATED(\"$stubs($name,deprecated,$index)\")\n"
471 set line "$rtype"
472 } elseif {[string range $rtype end-5 end] eq "MP_WUR"} {
473 set line "$scspec [string trim [string range $rtype 0 end-6]]"
474 } else {
475 set line "$scspec $rtype"
476 }
456477 set count [expr {2 - ([string length $line] / 8)}]
457 append line [string range "\t\t\t" 0 $count]
478 if {$count >= 0} {
479 append line [string range "\t\t\t" 0 $count]
480 }
458481 set pad [expr {24 - [string length $line]}]
459482 if {$pad <= 0} {
460483 append line " "
493516 set sep ", "
494517 }
495518 append line ", ...)"
519 if {[lindex $args end] eq "{const char *} format"} {
520 append line " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")"
521 }
496522 }
497523 default {
498524 set sep "("
516542 append line ")"
517543 }
518544 }
545 if {[string range $rtype end-5 end] eq "MP_WUR"} {
546 append line " MP_WUR"
547 }
519548 return "$text$line;\n"
520549 }
521550
560589
561590 proc genStubs::makeSlot {name decl index} {
562591 lassign $decl rtype fname args
592 variable stubs
563593
564594 set lfname [string tolower [string index $fname 0]]
565595 append lfname [string range $fname 1 end]
566596
567597 set text " "
598 if {[info exists stubs($name,deprecated,$index)]} {
599 append text "TCL_DEPRECATED_API(\"$stubs($name,deprecated,$index)\") "
600 } elseif {[info exists stubs($name,nostub,$index)]} {
601 append text "TCL_DEPRECATED_API(\"$stubs($name,nostub,$index)\") "
602 }
568603 if {$args eq ""} {
569604 append text $rtype " *" $lfname "; /* $index */\n"
570605 return $text
571606 }
572607 if {[string range $rtype end-8 end] eq "__stdcall"} {
573608 append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") "
609 } elseif {[string range $rtype 0 11] eq "TCL_NORETURN"} {
610 append text "TCL_NORETURN1 " [string trim [string range $rtype 12 end]] " (*" $lfname ") "
611 } elseif {[string range $rtype end-5 end] eq "MP_WUR"} {
612 append text [string trim [string range $rtype 0 end-6]] " (*" $lfname ") "
574613 } else {
575614 append text $rtype " (*" $lfname ") "
576615 }
590629 set sep ", "
591630 }
592631 append text ", ...)"
632 if {[lindex $args end] eq "{const char *} format"} {
633 append text " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")"
634 }
593635 }
594636 default {
595637 set sep "("
605647 }
606648 }
607649
650 if {[string range $rtype end-5 end] eq "MP_WUR"} {
651 append text " MP_WUR"
652 }
608653 append text "; /* $index */\n"
609654 return $text
610655 }
836881 }
837882 foreach intf [array names interfaces] {
838883 if {[info exists hooks($intf)]} {
839 if {[lsearch -exact $hooks($intf) $name] >= 0} {
884 if {$name in $hooks($intf)} {
840885 set root 0
841886 break
842887 }
99 * [style map].
1010 */
1111
12 #include <string.h>
13 #include <tk.h>
12 #include "tkInt.h"
1413 #include "ttkTheme.h"
1514
1615 #define MIN(a,b) ((a) < (b) ? (a) : (b))
33 * Ttk package: initialization routine and miscellaneous utilities.
44 */
55
6 #include <string.h>
7 #include <tk.h>
6 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
109
114113 */
115114 void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName)
116115 {
117 union {XEvent general; XVirtualEvent virtual;} event;
116 union {XEvent general; XVirtualEvent virt;} event;
118117
119118 memset(&event, 0, sizeof(event));
120119 event.general.xany.type = VirtualEvent;
122121 event.general.xany.send_event = False;
123122 event.general.xany.window = Tk_WindowId(tgtWin);
124123 event.general.xany.display = Tk_Display(tgtWin);
125 event.virtual.name = Tk_GetUid(eventName);
124 event.virt.name = Tk_GetUid(eventName);
126125
127126 Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
128127 }
274273
275274 Ttk_PlatformInit(interp);
276275
277 Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (ClientData)&ttkStubs);
276 Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
278277
279278 return TCL_OK;
280279 }
6464 Tk_Offset(TextElement,wrapLengthObj), "0" },
6565 { "-embossed", TK_OPTION_INT,
6666 Tk_Offset(TextElement,embossedObj), "0"},
67 { NULL, 0, 0, NULL }
67 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
6868 };
6969
7070 static int TextSetup(TextElement *text, Tk_Window tkwin)
137137 gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin));
138138 gc2 = Tk_GetGC(tkwin, GCFont | GCForeground, &gcValues);
139139
140 /*
140 /*
141141 * Place text according to -anchor:
142142 */
143143 Tk_GetAnchorFromObj(NULL, text->anchorObj, &anchor);
192192 }
193193
194194 static void TextElementSize(
195 void *clientData, void *elementRecord, Tk_Window tkwin,
195 void *dummy, void *elementRecord, Tk_Window tkwin,
196196 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
197197 {
198 TextElement *text = elementRecord;
198 TextElement *text = (TextElement *)elementRecord;
199 (void)dummy;
200 (void)paddingPtr;
199201
200202 if (!TextSetup(text, tkwin))
201203 return;
209211 }
210212
211213 static void TextElementDraw(
212 void *clientData, void *elementRecord, Tk_Window tkwin,
214 void *dummy, void *elementRecord, Tk_Window tkwin,
213215 Drawable d, Ttk_Box b, Ttk_State state)
214216 {
215 TextElement *text = elementRecord;
217 TextElement *text = (TextElement *)elementRecord;
218 (void)dummy;
219 (void)state;
220
216221 if (TextSetup(text, tkwin)) {
217222 TextDraw(text, tkwin, d, b);
218223 TextCleanup(text);
252257 Tk_Offset(ImageElement,stippleObj), "gray50" },
253258 { "-background", TK_OPTION_COLOR,
254259 Tk_Offset(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
255 { NULL, 0, 0, NULL }
260 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
256261 };
257262
258263 /*
340345
341346 Tk_RedrawImage(image->tkimg, 0,0, width, height, d, b.x, b.y);
342347
343 /* If we're disabled there's no state-specific 'disabled' image,
348 /* If we're disabled there's no state-specific 'disabled' image,
344349 * stipple the image.
345350 * @@@ Possibly: Don't do disabled-stippling at all;
346351 * @@@ it's ugly and out of fashion.
347 * Do not stipple at all under Aqua, just draw the image: it shows up
352 * Do not stipple at all under Aqua, just draw the image: it shows up
348353 * as a white rectangle otherwise.
349354 */
350355
351
356
352357 if (state & TTK_STATE_DISABLED) {
353358 if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) {
354359 #ifndef MAC_OSX_TK
359364 }
360365
361366 static void ImageElementSize(
362 void *clientData, void *elementRecord, Tk_Window tkwin,
367 void *dummy, void *elementRecord, Tk_Window tkwin,
363368 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
364369 {
365 ImageElement *image = elementRecord;
370 ImageElement *image = (ImageElement *)elementRecord;
371 (void)dummy;
372 (void)paddingPtr;
366373
367374 if (ImageSetup(image, tkwin, 0)) {
368375 *widthPtr = image->width;
372379 }
373380
374381 static void ImageElementDraw(
375 void *clientData, void *elementRecord, Tk_Window tkwin,
382 void *dummy, void *elementRecord, Tk_Window tkwin,
376383 Drawable d, Ttk_Box b, Ttk_State state)
377384 {
378 ImageElement *image = elementRecord;
385 ImageElement *image = (ImageElement *)elementRecord;
386 (void)dummy;
379387
380388 if (ImageSetup(image, tkwin, state)) {
381389 ImageDraw(image, tkwin, d, b, state);
476484 Tk_Offset(LabelElement,image.stippleObj), "gray50" },
477485 { "-background", TK_OPTION_COLOR,
478486 Tk_Offset(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
479 { NULL, 0, 0, NULL }
487 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
480488 };
481489
482490 /*
493501 {
494502 Ttk_Compound *compoundPtr = &c->compound;
495503
496 Tk_GetPixelsFromObj(NULL,tkwin,c->spaceObj,&c->space);
497 Ttk_GetCompoundFromObj(NULL,c->compoundObj,(int*)compoundPtr);
504 Tk_GetPixelsFromObj(NULL, tkwin, c->spaceObj, &c->space);
505 Ttk_GetCompoundFromObj(NULL, c->compoundObj, (int *)compoundPtr);
498506
499507 /*
500508 * Deal with TTK_COMPOUND_NONE.
560568 }
561569
562570 static void LabelElementSize(
563 void *clientData, void *elementRecord, Tk_Window tkwin,
571 void *dummy, void *elementRecord, Tk_Window tkwin,
564572 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
565573 {
566 LabelElement *label = elementRecord;
574 LabelElement *label = (LabelElement *)elementRecord;
567575 int textReqWidth = 0;
576 (void)dummy;
577 (void)paddingPtr;
568578
569579 LabelSetup(label, tkwin, 0);
570580
575585 if (label->compound != TTK_COMPOUND_IMAGE)
576586 textReqWidth = TextReqWidth(&label->text);
577587
578 switch (label->compound)
588 switch (label->compound)
579589 {
580590 case TTK_COMPOUND_TEXT:
581591 *widthPtr = textReqWidth;
586596 case TTK_COMPOUND_TOP:
587597 case TTK_COMPOUND_BOTTOM:
588598 case TTK_COMPOUND_CENTER:
589 *widthPtr = MAX(label->image.width, textReqWidth);
599 *widthPtr = MAX(label->image.width, textReqWidth);
590600 break;
591601 case TTK_COMPOUND_LEFT:
592602 case TTK_COMPOUND_RIGHT:
593 *widthPtr = label->image.width + textReqWidth + label->space;
603 *widthPtr = label->image.width + textReqWidth + label->space;
594604 break;
595605 case TTK_COMPOUND_NONE:
596606 break; /* Can't happen */
617627 }
618628
619629 static void LabelElementDraw(
620 void *clientData, void *elementRecord, Tk_Window tkwin,
630 void *dummy, void *elementRecord, Tk_Window tkwin,
621631 Drawable d, Ttk_Box b, Ttk_State state)
622632 {
623 LabelElement *l = elementRecord;
633 LabelElement *l = (LabelElement *)elementRecord;
624634 Tk_Anchor anchor = TK_ANCHOR_CENTER;
635 (void)dummy;
625636
626637 LabelSetup(l, tkwin, state);
627638
55 * Copyright (c) 2003 Joe English. Freely redistributable.
66 */
77
8 #include <string.h>
98 #include "tkInt.h"
109 #include "ttkThemeInt.h"
1110
809808 APPENDSTR("-sticky");
810809 APPENDOBJ(Ttk_NewStickyObj(flags & _TTK_MASK_STICK));
811810
812 /* @@@ Check again: are these necessary? */
811 /* @@@ Check again: are these necessary? Can't see any effect! */
813812 if (flags & TTK_BORDER) { APPENDSTR("-border"); APPENDSTR("1"); }
814813 if (flags & TTK_UNIT) { APPENDSTR("-unit"); APPENDSTR("1"); }
815814
33 * Support routines for geometry managers.
44 */
55
6 #include <string.h>
7 #include <tk.h>
6 #include "tkInt.h"
87 #include "ttkManager.h"
98
109 /*------------------------------------------------------------------------
1110 * +++ The Geometry Propagation Dance.
1211 *
13 * When a slave window requests a new size or some other parameter changes,
14 * the manager recomputes the required size for the master window and calls
12 * When a content window requests a new size or some other parameter changes,
13 * the manager recomputes the required size for the container window and calls
1514 * Tk_GeometryRequest(). This is scheduled as an idle handler so multiple
1615 * updates can be processed as a single batch.
1716 *
18 * If all goes well, the master's manager will process the request
19 * (and so on up the chain to the toplevel window), and the master
17 * If all goes well, the container's manager will process the request
18 * (and so on up the chain to the toplevel window), and the container
2019 * window will eventually receive a <Configure> event. At this point
21 * it recomputes the size and position of all slaves and places them.
22 *
23 * If all does not go well, however, the master's request may be ignored
20 * it recomputes the size and position of all content windows and places them.
21 *
22 * If all does not go well, however, the container's request may be ignored
2423 * (typically because the top-level window has a fixed, user-specified size).
2524 * Tk doesn't provide any notification when this happens; to account for this,
2625 * we also schedule an idle handler to call the layout procedure
2726 * after making a geometry request.
2827 *
29 * +++ Slave removal <<NOTE-LOSTSLAVE>>.
30 *
31 * There are three conditions under which a slave is removed:
28 * +++ Content window removal <<NOTE-LOSTCONTENT>>.
29 *
30 * There are three conditions under which a content window is removed:
3231 *
3332 * (1) Another GM claims control
3433 * (2) Manager voluntarily relinquishes control
35 * (3) Slave is destroyed
34 * (3) Content window is destroyed
3635 *
3736 * In case (1), Tk calls the manager's lostSlaveProc.
38 * Case (2) is performed by calling Tk_ManageGeometry(slave,NULL,0);
39 * in this case Tk does _not_ call the LostSlaveProc (documented behavior).
37 * Case (2) is performed by calling Tk_ManageGeometry(window,NULL,0);
38 * in this case Tk does _not_ call the lostSlaveProc (documented behavior).
4039 * Tk doesn't handle case (3) either; to account for that we
41 * register an event handler on the slave widget to track <Destroy> events.
40 * register an event handler on the content window to track <Destroy> events.
4241 */
4342
4443 /* ++ Data structures.
4544 */
4645 typedef struct
4746 {
48 Tk_Window slaveWindow;
47 Tk_Window window;
4948 Ttk_Manager *manager;
50 void *slaveData;
49 void *data;
5150 unsigned flags;
52 } Ttk_Slave;
53
54 /* slave->flags bits:
55 */
56 #define SLAVE_MAPPED 0x1 /* slave to be mapped when master is */
51 } Ttk_Content;
52
53 /* content->flags bits:
54 */
55 #define CONTENT_MAPPED 0x1 /* content windows to be mapped when container is */
5756
5857 struct TtkManager_
5958 {
6059 Ttk_ManagerSpec *managerSpec;
6160 void *managerData;
62 Tk_Window masterWindow;
61 Tk_Window window;
6362 unsigned flags;
64 int nSlaves;
65 Ttk_Slave **slaves;
63 int nContent;
64 Ttk_Content **content;
6665 };
6766
6867 /* manager->flags bits:
8786 }
8887
8988 /* ++ RecomputeSize --
90 * Recomputes the required size of the master window,
89 * Recomputes the required size of the container window,
9190 * makes geometry request.
9291 */
9392 static void RecomputeSize(Ttk_Manager *mgr)
9594 int width = 1, height = 1;
9695
9796 if (mgr->managerSpec->RequestedSize(mgr->managerData, &width, &height)) {
98 Tk_GeometryRequest(mgr->masterWindow, width, height);
97 Tk_GeometryRequest(mgr->window, width, height);
9998 ScheduleUpdate(mgr, MGR_RELAYOUT_REQUIRED);
10099 }
101100 mgr->flags &= ~MGR_RESIZE_REQUIRED;
102101 }
103102
104103 /* ++ RecomputeLayout --
105 * Recompute geometry of all slaves.
104 * Recompute geometry of all content windows.
106105 */
107106 static void RecomputeLayout(Ttk_Manager *mgr)
108107 {
115114 */
116115 static void ManagerIdleProc(ClientData clientData)
117116 {
118 Ttk_Manager *mgr = clientData;
117 Ttk_Manager *mgr = (Ttk_Manager *)clientData;
119118 mgr->flags &= ~MGR_UPDATE_PENDING;
120119
121120 if (mgr->flags & MGR_RESIZE_REQUIRED) {
135134 */
136135
137136 /* ++ ManagerEventHandler --
138 * Recompute slave layout when master widget is resized.
139 * Keep the slave's map state in sync with the master's.
137 * Recompute content layout when container widget is resized.
138 * Keep the content's map state in sync with the container's.
140139 */
141140 static const int ManagerEventMask = StructureNotifyMask;
142141 static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr)
143142 {
144 Ttk_Manager *mgr = clientData;
143 Ttk_Manager *mgr = (Ttk_Manager *)clientData;
145144 int i;
146145
147146 switch (eventPtr->type)
150149 RecomputeLayout(mgr);
151150 break;
152151 case MapNotify:
153 for (i = 0; i < mgr->nSlaves; ++i) {
154 Ttk_Slave *slave = mgr->slaves[i];
155 if (slave->flags & SLAVE_MAPPED) {
156 Tk_MapWindow(slave->slaveWindow);
152 for (i = 0; i < mgr->nContent; ++i) {
153 Ttk_Content *content = mgr->content[i];
154 if (content->flags & CONTENT_MAPPED) {
155 Tk_MapWindow(content->window);
157156 }
158157 }
159158 break;
160159 case UnmapNotify:
161 for (i = 0; i < mgr->nSlaves; ++i) {
162 Ttk_Slave *slave = mgr->slaves[i];
163 Tk_UnmapWindow(slave->slaveWindow);
160 for (i = 0; i < mgr->nContent; ++i) {
161 Ttk_Content *content = mgr->content[i];
162 Tk_UnmapWindow(content->window);
164163 }
165164 break;
166165 }
167166 }
168167
169 /* ++ SlaveEventHandler --
170 * Notifies manager when a slave is destroyed
171 * (see <<NOTE-LOSTSLAVE>>).
172 */
173 static const unsigned SlaveEventMask = StructureNotifyMask;
174 static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr)
175 {
176 Ttk_Slave *slave = clientData;
168 /* ++ ContentLostEventHandler --
169 * Notifies manager when a content window is destroyed
170 * (see <<NOTE-LOSTCONTENT>>).
171 */
172 static void ContentLostEventHandler(void *clientData, XEvent *eventPtr)
173 {
174 Ttk_Content *content = (Ttk_Content *)clientData;
177175 if (eventPtr->type == DestroyNotify) {
178 slave->manager->managerSpec->tkGeomMgr.lostSlaveProc(
179 slave->manager, slave->slaveWindow);
180 }
181 }
182
183 /*------------------------------------------------------------------------
184 * +++ Slave initialization and cleanup.
185 */
186
187 static Ttk_Slave *NewSlave(
188 Ttk_Manager *mgr, Tk_Window slaveWindow, void *slaveData)
189 {
190 Ttk_Slave *slave = ckalloc(sizeof(*slave));
191
192 slave->slaveWindow = slaveWindow;
193 slave->manager = mgr;
194 slave->flags = 0;
195 slave->slaveData = slaveData;
196
197 return slave;
198 }
199
200 static void DeleteSlave(Ttk_Slave *slave)
201 {
202 ckfree(slave);
176 content->manager->managerSpec->tkGeomMgr.lostSlaveProc(
177 content->manager, content->window);
178 }
179 }
180
181 /*------------------------------------------------------------------------
182 * +++ Content initialization and cleanup.
183 */
184
185 static Ttk_Content *NewContent(
186 Ttk_Manager *mgr, Tk_Window window, void *data)
187 {
188 Ttk_Content *content = (Ttk_Content *)ckalloc(sizeof(Ttk_Content));
189
190 content->window = window;
191 content->manager = mgr;
192 content->flags = 0;
193 content->data = data;
194
195 return content;
196 }
197
198 static void DeleteContent(Ttk_Content *content)
199 {
200 ckfree(content);
203201 }
204202
205203 /*------------------------------------------------------------------------
207205 */
208206
209207 Ttk_Manager *Ttk_CreateManager(
210 Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window masterWindow)
211 {
212 Ttk_Manager *mgr = ckalloc(sizeof(*mgr));
208 Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window window)
209 {
210 Ttk_Manager *mgr = (Ttk_Manager *)ckalloc(sizeof(*mgr));
213211
214212 mgr->managerSpec = managerSpec;
215213 mgr->managerData = managerData;
216 mgr->masterWindow = masterWindow;
217 mgr->nSlaves = 0;
218 mgr->slaves = NULL;
214 mgr->window = window;
215 mgr->nContent = 0;
216 mgr->content = NULL;
219217 mgr->flags = 0;
220218
221219 Tk_CreateEventHandler(
222 mgr->masterWindow, ManagerEventMask, ManagerEventHandler, mgr);
220 mgr->window, ManagerEventMask, ManagerEventHandler, mgr);
223221
224222 return mgr;
225223 }
227225 void Ttk_DeleteManager(Ttk_Manager *mgr)
228226 {
229227 Tk_DeleteEventHandler(
230 mgr->masterWindow, ManagerEventMask, ManagerEventHandler, mgr);
231
232 while (mgr->nSlaves > 0) {
233 Ttk_ForgetSlave(mgr, mgr->nSlaves - 1);
234 }
235 if (mgr->slaves) {
236 ckfree(mgr->slaves);
228 mgr->window, ManagerEventMask, ManagerEventHandler, mgr);
229
230 while (mgr->nContent > 0) {
231 Ttk_ForgetContent(mgr, mgr->nContent - 1);
232 }
233 if (mgr->content) {
234 ckfree(mgr->content);
237235 }
238236
239237 Tcl_CancelIdleCall(ManagerIdleProc, mgr);
242240 }
243241
244242 /*------------------------------------------------------------------------
245 * +++ Slave management.
246 */
247
248 /* ++ InsertSlave --
249 * Adds slave to the list of managed windows.
250 */
251 static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index)
252 {
253 int endIndex = mgr->nSlaves++;
254 mgr->slaves = ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *));
243 * +++ Content window management.
244 */
245
246 /* ++ InsertContent --
247 * Adds content to the list of managed windows.
248 */
249 static void InsertContent(Ttk_Manager *mgr, Ttk_Content *content, int index)
250 {
251 int endIndex = mgr->nContent++;
252 mgr->content = (Ttk_Content **)ckrealloc(mgr->content, mgr->nContent * sizeof(Ttk_Content *));
255253
256254 while (endIndex > index) {
257 mgr->slaves[endIndex] = mgr->slaves[endIndex - 1];
255 mgr->content[endIndex] = mgr->content[endIndex - 1];
258256 --endIndex;
259257 }
260258
261 mgr->slaves[index] = slave;
262
263 Tk_ManageGeometry(slave->slaveWindow,
264 &mgr->managerSpec->tkGeomMgr, (ClientData)mgr);
265
266 Tk_CreateEventHandler(slave->slaveWindow,
267 SlaveEventMask, SlaveEventHandler, (ClientData)slave);
259 mgr->content[index] = content;
260
261 Tk_ManageGeometry(content->window,
262 &mgr->managerSpec->tkGeomMgr, mgr);
263
264 Tk_CreateEventHandler(content->window,
265 StructureNotifyMask, ContentLostEventHandler, content);
268266
269267 ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
270268 }
271269
272 /* RemoveSlave --
273 * Unmanage and delete the slave.
270 /* RemoveContent --
271 * Unmanage and delete the content window.
274272 *
275273 * NOTES/ASSUMPTIONS:
276274 *
277275 * [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this
278 * routine is called from the slave's DestroyNotify event handler.
279 */
280 static void RemoveSlave(Ttk_Manager *mgr, int index)
281 {
282 Ttk_Slave *slave = mgr->slaves[index];
276 * routine is called from the content window's DestroyNotify event handler.
277 */
278 static void RemoveContent(Ttk_Manager *mgr, int index)
279 {
280 Ttk_Content *content = mgr->content[index];
283281 int i;
284282
285283 /* Notify manager:
288286
289287 /* Remove from array:
290288 */
291 --mgr->nSlaves;
292 for (i = index ; i < mgr->nSlaves; ++i) {
293 mgr->slaves[i] = mgr->slaves[i+1];
289 --mgr->nContent;
290 for (i = index ; i < mgr->nContent; ++i) {
291 mgr->content[i] = mgr->content[i+1];
294292 }
295293
296294 /* Clean up:
297295 */
298296 Tk_DeleteEventHandler(
299 slave->slaveWindow, SlaveEventMask, SlaveEventHandler, slave);
297 content->window, StructureNotifyMask, ContentLostEventHandler, content);
300298
301299 /* Note [1] */
302 Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow);
303 Tk_UnmapWindow(slave->slaveWindow);
304
305 DeleteSlave(slave);
300 Tk_UnmaintainGeometry(content->window, mgr->window);
301 Tk_UnmapWindow(content->window);
302
303 DeleteContent(content);
306304
307305 ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
308306 }
311309 * +++ Tk_GeomMgr hooks.
312310 */
313311
314 void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow)
315 {
316 Ttk_Manager *mgr = clientData;
317 int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow);
318 int reqWidth = Tk_ReqWidth(slaveWindow);
319 int reqHeight= Tk_ReqHeight(slaveWindow);
312 void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window)
313 {
314 Ttk_Manager *mgr = (Ttk_Manager *)clientData;
315 int index = Ttk_ContentIndex(mgr, window);
316 int reqWidth = Tk_ReqWidth(window);
317 int reqHeight= Tk_ReqHeight(window);
320318
321319 if (mgr->managerSpec->SlaveRequest(
322 mgr->managerData, slaveIndex, reqWidth, reqHeight))
320 mgr->managerData, index, reqWidth, reqHeight))
323321 {
324322 ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
325323 }
326324 }
327325
328 void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow)
329 {
330 Ttk_Manager *mgr = clientData;
331 int index = Ttk_SlaveIndex(mgr, slaveWindow);
326 void Ttk_LostContentProc(ClientData clientData, Tk_Window window)
327 {
328 Ttk_Manager *mgr = (Ttk_Manager *)clientData;
329 int index = Ttk_ContentIndex(mgr, window);
332330
333331 /* ASSERT: index >= 0 */
334 RemoveSlave(mgr, index);
332 RemoveContent(mgr, index);
335333 }
336334
337335 /*------------------------------------------------------------------------
338336 * +++ Public API.
339337 */
340338
341 /* ++ Ttk_InsertSlave --
342 * Add a new slave window at the specified index.
343 */
344 void Ttk_InsertSlave(
345 Ttk_Manager *mgr, int index, Tk_Window tkwin, void *slaveData)
346 {
347 Ttk_Slave *slave = NewSlave(mgr, tkwin, slaveData);
348 InsertSlave(mgr, slave, index);
349 }
350
351 /* ++ Ttk_ForgetSlave --
352 * Unmanage the specified slave.
353 */
354 void Ttk_ForgetSlave(Ttk_Manager *mgr, int slaveIndex)
355 {
356 Tk_Window slaveWindow = mgr->slaves[slaveIndex]->slaveWindow;
357 RemoveSlave(mgr, slaveIndex);
358 Tk_ManageGeometry(slaveWindow, NULL, 0);
359 }
360
361 /* ++ Ttk_PlaceSlave --
362 * Set the position and size of the specified slave window.
339 /* ++ Ttk_InsertContent --
340 * Add a new content window at the specified index.
341 */
342 void Ttk_InsertContent(
343 Ttk_Manager *mgr, int index, Tk_Window tkwin, void *data)
344 {
345 Ttk_Content *content = NewContent(mgr, tkwin, data);
346 InsertContent(mgr, content, index);
347 }
348
349 /* ++ Ttk_ForgetContent --
350 * Unmanage the specified content window.
351 */
352 void Ttk_ForgetContent(Ttk_Manager *mgr, int index)
353 {
354 Tk_Window window = mgr->content[index]->window;
355 RemoveContent(mgr, index);
356 Tk_ManageGeometry(window, NULL, 0);
357 }
358
359 /* ++ Ttk_PlaceContent --
360 * Set the position and size of the specified content window.
363361 *
364362 * NOTES:
365363 * Contrary to documentation, Tk_MaintainGeometry doesn't always
366 * map the slave.
367 */
368 void Ttk_PlaceSlave(
369 Ttk_Manager *mgr, int slaveIndex, int x, int y, int width, int height)
370 {
371 Ttk_Slave *slave = mgr->slaves[slaveIndex];
372 Tk_MaintainGeometry(slave->slaveWindow,mgr->masterWindow,x,y,width,height);
373 slave->flags |= SLAVE_MAPPED;
374 if (Tk_IsMapped(mgr->masterWindow)) {
375 Tk_MapWindow(slave->slaveWindow);
376 }
377 }
378
379 /* ++ Ttk_UnmapSlave --
380 * Unmap the specified slave, but leave it managed.
381 */
382 void Ttk_UnmapSlave(Ttk_Manager *mgr, int slaveIndex)
383 {
384 Ttk_Slave *slave = mgr->slaves[slaveIndex];
385 Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow);
386 slave->flags &= ~SLAVE_MAPPED;
364 * map the content window.
365 */
366 void Ttk_PlaceContent(
367 Ttk_Manager *mgr, int index, int x, int y, int width, int height)
368 {
369 Ttk_Content *content = mgr->content[index];
370 Tk_MaintainGeometry(content->window,mgr->window,x,y,width,height);
371 content->flags |= CONTENT_MAPPED;
372 if (Tk_IsMapped(mgr->window)) {
373 Tk_MapWindow(content->window);
374 }
375 }
376
377 /* ++ Ttk_UnmapContent --
378 * Unmap the specified content window, but leave it managed.
379 */
380 void Ttk_UnmapContent(Ttk_Manager *mgr, int index)
381 {
382 Ttk_Content *content = mgr->content[index];
383 Tk_UnmaintainGeometry(content->window, mgr->window);
384 content->flags &= ~CONTENT_MAPPED;
387385 /* Contrary to documentation, Tk_UnmaintainGeometry doesn't always
388 * unmap the slave:
389 */
390 Tk_UnmapWindow(slave->slaveWindow);
386 * unmap the content window:
387 */
388 Tk_UnmapWindow(content->window);
391389 }
392390
393391 /* LayoutChanged, SizeChanged --
405403
406404 /* +++ Accessors.
407405 */
408 int Ttk_NumberSlaves(Ttk_Manager *mgr)
409 {
410 return mgr->nSlaves;
411 }
412 void *Ttk_SlaveData(Ttk_Manager *mgr, int slaveIndex)
413 {
414 return mgr->slaves[slaveIndex]->slaveData;
415 }
416 Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, int slaveIndex)
417 {
418 return mgr->slaves[slaveIndex]->slaveWindow;
406 int Ttk_NumberContent(Ttk_Manager *mgr)
407 {
408 return mgr->nContent;
409 }
410 void *Ttk_ContentData(Ttk_Manager *mgr, int index)
411 {
412 return mgr->content[index]->data;
413 }
414 Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, int index)
415 {
416 return mgr->content[index]->window;
419417 }
420418
421419 /*------------------------------------------------------------------------
422420 * +++ Utility routines.
423421 */
424422
425 /* ++ Ttk_SlaveIndex --
426 * Returns the index of specified slave window, -1 if not found.
427 */
428 int Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow)
423 /* ++ Ttk_ContentIndex --
424 * Returns the index of specified content window, -1 if not found.
425 */
426 int Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
429427 {
430428 int index;
431 for (index = 0; index < mgr->nSlaves; ++index)
432 if (mgr->slaves[index]->slaveWindow == slaveWindow)
429 for (index = 0; index < mgr->nContent; ++index)
430 if (mgr->content[index]->window == window)
433431 return index;
434432 return -1;
435433 }
436434
437 /* ++ Ttk_GetSlaveIndexFromObj(interp, mgr, objPtr, indexPtr) --
438 * Return the index of the slave specified by objPtr.
439 * Slaves may be specified as an integer index or
435 /* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, indexPtr) --
436 * Return the index of the content window specified by objPtr.
437 * Content windows may be specified as an integer index or
440438 * as the name of the managed window.
441439 *
442440 * Returns:
443441 * Standard Tcl completion code. Leaves an error message in case of error.
444442 */
445443
446 int Ttk_GetSlaveIndexFromObj(
444 int Ttk_GetContentIndexFromObj(
447445 Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int *indexPtr)
448446 {
449447 const char *string = Tcl_GetString(objPtr);
450 int slaveIndex = 0;
448 int index = 0;
451449 Tk_Window tkwin;
452450
453451 /* Try interpreting as an integer first:
454452 */
455 if (Tcl_GetIntFromObj(NULL, objPtr, &slaveIndex) == TCL_OK) {
456 if (slaveIndex < 0 || slaveIndex >= mgr->nSlaves) {
453 if (Tcl_GetIntFromObj(NULL, objPtr, &index) == TCL_OK) {
454 if (index < 0 || index >= mgr->nContent) {
457455 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
458 "Slave index %d out of bounds", slaveIndex));
456 "Slave index %d out of bounds", index));
459457 Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
460458 return TCL_ERROR;
461459 }
462 *indexPtr = slaveIndex;
460 *indexPtr = index;
463461 return TCL_OK;
464462 }
465463
466 /* Try interpreting as a slave window name;
464 /* Try interpreting as a window name;
467465 */
468466 if ((*string == '.') &&
469 (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow))) {
470 slaveIndex = Ttk_SlaveIndex(mgr, tkwin);
471 if (slaveIndex < 0) {
467 (tkwin = Tk_NameToWindow(interp, string, mgr->window))) {
468 index = Ttk_ContentIndex(mgr, tkwin);
469 if (index < 0) {
472470 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
473471 "%s is not managed by %s", string,
474 Tk_PathName(mgr->masterWindow)));
472 Tk_PathName(mgr->window)));
475473 Tcl_SetErrorCode(interp, "TTK", "SLAVE", "MANAGER", NULL);
476474 return TCL_ERROR;
477475 }
478 *indexPtr = slaveIndex;
476 *indexPtr = index;
479477 return TCL_OK;
480478 }
481479
485483 return TCL_ERROR;
486484 }
487485
488 /* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) --
489 * Change slave order.
490 */
491 void Ttk_ReorderSlave(Ttk_Manager *mgr, int fromIndex, int toIndex)
492 {
493 Ttk_Slave *moved = mgr->slaves[fromIndex];
486 /* ++ Ttk_ReorderContent(mgr, fromIndex, toIndex) --
487 * Change content window order.
488 */
489 void Ttk_ReorderContent(Ttk_Manager *mgr, int fromIndex, int toIndex)
490 {
491 Ttk_Content *moved = mgr->content[fromIndex];
494492
495493 /* Shuffle down: */
496494 while (fromIndex > toIndex) {
497 mgr->slaves[fromIndex] = mgr->slaves[fromIndex - 1];
495 mgr->content[fromIndex] = mgr->content[fromIndex - 1];
498496 --fromIndex;
499497 }
500498 /* Or, shuffle up: */
501499 while (fromIndex < toIndex) {
502 mgr->slaves[fromIndex] = mgr->slaves[fromIndex + 1];
500 mgr->content[fromIndex] = mgr->content[fromIndex + 1];
503501 ++fromIndex;
504502 }
505503 /* ASSERT: fromIndex == toIndex */
506 mgr->slaves[fromIndex] = moved;
507
508 /* Schedule a relayout. In general, rearranging slaves
504 mgr->content[fromIndex] = moved;
505
506 /* Schedule a relayout. In general, rearranging content
509507 * may also change the size:
510508 */
511509 ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
512510 }
513511
514 /* ++ Ttk_Maintainable(interp, slave, master) --
515 * Utility routine. Verifies that 'master' may be used to maintain
516 * the geometry of 'slave' via Tk_MaintainGeometry:
517 *
518 * + 'master' is either 'slave's parent -OR-
519 * + 'master is a descendant of 'slave's parent.
520 * + 'slave' is not a toplevel window
521 * + 'slave' belongs to the same toplevel as 'master'
512 /* ++ Ttk_Maintainable(interp, window, container) --
513 * Utility routine. Verifies that 'container' may be used to maintain
514 * the geometry of 'window' via Tk_MaintainGeometry:
515 *
516 * + 'container' is either 'window's parent -OR-
517 * + 'container is a descendant of 'window's parent.
518 * + 'window' is not a toplevel window
519 * + 'window' belongs to the same toplevel as 'container'
522520 *
523521 * Returns: 1 if OK; otherwise 0, leaving an error message in 'interp'.
524522 */
525 int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window slave, Tk_Window master)
526 {
527 Tk_Window ancestor = master, parent = Tk_Parent(slave);
528
529 if (Tk_IsTopLevel(slave) || slave == master) {
523 int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window window, Tk_Window container)
524 {
525 Tk_Window ancestor = container, parent = Tk_Parent(window);
526
527 if (Tk_IsTopLevel(window) || window == container) {
530528 goto badWindow;
531529 }
532530
541539
542540 badWindow:
543541 Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s",
544 Tk_PathName(slave), Tk_PathName(master)));
542 Tk_PathName(window), Tk_PathName(container)));
545543 Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL);
546544 return 0;
547545 }
1313 /*
1414 * Geometry manager specification record:
1515 *
16 * RequestedSize computes the requested size of the master window.
16 * RequestedSize computes the requested size of the container window.
1717 *
18 * PlaceSlaves sets the position and size of all managed slaves
19 * by calling Ttk_PlaceSlave().
18 * PlaceSlaves sets the position and size of all managed content windows
19 * by calling Ttk_PlaceContent().
2020 *
21 * SlaveRemoved() is called immediately before a slave is removed.
22 * NB: the associated slave window may have been destroyed when this
21 * SlaveRemoved() is called immediately before a content window is removed.
22 * NB: the associated content window may have been destroyed when this
2323 * routine is called.
24 *
25 * SlaveRequest() is called when a slave requests a size change.
24 *
25 * SlaveRequest() is called when a content window requests a size change.
2626 * It should return 1 if the request should propagate, 0 otherwise.
2727 */
2828 typedef struct { /* Manager hooks */
3030
3131 int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr);
3232 void (*PlaceSlaves)(void *managerData);
33 int (*SlaveRequest)(void *managerData, int slaveIndex, int w, int h);
34 void (*SlaveRemoved)(void *managerData, int slaveIndex);
33 int (*SlaveRequest)(void *managerData, int index, int w, int h);
34 void (*SlaveRemoved)(void *managerData, int index);
3535 } Ttk_ManagerSpec;
3636
3737 /*
3838 * Default implementations for Tk_GeomMgr hooks:
3939 */
40 MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window slave);
41 MODULE_SCOPE void Ttk_LostSlaveProc(ClientData, Tk_Window slave);
40 #define Ttk_LostContentProc Ttk_LostSlaveProc
41 MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window window);
42 MODULE_SCOPE void Ttk_LostContentProc(ClientData, Tk_Window window);
4243
4344 /*
4445 * Public API:
4546 */
4647 MODULE_SCOPE Ttk_Manager *Ttk_CreateManager(
47 Ttk_ManagerSpec *, void *managerData, Tk_Window masterWindow);
48 Ttk_ManagerSpec *, void *managerData, Tk_Window window);
4849 MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *);
4950
50 MODULE_SCOPE void Ttk_InsertSlave(
51 Ttk_Manager *, int position, Tk_Window, void *slaveData);
51 #define Ttk_InsertContent Ttk_InsertSlave
52 MODULE_SCOPE void Ttk_InsertContent(
53 Ttk_Manager *, int position, Tk_Window, void *data);
5254
53 MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, int slaveIndex);
55 #define Ttk_ForgetContent Ttk_ForgetSlave
56 MODULE_SCOPE void Ttk_ForgetContent(Ttk_Manager *, int index);
5457
55 MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, int fromIndex, int toIndex);
56 /* Rearrange slave positions */
58 #define Ttk_ReorderContent Ttk_ReorderSlave
59 MODULE_SCOPE void Ttk_ReorderContent(Ttk_Manager *, int fromIndex, int toIndex);
60 /* Rearrange content window positions */
5761
58 MODULE_SCOPE void Ttk_PlaceSlave(
59 Ttk_Manager *, int slaveIndex, int x, int y, int width, int height);
60 /* Position and map the slave */
62 #define Ttk_PlaceContent Ttk_PlaceSlave
63 MODULE_SCOPE void Ttk_PlaceContent(
64 Ttk_Manager *, int index, int x, int y, int width, int height);
65 /* Position and map the content window */
6166
62 MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, int slaveIndex);
63 /* Unmap the slave */
67 #define Ttk_UnmapContent Ttk_UnmapSlave
68 MODULE_SCOPE void Ttk_UnmapContent(Ttk_Manager *, int index);
69 /* Unmap the content window */
6470
6571 MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *);
6672 MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *);
6874
6975 /* Utilities:
7076 */
71 MODULE_SCOPE int Ttk_SlaveIndex(Ttk_Manager *, Tk_Window);
72 /* Returns: index in slave array of specified window, -1 if not found */
77 #define Ttk_ContentIndex Ttk_SlaveIndex
78 MODULE_SCOPE int Ttk_ContentIndex(Ttk_Manager *, Tk_Window);
79 /* Returns: index in content array of specified window, -1 if not found */
7380
74 MODULE_SCOPE int Ttk_GetSlaveIndexFromObj(
81 #define Ttk_GetContentIndexFromObj Ttk_GetSlaveIndexFromObj
82 MODULE_SCOPE int Ttk_GetContentIndexFromObj(
7583 Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, int *indexPtr);
7684
7785 /* Accessor functions:
7886 */
79 MODULE_SCOPE int Ttk_NumberSlaves(Ttk_Manager *);
80 /* Returns: number of managed slaves */
87 #define Ttk_NumberContent Ttk_NumberSlaves
88 MODULE_SCOPE int Ttk_NumberContent(Ttk_Manager *);
89 /* Returns: number of managed content windows */
8190
82 MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, int slaveIndex);
83 /* Returns: client data associated with slave */
91 #define Ttk_ContentData Ttk_SlaveData
92 MODULE_SCOPE void *Ttk_ContentData(Ttk_Manager *, int index);
93 /* Returns: client data associated with content window */
8494
85 MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, int slaveIndex);
86 /* Returns: slave window */
95 #define Ttk_ContentWindow Ttk_SlaveWindow
96 MODULE_SCOPE Tk_Window Ttk_ContentWindow(Ttk_Manager *, int index);
97 /* Returns: content window */
8798
88 MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window slave, Tk_Window master);
89 /* Returns: 1 if master can manage slave; 0 otherwise leaving error msg */
99 MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window content, Tk_Window container);
100 /* Returns: 1 if container can manage content; 0 otherwise leaving error msg */
90101
91102 #endif /* _TTKMANAGER */
11 * Copyright (c) 2004, Joe English
22 */
33
4 #include <string.h>
5 #include <ctype.h>
6 #include <stdio.h>
7 #include <tk.h>
4 #include "tkInt.h"
85
96 #include "ttkTheme.h"
107 #include "ttkWidget.h"
5653 * relevant to the tab.
5754 *
5855 * PaneOptionSpecs includes additional options for child window placement
59 * and is used to configure the slave.
56 * and is used to configure the content window.
6057 */
6158 static Tk_OptionSpec TabOptionSpecs[] =
6259 {
6360 {TK_OPTION_STRING_TABLE, "-state", "", "",
6461 "normal", -1,Tk_Offset(Tab,state),
65 0,(ClientData)TabStateStrings,0 },
62 0, (void *)TabStateStrings, 0 },
6663 {TK_OPTION_STRING, "-text", "text", "Text", "",
6764 Tk_Offset(Tab,textObj), -1, 0,0,GEOMETRY_CHANGED },
6865 {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
6966 Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
7067 {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
7168 NULL, Tk_Offset(Tab,compoundObj), -1,
72 TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED },
69 TK_OPTION_NULL_OK, (void *)ttkCompoundStrings, GEOMETRY_CHANGED },
7370 {TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
7471 Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED },
7572 {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
10198 int activeIndex; /* index of currently active tab */
10299 Ttk_Layout tabLayout; /* Sublayout for tabs */
103100
104 Ttk_Box clientArea; /* Where to pack slave widgets */
101 Ttk_Box clientArea; /* Where to pack content widgets */
105102 } NotebookPart;
106103
107104 typedef struct
190187 * +++ Tab management.
191188 */
192189
193 static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow)
190 static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window window)
194191 {
195192 Tk_OptionTable optionTable = nb->notebook.paneOptionTable;
196 void *record = ckalloc(sizeof(Tab));
193 Tab *record = (Tab *)ckalloc(sizeof(Tab));
197194 memset(record, 0, sizeof(Tab));
198195
199 if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
196 if (Tk_InitOptions(interp, (char *)record, optionTable, window) != TCL_OK) {
200197 ckfree(record);
201198 return NULL;
202199 }
212209 }
213210
214211 static int ConfigureTab(
215 Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window slaveWindow,
212 Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window window,
216213 int objc, Tcl_Obj *const objv[])
217214 {
218215 Ttk_Sticky sticky = tab->sticky;
220217 Tk_SavedOptions savedOptions;
221218 int mask = 0;
222219
223 if (Tk_SetOptions(interp, (ClientData)tab, nb->notebook.paneOptionTable,
224 objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK)
220 if (Tk_SetOptions(interp, (void *)tab, nb->notebook.paneOptionTable,
221 objc, objv, window, &savedOptions, &mask) != TCL_OK)
225222 {
226223 return TCL_ERROR;
227224 }
233230 {
234231 goto error;
235232 }
236 if (Ttk_GetPaddingFromObj(interp, slaveWindow, tab->paddingObj, &padding)
233 if (Ttk_GetPaddingFromObj(interp, window, tab->paddingObj, &padding)
237234 != TCL_OK)
238235 {
239236 goto error;
260257 static int IdentifyTab(Notebook *nb, int x, int y)
261258 {
262259 int index;
263 for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) {
264 Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
260 for (index = 0; index < Ttk_NumberContent(nb->notebook.mgr); ++index) {
261 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,index);
265262 if ( tab->state != TAB_STATE_HIDDEN
266263 && Ttk_BoxContains(tab->parcel, x,y))
267264 {
293290 static Ttk_State TabState(Notebook *nb, int index)
294291 {
295292 Ttk_State state = nb->core.state;
296 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
293 Tab *itab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
297294 int i = 0;
298295
299296 if (index == nb->notebook.currentIndex) {
305302 if (index == nb->notebook.activeIndex) {
306303 state |= TTK_STATE_ACTIVE;
307304 }
308 for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
309 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
305 for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
306 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
310307 if (tab->state == TAB_STATE_HIDDEN) {
311308 continue;
312309 }
315312 }
316313 break;
317314 }
318 for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) {
319 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
315 for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != -1; --i) {
316 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
320317 if (tab->state == TAB_STATE_HIDDEN) {
321318 continue;
322319 }
325322 }
326323 break;
327324 }
328 if (tab->state == TAB_STATE_DISABLED) {
325 if (itab->state == TAB_STATE_DISABLED) {
329326 state |= TTK_STATE_DISABLED;
330327 }
331328
356353 int tabrowWidth = 0, tabrowHeight = 0;
357354 int i;
358355
359 for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
360 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
356 for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
357 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
361358 Ttk_State tabState = TabState(nb,i);
362359
363360 Ttk_RebindSublayout(tabLayout, tab);
381378 *
382379 * Total height is tab height + client area height + pane internal padding
383380 * Total width is max(client width, tab width) + pane internal padding
384 * Client area size determined by max size of slaves,
381 * Client area size determined by max size of content windows,
385382 * overridden by -width and/or -height if nonzero.
386383 */
387384
388385 static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
389386 {
390 Notebook *nb = clientData;
387 Notebook *nb = (Notebook *)clientData;
391388 NotebookStyle nbstyle;
392389 Ttk_Padding padding;
393390 Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client");
398395
399396 NotebookStyleOptions(nb, &nbstyle);
400397
401 /* Compute max requested size of all slaves:
402 */
403 for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
404 Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, i);
405 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
406 int slaveWidth
407 = Tk_ReqWidth(slaveWindow) + Ttk_PaddingWidth(tab->padding);
408 int slaveHeight
409 = Tk_ReqHeight(slaveWindow) + Ttk_PaddingHeight(tab->padding);
410
411 clientWidth = MAX(clientWidth, slaveWidth);
412 clientHeight = MAX(clientHeight, slaveHeight);
398 /* Compute max requested size of all content windows:
399 */
400 for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
401 Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, i);
402 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
403 int width
404 = Tk_ReqWidth(window) + Ttk_PaddingWidth(tab->padding);
405 int height
406 = Tk_ReqHeight(window) + Ttk_PaddingHeight(tab->padding);
407
408 clientWidth = MAX(clientWidth, width);
409 clientHeight = MAX(clientHeight, height);
413410 }
414411
415412 /* Client width/height overridable by widget options:
464461 static void SqueezeTabs(
465462 Notebook *nb, int needed, int available)
466463 {
467 int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
464 int nTabs = Ttk_NumberContent(nb->notebook.mgr);
468465
469466 if (nTabs > 0) {
470467 int difference = available - needed;
473470 int i;
474471
475472 for (i = 0; i < nTabs; ++i) {
476 Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
473 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,i);
477474 double ad = slack + tab->width * delta;
478475 tab->width += (int)ad;
479476 slack = ad - (int)ad;
488485 Notebook *nb, Ttk_Box tabrowBox, Ttk_PositionSpec tabPlacement)
489486 {
490487 Ttk_Layout tabLayout = nb->notebook.tabLayout;
491 int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
488 int nTabs = Ttk_NumberContent(nb->notebook.mgr);
492489 int i;
493490
494491 for (i = 0; i < nTabs; ++i) {
495 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
492 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
496493 Ttk_State tabState = TabState(nb, i);
497494
498495 if (tab->state != TAB_STATE_HIDDEN) {
516513 * Computes notebook layout and places tabs.
517514 *
518515 * Side effects:
519 * Sets clientArea, used to place slave panes.
516 * Sets clientArea, used to place panes.
520517 */
521518 static void NotebookDoLayout(void *recordPtr)
522519 {
523 Notebook *nb = recordPtr;
520 Notebook *nb = (Notebook *)recordPtr;
524521 Tk_Window nbwin = nb->core.tkwin;
525522 Ttk_Box cavity = Ttk_WinBox(nbwin);
526523 int tabrowWidth = 0, tabrowHeight = 0;
570567 }
571568
572569 /*
573 * NotebookPlaceSlave --
570 * NotebookPlaceContent --
574571 * Set the position and size of a child widget
575 * based on the current client area and slave options:
576 */
577 static void NotebookPlaceSlave(Notebook *nb, int slaveIndex)
578 {
579 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
580 Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, slaveIndex);
581 Ttk_Box slaveBox =
572 * based on the current client area and content window options:
573 */
574 static void NotebookPlaceContent(Notebook *nb, int index)
575 {
576 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
577 Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index);
578 Ttk_Box box =
582579 Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding),
583 Tk_ReqWidth(slaveWindow), Tk_ReqHeight(slaveWindow),tab->sticky);
584
585 Ttk_PlaceSlave(nb->notebook.mgr, slaveIndex,
586 slaveBox.x, slaveBox.y, slaveBox.width, slaveBox.height);
587 }
588
589 /* NotebookPlaceSlaves --
580 Tk_ReqWidth(window), Tk_ReqHeight(window),tab->sticky);
581
582 Ttk_PlaceContent(nb->notebook.mgr, index,
583 box.x, box.y, box.width, box.height);
584 }
585
586 /* NotebookPlaceContents --
590587 * Geometry manager hook.
591588 */
592 static void NotebookPlaceSlaves(void *recordPtr)
593 {
594 Notebook *nb = recordPtr;
589 static void NotebookPlaceContents(void *recordPtr)
590 {
591 Notebook *nb = (Notebook *)recordPtr;
595592 int currentIndex = nb->notebook.currentIndex;
596593 if (currentIndex >= 0) {
597594 NotebookDoLayout(nb);
598 NotebookPlaceSlave(nb, currentIndex);
595 NotebookPlaceContent(nb, currentIndex);
599596 }
600597 }
601598
605602 */
606603 static void SelectTab(Notebook *nb, int index)
607604 {
608 Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
605 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
609606 int currentIndex = nb->notebook.currentIndex;
610607
611608 if (index == currentIndex) {
623620 }
624621
625622 if (currentIndex >= 0) {
626 Ttk_UnmapSlave(nb->notebook.mgr, currentIndex);
627 }
628
629 /* Must be set before calling NotebookPlaceSlave(), otherwise it may
630 * happen that NotebookPlaceSlaves(), triggered by an interveaning
623 Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
624 }
625
626 /* Must be set before calling NotebookPlaceContent(), otherwise it may
627 * happen that NotebookPlaceContents(), triggered by an interveaning
631628 * geometry request, will swap to old index. */
632629 nb->notebook.currentIndex = index;
633630
634 NotebookPlaceSlave(nb, index);
631 NotebookPlaceContent(nb, index);
635632 TtkRedisplayWidget(&nb->core);
636633
637634 TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
644641 */
645642 static int NextTab(Notebook *nb, int index)
646643 {
647 int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
644 int nTabs = Ttk_NumberContent(nb->notebook.mgr);
648645 int nextIndex;
649646
650647 /* Scan forward for following usable tab:
651648 */
652649 for (nextIndex = index + 1; nextIndex < nTabs; ++nextIndex) {
653 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
650 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
654651 if (tab->state == TAB_STATE_NORMAL) {
655652 return nextIndex;
656653 }
659656 /* Not found -- scan backwards.
660657 */
661658 for (nextIndex = index - 1; nextIndex >= 0; --nextIndex) {
662 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
659 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
663660 if (tab->state == TAB_STATE_NORMAL) {
664661 return nextIndex;
665662 }
683680 int nextIndex = NextTab(nb, currentIndex);
684681
685682 if (currentIndex >= 0) {
686 Ttk_UnmapSlave(nb->notebook.mgr, currentIndex);
683 Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
687684 }
688685 if (currentIndex != nextIndex) {
689686 TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
694691 TtkRedisplayWidget(&nb->core);
695692 }
696693
697 /* TabRemoved -- GM SlaveRemoved hook.
694 /* TabRemoved -- GM TabRemoved hook.
698695 * Select the next tab if the current one is being removed.
699 * Adjust currentIndex to account for removed slave.
696 * Adjust currentIndex to account for removed content window.
700697 */
701698 static void TabRemoved(void *managerData, int index)
702699 {
703 Notebook *nb = managerData;
704 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
700 Notebook *nb = (Notebook *)managerData;
701 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
705702
706703 if (index == nb->notebook.currentIndex) {
707704 SelectNearestTab(nb);
716713 TtkRedisplayWidget(&nb->core);
717714 }
718715
719 static int TabRequest(void *managerData, int index, int width, int height)
716 static int TabRequest(
717 TCL_UNUSED(void *),
718 TCL_UNUSED(int),
719 TCL_UNUSED(int),
720 TCL_UNUSED(int))
720721 {
721722 return 1;
722723 }
726727 */
727728 static int AddTab(
728729 Tcl_Interp *interp, Notebook *nb,
729 int destIndex, Tk_Window slaveWindow,
730 int destIndex, Tk_Window window,
730731 int objc, Tcl_Obj *const objv[])
731732 {
732733 Tab *tab;
733 if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) {
734 if (!Ttk_Maintainable(interp, window, nb->core.tkwin)) {
734735 return TCL_ERROR;
735736 }
736737 #if 0 /* can't happen */
737 if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) {
738 if (Ttk_ContentIndex(nb->notebook.mgr, window) >= 0) {
738739 Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added",
739 Tk_PathName(slaveWindow)));
740 Tk_PathName(window)));
740741 Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL);
741742 return TCL_ERROR;
742743 }
744745
745746 /* Create and insert tab.
746747 */
747 tab = CreateTab(interp, nb, slaveWindow);
748 tab = CreateTab(interp, nb, window);
748749 if (!tab) {
749750 return TCL_ERROR;
750751 }
751 if (ConfigureTab(interp, nb, tab, slaveWindow, objc, objv) != TCL_OK) {
752 if (ConfigureTab(interp, nb, tab, window, objc, objv) != TCL_OK) {
752753 DestroyTab(nb, tab);
753754 return TCL_ERROR;
754755 }
755756
756 Ttk_InsertSlave(nb->notebook.mgr, destIndex, slaveWindow, tab);
757 Ttk_InsertContent(nb->notebook.mgr, destIndex, window, tab);
757758
758759 /* Adjust indices and/or autoselect first tab:
759760 */
767768 }
768769
769770 static Ttk_ManagerSpec NotebookManagerSpec = {
770 { "notebook", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
771 { "notebook", Ttk_GeometryRequestProc, Ttk_LostContentProc },
771772 NotebookSize,
772 NotebookPlaceSlaves,
773 NotebookPlaceContents,
773774 TabRequest,
774775 TabRemoved
775776 };
788789 ;
789790 static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr)
790791 {
791 Notebook *nb = clientData;
792 Notebook *nb = (Notebook *)clientData;
792793
793794 if (eventPtr->type == DestroyNotify) { /* Remove self */
794795 Tk_DeleteEventHandler(nb->core.tkwin,
812813 * + positional specifications @x,y,
813814 * + "current",
814815 * + numeric indices [0..nTabs],
815 * + slave window names
816 * + content window names
816817 *
817818 * Stores index of specified tab in *index_rtn, -1 if not found.
818819 *
843844 return TCL_OK;
844845 }
845846
846 /* ... or integer index or slave window name:
847 */
848 if (Ttk_GetSlaveIndexFromObj(
847 /* ... or integer index or content window name:
848 */
849 if (Ttk_GetContentIndexFromObj(
849850 interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK)
850851 {
851852 return TCL_OK;
852853 }
853854
854 /* Nothing matched; Ttk_GetSlaveIndexFromObj will have left error message.
855 /* Nothing matched; Ttk_GetContentIndexFromObj will have left error message.
855856 */
856857 return TCL_ERROR;
857858 }
884885 static int NotebookAddCommand(
885886 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
886887 {
887 Notebook *nb = recordPtr;
888 int index = Ttk_NumberSlaves(nb->notebook.mgr);
889 Tk_Window slaveWindow;
890 int slaveIndex;
888 Notebook *nb = (Notebook *)recordPtr;
889 Tk_Window window;
890 int index;
891891 Tab *tab;
892892
893893 if (objc <= 2 || objc % 2 != 1) {
895895 return TCL_ERROR;
896896 }
897897
898 slaveWindow = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin);
899 if (!slaveWindow) {
900 return TCL_ERROR;
901 }
902 slaveIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow);
903
904 if (slaveIndex < 0) { /* New tab */
905 return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3);
906 }
907
908 tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
898 window = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin);
899 if (!window) {
900 return TCL_ERROR;
901 }
902 index = Ttk_ContentIndex(nb->notebook.mgr, window);
903
904 if (index < 0) { /* New tab */
905 return AddTab(interp, nb, Ttk_NumberContent(nb->notebook.mgr), window, objc-3,objv+3);
906 }
907
908 tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
909909 if (tab->state == TAB_STATE_HIDDEN) {
910910 tab->state = TAB_STATE_NORMAL;
911911 }
912 if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) {
912 if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) {
913913 return TCL_ERROR;
914914 }
915915
924924 static int NotebookInsertCommand(
925925 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
926926 {
927 Notebook *nb = recordPtr;
927 Notebook *nb = (Notebook *)recordPtr;
928928 int current = nb->notebook.currentIndex;
929 int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
929 int nContent = Ttk_NumberContent(nb->notebook.mgr);
930930 int srcIndex, destIndex;
931931
932932 if (objc < 4) {
935935 }
936936
937937 if (!strcmp(Tcl_GetString(objv[2]), "end")) {
938 destIndex = Ttk_NumberSlaves(nb->notebook.mgr);
939 } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
938 destIndex = Ttk_NumberContent(nb->notebook.mgr);
939 } else if (TCL_OK != Ttk_GetContentIndexFromObj(
940940 interp, nb->notebook.mgr, objv[2], &destIndex)) {
941941 return TCL_ERROR;
942942 }
943943
944944 if (Tcl_GetString(objv[3])[0] == '.') {
945 /* Window name -- could be new or existing slave.
945 /* Window name -- could be new or existing content window.
946946 */
947 Tk_Window slaveWindow =
947 Tk_Window window =
948948 Tk_NameToWindow(interp,Tcl_GetString(objv[3]),nb->core.tkwin);
949949
950 if (!slaveWindow) {
950 if (!window) {
951951 return TCL_ERROR;
952952 }
953953
954 srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow);
955 if (srcIndex < 0) { /* New slave */
956 return AddTab(interp, nb, destIndex, slaveWindow, objc-4,objv+4);
957 }
958 } else if (Ttk_GetSlaveIndexFromObj(
954 srcIndex = Ttk_ContentIndex(nb->notebook.mgr, window);
955 if (srcIndex < 0) { /* New content window */
956 return AddTab(interp, nb, destIndex, window, objc-4,objv+4);
957 }
958 } else if (Ttk_GetContentIndexFromObj(
959959 interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK)
960960 {
961961 return TCL_ERROR;
962962 }
963963
964 /* Move existing slave:
964 /* Move existing content window:
965965 */
966966 if (ConfigureTab(interp, nb,
967 Ttk_SlaveData(nb->notebook.mgr,srcIndex),
968 Ttk_SlaveWindow(nb->notebook.mgr,srcIndex),
967 (Tab *)Ttk_ContentData(nb->notebook.mgr, srcIndex),
968 Ttk_ContentWindow(nb->notebook.mgr, srcIndex),
969969 objc-4,objv+4) != TCL_OK)
970970 {
971971 return TCL_ERROR;
972972 }
973973
974 if (destIndex >= nSlaves) {
975 destIndex = nSlaves - 1;
976 }
977 Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex);
974 if (destIndex >= nContent) {
975 destIndex = nContent - 1;
976 }
977 Ttk_ReorderContent(nb->notebook.mgr, srcIndex, destIndex);
978978
979979 /* Adjust internal indexes:
980980 */
998998 static int NotebookForgetCommand(
999999 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
10001000 {
1001 Notebook *nb = recordPtr;
1001 Notebook *nb = (Notebook *)recordPtr;
10021002 int index;
10031003
10041004 if (objc != 3) {
10101010 return TCL_ERROR;
10111011 }
10121012
1013 Ttk_ForgetSlave(nb->notebook.mgr, index);
1013 Ttk_ForgetContent(nb->notebook.mgr, index);
10141014 TtkRedisplayWidget(&nb->core);
10151015
10161016 return TCL_OK;
10221022 static int NotebookHideCommand(
10231023 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
10241024 {
1025 Notebook *nb = recordPtr;
1025 Notebook *nb = (Notebook *)recordPtr;
10261026 int index;
10271027 Tab *tab;
10281028
10351035 return TCL_ERROR;
10361036 }
10371037
1038 tab = Ttk_SlaveData(nb->notebook.mgr, index);
1038 tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
10391039 tab->state = TAB_STATE_HIDDEN;
10401040 if (index == nb->notebook.currentIndex) {
10411041 SelectNearestTab(nb);
10551055 static const char *whatTable[] = { "element", "tab", NULL };
10561056 enum { IDENTIFY_ELEMENT, IDENTIFY_TAB };
10571057 int what = IDENTIFY_ELEMENT;
1058 Notebook *nb = recordPtr;
1058 Notebook *nb = (Notebook *)recordPtr;
10591059 Ttk_Element element = NULL;
1060 int x, y, tabIndex;
1060 int x, y;
1061 int tabIndex;
10611062
10621063 if (objc < 4 || objc > 5) {
10631064 Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
10641065 return TCL_ERROR;
10651066 }
10661067
1067 if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
1068 if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
10681069 || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
10691070 || (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable,
10701071 sizeof(char *), "option", 0, &what) != TCL_OK)
10741075
10751076 tabIndex = IdentifyTab(nb, x, y);
10761077 if (tabIndex >= 0) {
1077 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, tabIndex);
1078 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, tabIndex);
10781079 Ttk_State state = TabState(nb, tabIndex);
10791080 Ttk_Layout tabLayout = nb->notebook.tabLayout;
10801081
11091110 static int NotebookIndexCommand(
11101111 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
11111112 {
1112 Notebook *nb = recordPtr;
1113 int index, status;
1113 Notebook *nb = (Notebook *)recordPtr;
1114 int index;
1115 int status;
11141116
11151117 if (objc != 3) {
11161118 Tcl_WrongNumArgs(interp, 2, objv, "tab");
11211123 * Special-case for "end":
11221124 */
11231125 if (!strcmp("end", Tcl_GetString(objv[2]))) {
1124 int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
1125 Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves));
1126 int nContent = Ttk_NumberContent(nb->notebook.mgr);
1127 Tcl_SetObjResult(interp, Tcl_NewIntObj(nContent));
11261128 return TCL_OK;
11271129 }
11281130
11411143 static int NotebookSelectCommand(
11421144 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
11431145 {
1144 Notebook *nb = recordPtr;
1146 Notebook *nb = (Notebook *)recordPtr;
11451147
11461148 if (objc == 2) {
11471149 if (nb->notebook.currentIndex >= 0) {
1148 Tk_Window pane = Ttk_SlaveWindow(
1150 Tk_Window pane = Ttk_ContentWindow(
11491151 nb->notebook.mgr, nb->notebook.currentIndex);
11501152 Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1));
11511153 }
11671169 static int NotebookTabsCommand(
11681170 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
11691171 {
1170 Notebook *nb = recordPtr;
1172 Notebook *nb = (Notebook *)recordPtr;
11711173 Ttk_Manager *mgr = nb->notebook.mgr;
11721174 Tcl_Obj *result;
11731175 int i;
11781180 }
11791181
11801182 result = Tcl_NewListObj(0, NULL);
1181 for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) {
1182 const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i));
1183 for (i = 0; i < Ttk_NumberContent(mgr); ++i) {
1184 const char *pathName = Tk_PathName(Ttk_ContentWindow(mgr,i));
11831185
11841186 Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(pathName,-1));
11851187 }
11921194 static int NotebookTabCommand(
11931195 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
11941196 {
1195 Notebook *nb = recordPtr;
1197 Notebook *nb = (Notebook *)recordPtr;
11961198 Ttk_Manager *mgr = nb->notebook.mgr;
11971199 int index;
1198 Tk_Window slaveWindow;
1200 Tk_Window window;
11991201 Tab *tab;
12001202
12011203 if (objc < 3) {
12071209 return TCL_ERROR;
12081210 }
12091211
1210 tab = Ttk_SlaveData(mgr, index);
1211 slaveWindow = Ttk_SlaveWindow(mgr, index);
1212 tab = (Tab *)Ttk_ContentData(mgr, index);
1213 window = Ttk_ContentWindow(mgr, index);
12121214
12131215 if (objc == 3) {
12141216 return TtkEnumerateOptions(interp, tab,
1215 PaneOptionSpecs, nb->notebook.paneOptionTable, slaveWindow);
1217 PaneOptionSpecs, nb->notebook.paneOptionTable, window);
12161218 } else if (objc == 4) {
12171219 return TtkGetOptionValue(interp, tab, objv[3],
1218 nb->notebook.paneOptionTable, slaveWindow);
1220 nb->notebook.paneOptionTable, window);
12191221 } /* else */
12201222
1221 if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) {
1223 if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) {
12221224 return TCL_ERROR;
12231225 }
12241226
12571259
12581260 static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
12591261 {
1260 Notebook *nb = recordPtr;
1262 Notebook *nb = (Notebook *)recordPtr;
12611263
12621264 nb->notebook.mgr = Ttk_CreateManager(
12631265 &NotebookManagerSpec, recordPtr, nb->core.tkwin);
12771279
12781280 static void NotebookCleanup(void *recordPtr)
12791281 {
1280 Notebook *nb = recordPtr;
1282 Notebook *nb = (Notebook *)recordPtr;
12811283
12821284 Ttk_DeleteManager(nb->notebook.mgr);
12831285 if (nb->notebook.tabLayout)
12861288
12871289 static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask)
12881290 {
1289 Notebook *nb = clientData;
1291 Notebook *nb = (Notebook *)clientData;
12901292
12911293 /*
12921294 * Error-checks:
13101312 static Ttk_Layout NotebookGetLayout(
13111313 Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
13121314 {
1313 Notebook *nb = recordPtr;
1315 Notebook *nb = (Notebook *)recordPtr;
13141316 Ttk_Layout notebookLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
13151317 Ttk_Layout tabLayout;
13161318
13381340 static void DisplayTab(Notebook *nb, int index, Drawable d)
13391341 {
13401342 Ttk_Layout tabLayout = nb->notebook.tabLayout;
1341 Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
1343 Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
13421344 Ttk_State state = TabState(nb, index);
13431345
13441346 if (tab->state != TAB_STATE_HIDDEN) {
13501352
13511353 static void NotebookDisplay(void *clientData, Drawable d)
13521354 {
1353 Notebook *nb = clientData;
1354 int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
1355 Notebook *nb = (Notebook *)clientData;
1356 int nContent = Ttk_NumberContent(nb->notebook.mgr);
13551357 int index;
13561358
13571359 /* Draw notebook background (base layout):
13611363 /* Draw tabs from left to right, but draw the current tab last
13621364 * so it will overwrite its neighbors.
13631365 */
1364 for (index = 0; index < nSlaves; ++index) {
1366 for (index = 0; index < nContent; ++index) {
13651367 if (index != nb->notebook.currentIndex) {
13661368 DisplayTab(nb, index, d);
13671369 }
55 * TODO: track active/pressed sash.
66 */
77
8 #include <string.h>
9 #include <tk.h>
8 #include "tkInt.h"
109 #include "ttkManager.h"
1110 #include "ttkTheme.h"
1211 #include "ttkWidget.h"
2827 * gives the same result as changing the size by X+Y pixels
2928 * in one step).
3029 *
31 * The request size is initially set to the slave window's requested size.
30 * The request size is initially set to the content window's requested size.
3231 * When the user drags a sash, each pane's request size is set to its
3332 * actual size. This ensures that panes "stay put" on the next resize.
3433 *
7776 static Tk_OptionSpec PanedOptionSpecs[] = {
7877 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
7978 Tk_Offset(Paned,paned.orientObj), Tk_Offset(Paned,paned.orient),
80 0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED },
79 0, (void *)ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED },
8180 {TK_OPTION_INT, "-width", "width", "Width", "0",
8281 -1,Tk_Offset(Paned,paned.width),
83 0,0,GEOMETRY_CHANGED },
82 0, 0, GEOMETRY_CHANGED },
8483 {TK_OPTION_INT, "-height", "height", "Height", "0",
8584 -1,Tk_Offset(Paned,paned.height),
86 0,0,GEOMETRY_CHANGED },
85 0, 0, GEOMETRY_CHANGED },
8786
8887 WIDGET_TAKEFOCUS_FALSE,
8988 WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
9089 };
9190
9291 /*------------------------------------------------------------------------
93 * +++ Slave pane record.
92 * +++ Pane record.
9493 */
9594 typedef struct {
9695 int reqSize; /* Pane request size */
107106 /* CreatePane --
108107 * Create a new pane record.
109108 */
110 static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow)
109 static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window window)
111110 {
112111 Tk_OptionTable optionTable = pw->paned.paneOptionTable;
113112 void *record = ckalloc(sizeof(Pane));
114 Pane *pane = record;
113 Pane *pane = (Pane *)record;
115114
116115 memset(record, 0, sizeof(Pane));
117 if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
116 if (Tk_InitOptions(interp, record, optionTable, window) != TCL_OK) {
118117 ckfree(record);
119118 return NULL;
120119 }
121120
122121 pane->reqSize
123122 = pw->paned.orient == TTK_ORIENT_HORIZONTAL
124 ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow);
123 ? Tk_ReqWidth(window) : Tk_ReqHeight(window);
125124
126125 return pane;
127126 }
140139 * Set pane options.
141140 */
142141 static int ConfigurePane(
143 Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window slaveWindow,
142 Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window window,
144143 int objc, Tcl_Obj *const objv[])
145144 {
146145 Ttk_Manager *mgr = pw->paned.mgr;
148147 int mask = 0;
149148
150149 if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable,
151 objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK)
150 objc, objv, window, &savedOptions, &mask) != TCL_OK)
152151 {
153152 return TCL_ERROR;
154153 }
188187
189188 static int ShoveUp(Paned *pw, int i, int pos)
190189 {
191 Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
190 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, i);
192191 int sashThickness = pw->paned.sashThickness;
193192
194193 if (i == 0) {
195194 if (pos < 0)
196195 pos = 0;
197196 } else {
198 Pane *prevPane = Ttk_SlaveData(pw->paned.mgr, i-1);
197 Pane *prevPane = (Pane *)Ttk_ContentData(pw->paned.mgr, i-1);
199198 if (pos < prevPane->sashPos + sashThickness)
200199 pos = ShoveUp(pw, i-1, pos - sashThickness) + sashThickness;
201200 }
208207 */
209208 static int ShoveDown(Paned *pw, int i, int pos)
210209 {
211 Pane *pane = Ttk_SlaveData(pw->paned.mgr,i);
210 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr,i);
212211 int sashThickness = pw->paned.sashThickness;
213212
214 if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) {
215 pos = pane->sashPos; /* Sentinel value == master window size */
213 if (i == Ttk_NumberContent(pw->paned.mgr) - 1) {
214 pos = pane->sashPos; /* Sentinel value == container window size */
216215 } else {
217 Pane *nextPane = Ttk_SlaveData(pw->paned.mgr,i+1);
216 Pane *nextPane = (Pane *)Ttk_ContentData(pw->paned.mgr,i+1);
218217 if (pos + sashThickness > nextPane->sashPos)
219218 pos = ShoveDown(pw, i+1, pos + sashThickness) - sashThickness;
220219 }
229228 */
230229 static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr)
231230 {
232 Paned *pw = recordPtr;
233 int nPanes = Ttk_NumberSlaves(pw->paned.mgr);
231 Paned *pw = (Paned *)recordPtr;
232 int nPanes = Ttk_NumberContent(pw->paned.mgr);
234233 int nSashes = nPanes - 1;
235234 int sashThickness = pw->paned.sashThickness;
236235 int width = 0, height = 0;
238237
239238 if (pw->paned.orient == TTK_ORIENT_HORIZONTAL) {
240239 for (index = 0; index < nPanes; ++index) {
241 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
242 Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
243
244 if (height < Tk_ReqHeight(slaveWindow))
245 height = Tk_ReqHeight(slaveWindow);
240 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
241 Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index);
242
243 if (height < Tk_ReqHeight(window))
244 height = Tk_ReqHeight(window);
246245 width += pane->reqSize;
247246 }
248247 width += nSashes * sashThickness;
249248 } else {
250249 for (index = 0; index < nPanes; ++index) {
251 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
252 Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
253
254 if (width < Tk_ReqWidth(slaveWindow))
255 width = Tk_ReqWidth(slaveWindow);
250 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
251 Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index);
252
253 if (width < Tk_ReqWidth(window))
254 width = Tk_ReqWidth(window);
256255 height += pane->reqSize;
257256 }
258257 height += nSashes * sashThickness;
277276 int pos = 0;
278277 int index;
279278
280 for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
281 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
279 for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
280 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
282281 int size = pane->sashPos - pos;
283282 pane->reqSize = size >= 0 ? size : 0;
284283 pos = pane->sashPos + sashThickness;
304303 static void PlaceSashes(Paned *pw, int width, int height)
305304 {
306305 Ttk_Manager *mgr = pw->paned.mgr;
307 int nPanes = Ttk_NumberSlaves(mgr);
306 int nPanes = Ttk_NumberContent(mgr);
308307 int sashThickness = pw->paned.sashThickness;
309308 int available = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? width : height;
310309 int reqSize = 0, totalWeight = 0;
316315 /* Compute total required size and total available weight:
317316 */
318317 for (i = 0; i < nPanes; ++i) {
319 Pane *pane = Ttk_SlaveData(mgr, i);
318 Pane *pane = (Pane *)Ttk_ContentData(mgr, i);
320319 reqSize += pane->reqSize;
321320 totalWeight += pane->weight * (pane->reqSize != 0);
322321 }
340339 */
341340 pos = 0;
342341 for (i = 0; i < nPanes; ++i) {
343 Pane *pane = Ttk_SlaveData(mgr, i);
342 Pane *pane = (Pane *)Ttk_ContentData(mgr, i);
344343 int weight = pane->weight * (pane->reqSize != 0);
345344 int size = pane->reqSize + delta * weight;
346345
364363 }
365364
366365 /* PlacePanes --
367 * Places slave panes based on sash positions.
366 * Places panes based on sash positions.
368367 */
369368 static void PlacePanes(Paned *pw)
370369 {
374373 int pos = 0;
375374 int index;
376375
377 for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
378 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
376 for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
377 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
379378 int size = pane->sashPos - pos;
380379
381380 if (size > 0) {
382381 if (horizontal) {
383 Ttk_PlaceSlave(pw->paned.mgr, index, pos, 0, size, height);
382 Ttk_PlaceContent(pw->paned.mgr, index, pos, 0, size, height);
384383 } else {
385 Ttk_PlaceSlave(pw->paned.mgr, index, 0, pos, width, size);
384 Ttk_PlaceContent(pw->paned.mgr, index, 0, pos, width, size);
386385 }
387386 } else {
388 Ttk_UnmapSlave(pw->paned.mgr, index);
387 Ttk_UnmapContent(pw->paned.mgr, index);
389388 }
390389
391390 pos = pane->sashPos + sashThickness;
396395 * +++ Manager specification.
397396 */
398397
399 static void PanedPlaceSlaves(void *managerData)
400 {
401 Paned *pw = managerData;
398 static void PanedPlaceContent(void *managerData)
399 {
400 Paned *pw = (Paned *)managerData;
402401 PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin));
403402 PlacePanes(pw);
404403 }
405404
406405 static void PaneRemoved(void *managerData, int index)
407406 {
408 Paned *pw = managerData;
409 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
407 Paned *pw = (Paned *)managerData;
408 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
410409 DestroyPane(pw, pane);
411410 }
412411
413412 static int AddPane(
414413 Tcl_Interp *interp, Paned *pw,
415 int destIndex, Tk_Window slaveWindow,
414 int destIndex, Tk_Window window,
416415 int objc, Tcl_Obj *const objv[])
417416 {
418417 Pane *pane;
419 if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) {
420 return TCL_ERROR;
421 }
422 if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) {
418 if (!Ttk_Maintainable(interp, window, pw->core.tkwin)) {
419 return TCL_ERROR;
420 }
421 if (Ttk_ContentIndex(pw->paned.mgr, window) >= 0) {
423422 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
424 "%s already added", Tk_PathName(slaveWindow)));
423 "%s already added", Tk_PathName(window)));
425424 Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL);
426425 return TCL_ERROR;
427426 }
428427
429 pane = CreatePane(interp, pw, slaveWindow);
428 pane = CreatePane(interp, pw, window);
430429 if (!pane) {
431430 return TCL_ERROR;
432431 }
433 if (ConfigurePane(interp, pw, pane, slaveWindow, objc, objv) != TCL_OK) {
432 if (ConfigurePane(interp, pw, pane, window, objc, objv) != TCL_OK) {
434433 DestroyPane(pw, pane);
435434 return TCL_ERROR;
436435 }
437436
438 Ttk_InsertSlave(pw->paned.mgr, destIndex, slaveWindow, pane);
437 Ttk_InsertContent(pw->paned.mgr, destIndex, window, pane);
439438 return TCL_OK;
440439 }
441440
442441 /* PaneRequest --
443 * Only update pane request size if slave is currently unmapped.
444 * Geometry requests from mapped slaves are not directly honored
442 * Only update pane request size if pane is currently unmapped.
443 * Geometry requests from mapped panes are not directly honored
445444 * in order to avoid unexpected pane resizes (esp. while the
446445 * user is dragging a sash [#1325286]).
447446 */
448447 static int PaneRequest(void *managerData, int index, int width, int height)
449448 {
450 Paned *pw = managerData;
451 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
452 Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
449 Paned *pw = (Paned *)managerData;
450 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
451 Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index);
453452 int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
454453
455 if (!Tk_IsMapped(slaveWindow)) {
454 if (!Tk_IsMapped(window)) {
456455 pane->reqSize = horizontal ? width : height;
457456 }
458457 return 1;
459458 }
460459
461460 static Ttk_ManagerSpec PanedManagerSpec = {
462 { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
461 { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostContentProc },
463462 PanedSize,
464 PanedPlaceSlaves,
463 PanedPlaceContent,
465464 PaneRequest,
466465 PaneRemoved
467466 };
482481 static const unsigned PanedEventMask = LeaveWindowMask;
483482 static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
484483 {
485 WidgetCore *corePtr = clientData;
484 WidgetCore *corePtr = (WidgetCore *)clientData;
486485 if ( eventPtr->type == LeaveNotify
487486 && eventPtr->xcrossing.detail == NotifyInferior)
488487 {
496495
497496 static void PanedInitialize(Tcl_Interp *interp, void *recordPtr)
498497 {
499 Paned *pw = recordPtr;
498 Paned *pw = (Paned *)recordPtr;
500499
501500 Tk_CreateEventHandler(pw->core.tkwin,
502501 PanedEventMask, PanedEventProc, recordPtr);
508507
509508 static void PanedCleanup(void *recordPtr)
510509 {
511 Paned *pw = recordPtr;
510 Paned *pw = (Paned *)recordPtr;
512511
513512 if (pw->paned.sashLayout)
514513 Ttk_FreeLayout(pw->paned.sashLayout);
519518
520519 /* Post-configuration hook.
521520 */
522 static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
523 {
524 Paned *pw = clientData;
521 static int PanedPostConfigure(
522 TCL_UNUSED(Tcl_Interp *),
523 void *clientData,
524 int mask)
525 {
526 Paned *pw = (Paned *)clientData;
525527
526528 if (mask & GEOMETRY_CHANGED) {
527529 /* User has changed -width or -height.
542544 static Ttk_Layout PanedGetLayout(
543545 Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
544546 {
545 Paned *pw = recordPtr;
547 Paned *pw = (Paned *)recordPtr;
546548 Ttk_Layout panedLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
547549
548550 if (panedLayout) {
580582 */
581583 static Ttk_Layout SashLayout(Paned *pw, int index)
582584 {
583 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
585 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
584586 int thickness = pw->paned.sashThickness,
585587 height = Tk_Height(pw->core.tkwin),
586588 width = Tk_Width(pw->core.tkwin),
602604
603605 static void PanedDisplay(void *recordPtr, Drawable d)
604606 {
605 Paned *pw = recordPtr;
606 int i, nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
607 Paned *pw = (Paned *)recordPtr;
608 int i, nSashes = Ttk_NumberContent(pw->paned.mgr) - 1;
607609
608610 TtkWidgetDisplay(recordPtr, d);
609611 for (i = 0; i < nSashes; ++i) {
620622 static int PanedAddCommand(
621623 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
622624 {
623 Paned *pw = recordPtr;
624 Tk_Window slaveWindow;
625 Paned *pw = (Paned *)recordPtr;
626 Tk_Window window;
625627
626628 if (objc < 3) {
627629 Tcl_WrongNumArgs(interp, 2, objv, "window");
628630 return TCL_ERROR;
629631 }
630632
631 slaveWindow = Tk_NameToWindow(
633 window = Tk_NameToWindow(
632634 interp, Tcl_GetString(objv[2]), pw->core.tkwin);
633635
634 if (!slaveWindow) {
635 return TCL_ERROR;
636 }
637
638 return AddPane(interp, pw, Ttk_NumberSlaves(pw->paned.mgr), slaveWindow,
636 if (!window) {
637 return TCL_ERROR;
638 }
639
640 return AddPane(interp, pw, Ttk_NumberContent(pw->paned.mgr), window,
639641 objc - 3, objv + 3);
640642 }
641643
642 /* $pw insert $index $slave ?-option value ...?
643 * Insert new slave, or move existing one.
644 /* $pw insert $index $window ?-option value ...?
645 * Insert new content window, or move existing one.
644646 */
645647 static int PanedInsertCommand(
646648 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
647649 {
648 Paned *pw = recordPtr;
649 int nSlaves = Ttk_NumberSlaves(pw->paned.mgr);
650 Paned *pw = (Paned *)recordPtr;
651 int nContent = Ttk_NumberContent(pw->paned.mgr);
650652 int srcIndex, destIndex;
651 Tk_Window slaveWindow;
653 Tk_Window window;
652654
653655 if (objc < 4) {
654656 Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
655657 return TCL_ERROR;
656658 }
657659
658 slaveWindow = Tk_NameToWindow(
660 window = Tk_NameToWindow(
659661 interp, Tcl_GetString(objv[3]), pw->core.tkwin);
660 if (!slaveWindow) {
662 if (!window) {
661663 return TCL_ERROR;
662664 }
663665
664666 if (!strcmp(Tcl_GetString(objv[2]), "end")) {
665 destIndex = Ttk_NumberSlaves(pw->paned.mgr);
666 } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
667 interp,pw->paned.mgr,objv[2],&destIndex))
667 destIndex = Ttk_NumberContent(pw->paned.mgr);
668 } else if (TCL_OK != Ttk_GetContentIndexFromObj(
669 interp,pw->paned.mgr, objv[2], &destIndex))
668670 {
669671 return TCL_ERROR;
670672 }
671673
672 srcIndex = Ttk_SlaveIndex(pw->paned.mgr, slaveWindow);
673 if (srcIndex < 0) { /* New slave: */
674 return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4);
675 } /* else -- move existing slave: */
676
677 if (destIndex >= nSlaves)
678 destIndex = nSlaves - 1;
679 Ttk_ReorderSlave(pw->paned.mgr, srcIndex, destIndex);
674 srcIndex = Ttk_ContentIndex(pw->paned.mgr, window);
675 if (srcIndex < 0) { /* New content: */
676 return AddPane(interp, pw, destIndex, window, objc-4, objv+4);
677 } /* else -- move existing content: */
678
679 if (destIndex >= nContent)
680 destIndex = nContent - 1;
681 Ttk_ReorderContent(pw->paned.mgr, srcIndex, destIndex);
680682
681683 return objc == 4 ? TCL_OK :
682684 ConfigurePane(interp, pw,
683 Ttk_SlaveData(pw->paned.mgr, destIndex),
684 Ttk_SlaveWindow(pw->paned.mgr, destIndex),
685 objc-4,objv+4);
685 (Pane *)Ttk_ContentData(pw->paned.mgr, destIndex),
686 Ttk_ContentWindow(pw->paned.mgr, destIndex),
687 objc-4, objv+4);
686688 }
687689
688690 /* $pw forget $pane
690692 static int PanedForgetCommand(
691693 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
692694 {
693 Paned *pw = recordPtr;
695 Paned *pw = (Paned *)recordPtr;
694696 int paneIndex;
695697
696698 if (objc != 3) {
698700 return TCL_ERROR;
699701 }
700702
701 if (TCL_OK != Ttk_GetSlaveIndexFromObj(
703 if (TCL_OK != Ttk_GetContentIndexFromObj(
702704 interp, pw->paned.mgr, objv[2], &paneIndex))
703705 {
704706 return TCL_ERROR;
705707 }
706 Ttk_ForgetSlave(pw->paned.mgr, paneIndex);
708 Ttk_ForgetContent(pw->paned.mgr, paneIndex);
707709
708710 return TCL_OK;
709711 }
717719 static const char *whatTable[] = { "element", "sash", NULL };
718720 enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
719721 int what = IDENTIFY_SASH;
720 Paned *pw = recordPtr;
722 Paned *pw = (Paned *)recordPtr;
721723 int sashThickness = pw->paned.sashThickness;
722 int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
724 int nSashes = Ttk_NumberContent(pw->paned.mgr) - 1;
723725 int x, y, pos;
724726 int index;
725727
738740
739741 pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y;
740742 for (index = 0; index < nSashes; ++index) {
741 Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
743 Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
742744 if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) {
743745 /* Found it. */
744746 switch (what) {
768770 static int PanedPaneCommand(
769771 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
770772 {
771 Paned *pw = recordPtr;
773 Paned *pw = (Paned *)recordPtr;
772774 int paneIndex;
773 Tk_Window slaveWindow;
775 Tk_Window window;
774776 Pane *pane;
775777
776778 if (objc < 3) {
778780 return TCL_ERROR;
779781 }
780782
781 if (TCL_OK != Ttk_GetSlaveIndexFromObj(
782 interp,pw->paned.mgr,objv[2],&paneIndex))
783 if (TCL_OK != Ttk_GetContentIndexFromObj(
784 interp,pw->paned.mgr, objv[2], &paneIndex))
783785 {
784786 return TCL_ERROR;
785787 }
786788
787 pane = Ttk_SlaveData(pw->paned.mgr, paneIndex);
788 slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex);
789 pane = (Pane *)Ttk_ContentData(pw->paned.mgr, paneIndex);
790 window = Ttk_ContentWindow(pw->paned.mgr, paneIndex);
789791
790792 switch (objc) {
791793 case 3:
792794 return TtkEnumerateOptions(interp, pane, PaneOptionSpecs,
793 pw->paned.paneOptionTable, slaveWindow);
795 pw->paned.paneOptionTable, window);
794796 case 4:
795797 return TtkGetOptionValue(interp, pane, objv[3],
796 pw->paned.paneOptionTable, slaveWindow);
798 pw->paned.paneOptionTable, window);
797799 default:
798 return ConfigurePane(interp, pw, pane, slaveWindow, objc-3,objv+3);
800 return ConfigurePane(interp, pw, pane, window, objc-3,objv+3);
799801 }
800802 }
801803
805807 static int PanedPanesCommand(
806808 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
807809 {
808 Paned *pw = recordPtr;
810 Paned *pw = (Paned *)recordPtr;
809811 Ttk_Manager *mgr = pw->paned.mgr;
810812 Tcl_Obj *panes;
811813 int i;
816818 }
817819
818820 panes = Tcl_NewListObj(0, NULL);
819 for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) {
820 const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i));
821 for (i = 0; i < Ttk_NumberContent(mgr); ++i) {
822 const char *pathName = Tk_PathName(Ttk_ContentWindow(mgr,i));
821823 Tcl_ListObjAppendElement(interp, panes, Tcl_NewStringObj(pathName,-1));
822824 }
823825 Tcl_SetObjResult(interp, panes);
832834 static int PanedSashposCommand(
833835 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
834836 {
835 Paned *pw = recordPtr;
837 Paned *pw = (Paned *)recordPtr;
836838 int sashIndex, position = -1;
837839 Pane *pane;
838840
843845 if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
844846 return TCL_ERROR;
845847 }
846 if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) {
848 if (sashIndex < 0 || sashIndex >= Ttk_NumberContent(pw->paned.mgr) - 1) {
847849 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
848850 "sash index %d out of range", sashIndex));
849851 Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL);
850852 return TCL_ERROR;
851853 }
852854
853 pane = Ttk_SlaveData(pw->paned.mgr, sashIndex);
855 pane = (Pane *)Ttk_ContentData(pw->paned.mgr, sashIndex);
854856
855857 if (objc == 3) {
856858 Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
923925 static Ttk_ElementOptionSpec SashElementOptions[] = {
924926 { "-sashthickness", TK_OPTION_INT,
925927 Tk_Offset(SashElement,thicknessObj), "5" },
926 { NULL, 0, 0, NULL }
928 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
927929 };
928930
929931 static void SashElementSize(
930 void *clientData, void *elementRecord, Tk_Window tkwin,
931 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
932 {
933 SashElement *sash = elementRecord;
932 TCL_UNUSED(void *),
933 void *elementRecord,
934 TCL_UNUSED(Tk_Window),
935 int *widthPtr,
936 int *heightPtr,
937 TCL_UNUSED(Ttk_Padding *))
938 {
939 SashElement *sash = (SashElement *)elementRecord;
934940 int thickness = DEFAULT_SASH_THICKNESS;
941
935942 Tcl_GetIntFromObj(NULL, sash->thicknessObj, &thickness);
936943 *widthPtr = *heightPtr = thickness;
937944 }
33 * ttk::progressbar widget.
44 */
55
6 #include <math.h>
7 #include <tk.h>
8
6 #include "tkInt.h"
97 #include "ttkTheme.h"
108 #include "ttkWidget.h"
119
4745 {
4846 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
4947 "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1,
50 0, (ClientData)ttkOrientStrings, STYLE_CHANGED },
48 0, (void *)ttkOrientStrings, STYLE_CHANGED },
5149 {TK_OPTION_PIXELS, "-length", "length", "Length",
5250 DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1,
5351 0, 0, GEOMETRY_CHANGED },
5452 {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate",
5553 Tk_Offset(Progressbar,progress.modeObj),
5654 Tk_Offset(Progressbar,progress.mode),
57 0, (ClientData)ProgressbarModeStrings, 0 },
55 0, (void *)ProgressbarModeStrings, 0 },
5856 {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
5957 "100", Tk_Offset(Progressbar,progress.maximumObj), -1,
6058 0, 0, 0 },
9997 */
10098 static void AnimateProgressProc(ClientData clientData)
10199 {
102 Progressbar *pb = clientData;
100 Progressbar *pb = (Progressbar *)clientData;
103101
104102 pb->progress.timer = 0;
105
106103 if (AnimationEnabled(pb)) {
107104 int phase = 0;
108105 Tcl_GetIntFromObj(NULL, pb->progress.phaseObj, &phase);
110107 /*
111108 * Update -phase:
112109 */
110
113111 ++phase;
114 if (pb->progress.maxPhase)
115 phase %= pb->progress.maxPhase;
112 if (phase > pb->progress.maxPhase) {
113 phase = 0;
114 }
116115 Tcl_DecrRefCount(pb->progress.phaseObj);
117116 pb->progress.phaseObj = Tcl_NewIntObj(phase);
118117 Tcl_IncrRefCount(pb->progress.phaseObj);
120119 /*
121120 * Reschedule:
122121 */
122
123123 pb->progress.timer = Tcl_CreateTimerHandler(
124124 pb->progress.period, AnimateProgressProc, clientData);
125
126125 TtkRedisplayWidget(&pb->core);
127126 }
128127 }
136135 if (AnimationEnabled(pb)) {
137136 if (pb->progress.timer == 0) {
138137 pb->progress.timer = Tcl_CreateTimerHandler(
139 pb->progress.period, AnimateProgressProc, (ClientData)pb);
138 pb->progress.period, AnimateProgressProc, pb);
140139 }
141140 } else {
142141 if (pb->progress.timer != 0) {
152151
153152 static void VariableChanged(void *recordPtr, const char *value)
154153 {
155 Progressbar *pb = recordPtr;
154 Progressbar *pb = (Progressbar *)recordPtr;
156155 Tcl_Obj *newValue;
157156 double scratch;
158157
185184 * +++ Widget class methods:
186185 */
187186
188 static void ProgressbarInitialize(Tcl_Interp *interp, void *recordPtr)
189 {
190 Progressbar *pb = recordPtr;
187 static void ProgressbarInitialize(Tcl_Interp *dummy, void *recordPtr)
188 {
189 Progressbar *pb = (Progressbar *)recordPtr;
190 (void)dummy;
191
191192 pb->progress.variableTrace = 0;
192193 pb->progress.timer = 0;
193194 }
194195
195196 static void ProgressbarCleanup(void *recordPtr)
196197 {
197 Progressbar *pb = recordPtr;
198 Progressbar *pb = (Progressbar *)recordPtr;
198199 if (pb->progress.variableTrace)
199200 Ttk_UntraceVariable(pb->progress.variableTrace);
200201 if (pb->progress.timer)
208209 */
209210 static int ProgressbarConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
210211 {
211 Progressbar *pb = recordPtr;
212 Progressbar *pb = (Progressbar *)recordPtr;
212213 Tcl_Obj *varName = pb->progress.variableObj;
213214 Ttk_TraceHandle *vt = 0;
214215
234235 * Post-configuration hook:
235236 */
236237 static int ProgressbarPostConfigure(
237 Tcl_Interp *interp, void *recordPtr, int mask)
238 {
239 Progressbar *pb = recordPtr;
238 Tcl_Interp *dummy, void *recordPtr, int mask)
239 {
240 Progressbar *pb = (Progressbar *)recordPtr;
240241 int status = TCL_OK;
242 (void)dummy;
243 (void)mask;
241244
242245 if (pb->progress.variableTrace) {
243246 status = Ttk_FireTrace(pb->progress.variableTrace);
265268 */
266269 static int ProgressbarSize(void *recordPtr, int *widthPtr, int *heightPtr)
267270 {
268 Progressbar *pb = recordPtr;
269 int length = 100, orient = TTK_ORIENT_HORIZONTAL;
271 Progressbar *pb = (Progressbar *)recordPtr;
272 int length = 100;
273 int orient = TTK_ORIENT_HORIZONTAL;
270274
271275 TtkWidgetSize(recordPtr, widthPtr, heightPtr);
272276
333337
334338 static void ProgressbarDoLayout(void *recordPtr)
335339 {
336 Progressbar *pb = recordPtr;
340 Progressbar *pb = (Progressbar *)recordPtr;
337341 WidgetCore *corePtr = &pb->core;
338342 Ttk_Element pbar = Ttk_FindElement(corePtr->layout, "pbar");
339343 double value = 0.0, maximum = 100.0;
365369 static Ttk_Layout ProgressbarGetLayout(
366370 Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
367371 {
368 Progressbar *pb = recordPtr;
372 Progressbar *pb = (Progressbar *)recordPtr;
369373 Ttk_Layout layout = TtkWidgetGetOrientedLayout(
370374 interp, theme, recordPtr, pb->progress.orientObj);
371375
395399 static int ProgressbarStepCommand(
396400 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
397401 {
398 Progressbar *pb = recordPtr;
402 Progressbar *pb = (Progressbar *)recordPtr;
399403 double value = 0.0, stepAmount = 1.0;
400 Tcl_Obj *newValueObj;
404 Tcl_Obj *newValueObj;
401405
402406 if (objc == 3) {
403407 if (Tcl_GetDoubleFromObj(interp, objv[2], &stepAmount) != TCL_OK) {
424428
425429 TtkRedisplayWidget(&pb->core);
426430
427 /* Update value by setting the linked -variable, if there is one:
431 /* Update value by setting the linked -variable, if there is one:
428432 */
429433 if (pb->progress.variableTrace) {
430434 int result = Tcl_ObjSetVar2(
445449 }
446450
447451 /* $sb start|stop ?args? --
448 * Change [$sb $cmd ...] to [ttk::progressbar::$cmd ...]
452 * Change [$sb $cmd ...] to [ttk::progressbar::$cmd ...]
449453 * and pass to interpreter.
450454 */
451455 static int ProgressbarStartStopCommand(
471475 static int ProgressbarStartCommand(
472476 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
473477 {
478 (void)recordPtr;
479
474480 return ProgressbarStartStopCommand(
475481 interp, "::ttk::progressbar::start", objc, objv);
476482 }
478484 static int ProgressbarStopCommand(
479485 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
480486 {
487 (void)recordPtr;
488
481489 return ProgressbarStartStopCommand(
482490 interp, "::ttk::progressbar::stop", objc, objv);
483491 }
33 * ttk::scale widget.
44 */
55
6 #include <tk.h>
7 #include <string.h>
8 #include <stdio.h>
6 #include "tkInt.h"
97 #include "ttkTheme.h"
108 #include "ttkWidget.h"
119
5452 static Tk_OptionSpec ScaleOptionSpecs[] =
5553 {
5654 {TK_OPTION_STRING, "-command", "command", "Command", "",
57 Tk_Offset(Scale,scale.commandObj), -1,
55 Tk_Offset(Scale,scale.commandObj), -1,
5856 TK_OPTION_NULL_OK,0,0},
5957 {TK_OPTION_STRING, "-variable", "variable", "Variable", "",
60 Tk_Offset(Scale,scale.variableObj), -1,
58 Tk_Offset(Scale,scale.variableObj), -1,
6159 0,0,0},
6260 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
6361 Tk_Offset(Scale,scale.orientObj),
64 Tk_Offset(Scale,scale.orient), 0,
65 (ClientData)ttkOrientStrings, STYLE_CHANGED },
62 Tk_Offset(Scale,scale.orient), 0,
63 (void *)ttkOrientStrings, STYLE_CHANGED },
6664
6765 {TK_OPTION_DOUBLE, "-from", "from", "From", "0",
6866 Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
7169 {TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
7270 Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
7371 {TK_OPTION_PIXELS, "-length", "length", "Length",
74 DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
72 DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
7573 GEOMETRY_CHANGED},
7674
7775 {TK_OPTION_STRING, "-state", "state", "State",
8886 /* ScaleVariableChanged --
8987 * Variable trace procedure for scale -variable;
9088 * Updates the scale's value.
91 * If the linked variable is not a valid double,
89 * If the linked variable is not a valid double,
9290 * sets the 'invalid' state.
9391 */
9492 static void ScaleVariableChanged(void *recordPtr, const char *value)
9593 {
96 Scale *scale = recordPtr;
94 Scale *scale = (Scale *)recordPtr;
9795 double v;
9896
9997 if (value == NULL || Tcl_GetDouble(0, value, &v) != TCL_OK) {
111109 /* ScaleInitialize --
112110 * Scale widget initialization hook.
113111 */
114 static void ScaleInitialize(Tcl_Interp *interp, void *recordPtr)
115 {
116 Scale *scalePtr = recordPtr;
112 static void ScaleInitialize(Tcl_Interp *dummy, void *recordPtr)
113 {
114 Scale *scalePtr = (Scale *)recordPtr;
115 (void)dummy;
116
117117 TtkTrackElementState(&scalePtr->core);
118118 }
119119
120120 static void ScaleCleanup(void *recordPtr)
121121 {
122 Scale *scale = recordPtr;
122 Scale *scale = (Scale *)recordPtr;
123123
124124 if (scale->scale.variableTrace) {
125125 Ttk_UntraceVariable(scale->scale.variableTrace);
132132 */
133133 static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
134134 {
135 Scale *scale = recordPtr;
135 Scale *scale = (Scale *)recordPtr;
136136 Tcl_Obj *varName = scale->scale.variableObj;
137137 Ttk_TraceHandle *vt = 0;
138138
162162 * Post-configuration hook.
163163 */
164164 static int ScalePostConfigure(
165 Tcl_Interp *interp, void *recordPtr, int mask)
166 {
167 Scale *scale = recordPtr;
165 Tcl_Interp *dummy, void *recordPtr, int mask)
166 {
167 Scale *scale = (Scale *)recordPtr;
168168 int status = TCL_OK;
169 (void)dummy;
170 (void)mask;
169171
170172 if (scale->scale.variableTrace) {
171173 status = Ttk_FireTrace(scale->scale.variableTrace);
188190 /* ScaleGetLayout --
189191 * getLayout hook.
190192 */
191 static Ttk_Layout
193 static Ttk_Layout
192194 ScaleGetLayout(Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
193195 {
194 Scale *scalePtr = recordPtr;
196 Scale *scalePtr = (Scale *)recordPtr;
195197 return TtkWidgetGetOrientedLayout(
196198 interp, theme, recordPtr, scalePtr->scale.orientObj);
197199 }
252254 }
253255
254256 /* $scale get ?x y? --
255 * Returns the current value of the scale widget, or if $x and
257 * Returns the current value of the scale widget, or if $x and
256258 * $y are specified, the value represented by point @x,y.
257259 */
258260 static int
259261 ScaleGetCommand(
260262 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
261263 {
262 Scale *scalePtr = recordPtr;
264 Scale *scalePtr = (Scale *)recordPtr;
263265 int x, y, r = TCL_OK;
264266 double value = 0;
265267
287289 ScaleSetCommand(
288290 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
289291 {
290 Scale *scalePtr = recordPtr;
292 Scale *scalePtr = (Scale *)recordPtr;
291293 double from = 0.0, to = 1.0, value;
292294 int result = TCL_OK;
293295
355357 ScaleCoordsCommand(
356358 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
357359 {
358 Scale *scalePtr = recordPtr;
360 Scale *scalePtr = (Scale *)recordPtr;
359361 double value;
360362 int r = TCL_OK;
361363
382384
383385 static void ScaleDoLayout(void *clientData)
384386 {
385 WidgetCore *corePtr = clientData;
387 WidgetCore *corePtr = (WidgetCore *)clientData;
386388 Ttk_Element slider = Ttk_FindElement(corePtr->layout, "slider");
387389
388390 Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
390392 /* Adjust the slider position:
391393 */
392394 if (slider) {
393 Scale *scalePtr = clientData;
395 Scale *scalePtr = (Scale *)clientData;
394396 Ttk_Box troughBox = TroughBox(scalePtr);
395397 Ttk_Box sliderBox = Ttk_ElementParcel(slider);
396398 double value = 0.0;
417419 */
418420 static int ScaleSize(void *clientData, int *widthPtr, int *heightPtr)
419421 {
420 WidgetCore *corePtr = clientData;
421 Scale *scalePtr = clientData;
422 WidgetCore *corePtr = (WidgetCore *)clientData;
423 Scale *scalePtr = (Scale *)clientData;
422424 int length;
423425
424426 Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
103103 Tcl_Release(corePtr);
104104
105105 if (code != TCL_OK && !Tcl_InterpDeleted(interp)) {
106 /* Disable the -scrollcommand, add to stack trace:
106 /* Add error to stack trace.
107 * Also set the SCROLL_UPDATE_REQUIRED flag so that a later call to
108 * TtkScrolled has an effect. Indeed, the error in the -scrollcommand
109 * callback may later be gone, for instance the callback proc got
110 * defined in the meantime.
107111 */
108 ckfree(s->scrollCmd);
109 s->scrollCmd = 0;
110112
111113 Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */
112114 "\n (scrolling command executed by ");
113115 Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin));
114116 Tcl_AddErrorInfo(interp, ")");
117 TtkScrollbarUpdateRequired(h);
115118 }
116119 return code;
117120 }
33 * ttk::scrollbar widget.
44 */
55
6 #include <tk.h>
7
6 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
109
2120 double first; /* top fraction */
2221 double last; /* bottom fraction */
2322
24 Ttk_Box troughBox; /* trough parcel */
23 Ttk_Box troughBox; /* trough parcel */
2524 int minSize; /* minimum size of thumb */
2625 } ScrollbarPart;
2726
3938 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
4039 Tk_Offset(Scrollbar,scrollbar.orientObj),
4140 Tk_Offset(Scrollbar,scrollbar.orient),
42 0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
41 0, (void *)ttkOrientStrings, STYLE_CHANGED },
4342
4443 WIDGET_TAKEFOCUS_FALSE,
4544 WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
4948 * +++ Widget hooks.
5049 */
5150
52 static void
53 ScrollbarInitialize(Tcl_Interp *interp, void *recordPtr)
54 {
55 Scrollbar *sb = recordPtr;
51 static void
52 ScrollbarInitialize(Tcl_Interp *dummy, void *recordPtr)
53 {
54 Scrollbar *sb = (Scrollbar *)recordPtr;
55 (void)dummy;
56
5657 sb->scrollbar.first = 0.0;
5758 sb->scrollbar.last = 1.0;
5859
6263 static Ttk_Layout ScrollbarGetLayout(
6364 Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
6465 {
65 Scrollbar *sb = recordPtr;
66 Scrollbar *sb = (Scrollbar *)recordPtr;
6667 return TtkWidgetGetOrientedLayout(
6768 interp, theme, recordPtr, sb->scrollbar.orientObj);
6869 }
7677 */
7778 static void ScrollbarDoLayout(void *recordPtr)
7879 {
79 Scrollbar *sb = recordPtr;
80 Scrollbar *sb = (Scrollbar *)recordPtr;
8081 WidgetCore *corePtr = &sb->core;
8182 Ttk_Element thumb;
8283 Ttk_Box thumbBox;
132133 ScrollbarSetCommand(
133134 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
134135 {
135 Scrollbar *scrollbar = recordPtr;
136 Scrollbar *scrollbar = (Scrollbar *)recordPtr;
136137 Tcl_Obj *firstObj, *lastObj;
137138 double first, last;
138139
183184 ScrollbarGetCommand(
184185 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
185186 {
186 Scrollbar *scrollbar = recordPtr;
187 Scrollbar *scrollbar = (Scrollbar *)recordPtr;
187188 Tcl_Obj *result[2];
188189
189190 if (objc != 2) {
206207 ScrollbarDeltaCommand(
207208 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
208209 {
209 Scrollbar *sb = recordPtr;
210 Scrollbar *sb = (Scrollbar *)recordPtr;
210211 double dx, dy;
211212 double delta = 0.0;
212213
240241
241242 /* $sb fraction $x $y --
242243 * Returns a real number between 0 and 1 indicating where the
243 * point given by x and y lies in the trough area of the scrollbar.
244 * point given by x and y lies in the trough area of the scrollbar.
244245 */
245246 static int
246247 ScrollbarFractionCommand(
247248 void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
248249 {
249 Scrollbar *sb = recordPtr;
250 Scrollbar *sb = (Scrollbar *)recordPtr;
250251 Ttk_Box b = sb->scrollbar.troughBox;
251252 int minSize = sb->scrollbar.minSize;
252253 double x, y;
314315 TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y,
315316 TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_TOP)
316317 TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM)
317 TTK_NODE(
318 "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH))
318 TTK_NODE("Vertical.Scrollbar.thumb", TTK_FILL_BOTH))
319319 TTK_END_LAYOUT
320320
321321 TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout)
322322 TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X,
323323 TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_LEFT)
324324 TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT)
325 TTK_NODE(
326 "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH))
325 TTK_NODE("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH))
327326 TTK_END_LAYOUT
328327
329328 /*------------------------------------------------------------------------
33 * ttk::separator and ttk::sizegrip widgets.
44 */
55
6 #include <tk.h>
7
6 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
109
2625 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
2726 Tk_Offset(Separator,separator.orientObj),
2827 Tk_Offset(Separator,separator.orient),
29 0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
28 0, (void *)ttkOrientStrings, STYLE_CHANGED },
3029
3130 WIDGET_TAKEFOCUS_FALSE,
3231 WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
22 * Minimal sample ttk widget.
33 */
44
5 #include <tk.h>
5 #include "tkInt.h"
66 #include "ttkTheme.h"
77 #include "ttkWidget.h"
88
5555 {TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
5656 DEFAULT_BACKGROUND, Tk_Offset(Square,square.foregroundObj),
5757 -1, 0, 0, 0},
58
58
5959 {TK_OPTION_PIXELS, "-width", "width", "Width",
6060 "50", Tk_Offset(Square,square.widthObj), -1, 0, 0,
6161 GEOMETRY_CHANGED},
6262 {TK_OPTION_PIXELS, "-height", "height", "Height",
6363 "50", Tk_Offset(Square,square.heightObj), -1, 0, 0,
6464 GEOMETRY_CHANGED},
65
65
6666 {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
67 Tk_Offset(Square,square.paddingObj), -1,
67 Tk_Offset(Square,square.paddingObj), -1,
6868 TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
69
69
7070 {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
7171 NULL, Tk_Offset(Square,square.reliefObj), -1, TK_OPTION_NULL_OK, 0, 0},
72
72
7373 {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
7474 NULL, Tk_Offset(Square,square.anchorObj), -1, TK_OPTION_NULL_OK, 0, 0},
75
75
7676 WIDGET_TAKEFOCUS_TRUE,
7777 WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
7878 };
108108 */
109109
110110 if (squareNode) {
111 Square *squarePtr = clientData;
111 Square *squarePtr = (Square *)clientData;
112112 Tk_Anchor anchor = TK_ANCHOR_CENTER;
113113 Ttk_Box b;
114114
137137 };
138138
139139 /*
140 * The Widget specification structure holds all the implementation
140 * The Widget specification structure holds all the implementation
141141 * information about this widget and this is what must be registered
142142 * with Tk in the package initialization code (see bottom).
143143 */
158158 TtkWidgetDisplay /* displayProc */
159159 };
160160
161 /* ----------------------------------------------------------------------
161 /* ----------------------------------------------------------------------
162162 * Square element
163163 *
164164 * In this section we demonstrate what is required to create a new themed
175175 Tcl_Obj *heightObj;
176176 } SquareElement;
177177
178 static Ttk_ElementOptionSpec SquareElementOptions[] =
178 static Ttk_ElementOptionSpec SquareElementOptions[] =
179179 {
180180 { "-background", TK_OPTION_BORDER, Tk_Offset(SquareElement,borderObj),
181181 DEFAULT_BACKGROUND },
187187 "raised" },
188188 { "-width", TK_OPTION_PIXELS, Tk_Offset(SquareElement,widthObj), "20"},
189189 { "-height", TK_OPTION_PIXELS, Tk_Offset(SquareElement,heightObj), "20"},
190 { NULL, 0, 0, NULL }
190 { NULL, TK_OPTION_BOOLEAN, 0, NULL }
191191 };
192192
193193 /*
197197 */
198198
199199 static void SquareElementSize(
200 void *clientData, void *elementRecord, Tk_Window tkwin,
200 void *dummy, void *elementRecord, Tk_Window tkwin,
201201 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
202202 {
203 SquareElement *square = elementRecord;
203 SquareElement *square = (SquareElement *)elementRecord;
204204 int borderWidth = 0;
205 (void)dummy;
205206
206207 Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
207208 *paddingPtr = Ttk_UniformPadding((short)borderWidth);
214215 */
215216
216217 static void SquareElementDraw(
217 void *clientData, void *elementRecord, Tk_Window tkwin,
218 void *dummy, void *elementRecord, Tk_Window tkwin,
218219 Drawable d, Ttk_Box b, unsigned int state)
219220 {
220 SquareElement *square = elementRecord;
221 SquareElement *square = (SquareElement *)elementRecord;
221222 Tk_3DBorder foreground = NULL;
222223 int borderWidth = 1, relief = TK_RELIEF_FLAT;
224 (void)dummy;
225 (void)state;
223226
224227 foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj);
225228 Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
247250 * engine is similar to the Tk pack geometry manager. Read the documentation
248251 * for the details. In this example we just need to have the square element
249252 * that has been defined for this widget placed on a background. We will
250 * also need some padding to keep it away from the edges.
253 * also need some padding to keep it away from the edges.
251254 */
252255
253256 TTK_BEGIN_LAYOUT(SquareLayout)
256259 TTK_NODE("Square.square", 0))
257260 TTK_END_LAYOUT
258261
259 /* ----------------------------------------------------------------------
262 /* ----------------------------------------------------------------------
260263 *
261264 * Widget initialization.
262265 *
263266 * This file defines a new element and a new widget. We need to register
264 * the element with the themes that will need it. In this case we will
267 * the element with the themes that will need it. In this case we will
265268 * register with the default theme that is the root of the theme inheritance
266269 * tree. This means all themes will find this element.
267270 * We then need to register the widget class style. This is the layout
286289
287290 /* register the new elements for this theme engine */
288291 Ttk_RegisterElement(interp, theme, "square", &SquareElementSpec, NULL);
289
292
290293 /* register the layout for this theme */
291294 Ttk_RegisterLayout(theme, "TSquare", SquareLayout);
292
295
293296 /* register the widget */
294297 RegisterWidget(interp, "ttk::square", &SquareWidgetSpec);
295298
44 *
55 */
66
7 #include <string.h>
8
9 #include <tk.h>
7 #include "tkInt.h"
108 #include "ttkTheme.h"
119
1210 /*
22 * It is compiled and linked in with the ttk package proper.
33 */
44
5 #include "tk.h"
5 #include "tkInt.h"
66 #include "ttkTheme.h"
77
88 MODULE_SCOPE const TtkStubs ttkStubs;
55 #undef USE_TCL_STUBS
66 #define USE_TCL_STUBS
77
8 #include "tk.h"
8 #include "tkInt.h"
99
1010 #define USE_TTK_STUBS 1
1111 #include "ttkTheme.h"
3535 int exact = 0;
3636 const char *packageName = "Ttk";
3737 const char *errMsg = NULL;
38 ClientData pkgClientData = NULL;
38 void *pkgClientData = NULL;
3939 const char *actualVersion = Tcl_PkgRequireEx(
4040 interp, packageName, version, exact, &pkgClientData);
41 const TtkStubs *stubsPtr = pkgClientData;
41 const TtkStubs *stubsPtr = (const TtkStubs *)pkgClientData;
4242
4343 if (!actualVersion) {
4444 return NULL;
6666 "Error loading ", packageName, " package",
6767 " (requested version '", version,
6868 "', loaded version '", actualVersion, "'): ",
69 errMsg,
69 errMsg,
7070 NULL);
7171 return NULL;
7272 }
33 * Copyright (C) 2005, Joe English. Freely redistributable.
44 */
55
6 #include <string.h> /* for memset() */
7 #include <tcl.h>
8 #include <tk.h>
6 #include "tkInt.h"
97
108 #include "ttkTheme.h"
119 #include "ttkWidget.h"
3331 */
3432 static Ttk_Tag NewTag(Ttk_TagTable tagTable, const char *tagName)
3533 {
36 Ttk_Tag tag = ckalloc(sizeof(*tag));
34 Ttk_Tag tag = (Ttk_Tag)ckalloc(sizeof(*tag));
3735 tag->tagRecord = ckalloc(tagTable->recordSize);
3836 memset(tag->tagRecord, 0, tagTable->recordSize);
3937 /* Don't need Tk_InitOptions() here, all defaults should be NULL. */
5755 Tcl_Interp *interp, Tk_Window tkwin,
5856 Tk_OptionSpec optionSpecs[], int recordSize)
5957 {
60 Ttk_TagTable tagTable = ckalloc(sizeof(*tagTable));
58 Ttk_TagTable tagTable = (Ttk_TagTable)ckalloc(sizeof(*tagTable));
6159 tagTable->tkwin = tkwin;
6260 tagTable->optionSpecs = optionSpecs;
6361 tagTable->optionTable = Tk_CreateOptionTable(interp, optionSpecs);
7472
7573 entryPtr = Tcl_FirstHashEntry(&tagTable->tags, &search);
7674 while (entryPtr != NULL) {
77 DeleteTag(tagTable, Tcl_GetHashValue(entryPtr));
75 DeleteTag(tagTable, (Ttk_Tag)Tcl_GetHashValue(entryPtr));
7876 entryPtr = Tcl_NextHashEntry(&search);
7977 }
8078
8987 &tagTable->tags, tagName, &isNew);
9088
9189 if (isNew) {
92 tagName = Tcl_GetHashKey(&tagTable->tags, entryPtr);
90 tagName = (char *)Tcl_GetHashKey(&tagTable->tags, entryPtr);
9391 Tcl_SetHashValue(entryPtr, NewTag(tagTable,tagName));
9492 }
95 return Tcl_GetHashValue(entryPtr);
93 return (Ttk_Tag)Tcl_GetHashValue(entryPtr);
9694 }
9795
9896 Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable tagTable, Tcl_Obj *objPtr)
115113 Ttk_TagSet Ttk_GetTagSetFromObj(
116114 Tcl_Interp *interp, Ttk_TagTable tagTable, Tcl_Obj *objPtr)
117115 {
118 Ttk_TagSet tagset = ckalloc(sizeof(*tagset));
116 Ttk_TagSet tagset = (Ttk_TagSet)ckalloc(sizeof(*tagset));
119117 Tcl_Obj **objv;
120118 int i, objc;
121119
130128 return NULL;
131129 }
132130
133 tagset->tags = ckalloc((objc+1) * sizeof(Ttk_Tag));
131 tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag));
134132 for (i=0; i<objc; ++i) {
135133 tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]);
136134 }
187185 return 0;
188186 }
189187 }
190 tagset->tags = ckrealloc(tagset->tags,
188 tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags,
191189 (tagset->nTags+1)*sizeof(tagset->tags[0]));
192190 tagset->tags[tagset->nTags++] = tag;
193191 return 1;
1414
1515 #define PKG_ASSOC_KEY "Ttk"
1616
17 #ifdef MAC_OSX_TK
18 extern void TkMacOSXFlushWindows(void);
19 #define UPDATE_WINDOWS() TkMacOSXFlushWindows()
20 #else
21 #define UPDATE_WINDOWS()
22 #endif
23
2417 /*------------------------------------------------------------------------
2518 * +++ Styles.
2619 *
4134 Ttk_ResourceCache cache; /* Back-pointer to resource cache */
4235 } Style;
4336
44 static Style *NewStyle()
45 {
46 Style *stylePtr = ckalloc(sizeof(Style));
37 static Style *NewStyle(void)
38 {
39 Style *stylePtr = (Style *)ckalloc(sizeof(Style));
4740
4841 stylePtr->styleName = NULL;
4942 stylePtr->parentStyle = NULL;
6255
6356 entryPtr = Tcl_FirstHashEntry(&stylePtr->settingsTable, &search);
6457 while (entryPtr != NULL) {
65 Ttk_StateMap stateMap = Tcl_GetHashValue(entryPtr);
58 Ttk_StateMap stateMap = (Ttk_StateMap)Tcl_GetHashValue(entryPtr);
6659 Tcl_DecrRefCount(stateMap);
6760 entryPtr = Tcl_NextHashEntry(&search);
6861 }
7063
7164 entryPtr = Tcl_FirstHashEntry(&stylePtr->defaultsTable, &search);
7265 while (entryPtr != NULL) {
73 Tcl_Obj *defaultValue = Tcl_GetHashValue(entryPtr);
66 Tcl_Obj *defaultValue = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
7467 Tcl_DecrRefCount(defaultValue);
7568 entryPtr = Tcl_NextHashEntry(&search);
7669 }
9184 Tcl_HashEntry *entryPtr =
9285 Tcl_FindHashEntry(&style->settingsTable, optionName);
9386 if (entryPtr) {
94 Ttk_StateMap stateMap = Tcl_GetHashValue(entryPtr);
87 Ttk_StateMap stateMap = (Ttk_StateMap)Tcl_GetHashValue(entryPtr);
9588 return Ttk_StateMapLookup(NULL, stateMap, state);
9689 }
9790 style = style->parentStyle;
109102 Tcl_HashEntry *entryPtr =
110103 Tcl_FindHashEntry(&style->defaultsTable, optionName);
111104 if (entryPtr)
112 return Tcl_GetHashValue(entryPtr);
105 return (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
113106 style= style->parentStyle;
114107 }
115108 return 0;
182175 static OptionMap
183176 BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
184177 {
185 OptionMap optionMap = ckalloc(
178 OptionMap optionMap = (OptionMap)ckalloc(
186179 sizeof(const Tk_OptionSpec) * elementClass->nResources + 1);
187180 int i;
188181
210203 optionMap = BuildOptionMap(elementClass, optionTable);
211204 Tcl_SetHashValue(entryPtr, optionMap);
212205 } else {
213 optionMap = Tcl_GetHashValue(entryPtr);
206 optionMap = (OptionMap)Tcl_GetHashValue(entryPtr);
214207 }
215208
216209 return optionMap;
224217 static Ttk_ElementClass *
225218 NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData)
226219 {
227 Ttk_ElementClass *elementClass = ckalloc(sizeof(Ttk_ElementClass));
220 Ttk_ElementClass *elementClass = (Ttk_ElementClass *)ckalloc(sizeof(Ttk_ElementClass));
228221 int i;
229222
230223 elementClass->name = name;
240233
241234 /* Initialize default values:
242235 */
243 elementClass->defaultValues =
236 elementClass->defaultValues = (Tcl_Obj **)
244237 ckalloc(elementClass->nResources * sizeof(Tcl_Obj *) + 1);
245238 for (i=0; i < elementClass->nResources; ++i) {
246239 const char *defaultValue = specPtr->options[i].defaultValue;
297290 * +++ Themes.
298291 */
299292
300 static int ThemeEnabled(Ttk_Theme theme, void *clientData) { return 1; }
293 static int ThemeEnabled(
294 TCL_UNUSED(Ttk_Theme),
295 TCL_UNUSED(void *))
296 {
301297 /* Default ThemeEnabledProc -- always return true */
298 return 1;
299 }
302300
303301 typedef struct Ttk_Theme_
304302 {
313311
314312 static Theme *NewTheme(Ttk_ResourceCache cache, Ttk_Theme parent)
315313 {
316 Theme *themePtr = ckalloc(sizeof(Theme));
314 Theme *themePtr = (Theme *)ckalloc(sizeof(Theme));
317315 Tcl_HashEntry *entryPtr;
318316 int unused;
319317
330328 entryPtr = Tcl_CreateHashEntry(&themePtr->styleTable, ".", &unused);
331329 themePtr->rootStyle = NewStyle();
332330 themePtr->rootStyle->styleName =
333 Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
331 (const char *)Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
334332 themePtr->rootStyle->cache = themePtr->cache;
335333 Tcl_SetHashValue(entryPtr, themePtr->rootStyle);
336334
347345 */
348346 entryPtr = Tcl_FirstHashEntry(&themePtr->elementTable, &search);
349347 while (entryPtr != NULL) {
350 Ttk_ElementClass *elementClass = Tcl_GetHashValue(entryPtr);
348 Ttk_ElementClass *elementClass = (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
351349 FreeElementClass(elementClass);
352350 entryPtr = Tcl_NextHashEntry(&search);
353351 }
358356 */
359357 entryPtr = Tcl_FirstHashEntry(&themePtr->styleTable, &search);
360358 while (entryPtr != NULL) {
361 Style *stylePtr = Tcl_GetHashValue(entryPtr);
359 Style *stylePtr = (Style *)Tcl_GetHashValue(entryPtr);
362360 FreeStyle(stylePtr);
363361 entryPtr = Tcl_NextHashEntry(&search);
364362 }
390388 } Cleanup;
391389
392390 /*------------------------------------------------------------------------
393 * +++ Master style package data structure.
391 * +++ Style package data structure.
394392 */
395393 typedef struct
396394 {
404402 int themeChangePending; /* scheduled ThemeChangedProc call? */
405403 } StylePackageData;
406404
407 static void ThemeChangedProc(ClientData); /* Forward */
405 static void ThemeChangedProc(void *); /* Forward */
408406
409407 /* Ttk_StylePkgFree --
410408 * Cleanup procedure for StylePackageData.
411409 */
412 static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *interp)
413 {
414 StylePackageData *pkgPtr = clientData;
410 static void Ttk_StylePkgFree(
411 ClientData clientData,
412 TCL_UNUSED(Tcl_Interp *))
413 {
414 StylePackageData *pkgPtr = (StylePackageData *)clientData;
415415 Tcl_HashSearch search;
416416 Tcl_HashEntry *entryPtr;
417417 Cleanup *cleanup;
428428 */
429429 entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
430430 while (entryPtr != NULL) {
431 Theme *themePtr = Tcl_GetHashValue(entryPtr);
431 Theme *themePtr = (Theme *)Tcl_GetHashValue(entryPtr);
432432 FreeTheme(themePtr);
433433 entryPtr = Tcl_NextHashEntry(&search);
434434 }
470470
471471 static StylePackageData *GetStylePackageData(Tcl_Interp *interp)
472472 {
473 return Tcl_GetAssocData(interp, PKG_ASSOC_KEY, NULL);
473 return (StylePackageData *)Tcl_GetAssocData(interp, PKG_ASSOC_KEY, NULL);
474474 }
475475
476476 /*
485485 void Ttk_RegisterCleanup(
486486 Tcl_Interp *interp, ClientData clientData, Ttk_CleanupProc *cleanupProc)
487487 {
488 StylePackageData *pkgPtr = GetStylePackageData(interp);
489 Cleanup *cleanup = ckalloc(sizeof(*cleanup));
488 StylePackageData *pkgPtr = (StylePackageData *)GetStylePackageData(interp);
489 Cleanup *cleanup = (Cleanup *)ckalloc(sizeof(*cleanup));
490490
491491 cleanup->clientData = clientData;
492492 cleanup->cleanupProc = cleanupProc;
509509 static void ThemeChangedProc(ClientData clientData)
510510 {
511511 static char ThemeChangedScript[] = "ttk::ThemeChanged";
512 StylePackageData *pkgPtr = clientData;
512 StylePackageData *pkgPtr = (StylePackageData *)clientData;
513513
514514 int code = Tcl_EvalEx(pkgPtr->interp, ThemeChangedScript, -1, TCL_EVAL_GLOBAL);
515515 if (code != TCL_OK) {
516516 Tcl_BackgroundException(pkgPtr->interp, code);
517517 }
518518 pkgPtr->themeChangePending = 0;
519 UPDATE_WINDOWS();
520519 }
521520
522521 /*
590589
591590 static Ttk_Theme LookupTheme(
592591 Tcl_Interp *interp, /* where to leave error messages */
593 StylePackageData *pkgPtr, /* style package master record */
592 StylePackageData *pkgPtr, /* style package record */
594593 const char *name) /* theme name */
595594 {
596595 Tcl_HashEntry *entryPtr;
603602 return NULL;
604603 }
605604
606 return Tcl_GetHashValue(entryPtr);
605 return (Ttk_Theme)Tcl_GetHashValue(entryPtr);
607606 }
608607
609608 /*
711710 stylePtr->parentStyle = themePtr->rootStyle;
712711 }
713712
714 stylePtr->styleName = Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
713 stylePtr->styleName = (const char *)Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
715714 stylePtr->cache = stylePtr->parentStyle->cache;
716715 Tcl_SetHashValue(entryPtr, stylePtr);
717716 return stylePtr;
718717 }
719 return Tcl_GetHashValue(entryPtr);
718 return (Ttk_Style)Tcl_GetHashValue(entryPtr);
720719 }
721720
722721 /* FindLayoutTemplate --
762761 */
763762 entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, elementName);
764763 if (entryPtr) {
765 return Tcl_GetHashValue(entryPtr);
764 return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
766765 }
767766
768767 /*
773772 entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, dot);
774773 }
775774 if (entryPtr) {
776 return Tcl_GetHashValue(entryPtr);
775 return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
777776 }
778777
779778 /*
789788 */
790789 entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, "");
791790 /* ASSERT: entryPtr != 0 */
792 return Tcl_GetHashValue(entryPtr);
791 return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
793792 }
794793
795794 const char *Ttk_ElementClassName(Ttk_ElementClass *elementClass)
806805 Ttk_ElementFactory factory, void *clientData)
807806 {
808807 StylePackageData *pkgPtr = GetStylePackageData(interp);
809 FactoryRec *recPtr = ckalloc(sizeof(*recPtr));
808 FactoryRec *recPtr = (FactoryRec *)ckalloc(sizeof(*recPtr));
810809 Tcl_HashEntry *entryPtr;
811810 int newEntry;
812811
827826 * (style element create $name) "from" $theme ?$element?
828827 */
829828 static int Ttk_CloneElement(
830 Tcl_Interp *interp, void *clientData,
829 Tcl_Interp *interp, TCL_UNUSED(void *),
831830 Ttk_Theme theme, const char *elementName,
832831 int objc, Tcl_Obj *const objv[])
833832 {
902901 return 0;
903902 }
904903
905 name = Tcl_GetHashKey(&theme->elementTable, entryPtr);
904 name = (char *)Tcl_GetHashKey(&theme->elementTable, entryPtr);
906905 elementClass = NewElementClass(name, specPtr, clientData);
907906 Tcl_SetHashValue(entryPtr, elementClass);
908907
991990 int i;
992991 for (i=0; i<nResources; ++i, ++elementOption) {
993992 Tcl_Obj **dest = (Tcl_Obj **)
994 (elementRecord + elementOption->offset);
993 ((char *)elementRecord + elementOption->offset);
995994 const char *optionName = elementOption->optionName;
996995 Tcl_Obj *dynamicSetting = Ttk_StyleMap(style, optionName, state);
997996 Tcl_Obj *widgetValue = 0;
999998
1000999 if (optionMap[i]) {
10011000 widgetValue = *(Tcl_Obj **)
1002 (widgetRecord + optionMap[i]->objOffset);
1001 ((char *)widgetRecord + optionMap[i]->objOffset);
10031002 }
10041003
10051004 if (widgetValue) {
11411140 Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search);
11421141
11431142 while (entryPtr != NULL) {
1144 Tcl_Obj *nameObj = Tcl_NewStringObj(Tcl_GetHashKey(ht, entryPtr),-1);
1143 Tcl_Obj *nameObj = Tcl_NewStringObj((const char *)Tcl_GetHashKey(ht, entryPtr),-1);
11451144 Tcl_ListObjAppendElement(interp, result, nameObj);
11461145 entryPtr = Tcl_NextHashEntry(&search);
11471146 }
11611160 Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search);
11621161
11631162 while (entryPtr != NULL) {
1164 Tcl_Obj *nameObj = Tcl_NewStringObj(Tcl_GetHashKey(ht, entryPtr),-1);
1165 Tcl_Obj *valueObj = Tcl_GetHashValue(entryPtr);
1163 Tcl_Obj *nameObj = Tcl_NewStringObj((const char *)Tcl_GetHashKey(ht, entryPtr),-1);
1164 Tcl_Obj *valueObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
11661165 Tcl_ListObjAppendElement(NULL, result, nameObj);
11671166 Tcl_ListObjAppendElement(NULL, result, valueObj);
11681167 entryPtr = Tcl_NextHashEntry(&search);
11781177 */
11791178 static int
11801179 StyleMapCmd(
1181 ClientData clientData, /* Master StylePackageData pointer */
1180 ClientData clientData, /* StylePackageData pointer */
11821181 Tcl_Interp *interp, /* Current interpreter */
11831182 int objc, /* Number of arguments */
11841183 Tcl_Obj *const objv[]) /* Argument objects */
11851184 {
1186 StylePackageData *pkgPtr = clientData;
1185 StylePackageData *pkgPtr = (StylePackageData *)clientData;
11871186 Ttk_Theme theme = pkgPtr->currentTheme;
11881187 const char *styleName;
11891188 Style *stylePtr;
12471246 static int StyleConfigureCmd(
12481247 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
12491248 {
1250 StylePackageData *pkgPtr = clientData;
1249 StylePackageData *pkgPtr = (StylePackageData *)clientData;
12511250 Ttk_Theme theme = pkgPtr->currentTheme;
12521251 const char *styleName;
12531252 Style *stylePtr;
13021301 static int StyleLookupCmd(
13031302 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
13041303 {
1305 StylePackageData *pkgPtr = clientData;
1304 StylePackageData *pkgPtr = (StylePackageData *)clientData;
13061305 Ttk_Theme theme = pkgPtr->currentTheme;
13071306 Ttk_Style style = NULL;
13081307 const char *optionName;
13441343 static int StyleThemeCurrentCmd(
13451344 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[])
13461345 {
1347 StylePackageData *pkgPtr = clientData;
1346 StylePackageData *pkgPtr = (StylePackageData *)clientData;
13481347 Tcl_HashSearch search;
13491348 Tcl_HashEntry *entryPtr = NULL;
13501349 const char *name = NULL;
13561355
13571356 entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
13581357 while (entryPtr != NULL) {
1359 Theme *ptr = Tcl_GetHashValue(entryPtr);
1358 Theme *ptr = (Theme *)Tcl_GetHashValue(entryPtr);
13601359 if (ptr == pkgPtr->currentTheme) {
1361 name = Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr);
1360 name = (char *)Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr);
13621361 break;
13631362 }
13641363 entryPtr = Tcl_NextHashEntry(&search);
13801379 static int StyleThemeCreateCmd(
13811380 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
13821381 {
1383 StylePackageData *pkgPtr = clientData;
1382 StylePackageData *pkgPtr = (StylePackageData *)clientData;
13841383 static const char *optStrings[] =
13851384 { "-parent", "-settings", NULL };
13861385 enum { OP_PARENT, OP_SETTINGS };
14421441 * Return list of registered themes.
14431442 */
14441443 static int StyleThemeNamesCmd(
1445 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
1446 {
1447 StylePackageData *pkgPtr = clientData;
1444 ClientData clientData,
1445 Tcl_Interp *interp,
1446 TCL_UNUSED(int),
1447 TCL_UNUSED(Tcl_Obj *const *))
1448 {
1449 StylePackageData *pkgPtr = (StylePackageData *)clientData;
1450
14481451 return TtkEnumerateHashTable(interp, &pkgPtr->themeTable);
14491452 }
14501453
14551458 */
14561459 static int
14571460 StyleThemeSettingsCmd(
1458 ClientData clientData, /* Master StylePackageData pointer */
1461 ClientData clientData, /* StylePackageData pointer */
14591462 Tcl_Interp *interp, /* Current interpreter */
14601463 int objc, /* Number of arguments */
14611464 Tcl_Obj *const objv[]) /* Argument objects */
14621465 {
1463 StylePackageData *pkgPtr = clientData;
1466 StylePackageData *pkgPtr = (StylePackageData *)clientData;
14641467 Ttk_Theme oldTheme = pkgPtr->currentTheme;
14651468 Ttk_Theme newTheme;
14661469 int status;
14861489 static int StyleElementCreateCmd(
14871490 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
14881491 {
1489 StylePackageData *pkgPtr = clientData;
1492 StylePackageData *pkgPtr = (StylePackageData *)clientData;
14901493 Ttk_Theme theme = pkgPtr->currentTheme;
14911494 const char *elementName, *factoryName;
14921495 Tcl_HashEntry *entryPtr;
15091512 return TCL_ERROR;
15101513 }
15111514
1512 recPtr = Tcl_GetHashValue(entryPtr);
1515 recPtr = (FactoryRec *)Tcl_GetHashValue(entryPtr);
15131516
15141517 return recPtr->factory(interp, recPtr->clientData,
15151518 theme, elementName, objc - 5, objv + 5);
15211524 static int StyleElementNamesCmd(
15221525 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
15231526 {
1524 StylePackageData *pkgPtr = clientData;
1527 StylePackageData *pkgPtr = (StylePackageData *)clientData;
15251528 Ttk_Theme theme = pkgPtr->currentTheme;
15261529
15271530 if (objc != 3) {
15371540 static int StyleElementOptionsCmd(
15381541 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
15391542 {
1540 StylePackageData *pkgPtr = clientData;
1543 StylePackageData *pkgPtr = (StylePackageData *)clientData;
15411544 Ttk_Theme theme = pkgPtr->currentTheme;
15421545 const char *elementName;
15431546 Ttk_ElementClass *elementClass;
15751578 static int StyleLayoutCmd(
15761579 ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
15771580 {
1578 StylePackageData *pkgPtr = clientData;
1581 StylePackageData *pkgPtr = (StylePackageData *)clientData;
15791582 Ttk_Theme theme = pkgPtr->currentTheme;
15801583 const char *layoutName;
15811584 Ttk_LayoutTemplate layoutTemplate;
16131616 */
16141617 static int
16151618 StyleThemeUseCmd(
1616 ClientData clientData, /* Master StylePackageData pointer */
1619 ClientData clientData, /* StylePackageData pointer */
16171620 Tcl_Interp *interp, /* Current interpreter */
16181621 int objc, /* Number of arguments */
16191622 Tcl_Obj *const objv[]) /* Argument objects */
16201623 {
1621 StylePackageData *pkgPtr = clientData;
1624 StylePackageData *pkgPtr = (StylePackageData *)clientData;
16221625 Ttk_Theme theme;
16231626
16241627 if (objc < 3 || objc > 4) {
16701673
16711674 static int
16721675 StyleObjCmd(
1673 ClientData clientData, /* Master StylePackageData pointer */
1676 ClientData clientData, /* StylePackageData pointer */
16741677 Tcl_Interp *interp, /* Current interpreter */
16751678 int objc, /* Number of arguments */
16761679 Tcl_Obj *const objv[]) /* Argument objects */
17131716 {
17141717 Tcl_Namespace *nsPtr;
17151718
1716 StylePackageData *pkgPtr = ckalloc(sizeof(StylePackageData));
1719 StylePackageData *pkgPtr = (StylePackageData *)ckalloc(sizeof(StylePackageData));
17171720
17181721 pkgPtr->interp = interp;
17191722 Tcl_InitHashTable(&pkgPtr->themeTable, TCL_STRING_KEYS);
22 *
33 * Simplified interface to Tcl_TraceVariable.
44 *
5 * PROBLEM: Can't distinguish "variable does not exist" (which is OK)
5 * PROBLEM: Can't distinguish "variable does not exist" (which is OK)
66 * from other errors (which are not).
77 */
88
9 #include <tk.h>
9 #include "tkInt.h"
1010 #include "ttkTheme.h"
1111 #include "ttkWidget.h"
1212
2929 const char *name2, /* (unused) */
3030 int flags) /* Information about what happened. */
3131 {
32 Ttk_TraceHandle *tracePtr = clientData;
32 Ttk_TraceHandle *tracePtr = (Ttk_TraceHandle *)clientData;
3333 const char *name, *value;
3434 Tcl_Obj *valuePtr;
35 (void)name1;
36 (void)name2;
3537
3638 if (Tcl_InterpDeleted(interp)) {
3739 return NULL;
5052 */
5153 if (tracePtr->interp == NULL) {
5254 Tcl_DecrRefCount(tracePtr->varnameObj);
53 ckfree((ClientData)tracePtr);
55 ckfree(tracePtr);
5456 return NULL;
5557 }
5658 Tcl_TraceVar2(interp, name, NULL,
8486 Ttk_TraceProc callback,
8587 void *clientData)
8688 {
87 Ttk_TraceHandle *h = ckalloc(sizeof(*h));
89 Ttk_TraceHandle *h = (Ttk_TraceHandle *)ckalloc(sizeof(*h));
8890 int status;
8991
9092 h->interp = interp;
9597
9698 status = Tcl_TraceVar2(interp, Tcl_GetString(varnameObj),
9799 NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
98 VarTraceProc, (ClientData)h);
100 VarTraceProc, h);
99101
100102 if (status != TCL_OK) {
101103 Tcl_DecrRefCount(h->varnameObj);
136138 */
137139 while ((cd = Tcl_VarTraceInfo(h->interp, Tcl_GetString(h->varnameObj),
138140 TCL_GLOBAL_ONLY, VarTraceProc, cd)) != NULL) {
139 if (cd == (ClientData) h) {
141 if (cd == h) {
140142 break;
141143 }
142144 }
151153 }
152154 Tcl_UntraceVar2(h->interp, Tcl_GetString(h->varnameObj),
153155 NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
154 VarTraceProc, (ClientData)h);
156 VarTraceProc, h);
155157 Tcl_DecrRefCount(h->varnameObj);
156158 ckfree(h);
157159 }
2222 * TODO: Handle "chords" properly (e.g., <B1-ButtonPress-2>)
2323 */
2424
25 #include <tk.h>
25 #include "tkInt.h"
2626 #include "ttkTheme.h"
2727 #include "ttkWidget.h"
2828
33 * ttk::treeview widget implementation.
44 */
55
6 #include <string.h>
7 #include <stdio.h>
86 #include "tkInt.h"
97 #include "ttkTheme.h"
108 #include "ttkWidget.h"
17781776 x+indent, y, colwidth-indent, rowHeight);
17791777 if (item->textObj) { displayItem.textObj = item->textObj; }
17801778 if (item->imageObj) { displayItem.imageObj = item->imageObj; }
1781 /* ??? displayItem.anchorObj = 0; <<NOTE-ANCHOR>> */
1779 displayItem.anchorObj = tv->tree.column0.anchorObj;
17821780 DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d);
17831781 x += colwidth;
17841782 }
28412839 TtkRedisplayWidget(&tv->core);
28422840 }
28432841 }
2844 tv->tree.yscroll.total = CountRows(tv->tree.root) - 1;
28452842
28462843 /* Make sure item is visible:
28472844 */
33203317 TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH,
33213318 TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT)
33223319 TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
3323 TTK_GROUP("Treeitem.focus", TTK_PACK_LEFT,
3324 TTK_NODE("Treeitem.text", TTK_PACK_LEFT))))
3320 TTK_NODE("Treeitem.text", TTK_FILL_BOTH)))
33253321
33263322 TTK_LAYOUT("Cell",
33273323 TTK_GROUP("Treedata.padding", TTK_FILL_BOTH,
33 * Core widget utilities.
44 */
55
6 #include <string.h>
76 #include "tkInt.h"
87 #include "ttkTheme.h"
98 #include "ttkWidget.h"
262261
263262 static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
264263 {
265 WidgetCore *corePtr = clientData;
264 WidgetCore *corePtr = (WidgetCore *)clientData;
266265
267266 switch (eventPtr->type)
268267 {
309308 corePtr->state |= TTK_STATE_HOVER;
310309 TtkRedisplayWidget(corePtr);
311310 break;
312 case VirtualEvent:
313 if (!strcmp("ThemeChanged", ((XVirtualEvent *)(eventPtr))->name)) {
311 case VirtualEvent: {
312 const char *name = ((XVirtualEvent *)eventPtr)->name;
313 if ((name != NULL) && !strcmp("ThemeChanged", name)) {
314314 (void)UpdateLayout(corePtr->interp, corePtr);
315315 SizeChanged(corePtr);
316316 TtkRedisplayWidget(corePtr);
317317 }
318 break;
319 }
318320 default:
319321 /* can't happen... */
320322 break;
110110
111111 /* WIDGET_TAKEFOCUS_TRUE --
112112 * WIDGET_TAKEFOCUS_FALSE --
113 * Add one or the other of these to each OptionSpecs table
114 * to indicate whether the widget should take focus
113 * Add one or the other of these to each OptionSpecs table
114 * to indicate whether the widget should take focus
115115 * during keyboard traversal.
116116 */
117117 #define WIDGET_TAKEFOCUS_TRUE \
4040 set w .bgerrorDialog
4141 set caption [option get $w.function text {}]
4242 set command [option get $w.function command {}]
43 if { ($caption eq "") || ($command eq "") } {
43 if {($caption eq "") || ($command eq "")} {
4444 grid forget $w.function
4545 }
4646 lappend command [$w.top.info.text get 1.0 end-1c]
4949 }
5050
5151 proc ::tk::dialog::error::SaveToLog {text} {
52 if { $::tcl_platform(platform) eq "windows" } {
52 if {$::tcl_platform(platform) eq "windows"} {
5353 set allFiles *.*
5454 } else {
5555 set allFiles *
128128 set lines 0
129129 set maxLine 45
130130 foreach line [split $err \n] {
131 if { [string length $line] > $maxLine } {
132 append displayedErr "[string range $line 0 [expr {$maxLine-3}]]..."
131 if {[string length $line] > $maxLine} {
132 append displayedErr "[string range $line 0 $maxLine-3]..."
133133 break
134134 }
135 if { $lines > 4 } {
135 if {$lines > 4} {
136136 append displayedErr "..."
137137 break
138138 } else {
181181 pack $W.text -side left -expand yes -fill both
182182 $W.text insert 0.0 "$err\n$info"
183183 $W.text mark set insert 0.0
184 bind $W.text <ButtonPress-1> { focus %W }
184 bind $W.text <Button-1> {focus %W}
185185 $W.text configure -state disabled
186186
187187 # 2. Fill the top part with bitmap and message
395395
396396 # Draw the selection polygons
397397 CreateSelector $w $sel $c
398 $sel bind $data($c,index) <ButtonPress-1> \
398 $sel bind $data($c,index) <Button-1> \
399399 [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
400400 $sel bind $data($c,index) <B1-Motion> \
401401 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
408408 set data($c,clickRegion) [$sel create rectangle 0 0 \
409409 $data(canvasWidth) $height -fill {} -outline {}]
410410
411 bind $col <ButtonPress-1> \
411 bind $col <Button-1> \
412412 [list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
413413 bind $col <B1-Motion> \
414414 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
415415 bind $col <ButtonRelease-1> \
416416 [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
417417
418 $sel bind $data($c,clickRegion) <ButtonPress-1> \
418 $sel bind $data($c,clickRegion) <Button-1> \
419419 [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
420420 $sel bind $data($c,clickRegion) <B1-Motion> \
421421 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
2828 # {....}
2929 # }
3030 #
31 # flags = currently unused.
31 # flags = a list of flags. Currently supported flags are:
32 # DONTSETDEFAULTS = skip default values setting
3233 #
3334 # argList = The list of "-option value" pairs.
3435 #
6263
6364 # 2: set the default values
6465 #
65 foreach cmdsw [array names cmd] {
66 set data($cmdsw) $def($cmdsw)
66 if {"DONTSETDEFAULTS" ni $flags} {
67 foreach cmdsw [array names cmd] {
68 set data($cmdsw) $def($cmdsw)
69 }
6770 }
6871
6972 # 3: parse the argument list
130130 default { set preferred {} }
131131 }
132132 foreach {family size} $preferred {
133 if {[lsearch -exact $families $family] != -1} {
133 if {$family in $families} {
134134 font configure TkConsoleFont -family $family -size $size
135135 break
136136 }
591591 }
592592 bind Console <F9> {
593593 eval destroy [winfo child .]
594 source [file join $tk_library console.tcl]
594 source -encoding utf-8 [file join $tk_library console.tcl]
595595 }
596596 if {[tk windowingsystem] eq "aqua"} {
597597 bind Console <Command-q> {
739739 }
740740 proc ::tk::console::FontchooserVisibility {index} {
741741 if {[tk fontchooser configure -visible]} {
742 .menubar.edit entryconfigure $index -label [msgcat::mc "Hide Fonts"]
743 } else {
744 .menubar.edit entryconfigure $index -label [msgcat::mc "Show Fonts"]
742 .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"]
743 } else {
744 .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"]
745745 }
746746 }
747747 proc ::tk::console::FontchooserFocus {w isFocusIn} {
153153 $c bind box <Leave> "$c itemconfigure current $demo_arrowInfo(boxStyle)"
154154 $c bind box <B1-Enter> " "
155155 $c bind box <B1-Leave> " "
156 $c bind box1 <1> {set demo_arrowInfo(motionProc) arrowMove1}
157 $c bind box2 <1> {set demo_arrowInfo(motionProc) arrowMove2}
158 $c bind box3 <1> {set demo_arrowInfo(motionProc) arrowMove3}
156 $c bind box1 <Button-1> {set demo_arrowInfo(motionProc) arrowMove1}
157 $c bind box2 <Button-1> {set demo_arrowInfo(motionProc) arrowMove2}
158 $c bind box3 <Button-1> {set demo_arrowInfo(motionProc) arrowMove3}
159159 $c bind box <B1-Motion> "\$demo_arrowInfo(motionProc) $c %x %y"
160 bind $c <Any-ButtonRelease-1> "arrowSetup $c"
160 bind $c <ButtonRelease-1> "arrowSetup $c"
161161
162162 # arrowMove1 --
163163 # This procedure is called for each mouse motion event on box1 (the
6262 # Create bindings for tags.
6363
6464 foreach tag {d1 d2 d3 d4 d5 d6} {
65 $w.text tag bind $tag <Any-Enter> "$w.text tag configure $tag $bold"
66 $w.text tag bind $tag <Any-Leave> "$w.text tag configure $tag $normal"
65 $w.text tag bind $tag <Enter> "$w.text tag configure $tag $bold"
66 $w.text tag bind $tag <Leave> "$w.text tag configure $tag $normal"
6767 }
6868 # Main widget program sets variable tk_demoDirectory
69 $w.text tag bind d1 <1> {source [file join $tk_demoDirectory items.tcl]}
70 $w.text tag bind d2 <1> {source [file join $tk_demoDirectory plot.tcl]}
71 $w.text tag bind d3 <1> {source [file join $tk_demoDirectory ctext.tcl]}
72 $w.text tag bind d4 <1> {source [file join $tk_demoDirectory arrow.tcl]}
73 $w.text tag bind d5 <1> {source [file join $tk_demoDirectory ruler.tcl]}
74 $w.text tag bind d6 <1> {source [file join $tk_demoDirectory cscroll.tcl]}
69 $w.text tag bind d1 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory items.tcl]}
70 $w.text tag bind d2 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory plot.tcl]}
71 $w.text tag bind d3 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ctext.tcl]}
72 $w.text tag bind d4 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory arrow.tcl]}
73 $w.text tag bind d5 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ruler.tcl]}
74 $w.text tag bind d6 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory cscroll.tcl]}
7575
7676 $w.text mark set insert 0.0
7777 $w.text configure -state disabled
3131 -width 20 -height 16 -setgrid 1
3232 pack $w.frame.list $w.frame.scroll -side left -fill y -expand 1
3333
34 bind $w.frame.list <Double-1> {
34 bind $w.frame.list <Double-Button-1> {
3535 tk_setPalette [selection get]
3636 }
3737 $w.frame.list insert 0 gray60 gray70 gray80 gray85 gray90 gray95 \
5252 }
5353 }
5454
55 $c bind all <Any-Enter> "scrollEnter $c"
56 $c bind all <Any-Leave> "scrollLeave $c"
57 $c bind all <1> "scrollButton $c"
58 bind $c <2> "$c scan mark %x %y"
59 bind $c <B2-Motion> "$c scan dragto %x %y"
60 if {[tk windowingsystem] eq "aqua"} {
55 $c bind all <Enter> "scrollEnter $c"
56 $c bind all <Leave> "scrollLeave $c"
57 $c bind all <Button-1> "scrollButton $c"
58 if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} {
59 bind $c <Button-3> "$c scan mark %x %y"
60 bind $c <B3-Motion> "$c scan dragto %x %y"
6161 bind $c <MouseWheel> {
62 %W yview scroll [expr {-(%D)}] units
62 %W yview scroll [expr {-%D}] units
6363 }
6464 bind $c <Option-MouseWheel> {
65 %W yview scroll [expr {-10 * (%D)}] units
65 %W yview scroll [expr {-10*%D}] units
6666 }
6767 bind $c <Shift-MouseWheel> {
68 %W xview scroll [expr {-(%D)}] units
68 %W xview scroll [expr {-%D}] units
6969 }
7070 bind $c <Shift-Option-MouseWheel> {
71 %W xview scroll [expr {-10 * (%D)}] units
71 %W xview scroll [expr {-10*%D}] units
7272 }
7373 } else {
74 bind $c <Button-2> "$c scan mark %x %y"
75 bind $c <B2-Motion> "$c scan dragto %x %y"
76 # We must make sure that positive and negative movements are rounded
77 # equally to integers, avoiding the problem that
78 # (int)1/-30 = -1,
79 # but
80 # (int)-1/-30 = 0
81 # The following code ensure equal +/- behaviour.
7482 bind $c <MouseWheel> {
75 %W yview scroll [expr {-(%D / 30)}] units
83 if {%D >= 0} {
84 %W yview scroll [expr {%D/-30}] units
85 } else {
86 %W yview scroll [expr {(%D-29)/-30}] units
87 }
88 }
89 bind $c <Option-MouseWheel> {
90 if {%D >= 0} {
91 %W yview scroll [expr {%D/-3}] units
92 } else {
93 %W yview scroll [expr {(%D-2)/-3}] units
94 }
7695 }
7796 bind $c <Shift-MouseWheel> {
78 %W xview scroll [expr {-(%D / 30)}] units
97 if {%D >= 0} {
98 %W xview scroll [expr {%D/-30}] units
99 } else {
100 %W xview scroll [expr {(%D-29)/-30}] units
101 }
102 }
103 bind $c <Shift-Option-MouseWheel> {
104 if {%D >= 0} {
105 %W xview scroll [expr {%D/-3}] units
106 } else {
107 %W xview scroll [expr {(%D-2)/-3}] units
108 }
79109 }
80110 }
81111
82 if {[tk windowingsystem] eq "x11"} {
112 if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} {
83113 # Support for mousewheels on Linux/Unix commonly comes through mapping
84114 # the wheel to the extended buttons. If you have a mousewheel, find
85115 # Linux configuration info at:
86116 # http://linuxreviews.org/howtos/xfree/mouse/
87 bind $c <4> {
117 bind $c <Button-4> {
88118 if {!$tk_strictMotif} {
89119 %W yview scroll -5 units
90120 }
91121 }
92 bind $c <Shift-4> {
122 bind $c <Shift-Button-4> {
93123 if {!$tk_strictMotif} {
94124 %W xview scroll -5 units
95125 }
96126 }
97 bind $c <5> {
127 bind $c <Button-5> {
98128 if {!$tk_strictMotif} {
99129 %W yview scroll 5 units
100130 }
101131 }
102 bind $c <Shift-5> {
132 bind $c <Shift-Button-5> {
103133 if {!$tk_strictMotif} {
104134 %W xview scroll 5 units
105135 }
4040 # First, create the text item and give it bindings so it can be edited.
4141
4242 $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]
43 $c bind text <1> "textB1Press $c %x %y"
43 $c bind text <Button-1> "textB1Press $c %x %y"
4444 $c bind text <B1-Motion> "textB1Move $c %x %y"
45 $c bind text <Shift-1> "$c select adjust current @%x,%y"
45 $c bind text <Shift-Button-1> "$c select adjust current @%x,%y"
4646 $c bind text <Shift-B1-Motion> "textB1Move $c %x %y"
47 $c bind text <KeyPress> "textInsert $c %A"
47 $c bind text <Key> "textInsert $c %A"
4848 $c bind text <Return> "textInsert $c \\n"
4949 $c bind text <Control-h> "textBs $c"
5050 $c bind text <BackSpace> "textBs $c"
5151 $c bind text <Delete> "textDel $c"
52 $c bind text <2> "textPaste $c @%x,%y"
52 if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
53 $c bind text <Button-3> "textPaste $c @%x,%y"
54 } else {
55 $c bind text <Button-2> "textPaste $c @%x,%y"
56 }
5357
5458 # Next, create some items that allow the text's anchor position
5559 # to be edited.
5761 proc mkTextConfigBox {w x y option value color} {
5862 set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \
5963 -outline black -fill $color -width 1]
60 $w bind $item <1> "$w itemconf text $option $value"
64 $w bind $item <Button-1> "$w itemconf text $option $value"
6165 $w addtag config withtag $item
6266 }
6367 proc mkTextConfigPie {w x y a option value color} {
6468 set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \
6569 -start [expr {$a-15}] -extent 30 -outline black -fill $color \
6670 -width 1]
67 $w bind $item <1> "$w itemconf text $option $value"
71 $w bind $item <Button-1> "$w itemconf text $option $value"
6872 $w addtag config withtag $item
6973 }
7074
8387 set item [$c create rect \
8488 [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \
8589 -outline black -fill red]
86 $c bind $item <1> "$c itemconf text -anchor center"
90 $c bind $item <Button-1> "$c itemconf text -anchor center"
8791 $c create text [expr {$x+45}] [expr {$y-5}] \
8892 -text {Text Position} -anchor s -font {Times 20} -fill brown
8993
11 #
22 # This demonstration script creates a dialog box with a local grab.
33
4 interp create slave
5 load {} Tk slave
6 slave eval {
7 wm title . slave
4 interp create child
5 load {} Tk child
6 child eval {
7 wm title . child
88 wm geometry . +700+30
99 pack [text .t -width 30 -height 10]
1010 }
1111
1212 after idle {.dialog1.msg configure -wraplength 4i}
13 set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \
13 set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "child" which was created by a child interpreter.} \
1414 info 0 OK Cancel {Show Code}]
1515
1616 switch $i {
1919 2 {showCode .dialog1}
2020 }
2121
22 if {[interp exists slave]} {
23 interp delete slave
22 if {[interp exists child]} {
23 interp delete child
2424 }
1515 wm iconname $w "entry1"
1616 positionWindow $w
1717
18 label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
18 label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse the middle mouse button pressed."
1919 pack $w.msg -side top
2020
2121 ## See Code / Dismiss buttons
1515 wm iconname $w "entry2"
1616 positionWindow $w
1717
18 label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with mouse button2 pressed."
18 label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed."
1919 pack $w.msg -side top
2020
2121 ## See Code / Dismiss buttons
101101
102102 proc validatePhoneChange {W vmode idx char} {
103103 global phoneNumberMap entry3content
104 if {$idx == -1} {return 1}
104 if {$idx < 0} {return 1}
105105 after idle [list $W configure -validate $vmode -invcmd bell]
106106 if {
107107 !($idx<3 || $idx==6 || $idx==7 || $idx==11 || $idx>15) &&
13531353
13541354 # Set up event bindings for canvas:
13551355
1356 $c bind floor1 <1> "floorDisplay $c 1"
1357 $c bind floor2 <1> "floorDisplay $c 2"
1358 $c bind floor3 <1> "floorDisplay $c 3"
1356 $c bind floor1 <Button-1> "floorDisplay $c 1"
1357 $c bind floor2 <Button-1> "floorDisplay $c 2"
1358 $c bind floor3 <Button-1> "floorDisplay $c 3"
13591359 $c bind room <Enter> "newRoom $c"
13601360 $c bind room <Leave> {set currentRoom ""}
1361 bind $c <2> "$c scan mark %x %y"
1362 bind $c <B2-Motion> "$c scan dragto %x %y"
1361 if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
1362 bind $c <Button-3> "$c scan mark %x %y"
1363 bind $c <B3-Motion> "$c scan dragto %x %y"
1364 } else {
1365 bind $c <Button-2> "$c scan mark %x %y"
1366 bind $c <B2-Motion> "$c scan dragto %x %y"
1367 }
13631368 bind $c <Destroy> "unset currentRoom"
13641369 set currentRoom ""
13651370 trace variable currentRoom w "roomChanged $c"
5454 grid $f.font - -sticky e
5555 grid columnconfigure $f 0 -weight 1
5656 grid rowconfigure $f 0 -weight 1
57 bind $w <Visibility> {
58 bind %W <Visibility> {}
59 grid propagate %W.f 0
60 }
6157
6258 ## See Code / Dismiss buttons
6359 set btns [addSeeDismiss $w.buttons $w]
6662 grid $btns -sticky ew
6763 grid columnconfigure $w 0 -weight 1
6864 grid rowconfigure $w 0 -weight 1
65 update idletasks
66 grid propagate $f 0
104104 $w.c yview moveto .05
105105 pack $w.c -in $w.screen -side top -fill both -expand 1
106106
107 bind $w.c <3> [list $w.pause invoke]
107 bind $w.c <Button-3> [list $w.pause invoke]
108108 bind $w.c <Destroy> {
109109 after cancel $animationCallbacks(goldberg)
110110 unset animationCallbacks(goldberg)
161161 grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5}
162162 pack $w.speed.scale -fill both -expand 1
163163 grid $w.about -in $w.ctrl -row 100 -sticky ew
164 bind $w.reset <3> {set S(mode) -1} ;# Debugging
164 bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging
165165
166166 ## See Code / Dismiss buttons hack!
167167 set btns [addSeeDismiss $w.ctrl.buttons $w]
341341 set xy {719 119 763 119}
342342 $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \
343343 -arrowshape {18 18 5}
344 $w.c bind I0 <1> Start
344 $w.c bind I0 <Button-1> Start
345345 }
346346 proc Move0 {w {step {}}} {
347347 set step [GetStep 0 $step]
371371
372372 set xy [box 812 122 9]
373373 $w.c create oval $xy -tag I1 -fill $color2 -outline {}
374 $w.c bind I1 <1> Start
374 $w.c bind I1 <Button-1> Start
375375 }
376376 proc Move1 {w {step {}}} {
377377 set step [GetStep 1 $step]
16191619 $w.c delete I24 I26
16201620 $w.c create text 430 755 -anchor s -tag I26 \
16211621 -text "click to continue" -font {{Times Roman} 24 bold}
1622 bind $w.c <1> [list Reset $w]
1622 bind $w.c <Button-1> [list Reset $w]
16231623 return 4
16241624 }
16251625
16741674 proc Reset {w} {
16751675 global S
16761676 DrawAll $w
1677 bind $w.c <1> {}
1677 bind $w.c <Button-1> {}
16781678 set S(mode) $::MSTART
16791679 set S(active) 0
16801680 }
9494 ttk::scrollbar $w.f.scroll -command "$w.f.list yview"
9595 pack $w.f.list $w.f.scroll -side left -fill y -expand 1
9696 $w.f.list insert 0 earth.gif earthris.gif teapot.ppm
97 bind $w.f.list <Double-1> "loadImage $w %x %y"
97 bind $w.f.list <Double-Button-1> "loadImage $w %x %y"
9898
9999 catch {image delete image2a}
100100 image create photo image2a
1616 positionWindow $w
1717 set c $w.frame.c
1818
19 label $w.msg -font $font -wraplength 5i -justify left -text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Button-1 drag:\tmoves item under pointer.\n Button-2 drag:\trepositions view.\n Button-3 drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
19 label $w.msg -font $font -wraplength 5i -justify left -text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Left-Button drag:\tmoves item under pointer.\n Middle-Button drag:\trepositions view.\n Right-Button drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
2020 pack $w.msg -side top
2121
2222 ## See Code / Dismiss buttons
170170
171171 # Set up event bindings for canvas:
172172
173 $c bind item <Any-Enter> "itemEnter $c"
174 $c bind item <Any-Leave> "itemLeave $c"
175 bind $c <2> "$c scan mark %x %y"
176 bind $c <B2-Motion> "$c scan dragto %x %y"
177 bind $c <3> "itemMark $c %x %y"
178 bind $c <B3-Motion> "itemStroke $c %x %y"
173 $c bind item <Enter> "itemEnter $c"
174 $c bind item <Leave> "itemLeave $c"
175 if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
176 bind $c <Button-2> "itemMark $c %x %y"
177 bind $c <B2-Motion> "itemStroke $c %x %y"
178 bind $c <Button-3> "$c scan mark %x %y"
179 bind $c <B3-Motion> "$c scan dragto %x %y"
180 } else {
181 bind $c <Button-2> "$c scan mark %x %y"
182 bind $c <B2-Motion> "$c scan dragto %x %y"
183 bind $c <Button-3> "itemMark $c %x %y"
184 bind $c <B3-Motion> "itemStroke $c %x %y"
185 }
179186 bind $c <<NextChar>> "itemsUnderArea $c"
180 bind $c <1> "itemStartDrag $c %x %y"
187 bind $c <Button-1> "itemStartDrag $c %x %y"
181188 bind $c <B1-Motion> "itemDrag $c %x %y"
182189
183190 # Utility procedures for highlighting the item under the pointer:
249256 set area [$c find withtag area]
250257 set items ""
251258 foreach i [$c find enclosed $areaX1 $areaY1 $areaX2 $areaY2] {
252 if {[lsearch [$c gettags $i] item] != -1} {
259 if {[lsearch [$c gettags $i] item] >= 0} {
253260 lappend items $i
254261 }
255262 }
256263 puts stdout "Items enclosed by area: $items"
257264 set items ""
258265 foreach i [$c find overlapping $areaX1 $areaY1 $areaX2 $areaY2] {
259 if {[lsearch [$c gettags $i] item] != -1} {
266 if {[lsearch [$c gettags $i] item] >= 0} {
260267 lappend items $i
261268 }
262269 }
5353 global screencyc ; set screencyc 600
5454
5555 set xfd [open "|xset q" r]
56 while {[gets $xfd line] > -1} {
56 while {[gets $xfd line] >= 0} {
5757 switch -- [lindex $line 0] {
5858 auto {
5959 set rpt [lindex $line 1]
196196
197197 bind . <Return> {.buttons.ok flash; .buttons.ok invoke}
198198 bind . <Escape> {.buttons.quit flash; .buttons.quit invoke}
199 bind . <1> {
199 bind . <Button-1> {
200200 if {![string match .buttons* %W]} {
201201 .buttons.apply configure -state normal
202202 .buttons.cancel configure -state normal
2020 # If you let it repeat then it will choose random start positions
2121 # for each new tour.
2222
23 package require Tk 8.5
23 package require Tk
2424
2525 # Return a list of accessible squares from a given square
2626 proc ValidMoves {square} {
2828 foreach pair {{-1 -2} {-2 -1} {-2 1} {-1 2} {1 2} {2 1} {2 -1} {1 -2}} {
2929 set col [expr {($square % 8) + [lindex $pair 0]}]
3030 set row [expr {($square / 8) + [lindex $pair 1]}]
31 if {$row > -1 && $row < 8 && $col > -1 && $col < 8} {
31 if {$row >= 0 && $row < 8 && $col >= 0 && $col < 8} {
3232 lappend moves [expr {$row * 8 + $col}]
3333 }
3434 }
4040 variable visited
4141 set moves 0
4242 foreach test [ValidMoves $square] {
43 if {[lsearch -exact -integer $visited $test] == -1} {
43 if {[lsearch -exact -integer $visited $test] < 0} {
4444 incr moves
4545 }
4646 }
5454 set minimum 9
5555 set nextSquare -1
5656 foreach testSquare [ValidMoves $square] {
57 if {[lsearch -exact -integer $visited $testSquare] == -1} {
57 if {[lsearch -exact -integer $visited $testSquare] < 0} {
5858 set count [CheckSquare $testSquare]
5959 if {$count < $minimum} {
6060 set minimum $count
189189 ttk::button $dlg.tf.b1 -text Start -command [list Tour $dlg]
190190 ttk::button $dlg.tf.b2 -text Exit -command [list Exit $dlg]
191191 set square 0
192 for {set row 7} {$row != -1} {incr row -1} {
192 for {set row 7} {$row >= 0} {incr row -1} {
193193 for {set col 0} {$col < 8} {incr col} {
194194 if {(($col & 1) ^ ($row & 1))} {
195195 set fill tan3 ; set dfill tan4
217217 -fill black -activefill "#600000"
218218 }
219219 $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1]
220 $c bind knight <ButtonPress-1> [namespace code [list DragStart %W %x %y]]
220 $c bind knight <Button-1> [namespace code [list DragStart %W %x %y]]
221221 $c bind knight <Motion> [namespace code [list DragMotion %W %x %y]]
222222 $c bind knight <ButtonRelease-1> [namespace code [list DragEnd %W %x %y]]
223223
6262 }
6363 foreach i {A B C D E F} {
6464 $m add command -label "Print letter \"$i\"" -underline 14 \
65 -accelerator Meta+$i -command "puts $i" -accelerator $modifier+$i
65 -accelerator $modifier+$i -command "puts $i"
6666 bind $w <$modifier-[string tolower $i]> "puts $i"
6767 }
6868
143143 set m $w.menu.colors
144144 $w.menu add cascade -label "Colors" -menu $m -underline 1
145145 menu $m -tearoff 1
146 foreach i {red orange yellow green blue} {
147 $m add command -label $i -background $i -command [list \
148 puts "You invoked \"$i\"" ]
146 if {[tk windowingsystem] eq "aqua"} {
147 # Aqua ignores the -background and -foreground options, but a compound
148 # button can be used for selecting colors.
149 foreach i {red orange yellow green blue} {
150 image create photo image_$i -height 16 -width 16
151 image_$i put black -to 0 0 16 1
152 image_$i put black -to 0 1 1 16
153 image_$i put black -to 0 15 16 16
154 image_$i put black -to 15 1 16 16
155 image_$i put $i -to 1 1 15 15
156 $m add command -label $i -image image_$i -compound left -command [list \
157 puts "You invoked \"$i\"" ]
158 }
159 } else {
160 foreach i {red orange yellow green blue} {
161 $m add command -label $i -background $i -command [list \
162 puts "You invoked \"$i\"" ]
163 }
149164 }
150165
151166 $w configure -menu $w.menu
112112 after cancel $animationCallbacks(pendulum)
113113 unset animationCallbacks(pendulum)
114114 }
115 bind $w.c <1> {
115 bind $w.c <Button-1> {
116116 after cancel $animationCallbacks(pendulum)
117117 showPendulum %W at %x %y
118118 }
5454 $c addtag point withtag $item
5555 }
5656
57 $c bind point <Any-Enter> "$c itemconfig current -fill red"
58 $c bind point <Any-Leave> "$c itemconfig current -fill SkyBlue2"
59 $c bind point <1> "plotDown $c %x %y"
57 $c bind point <Enter> "$c itemconfig current -fill red"
58 $c bind point <Leave> "$c itemconfig current -fill SkyBlue2"
59 $c bind point <Button-1> "plotDown $c %x %y"
6060 $c bind point <ButtonRelease-1> "$c dtag selected"
6161 bind $c <B1-Motion> "plotMove $c %x %y"
6262
7676 $c addtag well withtag [rulerMkTab $c [winfo pixels $c 13.5c] \
7777 [winfo pixels $c .65c]]
7878
79 $c bind well <1> "rulerNewTab $c %x %y"
80 $c bind tab <1> "rulerSelectTab $c %x %y"
79 $c bind well <Button-1> "rulerNewTab $c %x %y"
80 $c bind tab <Button-1> "rulerSelectTab $c %x %y"
8181 bind $c <B1-Motion> "rulerMoveTab $c %x %y"
82 bind $c <Any-ButtonRelease-1> "rulerReleaseTab $c"
82 bind $c <ButtonRelease-1> "rulerReleaseTab $c"
8383
8484 # rulerNewTab --
8585 # Does all the work of creating a tab stop, including creating the
1717 pack .s -expand yes -fill both
1818 wm minsize . 1 1
1919
20 bind .s <1> {center %x %y}
20 bind .s <Button-1> {center %x %y}
2121 bind .s <B1-Motion> {center %x %y}
2222 bind .s a animate
2323 focus .s
55 # element name is the name of a command and the value is
66 # a script that loads the command.
77
8 set auto_index(arrowSetup) [list source [file join $dir arrow.tcl]]
9 set auto_index(arrowMove1) [list source [file join $dir arrow.tcl]]
10 set auto_index(arrowMove2) [list source [file join $dir arrow.tcl]]
11 set auto_index(arrowMove3) [list source [file join $dir arrow.tcl]]
12 set auto_index(textLoadFile) [list source [file join $dir search.tcl]]
13 set auto_index(textSearch) [list source [file join $dir search.tcl]]
14 set auto_index(textToggle) [list source [file join $dir search.tcl]]
15 set auto_index(itemEnter) [list source [file join $dir items.tcl]]
16 set auto_index(itemLeave) [list source [file join $dir items.tcl]]
17 set auto_index(itemMark) [list source [file join $dir items.tcl]]
18 set auto_index(itemStroke) [list source [file join $dir items.tcl]]
19 set auto_index(itemsUnderArea) [list source [file join $dir items.tcl]]
20 set auto_index(itemStartDrag) [list source [file join $dir items.tcl]]
21 set auto_index(itemDrag) [list source [file join $dir items.tcl]]
22 set auto_index(butPress) [list source [file join $dir items.tcl]]
23 set auto_index(loadDir) [list source [file join $dir image2.tcl]]
24 set auto_index(loadImage) [list source [file join $dir image2.tcl]]
25 set auto_index(rulerMkTab) [list source [file join $dir ruler.tcl]]
26 set auto_index(rulerNewTab) [list source [file join $dir ruler.tcl]]
27 set auto_index(rulerSelectTab) [list source [file join $dir ruler.tcl]]
28 set auto_index(rulerMoveTab) [list source [file join $dir ruler.tcl]]
29 set auto_index(rulerReleaseTab) [list source [file join $dir ruler.tcl]]
30 set auto_index(mkTextConfig) [list source [file join $dir ctext.tcl]]
31 set auto_index(textEnter) [list source [file join $dir ctext.tcl]]
32 set auto_index(textInsert) [list source [file join $dir ctext.tcl]]
33 set auto_index(textPaste) [list source [file join $dir ctext.tcl]]
34 set auto_index(textB1Press) [list source [file join $dir ctext.tcl]]
35 set auto_index(textB1Move) [list source [file join $dir ctext.tcl]]
36 set auto_index(textBs) [list source [file join $dir ctext.tcl]]
37 set auto_index(textDel) [list source [file join $dir ctext.tcl]]
38 set auto_index(bitmapRow) [list source [file join $dir bitmap.tcl]]
39 set auto_index(scrollEnter) [list source [file join $dir cscroll.tcl]]
40 set auto_index(scrollLeave) [list source [file join $dir cscroll.tcl]]
41 set auto_index(scrollButton) [list source [file join $dir cscroll.tcl]]
42 set auto_index(textWindOn) [list source [file join $dir twind.tcl]]
43 set auto_index(textWindOff) [list source [file join $dir twind.tcl]]
44 set auto_index(textWindPlot) [list source [file join $dir twind.tcl]]
45 set auto_index(embPlotDown) [list source [file join $dir twind.tcl]]
46 set auto_index(embPlotMove) [list source [file join $dir twind.tcl]]
47 set auto_index(textWindDel) [list source [file join $dir twind.tcl]]
48 set auto_index(embDefBg) [list source [file join $dir twind.tcl]]
49 set auto_index(floorDisplay) [list source [file join $dir floor.tcl]]
50 set auto_index(newRoom) [list source [file join $dir floor.tcl]]
51 set auto_index(roomChanged) [list source [file join $dir floor.tcl]]
52 set auto_index(bg1) [list source [file join $dir floor.tcl]]
53 set auto_index(bg2) [list source [file join $dir floor.tcl]]
54 set auto_index(bg3) [list source [file join $dir floor.tcl]]
55 set auto_index(fg1) [list source [file join $dir floor.tcl]]
56 set auto_index(fg2) [list source [file join $dir floor.tcl]]
57 set auto_index(fg3) [list source [file join $dir floor.tcl]]
58 set auto_index(setWidth) [list source [file join $dir hscale.tcl]]
59 set auto_index(plotDown) [list source [file join $dir plot.tcl]]
60 set auto_index(plotMove) [list source [file join $dir plot.tcl]]
61 set auto_index(puzzleSwitch) [list source [file join $dir puzzle.tcl]]
62 set auto_index(setHeight) [list source [file join $dir vscale.tcl]]
63 set auto_index(showMessageBox) [list source [file join $dir msgbox.tcl]]
64 set auto_index(setColor) [list source [file join $dir clrpick.tcl]]
65 set auto_index(setColor_helper) [list source [file join $dir clrpick.tcl]]
66 set auto_index(fileDialog) [list source [file join $dir filebox.tcl]]
8 set auto_index(arrowSetup) [list source -encoding utf-8 [file join $dir arrow.tcl]]
9 set auto_index(arrowMove1) [list source -encoding utf-8 [file join $dir arrow.tcl]]
10 set auto_index(arrowMove2) [list source -encoding utf-8 [file join $dir arrow.tcl]]
11 set auto_index(arrowMove3) [list source -encoding utf-8 [file join $dir arrow.tcl]]
12 set auto_index(textLoadFile) [list source -encoding utf-8 [file join $dir search.tcl]]
13 set auto_index(textSearch) [list source -encoding utf-8 [file join $dir search.tcl]]
14 set auto_index(textToggle) [list source -encoding utf-8 [file join $dir search.tcl]]
15 set auto_index(itemEnter) [list source -encoding utf-8 [file join $dir items.tcl]]
16 set auto_index(itemLeave) [list source -encoding utf-8 [file join $dir items.tcl]]
17 set auto_index(itemMark) [list source -encoding utf-8 [file join $dir items.tcl]]
18 set auto_index(itemStroke) [list source -encoding utf-8 [file join $dir items.tcl]]
19 set auto_index(itemsUnderArea) [list source -encoding utf-8 [file join $dir items.tcl]]
20 set auto_index(itemStartDrag) [list source -encoding utf-8 [file join $dir items.tcl]]
21 set auto_index(itemDrag) [list source -encoding utf-8 [file join $dir items.tcl]]
22 set auto_index(butPress) [list source -encoding utf-8 [file join $dir items.tcl]]
23 set auto_index(loadDir) [list source -encoding utf-8 [file join $dir image2.tcl]]
24 set auto_index(loadImage) [list source -encoding utf-8 [file join $dir image2.tcl]]
25 set auto_index(rulerMkTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
26 set auto_index(rulerNewTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
27 set auto_index(rulerSelectTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
28 set auto_index(rulerMoveTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
29 set auto_index(rulerReleaseTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
30 set auto_index(mkTextConfig) [list source -encoding utf-8 [file join $dir ctext.tcl]]
31 set auto_index(textEnter) [list source -encoding utf-8 [file join $dir ctext.tcl]]
32 set auto_index(textInsert) [list source -encoding utf-8 [file join $dir ctext.tcl]]
33 set auto_index(textPaste) [list source -encoding utf-8 [file join $dir ctext.tcl]]
34 set auto_index(textB1Press) [list source -encoding utf-8 [file join $dir ctext.tcl]]
35 set auto_index(textB1Move) [list source -encoding utf-8 [file join $dir ctext.tcl]]
36 set auto_index(textBs) [list source -encoding utf-8 [file join $dir ctext.tcl]]
37 set auto_index(textDel) [list source -encoding utf-8 [file join $dir ctext.tcl]]
38 set auto_index(bitmapRow) [list source -encoding utf-8 [file join $dir bitmap.tcl]]
39 set auto_index(scrollEnter) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
40 set auto_index(scrollLeave) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
41 set auto_index(scrollButton) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
42 set auto_index(textWindOn) [list source -encoding utf-8 [file join $dir twind.tcl]]
43 set auto_index(textWindOff) [list source -encoding utf-8 [file join $dir twind.tcl]]
44 set auto_index(textWindPlot) [list source -encoding utf-8 [file join $dir twind.tcl]]
45 set auto_index(embPlotDown) [list source -encoding utf-8 [file join $dir twind.tcl]]
46 set auto_index(embPlotMove) [list source -encoding utf-8 [file join $dir twind.tcl]]
47 set auto_index(textWindDel) [list source -encoding utf-8 [file join $dir twind.tcl]]
48 set auto_index(embDefBg) [list source -encoding utf-8 [file join $dir twind.tcl]]
49 set auto_index(floorDisplay) [list source -encoding utf-8 [file join $dir floor.tcl]]
50 set auto_index(newRoom) [list source -encoding utf-8 [file join $dir floor.tcl]]
51 set auto_index(roomChanged) [list source -encoding utf-8 [file join $dir floor.tcl]]
52 set auto_index(bg1) [list source -encoding utf-8 [file join $dir floor.tcl]]
53 set auto_index(bg2) [list source -encoding utf-8 [file join $dir floor.tcl]]
54 set auto_index(bg3) [list source -encoding utf-8 [file join $dir floor.tcl]]
55 set auto_index(fg1) [list source -encoding utf-8 [file join $dir floor.tcl]]
56 set auto_index(fg2) [list source -encoding utf-8 [file join $dir floor.tcl]]
57 set auto_index(fg3) [list source -encoding utf-8 [file join $dir floor.tcl]]
58 set auto_index(setWidth) [list source -encoding utf-8 [file join $dir hscale.tcl]]
59 set auto_index(plotDown) [list source -encoding utf-8 [file join $dir plot.tcl]]
60 set auto_index(plotMove) [list source -encoding utf-8 [file join $dir plot.tcl]]
61 set auto_index(puzzleSwitch) [list source -encoding utf-8 [file join $dir puzzle.tcl]]
62 set auto_index(setHeight) [list source -encoding utf-8 [file join $dir vscale.tcl]]
63 set auto_index(showMessageBox) [list source -encoding utf-8 [file join $dir msgbox.tcl]]
64 set auto_index(setColor) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
65 set auto_index(setColor_helper) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
66 set auto_index(fileDialog) [list source -encoding utf-8 [file join $dir filebox.tcl]]
66 # create colors using either the RGB, HSB, or CYM color spaces
77 # and apply the color to existing applications.
88
9 package require Tk 8.4
9 package require Tk
1010 wm title . "Color Editor"
1111
1212 # Global variables that control the program:
8989 grid columnconfigure . 0 -weight 1
9090 listbox .names.lb -width 20 -height 12 -yscrollcommand ".names.s set" \
9191 -exportselection false
92 bind .names.lb <Double-1> {
92 bind .names.lb <Double-Button-1> {
9393 tc_loadNamedColor [.names.lb get [.names.lb curselection]]
9494 }
9595 scrollbar .names.s -orient vertical -command ".names.lb yview"
5656
5757 1. Scrolling. Use the scrollbar to adjust the view in the text window.
5858
59 2. Scanning. Press mouse button 2 in the text window and drag up or down.
60 This will drag the text at high speed to allow you to scan its contents.
59 2. Scanning. Press the middle mouse button in the text window and drag up
60 or down. This will drag the text at high speed to allow you to scan its
61 contents.
6162
6263 3. Insert text. Press mouse button 1 to set the insertion cursor, then
6364 type text. What you type will be added to the widget.
7677
7778 6. Copy the selection. To copy the selection into this window, select
7879 what you want to copy (either here or in another application), then
79 click button 2 to copy the selection to the point of the mouse cursor.
80 click the middle mouse button to copy the selection to the point of the
81 mouse cursor.
8082
8183 7. Edit. Text widgets support the standard Motif editing characters
8284 plus many Emacs editing characters. Backspace and Control-h erase the
3838 set path [$tree set $node fullpath]
3939 $tree delete [$tree children $node]
4040 foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] {
41 set f [file normalize $f]
4142 set type [file type $f]
4243 set id [$tree insert $node end -text [file tail $f] \
4344 -values [list $f $type]]
264264 $c addtag point withtag $item
265265 }
266266
267 $c bind point <Any-Enter> "$c itemconfig current -fill red"
268 $c bind point <Any-Leave> "$c itemconfig current -fill SkyBlue2"
269 $c bind point <1> "embPlotDown $c %x %y"
267 $c bind point <Enter> "$c itemconfig current -fill red"
268 $c bind point <Leave> "$c itemconfig current -fill SkyBlue2"
269 $c bind point <Button-1> "embPlotDown $c %x %y"
270270 $c bind point <ButtonRelease-1> "$c dtag selected"
271271 bind $c <B1-Motion> "embPlotMove $c %x %y"
272272 return $c
108108 }
109109 addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57"
110110 addSample $w "Simpl. Chinese" "\u6C49\u8BED"
111 addSample $w French "Langue fran\u00E7aise"
111 addSample $w French "Langue fran\xE7aise"
112112 addSample $w Greek \
113 "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
114 "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
113 "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
114 "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
115115 if {[usePresentationFormsFor Hebrew]} {
116116 # Visual order (pre-layouted)
117117 addSample $w Hebrew \
122122 "\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA"
123123 }
124124 addSample $w Hindi \
125 "\u0939\u093f\u0928\u094d\u0926\u0940 \u092d\u093e\u0937\u093e"
126 addSample $w Icelandic "\u00CDslenska"
125 "\u0939\u093F\u0928\u094D\u0926\u0940 \u092D\u093E\u0937\u093E"
126 addSample $w Icelandic "\xCDslenska"
127127 addSample $w Japanese \
128 "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
129 "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
128 "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
129 "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
130130 addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00"
131131 addSample $w Russian \
132132 "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A"
133 if {[tk windowingsystem] ne "x11"} {
134 addSample $w Emoji \
135 "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1"
133 if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} {
134 if {[package vsatisfies [package provide Tcl] 8.7-]} {
135 addSample $w Emoji "😀💩👍🇳🇱"
136 } else {
137 addSample $w Emoji \
138 "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1"
139 }
136140 }
137141
138142 ## We're done processing, so change things back to normal running...
8282
8383 # Note that this is run through the message catalog! This is because this is
8484 # actually an image of a word.
85 image create photo ::img::new -format GIF -data [mc {
86 R0lGODlhHgAOALMPALMAANyIiOu7u8dEROaqqvru7sxVVeGZmbgREfXd3b0iItZ3
87 d8IzM9FmZvDMzP///yH5BAEAAA8ALAAAAAAeAA4AAASa8MlJq7046827WVOCHEkw
88 nANhUgJlEBIABJIwL3K+4IcUALCHjfbItYZDSgJgkBiYPmBMAUAkkLPKs/BAyLgM
89 wAQwOAAY2ByCaw4QAFQSoDEePJ6DmU1xInYZTw5nOEFFdgVUelkVDTIMd3AKFGQ1
90 MgI2AwEmQW8APZ0gdRONAks5nhIFVVxdAAkUAS2pAVwFl7ITB4UqHb0XEQA7
85 image create photo ::img::new -format PNG -data [mc {
86 iVBORw0KGgoAAAANSUhEUgAAAB4AAAAOCAYAAAA45qw5AAACMElEQVR4AeVTAwxd
87 QRCc2tZHGtQ2w9q2bdsOa9u2bUW1bdt2Z372JZe6DapJLqtb3h7+T8yKi5j4CsYD
88 EUQXxETclT7kWOlH2VV+tFkdQHPSwksSISF+BauCqL0qgOcMWgGfgEkaMsHxqUBk
89 3plE/sOnh/qDPAPJH/CKFBivGHWzFwBRnHhlqbu1Mh6CoFNnC/JshQ9p4YC2lrKt
90 DCAV+THiVejyhMjAbrNSrroiEfKR9g7ZfCgOog8QfnUQV62wAk68ndQ9ZbyoWO1H
91 Y6eDY1LCQL6a9ApOp9Hi1T0+gQq2JKMlky/oTKQliKWxEZvyG575kpW4pl1aZnQK
92 CLOVt45Lkp8uXp2SL8KO6uitNTZLdpK6s+I/eZbhpmsmWeOGOVQNKYLITzpKPAO3
93 tY7LSNZ7ccSLxX9y3uuOxRkg3dKESMoCHvL+GRVCutXsB3guLgDCeXOv4iWWkvwG
94 BaS+PmlpK6SI9ApI2oC2UtrwZQEkhkH+NtolVlQXJl1I+QltuU3XEc721bIRFpa8
95 IA5iqTo6vNNWmkNBLQbPeXwF2g17Q94nTQAfY3YzeY+WSu8MDzQ2kpELUhSGJUHE
96 0zeR3rY1L+Xl5G/re+jbiK6KhThwwInsts1fbMUUcpZszKeVtggZEiGdZDe5AtHh
97 7vL4CGiRvvKPS8FAvq9Nr4ZkFadR2y6kggu1z4vlyIbBp6BugQ8JLEg4bTkD9eMZ
98 QZ8hpJ3VvTtuvbWrY/ElvP/9R+Aj3603+iE3fkEAAAAASUVORK5CYII=
9199 }]
92100
93101 #----------------------------------------------------------------
185193 -foreground blue -underline 1
186194 .t tag configure visited -lmargin1 1c -lmargin2 1c \
187195 -foreground #303080 -underline 1
196 if {[tk windowingsystem] eq "aqua"} {
197 .t tag configure demo -foreground systemLinkColor
198 .t tag configure visited -foreground purple
199 }
188200 .t tag configure hot -foreground red -underline 1
189201 }
190202 .t tag bind demo <ButtonRelease-1> {
503515 .t configure -cursor [::ttk::cursor busy]
504516 update
505517 set demo [string range [lindex $tags $i] 5 end]
506 uplevel 1 [list source [file join $tk_demoDirectory $demo.tcl]]
518 uplevel 1 [list source -encoding utf-8 [file join $tk_demoDirectory $demo.tcl]]
507519 update
508520 .t configure -cursor $cursor
509521
611623 wm title $top [mc "Demo code: %s" [file join $tk_demoDirectory $file]]
612624 wm iconname $top $file
613625 set id [open [file join $tk_demoDirectory $file]]
626 fconfigure $id -encoding utf-8 -eofchar \032
614627 $top.f.text delete 1.0 end
615628 $top.f.text insert 1.0 [read $id]
616629 $top.f.text mark set insert 1.0
709722 proc tkAboutDialog {} {
710723 tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \
711724 -message [mc "Tk widget demonstration application"] -detail \
712 "[mc "Copyright \u00a9 %s" {1996-1997 Sun Microsystems, Inc.}]
713 [mc "Copyright \u00a9 %s" {1997-2000 Ajuba Solutions, Inc.}]
714 [mc "Copyright \u00a9 %s" {2001-2009 Donal K. Fellows}]
715 [mc "Copyright \u00a9 %s" {2002-2007 Daniel A. Steffen}]"
725 "[mc "Copyright \xA9 %s" {1996-1997 Sun Microsystems, Inc.}]
726 [mc "Copyright \xA9 %s" {1997-2000 Ajuba Solutions, Inc.}]
727 [mc "Copyright \xA9 %s" {2001-2009 Donal K. Fellows}]
728 [mc "Copyright \xA9 %s" {2002-2007 Daniel A. Steffen}]"
716729 }
717730
718731 # Local Variables:
5757 }
5858 bind Entry <<Clear>> {
5959 # ignore if there is no selection
60 catch { %W delete sel.first sel.last }
60 catch {%W delete sel.first sel.last}
6161 }
6262 bind Entry <<PasteSelection>> {
6363 if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
7373
7474 # Standard Motif bindings:
7575
76 bind Entry <1> {
76 bind Entry <Button-1> {
7777 tk::EntryButton1 %W %x
7878 %W selection clear
7979 }
8181 set tk::Priv(x) %x
8282 tk::EntryMouseSelect %W %x
8383 }
84 bind Entry <Double-1> {
84 bind Entry <Double-Button-1> {
8585 set tk::Priv(selectMode) word
8686 tk::EntryMouseSelect %W %x
8787 catch {%W icursor sel.last}
8888 }
89 bind Entry <Triple-1> {
89 bind Entry <Triple-Button-1> {
9090 set tk::Priv(selectMode) line
9191 tk::EntryMouseSelect %W %x
9292 catch {%W icursor sel.last}
9393 }
94 bind Entry <Shift-1> {
94 bind Entry <Shift-Button-1> {
9595 set tk::Priv(selectMode) char
9696 %W selection adjust @%x
9797 }
98 bind Entry <Double-Shift-1> {
98 bind Entry <Double-Shift-Button-1> {
9999 set tk::Priv(selectMode) word
100100 tk::EntryMouseSelect %W %x
101101 }
102 bind Entry <Triple-Shift-1> {
102 bind Entry <Triple-Shift-Button-1> {
103103 set tk::Priv(selectMode) line
104104 tk::EntryMouseSelect %W %x
105105 }
113113 bind Entry <ButtonRelease-1> {
114114 tk::CancelRepeat
115115 }
116 bind Entry <Control-1> {
116 bind Entry <Control-Button-1> {
117117 %W icursor @%x
118118 }
119119
120120 bind Entry <<PrevChar>> {
121 tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
121 tk::EntrySetCursor %W [expr {[%W index insert]-1}]
122122 }
123123 bind Entry <<NextChar>> {
124 tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
124 tk::EntrySetCursor %W [expr {[%W index insert]+1}]
125125 }
126126 bind Entry <<SelectPrevChar>> {
127 tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
127 tk::EntryKeySelect %W [expr {[%W index insert]-1}]
128128 tk::EntrySeeInsert %W
129129 }
130130 bind Entry <<SelectNextChar>> {
131 tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
131 tk::EntryKeySelect %W [expr {[%W index insert]+1}]
132132 tk::EntrySeeInsert %W
133133 }
134134 bind Entry <<PrevWord>> {
189189 bind Entry <<SelectNone>> {
190190 %W selection clear
191191 }
192 bind Entry <KeyPress> {
192 bind Entry <Key> {
193193 tk::CancelRepeat
194194 tk::EntryInsert %W %A
195195 }
196196
197197 # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
198198 # Otherwise, if a widget binding for one of these is defined, the
199 # <KeyPress> class binding will also fire and insert the character,
199 # <Key> class binding will also fire and insert the character,
200200 # which is wrong. Ditto for Escape, Return, and Tab.
201201
202 bind Entry <Alt-KeyPress> {# nothing}
203 bind Entry <Meta-KeyPress> {# nothing}
204 bind Entry <Control-KeyPress> {# nothing}
202 bind Entry <Alt-Key> {# nothing}
203 bind Entry <Meta-Key> {# nothing}
204 bind Entry <Control-Key> {# nothing}
205205 bind Entry <Escape> {# nothing}
206206 bind Entry <Return> {# nothing}
207207 bind Entry <KP_Enter> {# nothing}
209209 bind Entry <Prior> {# nothing}
210210 bind Entry <Next> {# nothing}
211211 if {[tk windowingsystem] eq "aqua"} {
212 bind Entry <Command-KeyPress> {# nothing}
212 bind Entry <Command-Key> {# nothing}
213213 }
214214 # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
215215 bind Entry <<NextLine>> {# nothing}
277277 dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
278278 }
279279 bind Entry <<TkEndIMEMarkedText>> {
280 if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
280 if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} {
281281 bell
282282 } else {
283283 %W selection range $mark insert
292292
293293 # A few additional bindings of my own.
294294
295 bind Entry <2> {
296 if {!$tk_strictMotif} {
297 ::tk::EntryScanMark %W %x
298 }
299 }
300 bind Entry <B2-Motion> {
301 if {!$tk_strictMotif} {
302 ::tk::EntryScanDrag %W %x
295 if {[tk windowingsystem] ne "aqua"} {
296 bind Entry <Button-2> {
297 if {!$tk_strictMotif} {
298 ::tk::EntryScanMark %W %x
299 }
300 }
301 bind Entry <B2-Motion> {
302 if {!$tk_strictMotif} {
303 ::tk::EntryScanDrag %W %x
304 }
305 }
306 } else {
307 bind Entry <Button-3> {
308 if {!$tk_strictMotif} {
309 ::tk::EntryScanMark %W %x
310 }
311 }
312 bind Entry <B3-Motion> {
313 if {!$tk_strictMotif} {
314 ::tk::EntryScanDrag %W %x
315 }
303316 }
304317 }
305318
377390 word {
378391 if {$cur < $anchor} {
379392 set before [tcl_wordBreakBefore [$w get] $cur]
380 set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]]
393 set after [tcl_wordBreakAfter [$w get] $anchor-1]
381394 } elseif {$cur > $anchor} {
382395 set before [tcl_wordBreakBefore [$w get] $anchor]
383 set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]]
396 set after [tcl_wordBreakAfter [$w get] $cur-1]
384397 } else {
385398 if {[$w index @$Priv(pressX)] < $anchor} {
386399 incr anchor -1
504517 if {[$w selection present]} {
505518 $w delete sel.first sel.last
506519 } else {
507 set x [expr {[$w index insert] - 1}]
508 if {$x >= 0} {
509 $w delete $x
520 set x [$w index insert]
521 if {$x > 0} {
522 $w delete [expr {$x-1}]
510523 }
511524 if {[$w index @0] >= [$w index insert]} {
512525 set range [$w xview]
561574 if {$i < [$w index end]} {
562575 incr i
563576 }
577 if {$i < 2} {
578 return
579 }
564580 set first [expr {$i-2}]
565 if {$first < 0} {
566 return
567 }
568581 set data [$w get]
569 set new [string index $data [expr {$i-1}]][string index $data $first]
582 set new [string index $data $i-1][string index $data $first]
570583 $w delete $first $i
571584 $w insert insert $new
572585 EntrySeeInsert $w
646659 proc ::tk::EntryScanDrag {w x} {
647660 # Make sure these exist, as some weird situations can trigger the
648661 # motion binding without the initial press. [Bug #220269]
649 if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x }
662 if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x}
650663 # allow for a delta
651664 if {abs($x-$::tk::Priv(x)) > 2} {
652665 set ::tk::Priv(mouseMoved) 1
663676
664677 proc ::tk::EntryGetSelection {w} {
665678 set entryString [string range [$w get] [$w index sel.first] \
666 [expr {[$w index sel.last] - 1}]]
679 [$w index sel.last]-1]
667680 if {[$w cget -show] ne ""} {
668681 return [string repeat [string index [$w cget -show] 0] \
669682 [string length $entryString]]
670683 }
671684 return $entryString
672685 }
673
674
675
676
677
678
679
680
681
1313 set S(W) .__tk__fontchooser
1414 set S(fonts) [lsort -dictionary [font families]]
1515 set S(styles) [list \
16 [::msgcat::mc "Regular"] \
17 [::msgcat::mc "Italic"] \
18 [::msgcat::mc "Bold"] \
19 [::msgcat::mc "Bold Italic"] \
20 ]
16 [::msgcat::mc "Regular"] \
17 [::msgcat::mc "Italic"] \
18 [::msgcat::mc "Bold"] \
19 [::msgcat::mc "Bold Italic"] \
20 ]
2121
2222 set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72}
2323 set S(strike) 0
3535
3636 # Canonical versions of font families, styles, etc. for easier searching
3737 set S(fonts,lcase) {}
38 foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]}
38 foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]}
3939 set S(styles,lcase) {}
40 foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style]}
40 foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]}
4141 set S(sizes,lcase) $S(sizes)
4242
4343 ::ttk::style layout FontchooserFrame {
110110
111111 set cache [dict create -parent $S(-parent) -title $S(-title) \
112112 -font $S(-font) -command $S(-command)]
113 set r [tclParseConfigSpec [namespace which -variable S] $specs "" $args]
113 set r [tclParseConfigSpec [namespace which -variable S] $specs DONTSETDEFAULTS $args]
114114 if {![winfo exists $S(-parent)]} {
115115 set code [list TK LOOKUP WINDOW $S(-parent)]
116116 set err "bad window path name \"$S(-parent)\""
120120 if {[string trim $S(-title)] eq ""} {
121121 set S(-title) [::msgcat::mc "Font"]
122122 }
123 if {[winfo exists $S(W)] && [lsearch $args -font] != -1} {
123 if {[winfo exists $S(W)] && ("-font" in $args)} {
124124 Init $S(-font)
125125 event generate $S(-parent) <<TkFontchooserFontChanged>>
126126 }
144144 wm title $S(W) $S(-title)
145145 wm transient $S(W) [winfo toplevel $S(-parent)]
146146
147 set scaling [tk scaling]
148 set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}]
149
147150 set outer [::ttk::frame $S(W).outer -padding {10 10}]
148151 ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"]
149152 ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"]
150 ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"]
153 ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth
151154 ttk::entry $S(W).efont -width 18 \
152155 -textvariable [namespace which -variable S](font)
153156 ttk::entry $S(W).estyle -width 10 \
198201 set minsize(sizes) \
199202 [expr {[font measure TkDefaultFont "-99"] + $scroll_width}]
200203 set min [expr {$minsize(gap) * 4}]
201 foreach {what width} [array get minsize] { incr min $width }
204 foreach {what width} [array get minsize] {incr min $width}
202205 wm minsize $S(W) $min 260
203206
204207 bind $S(W) <Return> [namespace code [list Done 1]]
276279 # Arguments:
277280 # ok true if user pressed OK
278281 #
279 proc ::tk::::fontchooser::Done {ok} {
282 proc ::tk::fontchooser::Done {ok} {
280283 variable S
281284
282285 if {! $ok} {
326329 set S(size) $F(-size)
327330 set S(strike) $F(-overstrike)
328331 set S(under) $F(-underline)
329 set S(style) "Regular"
332 set S(style) [::msgcat::mc "Regular"]
330333 if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} {
331 set S(style) "Bold Italic"
334 set S(style) [::msgcat::mc "Bold Italic"]
332335 } elseif {$F(-weight) eq "bold"} {
333 set S(style) "Bold"
336 set S(style) [::msgcat::mc "Bold"]
334337 } elseif {$F(-slant) eq "italic"} {
335 set S(style) "Italic"
338 set S(style) [::msgcat::mc "Italic"]
336339 }
337340
338341 set S(first) 0
380383 $S(W).l${var}s selection clear 0 end
381384 set n [lsearch -exact $S(${var}s,lcase) $value]
382385 $S(W).l${var}s selection set $n
383 if {$n != -1} {
386 if {$n >= 0} {
384387 set S($var) [lindex $S(${var}s) $n]
385388 $S(W).e$var icursor end
386389 $S(W).e$var selection clear
395398 }
396399 $S(W).l${var}s see $n
397400 }
398 if {!$bad} { Update }
401 if {!$bad} {Update}
399402 $S(W).ok configure -state $nstate
400403 }
401404
407410 variable S
408411
409412 set S(result) [list $S(font) $S(size)]
410 if {$S(style) eq "Bold"} { lappend S(result) bold }
411 if {$S(style) eq "Italic"} { lappend S(result) italic }
412 if {$S(style) eq "Bold Italic"} { lappend S(result) bold italic}
413 if {$S(strike)} { lappend S(result) overstrike}
414 if {$S(under)} { lappend S(result) underline}
413 if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold}
414 if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic}
415 if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic}
416 if {$S(strike)} {lappend S(result) overstrike}
417 if {$S(under)} {lappend S(result) underline}
415418
416419 $S(sample) configure -font $S(result)
417420 }
2525 # <path> selection includes <item>
2626 # <path> selection set <first> ?<last>?
2727
28 package require Tk 8.6
28 package require Tk
2929
3030 ::tk::Megawidget create ::tk::IconList ::tk::FocusableWidget {
3131 variable w canvas sbar accel accelCB fill font index \
696696 }
697697 }
698698
699 if {$theIndex > -1} {
699 if {$theIndex >= 0} {
700700 $w selection clear 0 end
701701 $w selection set $theIndex
702702 $w selection anchor $theIndex
310310 set Priv(listboxSelection) [$w curselection]
311311 }
312312 while {($i < $el) && ($i < $anchor)} {
313 if {[lsearch $Priv(listboxSelection) $i] >= 0} {
313 if {$i in $Priv(listboxSelection)} {
314314 $w selection set $i
315315 }
316316 incr i
317317 }
318318 while {($i > $el) && ($i > $anchor)} {
319 if {[lsearch $Priv(listboxSelection) $i] >= 0} {
319 if {$i in $Priv(listboxSelection)} {
320320 $w selection set $i
321321 }
322322 incr i -1
516516 }
517517 $w selection clear $first $last
518518 while {$first <= $last} {
519 if {[lsearch $Priv(listboxSelection) $first] >= 0} {
519 if {$first in $Priv(listboxSelection)} {
520520 $w selection set $first
521521 }
522522 incr first
99 # this file, and for a DISCLAIMER OF ALL WARRANTIES.
1010 #
1111
12 package require Tk 8.6
12 package require Tk
1313
1414 ::oo::class create ::tk::Megawidget {
1515 superclass ::oo::class
137137 bind Menu <Motion> {
138138 tk::MenuMotion %W %x %y %s
139139 }
140 bind Menu <ButtonPress> {
140 bind Menu <Button> {
141141 tk::MenuButtonDown %W
142142 }
143143 bind Menu <ButtonRelease> {
1313 # Note: It is now ok to let untrusted code being executed
1414 # between the creation of the interp and the actual loading
1515 # of Tk in that interp because the C side Tk_Init will
16 # now look up the master interp and ask its safe::TkInit
16 # now look up the parent interp and ask its safe::TkInit
1717 # for the actual parameters to use for it's initialization (if allowed),
18 # not relying on the slave state.
18 # not relying on the child state.
1919 #
2020
2121 # We use opt (optional arguments parsing)
2828 }
2929
3030 #
31 # tkInterpInit : prepare the slave interpreter for tk loading
31 # tkInterpInit : prepare the child interpreter for tk loading
3232 # most of the real job is done by loadTk
33 # returns the slave name (tkInterpInit does)
34 #
35 proc ::safe::tkInterpInit {slave argv} {
33 # returns the child name (tkInterpInit does)
34 #
35 proc ::safe::tkInterpInit {child argv} {
3636 global env tk_library
3737
3838 # We have to make sure that the tk_library variable is normalized.
3939 set tk_library [file normalize $tk_library]
4040
4141 # Clear Tk's access for that interp (path).
42 allowTk $slave $argv
42 allowTk $child $argv
4343
4444 # Ensure tk_library and subdirs (eg, ttk) are on the access path
45 ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]]
45 ::interp eval $child [list set tk_library [::safe::interpAddToAccessPath $child $tk_library]]
4646 foreach subdir [::safe::AddSubDirs [list $tk_library]] {
47 ::safe::interpAddToAccessPath $slave $subdir
48 }
49 return $slave
47 ::safe::interpAddToAccessPath $child $subdir
48 }
49 return $child
5050 }
5151
5252
5353 # tkInterpLoadTk:
5454 # Do additional configuration as needed (calling tkInterpInit)
55 # and actually load Tk into the slave.
55 # and actually load Tk into the child.
5656 #
5757 # Either contained in the specified windowId (-use) or
5858 # creating a decorated toplevel for it.
6161 proc ::safe::loadTk {} {}
6262
6363 ::tcl::OptProc ::safe::loadTk {
64 {slave -interp "name of the slave interpreter"}
64 {child -interp "name of the child interpreter"}
6565 {-use -windowId {} "window Id to use (new toplevel otherwise)"}
6666 {-display -displayName {} "display name to use (current one otherwise)"}
6767 } {
6868 set displayGiven [::tcl::OptProcArgGiven "-display"]
6969 if {!$displayGiven} {
7070 # Try to get the current display from "."
71 # (which might not exist if the master is tk-less)
71 # (which might not exist if the parent is tk-less)
7272 if {[catch {set display [winfo screen .]}]} {
7373 if {[info exists ::env(DISPLAY)]} {
7474 set display $::env(DISPLAY)
7575 } else {
76 Log $slave "no winfo screen . nor env(DISPLAY)" WARNING
76 Log $child "no winfo screen . nor env(DISPLAY)" WARNING
7777 set display ":0.0"
7878 }
7979 }
8080 }
8181
8282 # Get state for access to the cleanupHook.
83 namespace upvar ::safe S$slave state
83 namespace upvar ::safe S$child state
8484
8585 if {![::tcl::OptProcArgGiven "-use"]} {
8686 # create a decorated toplevel
87 lassign [tkTopLevel $slave $display] w use
88
89 # set our delete hook (slave arg is added by interpDelete)
90 # to clean up both window related code and tkInit(slave)
87 lassign [tkTopLevel $child $display] w use
88
89 # set our delete hook (child arg is added by interpDelete)
90 # to clean up both window related code and tkInit(child)
9191 set state(cleanupHook) [list tkDelete {} $w]
9292 } else {
93 # set our delete hook (slave arg is added by interpDelete)
94 # to clean up tkInit(slave)
93 # set our delete hook (child arg is added by interpDelete)
94 # to clean up tkInit(child)
9595 set state(cleanupHook) [list disallowTk]
9696
9797 # Let's be nice and also accept tk window names instead of ids
121121 }
122122 }
123123
124 # Prepares the slave for tk with those parameters
125 tkInterpInit $slave [list "-use" $use "-display" $display]
126
127 load {} Tk $slave
128
129 return $slave
124 # Prepares the child for tk with those parameters
125 tkInterpInit $child [list "-use" $use "-display" $display]
126
127 load {} Tk $child
128
129 return $child
130130 }
131131
132132 proc ::safe::TkInit {interpPath} {
148148 # safe::TkInit.
149149 #
150150 # Arguments:
151 # interpPath slave interpreter handle
151 # interpPath child interpreter handle
152152 # argv arguments passed to safe::TkInterpInit
153153 #
154154 # Results:
167167 # in safe::TkInit.
168168 #
169169 # Arguments:
170 # interpPath slave interpreter handle
170 # interpPath child interpreter handle
171171 #
172172 # Results:
173173 # none.
187187 # Clean up the window associated with the interp being deleted.
188188 #
189189 # Arguments:
190 # interpPath slave interpreter handle
190 # interpPath child interpreter handle
191191 #
192192 # Results:
193193 # none.
194194
195 proc ::safe::tkDelete {W window slave} {
195 proc ::safe::tkDelete {W window child} {
196196
197197 # we are going to be called for each widget... skip untill it's
198198 # top level
199199
200 Log $slave "Called tkDelete $W $window" NOTICE
201 if {[::interp exists $slave]} {
202 if {[catch {::safe::interpDelete $slave} msg]} {
203 Log $slave "Deletion error : $msg"
200 Log $child "Called tkDelete $W $window" NOTICE
201 if {[::interp exists $child]} {
202 if {[catch {::safe::interpDelete $child} msg]} {
203 Log $child "Deletion error : $msg"
204204 }
205205 }
206206 if {[winfo exists $window]} {
207 Log $slave "Destroy toplevel $window" NOTICE
207 Log $child "Destroy toplevel $window" NOTICE
208208 destroy $window
209209 }
210210
211 # clean up tkInit(slave)
212 disallowTk $slave
211 # clean up tkInit(child)
212 disallowTk $child
213213 return
214214 }
215215
216 proc ::safe::tkTopLevel {slave display} {
216 proc ::safe::tkTopLevel {child display} {
217217 variable tkSafeId
218218 incr tkSafeId
219219 set w ".safe$tkSafeId"
220220 if {[catch {toplevel $w -screen $display -class SafeTk} msg]} {
221221 return -code error -errorcode {TK TOPLEVEL SAFE} \
222 "Unable to create toplevel for safe slave \"$slave\" ($msg)"
223 }
224 Log $slave "New toplevel $w" NOTICE
225
226 set msg "Untrusted Tcl applet ($slave)"
222 "Unable to create toplevel for \"$child\" ($msg)"
223 }
224 Log $child "New toplevel $w" NOTICE
225
226 set msg "Untrusted Tcl applet ($child)"
227227 wm title $w $msg
228228
229229 # Control frame (we must create a style for it)
235235
236236 # We will destroy the interp when the window is destroyed
237237 bindtags $wc [concat Safe$wc [bindtags $wc]]
238 bind Safe$wc <Destroy> [list ::safe::tkDelete %W $w $slave]
238 bind Safe$wc <Destroy> [list ::safe::tkDelete %W $w $child]
239239
240240 ttk::label $wc.l -text $msg -anchor w
241241
246246 # but still have the default background instead of red one from the parent
247247 ttk::frame $wc.fb -borderwidth 0
248248 ttk::button $wc.fb.b -text "Delete" \
249 -command [list ::safe::tkDelete $w $w $slave]
249 -command [list ::safe::tkDelete $w $w $child]
250250 pack $wc.fb.b -side right -fill both
251251 pack $wc.fb -side right -fill both -expand 1
252252 pack $wc.l -side left -fill both -expand 1 -ipady 2
279279
280280 # A few additional bindings of my own.
281281
282 bind Spinbox <2> {
283 if {!$tk_strictMotif} {
284 ::tk::EntryScanMark %W %x
285 }
286 }
287 bind Spinbox <B2-Motion> {
288 if {!$tk_strictMotif} {
289 ::tk::EntryScanDrag %W %x
282 if {[tk windowingsystem] ne "aqua"} {
283 bind Spinbox <2> {
284 if {!$tk_strictMotif} {
285 ::tk::EntryScanMark %W %x
286 }
287 }
288 bind Spinbox <B2-Motion> {
289 if {!$tk_strictMotif} {
290 ::tk::EntryScanDrag %W %x
291 }
292 }
293 } else {
294 bind Spinbox <3> {
295 if {!$tk_strictMotif} {
296 ::tk::EntryScanMark %W %x
297 }
298 }
299 bind Spinbox <B3-Motion> {
300 if {!$tk_strictMotif} {
301 ::tk::EntryScanDrag %W %x
302 }
290303 }
291304 }
292305
469482 word {
470483 if {$cur < [$w index anchor]} {
471484 set before [tcl_wordBreakBefore [$w get] $cur]
472 set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]]
485 set after [tcl_wordBreakAfter [$w get] $anchor-1]
473486 } else {
474487 set before [tcl_wordBreakBefore [$w get] $anchor]
475 set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]]
488 set after [tcl_wordBreakAfter [$w get] $cur-1]
476489 }
477490 if {$before < 0} {
478491 set before 0
3838 # Shift by height of tearoff entry minus height of window titlebar
3939 catch {incr y [expr {[$w yposition 1] - 16}]}
4040 # Avoid the native menu bar which sits on top of everything.
41 if {$y < 22} { set y 22 }
41 if {$y < 22} {set y 22}
4242 }
4343 }
4444
152152
153153 # Copy tags to x, replacing each substring of src with dst.
154154
155 while {[set index [string first $src $tags]] != -1} {
156 append x [string range $tags 0 [expr {$index - 1}]]$dst
157 set tags [string range $tags [expr {$index + $srcLen}] end]
155 while {[set index [string first $src $tags]] >= 0} {
156 if {$index > 0} {
157 append x [string range $tags 0 $index-1]$dst
158 }
159 set tags [string range $tags $index+$srcLen end]
158160 }
159161 append x $tags
160162
167169
168170 # Copy script to x, replacing each substring of event with dst.
169171
170 while {[set index [string first $event $script]] != -1} {
171 append x [string range $script 0 [expr {$index - 1}]]
172 while {[set index [string first $event $script]] >= 0} {
173 if {$index > 0} {
174 append x [string range $script 0 $index-1]
175 }
172176 append x $dst
173 set script [string range $script [expr {$index + $eventLen}] end]
177 set script [string range $script $index+$eventLen end]
174178 }
175179 append x $script
176180
428428 %W see insert
429429 }
430430 }
431 bind Text <2> {
432 if {!$tk_strictMotif} {
433 tk::TextScanMark %W %x %y
434 }
435 }
436 bind Text <B2-Motion> {
437 if {!$tk_strictMotif} {
438 tk::TextScanDrag %W %x %y
431 if {[tk windowingsystem] ne "aqua"} {
432 bind Text <2> {
433 if {!$tk_strictMotif} {
434 tk::TextScanMark %W %x %y
435 }
436 }
437 bind Text <B2-Motion> {
438 if {!$tk_strictMotif} {
439 tk::TextScanDrag %W %x %y
440 }
441 }
442 } else {
443 bind Text <3> {
444 if {!$tk_strictMotif} {
445 tk::TextScanMark %W %x %y
446 }
447 }
448 bind Text <B3-Motion> {
449 if {!$tk_strictMotif} {
450 tk::TextScanDrag %W %x %y
451 }
439452 }
440453 }
441454 set ::tk::Priv(prevPos) {}
557570 } else {
558571 $w mark gravity $anchorname left
559572 }
560 # Allow focus in any case on Windows, because that will let the
561 # selection be displayed even for state disabled text widgets.
562 if {[tk windowingsystem] eq "win32" \
563 || [$w cget -state] eq "normal"} {
564 focus $w
565 }
573 focus $w
566574 if {[$w cget -autoseparators]} {
567575 $w edit separator
568576 }
1010 # this file, and for a DISCLAIMER OF ALL WARRANTIES.
1111
1212 # Verify that we have Tk binary and script components from the same release
13 package require -exact Tk 8.6.10
13 package require -exact Tk 8.6.11
1414
1515 # Create a ::tk namespace
1616 namespace eval ::tk {
399399 event add <<NextPara>> <Control-Down>
400400 event add <<SelectPrevPara>> <Control-Shift-Up>
401401 event add <<SelectNextPara>> <Control-Shift-Down>
402 event add <<ToggleSelection>> <Control-ButtonPress-1>
402 event add <<ToggleSelection>> <Control-Button-1>
403403
404404 # Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is
405405 # returned when the user presses <Shift-Tab>. In order for tab
448448 event add <<NextPara>> <Control-Down>
449449 event add <<SelectPrevPara>> <Control-Shift-Up>
450450 event add <<SelectNextPara>> <Control-Shift-Down>
451 event add <<ToggleSelection>> <Control-ButtonPress-1>
451 event add <<ToggleSelection>> <Control-Button-1>
452452 }
453453 "aqua" {
454454 event add <<Cut>> <Command-Key-x> <Key-F2> <Command-Lock-Key-X>
461461 # Official bindings
462462 # See http://support.apple.com/kb/HT1343
463463 event add <<SelectAll>> <Command-Key-a>
464 #Attach function keys not otherwise assigned to this event so they no-op - workaround for bug 0e6930dfe7
465 event add <<SelectNone>> <Option-Command-Key-a> <Key-F5> <Key-F1> <Key-F5> <Key-F6> <Key-F7> <Key-F8> <Key-F9> <Key-F10> <Key-F11> <Key-F12>
466464 event add <<Undo>> <Command-Key-z> <Command-Lock-Key-Z>
467465 event add <<Redo>> <Shift-Command-Key-z> <Shift-Command-Lock-Key-z>
468466 event add <<NextChar>> <Right> <Control-Key-f> <Control-Lock-Key-F>
487485 event add <<NextPara>> <Option-Down>
488486 event add <<SelectPrevPara>> <Shift-Option-Up>
489487 event add <<SelectNextPara>> <Shift-Option-Down>
490 event add <<ToggleSelection>> <Command-ButtonPress-1>
488 event add <<ToggleSelection>> <Command-Button-1>
491489 }
492490 }
493491
497495
498496 if {$::tk_library ne ""} {
499497 proc ::tk::SourceLibFile {file} {
500 namespace eval :: [list source [file join $::tk_library $file.tcl]]
498 namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]]
501499 }
502500 namespace eval ::tk {
503501 SourceLibFile icons
688686 if {[tk windowingsystem] eq "aqua"} {
689687 #stub procedures to respond to "do script" Apple Events
690688 proc ::tk::mac::DoScriptFile {file} {
691 source $file
689 uplevel #0 $file
690 source -encoding utf-8 $file
692691 }
693692 proc ::tk::mac::DoScriptText {script} {
693 uplevel #0 $script
694694 eval $script
695695 }
696696 }
702702
703703 # Run the Ttk themed widget set initialization
704704 if {$::ttk::library ne ""} {
705 uplevel \#0 [list source $::ttk::library/ttk.tcl]
705 uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl]
706706 }
707707
708708 # Local Variables:
1414 -insertwidth 1
1515
1616 ttk::style map . \
17 -foreground {
17 -foreground {
1818 disabled systemDisabledControlTextColor
1919 background systemLabelColor} \
2020 -selectbackground {
3434 ttk::style configure TMenubutton -anchor center -padding {2 0 0 2}
3535 ttk::style configure Toolbutton -anchor center
3636
37 # For Entry, Combobox and Spinbox widgets the selected text background
38 # is the "Highlight color" selected in preferences when the widget
39 # has focus. It is a gray color when the widget does not have focus or
40 # the window does not have focus. (The background state implies !focus
41 # so we only need to specify !focus.)
42
3743 # Entry
38 ttk::style configure TEntry \
39 -foreground systemTextColor \
40 -background systemTextBackgroundColor
4144 ttk::style map TEntry \
4245 -foreground {
4346 disabled systemDisabledControlTextColor
4447 } \
45 -selectforeground {
46 background systemTextColor
48 -selectbackground {
49 !focus systemUnemphasizedSelectedTextBackgroundColor
50 }
51
52 # Combobox:
53 ttk::style map TCombobox \
54 -foreground {
55 disabled systemDisabledControlTextColor
4756 } \
4857 -selectbackground {
49 background systemTextBackgroundColor
58 !focus systemUnemphasizedSelectedTextBackgroundColor
5059 }
51
60
61 # Spinbox
62 ttk::style map TSpinbox \
63 -foreground {
64 disabled systemDisabledControlTextColor
65 } \
66 -selectbackground {
67 !focus systemUnemphasizedSelectedTextBackgroundColor
68 }
5269
5370 # Workaround for #1100117:
5471 # Actually, on Aqua we probably shouldn't stipple images in
6683 disabled systemDisabledControlTextColor
6784 selected systemSelectedTabTextColor}
6885
69 # Combobox:
70 ttk::style configure TCombobox \
71 -foreground systemTextColor \
72 -background systemTransparent
73 ttk::style map TCombobox \
74 -foreground {
75 disabled systemDisabledControlTextColor
76 } \
77 -selectforeground {
78 background systemTextColor
79 } \
80 -selectbackground {
81 background systemTransparent
82 }
83
84 # Spinbox
85 ttk::style configure TSpinbox \
86 -foreground systemTextColor \
87 -background systemTextBackgroundColor \
88 -selectforeground systemSelectedTextColor \
89 -selectbackground systemSelectedTextBackgroundColor
90 ttk::style map TSpinbox \
91 -foreground {
92 disabled systemDisabledControlTextColor
93 } \
94 -selectforeground {
95 !active systemTextColor
96 } \
97 -selectbackground {
98 !active systemTextBackgroundColor
99 !focus systemTextBackgroundColor
100 focus systemSelectedTextBackgroundColor
101 }
102
10386 # Treeview:
10487 ttk::style configure Heading \
10588 -font TkHeadingFont \
11598 }
11699
117100 # Enable animation for ttk::progressbar widget:
118 ttk::style configure TProgressbar -period 100 -maxphase 255
101 ttk::style configure TProgressbar -period 100 -maxphase 120
119102
120103 # For Aqua, labelframe labels should appear outside the border,
121104 # with a 14 pixel inset and 4 pixels spacing between border and label
77 # (If the button is released off the widget, the grab deactivates and
88 # we get a <Leave> event then, which turns off the "active" state)
99 #
10 # Normally, <ButtonRelease> and <ButtonN-Enter/Leave> events are
11 # delivered to the widget which received the initial <ButtonPress>
10 # Normally, <ButtonRelease> and <ButtonN-Enter/Leave> events are
11 # delivered to the widget which received the initial <Button>
1212 # event. However, Tk [grab]s (#1223103) and menu interactions
1313 # (#1222605) can interfere with this. To guard against spurious
1414 # <Button1-Enter> events, the <Button1-Enter> binding only sets
1919
2020 bind TButton <Enter> { %W instate !disabled {%W state active} }
2121 bind TButton <Leave> { %W state !active }
22 bind TButton <Key-space> { ttk::button::activate %W }
22 bind TButton <space> { ttk::button::activate %W }
2323 bind TButton <<Invoke>> { ttk::button::activate %W }
2424
25 bind TButton <ButtonPress-1> \
25 bind TButton <Button-1> \
2626 { %W instate !disabled { ttk::clickToFocus %W; %W state pressed } }
2727 bind TButton <ButtonRelease-1> \
2828 { %W instate pressed { %W state !pressed; %W instate !disabled { %W invoke } } }
3838
3939 # ...plus a few more:
4040
41 bind TRadiobutton <KeyPress-Up> { ttk::button::RadioTraverse %W -1 }
42 bind TRadiobutton <KeyPress-Down> { ttk::button::RadioTraverse %W +1 }
41 bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 }
42 bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 }
4343
44 # bind TCheckbutton <KeyPress-plus> { %W select }
45 # bind TCheckbutton <KeyPress-minus> { %W deselect }
44 # bind TCheckbutton <plus> { %W select }
45 # bind TCheckbutton <minus> { %W deselect }
4646
4747 # activate --
4848 # Simulate a button press: temporarily set the state to 'pressed',
44 #
55
66 namespace eval ttk::theme::clam {
7 variable colors
7 variable colors
88 array set colors {
99 -disabledfg "#999999"
1010 -frame "#dcdad5"
4444
4545 ttk::copyBindings TEntry TCombobox
4646
47 bind TCombobox <KeyPress-Down> { ttk::combobox::Post %W }
48 bind TCombobox <KeyPress-Escape> { ttk::combobox::Unpost %W }
49
50 bind TCombobox <ButtonPress-1> { ttk::combobox::Press "" %W %x %y }
51 bind TCombobox <Shift-ButtonPress-1> { ttk::combobox::Press "s" %W %x %y }
52 bind TCombobox <Double-ButtonPress-1> { ttk::combobox::Press "2" %W %x %y }
53 bind TCombobox <Triple-ButtonPress-1> { ttk::combobox::Press "3" %W %x %y }
47 bind TCombobox <Down> { ttk::combobox::Post %W }
48 bind TCombobox <Escape> { ttk::combobox::Unpost %W }
49
50 bind TCombobox <Button-1> { ttk::combobox::Press "" %W %x %y }
51 bind TCombobox <Shift-Button-1> { ttk::combobox::Press "s" %W %x %y }
52 bind TCombobox <Double-Button-1> { ttk::combobox::Press "2" %W %x %y }
53 bind TCombobox <Triple-Button-1> { ttk::combobox::Press "3" %W %x %y }
5454 bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x }
5555 bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y }
5656
6161 ### Combobox listbox bindings.
6262 #
6363 bind ComboboxListbox <ButtonRelease-1> { ttk::combobox::LBSelected %W }
64 bind ComboboxListbox <KeyPress-Return> { ttk::combobox::LBSelected %W }
65 bind ComboboxListbox <KeyPress-Escape> { ttk::combobox::LBCancel %W }
66 bind ComboboxListbox <KeyPress-Tab> { ttk::combobox::LBTab %W next }
64 bind ComboboxListbox <Return> { ttk::combobox::LBSelected %W }
65 bind ComboboxListbox <Escape> { ttk::combobox::LBCancel %W }
66 bind ComboboxListbox <Tab> { ttk::combobox::LBTab %W next }
6767 bind ComboboxListbox <<PrevWindow>> { ttk::combobox::LBTab %W prev }
6868 bind ComboboxListbox <Destroy> { ttk::combobox::LBCleanup %W }
6969 bind ComboboxListbox <Motion> { ttk::combobox::LBHover %W %x %y }
8181 #
8282 bind ComboboxPopdown <Map> { ttk::combobox::MapPopdown %W }
8383 bind ComboboxPopdown <Unmap> { ttk::combobox::UnmapPopdown %W }
84 bind ComboboxPopdown <ButtonPress> \
84 bind ComboboxPopdown <Button> \
8585 { ttk::combobox::Unpost [winfo parent %W] }
8686
8787 ### Option database settings.
105105 ### Binding procedures.
106106 #
107107
108 ## Press $mode $x $y -- ButtonPress binding for comboboxes.
108 ## Press $mode $x $y -- Button binding for comboboxes.
109109 # Either post/unpost the listbox, or perform Entry widget binding,
110110 # depending on widget state and location of button press.
111111 #
134134 }
135135
136136 ## Drag -- B1-Motion binding for comboboxes.
137 # If the initial ButtonPress event was handled by Entry binding,
137 # If the initial Button event was handled by Entry binding,
138138 # perform Entry widget drag binding; otherwise nothing.
139139 #
140140 proc ttk::combobox::Drag {w x} {
148148 # Set cursor.
149149 #
150150 proc ttk::combobox::Motion {w x y} {
151 variable State
152 ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
151153 if { [$w identify $x $y] eq "textarea"
152154 && [$w instate {!readonly !disabled}]
153155 } {
154156 ttk::setCursor $w text
155157 } else {
156 ttk::setCursor $w ""
158 ttk::setCursor $w $State(userConfCursor)
157159 }
158160 }
159161
354356 set w [winfo width $cb]
355357 set h [winfo height $cb]
356358 set style [$cb cget -style]
359 if { $style eq {} } {
360 set style TCombobox
361 }
357362 set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}]
358363 foreach var {x y w h} delta $postoffset {
359364 incr $var $delta
139139
140140 proc ttk::setCursor {w name} {
141141 variable Cursors
142 if {[$w cget -cursor] ne $Cursors($name)} {
143 $w configure -cursor $Cursors($name)
142 if {[info exists Cursors($name)]} {
143 set cursorname $Cursors($name)
144 } else {
145 set cursorname $name
146 }
147 if {[$w cget -cursor] ne $cursorname} {
148 $w configure -cursor $cursorname
149 }
150 }
151
152 ## ttk::saveCursor $w $saveVar $excludeList --
153 # Set variable $saveVar to the -cursor value from widget $w,
154 # if either:
155 # a. $saveVar does not yet exist
156 # b. the currently user-specified cursor for $w is not in
157 # $excludeList
158
159 proc ttk::saveCursor {w saveVar excludeList} {
160 upvar $saveVar sv
161 if {![info exists sv]} {
162 set sv [$w cget -cursor]
163 }
164 if {[$w cget -cursor] ni $excludeList} {
165 set sv [$w cget -cursor]
144166 }
145167 }
146168
4242 ttk::style configure TButton \
4343 -anchor center -padding "3 3" -width -9 \
4444 -relief raised -shiftrelief 1
45 ttk::style map TButton -relief [list {!disabled pressed} sunken]
45 ttk::style map TButton -relief [list {!disabled pressed} sunken]
4646
4747 ttk::style configure TCheckbutton \
4848 -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1
3939 #
4040 # Removed the following standard Tk bindings:
4141 #
42 # <Control-Key-space>, <Control-Shift-Key-space>,
43 # <Key-Select>, <Shift-Key-Select>:
42 # <Control-space>, <Control-Shift-space>,
43 # <Select>, <Shift-Select>:
4444 # Ttk entry widget doesn't use selection anchor.
45 # <Key-Insert>:
45 # <Insert>:
4646 # Inserts PRIMARY selection (on non-Windows platforms).
4747 # This is inconsistent with typical platform bindings.
48 # <Double-Shift-ButtonPress-1>, <Triple-Shift-ButtonPress-1>:
48 # <Double-Shift-Button-1>, <Triple-Shift-Button-1>:
4949 # These don't do the right thing to start with.
50 # <Meta-Key-b>, <Meta-Key-d>, <Meta-Key-f>,
51 # <Meta-Key-BackSpace>, <Meta-Key-Delete>:
50 # <Meta-b>, <Meta-d>, <Meta-f>,
51 # <Meta-BackSpace>, <Meta-Delete>:
5252 # Judgment call. If <Meta> happens to be assigned to the Alt key,
5353 # these could conflict with application accelerators.
5454 # (Plus, who has a Meta key these days?)
55 # <Control-Key-t>:
55 # <Control-t>:
5656 # Another judgment call. If anyone misses this, let me know
5757 # and I'll put it back.
5858 #
6767 ## Button1 bindings:
6868 # Used for selection and navigation.
6969 #
70 bind TEntry <ButtonPress-1> { ttk::entry::Press %W %x }
71 bind TEntry <Shift-ButtonPress-1> { ttk::entry::Shift-Press %W %x }
72 bind TEntry <Double-ButtonPress-1> { ttk::entry::Select %W %x word }
73 bind TEntry <Triple-ButtonPress-1> { ttk::entry::Select %W %x line }
70 bind TEntry <Button-1> { ttk::entry::Press %W %x }
71 bind TEntry <Shift-Button-1> { ttk::entry::Shift-Press %W %x }
72 bind TEntry <Double-Button-1> { ttk::entry::Select %W %x word }
73 bind TEntry <Triple-Button-1> { ttk::entry::Select %W %x line }
7474 bind TEntry <B1-Motion> { ttk::entry::Drag %W %x }
7575
76 bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m }
77 bind TEntry <B1-Enter> { ttk::entry::DragIn %W }
78 bind TEntry <ButtonRelease-1> { ttk::entry::Release %W }
76 bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m }
77 bind TEntry <B1-Enter> { ttk::entry::DragIn %W }
78 bind TEntry <ButtonRelease-1> { ttk::entry::Release %W }
7979
8080 bind TEntry <<ToggleSelection>> {
8181 %W instate {!readonly !disabled} { %W icursor @%x ; focus %W }
8282 }
8383
84 ## Button2 bindings:
84 ## Button2 (Button3 on Aqua) bindings:
8585 # Used for scanning and primary transfer.
86 # Note: ButtonRelease-2 is mapped to <<PasteSelection>> in tk.tcl.
87 #
88 bind TEntry <ButtonPress-2> { ttk::entry::ScanMark %W %x }
89 bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x }
90 bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x }
86 # Note: ButtonRelease-2 (ButtonRelease-3 on Aqua)
87 # is mapped to <<PasteSelection>> in tk.tcl.
88 #
89 if {[tk windowingsystem] ne "aqua"} {
90 bind TEntry <Button-2> { ttk::entry::ScanMark %W %x }
91 bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x }
92 bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x }
93 } else {
94 bind TEntry <Button-3> { ttk::entry::ScanMark %W %x }
95 bind TEntry <B3-Motion> { ttk::entry::ScanDrag %W %x }
96 bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x }
97 }
9198 bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x }
9299
93100 ## Keyboard navigation bindings:
113120
114121 ## Edit bindings:
115122 #
116 bind TEntry <KeyPress> { ttk::entry::Insert %W %A }
117 bind TEntry <Key-Delete> { ttk::entry::Delete %W }
118 bind TEntry <Key-BackSpace> { ttk::entry::Backspace %W }
123 bind TEntry <Key> { ttk::entry::Insert %W %A }
124 bind TEntry <Delete> { ttk::entry::Delete %W }
125 bind TEntry <BackSpace> { ttk::entry::Backspace %W }
119126
120127 # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
121 # Otherwise, the <KeyPress> class binding will fire and insert the character.
128 # Otherwise, the <Key> class binding will fire and insert the character.
122129 # Ditto for Escape, Return, and Tab.
123130 #
124 bind TEntry <Alt-KeyPress> {# nothing}
125 bind TEntry <Meta-KeyPress> {# nothing}
126 bind TEntry <Control-KeyPress> {# nothing}
127 bind TEntry <Key-Escape> {# nothing}
128 bind TEntry <Key-Return> {# nothing}
129 bind TEntry <Key-KP_Enter> {# nothing}
130 bind TEntry <Key-Tab> {# nothing}
131 bind TEntry <Alt-Key> {# nothing}
132 bind TEntry <Meta-Key> {# nothing}
133 bind TEntry <Control-Key> {# nothing}
134 bind TEntry <Escape> {# nothing}
135 bind TEntry <Return> {# nothing}
136 bind TEntry <KP_Enter> {# nothing}
137 bind TEntry <Tab> {# nothing}
131138
132139 # Argh. Apparently on Windows, the NumLock modifier is interpreted
133140 # as a Command modifier.
134141 if {[tk windowingsystem] eq "aqua"} {
135 bind TEntry <Command-KeyPress> {# nothing}
142 bind TEntry <Command-Key> {# nothing}
136143 }
137144 # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
138145 bind TEntry <<PrevLine>> {# nothing}
140147
141148 ## Additional emacs-like bindings:
142149 #
143 bind TEntry <Control-Key-d> { ttk::entry::Delete %W }
144 bind TEntry <Control-Key-h> { ttk::entry::Backspace %W }
145 bind TEntry <Control-Key-k> { %W delete insert end }
150 bind TEntry <Control-d> { ttk::entry::Delete %W }
151 bind TEntry <Control-h> { ttk::entry::Backspace %W }
152 bind TEntry <Control-k> { %W delete insert end }
146153
147154 # Bindings for IME text input.
148155
350357 # Triple-clicking enters "line-select" mode.
351358 #
352359
353 ## Press -- ButtonPress-1 binding.
360 ## Press -- Button-1 binding.
354361 # Set the insertion cursor, claim the input focus, set up for
355362 # future drag operations.
356363 #
367374 set State(anchor) [$w index insert]
368375 }
369376
370 ## Shift-Press -- Shift-ButtonPress-1 binding.
377 ## Shift-Press -- Shift-Button-1 binding.
371378 # Extends the selection, sets anchor for future drag operations.
372379 #
373380 proc ttk::entry::Shift-Press {w x} {
516523 ### Button 2 binding procedures.
517524 #
518525
519 ## ScanMark -- ButtonPress-2 binding.
526 ## ScanMark -- Button-2 binding.
520527 # Marks the start of a scan or primary transfer operation.
521528 #
522529 proc ttk::entry::ScanMark {w x} {
8181 set F(family) "MS Sans Serif"
8282 }
8383 } else {
84 if {[lsearch -exact [font families] Tahoma] != -1} {
84 if {[lsearch -exact [font families] Tahoma] >= 0} {
8585 set F(family) "Tahoma"
8686 } else {
8787 set F(family) "MS Sans Serif"
44 #
55 # Pulldown: Press menubutton, drag over menu, release to activate menu entry
66 # Popdown: Click menubutton to post menu
7 # Keyboard: <Key-space> or accelerator key to post menu
7 # Keyboard: <space> or accelerator key to post menu
88 #
99 # (In addition, when menu system is active, "dropdown" -- menu posts
1010 # on mouse-over. Ttk menubuttons don't implement this).
1111 #
12 # For keyboard and popdown mode, we hand off to tk_popup and let
12 # For keyboard and popdown mode, we hand off to tk_popup and let
1313 # the built-in Tk bindings handle the rest of the interaction.
1414 #
1515 # ON X11:
1818 # This won't work for Ttk menubuttons in pulldown mode,
1919 # since we need to process the final <ButtonRelease> event,
2020 # and this might be delivered to the menu. So instead we
21 # rely on the passive grab that occurs on <ButtonPress> events,
21 # rely on the passive grab that occurs on <Button> events,
2222 # and transition to popdown mode when the mouse is released
2323 # or dragged outside the menubutton.
24 #
24 #
2525 # ON WINDOWS:
2626 #
27 # I'm not sure what the hell is going on here. [$menu post] apparently
27 # I'm not sure what the hell is going on here. [$menu post] apparently
2828 # sets up some kind of internal grab for native menus.
2929 # On this platform, just use [tk_popup] for all menu actions.
30 #
30 #
3131 # ON MACOS:
3232 #
3333 # Same probably applies here.
4545
4646 bind TMenubutton <Enter> { %W instate !disabled {%W state active } }
4747 bind TMenubutton <Leave> { %W state !active }
48 bind TMenubutton <Key-space> { ttk::menubutton::Popdown %W }
48 bind TMenubutton <space> { ttk::menubutton::Popdown %W }
4949 bind TMenubutton <<Invoke>> { ttk::menubutton::Popdown %W }
5050
5151 if {[tk windowingsystem] eq "x11"} {
52 bind TMenubutton <ButtonPress-1> { ttk::menubutton::Pulldown %W }
52 bind TMenubutton <Button-1> { ttk::menubutton::Pulldown %W }
5353 bind TMenubutton <ButtonRelease-1> { ttk::menubutton::TransferGrab %W }
5454 bind TMenubutton <B1-Leave> { ttk::menubutton::TransferGrab %W }
5555 } else {
56 bind TMenubutton <ButtonPress-1> \
56 bind TMenubutton <Button-1> \
5757 { %W state pressed ; ttk::menubutton::Popdown %W }
5858 bind TMenubutton <ButtonRelease-1> \
5959 { if {[winfo exists %W]} { %W state !pressed } }
9696 }
9797 below {
9898 set entry ""
99 incr y $bh
99 incr y $bh
100100 }
101101 left {
102102 incr y $menuPad
104104 }
105105 right {
106106 incr y $menuPad
107 incr x $bw
107 incr x $bw
108108 }
109109 default {
110110 incr y $bbh
181181
182182 # Pulldown (X11 only) --
183183 # Called when Button1 is pressed on a menubutton.
184 # Posts the menu; a subsequent ButtonRelease
184 # Posts the menu; a subsequent ButtonRelease
185185 # or Leave event will set a grab on the menu.
186186 #
187187 proc ttk::menubutton::Pulldown {mb} {
223223 # FindMenuEntry --
224224 # Hack to support tk_optionMenus.
225225 # Returns the index of the menu entry with a matching -label,
226 # -1 if not found.
226 # "" if not found.
227227 #
228228 proc ttk::menubutton::FindMenuEntry {menu s} {
229229 set last [$menu index last]
230 if {$last eq "none"} {
230 if {$last eq "none" || $last eq ""} {
231231 return ""
232232 }
233233 for {set i 0} {$i <= $last} {incr i} {
55 variable TLNotebooks ;# See enableTraversal
66 }
77
8 bind TNotebook <ButtonPress-1> { ttk::notebook::Press %W %x %y }
9 bind TNotebook <Key-Right> { ttk::notebook::CycleTab %W 1; break }
10 bind TNotebook <Key-Left> { ttk::notebook::CycleTab %W -1; break }
11 bind TNotebook <Control-Key-Tab> { ttk::notebook::CycleTab %W 1; break }
12 bind TNotebook <Control-Shift-Key-Tab> { ttk::notebook::CycleTab %W -1; break }
8 bind TNotebook <Button-1> { ttk::notebook::Press %W %x %y }
9 bind TNotebook <Right> { ttk::notebook::CycleTab %W 1; break }
10 bind TNotebook <Left> { ttk::notebook::CycleTab %W -1; break }
11 bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break }
12 bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break }
1313 catch {
1414 bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break }
1515 }
4242 }
4343
4444 # Press $nb $x $y --
45 # ButtonPress-1 binding for notebook widgets.
45 # Button-1 binding for notebook widgets.
4646 # Activate the tab under the mouse cursor, if any.
4747 #
4848 proc ttk::notebook::Press {w x y} {
6969 }
7070
7171 # MnemonicTab $nb $key --
72 # Scan all tabs in the specified notebook for one with the
72 # Scan all tabs in the specified notebook for one with the
7373 # specified mnemonic. If found, returns path name of tab;
7474 # otherwise returns ""
7575 #
9393 # Enable keyboard traversal for a notebook widget
9494 # by adding bindings to the containing toplevel window.
9595 #
96 # TLNotebooks($top) keeps track of the list of all traversal-enabled
97 # notebooks contained in the toplevel
96 # TLNotebooks($top) keeps track of the list of all traversal-enabled
97 # notebooks contained in the toplevel
9898 #
9999 proc ttk::notebook::enableTraversal {nb} {
100100 variable TLNotebooks
104104 if {![info exists TLNotebooks($top)]} {
105105 # Augment $top bindings:
106106 #
107 bind $top <Control-Key-Next> {+ttk::notebook::TLCycleTab %W 1}
108 bind $top <Control-Key-Prior> {+ttk::notebook::TLCycleTab %W -1}
109 bind $top <Control-Key-Tab> {+ttk::notebook::TLCycleTab %W 1}
110 bind $top <Control-Shift-Key-Tab> {+ttk::notebook::TLCycleTab %W -1}
107 bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1}
108 bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1}
109 bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1}
110 bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1}
111111 catch {
112 bind $top <Control-Key-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1}
112 bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1}
113113 }
114114 if {[tk windowingsystem] eq "aqua"} {
115 bind $top <Option-KeyPress> \
115 bind $top <Option-Key> \
116116 +[list ttk::notebook::MnemonicActivation $top %K]
117117 } else {
118 bind $top <Alt-KeyPress> \
118 bind $top <Alt-Key> \
119119 +[list ttk::notebook::MnemonicActivation $top %K]
120120 }
121121 bind $top <Destroy> {+ttk::notebook::TLCleanup %W}
144144 }
145145 }
146146
147 # EnclosingNotebook $w --
147 # EnclosingNotebook $w --
148148 # Return the nearest traversal-enabled notebook widget
149149 # that contains $w.
150150 #
170170
171171 # TLCycleTab --
172172 # toplevel binding procedure for Control-Tab / Control-Shift-Tab
173 # Select the next/previous tab in the nearest ancestor notebook.
173 # Select the next/previous tab in the nearest ancestor notebook.
174174 #
175175 proc ttk::notebook::TLCycleTab {w dir} {
176176 set nb [EnclosingNotebook $w]
181181 }
182182
183183 # MnemonicActivation $nb $key --
184 # Alt-KeyPress binding procedure for mnemonic activation.
184 # Alt-Key binding procedure for mnemonic activation.
185185 # Scan all notebooks in specified toplevel for a tab with the
186186 # the specified mnemonic. If found, activate it and return TCL_BREAK.
187187 #
1414
1515 ## Bindings:
1616 #
17 bind TPanedwindow <ButtonPress-1> { ttk::panedwindow::Press %W %x %y }
17 bind TPanedwindow <Button-1> { ttk::panedwindow::Press %W %x %y }
1818 bind TPanedwindow <B1-Motion> { ttk::panedwindow::Drag %W %x %y }
1919 bind TPanedwindow <ButtonRelease-1> { ttk::panedwindow::Release %W %x %y }
2020
6161 #
6262 proc ttk::panedwindow::ResetCursor {w} {
6363 variable State
64
65 ttk::saveCursor $w State(userConfCursor) \
66 [list [ttk::cursor hresize] [ttk::cursor vresize]]
67
6468 if {!$State(pressed)} {
65 ttk::setCursor $w {}
69 ttk::setCursor $w $State(userConfCursor)
6670 }
6771 }
6872
6973 proc ttk::panedwindow::SetCursor {w x y} {
70 set cursor ""
74 variable State
75
76 ttk::saveCursor $w State(userConfCursor) \
77 [list [ttk::cursor hresize] [ttk::cursor vresize]]
78
79 set cursor $State(userConfCursor)
7180 if {[llength [$w identify $x $y]]} {
7281 # Assume we're over a sash.
7382 switch -- [$w cget -orient] {
88 }
99 }
1010
11 bind TScale <ButtonPress-1> { ttk::scale::Press %W %x %y }
11 bind TScale <Button-1> { ttk::scale::Press %W %x %y }
1212 bind TScale <B1-Motion> { ttk::scale::Drag %W %x %y }
1313 bind TScale <ButtonRelease-1> { ttk::scale::Release %W %x %y }
1414
15 bind TScale <ButtonPress-2> { ttk::scale::Jump %W %x %y }
15 bind TScale <Button-2> { ttk::scale::Jump %W %x %y }
1616 bind TScale <B2-Motion> { ttk::scale::Drag %W %x %y }
1717 bind TScale <ButtonRelease-2> { ttk::scale::Release %W %x %y }
1818
19 bind TScale <ButtonPress-3> { ttk::scale::Jump %W %x %y }
19 bind TScale <Button-3> { ttk::scale::Jump %W %x %y }
2020 bind TScale <B3-Motion> { ttk::scale::Drag %W %x %y }
2121 bind TScale <ButtonRelease-3> { ttk::scale::Release %W %x %y }
2222
5151 }
5252 }
5353
54 # scale::Jump -- ButtonPress-2/3 binding for scale acts like
54 # scale::Jump -- Button-2/3 binding for scale acts like
5555 # Press except that clicking in the trough jumps to the
5656 # clicked position.
5757 proc ttk::scale::Jump {w x y} {
88 # State(first) -- value of -first at start of drag.
99 }
1010
11 bind TScrollbar <ButtonPress-1> { ttk::scrollbar::Press %W %x %y }
11 bind TScrollbar <Button-1> { ttk::scrollbar::Press %W %x %y }
1212 bind TScrollbar <B1-Motion> { ttk::scrollbar::Drag %W %x %y }
1313 bind TScrollbar <ButtonRelease-1> { ttk::scrollbar::Release %W %x %y }
1414
15 bind TScrollbar <ButtonPress-2> { ttk::scrollbar::Jump %W %x %y }
15 bind TScrollbar <Button-2> { ttk::scrollbar::Jump %W %x %y }
1616 bind TScrollbar <B2-Motion> { ttk::scrollbar::Drag %W %x %y }
1717 bind TScrollbar <ButtonRelease-2> { ttk::scrollbar::Release %W %x %y }
18
19 # Redirect scrollwheel bindings to the scrollbar widget
20 #
21 # The shift-bindings scroll left/right (not up/down)
22 # if a widget has both possibilities
23 set eventList [list <MouseWheel> <Shift-MouseWheel>]
24 switch [tk windowingsystem] {
25 aqua {
26 lappend eventList <Option-MouseWheel> <Shift-Option-MouseWheel>
27 }
28 x11 {
29 lappend eventList <Button-4> <Button-5> \
30 <Shift-Button-4> <Shift-Button-5>
31 # For tk 8.7, the event list will be extended by
32 # <Button-6> <Button-7>
33 }
34 }
35 foreach event $eventList {
36 bind TScrollbar $event [bind Scrollbar $event]
37 }
38 unset eventList event
1839
1940 proc ttk::scrollbar::Scroll {w n units} {
2041 set cmd [$w cget -command]
3758 set State(yPress) $y
3859
3960 switch -glob -- [$w identify $x $y] {
40 *uparrow -
61 *uparrow -
4162 *leftarrow {
4263 ttk::Repeatedly Scroll $w -1 units
4364 }
4566 *rightarrow {
4667 ttk::Repeatedly Scroll $w 1 units
4768 }
69 *grip -
4870 *thumb {
4971 set State(first) [lindex [$w get] 0]
5072 }
6789 proc ttk::scrollbar::Drag {w x y} {
6890 variable State
6991 if {![info exists State(first)]} {
70 # Initial buttonpress was not on the thumb,
92 # Initial buttonpress was not on the thumb,
7193 # or something screwy has happened. In either case, ignore:
7294 return;
7395 }
82104 ttk::CancelRepeat
83105 }
84106
85 # scrollbar::Jump -- ButtonPress-2 binding for scrollbars.
107 # scrollbar::Jump -- Button-2 binding for scrollbars.
86108 # Behaves exactly like scrollbar::Press, except that
87109 # clicking in the trough jumps to the the selected position.
88110 #
90112 variable State
91113
92114 switch -glob -- [$w identify $x $y] {
115 *grip -
93116 *thumb -
94117 *trough {
95118 set State(first) [$w fraction $x $y]
3131 }
3232 }
3333
34 bind TSizegrip <ButtonPress-1> { ttk::sizegrip::Press %W %X %Y }
34 bind TSizegrip <Button-1> { ttk::sizegrip::Press %W %X %Y }
3535 bind TSizegrip <B1-Motion> { ttk::sizegrip::Drag %W %X %Y }
3636 bind TSizegrip <ButtonRelease-1> { ttk::sizegrip::Release %W %X %Y }
3737
1111 ttk::copyBindings TEntry TSpinbox
1212
1313 bind TSpinbox <Motion> { ttk::spinbox::Motion %W %x %y }
14 bind TSpinbox <ButtonPress-1> { ttk::spinbox::Press %W %x %y }
14 bind TSpinbox <Button-1> { ttk::spinbox::Press %W %x %y }
1515 bind TSpinbox <ButtonRelease-1> { ttk::spinbox::Release %W }
1616 bind TSpinbox <Double-Button-1> { ttk::spinbox::DoubleClick %W %x %y }
1717 bind TSpinbox <Triple-Button-1> {} ;# disable TEntry triple-click
1818
19 bind TSpinbox <KeyPress-Up> { event generate %W <<Increment>> }
20 bind TSpinbox <KeyPress-Down> { event generate %W <<Decrement>> }
19 bind TSpinbox <Up> { event generate %W <<Increment>> }
20 bind TSpinbox <Down> { event generate %W <<Decrement>> }
2121
2222 bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 }
2323 bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 }
2828 # Sets cursor.
2929 #
3030 proc ttk::spinbox::Motion {w x y} {
31 variable State
32 ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
3133 if { [$w identify $x $y] eq "textarea"
32 && [$w instate {!readonly !disabled}]
34 && [$w instate {!readonly !disabled}]
3335 } {
3436 ttk::setCursor $w text
3537 } else {
36 ttk::setCursor $w ""
38 ttk::setCursor $w $State(userConfCursor)
3739 }
3840 }
3941
4345 if {[$w instate disabled]} { return }
4446 focus $w
4547 switch -glob -- [$w identify $x $y] {
46 *textarea { ttk::entry::Press $w $x }
48 *textarea { ttk::entry::Press $w $x }
4749 *rightarrow -
48 *uparrow { ttk::Repeatedly event generate $w <<Increment>> }
50 *uparrow { ttk::Repeatedly event generate $w <<Increment>> }
4951 *leftarrow -
50 *downarrow { ttk::Repeatedly event generate $w <<Decrement>> }
52 *downarrow { ttk::Repeatedly event generate $w <<Decrement>> }
5153 *spinbutton {
5254 if {$y * 2 >= [winfo height $w]} {
53 set event <<Decrement>>
55 set event <<Decrement>>
5456 } else {
55 set event <<Increment>>
57 set event <<Increment>>
5658 }
5759 ttk::Repeatedly event generate $w $event
5860 }
6668 if {[$w instate disabled]} { return }
6769
6870 switch -glob -- [$w identify $x $y] {
69 *textarea { SelectAll $w }
71 *textarea { SelectAll $w }
7072 * { Press $w $x $y }
7173 }
7274 }
132134 # -from, -to, and -increment.
133135 #
134136 proc ttk::spinbox::Spin {w dir} {
137 variable State
138
135139 if {[$w instate disabled]} { return }
136 set nvalues [llength [set values [$w cget -values]]]
137 set value [$w get]
138 if {$nvalues} {
139 set current [lsearch -exact $values $value]
140 set index [Adjust $w [expr {$current + $dir}] 0 [expr {$nvalues - 1}]]
141 $w set [lindex $values $index]
140
141 if {![info exists State($w,values.length)]} {
142 set State($w,values.index) -1
143 set State($w,values.last) {}
144 }
145 set State($w,values) [$w cget -values]
146 set State($w,values.length) [llength $State($w,values)]
147
148 if {$State($w,values.length) > 0} {
149 set value [$w get]
150 set current $State($w,values.index)
151 if {$value ne $State($w,values.last)} {
152 set current [lsearch -exact $State($w,values) $value]
153 if {$current < 0} {set current -1}
154 }
155 set State($w,values.index) [Adjust $w [expr {$current + $dir}] 0 \
156 [expr {$State($w,values.length) - 1}]]
157 set State($w,values.last) [lindex $State($w,values) $State($w,values.index)]
158 $w set $State($w,values.last)
142159 } else {
143 if {[catch {
144 set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}]
160 if {[catch {
161 set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}]
145162 }]} {
146163 set v [$w cget -from]
147164 }
159176 if {$fmt eq ""} {
160177 # Try to guess a suitable -format based on -increment.
161178 set delta [expr {abs([$w cget -increment])}]
162 if {0 < $delta && $delta < 1} {
179 if {0 < $delta && $delta < 1} {
163180 # NB: This guesses wrong if -increment has more than 1
164181 # significant digit itself, e.g., -increment 0.25
165182 set nsd [expr {int(ceil(-log10($delta)))}]
2727 bind Treeview <Motion> { ttk::treeview::Motion %W %x %y }
2828 bind Treeview <B1-Leave> { #nothing }
2929 bind Treeview <Leave> { ttk::treeview::ActivateHeading {} {}}
30 bind Treeview <ButtonPress-1> { ttk::treeview::Press %W %x %y }
31 bind Treeview <Double-ButtonPress-1> { ttk::treeview::DoubleClick %W %x %y }
30 bind Treeview <Button-1> { ttk::treeview::Press %W %x %y }
31 bind Treeview <Double-Button-1> { ttk::treeview::DoubleClick %W %x %y }
3232 bind Treeview <ButtonRelease-1> { ttk::treeview::Release %W %x %y }
3333 bind Treeview <B1-Motion> { ttk::treeview::Drag %W %x %y }
34 bind Treeview <KeyPress-Up> { ttk::treeview::Keynav %W up }
35 bind Treeview <KeyPress-Down> { ttk::treeview::Keynav %W down }
36 bind Treeview <KeyPress-Right> { ttk::treeview::Keynav %W right }
37 bind Treeview <KeyPress-Left> { ttk::treeview::Keynav %W left }
38 bind Treeview <KeyPress-Prior> { %W yview scroll -1 pages }
39 bind Treeview <KeyPress-Next> { %W yview scroll 1 pages }
40 bind Treeview <KeyPress-Return> { ttk::treeview::ToggleFocus %W }
41 bind Treeview <KeyPress-space> { ttk::treeview::ToggleFocus %W }
42
43 bind Treeview <Shift-ButtonPress-1> \
34 bind Treeview <Up> { ttk::treeview::Keynav %W up }
35 bind Treeview <Down> { ttk::treeview::Keynav %W down }
36 bind Treeview <Right> { ttk::treeview::Keynav %W right }
37 bind Treeview <Left> { ttk::treeview::Keynav %W left }
38 bind Treeview <Prior> { %W yview scroll -1 pages }
39 bind Treeview <Next> { %W yview scroll 1 pages }
40 bind Treeview <Return> { ttk::treeview::ToggleFocus %W }
41 bind Treeview <space> { ttk::treeview::ToggleFocus %W }
42
43 bind Treeview <Shift-Button-1> \
4444 { ttk::treeview::Select %W %x %y extend }
4545 bind Treeview <<ToggleSelection>> \
4646 { ttk::treeview::Select %W %x %y toggle }
4747
48 ttk::copyBindings TtkScrollable Treeview
48 ttk::copyBindings TtkScrollable Treeview
4949
5050 ### Binding procedures.
5151 #
101101 # Sets cursor, active element ...
102102 #
103103 proc ttk::treeview::Motion {w x y} {
104 set cursor {}
104 variable State
105
106 ttk::saveCursor $w State(userConfCursor) [ttk::cursor hresize]
107
108 set cursor $State(userConfCursor)
105109 set activeHeading {}
106110
107111 switch -- [$w identify region $x $y] {
126130 # triggers a <Leave> event. A proc checking if the display column
127131 # $State(activeHeading) is really still present or not could be
128132 # written but it would need to check several special cases:
129 # a. -displaycolumns "#all" or being an explicit columns list
133 # a. -displaycolumns "#all" or being an explicit columns list
130134 # b. column #0 display is not governed by the -displaycolumn
131135 # list but by the value of the -show option
132136 # --> Let's rather catch the following line.
150154 }
151155 }
152156
153 ## DoubleClick -- Double-ButtonPress-1 binding.
157 ## DoubleClick -- Double-Button-1 binding.
154158 #
155159 proc ttk::treeview::DoubleClick {w x y} {
156160 if {[set row [$w identify row $x $y]] ne ""} {
160164 }
161165 }
162166
163 ## Press -- ButtonPress binding.
167 ## Press -- Button binding.
164168 #
165169 proc ttk::treeview::Press {w x y} {
166170 focus $w
260264
261265 ## -selectmode none:
262266 #
263 proc ttk::treeview::select.choose.none {w item} { $w focus $item }
264 proc ttk::treeview::select.toggle.none {w item} { $w focus $item }
265 proc ttk::treeview::select.extend.none {w item} { $w focus $item }
267 proc ttk::treeview::select.choose.none {w item} { $w focus $item; $w see $item }
268 proc ttk::treeview::select.toggle.none {w item} { $w focus $item; $w see $item }
269 proc ttk::treeview::select.extend.none {w item} { $w focus $item; $w see $item }
266270
267271 ## -selectmode browse:
268272 #
1111 }
1212 }
1313
14 source [file join $::ttk::library fonts.tcl]
15 source [file join $::ttk::library cursors.tcl]
16 source [file join $::ttk::library utils.tcl]
14 source -encoding utf-8 [file join $::ttk::library fonts.tcl]
15 source -encoding utf-8 [file join $::ttk::library cursors.tcl]
16 source -encoding utf-8 [file join $::ttk::library utils.tcl]
1717
1818 ## ttk::deprecated $old $new --
1919 # Define $old command as a deprecated alias for $new command
9696
9797 ### Load widget bindings.
9898 #
99 source [file join $::ttk::library button.tcl]
100 source [file join $::ttk::library menubutton.tcl]
101 source [file join $::ttk::library scrollbar.tcl]
102 source [file join $::ttk::library scale.tcl]
103 source [file join $::ttk::library progress.tcl]
104 source [file join $::ttk::library notebook.tcl]
105 source [file join $::ttk::library panedwindow.tcl]
106 source [file join $::ttk::library entry.tcl]
107 source [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
108 source [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
109 source [file join $::ttk::library treeview.tcl]
110 source [file join $::ttk::library sizegrip.tcl]
99 source -encoding utf-8 [file join $::ttk::library button.tcl]
100 source -encoding utf-8 [file join $::ttk::library menubutton.tcl]
101 source -encoding utf-8 [file join $::ttk::library scrollbar.tcl]
102 source -encoding utf-8 [file join $::ttk::library scale.tcl]
103 source -encoding utf-8 [file join $::ttk::library progress.tcl]
104 source -encoding utf-8 [file join $::ttk::library notebook.tcl]
105 source -encoding utf-8 [file join $::ttk::library panedwindow.tcl]
106 source -encoding utf-8 [file join $::ttk::library entry.tcl]
107 source -encoding utf-8 [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
108 source -encoding utf-8 [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
109 source -encoding utf-8 [file join $::ttk::library treeview.tcl]
110 source -encoding utf-8 [file join $::ttk::library sizegrip.tcl]
111111
112112 ## Label and Labelframe bindings:
113113 # (not enough to justify their own file...)
121121 variable library
122122
123123 # "default" always present:
124 uplevel #0 [list source [file join $library defaults.tcl]]
124 uplevel #0 [list source -encoding utf-8 [file join $library defaults.tcl]]
125125
126126 set builtinThemes [style theme names]
127127 foreach {theme scripts} {
134134 } {
135135 if {[lsearch -exact $builtinThemes $theme] >= 0} {
136136 foreach script $scripts {
137 uplevel #0 [list source [file join $library $script]]
137 uplevel #0 [list source -encoding utf-8 [file join $library $script]]
138138 }
139139 }
140140 }
5757 }
5858
5959 ## ttk::clickToFocus $w --
60 # Utility routine, used in <ButtonPress-1> bindings --
60 # Utility routine, used in <Button-1> bindings --
6161 # Assign keyboard focus to the specified widget if -takefocus is enabled.
6262 #
6363 proc ttk::clickToFocus {w} {
277277 # On OSX, Tk generates sensible values for the %D field in <MouseWheel> events.
278278 #
279279 # On Windows, %D must be scaled by a factor of 120.
280 # In addition, Tk redirects mousewheel events to the window with
281 # keyboard focus instead of sending them to the window under the pointer.
282 # We do not attempt to fix that here, see also TIP#171.
283280 #
284281 # OSX conventionally uses Shift+MouseWheel for horizontal scrolling,
285282 # and Option+MouseWheel for accelerated scrolling.
300297
301298 proc ttk::bindMouseWheel {bindtag callback} {
302299 if {[tk windowingsystem] eq "x11"} {
303 bind $bindtag <ButtonPress-4> "$callback -1"
304 bind $bindtag <ButtonPress-5> "$callback +1"
300 bind $bindtag <Button-4> "$callback -1"
301 bind $bindtag <Button-5> "$callback +1"
305302 }
306303 if {[tk windowingsystem] eq "aqua"} {
307 bind $bindtag <MouseWheel> [append callback { [expr {-(%D)}]} ]
308 bind $bindtag <Option-MouseWheel> [append callback { [expr {-10 *(%D)}]} ]
304 bind $bindtag <MouseWheel> "$callback \[expr {-%D}\]"
305 bind $bindtag <Option-MouseWheel> "$callback \[expr {-10*%D}\]"
309306 } else {
310 bind $bindtag <MouseWheel> [append callback { [expr {-(%D / 120)}]}]
307 bind $bindtag <MouseWheel> "$callback \[expr {-%D/120)}\]"
311308 }
312309 }
313310
320317 #
321318
322319 if {[tk windowingsystem] eq "x11"} {
323 bind TtkScrollable <ButtonPress-4> { %W yview scroll -5 units }
324 bind TtkScrollable <ButtonPress-5> { %W yview scroll 5 units }
325 bind TtkScrollable <Shift-ButtonPress-4> { %W xview scroll -5 units }
326 bind TtkScrollable <Shift-ButtonPress-5> { %W xview scroll 5 units }
320 bind TtkScrollable <Button-4> { %W yview scroll -5 units }
321 bind TtkScrollable <Button-5> { %W yview scroll 5 units }
322 bind TtkScrollable <Shift-Button-4> { %W xview scroll -5 units }
323 bind TtkScrollable <Shift-Button-5> { %W xview scroll 5 units }
327324 }
328325 if {[tk windowingsystem] eq "aqua"} {
329326 bind TtkScrollable <MouseWheel> \
22 #
33
44 # The Vista theme can only be defined on Windows Vista and above. The theme
5 # is created in C due to the need to assign a theme-enabled function for
5 # is created in C due to the need to assign a theme-enabled function for
66 # detecting when themeing is disabled. On systems that cannot support the
77 # Vista theme, there will be no such theme created and we must not
88 # evaluate this script.
6868 ttk::style layout TCombobox {
6969 Combobox.border -sticky nswe -border 0 -children {
7070 Combobox.rightdownarrow -side right -sticky ns
71 Combobox.padding -expand 1 -sticky nswe -children {
71 Combobox.padding -sticky nswe -children {
7272 Combobox.background -sticky nswe -children {
73 Combobox.focus -expand 1 -sticky nswe -children {
73 Combobox.focus -sticky nswe -children {
7474 Combobox.textarea -sticky nswe
7575 }
7676 }
137137 Spinbox.background -sticky news -children {
138138 Spinbox.padding -sticky news -children {
139139 Spinbox.innerbg -sticky news -children {
140 Spinbox.textarea -expand 1
140 Spinbox.textarea
141141 }
142142 }
143143 Spinbox.uparrow -side top -sticky ens
150150 -selectforeground [list !focus SystemWindowText] \
151151 ;
152152
153
153
154154 # SCROLLBAR elements (Vista includes a state for 'hover')
155155 ttk::style element create Vertical.Scrollbar.uparrow vsapi \
156156 SCROLLBAR 1 {disabled 4 pressed 3 active 2 hover 17 {} 1} \
195195 Vertical.Progressbar.pbar -side bottom -sticky we
196196 }
197197 }
198
198
199199 # Scale
200200 ttk::style element create Horizontal.Scale.slider vsapi \
201201 TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
202202 -width 6 -height 12
203203 ttk::style layout Horizontal.TScale {
204 Scale.focus -expand 1 -sticky nswe -children {
205 Horizontal.Scale.trough -expand 1 -sticky nswe -children {
204 Scale.focus -sticky nswe -children {
205 Horizontal.Scale.trough -sticky nswe -children {
206206 Horizontal.Scale.track -sticky we
207207 Horizontal.Scale.slider -side left -sticky {}
208208 }
212212 TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
213213 -width 12 -height 6
214214 ttk::style layout Vertical.TScale {
215 Scale.focus -expand 1 -sticky nswe -children {
216 Vertical.Scale.trough -expand 1 -sticky nswe -children {
215 Scale.focus -sticky nswe -children {
216 Vertical.Scale.trough -sticky nswe -children {
217217 Vertical.Scale.track -sticky ns
218218 Vertical.Scale.slider -side top -sticky {}
219219 }
220220 }
221221 }
222
222
223223 # Treeview
224224 ttk::style configure Item -padding {4 0 0 0}
225
225
226226 package provide ttk::theme::vista 1.0
227227 }
228228 }
2626 ttk::style configure TNotebook -tabmargins {2 2 2 0}
2727 ttk::style map TNotebook.Tab \
2828 -expand [list selected {2 2 2 2}]
29
30 # Treeview:
31 ttk::style configure Heading -font TkHeadingFont
32 ttk::style configure Treeview -background SystemWindow
33 ttk::style map Treeview \
34 -background [list selected SystemHighlight] \
35 -foreground [list selected SystemHighlightText] ;
3629
3730 ttk::style configure TLabelframe.Label -foreground "#0046d5"
3831
0 <!doctype htmL>
1 <html>
2 <head>
3 </head>
4 <body style="font-size:120%;font-family:Arial,sans-serif;">
5 <p>
6 Tcl and Tk are distributed under a modified BSD license:<br>
7 <a href="https:www.tcl.tk/software/tcltk/license.html">
8 https:www.tcl.tk/software/tcltk/license.html
9 </a>
10 </p>
11 <ul style="list-style-type:none;">
12 <li>&copy; 1987-@TK_YEAR@ Tcl Core Team and Contributers.</li>
13 <li>&copy; 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.</li>
14 <li>&copy; 2014-@TK_YEAR@ Marc Culler.</li>
15 <li>&copy; 2002-2012 Daniel A. Steffen.</li>
16 <li>&copy; 2001-2009 Apple Inc.</li>
17 <li>&copy; 2001-2002 Jim Ingham &amp; Ian Reid.</li>
18 <li>&copy; 1998-2000 Jim Ingham &amp; Ray Johnson.</li>
19 <li>&copy; 1998-2000 Scriptics Inc.</li>
20 <li>&copy; 1996-1997 Sun Microsystems Inc.</li>
21 </ul>
22 </body>
23 </html>
2424 EXTRA_MAKE_ARGS ?=
2525
2626 INSTALL_PATH ?= /Library/Frameworks
27 TCL_INSTALL_PATH ?= ${INSTALL_PATH}/Tcl.framework
2728 APPLICATION_INSTALL_PATH ?= /Applications/Utilities
2829 PREFIX ?= /usr/local
2930 BINDIR ?= ${PREFIX}/bin
4142
4243 # set to non-empty value to build TkX11 instead of TkAqua:
4344 TK_X11 ?=
45
46 # Checks and overrides for subframework builds
47 ifeq (${SUBFRAMEWORK}_${TK_X11},1_)
48 ifeq (${DYLIB_INSTALL_DIR},)
49 @echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false
50 endif
51 ifeq (${DESTDIR},)
52 @echo "Cannot install subframework with empty DESTDIR !" && false
53 endif
54 override BUILD_DIR = ${DESTDIR}/build
55 override INSTALL_PATH = /Frameworks
56 endif
4457
4558 #-------------------------------------------------------------------------------------------------------
4659 # meta targets
106119 wish := wish
107120 WISH = wish${VERSION}
108121
109 BUILD_TARGET := all tktest
122 BUILD_TARGET := binaries libraries tktest
110123 INSTALL_TARGET := install
111124
112125 ifneq ($(wildcard $(subst ${space},\ ,${TCL_BUILD_DIR})/tclConfig.sh),)
114127 TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/..
115128 MAKE_VARS :=
116129 else
117 TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework
130 TCL_DIR := ${TCL_INSTALL_PATH}
118131 TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION}
119132 MAKE_VARS := TCL_EXE
120133 export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR}
209222 ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_)
210223 @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false
211224 endif
225 ifeq (${SUBFRAMEWORK}_${DYLIB_INSTALL_DIR},1_)
226 @echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false
227 endif
212228 ifeq (${EMBEDDED_BUILD},1)
213229 @rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tk.framework"
230 endif
231 ifeq (${SUBFRAMEWORK},1)
232 @rm -rf "${INSTALL_ROOT}/Frameworks/Tk.framework"
214233 endif
215234 ${DO_MAKE}
216235 ifeq (${EMBEDDED_BUILD}_${TK_X11},1_)
226245 else
227246 # install wish symbolic link
228247 @ln -fs ${WISH} "${INSTALL_ROOT}${BINDIR}/${wish}"
229 endif
230 endif
248 endif # embedded
249 endif # install
231250 ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_)
232251 # keep copy of debug library around, so that
233252 # Deployment build can be installed on top
235254 # the debug library
236255 @cd "${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}" && \
237256 ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug"
238 endif
257 endif # Development, not embedded
239258 ifeq (${TK_X11},)
259 ifeq (${SUBFRAMEWORK},)
240260 ifeq (${EMBEDDED_BUILD},)
241261 # install Wish.app link in APPLICATION_INSTALL_PATH and setup 'Wish Shell' compatibility links
242262 @cd "${TOP_DIR}" && if [ -n "${APP_DIR}" ]; then mkdir -p "./${APP_DIR}" && rm -rf "./${APP_DIR}/Wish.app" && \
270290 fix_install_name MacOS/Wish Tcl && fix_install_name MacOS/Wish Tk
271291 ifeq (${INSTALL_BUILD},1)
272292 @cd "${TOP_DIR}" && rm -rf "./${FMWK_DIR}"/T{cl,k}.framework && rmdir -p "./${FMWK_DIR}" 2>&- || true
273 endif
274 endif
275 endif
293 endif # install not subframework
294 endif # embedded
295 endif # not subframework
296 endif # not X11
276297
277298 clean-${PROJECT}: %-${PROJECT}:
278299 ${DO_MAKE}
274274 Tk now provides the following semantic colors as system colors:
275275 systemTextColor, systemTextBackgroundColor, systemSelectedTextColor,
276276 systemSelectedTextBackgroundColor, systemControlTextColor,
277 systemDisabledControlTextColor, systemLabelColor, and
278 systemControlAccentColor. All of these except the last two were
279 present in OSX 10.0 (and those two are simulated in systems where they
277 systemDisabledControlTextColor, systemLabelColor, systemLinkColor, and
278 systemControlAccentColor. All of these except the last three were
279 present in OSX 10.0 (and those three are simulated in systems where they
280280 do not exist). The change in 10.14 was that the RGB color value of
281281 these colors became dynamic, meaning that the color value can change
282282 when the application appearance changes. In particular, when a user
454454 TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
455455 The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3.
456456
457 - To build a Tcl.framework and Tk.framework for use as subframeworks in another
458 framework, use the install-embedded target and set SUBFRAMEWORK=1. Set the
459 DYLIB_INSTALL_DIR variable to the path which should be the install_name path of
460 the shared library and set the DESTDIR variable to the pathname of a staging
461 directory where the frameworks will be written. The Tcl framework must be
462 built first.
463 For example, running the commands:
464 make -C ../tcl8.6/macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \
465 DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tcl.framework
466 make -C macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \
467 DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tk.framework
468 will produce a Tcl.framework and a Tk.framework usable as subframeworks of
469 Some.framework. The frameworks will be found in /tmp/tcltk/Frameworks/
470
457471 5. Details regarding the macOS port of Tk.
458472 -------------------------------------------
459473
661675 windows are redrawn within the DisplayText function by some
662676 conditional code which is only used for macOS.
663677
664 6.0 Virtual events on 10.14
665 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
666
667 10.14 supports system appearance changes, and has added a "Dark Mode"
668 that casts all window frames and menus as black. Tk 8.6.9 has added two
669 virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update
670 your Tk app's appearance when the system appearance changes. Just bind
671 your appearance-updating code to these virtual events and you will see
672 it triggered when the system appearance toggles between dark and light.
678 6.0 Virtual events on macOS 10.14 and later
679 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
680
681 The 10.14 release added support for system appearance changes,
682 including a "Dark Mode" that renders all window frames and menus in
683 dark colors. Tk 8.6.11 provides three virtual events <<LightAqua>>,
684 <<DarkAqua>> and <<AppearanceChanged>>, to allow you to update your Tk
685 app's appearance when the system appearance changes. These events are
686 generated in [NSView effectiveAppearanceChanged], which is called by
687 the Apple window manager when the General Preferences is changed
688 either by switching between Light Mode and Dark Mode or by changing
689 the Accent Color or Highlight Color.
690
691 The <<AppearanceChanged>> virtual event has a data string which can be
692 accessed with the %d substitution. The format of the data string is
693 that it consists of 6 words:
694 "Appearance XXXX Accent YYYY Highlight ZZZZ"
695 For example, the following code will print the current appearance
696 name, accent color and highlight color when the <<AppearanceChanged>>
697 virtual event fires:
698
699 bind . <<AppearanceChanged>> {
700 array set data [split %d]
701 puts " Appearance: $data(Appearance)"
702 puts " Accent: $data(Accent)"
703 puts " Highlight: $data(Highlight)\n"
704 }
705
706
673707
674708 7.0 Mac Services
675709 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
14101410 F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = "<group>"; };
14111411 F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = "<group>"; };
14121412 F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = "<group>"; };
1413 F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = "<group>"; };
1413 F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = "<group>"; };
14141414 F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = "<group>"; };
14151415 F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = "<group>"; };
14161416 F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = "<group>"; };
30773077 F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */,
30783078 F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */,
30793079 F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */,
3080 F96D3E2208F272A5004A47F5 /* CrtSlave.3 */,
3080 F96D3E2208F272A5004A47F5 /* CrtAlias.3 */,
30813081 F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */,
30823082 F96D3E2408F272A5004A47F5 /* CrtTrace.3 */,
30833083 F96D3E2508F272A5004A47F5 /* dde.n */,
14101410 F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = "<group>"; };
14111411 F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = "<group>"; };
14121412 F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = "<group>"; };
1413 F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = "<group>"; };
1413 F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = "<group>"; };
14141414 F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = "<group>"; };
14151415 F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = "<group>"; };
14161416 F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = "<group>"; };
30773077 F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */,
30783078 F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */,
30793079 F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */,
3080 F96D3E2208F272A5004A47F5 /* CrtSlave.3 */,
3080 F96D3E2208F272A5004A47F5 /* CrtAlias.3 */,
30813081 F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */,
30823082 F96D3E2408F272A5004A47F5 /* CrtTrace.3 */,
30833083 F96D3E2508F272A5004A47F5 /* dde.n */,
22862286 TK_VERSION=8.6
22872287 TK_MAJOR_VERSION=8
22882288 TK_MINOR_VERSION=6
2289 TK_PATCH_LEVEL=".10"
2289 TK_PATCH_LEVEL=".11"
22902290 VERSION=${TK_VERSION}
22912291 LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
22922292
24302430 { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
24312431 $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
24322432 fi
2433
2434 # eval is required to do the TCL_DBGX substitution
2435 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
2436 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
24372433
24382434 # If the TCL_BIN_DIR is the build directory (not the install directory),
24392435 # then set the common variable name to the value of the build variables.
24672463 ;;
24682464 esac
24692465 fi
2470
2471 # eval is required to do the TCL_DBGX substitution
2472 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
2473 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
2474 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
2475 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
24762466
24772467
24782468
42854275 tcl_ok=yes
42864276 fi
42874277
4288
4289 if test "${enable_shared+set}" = set; then
4290 enableval="$enable_shared"
4291 tcl_ok=$enableval
4292 else
4293 tcl_ok=yes
4294 fi
4295
42964278 if test "$tcl_ok" = "yes" ; then
42974279 { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5
42984280 $as_echo "shared" >&6; }
46064588 if test "$GCC" = yes; then :
46074589
46084590 CFLAGS_OPTIMIZE=-O2
4609 CFLAGS_WARNING="-Wall"
4591 CFLAGS_WARNING="-Wall -Wpointer-arith"
46104592
46114593 else
46124594
48744856 CC_SEARCH_FLAGS=""
48754857 LD_SEARCH_FLAGS=""
48764858 ;;
4877 CYGWIN_*|MINGW32*)
4859 CYGWIN_*|MINGW32_*|MSYS_*)
48784860 SHLIB_CFLAGS=""
48794861 SHLIB_LD='${CC} -shared'
48804862 SHLIB_SUFFIX=".dll"
48854867 CC_SEARCH_FLAGS=""
48864868 LD_SEARCH_FLAGS=""
48874869 TCL_NEEDS_EXP_FILE=1
4888 TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
4870 TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
48894871 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a"
48904872 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cygwin version of gcc" >&5
48914873 $as_echo_n "checking for Cygwin version of gcc... " >&6; }
50915073 SHLIB_LD='${CC} -shared'
50925074 if test $doRpath = yes; then :
50935075
5094 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5076 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
50955077 fi
50965078 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
50975079 ;;
51815163
51825164 if test $doRpath = yes; then :
51835165
5184 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5166 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
51855167 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
51865168 fi
51875169 ;;
51995181
52005182 if test $doRpath = yes; then :
52015183
5202 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5184 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
52035185 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
52045186 fi
52055187 if test "$GCC" = yes; then :
52365218
52375219 if test $doRpath = yes; then :
52385220
5239 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5221 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
52405222 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
52415223 fi
52425224
52765258 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
52775259 if test $doRpath = yes; then :
52785260
5279 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5261 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
52805262 fi
52815263 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
52825264 if test "`uname -m`" = "alpha"; then :
53435325 LD_FLAGS="-Wl,--export-dynamic"
53445326 if test $doRpath = yes; then :
53455327
5346 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5347 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5328 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
5329 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
53485330 fi
53495331 ;;
53505332 MP-RAS-02*)
53845366 DL_LIBS=""
53855367 if test $doRpath = yes; then :
53865368
5387 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5369 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
53885370 fi
53895371 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
53905372 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
54125394 LDFLAGS="$LDFLAGS -export-dynamic"
54135395 if test $doRpath = yes; then :
54145396
5415 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5397 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
54165398 fi
54175399 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
54185400 if test "${TCL_THREADS}" = "1"; then :
54325414 SHLIB_SUFFIX=".so"
54335415 DL_OBJS="tclLoadDl.o"
54345416 DL_LIBS=""
5435 LDFLAGS=""
54365417 if test $doRpath = yes; then :
54375418
5438 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5439 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5419 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
5420 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
54405421 fi
54415422 if test "${TCL_THREADS}" = "1"; then :
54425423
56395620
56405621 $as_echo "#define MODULE_SCOPE __private_extern__" >>confdefs.h
56415622
5623 tcl_cv_cc_visibility_hidden=yes
56425624
56435625 fi
56445626 CC_SEARCH_FLAGS=""
58295811 DL_LIBS=""
58305812 if test $doRpath = yes; then :
58315813
5832 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5814 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
58335815 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
58345816 fi
58355817 if test "$GCC" = yes; then :
62326214 case $system in
62336215 AIX-*) ;;
62346216 BSD/OS*) ;;
6235 CYGWIN_*|MINGW32_*) ;;
6217 CYGWIN_*|MINGW32_*|MSYS_*) ;;
62366218 IRIX*) ;;
62376219 NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
62386220 Darwin-*) ;;
62626244 if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""; then :
62636245
62646246 LIB_SUFFIX=${SHARED_LIB_SUFFIX}
6265 MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
6247 MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
62666248 if test "${SHLIB_SUFFIX}" = ".dll"; then :
62676249
62686250 INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
64036385 fi
64046386
64056387 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
6406 DBGX=""
64076388 if test "$tcl_ok" = "no"; then
64086389 CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
64096390 LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
73837364 int
73847365 main ()
73857366 {
7386 struct passwd pwd; pwd.pw_gecos;
7367 struct passwd pwd; (void)pwd.pw_gecos;
73877368 ;
73887369 return 0;
73897370 }
86678648 echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000'
86688649 TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist'
86698650 EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist'
8651 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html'
8652 if test "${SHARED_BUILD}" = "0"; then
8653 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -ObjC'
8654 fi
86708655 EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic'
8671 ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in"
8656 ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in"
86728657
86738658 for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done
86748659 TK_YEAR="`date +%Y`"
87028687 EXTRA_INSTALL="install-private-headers html-tk"
87038688 EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
87048689 EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
8690 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"'
87058691 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
87068692 if test $tk_aqua = yes; then
87078693 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
87118697 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
87128698 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
87138699 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
8700 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"'
87148701 fi
87158702 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
87168703 # Don't use AC_DEFINE for the following as the framework version define
95249511 "tkConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS tkConfig.h:../unix/tkConfig.h.in" ;;
95259512 "Tk-Info.plist") CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../macosx/Tk-Info.plist.in" ;;
95269513 "Wish-Info.plist") CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../macosx/Wish-Info.plist.in" ;;
9514 "Credits.html") CONFIG_FILES="$CONFIG_FILES Credits.html:../macosx/Credits.html.in" ;;
95279515 "Tk.framework") CONFIG_COMMANDS="$CONFIG_COMMANDS Tk.framework" ;;
95289516 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:../unix/Makefile.in" ;;
95299517 "tkConfig.sh") CONFIG_FILES="$CONFIG_FILES tkConfig.sh:../unix/tkConfig.sh.in" ;;
2525 typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window);
2626 typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
2727 typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window);
28 typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn);
28 typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, void *rgn);
2929 typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner);
3030
3131 #include "tkPlatDecls.h"
4343 {"stop", kAlertStopIcon},
4444 {"note", kAlertNoteIcon},
4545 {"caution", kAlertCautionIcon},
46 {NULL}
46 {NULL, 0}
4747 };
4848
4949 #define builtInIconSize 32
9999 name = Tk_GetUid(builtInPtr->name);
100100 predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
101101 if (isNew) {
102 TkPredefBitmap *predefPtr = ckalloc(sizeof(TkPredefBitmap));
102 TkPredefBitmap *predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap));
103103
104104 predefPtr->source = UINT2PTR(builtInPtr->iconType);
105105 predefPtr->width = builtInIconSize;
135135 Pixmap pixmap;
136136
137137 pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0);
138 if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
138 if (TkMacOSXSetupDrawingContext(pixmap, NULL, &dc)) {
139139 if (dc.context) {
140140 CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
141141 .tx = 0, .ty = size.height};
142142 CGContextConcatCTM(dc.context, t);
143143 [NSGraphicsContext saveGraphicsState];
144 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
145 graphicsContextWithGraphicsPort:dc.context
146 flipped:NO]];
144 [NSGraphicsContext setCurrentContext:GET_NSCONTEXT(dc.context, NO)];
147145 [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
148146 operation:NSCompositeCopy fraction:1.0];
149147 [NSGraphicsContext restoreGraphicsState];
179177 NSImage *iconImage = [[NSWorkspace sharedWorkspace]
180178 iconForFileType: iconUTI];
181179 CGSize size = CGSizeMake(builtInIconSize, builtInIconSize);
182 Pixmap pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
180 Pixmap pixmap = PixmapFromImage(display, iconImage, size);
183181 return pixmap;
184182 }
185183
316314 OSType iconType;
317315 if (OSTypeFromString(name, &iconType) == TCL_OK) {
318316 NSString *iconUTI = OSTYPE_TO_UTI(iconType);
319 printf("Found image for UTI %s\n", iconUTI.UTF8String);
320317 NSImage *iconImage = [[NSWorkspace sharedWorkspace]
321318 iconForFileType: iconUTI];
322319 pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
343340
344341 int
345342 TkMacOSXIconBitmapObjCmd(
346 ClientData clientData, /* Unused. */
343 TCL_UNUSED(void *),
347344 Tcl_Interp *interp, /* Current interpreter. */
348345 int objc, /* Number of arguments. */
349346 Tcl_Obj *const objv[]) /* Argument objects. */
398395 }
399396 }
400397 #endif
401 ib.value = ckalloc(len + 1);
398 ib.value = (char *)ckalloc(len + 1);
402399 strcpy(ib.value, value);
403400 if (!iconBitmapTable.buckets) {
404401 Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS);
408405 iconBitmap = Tcl_GetHashValue(hPtr);
409406 ckfree(iconBitmap->value);
410407 } else {
411 iconBitmap = ckalloc(sizeof(IconBitmap));
408 iconBitmap = (IconBitmap *)ckalloc(sizeof(IconBitmap));
412409 Tcl_SetHashValue(hPtr, iconBitmap);
413410 }
414411 *iconBitmap = ib;
9494 const Tk_ClassProcs tkpButtonProcs = {
9595 sizeof(Tk_ClassProcs), /* size */
9696 TkButtonWorldChanged, /* worldChangedProc */
97 NULL,
98 NULL
9799 };
98100
99101 static int bCount;
142144 TkpCreateButton(
143145 Tk_Window tkwin)
144146 {
145 MacButton *macButtonPtr = ckalloc(sizeof(MacButton));
147 MacButton *macButtonPtr = (MacButton *)ckalloc(sizeof(MacButton));
146148
147149 Tk_CreateEventHandler(tkwin, ActivateMask,
148150 ButtonEventProc, macButtonPtr);
185187 DrawParams* dpPtr = &macButtonPtr->drawParams;
186188 int needhighlight = 0;
187189
188 if (butPtr->flags & BUTTON_DELETED) {
189 return;
190 }
191190 butPtr->flags &= ~REDRAW_PENDING;
192191 if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
193192 return;
194193 }
195194 pixmap = (Pixmap) Tk_WindowId(tkwin);
196
197 /*
198 * Set up clipping region. Make sure the we are using the port
199 * for this button, or we will set the wrong window's clip.
200 */
201
202 TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
203195
204196 if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) {
205197 macButtonPtr->useTkText = 0;
331323 haveText = 1;
332324 }
333325
334 if (haveImage && haveText) { /* Image and Text */
335 switch ((enum compound) butPtr->compound) {
336 case COMPOUND_TOP:
337 case COMPOUND_BOTTOM:
338 /*
339 * Image is above or below text.
340 */
341
342 height += txtHeight + butPtr->padY;
343 width = (width > txtWidth ? width : txtWidth);
344 break;
345 case COMPOUND_LEFT:
346 case COMPOUND_RIGHT:
347 /*
348 * Image is left or right of text.
349 */
350
351 width += txtWidth + 2*butPtr->padX;
352 height = (height > txtHeight ? height : txtHeight);
353 break;
354 case COMPOUND_CENTER:
355 /*
356 * Image and text are superimposed.
357 */
358
359 width = (width > txtWidth ? width : txtWidth);
360 height = (height > txtHeight ? height : txtHeight);
361 break;
362 default:
363 break;
364 }
365 width += butPtr->indicatorSpace;
366 } else if (haveImage) { /* Image only */
326 if (haveImage) {
327 if (haveText) { /* Image and Text */
328 switch ((enum compound) butPtr->compound) {
329 case COMPOUND_TOP:
330 case COMPOUND_BOTTOM:
331 /*
332 * Image is above or below text.
333 */
334
335 height += txtHeight + butPtr->padY;
336 width = (width > txtWidth ? width : txtWidth);
337 break;
338 case COMPOUND_LEFT:
339 case COMPOUND_RIGHT:
340 /*
341 * Image is left or right of text.
342 */
343
344 width += txtWidth + 2*butPtr->padX;
345 height = (height > txtHeight ? height : txtHeight);
346 break;
347 case COMPOUND_CENTER:
348 /*
349 * Image and text are superimposed.
350 */
351
352 width = (width > txtWidth ? width : txtWidth);
353 height = (height > txtHeight ? height : txtHeight);
354 break;
355 default:
356 break;
357 }
358 }
359 /* Image with or without text */
367360 width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace;
368361 height = butPtr->height > 0 ? butPtr->height : height;
369362 if (butPtr->type == TYPE_BUTTON) {
398391
399392 width += butPtr->inset*2;
400393 height += butPtr->inset*2;
401 if ([NSApp macMinorVersion] == 6) {
394 if ([NSApp macOSVersion] == 100600) {
402395 width += 12;
403396 }
404397 if (mbPtr->btnkind == kThemePushButton) {
464457
465458 pixmap = (Pixmap) Tk_WindowId(tkwin);
466459
467 if (butPtr->image != None) {
460 if (butPtr->image != NULL) {
468461 Tk_SizeOfImage(butPtr->image, &width, &height);
469462 haveImage = 1;
470463 } else if (butPtr->bitmap != None) {
480473 }
481474
482475 haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
483 if (haveImage && haveText) { /* Image and Text */
476 if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */
484477 int x, y;
485478
486479 switch ((enum compound) butPtr->compound) {
725718 static void
726719 TkMacOSXDrawButton(
727720 MacButton *mbPtr, /* Mac button. */
728 GC gc, /* The GC we are drawing into - needed for
721 TCL_UNUSED(GC), /* The GC we are drawing into - needed for
729722 * the bevel button */
730723 Pixmap pixmap) /* The pixmap we are drawing into - needed
731724 * for the bevel button */
750743
751744 ButtonBackgroundDrawCB(&cntrRect, mbPtr, 32, true);
752745
753 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
746 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
754747 return;
755748 }
756749
783776 ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo,
784777 (MacButton *) mbPtr, 32, true);
785778 } else {
786 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
779 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
787780 return;
788781 }
789782
811804
812805 static void
813806 ButtonBackgroundDrawCB(
814 const HIRect *btnbounds,
807 TCL_UNUSED(const HIRect *),
815808 MacButton *ptr,
816 SInt16 depth,
817 Boolean isColorDev)
809 TCL_UNUSED(SInt16),
810 TCL_UNUSED(Boolean))
818811 {
819812 MacButton *mbPtr = (MacButton *) ptr;
820813 TkButton *butPtr = (TkButton *) mbPtr;
863856 */
864857 static void
865858 ButtonContentDrawCB (
866 const HIRect * btnbounds,
867 ThemeButtonKind kind,
868 const HIThemeButtonDrawInfo *drawinfo,
859 TCL_UNUSED(const HIRect *),
860 TCL_UNUSED(ThemeButtonKind),
861 TCL_UNUSED(const HIThemeButtonDrawInfo *),
869862 MacButton *ptr,
870 SInt16 depth,
871 Boolean isColorDev)
863 TCL_UNUSED(SInt16),
864 TCL_UNUSED(Boolean))
872865 {
873866 TkButton *butPtr = (TkButton *) ptr;
874867 Tk_Window tkwin = butPtr->tkwin;
10461039 if (drawinfo->state != kThemeStatePressed) {
10471040 drawinfo->adornment |= kThemeAdornmentDefault;
10481041 }
1049 if (!mbPtr->defaultPulseHandler) {
1042
1043 /*
1044 * Older macOS systems (10.9 and earlier) use an animation to
1045 * indicate the active button. This is simulated by redrawing
1046 * the button periodically.
1047 */
1048
1049 if (!mbPtr->defaultPulseHandler && ([NSApp macOSVersion] <= 100900)) {
10501050 mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
10511051 PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr);
10521052 }
11761176 MacButton *mbPtr = clientData;
11771177
11781178 TkpDisplayButton(clientData);
1179 /*
1180 * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled
1181 * in case the button is destroyed and has its data freed before the idle
1182 * event is handled (DestroyButton only cancels calls when REDRAW_PENDING
1183 * is set, which is not the case after calling TkpDisplayButton directly).
1184 */
1185 Tcl_CancelIdleCall(TkpDisplayButton, clientData);
11791186 mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
11801187 PULSE_TIMER_MSECS, PulseDefaultButtonProc, clientData);
11811188 }
3434 targetPtr->type == dispPtr->utf8Atom) {
3535 for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr;
3636 cbPtr; cbPtr = cbPtr->nextPtr) {
37 NSString *s = TclUniToNSString(cbPtr->buffer, cbPtr->length);
37 NSString *s = [[TKNSString alloc]
38 initWithTclUtfBytes:cbPtr->buffer
39 length:cbPtr->length];
3840 [string appendString:s];
3941 [s release];
4042 }
134136 string = [pb stringForType:type];
135137 }
136138 if (string) {
137
138 /*
139 * Encode the string using the encoding which is used in Tcl
140 * when TCL_UTF_MAX = 3. This replaces each UTF-16 surrogate with
141 * a 3-byte sequence generated using the UTF-8 algorithm. (Even
142 * though UTF-8 does not allow encoding surrogates, the algorithm
143 * does produce a 3-byte sequence.)
144 */
145
146 char *bytes = NSStringToTclUni(string, NULL);
147 result = proc(clientData, interp, bytes);
148 if (bytes) {
149 ckfree(bytes);
139 if (target == dispPtr->utf8Atom) {
140 result = proc(clientData, interp, string.UTF8String);
141 } else if (target == XA_STRING) {
142 const char *latin1 = [string
143 cStringUsingEncoding:NSISOLatin1StringEncoding];
144 result = proc(clientData, interp, latin1);
150145 }
151146 }
152147 } else {
153148 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
154 "%s selection doesn't exist or form \"%s\" not defined",
155 Tk_GetAtomName(tkwin, selection),
156 Tk_GetAtomName(tkwin, target)));
149 "%s selection doesn't exist or form \"%s\" not defined",
150 Tk_GetAtomName(tkwin, selection),
151 Tk_GetAtomName(tkwin, target)));
157152 Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
158153 }
159154 return result;
181176 Display *display, /* X Display. */
182177 Atom selection, /* What selection to own. */
183178 Window owner, /* Window to be the owner. */
184 Time time) /* The current time? */
179 TCL_UNUSED(Time)) /* The current time? */
185180 {
186181 TkDisplay *dispPtr = TkGetDisplayList();
187182
241236
242237 void
243238 TkSelUpdateClipboard(
244 TkWindow *winPtr, /* Window associated with clipboard. */
245 TkClipboardTarget *targetPtr)
239 TCL_UNUSED(TkWindow *), /* Window associated with clipboard. */
240 TCL_UNUSED(TkClipboardTarget *))
246241 /* Info about the content. */
247242 {
248243 NSPasteboard *pb = [NSPasteboard generalPasteboard];
270265 void
271266 TkSelEventProc(
272267 Tk_Window tkwin, /* Window for which event was targeted. */
273 register XEvent *eventPtr) /* X event: either SelectionClear,
268 XEvent *eventPtr) /* X event: either SelectionClear,
274269 * SelectionRequest, or SelectionNotify. */
275270 {
276271 if (eventPtr->type == SelectionClear) {
298293
299294 void
300295 TkSelPropProc(
301 register XEvent *eventPtr) /* X PropertyChange event. */
296 TCL_UNUSED(XEvent *)) /* X PropertyChange event. */
302297 {
303298 }
304299
00 /*
1 * tkMacOSXColor.c --
1 * TkMacOSXColor.c --
22 *
33 * This file maintains a database of color values for the Tk
44 * toolkit, in order to avoid round-trips to the server to
88 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
99 * Copyright 2001-2009, Apple Inc.
1010 * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
11 * Copyright (c) 2020 Marc Culler
1112 *
1213 * See the file "license.terms" for information on usage and redistribution
1314 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1516
1617 #include "tkMacOSXPrivate.h"
1718 #include "tkColor.h"
18
19 /*
20 * The colorType specifies how the color value should be interpreted. For the
21 * unique rgbColor entry, the RGB values are generated from the pixel value of
22 * an XColor. The ttkBackground and semantic types are dynamic, meaning
23 * that they change when dark mode is enabled on OSX 10.13 and later.
24 */
25
26 enum colorType {
27 clearColor, /* There should be only one of these. */
28 rgbColor, /* There should be only one of these. */
29 appearance, /* There should be only one of these. */
30 HIBrush, /* The value is a HITheme brush color table index. */
31 HIText, /* The value is a HITheme text color table index. */
32 HIBackground, /* The value is a HITheme background color table index. */
33 ttkBackground, /* The value can be used as a parameter.*/
34 semantic, /* The value can be used as a parameter.*/
35 };
36
37 /*
38
39 */
40
41 struct SystemColorMapEntry {
42 const char *name;
43 enum colorType type;
44 long value;
45 }; /* unsigned char pixelCode; */
46
47 /*
48 * Array of system color definitions: the array index is required to equal the
49 * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept
50 * in sync with the public pixel code values in tkMacOSXPort.h !
51 */
52
53 #define MIN_PIXELCODE 30
54 static const struct SystemColorMapEntry systemColorMap[] = {
55 { "Transparent", clearColor, 0 }, /* 30: TRANSPARENT_PIXEL */
56 { "Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 31 */
57 { "HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 32 */
58 { "HighlightText", HIBrush, kThemeBrushBlack }, /* 33 */
59 { "HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 34 */
60 { "ButtonText", HIText, kThemeTextColorPushButtonActive }, /* 35 */
61 { "PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 36 */
62 { "ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, /* 37 */
63 { "SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 38 */
64 { "ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, /* 39 */
65 { "AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 40 */
66 { "WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, /* 41 */
67 { "SheetBackground", HIBrush, kThemeBrushSheetBackground }, /* 42 */
68 { "MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 43 */
69 { "Black", HIBrush, kThemeBrushBlack }, /* 44 */
70 { "MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, /* 45 */
71 { "White", HIBrush, kThemeBrushWhite }, /* 46 */
72 { "Menu", HIBrush, kThemeBrushMenuBackground }, /* 47 */
73 { "DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, /* 48 */
74 { "MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, /* 49 */
75 { "DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, /* 50 */
76 { "MenuText", HIText, kThemeTextColorMenuItemActive }, /* 51 */
77 { "AppearanceColor", appearance, 0 }, /* 52: APPEARANCE_PIXEL */
78 { "AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, /* 53 */
79 { "AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, /* 54 */
80 { "ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, /* 55 */
81 { "ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, /* 56 */
82 { "UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, /* 57 */
83 { "UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, /* 58 */
84 { "ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, /* 59 */
85 { "ListViewBackground", HIBrush, kThemeBrushListViewBackground }, /* 60 */
86 { "IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, /* 61 */
87 { "ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, /* 62 */
88 { "ChasingArrows", HIBrush, kThemeBrushChasingArrows }, /* 63 */
89 { "DragHilite", HIBrush, kThemeBrushDragHilite }, /* 64 */
90 { "DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, /* 65 */
91 { "FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, /* 66 */
92 { "ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, /* 67 */
93 { "ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, /* 68 */
94 { "FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, /* 69 */
95 { "PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, /* 70 */
96 { "PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, /* 71 */
97 { "PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, /* 72 */
98 { "AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, /* 73 */
99 { "IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, /* 74 */
100 { "StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, /* 75 */
101 { "ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, /* 76 */
102 { "ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, /* 77 */
103 { "ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, /* 78 */
104 { "ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, /* 79 */
105 { "ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, /* 80 */
106 { "ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, /* 81 */
107 { "ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, /* 82 */
108 { "ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, /* 83 */
109 { "ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, /* 84 */
110 { "ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, /* 85 */
111 { "ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, /* 86 */
112 { "ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, /* 87 */
113 { "ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, /* 88 */
114 { "ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, /* 89 */
115 { "ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, /* 90 */
116 { "ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, /* 91 */
117 { "ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, /* 92 */
118 { "ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, /* 93 */
119 { "BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, /* 94 */
120 { "BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, /* 95 */
121 { "BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, /* 96 */
122 { "BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, /* 97 */
123 { "NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, /* 98 */
124 { "MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, /* 99 */
125 { "SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, /* 100 */
126 { "DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, /* 101 */
127 { "ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, /* 102 */
128 { "SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, /* 103 */
129 { "MenuBackground", HIBrush, kThemeBrushMenuBackground }, /* 104 */
130 { "Pixel", rgbColor, 0 }, /* 105: PIXEL_MAGIC */
131 { "MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 106 */
132 { "ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, /* 107 */
133 { "ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, /* 108 */
134 { "ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, /* 109 */
135 { "BlackText", HIText, kThemeTextColorBlack }, /* 110 */
136 { "DialogActiveText", HIText, kThemeTextColorDialogActive }, /* 111 */
137 { "DialogInactiveText", HIText, kThemeTextColorDialogInactive }, /* 112 */
138 { "AlertActiveText", HIText, kThemeTextColorAlertActive }, /* 113 */
139 { "AlertInactiveText", HIText, kThemeTextColorAlertInactive }, /* 114 */
140 { "ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, /* 115 */
141 { "ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, /* 116 */
142 { "WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, /* 117 */
143 { "WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, /* 118 */
144 { "PlacardActiveText", HIText, kThemeTextColorPlacardActive }, /* 119 */
145 { "PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, /* 120 */
146 { "PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, /* 121 */
147 { "PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, /* 122 */
148 { "PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, /* 123 */
149 { "PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, /* 124 */
150 { "BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, /* 125 */
151 { "BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, /* 126 */
152 { "BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, /* 127 */
153 { "PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, /* 128 */
154 { "PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, /* 129 */
155 { "PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, /* 130 */
156 { "IconLabelText", HIText, kThemeTextColorIconLabel }, /* 131 */
157 { "ListViewText", HIText, kThemeTextColorListView }, /* 132 */
158 { "DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, /* 133 */
159 { "DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, /* 134 */
160 { "MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, /* 135 */
161 { "MovableModalWindowTitleInactiveText",HIText, kThemeTextColorMovableModalWindowTitleInactive }, /* 136 */
162 { "UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, /* 137 */
163 { "UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, /* 138 */
164 { "PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, /* 139 */
165 { "PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, /* 140 */
166 { "RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, /* 141 */
167 { "RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, /* 142 */
168 { "RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, /* 143 */
169 { "MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, /* 144 */
170 { "MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, /* 145 */
171 { "MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, /* 146 */
172 { "PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, /* 147 */
173 { "PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, /* 148 */
174 { "TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, /* 149 */
175 { "TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, /* 150 */
176 { "TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, /* 151 */
177 { "TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, /* 152 */
178 { "TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, /* 153 */
179 { "IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, /* 154 */
180 { "BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, /* 155 */
181 { "BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, /* 156 */
182 { "NotificationText", HIText, kThemeTextColorNotification }, /* 157 */
183 { "SystemDetailText", HIText, kThemeTextColorSystemDetail }, /* 158 */
184 { "WhiteText", HIText, kThemeTextColorWhite }, /* 159 */
185 { "TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, /* 160 */
186 { "PlacardBackground", HIBackground, kThemeBackgroundPlacard }, /* 161 */
187 { "WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, /* 162 */
188 { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */
189 { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */
190 { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */
19 #include "tkMacOSXColor.h"
20
21 static Tcl_HashTable systemColors;
22 static int numSystemColors;
23 static int rgbColorIndex;
24 static int controlAccentIndex;
25 static int selectedTabTextIndex;
26 static Bool useFakeAccentColor = NO;
27 static SystemColorDatum **systemColorIndex;
28 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
29 static NSAppearance *lightAqua = nil;
30 static NSAppearance *darkAqua = nil;
31 #endif
32 static NSColorSpace* sRGB = NULL;
33 static const CGFloat WINDOWBACKGROUND[4] =
34 {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
35
36 void initColorTable()
37 {
38 NSAutoreleasePool *pool = [NSAutoreleasePool new];
39 Tcl_InitHashTable(&systemColors, TCL_STRING_KEYS);
40 SystemColorDatum *entry, *oldEntry;
41 Tcl_HashSearch search;
42 Tcl_HashEntry *hPtr;
43 int newPtr, index = 0;
44 NSColorList *systemColorList = [NSColorList colorListNamed:@"System"];
45 NSString *key;
46
47 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
48 if (@available(macOS 10.14, *)) {
49 darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
50 lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
51 }
52 #endif
19153
19254 /*
193 * Colors based on "semantic" NSColors.
55 * Build a hash table for looking up a color by its name.
56 * First add all of the static entries from tkMacOSXColor.h
19457 */
19558
196 { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */
197 { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */
198 { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */
199 { "WindowBackgroundColor3", ttkBackground, 3 }, /* 169 */
200 { "WindowBackgroundColor4", ttkBackground, 4 }, /* 170 */
201 { "WindowBackgroundColor5", ttkBackground, 5 }, /* 171 */
202 { "WindowBackgroundColor6", ttkBackground, 6 }, /* 172 */
203 { "WindowBackgroundColor7", ttkBackground, 7 }, /* 173 */
204 { "TextColor", semantic, 0 }, /* 174 */
205 { "SelectedTextColor", semantic, 1 }, /* 175 */
206 { "LabelColor", semantic, 2 }, /* 176 */
207 { "ControlTextColor", semantic, 3 }, /* 177 */
208 { "DisabledControlTextColor", semantic, 4 }, /* 178 */
209 { "SelectedTabTextColor", semantic, 5 }, /* 179 */
210 { "TextBackgroundColor", semantic, 6 }, /* 180 */
211 { "SelectedTextBackgroundColor", semantic, 7 }, /* 181 */
212 { "ControlAccentColor", semantic, 8 }, /* 182 */
213 { NULL, 0, 0 }
214 };
215 #define FIRST_SEMANTIC_COLOR 166
216 #define MAX_PIXELCODE 182
217
218 /*
219 *----------------------------------------------------------------------
220 *
221 * GetEntryFromPixelCode --
222 *
223 * Extract a SystemColorMapEntry from the table.
224 *
225 * Results:
226 * Returns false if the code is out of bounds.
59 for (entry = systemColorData; entry->name != NULL; entry++) {
60 hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr);
61 if (entry->type == semantic) {
62 NSString *colorName = [[NSString alloc]
63 initWithCString:entry->macName
64 encoding:NSUTF8StringEncoding];
65 SEL colorSelector = NSSelectorFromString(colorName);
66 if (![NSColor respondsToSelector:colorSelector]) {
67 if ([colorName isEqualToString:@"controlAccentColor"]) {
68 useFakeAccentColor = YES;
69 } else if (![colorName isEqualToString:@"selectedTabTextColor"]) {
70 /* Uncomment to print all unsupported colors: */
71 /* printf("Unsupported color %s\n", colorName.UTF8String); */
72 continue;
73 }
74 }
75 entry->selector = [colorName retain];
76 }
77 if (newPtr == 0) {
78 oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
79 entry->index = oldEntry->index;
80 [oldEntry->selector release];
81 } else {
82 entry->index = index++;
83 }
84 Tcl_SetHashValue(hPtr, entry);
85 }
86
87 /*
88 * Add all of the colors in the System ColorList.
89 */
90
91 for (key in [systemColorList allKeys]) {
92 int length = [key lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
93 char *name;
94 entry = (SystemColorDatum *)ckalloc(sizeof(SystemColorDatum));
95 bzero(entry, sizeof(SystemColorDatum));
96 name = (char *)ckalloc(length + 1);
97 strcpy(name, key.UTF8String);
98 name[0] = toupper(name[0]);
99 if (!strcmp(name, "WindowBackgroundColor")) {
100
101 /*
102 * Avoid black windows on old systems.
103 */
104
105 continue;
106 }
107 entry->type=semantic;
108 entry->name = name;
109 entry->selector = [key retain];
110 hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr);
111 if (newPtr == 0) {
112 oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
113 entry->index = oldEntry->index;
114 [oldEntry->selector release];
115 } else {
116 entry->index = index++;
117 }
118 Tcl_SetHashValue(hPtr, entry);
119 }
120
121 /*
122 * Build an array for looking up a color by its index.
123 */
124
125 numSystemColors = index;
126 systemColorIndex = (SystemColorDatum **)ckalloc(numSystemColors * sizeof(SystemColorDatum *));
127 for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL;
128 hPtr = Tcl_NextHashEntry(&search)) {
129 entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
130 if (entry == NULL) {
131 Tcl_Panic("Unsupported semantic color with no supported backup!");
132 }
133 systemColorIndex[entry->index] = entry;
134 }
135
136 /*
137 * Remember the indexes of some special entries.
138 */
139
140 hPtr = Tcl_FindHashEntry(&systemColors, "Pixel");
141 entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
142 rgbColorIndex = entry->index;
143 hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor");
144 entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
145 controlAccentIndex = entry->index;
146 hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor");
147 entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
148 selectedTabTextIndex = entry->index;
149 [pool drain];
150 }
151
152 /*
153 *----------------------------------------------------------------------
154 *
155 * TkMacOSXRGBPixel --
156 *
157 * Return an unsigned long value suitable for use in the pixel
158 * field of an XColor with the specified red, green and blue
159 * intensities. The inputs are cast as unsigned longs but are
160 * expected to have values representable by an unsigned char.
161 *
162 * This is called in the TkpGetPixel macro, used in xcolor.c,
163 * and in ImageGetPixel.
164 *
165 * Results:
166 * An unsigned long that can be used as the pixel field of an XColor.
227167 *
228168 * Side effects:
229169 * None.
230 *
231 *----------------------------------------------------------------------
232 */
233
234 static bool
235 GetEntryFromPixelCode(
236 unsigned char code,
237 struct SystemColorMapEntry *entry)
238 {
239 if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
240 *entry = systemColorMap[code - MIN_PIXELCODE];
241 return true;
170 *----------------------------------------------------------------------
171 */
172 MODULE_SCOPE
173 unsigned long
174 TkMacOSXRGBPixel(
175 unsigned long red,
176 unsigned long green,
177 unsigned long blue)
178 {
179 MacPixel p = {0};
180 p.pixel.colortype = rgbColor;
181 p.pixel.value = ((red & 0xff) << 16) |
182 ((green & 0xff) << 8) |
183 (blue & 0xff);
184 return p.ulong;
185 }
186
187 /*
188 *----------------------------------------------------------------------
189 *
190 * TkMacOSXClearPixel --
191 *
192 * Return the unsigned long value that appears in the pixel
193 * field of the XColor for systemTransparentColor.
194 *
195 * This is used in tkMacOSXImage.c.
196 *
197 * Results:
198 * The unsigned long that appears in the pixel field of the XColor
199 * for systemTransparentPixel.
200 *
201 * Side effects:
202 * None.
203 *----------------------------------------------------------------------
204 */
205 MODULE_SCOPE
206 unsigned long TkMacOSXClearPixel(
207 void)
208 {
209 MacPixel p = {0};
210 p.pixel.value = 0;
211 p.pixel.colortype = clearColor;
212 return p.ulong;
213 }
214
215
216 /*
217 *----------------------------------------------------------------------
218 *
219 * GetEntryFromPixel --
220 *
221 * Look up a SystemColorDatum which describes the XColor with
222 * the specified value as its pixel field.
223 *
224 * Results:
225 * A pointer to a SystemColorDatum, or NULL if the pixel value is
226 * invalid.
227 *
228 * Side effects:
229 * None
230 *
231 *----------------------------------------------------------------------
232 */
233
234 SystemColorDatum*
235 GetEntryFromPixel(
236 unsigned long pixel)
237 {
238 MacPixel p = {0};
239 int index = rgbColorIndex;
240
241 p.ulong = pixel;
242 if (p.pixel.colortype != rgbColor) {
243 index = p.pixel.value;
244 }
245 if (index < numSystemColors) {
246 return systemColorIndex[index];
242247 } else {
243 return false;
244 }
245 }
246
247 /*
248 *----------------------------------------------------------------------
249 *
250 * SetCGColorComponents --
251 *
252 * Set the components of a CGColorRef from an XColor pixel value and a
253 * system color map entry. The pixel value is only used in the case where
254 * the color is of type rgbColor. In that case the normalized XColor RGB
255 * values are copied into the CGColorRef.
256 *
257 * Results:
258 * OSStatus
259 *
260 * Side effects:
261 * None.
262 *
263 *----------------------------------------------------------------------
264 */
265
266 static NSColorSpace* deviceRGB = NULL;
267 static CGFloat blueAccentRGBA[4] = {0, 122.0 / 255, 1.0, 1.0};
268 static CGFloat windowBackground[4] =
269 {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
270
271 static OSStatus
272 SetCGColorComponents(
273 struct SystemColorMapEntry entry,
248 return NULL;
249 }
250 }
251
252
253 /*
254 *----------------------------------------------------------------------
255 *
256 * GetRGBA --
257 *
258 * Given a SystemColorDatum and a pointer to an array of 4 CGFloats, store
259 * the associated RGBA color values in the array. In the case of the
260 * RGBColor datum, the unsigned long pixel value containing the RGB values
261 * must also be provided as the pixel parameter. Otherwise the pixel
262 * parameter is ignored.
263 *
264 * Results:
265 * None
266 *
267 * Side effects:
268 * The array rgba is filled in.
269 *
270 *----------------------------------------------------------------------
271 */
272
273 static void
274 GetRGBA(
275 SystemColorDatum *entry,
274276 unsigned long pixel,
275 CGColorRef *c)
276 {
277 OSStatus err = noErr;
277 CGFloat *rgba)
278 {
278279 NSColor *bgColor, *color = nil;
279 CGFloat rgba[4] = {0, 0, 0, 1};
280 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
281 NSInteger colorVariant;
282 static CGFloat graphiteAccentRGBA[4] =
283 {152.0 / 255, 152.0 / 255, 152.0 / 255, 1.0};
284 #endif
285
286 if (!deviceRGB) {
287 deviceRGB = [NSColorSpace deviceRGBColorSpace];
288 }
289
290 /*
291 * This function is called before our autorelease pool is set up,
292 * so it needs its own pool.
293 */
294
295 NSAutoreleasePool *pool = [NSAutoreleasePool new];
296
297 switch (entry.type) {
298 case HIBrush:
299 err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c);
300 return err;
280
281 if (!sRGB) {
282 sRGB = [NSColorSpace sRGBColorSpace];
283 }
284
285 switch (entry->type) {
301286 case rgbColor:
302287 rgba[0] = ((pixel >> 16) & 0xff) / 255.0;
303288 rgba[1] = ((pixel >> 8) & 0xff) / 255.0;
310295 * windowBackGroundColor.
311296 */
312297
313 if ([NSApp macMinorVersion] < 14) {
314 for (int i=0; i<3; i++) {
315 rgba[i] = windowBackground[i];
298 if ([NSApp macOSVersion] < 101400) {
299 for (int i = 0; i < 3; i++) {
300 rgba[i] = WINDOWBACKGROUND[i];
316301 }
317302 } else {
318 bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:
319 deviceRGB];
303 bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB];
320304 [bgColor getComponents: rgba];
321305 }
322306 if (rgba[0] + rgba[1] + rgba[2] < 1.5) {
323307 for (int i=0; i<3; i++) {
324 rgba[i] += entry.value*8.0 / 255.0;
308 rgba[i] += entry->value*8.0 / 255.0;
325309 }
326310 } else {
327311 for (int i=0; i<3; i++) {
328 rgba[i] -= entry.value*8.0 / 255.0;
312 rgba[i] -= entry->value*8.0 / 255.0;
329313 }
330314 }
315 break;
316 case clearColor:
317 rgba[0] = rgba[1] = rgba[2] = 1.0;
318 rgba[3] = 0;
331319 break;
332320 case semantic:
333 switch (entry.value) {
334 case 0:
335 color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
336 break;
337 case 1:
338 color = [[NSColor selectedTextColor] colorUsingColorSpace: deviceRGB];
339 break;
340 case 2:
341 if ([NSApp macMinorVersion] > 9) {
342 #if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
343 color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB];
321 if (entry->index == controlAccentIndex && useFakeAccentColor) {
322 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
323 color = [[NSColor colorForControlTint: [NSColor currentControlTint]]
324 colorUsingColorSpace:sRGB];
344325 #endif
326 } else if (entry->index == selectedTabTextIndex) {
327 int OSVersion = [NSApp macOSVersion];
328 if (OSVersion > 100600 && OSVersion < 110000) {
329 color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
345330 } else {
346 color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
331 color = [[NSColor textColor] colorUsingColorSpace:sRGB];
347332 }
348 break;
349 case 3:
350 color = [[NSColor controlTextColor] colorUsingColorSpace:
351 deviceRGB];
352 break;
353 case 4:
354 color = [[NSColor disabledControlTextColor] colorUsingColorSpace:
355 deviceRGB];
356 break;
357 case 5:
358 if ([NSApp macMinorVersion] > 6) {
359 color = [[NSColor whiteColor] colorUsingColorSpace:
360 deviceRGB];
361 } else {
362 color = [[NSColor blackColor] colorUsingColorSpace:
363 deviceRGB];
364 }
365 break;
366 case 6:
367 color = [[NSColor textBackgroundColor] colorUsingColorSpace:
368 deviceRGB];
369 break;
370 case 7:
371 color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpace:
372 deviceRGB];
373 break;
374 case 8:
375 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
376 if (@available(macOS 10.14, *)) {
377 color = [[NSColor controlAccentColor] colorUsingColorSpace:
378 deviceRGB];
379 } else {
380 color = [NSColor colorWithColorSpace: deviceRGB
381 components: blueAccentRGBA
382 count: 4];
383 }
384 #else
385 colorVariant = [[NSUserDefaults standardUserDefaults]
386 integerForKey:@"AppleAquaColorVariant"];
387 if (colorVariant == 6) {
388 color = [NSColor colorWithColorSpace: deviceRGB
389 components: graphiteAccentRGBA
390 count: 4];
391 } else {
392 color = [NSColor colorWithColorSpace: deviceRGB
393 components: blueAccentRGBA
394 count: 4];
395 }
396 #endif
397 break;
398 default:
399 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
400 if ([NSApp macMinorVersion] >= 10) {
401 color = [[NSColor labelColor] colorUsingColorSpace:
402 deviceRGB];
403 break;
404 }
405 #endif
406 color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
407 break;
333 } else {
334 color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB];
408335 }
409336 [color getComponents: rgba];
410337 break;
411 case clearColor:
412 rgba[3] = 0.0;
338 case HIText:
339 #ifdef __LP64__
340 color = [[NSColor textColor] colorUsingColorSpace:sRGB];
341 [color getComponents: rgba];
342 #else
343 {
344 OSStatus err = noErr;
345 RGBColor rgb;
346 err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32,
347 true, &rgb);
348 if (err == noErr) {
349 rgba[0] = (CGFloat) rgb.red / 65535;
350 rgba[1] = (CGFloat) rgb.green / 65535;
351 rgba[2] = (CGFloat) rgb.blue / 65535;
352 }
353 }
354 #endif
413355 break;
414
415 /*
416 * There are no HITheme functions which convert Text or background colors
417 * to CGColors. (GetThemeTextColor has been removed, and it was never
418 * possible with backgrounds.) If we get one of these we return black.
419 */
420
421 case HIText:
422356 case HIBackground:
357 color = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB];
358 [color getComponents: rgba];
359 break;
423360 default:
424361 break;
425362 }
426 *c = CGColorCreate(deviceRGB.CGColorSpace, rgba);
363 }
364
365 /*
366 *----------------------------------------------------------------------
367 *
368 * SetCGColorComponents --
369 *
370 * Set the components of a CGColorRef from an XColor pixel value and a
371 * SystemColorDatum. The pixel value is only used in the case where
372 * the color is of type rgbColor. In that case the normalized XColor RGB
373 * values are copied into the CGColorRef. Otherwise the components are
374 * computed from the SystemColorDatum.
375 *
376 * In 64 bit macOS systems there are no HITheme functions which convert
377 * HIText or HIBackground colors to CGColors. (GetThemeTextColor was
378 * removed, and it was never possible with backgrounds.) On 64-bit systems
379 * we replace all HIText colors by systemTextColor and all HIBackground
380 * colors by systemWindowBackgroundColor.
381 *
382 * Results:
383 * True if the function succeeds, false otherwise.
384 *
385 * Side effects:
386 * None.
387 *
388 *----------------------------------------------------------------------
389 */
390
391 static Bool
392 SetCGColorComponents(
393 SystemColorDatum *entry,
394 unsigned long pixel,
395 CGColorRef *c)
396 {
397 CGFloat rgba[4] = {0, 0, 0, 1};
398
399 /*
400 * This function is called before our autorelease pool is set up,
401 * so it needs its own pool.
402 */
403
404 NSAutoreleasePool *pool = [NSAutoreleasePool new];
405
406 if (entry->type == HIBrush) {
407 OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c);
408 return err == noErr;
409 }
410 GetRGBA(entry, pixel, rgba);
411 *c = CGColorCreate(sRGB.CGColorSpace, rgba);
427412 [pool drain];
428 return err;
413 return true;
429414 }
430415
431416 /*
447432 MODULE_SCOPE Bool
448433 TkMacOSXInDarkMode(Tk_Window tkwin)
449434 {
450 int result = false;
451435
452436 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
453 if ([NSApp macMinorVersion] >= 14) {
454 static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua";
437 if (@available(macOS 10.14, *)) {
455438 TkWindow *winPtr = (TkWindow*) tkwin;
456 NSView *view = TkMacOSXDrawableView(winPtr->privatePtr);
457 result = (view &&
458 [view.effectiveAppearance.name isEqualToString:darkAqua]);
439 NSAppearanceName name;
440 NSView *view = nil;
441 if (winPtr && winPtr->privatePtr) {
442 view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr);
443 }
444 if (view) {
445 name = [[view effectiveAppearance] name];
446 } else {
447 name = [[NSAppearance currentAppearance] name];
448 }
449 return (name == NSAppearanceNameDarkAqua);
459450 }
460451 #endif
461 return result;
452 return false;
462453 }
463454
464455 /*
466457 *
467458 * TkSetMacColor --
468459 *
469 * Sets the components of a CGColorRef from an XColor pixel value.
470 * The high order byte of the pixel value is used as an index into
471 * the system color table, and then SetCGColorComponents is called
472 * with the table entry and the pixel value.
473 *
474 * Results:
475 * Returns false if the high order byte is not a valid index, true
476 * otherwise.
477 *
478 * Side effects:
479 * The variable macColor is set to a new CGColorRef, the caller is
480 * responsible for releasing it!
460 * Sets the components of a CGColorRef from an XColor pixel value. The
461 * pixel value is used to look up the color in the system color table, and
462 * then SetCGColorComponents is called with the table entry and the pixel
463 * value. The parameter macColor should be a pointer to a CGColorRef.
464 *
465 * Results:
466 * Returns false if the color is not found, true otherwise.
467 *
468 * Side effects:
469 * The CGColorRef referenced by the variable macColor may be modified.
481470 *
482471 *----------------------------------------------------------------------
483472 */
484473
485474 int
486475 TkSetMacColor(
487 unsigned long pixel, /* Pixel value to convert. */
488 void *macColor) /* CGColorRef to modify. */
476 unsigned long pixel, /* Pixel value to convert. */
477 void *macColor) /* CGColorRef to modify. */
489478 {
490479 CGColorRef *color = (CGColorRef*)macColor;
491 OSStatus err = -1;
492 struct SystemColorMapEntry entry;
493
494 if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) {
495 err = ChkErr(SetCGColorComponents, entry, pixel, color);
496 }
497 return (err == noErr);
498 }
499
500 /*
501 *----------------------------------------------------------------------
502 *
503 * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
504 *
505 * Maintain a per-GC cache of previously converted CGColorRefs
506 *
507 * Results:
508 * None resp. retained CGColorRef for CopyCachedColor()
509 *
510 * Side effects:M
511 * None.
512 *
513 *----------------------------------------------------------------------
514 */
515
516 void
517 TkpInitGCCache(
518 GC gc)
519 {
520 bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
521 }
522
523 void
524 TkpFreeGCCache(
525 GC gc)
526 {
527 TkpGCCache *gcCache = TkpGetGCCache(gc);
528
529 if (gcCache->cachedForegroundColor) {
530 CFRelease(gcCache->cachedForegroundColor);
531 }
532 if (gcCache->cachedBackgroundColor) {
533 CFRelease(gcCache->cachedBackgroundColor);
534 }
535 }
536
537 static CGColorRef
538 CopyCachedColor(
539 GC gc,
540 unsigned long pixel)
541 {
542 TkpGCCache *gcCache = TkpGetGCCache(gc);
543 CGColorRef cgColor = NULL;
544
545 if (gcCache) {
546 if (gcCache->cachedForeground == pixel) {
547 cgColor = gcCache->cachedForegroundColor;
548 } else if (gcCache->cachedBackground == pixel) {
549 cgColor = gcCache->cachedBackgroundColor;
550 }
551 if (cgColor) {
552 CFRetain(cgColor);
553 }
554 }
555 return cgColor;
556 }
557
558 static void
559 SetCachedColor(
560 GC gc,
561 unsigned long pixel,
562 CGColorRef cgColor)
563 {
564 TkpGCCache *gcCache = TkpGetGCCache(gc);
565
566 if (gcCache && cgColor) {
567 if (gc->foreground == pixel) {
568 if (gcCache->cachedForegroundColor) {
569 CFRelease(gcCache->cachedForegroundColor);
570 }
571 gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor);
572 gcCache->cachedForeground = pixel;
573 } else if (gc->background == pixel) {
574 if (gcCache->cachedBackgroundColor) {
575 CFRelease(gcCache->cachedBackgroundColor);
576 }
577 gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor);
578 gcCache->cachedBackground = pixel;
579 }
580 }
581 }
582
583 /*
584 *----------------------------------------------------------------------
585 *
586 * TkMacOSXCreateCGColor --
587 *
588 * Creates a CGColorRef from a X style pixel value.
589 *
590 * Results:
591 * Returns NULL if not a real pixel, CGColorRef otherwise.
592 *
593 * Side effects:
594 * None
595 *
596 *----------------------------------------------------------------------
597 */
598
599 CGColorRef
600 TkMacOSXCreateCGColor(
601 GC gc,
602 unsigned long pixel) /* Pixel value to convert. */
603 {
604 CGColorRef cgColor = CopyCachedColor(gc, pixel);
605
606 if (!cgColor && TkSetMacColor(pixel, &cgColor)) {
607 SetCachedColor(gc, pixel, cgColor);
608 }
609 return cgColor;
480 SystemColorDatum *entry = GetEntryFromPixel(pixel);
481
482 if (entry) {
483 return SetCGColorComponents(entry, pixel, color);
484 } else {
485 return false;
486 }
610487 }
611488
612489 /*
615492 * TkMacOSXGetNSColor --
616493 *
617494 * Creates an autoreleased NSColor from a X style pixel value.
618 *
619 * Results:
620 * Returns nil if not a real pixel, NSColor* otherwise.
495 * The return value is nil if the pixel value is invalid.
496 *
497 * Results:
498 * A possibly nil pointer to an NSColor.
621499 *
622500 * Side effects:
623501 * None
630508 GC gc,
631509 unsigned long pixel) /* Pixel value to convert. */
632510 {
633 CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
511 CGColorRef cgColor;
634512 NSColor *nsColor = nil;
635513
636 if (cgColor) {
637 NSColorSpace *colorSpace = [[NSColorSpace alloc]
638 initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
639
640 nsColor = [NSColor colorWithColorSpace:colorSpace
641 components:CGColorGetComponents(cgColor)
642 count:CGColorGetNumberOfComponents(cgColor)];
643 [colorSpace release];
644 CFRelease(cgColor);
645 }
514 TkSetMacColor(pixel, &cgColor);
515 nsColor = [NSColor colorWithColorSpace:sRGB
516 components:CGColorGetComponents(cgColor)
517 count:CGColorGetNumberOfComponents(cgColor)];
646518 return nsColor;
647519 }
648520
651523 *
652524 * TkMacOSXSetColorInContext --
653525 *
654 * Sets fill and stroke color in the given CG context from an X
655 * pixel value, or if the pixel code indicates a system color,
656 * sets the corresponding brush, textColor or background via
657 * HITheme APIs if available or Appearance mgr APIs.
526 * Sets the fill and stroke colors in the given CGContext to the CGColor
527 * which corresponds to the XColor having the specified value for its pixel
528 * field.
658529 *
659530 * Results:
660531 * None.
673544 {
674545 OSStatus err = noErr;
675546 CGColorRef cgColor = nil;
676 struct SystemColorMapEntry entry;
547 SystemColorDatum *entry = GetEntryFromPixel(pixel);
677548 CGRect rect;
678 int code = (pixel >> 24) & 0xff;
679 HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};;
680 static CGColorSpaceRef deviceRGBSpace = NULL;
681
682 if (!deviceRGBSpace) {
683 deviceRGBSpace = CGColorSpaceCreateDeviceRGB();
684 }
685 if (code < FIRST_SEMANTIC_COLOR) {
686 cgColor = CopyCachedColor(gc, pixel);
687 }
688 if (!cgColor && GetEntryFromPixelCode(code, &entry)) {
689 switch (entry.type) {
549 HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};
550
551 if (entry) {
552 switch (entry->type) {
690553 case HIBrush:
691 err = ChkErr(HIThemeSetFill, entry.value, NULL, context,
554 err = ChkErr(HIThemeSetFill, entry->value, NULL, context,
692555 kHIThemeOrientationNormal);
693556 if (err == noErr) {
694 err = ChkErr(HIThemeSetStroke, entry.value, NULL, context,
557 err = ChkErr(HIThemeSetStroke, entry->value, NULL, context,
695558 kHIThemeOrientationNormal);
696559 }
697560 break;
698561 case HIText:
699 err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context,
562 err = ChkErr(HIThemeSetTextFill, entry->value, NULL, context,
700563 kHIThemeOrientationNormal);
701564 break;
702565 case HIBackground:
703 info.kind = entry.value;
566 info.kind = entry->value;
704567 rect = CGContextGetClipBoundingBox(context);
705568 err = ChkErr(HIThemeApplyBackground, &rect, &info,
706569 context, kHIThemeOrientationNormal);
707570 break;
708571 default:
709 err = ChkErr(SetCGColorComponents, entry, pixel, &cgColor);
710 if (err == noErr) {
711 SetCachedColor(gc, pixel, cgColor);
712 }
572 SetCGColorComponents(entry, pixel, &cgColor);
713573 break;
714574 }
715575 }
728588 *
729589 * TkpGetColor --
730590 *
731 * Allocate a new TkColor for the color with the given name.
591 * Create a new TkColor for the color with the given name, for use in the
592 * specified window. The colormap field is set to lightColormap if the
593 * window has a LightAqua appearance, or darkColormap if the window has a
594 * DarkAqua appearance. TkColors with different colormaps are managed
595 * separately in the per-display table of TkColors maintained by Tk.
596 *
597 * This function is called by Tk_GetColor.
732598 *
733599 * Results:
734600 * Returns a newly allocated TkColor, or NULL on failure.
735601 *
736602 * Side effects:
737 * May invalidate the colormap cache associated with tkwin upon
738 * allocating a new colormap entry. Allocates a new TkColor
739 * structure.
603 *
604 * Allocates memory for the TkColor structure.
740605 *
741606 *----------------------------------------------------------------------
742607 */
747612 Tk_Uid name) /* Name of color to be allocated (in form
748613 * suitable for passing to XParseColor). */
749614 {
750 Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
751 Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None;
615 Display *display = NULL;
752616 TkColor *tkColPtr;
753617 XColor color;
618 Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap;
619 NSView *view = nil;
620 static Bool initialized = NO;
621 static NSColorSpace* sRGB = nil;
622
623 if (!initialized) {
624 initialized = YES;
625 sRGB = [NSColorSpace sRGBColorSpace];
626 initColorTable();
627 }
628 if (tkwin) {
629 display = Tk_Display(tkwin);
630 Drawable d = Tk_WindowId(tkwin);
631 view = TkMacOSXGetNSViewForDrawable(d);
632 }
754633
755634 /*
756 * Check to see if this is a system color. Otherwise, XParseColor
757 * will do all the work.
635 * Check to see if this is a system color. If not, just call XParseColor.
758636 */
759637
760638 if (strncasecmp(name, "system", 6) == 0) {
761 Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1);
762 int idx, result;
763
764 result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap,
765 sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
766 Tcl_DecrRefCount(strPtr);
767 if (result == TCL_OK) {
768 OSStatus err;
639 Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6);
640 MacPixel p = {0};
641
642 if (hPtr != NULL) {
643 SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr);
769644 CGColorRef c;
770 unsigned char pixelCode = idx + MIN_PIXELCODE;
771 struct SystemColorMapEntry entry = systemColorMap[idx];
772
773 err = ChkErr(SetCGColorComponents, entry, 0, &c);
774 if (err == noErr) {
645
646 p.pixel.colortype = entry->type;
647 p.pixel.value = entry->index;
648 color.pixel = p.ulong;
649 if (entry->type == semantic) {
650 CGFloat rgba[4];
651 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
652 if (@available(macOS 10.14, *)) {
653 NSAppearance *savedAppearance = [NSAppearance currentAppearance];
654 NSAppearance *windowAppearance = savedAppearance;
655 if (view) {
656 windowAppearance = [view effectiveAppearance];
657 }
658 if ([windowAppearance name] == NSAppearanceNameDarkAqua) {
659 colormap = darkColormap;
660 } else {
661 colormap = lightColormap;
662 }
663 [NSAppearance setCurrentAppearance:windowAppearance];
664 GetRGBA(entry, p.ulong, rgba);
665 [NSAppearance setCurrentAppearance:savedAppearance];
666 } else {
667 GetRGBA(entry, p.ulong, rgba);
668 }
669 #else
670 GetRGBA(entry, p.ulong, rgba);
671 #endif
672 color.red = rgba[0] * 65535.0;
673 color.green = rgba[1] * 65535.0;
674 color.blue = rgba[2] * 65535.0;
675 goto validXColor;
676 } else if (SetCGColorComponents(entry, 0, &c)) {
775677 const size_t n = CGColorGetNumberOfComponents(c);
776678 const CGFloat *rgba = CGColorGetComponents(c);
777679
787689 default:
788690 Tcl_Panic("CGColor with %d components", (int) n);
789691 }
790 color.pixel = ((((((pixelCode << 8)
791 | ((color.red >> 8) & 0xff)) << 8)
792 | ((color.green >> 8) & 0xff)) << 8)
793 | ((color.blue >> 8) & 0xff));
794692 CGColorRelease(c);
795693 goto validXColor;
796694 }
797 CGColorRelease(c);
798 }
799 }
800
695 }
696 }
801697 if (TkParseColor(display, colormap, name, &color) == 0) {
802698 return NULL;
803699 }
804700
805701 validXColor:
806 tkColPtr = ckalloc(sizeof(TkColor));
702 tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
703 tkColPtr->colormap = colormap;
807704 tkColPtr->color = color;
808
809705 return tkColPtr;
810706 }
811707
814710 *
815711 * TkpGetColorByValue --
816712 *
817 * Given a desired set of red-green-blue intensities for a color,
818 * locate a pixel value to use to draw that color in a given
819 * window.
820 *
821 * Results:
822 * The return value is a pointer to an TkColor structure that
823 * indicates the closest red, blue, and green intensities available
824 * to those specified in colorPtr, and also specifies a pixel
825 * value to use to draw in that color.
713 * Given an pointer to an XColor, construct a TkColor whose red, green and
714 * blue intensities match those of the XColor as closely as possible. For
715 * the Macintosh, this means that the colortype bitfield of the pixel
716 * value will be RGBColor and that the color intensities stored in its
717 * 24-bit value bitfield are computed from the 16-bit red green and blue
718 * values in the XColor by dividing by 256.
719 *
720 * Results:
721 * A pointer to a newly allocated TkColor structure.
826722 *
827723 * Side effects:
828724 * May invalidate the colormap cache for the specified window.
829 * Allocates a new TkColor structure.
725 * Allocates memory for a TkColor structure.
830726 *
831727 *----------------------------------------------------------------------
832728 */
833729
834730 TkColor *
835731 TkpGetColorByValue(
836 Tk_Window tkwin, /* Window in which color will be used. */
732 TCL_UNUSED(Tk_Window), /* Window in which color will be used. */
837733 XColor *colorPtr) /* Red, green, and blue fields indicate
838734 * desired color. */
839735 {
840 TkColor *tkColPtr = ckalloc(sizeof(TkColor));
736 TkColor *tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
841737
842738 tkColPtr->color.red = colorPtr->red;
843739 tkColPtr->color.green = colorPtr->green;
844740 tkColPtr->color.blue = colorPtr->blue;
845 tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color);
741 tkColPtr->color.pixel = TkpGetPixel(colorPtr);
846742 return tkColPtr;
847743 }
848744
866762 Status
867763 XAllocColor(
868764 Display *display, /* Display. */
869 Colormap map, /* Not used. */
765 TCL_UNUSED(Colormap), /* Not used. */
870766 XColor *colorPtr) /* XColor struct to modify. */
871767 {
872768 display->request++;
876772
877773 Colormap
878774 XCreateColormap(
879 Display *display, /* Display. */
880 Window window, /* X window. */
881 Visual *visual, /* Not used. */
882 int alloc) /* Not used. */
883 {
884 static Colormap index = 1;
775 TCL_UNUSED(Display *), /* Display. */
776 TCL_UNUSED(Window), /* X window. */
777 TCL_UNUSED(Visual *), /* Not used. */
778 TCL_UNUSED(int)) /* Not used. */
779 {
780 static Colormap index = 16;
885781
886782 /*
887 * Just return a new value each time.
783 * Just return a new value each time, large enough that it will not
784 * conflict with any value of the macColormap enum.
888785 */
889786 return index++;
890787 }
891788
892789 int
893790 XFreeColormap(
894 Display* display, /* Display. */
895 Colormap colormap) /* Colormap. */
791 TCL_UNUSED(Display *), /* Display. */
792 TCL_UNUSED(Colormap)) /* Colormap. */
896793 {
897794 return Success;
898795 }
899796
900797 int
901798 XFreeColors(
902 Display* display, /* Display. */
903 Colormap colormap, /* Colormap. */
904 unsigned long* pixels, /* Array of pixels. */
905 int npixels, /* Number of pixels. */
906 unsigned long planes) /* Number of pixel planes. */
799 TCL_UNUSED(Display *), /* Display. */
800 TCL_UNUSED(Colormap), /* Colormap. */
801 TCL_UNUSED(unsigned long *), /* Array of pixels. */
802 TCL_UNUSED(int), /* Number of pixels. */
803 TCL_UNUSED(unsigned long)) /* Number of pixel planes. */
907804 {
908805 /*
909 * The Macintosh version of Tk uses TrueColor. Nothing
910 * needs to be done to release colors as there really is
911 * no colormap in the Tk sense.
806 * Nothing needs to be done to release colors as there really is no
807 * colormap in the Tk sense.
912808 */
913809 return Success;
914810 }
0 #ifndef MACOSXCOLOR_H
1 #define MACOSXCOLOR_H
2 /*
3 * The generic Tk code uses the X11 GC type to describe a graphics context.
4 * (A GC is a pointer to a struct XGCValues). The foreground and background
5 * colors in a GC are unsigned longs. These are meant to be used as indexes
6 * into a table of XColors, where an XColor is declared in Xlib.h as:
7 * typedef struct {
8 * unsigned long pixel;
9 * unsigned short red, green, blue;
10 * char flags;
11 * char pad;
12 * } XColor;
13 *
14 * The xlib function XParseColor creates XColors from strings. It recognizes
15 * literal hexadecimal color specifications such as "#RRGGBB" as well as the
16 * standard X11 color names. When XParseColor creates an XColor it fills in
17 * all of the fields except for the pixel field, and then passes the XColor
18 * to TkpGetPixel to get a value to use for the pixel field. Since TkpGetPixel
19 * is platform specific, each platform is free to choose a value which can
20 * be used to set the foreground or background color in the platform's graphics
21 * context.
22 *
23 * Tk represents a color by a struct TkColor, which extends the XColor struct.
24 * Tk provides a mapping from color names to TkColors which extends the mapping
25 * provided by XParseColor but also allows for platform specific color names.
26 * By convention, these platform specific color names begin with the string
27 * "system". The mapping from names to TkColors is implemented by the function
28 * TkpGetColor defined for the Macintosh in this file. The pixel field in the
29 * XColor contained in a TkColor will be stored in the X11 graphics context.
30 * In X11 the pixel field is used as an index into a colormap. On the Mac
31 * the high order byte of the pixel is used to indicate a color type and
32 * the low 24 bits are either used as an rgb value (if the type is rgbColor)
33 * or as an index into a table of color descriptions.
34 */
35
36 enum colorType {
37 rgbColor, /* The 24 bit value is an rgb color. */
38 clearColor, /* The unique rgba color with all channels 0. */
39 HIBrush, /* A HITheme brush color.*/
40 HIText, /* A HITheme text color. */
41 HIBackground, /* A HITheme background color. */
42 ttkBackground, /* A background color which indicates nesting level.*/
43 semantic, /* A semantic NSColor.*/
44 };
45
46 typedef struct xpixel_t {
47 unsigned value: 24; /* Either RGB or an index into systemColorMap. */
48 unsigned colortype: 8;
49 } xpixel;
50
51 typedef union MacPixel_t {
52 unsigned long ulong;
53 xpixel pixel;
54 } MacPixel;
55
56 /*
57 * We maintain two colormaps, one for the LightAqua appearance and one for the
58 * DarkAqua appearance.
59 */
60
61 enum macColormap {
62 noColormap,
63 lightColormap,
64 darkColormap,
65 };
66
67 /*
68 * In TkMacOSXColor.c a Tk hash table is constructed from the static data
69 * below to map system color names to CGColors.
70 */
71
72 typedef struct {
73 const char *name;
74 enum colorType type;
75 int value;
76 const char *macName;
77 /* Fields below are filled in after or during construction of the hash table. */
78 int index;
79 NSString *selector;
80 } SystemColorDatum;
81
82 /*
83 * WARNING: Semantic colors which are not supported on all systems must be
84 * preceded by a backup color with the same name which *is* supported. Systems
85 * which do support the color will replace the backup value when the table is
86 * constructed. Failing to ensure this will result in a Tcl_Panic abort.
87 */
88
89 static SystemColorDatum systemColorData[] = {
90 {"Pixel", rgbColor, 0, NULL, 0, NULL },
91 {"Transparent", clearColor, 0, NULL, 0, NULL },
92
93 {"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL },
94 {"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL },
95 {"HighlightText", HIBrush, kThemeBrushBlack, NULL, 0, NULL },
96 {"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL },
97 {"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL },
98 {"ButtonFace", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL },
99 {"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL },
100 {"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL },
101 {"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL },
102 {"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL },
103 {"SheetBackground", HIBrush, kThemeBrushSheetBackground, NULL, 0, NULL },
104 {"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL },
105 {"Menu", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL },
106 {"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive, NULL, 0, NULL },
107 {"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive, NULL, 0, NULL },
108 {"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive, NULL, 0, NULL },
109 {"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive, NULL, 0, NULL },
110 {"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive, NULL, 0, NULL },
111 {"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive, NULL, 0, NULL },
112 {"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive, NULL, 0, NULL },
113 {"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive, NULL, 0, NULL },
114 {"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground, NULL, 0, NULL },
115 {"ListViewBackground", HIBrush, kThemeBrushListViewBackground, NULL, 0, NULL },
116 {"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground, NULL, 0, NULL },
117 {"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator, NULL, 0, NULL },
118 {"ChasingArrows", HIBrush, kThemeBrushChasingArrows, NULL, 0, NULL },
119 {"DragHilite", HIBrush, kThemeBrushDragHilite, NULL, 0, NULL },
120 {"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL },
121 {"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground, NULL, 0, NULL },
122 {"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive, NULL, 0, NULL },
123 {"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive, NULL, 0, NULL },
124 {"FocusHighlight", HIBrush, kThemeBrushFocusHighlight, NULL, 0, NULL },
125 {"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive, NULL, 0, NULL },
126 {"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed, NULL, 0, NULL },
127 {"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive, NULL, 0, NULL },
128 {"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark, NULL, 0, NULL },
129 {"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected, NULL, 0, NULL },
130 {"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill, NULL, 0, NULL },
131 {"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill, NULL, 0, NULL },
132 {"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL },
133 {"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive, NULL, 0, NULL },
134 {"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL },
135 {"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive, NULL, 0, NULL },
136 {"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed, NULL, 0, NULL },
137 {"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow, NULL, 0, NULL },
138 {"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight, NULL, 0, NULL },
139 {"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow, NULL, 0, NULL },
140 {"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight, NULL, 0, NULL },
141 {"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow, NULL, 0, NULL },
142 {"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight, NULL, 0, NULL },
143 {"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow, NULL, 0, NULL },
144 {"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight, NULL, 0, NULL },
145 {"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow, NULL, 0, NULL },
146 {"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight, NULL, 0, NULL },
147 {"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow, NULL, 0, NULL },
148 {"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight, NULL, 0, NULL },
149 {"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight, NULL, 0, NULL },
150 {"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark, NULL, 0, NULL },
151 {"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight, NULL, 0, NULL },
152 {"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark, NULL, 0, NULL },
153 {"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground, NULL, 0, NULL },
154 {"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground, NULL, 0, NULL },
155 {"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque, NULL, 0, NULL },
156 {"DrawerBackground", HIBrush, kThemeBrushDrawerBackground, NULL, 0, NULL },
157 {"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground, NULL, 0, NULL },
158 {"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent, NULL, 0, NULL },
159 {"MenuBackground", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL },
160 {"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL },
161 {"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground, NULL, 0, NULL },
162 {"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground, NULL, 0, NULL },
163 {"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider, NULL, 0, NULL },
164
165 {"ButtonText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL },
166 {"MenuActiveText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL },
167 {"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL },
168 {"MenuText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL },
169 {"BlackText", HIText, kThemeTextColorBlack, NULL, 0, NULL },
170 {"DialogActiveText", HIText, kThemeTextColorDialogActive, NULL, 0, NULL },
171 {"DialogInactiveText", HIText, kThemeTextColorDialogInactive, NULL, 0, NULL },
172 {"AlertActiveText", HIText, kThemeTextColorAlertActive, NULL, 0, NULL },
173 {"AlertInactiveText", HIText, kThemeTextColorAlertInactive, NULL, 0, NULL },
174 {"ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive, NULL, 0, NULL },
175 {"ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive, NULL, 0, NULL },
176 {"WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive, NULL, 0, NULL },
177 {"WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive, NULL, 0, NULL },
178 {"PlacardActiveText", HIText, kThemeTextColorPlacardActive, NULL, 0, NULL },
179 {"PlacardInactiveText", HIText, kThemeTextColorPlacardInactive, NULL, 0, NULL },
180 {"PlacardPressedText", HIText, kThemeTextColorPlacardPressed, NULL, 0, NULL },
181 {"PushButtonActiveText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL },
182 {"PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive, NULL, 0, NULL },
183 {"PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed, NULL, 0, NULL },
184 {"BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive, NULL, 0, NULL },
185 {"BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive, NULL, 0, NULL },
186 {"BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed, NULL, 0, NULL },
187 {"PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive, NULL, 0, NULL },
188 {"PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive, NULL, 0, NULL },
189 {"PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed, NULL, 0, NULL },
190 {"IconLabelText", HIText, kThemeTextColorIconLabel, NULL, 0, NULL },
191 {"ListViewText", HIText, kThemeTextColorListView, NULL, 0, NULL },
192 {"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive, NULL, 0, NULL },
193 {"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive, NULL, 0, NULL },
194 {"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive, NULL, 0, NULL },
195 {"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive, NULL, 0, NULL },
196 {"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive, NULL, 0, NULL },
197 {"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive, NULL, 0, NULL },
198 {"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive, NULL, 0, NULL },
199 {"PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive, NULL, 0, NULL },
200 {"RootMenuActiveText", HIText, kThemeTextColorRootMenuActive, NULL, 0, NULL },
201 {"RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected, NULL, 0, NULL },
202 {"RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled, NULL, 0, NULL },
203 {"MenuItemActiveText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL },
204 {"MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL },
205 {"MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL },
206 {"PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive, NULL, 0, NULL },
207 {"PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive, NULL, 0, NULL },
208 {"TabFrontActiveText", HIText, kThemeTextColorTabFrontActive, NULL, 0, NULL },
209 {"TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive, NULL, 0, NULL },
210 {"TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed, NULL, 0, NULL },
211 {"TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive, NULL, 0, NULL },
212 {"TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive, NULL, 0, NULL },
213 {"IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected, NULL, 0, NULL },
214 {"BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive, NULL, 0, NULL },
215 {"BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive, NULL, 0, NULL },
216 {"NotificationText", HIText, kThemeTextColorNotification, NULL, 0, NULL },
217 {"SystemDetailText", HIText, kThemeTextColorSystemDetail, NULL, 0, NULL },
218 {"PlacardBackground", HIBackground, kThemeBackgroundPlacard, NULL, 0, NULL },
219 {"WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader, NULL, 0, NULL },
220 {"ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader, NULL, 0, NULL },
221 {"MetalBackground", HIBackground, kThemeBackgroundMetal, NULL, 0, NULL },
222
223 {"SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox, NULL, 0, NULL },
224 {"TabPaneBackground", HIBackground, kThemeBackgroundTabPane, NULL, 0, NULL },
225 {"WhiteText", HIText, kThemeTextColorWhite, NULL, 0, NULL },
226 {"Black", HIBrush, kThemeBrushBlack, NULL, 0, NULL },
227 {"White", HIBrush, kThemeBrushWhite, NULL, 0, NULL },
228
229 /*
230 * Dynamic Colors
231 */
232
233 {"WindowBackgroundColor", ttkBackground, 0, NULL, 0, NULL },
234 {"WindowBackgroundColor1", ttkBackground, 1, NULL, 0, NULL },
235 {"WindowBackgroundColor2", ttkBackground, 2, NULL, 0, NULL },
236 {"WindowBackgroundColor3", ttkBackground, 3, NULL, 0, NULL },
237 {"WindowBackgroundColor4", ttkBackground, 4, NULL, 0, NULL },
238 {"WindowBackgroundColor5", ttkBackground, 5, NULL, 0, NULL },
239 {"WindowBackgroundColor6", ttkBackground, 6, NULL, 0, NULL },
240 {"WindowBackgroundColor7", ttkBackground, 7, NULL, 0, NULL },
241 /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */
242 {"SecondaryLabelColor", ttkBackground, 14, NULL, 0, NULL },
243 /* Color to use for notebook tab labels -- depends on OS version. */
244 {"SelectedTabTextColor", semantic, 0, "textColor", 0, NULL },
245 /* Semantic colors that we simulate on older systems which don't supoort them. */
246 {"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL },
247 {"LabelColor", semantic, 0, "blackColor", 0, NULL },
248 {"LinkColor", semantic, 0, "blueColor", 0, NULL },
249 {"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL },
250 {"SeparatorColor", semantic, 0, "grayColor", 0, NULL },
251 {"UnemphasizedSelectedTextBackgroundColor", semantic, 0, "grayColor", 0, NULL },
252 {NULL, 0, 0, NULL, 0, NULL }
253 };
254
255 #endif
256 /*
257 * Local Variables:
258 * mode: objc
259 * c-basic-offset: 4
260 * fill-column: 79
261 * coding: utf-8
262 * End:
263 */
1616
1717 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
1818 #define NSFullScreenWindowMask (1 << 14)
19 #endif
20
21 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
22 typedef NSInteger NSModalResponse;
1923 #endif
2024
2125 /*
97101 #define NSStringPboardType NSPasteboardTypeString
98102 #define NSOnState NSControlStateValueOn
99103 #define NSOffState NSControlStateValueOff
100 // Now we are also changing names of methods!
101 #define graphicsContextWithGraphicsPort graphicsContextWithCGContext
102104 #endif
103105
106 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
107 #define NSWindowStyleMaskTexturedBackground 0
108 #endif
109
110 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
111 #define GET_NSCONTEXT(context, flip) [NSGraphicsContext \
112 graphicsContextWithGraphicsPort:context flipped:flip]
113 #else
114 #define GET_NSCONTEXT(context, flip) [NSGraphicsContext \
115 graphicsContextWithCGContext:context flipped:NO]
116 #endif
104117
105118 #endif
106
5353 #define MacXCursorData(n) ((id)tkMacOSXXCursors[TK_MAC_XCURSOR_##n])
5454
5555 static const struct CursorName cursorNames[] = {
56 {"none", NONE, nil},
57 {"arrow", SELECTOR, @"arrowCursor"},
58 {"top_left_arrow", SELECTOR, @"arrowCursor"},
59 {"left_ptr", SELECTOR, @"arrowCursor"},
60 {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor"},
61 {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor"},
62 {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor"},
63 {"movearrow", SELECTOR, @"_moveCursor"},
64 {"ibeam", SELECTOR, @"IBeamCursor"},
65 {"text", SELECTOR, @"IBeamCursor"},
66 {"xterm", SELECTOR, @"IBeamCursor"},
67 {"cross", SELECTOR, @"crosshairCursor"},
68 {"crosshair", SELECTOR, @"crosshairCursor"},
69 {"cross-hair", SELECTOR, @"crosshairCursor"},
70 {"tcross", SELECTOR, @"crosshairCursor"},
71 {"hand", SELECTOR, @"openHandCursor"},
72 {"openhand", SELECTOR, @"openHandCursor"},
73 {"closedhand", SELECTOR, @"closedHandCursor"},
74 {"fist", SELECTOR, @"closedHandCursor"},
75 {"pointinghand", SELECTOR, @"pointingHandCursor"},
76 {"resize", SELECTOR, @"arrowCursor"},
77 {"resizeleft", SELECTOR, @"resizeLeftCursor"},
78 {"resizeright", SELECTOR, @"resizeRightCursor"},
79 {"resizeleftright", SELECTOR, @"resizeLeftRightCursor"},
80 {"resizeup", SELECTOR, @"resizeUpCursor"},
81 {"resizedown", SELECTOR, @"resizeDownCursor"},
82 {"resizeupdown", SELECTOR, @"resizeUpDownCursor"},
83 {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor"},
84 {"resizetopleft", SELECTOR, @"_topLeftResizeCursor"},
85 {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor"},
86 {"resizetopright", SELECTOR, @"_topRightResizeCursor"},
87 {"notallowed", SELECTOR, @"operationNotAllowedCursor"},
88 {"poof", SELECTOR, @"disappearingItemCursor"},
89 {"wait", SELECTOR, @"busyButClickableCursor"},
90 {"spinning", SELECTOR, @"busyButClickableCursor"},
91 {"countinguphand", SELECTOR, @"busyButClickableCursor"},
92 {"countingdownhand", SELECTOR, @"busyButClickableCursor"},
93 {"countingupanddownhand", SELECTOR, @"busyButClickableCursor"},
56 {"none", NONE, nil, nil, {0, 0}},
57 {"arrow", SELECTOR, @"arrowCursor", nil, {0, 0}},
58 {"top_left_arrow", SELECTOR, @"arrowCursor", nil, {0, 0}},
59 {"left_ptr", SELECTOR, @"arrowCursor", nil, {0, 0}},
60 {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor", {0, 0}},
61 {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor", {0, 0}},
62 {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor", nil, {0, 0}},
63 {"movearrow", SELECTOR, @"_moveCursor", nil, {0, 0}},
64 {"ibeam", SELECTOR, @"IBeamCursor", nil, {0, 0}},
65 {"text", SELECTOR, @"IBeamCursor", nil, {0, 0}},
66 {"xterm", SELECTOR, @"IBeamCursor", nil, {0, 0}},
67 {"cross", SELECTOR, @"crosshairCursor", nil, {0, 0}},
68 {"crosshair", SELECTOR, @"crosshairCursor", nil, {0, 0}},
69 {"cross-hair", SELECTOR, @"crosshairCursor", nil, {0, 0}},
70 {"tcross", SELECTOR, @"crosshairCursor", nil, {0, 0}},
71 {"hand", SELECTOR, @"openHandCursor", nil, {0, 0}},
72 {"openhand", SELECTOR, @"openHandCursor", nil, {0, 0}},
73 {"closedhand", SELECTOR, @"closedHandCursor", nil, {0, 0}},
74 {"fist", SELECTOR, @"closedHandCursor", nil, {0, 0}},
75 {"pointinghand", SELECTOR, @"pointingHandCursor", nil, {0, 0}},
76 {"resize", SELECTOR, @"arrowCursor", nil, {0, 0}},
77 {"resizeleft", SELECTOR, @"resizeLeftCursor", nil, {0, 0}},
78 {"resizeright", SELECTOR, @"resizeRightCursor", nil, {0, 0}},
79 {"resizeleftright", SELECTOR, @"resizeLeftRightCursor", nil, {0, 0}},
80 {"resizeup", SELECTOR, @"resizeUpCursor", nil, {0, 0}},
81 {"resizedown", SELECTOR, @"resizeDownCursor", nil, {0, 0}},
82 {"resizeupdown", SELECTOR, @"resizeUpDownCursor", nil, {0, 0}},
83 {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor", nil, {0, 0}},
84 {"resizetopleft", SELECTOR, @"_topLeftResizeCursor", nil, {0, 0}},
85 {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor", nil, {0, 0}},
86 {"resizetopright", SELECTOR, @"_topRightResizeCursor", nil, {0, 0}},
87 {"notallowed", SELECTOR, @"operationNotAllowedCursor", nil, {0, 0}},
88 {"poof", SELECTOR, @"disappearingItemCursor", nil, {0, 0}},
89 {"wait", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
90 {"spinning", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
91 {"countinguphand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
92 {"countingdownhand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
93 {"countingupanddownhand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
9494 {"help", IMAGENAMED, @"NSHelpCursor", nil, {8, 8}},
95 // {"hand", IMAGEBITMAP, MacCursorData(hand)},
96 {"bucket", IMAGEBITMAP, MacCursorData(bucket)},
97 {"cancel", IMAGEBITMAP, MacCursorData(cancel)},
98 // {"resize", IMAGEBITMAP, MacCursorData(resize)},
99 {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop)},
100 {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full)},
101 {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in)},
102 {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out)},
103 {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor)},
104 // {"arrow", IMAGEBITMAP, MacXCursorData(arrow)},
105 {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down)},
106 {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up)},
107 {"boat", IMAGEBITMAP, MacXCursorData(boat)},
108 {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity)},
109 {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner)},
110 {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner)},
111 {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side)},
112 {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee)},
113 {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral)},
114 {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr)},
115 {"circle", IMAGEBITMAP, MacXCursorData(circle)},
116 {"clock", IMAGEBITMAP, MacXCursorData(clock)},
117 {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug)},
118 // {"cross", IMAGEBITMAP, MacXCursorData(cross)},
119 {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse)},
120 // {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair)},
121 {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross)},
122 {"dot", IMAGEBITMAP, MacXCursorData(dot)},
123 {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox)},
124 {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow)},
125 {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large)},
126 {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small)},
127 {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box)},
128 {"exchange", IMAGEBITMAP, MacXCursorData(exchange)},
129 {"fleur", IMAGEBITMAP, MacXCursorData(fleur)},
130 {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler)},
131 {"gumby", IMAGEBITMAP, MacXCursorData(gumby)},
132 {"hand1", IMAGEBITMAP, MacXCursorData(hand1)},
133 {"hand2", IMAGEBITMAP, MacXCursorData(hand2)},
134 {"heart", IMAGEBITMAP, MacXCursorData(heart)},
135 {"icon", IMAGEBITMAP, MacXCursorData(icon)},
136 {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross)},
137 // {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr)},
138 {"left_side", IMAGEBITMAP, MacXCursorData(left_side)},
139 {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee)},
140 {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton)},
141 {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle)},
142 {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle)},
143 {"man", IMAGEBITMAP, MacXCursorData(man)},
144 {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton)},
145 {"mouse", IMAGEBITMAP, MacXCursorData(mouse)},
146 {"pencil", IMAGEBITMAP, MacXCursorData(pencil)},
147 {"pirate", IMAGEBITMAP, MacXCursorData(pirate)},
148 {"plus", IMAGEBITMAP, MacXCursorData(plus)},
149 {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow)},
150 {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr)},
151 {"right_side", IMAGEBITMAP, MacXCursorData(right_side)},
152 {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee)},
153 {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton)},
154 {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo)},
155 {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat)},
156 {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow)},
157 {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow)},
158 {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow)},
159 {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow)},
160 {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow)},
161 {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow)},
162 {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle)},
163 {"sizing", IMAGEBITMAP, MacXCursorData(sizing)},
164 {"spider", IMAGEBITMAP, MacXCursorData(spider)},
165 {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan)},
166 {"star", IMAGEBITMAP, MacXCursorData(star)},
167 {"target", IMAGEBITMAP, MacXCursorData(target)},
168 // {"tcross", IMAGEBITMAP, MacXCursorData(tcross)},
169 // {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow)},
170 {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner)},
171 {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner)},
172 {"top_side", IMAGEBITMAP, MacXCursorData(top_side)},
173 {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee)},
174 {"trek", IMAGEBITMAP, MacXCursorData(trek)},
175 {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle)},
176 {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella)},
177 {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle)},
178 {"watch", IMAGEBITMAP, MacXCursorData(watch)},
179 // {"xterm", IMAGEBITMAP, MacXCursorData(xterm)},
180 {NULL}
95 // {"hand", IMAGEBITMAP, MacCursorData(hand), nil, {0, 0}},
96 {"bucket", IMAGEBITMAP, MacCursorData(bucket), nil, {0, 0}},
97 {"cancel", IMAGEBITMAP, MacCursorData(cancel), nil, {0, 0}},
98 // {"resize", IMAGEBITMAP, MacCursorData(resize), nil, {0, 0}},
99 {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop), nil, {0, 0}},
100 {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full), nil, {0, 0}},
101 {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in), nil, {0, 0}},
102 {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out), nil, {0, 0}},
103 {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor), nil, {0, 0}},
104 // {"arrow", IMAGEBITMAP, MacXCursorData(arrow), nil, {0, 0}},
105 {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down), nil, {0, 0}},
106 {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up), nil, {0, 0}},
107 {"boat", IMAGEBITMAP, MacXCursorData(boat), nil, {0, 0}},
108 {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity), nil, {0, 0}},
109 {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner), nil, {0, 0}},
110 {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner), nil, {0, 0}},
111 {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side), nil, {0, 0}},
112 {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee), nil, {0, 0}},
113 {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral), nil, {0, 0}},
114 {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr), nil, {0, 0}},
115 {"circle", IMAGEBITMAP, MacXCursorData(circle), nil, {0, 0}},
116 {"clock", IMAGEBITMAP, MacXCursorData(clock), nil, {0, 0}},
117 {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug), nil, {0, 0}},
118 // {"cross", IMAGEBITMAP, MacXCursorData(cross), nil, {0, 0}},
119 {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse), nil, {0, 0}},
120 // {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair), nil, {0, 0}},
121 {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross), nil, {0, 0}},
122 {"dot", IMAGEBITMAP, MacXCursorData(dot), nil, {0, 0}},
123 {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox), nil, {0, 0}},
124 {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow), nil, {0, 0}},
125 {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large), nil, {0, 0}},
126 {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small), nil, {0, 0}},
127 {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box), nil, {0, 0}},
128 {"exchange", IMAGEBITMAP, MacXCursorData(exchange), nil, {0, 0}},
129 {"fleur", IMAGEBITMAP, MacXCursorData(fleur), nil, {0, 0}},
130 {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler), nil, {0, 0}},
131 {"gumby", IMAGEBITMAP, MacXCursorData(gumby), nil, {0, 0}},
132 {"hand1", IMAGEBITMAP, MacXCursorData(hand1), nil, {0, 0}},
133 {"hand2", IMAGEBITMAP, MacXCursorData(hand2), nil, {0, 0}},
134 {"heart", IMAGEBITMAP, MacXCursorData(heart), nil, {0, 0}},
135 {"icon", IMAGEBITMAP, MacXCursorData(icon), nil, {0, 0}},
136 {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross), nil, {0, 0}},
137 // {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr), nil, {0, 0}},
138 {"left_side", IMAGEBITMAP, MacXCursorData(left_side), nil, {0, 0}},
139 {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee), nil, {0, 0}},
140 {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton), nil, {0, 0}},
141 {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle), nil, {0, 0}},
142 {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle), nil, {0, 0}},
143 {"man", IMAGEBITMAP, MacXCursorData(man), nil, {0, 0}},
144 {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton), nil, {0, 0}},
145 {"mouse", IMAGEBITMAP, MacXCursorData(mouse), nil, {0, 0}},
146 {"pencil", IMAGEBITMAP, MacXCursorData(pencil), nil, {0, 0}},
147 {"pirate", IMAGEBITMAP, MacXCursorData(pirate), nil, {0, 0}},
148 {"plus", IMAGEBITMAP, MacXCursorData(plus), nil, {0, 0}},
149 {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow), nil, {0, 0}},
150 {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr), nil, {0, 0}},
151 {"right_side", IMAGEBITMAP, MacXCursorData(right_side), nil, {0, 0}},
152 {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee), nil, {0, 0}},
153 {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton), nil, {0, 0}},
154 {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo), nil, {0, 0}},
155 {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat), nil, {0, 0}},
156 {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow), nil, {0, 0}},
157 {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow), nil, {0, 0}},
158 {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow), nil, {0, 0}},
159 {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow), nil, {0, 0}},
160 {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow), nil, {0, 0}},
161 {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow), nil, {0, 0}},
162 {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle), nil, {0, 0}},
163 {"sizing", IMAGEBITMAP, MacXCursorData(sizing), nil, {0, 0}},
164 {"spider", IMAGEBITMAP, MacXCursorData(spider), nil, {0, 0}},
165 {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan), nil, {0, 0}},
166 {"star", IMAGEBITMAP, MacXCursorData(star), nil, {0, 0}},
167 {"target", IMAGEBITMAP, MacXCursorData(target), nil, {0, 0}},
168 // {"tcross", IMAGEBITMAP, MacXCursorData(tcross), nil, {0, 0}},
169 // {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow), nil, {0, 0}},
170 {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner), nil, {0, 0}},
171 {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner), nil, {0, 0}},
172 {"top_side", IMAGEBITMAP, MacXCursorData(top_side), nil, {0, 0}},
173 {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee), nil, {0, 0}},
174 {"trek", IMAGEBITMAP, MacXCursorData(trek), nil, {0, 0}},
175 {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle), nil, {0, 0}},
176 {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella), nil, {0, 0}},
177 {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle), nil, {0, 0}},
178 {"watch", IMAGEBITMAP, MacXCursorData(watch), nil, {0, 0}},
179 // {"xterm", IMAGEBITMAP, MacXCursorData(xterm), nil, {0, 0}},
180 {NULL, 0, nil, nil, {0, 0}}
181181 };
182182
183183 /*
270270 break;
271271 case IMAGEBITMAP: {
272272 unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1);
273 NSBitmapImageRep *bitmapImageRep = NULL;
273 NSBitmapImageRep *bitmapImageRep = nil;
274274 CGImageRef img = NULL, mask = NULL, maskedImg = NULL;
275275 static const CGFloat decodeWB[] = {1, 0};
276276 CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(
311311 if (bitmapImageRep) {
312312 image = [[NSImage alloc] initWithSize:NSMakeSize(pix, pix)];
313313 [image addRepresentation:bitmapImageRep];
314 [image setTemplate:YES];
314315 [bitmapImageRep release];
315316 }
316317
373374 TkCursor *
374375 TkGetCursorByName(
375376 Tcl_Interp *interp, /* Interpreter to use for error reporting. */
376 Tk_Window tkwin, /* Window in which cursor will be used. */
377 TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */
377378 Tk_Uid string) /* Description of cursor. See manual entry
378379 * for details on legal syntax. */
379380 {
388389
389390 if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) {
390391 if (argc) {
391 macCursorPtr = ckalloc(sizeof(TkMacOSXCursor));
392 macCursorPtr = (TkMacOSXCursor *)ckalloc(sizeof(TkMacOSXCursor));
392393 macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr;
393394 macCursorPtr->macCursor = nil;
394395 macCursorPtr->type = 0;
427428
428429 TkCursor *
429430 TkCreateCursorFromData(
430 Tk_Window tkwin, /* Window in which cursor will be used. */
431 const char *source, /* Bitmap data for cursor shape. */
432 const char *mask, /* Bitmap data for cursor mask. */
433 int width, int height, /* Dimensions of cursor. */
434 int xHot, int yHot, /* Location of hot-spot in cursor. */
435 XColor fgColor, /* Foreground color for cursor. */
436 XColor bgColor) /* Background color for cursor. */
431 TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */
432 TCL_UNUSED(const char *), /* Bitmap data for cursor shape. */
433 TCL_UNUSED(const char *), /* Bitmap data for cursor mask. */
434 TCL_UNUSED(int), /* Dimensions of cursor. */
435 TCL_UNUSED(int),
436 TCL_UNUSED(int), /* Location of hot-spot in cursor. */
437 TCL_UNUSED(int),
438 TCL_UNUSED(XColor), /* Foreground color for cursor. */
439 TCL_UNUSED(XColor)) /* Background color for cursor. */
437440 {
438441 return NULL;
439442 }
462465 TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr;
463466
464467 [macCursorPtr->macCursor release];
465 macCursorPtr->macCursor = NULL;
468 macCursorPtr->macCursor = nil;
466469 if (macCursorPtr == gCurrentCursor) {
467470 gCurrentCursor = NULL;
468471 }
6363 for (i = 0; i < n; i++) {
6464 if (module && *module) {
6565 /* Find image with given module name */
66 char *name;
66 const char *name;
6767 const char *path = _dyld_get_image_name(i);
6868
6969 if (!path) {
4141 #define ACTIVE_FG "systemTextColor"
4242 #define SELECT_BG "systemSelectedTextBackgroundColor"
4343 #define SELECT_FG "systemSelectedTextColor"
44 #define INACTIVE_SELECT_BG "systemSelectedTextBackgroundColor"
44 #define INACTIVE_SELECT_BG "systemUnemphasizedSelectedTextBackgroundColor"
4545 #define TROUGH "#c3c3c3"
4646 #define INDICATOR "#b03060"
4747 #define DISABLED "#a3a3a3"
48 #define IGNORED "#abcdef"
4849
4950 /*
5051 * Defaults for labels, buttons, checkbuttons, and radiobuttons:
8788 #define DEF_BUTTON_ON_VALUE "1"
8889 #define DEF_BUTTON_TRISTATE_VALUE ""
8990 #define DEF_BUTTON_OVER_RELIEF ""
90 //#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
91 //#define DEF_BUTTON_PADX "12"
92 //#define DEF_BUTTON_PADX_NOCM "1"
93 //#else
9491 #define DEF_BUTTON_PADX "1"
95 //#endif
9692 #define DEF_LABCHKRAD_PADX "1"
97 //#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
98 //#define DEF_BUTTON_PADY "3"
99 //#define DEF_BUTTON_PADY_NOCM "1"
100 //#else
10193 #define DEF_BUTTON_PADY "1"
102 //#endif
10394 #define DEF_LABCHKRAD_PADY "1"
10495 #define DEF_BUTTON_RELIEF "flat"
10596 #define DEF_LABCHKRAD_RELIEF "flat"
306297 * Defaults for menus overall:
307298 */
308299
309 #define DEF_MENU_ACTIVE_BG_COLOR "systemMenuActive"
310 #define DEF_MENU_ACTIVE_BG_MONO BLACK
300 #define DEF_MENU_ACTIVE_BG_COLOR IGNORED
301 #define DEF_MENU_ACTIVE_BG_MONO IGNORED
311302 #define DEF_MENU_ACTIVE_BORDER_WIDTH "0"
312 #define DEF_MENU_ACTIVE_FG_COLOR "systemMenuActiveText"
313 #define DEF_MENU_ACTIVE_FG_MONO WHITE
314 #define DEF_MENU_BG_COLOR "systemMenu"
315 #define DEF_MENU_BG_MONO WHITE
303 #define DEF_MENU_ACTIVE_FG_COLOR IGNORED
304 #define DEF_MENU_ACTIVE_FG_MONO IGNORED
305 #define DEF_MENU_BG_COLOR "#000001" /* Detects custom bg. */
306 #define DEF_MENU_BG_MONO IGNORED
316307 #define DEF_MENU_BORDER_WIDTH "0"
317308 #define DEF_MENU_CURSOR "arrow"
318 #define DEF_MENU_DISABLED_FG_COLOR "systemMenuDisabled"
309 #define DEF_MENU_DISABLED_FG_COLOR IGNORED
319310 #define DEF_MENU_DISABLED_FG_MONO ""
320311 #define DEF_MENU_FONT "menu" /* special: see tkMacOSXMenu.c */
321 #define DEF_MENU_FG "systemMenuText"
312 #define DEF_MENU_FG "#010000" /* Detects custom fg. */
322313 #define DEF_MENU_POST_COMMAND ""
323314 #define DEF_MENU_RELIEF "flat"
324 #define DEF_MENU_SELECT_COLOR "systemMenuActive"
325 #define DEF_MENU_SELECT_MONO BLACK
315 #define DEF_MENU_SELECT_COLOR IGNORED
316 #define DEF_MENU_SELECT_MONO IGNORED
326317 #define DEF_MENU_TAKE_FOCUS "0"
327318 #define DEF_MENU_TEAROFF "0"
328319 #define DEF_MENU_TEAROFF_CMD NULL
2222 #define modalOK NSModalResponseOK
2323 #define modalCancel NSModalResponseCancel
2424 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090
25 #define modalOther -1
25 #define modalOther -1 // indicates that the -command option was used.
2626 #define modalError -2
2727
2828 /*
5151 * filter. */
5252 } filepanelFilterInfo;
5353
54 /*
55 * Only one of these is needed for the application, so they can be static.
56 */
57
5458 static filepanelFilterInfo filterInfo;
5559 static NSOpenPanel *openpanel;
5660 static NSSavePanel *savepanel;
197201 @implementation TKApplication(TKDialog)
198202
199203 - (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url {
204 (void)sender;
205 (void)url;
200206 return YES;
201207 }
202208
203209 - (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url {
210 (void)sender; (void)url;
204211 }
205212
206213 - (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError {
214 (void)sender; (void)url;
207215 *outError = nil;
208216 return YES;
209217 }
210218
211219 - (void) tkFilePanelDidEnd: (NSSavePanel *) panel
212 returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
220 returnCode: (NSModalResponse) returnCode
221 contextInfo: (void *) contextInfo
213222 {
214223 FilePanelCallbackInfo *callbackInfo = contextInfo;
215224
231240 callbackInfo->cmdObj, &objc, &objv);
232241
233242 if (result == TCL_OK && objc) {
234 tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
243 tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
235244 memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
236245 tmpv[objc] = resultObj;
237246 TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
244253 } else if (returnCode == modalCancel) {
245254 Tcl_ResetResult(callbackInfo->interp);
246255 }
247 if (panel == [NSApp modalWindow]) {
248 [NSApp stopModalWithCode:returnCode];
249 }
250256 if (callbackInfo->cmdObj) {
251257 Tcl_DecrRefCount(callbackInfo->cmdObj);
258 }
259 if (callbackInfo) {
252260 ckfree(callbackInfo);
253261 }
262 [NSApp stopModalWithCode:returnCode];
254263 }
255264
256265 - (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
269278 callbackInfo->cmdObj, &objc, &objv);
270279
271280 if (result == TCL_OK && objc) {
272 tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
281 tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
273282 memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
274283 tmpv[objc] = resultObj;
275284 TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
292301 - (void)selectFormat:(id)sender {
293302 NSPopUpButton *button = (NSPopUpButton *)sender;
294303 filterInfo.fileTypeIndex = [button indexOfSelectedItem];
295
296304 if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) {
297305 [openpanel setAllowsOtherFileTypes:YES];
298306
342350 {
343351 NSInteger modalReturnCode;
344352
345 if (parent && ![parent attachedSheet] && [NSApp macMinorVersion] < 15) {
353 if (parent && ![parent attachedSheet]) {
346354 [panel beginSheetModalForWindow:parent
347 completionHandler:^(NSInteger returnCode) {
355 completionHandler:^(NSModalResponse returnCode) {
348356 [NSApp tkFilePanelDidEnd:panel
349357 returnCode:returnCode
350358 contextInfo:callbackInfo ];
351359 }];
352 modalReturnCode = callbackInfo->cmdObj ? modalOther :
353 [NSApp runModalForWindow:panel];
360
361 /*
362 * The sheet has been prepared, so now we have to run it as a modal
363 * window. Using [NSApp runModalForWindow:] on macOS 10.15 or later
364 * generates warnings on stderr. But using [NSOpenPanel runModal] or
365 * [NSSavePanel runModal] on 10.14 or earler does not cause the
366 * completion handler to run when the panel is closed.
367 */
368
369 if ([NSApp macOSVersion] > 101400) {
370 modalReturnCode = [panel runModal];
371 } else {
372 modalReturnCode = [NSApp runModalForWindow:panel];
373 }
354374 } else {
355 modalReturnCode = [panel runModal];
356 [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
357 contextInfo:callbackInfo];
358 }
359 return modalReturnCode;
375
376 /*
377 * For the standalone file dialog, completion handlers do not work
378 * at all on macOS 10.14 and earlier.
379 */
380
381 if ([NSApp macOSVersion] > 101400) {
382 [panel beginWithCompletionHandler:^(NSModalResponse returnCode) {
383 [NSApp tkFilePanelDidEnd:panel
384 returnCode:returnCode
385 contextInfo:callbackInfo ];
386 }];
387 modalReturnCode = [panel runModal];
388 } else {
389 modalReturnCode = [panel runModal];
390 [NSApp tkFilePanelDidEnd:panel
391 returnCode:modalReturnCode
392 contextInfo:callbackInfo ];
393 [panel close];
394 }
395 }
396 return callbackInfo->cmdObj ? modalOther : modalReturnCode;
360397 }
361398
362399 /*
653690 NSInteger modalReturnCode = modalError;
654691 BOOL parentIsKey = NO;
655692
656 [openpanel setDelegate:NSApp];
657
658693 for (i = 1; i < objc; i += 2) {
659694 if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings,
660695 sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
724759 * panel. Prepend the title to the message in this case.
725760 */
726761
727 if ([NSApp macMinorVersion] > 10) {
762 if ([NSApp macOSVersion] > 101000) {
728763 if (message) {
729764 NSString *fullmessage =
730765 [[NSString alloc] initWithFormat:@"%@\n%@", title, message];
762797 [label setBezeled:NO];
763798 [label setDrawsBackground:NO];
764799 [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
800 [popupButton setTarget:NSApp];
765801 [popupButton setAction:@selector(selectFormat:)];
766802 [accessoryView addSubview:label];
767803 [accessoryView addSubview:popupButton];
803839 }
804840 Tcl_IncrRefCount(cmdObj);
805841 }
806 callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
842 callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
807843 callbackInfo->cmdObj = cmdObj;
808844 callbackInfo->interp = interp;
809845 callbackInfo->multiple = multiple;
813849 [openpanel setDirectoryURL:fileURL];
814850 }
815851 if (haveParentOption) {
816 parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
852 parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
817853 parentIsKey = parent && [parent isKeyWindow];
818854 } else {
819855 parent = nil;
865901 selectedFilterIndex = filterInfo.fileTypeIndex; // The preselection from the typevariable
866902 selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
867903 } else {
868 NSUInteger i;
869
870 for (i = 0; i < [filterInfo.fileTypeNames count]; i++) {
871 if (filterCompatible(extension, i)) {
872 selectedFilterIndex = i;
904 NSUInteger j;
905
906 for (j = 0; j < [filterInfo.fileTypeNames count]; j++) {
907 if (filterCompatible(extension, j)) {
908 selectedFilterIndex = j;
873909 break;
874910 }
875911 }
876 if (i == selectedFilterIndex) {
912 if (j == selectedFilterIndex) {
877913 selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
878914 } else {
879915 selectedFilter = @"";
912948 int objc, /* Number of arguments. */
913949 Tcl_Obj *const objv[]) /* Argument objects. */
914950 {
915 Tk_Window tkwin = clientData;
951 Tk_Window tkwin = (Tk_Window)clientData;
916952 char *str;
917953 int i, result = TCL_ERROR, haveParentOption = 0;
918954 int confirmOverwrite = 1;
926962 savepanel = [NSSavePanel savePanel];
927963 NSInteger modalReturnCode = modalError;
928964 BOOL parentIsKey = NO;
929
930 [savepanel setDelegate:NSApp];
931965
932966 for (i = 1; i < objc; i += 2) {
933967 if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings,
10491083
10501084 [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
10511085 [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
1086 [popupButton setTarget:NSApp];
10521087 [popupButton setAction:@selector(saveFormat:)];
1053
10541088 [accessoryView addSubview:label];
10551089 [accessoryView addSubview:popupButton];
10561090
10811115 }
10821116 Tcl_IncrRefCount(cmdObj);
10831117 }
1084 callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
1118 callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
10851119 callbackInfo->cmdObj = cmdObj;
10861120 callbackInfo->interp = interp;
10871121 callbackInfo->multiple = 0;
11011135 [savepanel setNameFieldStringValue:@""];
11021136 }
11031137 if (haveParentOption) {
1104 parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
1138 parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
11051139 parentIsKey = parent && [parent isKeyWindow];
11061140 } else {
11071141 parent = nil;
11561190 int objc, /* Number of arguments. */
11571191 Tcl_Obj *const objv[]) /* Argument objects. */
11581192 {
1159 Tk_Window tkwin = clientData;
1193 Tk_Window tkwin = (Tk_Window)clientData;
11601194 char *str;
11611195 int i, result = TCL_ERROR, haveParentOption = 0;
11621196 int index, len, mustexist = 0;
11701204 NSInteger modalReturnCode = modalError;
11711205 BOOL parentIsKey = NO;
11721206
1173 [panel setDelegate:NSApp];
1174
11751207 for (i = 1; i < objc; i += 2) {
11761208 if (Tcl_GetIndexFromObjStruct(interp, objv[i], chooseOptionStrings,
11771209 sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
12321264 }
12331265 Tcl_IncrRefCount(cmdObj);
12341266 }
1235 callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
1267 callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
12361268 callbackInfo->cmdObj = cmdObj;
12371269 callbackInfo->interp = interp;
12381270 callbackInfo->multiple = 0;
12451277 if (!directory) {
12461278 directory = @"/";
12471279 }
1248 parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
1280 parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
12491281 [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
12501282 if (haveParentOption) {
1251 parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
1283 parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
12521284 parentIsKey = parent && [parent isKeyWindow];
12531285 } else {
12541286 parent = nil;
12821314 void
12831315 TkAboutDlg(void)
12841316 {
1285 NSImage *image;
1286 NSString *path = [NSApp tkFrameworkImagePath: @"Tk.tiff"];
1287
1288 if (path) {
1289 image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
1290 } else {
1291 image = [NSApp applicationIconImage];
1292 }
1293
1294 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
1295
1296 [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
1297 [dateFormatter setDateFormat:@"Y"];
1298
1299 NSString *year = [dateFormatter stringFromDate:[NSDate date]];
1300
1301 [dateFormatter release];
1302
1303 /*
1304 * This replaces the old about dialog with a standard alert that displays
1305 * correctly on 10.14.
1306 */
1307
1308 NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL;
1309 NSString *url = @"www.tcl-lang.org";
1310 NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)];
1311 NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
1312 NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font
1313 forKey:NSFontAttributeName];
1314
1315 [credits insertText: [[NSAttributedString alloc]
1316 initWithString:[NSString stringWithFormat: @"\n"
1317 "Tcl and Tk are distributed under a modified BSD license: "
1318 "www.tcl.tk/software/tcltk/license.html\n\n"
1319 "%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n"
1320 "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n"
1321 "%1$C 2014-%2$@ Marc Culler.\n\n"
1322 "%1$C 2002-2012 Daniel A. Steffen.\n\n"
1323 "%1$C 2001-2009 Apple Inc.\n\n"
1324 "%1$C 2001-2002 Jim Ingham & Ian Reid\n\n"
1325 "%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n"
1326 "%1$C 1998-2000 Scriptics Inc.\n\n"
1327 "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year]
1328 attributes:textAttributes]
1329 replacementRange:NSMakeRange(0,0)];
1330 [credits setDrawsBackground:NO];
1331 [credits setEditable:NO];
1332
1333 NSAlert *about = [[NSAlert alloc] init];
1334
1335 [[about window] setTitle:@"About Tcl & Tk"];
1336 [about setMessageText: version];
1337 [about setInformativeText:url];
1338 about.accessoryView = credits;
1339 [about runModal];
1340 [about release];
1341 }
1342
1317 [NSApp orderFrontStandardAboutPanel:nil];
1318 }
1319
13431320 /*
13441321 *----------------------------------------------------------------------
13451322 *
13581335
13591336 int
13601337 TkMacOSXStandardAboutPanelObjCmd(
1361 ClientData clientData, /* Unused. */
1338 TCL_UNUSED(void *),
13621339 Tcl_Interp *interp, /* Current interpreter. */
13631340 int objc, /* Number of arguments. */
13641341 Tcl_Obj *const objv[]) /* Argument objects. */
13671344 Tcl_WrongNumArgs(interp, 1, objv, NULL);
13681345 return TCL_ERROR;
13691346 }
1370 TkAboutDlg();
1347 [NSApp orderFrontStandardAboutPanel:nil];
13711348 return TCL_OK;
13721349 }
13731350
13941371 int objc, /* Number of arguments. */
13951372 Tcl_Obj *const objv[]) /* Argument objects. */
13961373 {
1397 Tk_Window tkwin = clientData;
1374 Tk_Window tkwin = (Tk_Window)clientData;
13981375 char *str;
13991376 int i, result = TCL_ERROR, haveParentOption = 0;
14001377 int index, typeIndex, iconIndex, indexDefaultOption = 0;
15281505 }
15291506 Tcl_IncrRefCount(cmdObj);
15301507 }
1531 callbackInfo = ckalloc(sizeof(AlertCallbackInfo));
1508 callbackInfo = (AlertCallbackInfo *)ckalloc(sizeof(AlertCallbackInfo));
15321509 callbackInfo->cmdObj = cmdObj;
15331510 callbackInfo->interp = interp;
15341511 callbackInfo->typeIndex = typeIndex;
1535 parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
1512 parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
15361513 if (haveParentOption && parent && ![parent attachedSheet]) {
15371514 parentIsKey = [parent isKeyWindow];
15381515 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
16291606 - (void) changeFont: (id) sender
16301607 {
16311608 NSFontManager *fm = [NSFontManager sharedFontManager];
1609 (void)sender;
16321610
16331611 if ([fm currentFontAction] == NSViaPanelFontAction) {
16341612 NSFont *font = [fm convertFont:fontPanelFont];
16521630 }
16531631 }
16541632
1655 - (NSUInteger) validModesForFontPanel: (NSFontPanel *) fontPanel
1656 {
1633 - (NSUInteger) validModesForFontPanel: (NSFontPanel *)fontPanel
1634 {
1635 (void)fontPanel;
1636
16571637 return (NSFontPanelStandardModesMask & ~NSFontPanelAllEffectsModeMask) |
16581638 NSFontPanelUnderlineEffectModeMask |
16591639 NSFontPanelStrikethroughEffectModeMask;
16601640 }
16611641
1662 - (void) windowDidOrderOffScreen: (NSNotification *) notification
1642 - (void) windowDidOrderOffScreen: (NSNotification *)notification
16631643 {
16641644 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
16651645 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
16831663 * None.
16841664 *
16851665 * Side effects:
1686 * Additional events may be place on the Tk event queue.
1666 * Additional events may be placed on the Tk event queue.
16871667 *
16881668 *----------------------------------------------------------------------
16891669 */
17171697 result = Tcl_ListObjGetElements(fontchooserInterp,
17181698 fcdPtr->cmdObj, &objc, &objv);
17191699 if (result == TCL_OK) {
1720 tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
1700 tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
17211701 memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
17221702 tmpv[objc] = fontObj;
17231703 TkBackgroundEvalObjv(fontchooserInterp, objc + 1, tmpv,
17591739 case FontchooserParent:
17601740 if (fcdPtr->parent != None) {
17611741 resObj = Tcl_NewStringObj(
1762 ((TkWindow *) fcdPtr->parent)->pathName, -1);
1742 ((TkWindow *)fcdPtr->parent)->pathName, -1);
17631743 } else {
17641744 resObj = Tcl_NewStringObj(".", 1);
17651745 }
19801960 FontchooserShowCmd(
19811961 ClientData clientData, /* Main window */
19821962 Tcl_Interp *interp,
1983 int objc,
1984 Tcl_Obj *const objv[])
1963 TCL_UNUSED(int),
1964 TCL_UNUSED(Tcl_Obj *const *))
19851965 {
19861966 FontchooserData *fcdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser",
19871967 NULL);
19881968
19891969 if (fcdPtr->parent == None) {
1990 fcdPtr->parent = (Tk_Window) clientData;
1970 fcdPtr->parent = (Tk_Window)clientData;
19911971 Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask,
19921972 FontchooserParentEventHandler, fcdPtr);
19931973 }
20262006
20272007 static int
20282008 FontchooserHideCmd(
2029 ClientData clientData, /* Main window */
2030 Tcl_Interp *interp,
2031 int objc,
2032 Tcl_Obj *const objv[])
2009 TCL_UNUSED(void *), /* Main window */
2010 TCL_UNUSED(Tcl_Interp *),
2011 TCL_UNUSED(int),
2012 TCL_UNUSED(Tcl_Obj *const *))
20332013 {
20342014 NSFontPanel *fp = [[NSFontManager sharedFontManager] fontPanel:NO];
20352015
21282108 MODULE_SCOPE int
21292109 TkInitFontchooser(
21302110 Tcl_Interp *interp,
2131 ClientData clientData)
2132 {
2133 FontchooserData *fcdPtr = ckalloc(sizeof(FontchooserData));
2111 TCL_UNUSED(void *))
2112 {
2113 FontchooserData *fcdPtr = (FontchooserData *)ckalloc(sizeof(FontchooserData));
21342114
21352115 bzero(fcdPtr, sizeof(FontchooserData));
21362116 Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteFontchooserData,
00 /*
11 * tkMacOSXDraw.c --
22 *
3 * This file contains functions that perform drawing to Xlib windows. Most
4 * of the functions simply emulate Xlib functions.
3 * This file contains functions that draw to windows. Many of thees
4 * functions emulate Xlib functions.
55 *
66 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
7 * Copyright 2001-2009, Apple Inc.
7 * Copyright (c) 2001-2009 Apple Inc.
88 * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
9 * Copyright 2014 Marc Culler.
9 * Copyright (c) 2014-2020 Marc Culler.
1010 *
1111 * See the file "license.terms" for information on usage and redistribution
1212 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1616 #include "tkMacOSXDebug.h"
1717 #include "tkButton.h"
1818
19 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
19 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
2020 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext]
2121 #else
2222 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort]
4242
4343 static int useThemedToplevel = 0;
4444 static int useThemedFrame = 0;
45 static unsigned long transparentColor;
4546
4647 /*
4748 * Prototypes for functions used only in this file.
4849 */
4950
5051 static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr);
52 static NSImage *CreateNSImageFromPixmap(Pixmap pixmap, int width, int height);
53
5154
5255 /*
5356 *----------------------------------------------------------------------
6871 MODULE_SCOPE int
6972 TkMacOSXInitCGDrawing(
7073 Tcl_Interp *interp,
71 int enable,
74 TCL_UNUSED(int),
7275 int limit)
7376 {
7477 static Boolean initialized = FALSE;
8184 }
8285
8386 if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit",
84 (char *) &cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) {
87 (char *)&cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) {
8588 Tcl_ResetResult(interp);
8689 }
8790 cgAntiAliasLimit = limit;
9194 */
9295
9396 if (Tcl_LinkVar(interp, "::tk::mac::useThemedToplevel",
94 (char *) &useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) {
97 (char *)&useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) {
9598 Tcl_ResetResult(interp);
9699 }
97100 if (Tcl_LinkVar(interp, "::tk::mac::useThemedFrame",
98 (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) {
101 (char *)&useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) {
99102 Tcl_ResetResult(interp);
100103 }
104 transparentColor = TkMacOSXClearPixel();
101105 }
102106 return TCL_OK;
103107 }
105109 /*
106110 *----------------------------------------------------------------------
107111 *
108 * TkMacOSXBitmapRepFromDrawableRect
109 *
110 * Extract bitmap data from a MacOSX drawable as an NSBitmapImageRep.
111 *
112 * This is only used by XGetImage, which is never called. And this
113 * implementation does not work correctly. Originally it relied on
114 * [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was
115 * deprecated by Apple in OSX 10.14 and also required the use of other
116 * deprecated functions such as [NSView lockFocus]. Apple's suggested
117 * replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that
118 * is what is being used here. However, that method only works when the
119 * view has a valid CGContext, and a view is only guaranteed to have a
120 * valid context during a call to [NSView drawRect]. To further complicate
121 * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is
122 * asking the view to draw a subrectangle of itself into a special
123 * graphics context which is linked to the BitmapImageRep. But our
124 * implementation of [NSView drawRect] does not allow recursive calls. If
125 * called recursively it returns immediately without doing any drawing.
126 * So the bottom line is that this function either returns a NULL pointer
127 * or a black image. To make it useful would require a significant amount
128 * of rewriting of the drawRect method. Perhaps the next release of OSX
129 * will include some more helpful ways of doing this.
130 *
131 * Results:
132 * Returns an NSBitmapRep representing the image of the given rectangle of
133 * the given drawable. This object is retained. The caller is responsible
134 * for releasing it.
135 *
136 * NOTE: The x,y coordinates should be relative to a coordinate system
137 * with origin at the top left, as used by XImage and CGImage, not bottom
138 * left as used by NSView.
139 *
140 * Side effects:
141 * None
142 *
143 *----------------------------------------------------------------------
144 */
145
146 NSBitmapImageRep *
147 TkMacOSXBitmapRepFromDrawableRect(
148 Drawable drawable,
149 int x,
150 int y,
151 unsigned int width,
152 unsigned int height)
153 {
154 MacDrawable *mac_drawable = (MacDrawable *) drawable;
155 CGContextRef cg_context = NULL;
156 CGImageRef cg_image = NULL, sub_cg_image = NULL;
157 NSBitmapImageRep *bitmap_rep = NULL;
158 NSView *view = NULL;
159 if (mac_drawable->flags & TK_IS_PIXMAP) {
160 /*
161 * This MacDrawable is a bitmap, so its view is NULL.
162 */
163
164 CGRect image_rect = CGRectMake(x, y, width, height);
165
166 cg_context = TkMacOSXGetCGContextForDrawable(drawable);
167 cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context);
168 sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect);
169 if (sub_cg_image) {
170 bitmap_rep = [NSBitmapImageRep alloc];
171 [bitmap_rep initWithCGImage:sub_cg_image];
172 }
173 if (cg_image) {
174 CGImageRelease(cg_image);
175 }
176 } else if ((view = TkMacOSXDrawableView(mac_drawable)) != NULL) {
177 /*
178 * Convert Tk top-left to NSView bottom-left coordinates.
179 */
180
181 int view_height = [view bounds].size.height;
182 NSRect view_rect = NSMakeRect(x + mac_drawable->xOff,
183 view_height - height - y - mac_drawable->yOff,
184 width, height);
185
186 /*
187 * Attempt to copy from the view to a bitmapImageRep. If the view does
188 * not have a valid CGContext, doing this will silently corrupt memory
189 * and make a big mess. So, in that case, we mark the view as needing
190 * display and return NULL.
191 */
192
193 if (view == [NSView focusView]) {
194 bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect];
195 [bitmap_rep retain];
196 [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep];
197 } else {
198 TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap.");
199 [view setNeedsDisplay:YES];
200 return NULL;
201 }
202 } else {
203 TkMacOSXDbgMsg("Invalid source drawable");
204 }
205 return bitmap_rep;
206 }
207
208 /*
209 *----------------------------------------------------------------------
210 *
211 * XCopyArea --
212 *
213 * Copies data from one drawable to another.
214 *
215 * Results:
216 * None.
217 *
218 * Side effects:
219 * Data is moved from a window or bitmap to a second window or bitmap.
220 *
221 *----------------------------------------------------------------------
222 */
223
224 int
225 XCopyArea(
226 Display *display, /* Display. */
227 Drawable src, /* Source drawable. */
228 Drawable dst, /* Destination drawable. */
229 GC gc, /* GC to use. */
230 int src_x, /* X & Y, width & height */
231 int src_y, /* define the source rectangle */
232 unsigned int width, /* that will be copied. */
233 unsigned int height,
234 int dest_x, /* Dest X & Y on dest rect. */
235 int dest_y)
236 {
237 TkMacOSXDrawingContext dc;
238 MacDrawable *srcDraw = (MacDrawable *) src;
239 NSBitmapImageRep *bitmap_rep = NULL;
240 CGImageRef img = NULL;
241 CGRect bounds, srcRect, dstRect;
242
243 display->request++;
244 if (!width || !height) {
245 return BadDrawable;
246 }
247
248 if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
249 TkMacOSXDbgMsg("Failed to setup drawing context.");
250 return BadDrawable;
251 }
252
253 if (!dc.context) {
254 TkMacOSXDbgMsg("Invalid destination drawable - no context.");
255 return BadDrawable;
256 }
257
258 if (srcDraw->flags & TK_IS_PIXMAP) {
259 img = TkMacOSXCreateCGImageWithDrawable(src);
260 } else if (TkMacOSXDrawableWindow(src)) {
261 bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src,
262 src_x, src_y, width, height);
263 if (bitmap_rep) {
264 img = [bitmap_rep CGImage];
265 }
266 } else {
267 TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap.");
268 }
269
270 if (img) {
271 bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height);
272 srcRect = CGRectMake(src_x, src_y, width, height);
273 dstRect = CGRectMake(dest_x, dest_y, width, height);
274 TkMacOSXDrawCGImage(dst, gc, dc.context, img,
275 gc->foreground, gc->background, bounds, srcRect, dstRect);
276 CFRelease(img);
277 } else {
278 TkMacOSXDbgMsg("Failed to construct CGImage.");
279 }
280
281 TkMacOSXRestoreDrawingContext(&dc);
282 return Success;
283 }
284
285 /*
286 *----------------------------------------------------------------------
287 *
288 * XCopyPlane --
289 *
290 * Copies a bitmap from a source drawable to a destination drawable. The
291 * plane argument specifies which bit plane of the source contains the
292 * bitmap. Note that this implementation ignores the gc->function.
293 *
294 * Results:
295 * None.
296 *
297 * Side effects:
298 * Changes the destination drawable.
299 *
300 *----------------------------------------------------------------------
301 */
302
303 int
304 XCopyPlane(
305 Display *display, /* Display. */
306 Drawable src, /* Source drawable. */
307 Drawable dst, /* Destination drawable. */
308 GC gc, /* GC to use. */
309 int src_x, /* X & Y, width & height */
310 int src_y, /* define the source rectangle */
311 unsigned int width, /* that will be copied. */
312 unsigned int height,
313 int dest_x, /* Dest X & Y on dest rect. */
314 int dest_y,
315 unsigned long plane) /* Which plane to copy. */
316 {
317 TkMacOSXDrawingContext dc;
318 MacDrawable *srcDraw = (MacDrawable *) src;
319 MacDrawable *dstDraw = (MacDrawable *) dst;
320 CGRect bounds, srcRect, dstRect;
321 display->request++;
322 if (!width || !height) {
323 /* TkMacOSXDbgMsg("Drawing of empty area requested"); */
324 return BadDrawable;
325 }
326 if (plane != 1) {
327 Tcl_Panic("Unexpected plane specified for XCopyPlane");
328 }
329 if (srcDraw->flags & TK_IS_PIXMAP) {
330 if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
331 return BadDrawable;
332 }
333
334 CGContextRef context = dc.context;
335
336 if (context) {
337 CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src);
338
339 if (img) {
340 TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
341 unsigned long imageBackground = gc->background;
342
343 if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP) {
344 srcRect = CGRectMake(src_x, src_y, width, height);
345 CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(
346 clipPtr->value.pixmap);
347 CGImageRef submask = CGImageCreateWithImageInRect(
348 img, srcRect);
349 CGRect rect = CGRectMake(dest_x, dest_y, width, height);
350
351 rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff);
352 CGContextSaveGState(context);
353
354 /*
355 * Move the origin of the destination to top left.
356 */
357
358 CGContextTranslateCTM(context,
359 0, rect.origin.y + CGRectGetMaxY(rect));
360 CGContextScaleCTM(context, 1, -1);
361
362 /*
363 * Fill with the background color, clipping to the mask.
364 */
365
366 CGContextClipToMask(context, rect, submask);
367 TkMacOSXSetColorInContext(gc, gc->background, dc.context);
368 CGContextFillRect(context, rect);
369
370 /*
371 * Fill with the foreground color, clipping to the
372 * intersection of img and mask.
373 */
374
375 CGImageRef subimage = CGImageCreateWithImageInRect(
376 img, srcRect);
377 CGContextClipToMask(context, rect, subimage);
378 TkMacOSXSetColorInContext(gc, gc->foreground, context);
379 CGContextFillRect(context, rect);
380 CGContextRestoreGState(context);
381 CGImageRelease(img);
382 CGImageRelease(mask);
383 CGImageRelease(submask);
384 CGImageRelease(subimage);
385 } else {
386 bounds = CGRectMake(0, 0,
387 srcDraw->size.width, srcDraw->size.height);
388 srcRect = CGRectMake(src_x, src_y, width, height);
389 dstRect = CGRectMake(dest_x, dest_y, width, height);
390 TkMacOSXDrawCGImage(dst, gc, dc.context, img,
391 gc->foreground, imageBackground, bounds,
392 srcRect, dstRect);
393 CGImageRelease(img);
394 }
395 } else {
396 /* no image */
397 TkMacOSXDbgMsg("Invalid source drawable");
398 }
399 } else {
400 TkMacOSXDbgMsg("Invalid destination drawable - "
401 "could not get a bitmap context.");
402 }
403 TkMacOSXRestoreDrawingContext(&dc);
404 return Success;
405 } else {
406 /*
407 * Source drawable is a Window, not a Pixmap.
408 */
409
410 return XCopyArea(display, src, dst, gc, src_x, src_y, width, height,
411 dest_x, dest_y);
412 }
413 }
414
415 /*
416 *----------------------------------------------------------------------
417 *
418 * TkMacOSXCreateCGImageWithDrawable --
419 *
420 * Create a CGImage from the given Drawable.
421 *
422 * Results:
423 * CGImage, release after use.
424 *
425 * Side effects:
426 * None.
427 *
428 *----------------------------------------------------------------------
429 */
430
431 CGImageRef
432 TkMacOSXCreateCGImageWithDrawable(
433 Drawable drawable)
434 {
435 CGImageRef img = NULL;
436 CGContextRef context = TkMacOSXGetCGContextForDrawable(drawable);
437
438 if (context) {
439 img = CGBitmapContextCreateImage(context);
440 }
441 return img;
442 }
443
444 /*
445 *----------------------------------------------------------------------
446 *
447 * CreateNSImageWithPixmap --
112 * TkMacOSXGetNSImageFromTkImage --
113 *
114 * Get autoreleased NSImage for Tk_Image.
115 *
116 * Results:
117 * NSImage.
118 *
119 * Side effects:
120 * None.
121 *
122 *----------------------------------------------------------------------
123 */
124
125 NSImage *
126 TkMacOSXGetNSImageFromTkImage(
127 Display *display,
128 Tk_Image image,
129 int width,
130 int height)
131 {
132 Pixmap pixmap;
133 NSImage *nsImage;
134 if (width == 0 || height == 0) {
135 return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)];
136 }
137 pixmap = Tk_GetPixmap(display, None, width, height, 0);
138 Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
139 nsImage = CreateNSImageFromPixmap(pixmap, width, height);
140 Tk_FreePixmap(display, pixmap);
141
142 return [nsImage autorelease];
143 }
144
145 /*
146 *----------------------------------------------------------------------
147 *
148 * TkMacOSXGetNSImageFromBitmap --
149 *
150 * Get autoreleased NSImage for Bitmap.
151 *
152 * Results:
153 * NSImage.
154 *
155 * Side effects:
156 * None.
157 *
158 *----------------------------------------------------------------------
159 */
160
161 NSImage *
162 TkMacOSXGetNSImageFromBitmap(
163 Display *display,
164 Pixmap bitmap,
165 GC gc,
166 int width,
167 int height)
168 {
169 Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
170 NSImage *nsImage;
171
172 unsigned long origBackground = gc->background;
173
174 gc->background = transparentColor;
175 XSetClipOrigin(display, gc, 0, 0);
176 XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
177 gc->background = origBackground;
178 nsImage = CreateNSImageFromPixmap(pixmap, width, height);
179 Tk_FreePixmap(display, pixmap);
180
181 return [nsImage autorelease];
182 }
183
184 /*
185 *----------------------------------------------------------------------
186 *
187 * CreateNSImageFromPixmap --
448188 *
449189 * Create NSImage for Pixmap.
450190 *
458198 */
459199
460200 static NSImage *
461 CreateNSImageWithPixmap(
201 CreateNSImageFromPixmap(
462202 Pixmap pixmap,
463203 int width,
464204 int height)
466206 CGImageRef cgImage;
467207 NSImage *nsImage;
468208 NSBitmapImageRep *bitmapImageRep;
469
470 cgImage = TkMacOSXCreateCGImageWithDrawable(pixmap);
209 CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap);
210
211 if (context) {
212 cgImage = CGBitmapContextCreateImage(context);
213 } else {
214 return NULL;
215 }
471216 nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
472217 bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
473218 [nsImage addRepresentation:bitmapImageRep];
480225 /*
481226 *----------------------------------------------------------------------
482227 *
483 * TkMacOSXGetNSImageWithTkImage --
484 *
485 * Get autoreleased NSImage for Tk_Image.
486 *
487 * Results:
488 * NSImage.
489 *
490 * Side effects:
491 * None.
492 *
493 *----------------------------------------------------------------------
494 */
495
496 NSImage *
497 TkMacOSXGetNSImageWithTkImage(
498 Display *display,
499 Tk_Image image,
500 int width,
501 int height)
502 {
503 Pixmap pixmap;
504 NSImage *nsImage;
505 if (width == 0 || height == 0) {
506 return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)];
507 }
508 pixmap = Tk_GetPixmap(display, None, width, height, 0);
509 Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
510 nsImage = CreateNSImageWithPixmap(pixmap, width, height);
511 Tk_FreePixmap(display, pixmap);
512
513 return [nsImage autorelease];
514 }
515
516 /*
517 *----------------------------------------------------------------------
518 *
519 * TkMacOSXGetNSImageWithBitmap --
520 *
521 * Get autoreleased NSImage for Bitmap.
522 *
523 * Results:
524 * NSImage.
525 *
526 * Side effects:
527 * None.
528 *
529 *----------------------------------------------------------------------
530 */
531
532 NSImage *
533 TkMacOSXGetNSImageWithBitmap(
534 Display *display,
535 Pixmap bitmap,
536 GC gc,
537 int width,
538 int height)
539 {
540 Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
541 NSImage *nsImage;
542
543 unsigned long origBackground = gc->background;
544
545 gc->background = TRANSPARENT_PIXEL << 24;
546 XSetClipOrigin(display, gc, 0, 0);
547 XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
548 gc->background = origBackground;
549 nsImage = CreateNSImageWithPixmap(pixmap, width, height);
550 Tk_FreePixmap(display, pixmap);
551
552 return [nsImage autorelease];
553 }
554
555 /*
556 *----------------------------------------------------------------------
557 *
558228 * TkMacOSXGetCGContextForDrawable --
559229 *
560230 * Get CGContext for given Drawable, creating one if necessary.
572242 TkMacOSXGetCGContextForDrawable(
573243 Drawable drawable)
574244 {
575 MacDrawable *macDraw = (MacDrawable *) drawable;
245 MacDrawable *macDraw = (MacDrawable *)drawable;
576246
577247 if (macDraw && (macDraw->flags & TK_IS_PIXMAP) && !macDraw->context) {
578248 const size_t bitsPerComponent = 8;
590260
591261 if (macDraw->flags & TK_IS_BW_PIXMAP) {
592262 bitsPerPixel = 8;
593 bitmapInfo = (CGBitmapInfo) kCGImageAlphaOnly;
263 bitmapInfo = (CGBitmapInfo)kCGImageAlphaOnly;
594264 } else {
595265 colorspace = CGColorSpaceCreateDeviceRGB();
596266 bitsPerPixel = 32;
599269 bytesPerRow = ((size_t)
600270 macDraw->size.width * bitsPerPixel + 127) >> 3 & ~15;
601271 len = macDraw->size.height * bytesPerRow;
602 data = ckalloc(len);
272 data = (char *)ckalloc(len);
603273 bzero(data, len);
604274 macDraw->context = CGBitmapContextCreate(data, macDraw->size.width,
605275 macDraw->size.height, bitsPerComponent, bytesPerRow,
643313 CGRect srcBounds,
644314 CGRect dstBounds)
645315 {
646 MacDrawable *macDraw = (MacDrawable *) d;
316 MacDrawable *macDraw = (MacDrawable *)d;
647317
648318 if (macDraw && context && image) {
649319 CGImageRef subImage = NULL;
661331 dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff);
662332 if (CGImageIsMask(image)) {
663333 if (macDraw->flags & TK_IS_BW_PIXMAP) {
334
664335 /*
665336 * Set fill color to black; background comes from the context,
666337 * or is transparent.
667338 */
668339
669 if (imageBackground != TRANSPARENT_PIXEL << 24) {
340 if (imageBackground != transparentColor) {
670341 CGContextClearRect(context, dstBounds);
671342 }
672343 CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
673344 } else {
674 if (imageBackground != TRANSPARENT_PIXEL << 24) {
345 if (imageBackground != transparentColor) {
675346 TkMacOSXSetColorInContext(gc, imageBackground, context);
676347 CGContextFillRect(context, dstBounds);
677348 }
738409 int npoints, /* Number of points. */
739410 int mode) /* Line drawing mode. */
740411 {
741 MacDrawable *macWin = (MacDrawable *) d;
412 MacDrawable *macWin = (MacDrawable *)d;
742413 TkMacOSXDrawingContext dc;
743414 int i, lw = gc->line_width;
744415
747418 }
748419
749420 display->request++;
750 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
421 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
751422 return BadDrawable;
752423 }
753424 if (dc.context) {
810481 XSegment *segments,
811482 int nsegments)
812483 {
813 MacDrawable *macWin = (MacDrawable *) d;
484 MacDrawable *macWin = (MacDrawable *)d;
814485 TkMacOSXDrawingContext dc;
815486 int i, lw = gc->line_width;
816487
817488 display->request++;
818 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
489 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
819490 return BadDrawable;
820491 }
821492 if (dc.context) {
859530 GC gc, /* Use this GC. */
860531 XPoint *points, /* Array of points. */
861532 int npoints, /* Number of points. */
862 int shape, /* Shape to draw. */
533 TCL_UNUSED(int), /* Shape to draw. */
863534 int mode) /* Drawing mode. */
864535 {
865 MacDrawable *macWin = (MacDrawable *) d;
536 MacDrawable *macWin = (MacDrawable *)d;
866537 TkMacOSXDrawingContext dc;
867538 int i;
868539
869540 display->request++;
870 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
541 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
871542 return BadDrawable;
872543 }
873544 if (dc.context) {
920591 unsigned int width, /* Width & height of rect. */
921592 unsigned int height)
922593 {
923 MacDrawable *macWin = (MacDrawable *) d;
594 MacDrawable *macWin = (MacDrawable *)d;
924595 TkMacOSXDrawingContext dc;
925596 int lw = gc->line_width;
926597
929600 }
930601
931602 display->request++;
932 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
603 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
933604 return BadDrawable;
934605 }
935606 if (dc.context) {
970641 *----------------------------------------------------------------------
971642 */
972643
973 void
644 int
974645 XDrawRectangles(
975646 Display *display,
976 Drawable drawable,
647 Drawable d,
977648 GC gc,
978649 XRectangle *rectArr,
979650 int nRects)
980651 {
981 MacDrawable *macWin = (MacDrawable *) drawable;
652 MacDrawable *macWin = (MacDrawable *)d;
982653 TkMacOSXDrawingContext dc;
983654 XRectangle * rectPtr;
984655 int i, lw = gc->line_width;
985656
986657 display->request++;
987 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
988 return;
658 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
659 return BadDrawable;
989660 }
990661 if (dc.context) {
991662 CGRect rect;
1003674 }
1004675 }
1005676 TkMacOSXRestoreDrawingContext(&dc);
677 return Success;
1006678 }
1007679 #endif
1008680
1030702 XRectangle *rectangles, /* Rectangle array. */
1031703 int n_rectangles) /* Number of rectangles. */
1032704 {
1033 MacDrawable *macWin = (MacDrawable *) d;
705 MacDrawable *macWin = (MacDrawable *)d;
1034706 TkMacOSXDrawingContext dc;
1035707 XRectangle * rectPtr;
1036708 int i;
1037709
1038710 display->request++;
1039 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
711 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1040712 return BadDrawable;
1041713 }
1042714 if (dc.context) {
1089761 TkMacOSXDrawingContext dc;
1090762 CGRect outerRect, innerRect;
1091763
1092 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
764 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1093765 return;
1094766 }
1095767 if (dc.context) {
1132804 int angle1, /* Staring angle of arc. */
1133805 int angle2) /* Extent of arc. */
1134806 {
1135 MacDrawable *macWin = (MacDrawable *) d;
807 MacDrawable *macWin = (MacDrawable *)d;
1136808 TkMacOSXDrawingContext dc;
1137809 int lw = gc->line_width;
1138810
1141813 }
1142814
1143815 display->request++;
1144 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
816 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1145817 return BadDrawable;
1146818 }
1147819 if (dc.context) {
1206878 XArc *arcArr,
1207879 int nArcs)
1208880 {
1209 MacDrawable *macWin = (MacDrawable *) d;
881 MacDrawable *macWin = (MacDrawable *)d;
1210882 TkMacOSXDrawingContext dc;
1211883 XArc *arcPtr;
1212884 int i, lw = gc->line_width;
1213885
1214886 display->request++;
1215 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
887 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1216888 return BadDrawable;
1217889 }
1218890 if (dc.context) {
1285957 int angle1, /* Staring angle of arc. */
1286958 int angle2) /* Extent of arc. */
1287959 {
1288 MacDrawable *macWin = (MacDrawable *) d;
960 MacDrawable *macWin = (MacDrawable *)d;
1289961 TkMacOSXDrawingContext dc;
1290962 int lw = gc->line_width;
1291963
1294966 }
1295967
1296968 display->request++;
1297 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
969 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1298970 return BadDrawable;
1299971 }
1300972 if (dc.context) {
13541026 *----------------------------------------------------------------------
13551027 */
13561028
1357 void
1029 int
13581030 XFillArcs(
13591031 Display *display,
13601032 Drawable d,
13621034 XArc *arcArr,
13631035 int nArcs)
13641036 {
1365 MacDrawable *macWin = (MacDrawable *) d;
1037 MacDrawable *macWin = (MacDrawable *)d;
13661038 TkMacOSXDrawingContext dc;
13671039 XArc * arcPtr;
13681040 int i, lw = gc->line_width;
13691041
13701042 display->request++;
1371 if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
1372 return;
1043 if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) {
1044 return BadDrawable;
13731045 }
13741046 if (dc.context) {
13751047 CGRect rect;
14171089 }
14181090 }
14191091 TkMacOSXRestoreDrawingContext(&dc);
1092 return Success;
14201093 }
14211094 #endif
14221095
14581131 int
14591132 TkScrollWindow(
14601133 Tk_Window tkwin, /* The window to be scrolled. */
1461 GC gc, /* GC for window to be scrolled. */
1134 TCL_UNUSED(GC), /* GC for window to be scrolled. */
14621135 int x, int y, /* Position rectangle to be scrolled. */
14631136 int width, int height,
14641137 int dx, int dy, /* Distance rectangle should be moved. */
14651138 TkRegion damageRgn) /* Region to accumulate damage in. */
14661139 {
14671140 Drawable drawable = Tk_WindowId(tkwin);
1468 MacDrawable *macDraw = (MacDrawable *) drawable;
1469 TKContentView *view = (TKContentView *) TkMacOSXDrawableView(macDraw);
1141 MacDrawable *macDraw = (MacDrawable *)drawable;
1142 TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(macDraw);
14701143 CGRect srcRect, dstRect;
14711144 HIShapeRef dmgRgn = NULL, extraRgn = NULL;
14721145 NSRect bounds, visRect, scrollSrc, scrollDst;
15541227
15551228 void
15561229 TkMacOSXSetUpGraphicsPort(
1557 GC gc, /* GC to apply to current port. */
1558 void *destPort)
1230 TCL_UNUSED(GC), /* GC to apply to current port. */
1231 TCL_UNUSED(void *))
15591232 {
15601233 Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!");
15611234 }
15661239 *
15671240 * TkMacOSXSetUpDrawingContext --
15681241 *
1569 * Set up a drawing context for the given drawable and GC.
1570 *
1571 * Results:
1572 * Boolean indicating whether it is ok to draw; if false, drawing context
1573 * was not setup, so do not attempt to draw and do not call
1242 * Set up a drawing context for the given drawable from an X GC.
1243 *
1244 * Results:
1245 * Boolean indicating whether it is ok to draw; if false, the drawing
1246 * context was not setup, so do not attempt to draw and do not call
15741247 * TkMacOSXRestoreDrawingContext().
15751248 *
15761249 * Side effects:
1577 * None.
1250 * May modify or create the drawable's graphics context. May expand the
1251 * drawable's dirty rectangle. When the result is true The dcPtr
1252 * parameter is set to reference the new or updated drawing context.
15781253 *
15791254 *----------------------------------------------------------------------
15801255 */
15831258 TkMacOSXSetupDrawingContext(
15841259 Drawable d,
15851260 GC gc,
1586 int useCG, /* advisory only ! */
15871261 TkMacOSXDrawingContext *dcPtr)
15881262 {
1589 MacDrawable *macDraw = (MacDrawable *) d;
1263 MacDrawable *macDraw = (MacDrawable *)d;
15901264 Bool canDraw = true;
1591 NSWindow *win = NULL;
1265 TKContentView *view = nil;
15921266 TkMacOSXDrawingContext dc = {};
1593 CGRect clipBounds;
15941267
15951268 /*
1596 * If the drawable is not a pixmap and it has an associated NSWindow then
1597 * we know we are drawing to a window.
1269 * If the drawable is not a pixmap, get the associated NSView.
15981270 */
15991271
16001272 if (!(macDraw->flags & TK_IS_PIXMAP)) {
1601 win = TkMacOSXDrawableWindow(d);
1273 view = (TKContentView *)TkMacOSXGetNSViewForDrawable(d);
1274 if (!view) {
1275 Tcl_Panic("TkMacOSXSetupDrawingContext(): "
1276 "no NSView to draw into !");
1277 }
16021278 }
16031279
16041280 /*
1605 * Check that we have a non-empty clipping region.
1281 * Intersect the drawable's clipping region with the region stored in the
1282 * X GC. If the resulting region is empty, don't do any drawing.
16061283 */
16071284
16081285 dc.clipRgn = TkMacOSXGetClipRgn(d);
16131290 }
16141291
16151292 /*
1616 * If we already have a CGContext, use it. Otherwise, if we are drawing to
1617 * a window then we can get one from the window.
1293 * If the drawable already has a CGContext, use it. Otherwise, we must be
1294 * drawing to a window and we use the current context of its ContentView.
16181295 */
16191296
16201297 dc.context = TkMacOSXGetCGContextForDrawable(d);
16211298 if (dc.context) {
1622 dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context);
1623 } else if (win) {
1624 NSView *view = TkMacOSXDrawableView(macDraw);
1625
1626 if (!view) {
1627 Tcl_Panic("TkMacOSXSetupDrawingContext(): "
1628 "no NSView to draw into !");
1629 }
1630
1631 /*
1632 * We can only draw into the view when the current CGContext is valid
1633 * and belongs to the view. Validity can only be guaranteed inside of
1634 * a view's drawRect or setFrame methods. The isDrawing attribute
1635 * tells us whether we are being called from one of those methods.
1636 *
1637 * If the CGContext is not valid then we mark our view as needing
1638 * display in the bounding rectangle of the clipping region and
1639 * return failure. That rectangle should get drawn in a later call
1640 * to drawRect.
1641 *
1642 * As an exception to the above, if mouse buttons are pressed at the
1643 * moment when we fail to obtain a valid context we schedule the entire
1644 * view for a redraw rather than just the clipping region. The purpose
1645 * of this is to make sure that scrollbars get updated correctly.
1646 */
1647
1648 if (![NSApp isDrawing] || view != [NSView focusView]) {
1649 NSRect bounds = [view bounds];
1650 NSRect dirtyNS = bounds;
1651 if ([NSEvent pressedMouseButtons]) {
1652 [view setNeedsDisplay:YES];
1653 } else {
1654 CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
1655 .ty = dirtyNS.size.height};
1656 if (dc.clipRgn) {
1657 CGRect dirtyCG = NSRectToCGRect(dirtyNS);
1658 HIShapeGetBounds(dc.clipRgn, &dirtyCG);
1659 dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t));
1660 }
1661 [view setNeedsDisplayInRect:dirtyNS];
1662 }
1663 canDraw = false;
1664 goto end;
1665 }
1299 dc.portBounds = CGContextGetClipBoundingBox(dc.context);
1300 } else {
1301 NSRect drawingBounds, currentBounds;
16661302
16671303 dc.view = view;
16681304 dc.context = GET_CGCONTEXT;
16691305 dc.portBounds = NSRectToCGRect([view bounds]);
16701306 if (dc.clipRgn) {
1671 clipBounds = CGContextGetClipBoundingBox(dc.context);
1672 }
1673 } else {
1674 Tcl_Panic("TkMacOSXSetupDrawingContext(): "
1675 "no context to draw into !");
1307 CGRect clipBounds;
1308 CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
1309 .ty = [view bounds].size.height};
1310 HIShapeGetBounds(dc.clipRgn, &clipBounds);
1311 clipBounds = CGRectApplyAffineTransform(clipBounds, t);
1312 drawingBounds = NSRectFromCGRect(clipBounds);
1313 } else {
1314 drawingBounds = [view bounds];
1315 }
1316
1317 /*
1318 * We can only draw into the NSView which is the current focusView.
1319 * When the current [NSView focusView] is nil, the CGContext for
1320 * [NSGraphicsContext currentContext] is nil. Otherwise the current
1321 * CGContext draws into the current focusView. An NSView is guaranteed
1322 * to be the focusView when its drawRect or setFrame methods are
1323 * running. Prior to OSX 10.14 it was also possible to call the
1324 * lockFocus method to force an NSView to become the current focusView.
1325 * But that method was deprecated in 10.14 and so is no longer used by
1326 * Tk. Instead, if the view is not the current focusView then we add
1327 * the drawing bounds to its dirty rectangle and return false. The
1328 * part of the view inside the drawing bounds will get redrawn during
1329 * the next call to its drawRect method.
1330 */
1331
1332 if (view != [NSView focusView]) {
1333 [view addTkDirtyRect:drawingBounds];
1334 canDraw = false;
1335 goto end;
1336 }
1337
1338 /*
1339 * Drawing will also fail when the view is the current focusView but
1340 * the clipping rectangle set by drawRect does not contain the clipping
1341 * region of our drawing context. (See bug [2a61eca3a8].) If part of
1342 * the drawing bounds will be clipped then we draw whatever we can, but
1343 * we also add the drawing bounds to the view's dirty rectangle so it
1344 * will get redrawn in the next call to its drawRect method.
1345 */
1346
1347 currentBounds = NSRectFromCGRect(CGContextGetClipBoundingBox(dc.context));
1348 if (!NSContainsRect(currentBounds, drawingBounds)) {
1349 [view addTkDirtyRect:drawingBounds];
1350 }
16761351 }
16771352
16781353 /*
1679 * Configure the drawing context.
1354 * Finish configuring the drawing context.
16801355 */
16811356
1682 if (dc.context) {
1683 CGAffineTransform t = {
1684 .a = 1, .b = 0,
1685 .c = 0, .d = -1,
1686 .tx = 0,
1687 .ty = dc.portBounds.size.height
1357 CGAffineTransform t = {
1358 .a = 1, .b = 0,
1359 .c = 0, .d = -1,
1360 .tx = 0,
1361 .ty = dc.portBounds.size.height
1362 };
1363
1364 dc.portBounds.origin.x += macDraw->xOff;
1365 dc.portBounds.origin.y += macDraw->yOff;
1366 CGContextSaveGState(dc.context);
1367 CGContextSetTextDrawingMode(dc.context, kCGTextFill);
1368 CGContextConcatCTM(dc.context, t);
1369 if (dc.clipRgn) {
1370
1371 #ifdef TK_MAC_DEBUG_DRAWING
1372 CGContextSaveGState(dc.context);
1373 ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
1374 CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1);
1375 CGContextEOFillPath(dc.context);
1376 CGContextRestoreGState(dc.context);
1377 #endif /* TK_MAC_DEBUG_DRAWING */
1378
1379 CGRect r;
1380 CGRect b = CGRectApplyAffineTransform(
1381 CGContextGetClipBoundingBox(dc.context), t);
1382 if (!HIShapeIsRectangular(dc.clipRgn) ||
1383 !CGRectContainsRect(*HIShapeGetBounds(dc.clipRgn, &r), b)) {
1384 ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
1385 CGContextEOClip(dc.context);
1386 }
1387 }
1388 if (gc) {
1389 static const CGLineCap cgCap[] = {
1390 [CapNotLast] = kCGLineCapButt,
1391 [CapButt] = kCGLineCapButt,
1392 [CapRound] = kCGLineCapRound,
1393 [CapProjecting] = kCGLineCapSquare,
16881394 };
1689
1690 dc.portBounds.origin.x += macDraw->xOff;
1691 dc.portBounds.origin.y += macDraw->yOff;
1692 CGContextSaveGState(dc.context);
1693 CGContextSetTextDrawingMode(dc.context, kCGTextFill);
1694 CGContextConcatCTM(dc.context, t);
1695 if (dc.clipRgn) {
1696 #ifdef TK_MAC_DEBUG_DRAWING
1697 CGContextSaveGState(dc.context);
1698 ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
1699 CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1);
1700 CGContextEOFillPath(dc.context);
1701 CGContextRestoreGState(dc.context);
1702 #endif /* TK_MAC_DEBUG_DRAWING */
1703 CGRect r;
1704
1705 if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect(
1706 *HIShapeGetBounds(dc.clipRgn, &r),
1707 CGRectApplyAffineTransform(clipBounds, t))) {
1708 ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
1709 CGContextEOClip(dc.context);
1395 static const CGLineJoin cgJoin[] = {
1396 [JoinMiter] = kCGLineJoinMiter,
1397 [JoinRound] = kCGLineJoinRound,
1398 [JoinBevel] = kCGLineJoinBevel,
1399 };
1400 bool shouldAntialias = !notAA(gc->line_width);
1401 double w = gc->line_width;
1402
1403 TkMacOSXSetColorInContext(gc, gc->foreground, dc.context);
1404 if (view) {
1405 CGContextSetPatternPhase(dc.context, CGSizeMake(
1406 dc.portBounds.size.width, dc.portBounds.size.height));
1407 }
1408 if (gc->function != GXcopy) {
1409 TkMacOSXDbgMsg("Logical functions other than GXcopy are "
1410 "not supported for CG drawing!");
1411 }
1412 if (!shouldAntialias) {
1413
1414 /*
1415 * Make non-antialiased CG drawing look more like X11.
1416 */
1417
1418 w -= (gc->line_width ? NON_AA_CG_OFFSET : 0);
1419 }
1420 CGContextSetShouldAntialias(dc.context, shouldAntialias);
1421 CGContextSetLineWidth(dc.context, w);
1422 if (gc->line_style != LineSolid) {
1423 int num = 0;
1424 char *p = &gc->dashes;
1425 CGFloat dashOffset = gc->dash_offset;
1426 dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0;
1427 CGFloat lengths[10];
1428
1429 while (p[num] != '\0' && num < 10) {
1430 lengths[num] = p[num];
1431 num++;
17101432 }
1711 }
1712 if (gc) {
1713 static const CGLineCap cgCap[] = {
1714 [CapNotLast] = kCGLineCapButt,
1715 [CapButt] = kCGLineCapButt,
1716 [CapRound] = kCGLineCapRound,
1717 [CapProjecting] = kCGLineCapSquare,
1718 };
1719 static const CGLineJoin cgJoin[] = {
1720 [JoinMiter] = kCGLineJoinMiter,
1721 [JoinRound] = kCGLineJoinRound,
1722 [JoinBevel] = kCGLineJoinBevel,
1723 };
1724 bool shouldAntialias;
1725 double w = gc->line_width;
1726
1727 TkMacOSXSetColorInContext(gc, gc->foreground, dc.context);
1728 if (win) {
1729 CGContextSetPatternPhase(dc.context, CGSizeMake(
1730 dc.portBounds.size.width, dc.portBounds.size.height));
1731 }
1732 if (gc->function != GXcopy) {
1733 TkMacOSXDbgMsg("Logical functions other than GXcopy are "
1734 "not supported for CG drawing!");
1735 }
1736
1737 /*
1738 * When should we antialias?
1739 */
1740
1741 shouldAntialias = !notAA(gc->line_width);
1742 if (!shouldAntialias) {
1743 /*
1744 * Make non-antialiased CG drawing look more like X11.
1745 */
1746
1747 w -= (gc->line_width ? NON_AA_CG_OFFSET : 0);
1748 }
1749 CGContextSetShouldAntialias(dc.context, shouldAntialias);
1750 CGContextSetLineWidth(dc.context, w);
1751 if (gc->line_style != LineSolid) {
1752 int num = 0;
1753 char *p = &gc->dashes;
1754 CGFloat dashOffset = gc->dash_offset;
1755 CGFloat lengths[10];
1756
1757 while (p[num] != '\0' && num < 10) {
1758 lengths[num] = p[num];
1759 num++;
1760 }
1761 CGContextSetLineDash(dc.context, dashOffset, lengths, num);
1762 }
1763 if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) {
1764 CGContextSetLineCap(dc.context,
1765 cgCap[(unsigned) gc->cap_style]);
1766 }
1767 if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) {
1768 CGContextSetLineJoin(dc.context,
1769 cgJoin[(unsigned) gc->join_style]);
1770 }
1433 CGContextSetLineDash(dc.context, dashOffset, lengths, num);
1434 }
1435 if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) {
1436 CGContextSetLineCap(dc.context, cgCap[(unsigned) gc->cap_style]);
1437 }
1438 if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) {
1439 CGContextSetLineJoin(dc.context, cgJoin[(unsigned) gc->join_style]);
17711440 }
17721441 }
17731442
17741443 end:
1444
17751445 #ifdef TK_MAC_DEBUG_DRAWING
17761446 if (!canDraw && win != NULL) {
17771447 TkWindow *winPtr = TkMacOSXGetTkWindow(win);
17821452 }
17831453 }
17841454 #endif
1455
17851456 if (!canDraw && dc.clipRgn) {
17861457 CFRelease(dc.clipRgn);
17871458 dc.clipRgn = NULL;
18431514 TkMacOSXGetClipRgn(
18441515 Drawable drawable) /* Drawable. */
18451516 {
1846 MacDrawable *macDraw = (MacDrawable *) drawable;
1517 MacDrawable *macDraw = (MacDrawable *)drawable;
18471518 HIShapeRef clipRgn = NULL;
18481519
18491520 if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) {
18511522 #ifdef TK_MAC_DEBUG_DRAWING
18521523 TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName);
18531524
1854 NSView *view = TkMacOSXDrawableView(macDraw);
1525 NSView *view = TkMacOSXGetNSViewForDrawable(macDraw);
1526 CGContextRef context = GET_CGCONTEXT;
18551527
18561528 CGContextSaveGState(context);
18571529 CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0,
19131585
19141586 void
19151587 TkpClipDrawableToRect(
1916 Display *display,
1588 TCL_UNUSED(Display *),
19171589 Drawable d,
19181590 int x, int y,
19191591 int width, int height)
19201592 {
1921 MacDrawable *macDraw = (MacDrawable *) d;
1593 MacDrawable *macDraw = (MacDrawable *)d;
19221594
19231595 if (macDraw->drawRgn) {
19241596 CFRelease(macDraw->drawRgn);
19651637 HIShapeRef *clipRgnPtr) /* must point to initialized variable */
19661638 {
19671639 if (gc && gc->clip_mask &&
1968 ((TkpClipMask *) gc->clip_mask)->type == TKP_CLIP_REGION) {
1969 TkRegion gcClip = ((TkpClipMask *) gc->clip_mask)->value.region;
1970 int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin;
1971 int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin;
1640 ((TkpClipMask *)gc->clip_mask)->type == TKP_CLIP_REGION) {
1641 TkRegion gcClip = ((TkpClipMask *)gc->clip_mask)->value.region;
1642 int xOffset = ((MacDrawable *)d)->xOff + gc->clip_x_origin;
1643 int yOffset = ((MacDrawable *)d)->yOff + gc->clip_y_origin;
19721644 HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn;
19731645
1974 TkMacOSXOffsetRegion(gcClip, xOffset, yOffset);
1646 XOffsetRegion(gcClip, xOffset, yOffset);
19751647 gcClipRgn = TkMacOSXGetNativeRegion(gcClip);
19761648 if (clipRgn) {
19771649 *clipRgnPtr = HIShapeCreateIntersection(gcClipRgn, clipRgn);
19801652 *clipRgnPtr = HIShapeCreateCopy(gcClipRgn);
19811653 }
19821654 CFRelease(gcClipRgn);
1983 TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset);
1655 XOffsetRegion(gcClip, -xOffset, -yOffset);
19841656 }
19851657 }
19861658
20041676
20051677 void *
20061678 TkMacOSXMakeStippleMap(
2007 Drawable drawable, /* Window to apply stipple. */
2008 Drawable stipple) /* The stipple pattern. */
1679 TCL_UNUSED(Drawable), /* Window to apply stipple. */
1680 TCL_UNUSED(Drawable)) /* The stipple pattern. */
20091681 {
20101682 return NULL;
20111683 }
445445 for (containerPtr = firstContainerPtr; containerPtr != NULL;
446446 containerPtr = containerPtr->nextPtr) {
447447 if (containerPtr->embeddedPtr == winPtr) {
448 return (MacDrawable *) containerPtr->parent;
448 return (MacDrawable *)containerPtr->parent;
449449 }
450450 }
451451 Tcl_Panic("TkMacOSXContainerId couldn't find window");
852852 * Here we are following unix, by destroying the container.
853853 */
854854
855 Tk_DestroyWindow((Tk_Window) winPtr);
855 Tk_DestroyWindow((Tk_Window)winPtr);
856856 }
857857 Tk_DeleteErrorHandler(errHandler);
858858 }
901901
902902 errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
903903 -1, -1, NULL, NULL);
904 Tk_MoveResizeWindow((Tk_Window) containerPtr->embeddedPtr, 0, 0,
905 (unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr),
904 Tk_MoveResizeWindow((Tk_Window)containerPtr->embeddedPtr, 0, 0,
905 (unsigned) Tk_Width((Tk_Window)containerPtr->parentPtr),
906906 (unsigned) Tk_Height((Tk_Window)containerPtr->parentPtr));
907907 Tk_DeleteErrorHandler(errHandler);
908908 }
10471047 * if the window's size didn't change then generate a configure event.
10481048 */
10491049
1050 Tk_GeometryRequest((Tk_Window) winPtr, width, height);
1051 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {
1052 /* Empty loop body. */
1053 }
1050 Tk_GeometryRequest((Tk_Window)winPtr, width, height);
1051 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {}
10541052 if ((winPtr->changes.width != width)
10551053 || (winPtr->changes.height != height)) {
10561054 EmbedSendConfigure(containerPtr);
9191 GC bgGC;
9292 Tk_Window tkwin = entryPtr->tkwin;
9393 int oldWidth = 0;
94 MacDrawable *macDraw = (MacDrawable *) d;
94 MacDrawable *macDraw = (MacDrawable *)d;
9595 const HIThemeFrameDrawInfo info = {
9696 .version = 0,
9797 .kind = kHIThemeFrameTextFieldSquare,
154154 bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
155155 bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
156156 bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
157 if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
157 if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) {
158158
159159 /*
160160 * No graphics context is available. If the widget is a Spinbox, we
207207 TkMacOSXDrawingContext dc;
208208 XRectangle rects[1];
209209 GC bgGC;
210 MacDrawable *macDraw = (MacDrawable *) d;
210 MacDrawable *macDraw = (MacDrawable *)d;
211211 HIThemeButtonDrawInfo info = {
212212 .version = 0,
213213 .adornment = kThemeAdornmentNone,
264264 rects[0].height = Tk_Height(tkwin);
265265 XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1);
266266
267 if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
267 if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) {
268268 return 0;
269269 }
270270 ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
103103 return processedEvent;
104104 }
105105 @end
106 #pragma mark -
106107
107 #pragma mark -
108
109 /*
110 *----------------------------------------------------------------------
111 *
112 * TkMacOSXFlushWindows --
113 *
114 * This routine is a stub called by XSync, which is called during the Tk
115 * update command. The language specification does not require that the
116 * update command be synchronous but many of the tests implicitly assume
117 * that it is. It is definitely asynchronous on macOS since many idle
118 * tasks are run inside of the drawRect method of a window's contentView,
119 * which will not be called until after this function returns.
120 *
121 * Results:
122 * None.
123 *
124 * Side effects: Processes all pending idle events then calls the display
125 * method of each visible window.
126 *
127 *----------------------------------------------------------------------
128 */
129
130 MODULE_SCOPE void
131 TkMacOSXFlushWindows(void)
132 {
133 if (Tk_GetNumMainWindows() == 0) {
134 return;
135 }
136 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){}
137 for (NSWindow *w in [NSApp orderedWindows]) {
138 [w display];
139 }
140 }
141
142
143108 /*
144109 * Local Variables:
145110 * mode: objc
1717 #include "tkMacOSXInt.h"
1818 #endif
1919
20 MODULE_SCOPE void TkMacOSXFlushWindows(void);
20 /*
21 * Currently nothing needs to be declared here.
22 */
2123
2224 #endif
5555 #define ThemeFont(n, ...) { kTheme##n##Font, "system" #n "Font", ##__VA_ARGS__ }
5656 static const struct SystemFontMapEntry systemFontMap[] = {
5757 ThemeFont(System, "TkDefaultFont", "TkIconFont"),
58 ThemeFont(EmphasizedSystem, "TkCaptionFont"),
58 ThemeFont(EmphasizedSystem, "TkCaptionFont", NULL),
5959 ThemeFont(SmallSystem, "TkHeadingFont", "TkTooltipFont"),
60 ThemeFont(SmallEmphasizedSystem),
61 ThemeFont(Application, "TkTextFont"),
62 ThemeFont(Label, "TkSmallCaptionFont"),
63 ThemeFont(Views),
64 ThemeFont(MenuTitle),
65 ThemeFont(MenuItem, "TkMenuFont"),
66 ThemeFont(MenuItemMark),
67 ThemeFont(MenuItemCmdKey),
68 ThemeFont(WindowTitle),
69 ThemeFont(PushButton),
70 ThemeFont(UtilityWindowTitle),
71 ThemeFont(AlertHeader),
72 ThemeFont(Toolbar),
73 ThemeFont(MiniSystem),
74 { kThemeSystemFontDetail, "systemDetailSystemFont" },
75 { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont" },
76 { -1, NULL }
60 ThemeFont(SmallEmphasizedSystem, NULL, NULL),
61 ThemeFont(Application, "TkTextFont", NULL),
62 ThemeFont(Label, "TkSmallCaptionFont", NULL),
63 ThemeFont(Views, NULL, NULL),
64 ThemeFont(MenuTitle, NULL, NULL),
65 ThemeFont(MenuItem, "TkMenuFont", NULL),
66 ThemeFont(MenuItemMark, NULL, NULL),
67 ThemeFont(MenuItemCmdKey, NULL, NULL),
68 ThemeFont(WindowTitle, NULL, NULL),
69 ThemeFont(PushButton, NULL, NULL),
70 ThemeFont(UtilityWindowTitle, NULL, NULL),
71 ThemeFont(AlertHeader, NULL, NULL),
72 ThemeFont(Toolbar, NULL, NULL),
73 ThemeFont(MiniSystem, NULL, NULL),
74 { kThemeSystemFontDetail, "systemDetailSystemFont", NULL, NULL },
75 { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont", NULL, NULL },
76 { -1, NULL, NULL, NULL }
7777 };
7878 #undef ThemeFont
7979
9292 static int CreateNamedSystemFont(Tcl_Interp *interp,
9393 Tk_Window tkwin, const char *name,
9494 TkFontAttributes *faPtr);
95 static void DrawCharsInContext(Display *display, Drawable drawable,
96 GC gc, Tk_Font tkfont, const char *source,
97 int numBytes, int rangeStart, int rangeLength,
98 int x, int y, double angle);
9995
10096 #pragma mark -
10197 #pragma mark Font Helpers:
10298
10399 /*
104 *---------------------------------------------------------------------------
105 *
106 * TclUniToNSString --
107 *
108 * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot
109 * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8
110 * encoding requires 4 bytes.
111 *
112 * As a workaround, these versions of Tcl encode non-BMP characters as a string
113 * of length 6 in which the high and low UTF-16 surrogates have been encoded
114 * using the UTF-8 algorithm. The UTF-8 encoding does not allow encoding
115 * surrogates, so these 6-byte strings are not valid UTF-8, and hence Apple's
116 * NString class will refuse to instantiate an NSString from the 6-byte
117 * encoding. This function allows creating an NSString from a C-string which
118 * has been encoded using this scheme.
119 *
120 * Results:
121 * An NSString, which may be nil.
122 *
123 * Side effects:
124 * None.
125 *---------------------------------------------------------------------------
126 */
127
128 MODULE_SCOPE NSString*
129 TclUniToNSString(
130 const char *source,
131 int numBytes)
132 {
133 NSString *string = [[NSString alloc] initWithBytesNoCopy:(void *)source
134 length:numBytes
135 encoding:NSUTF8StringEncoding
136 freeWhenDone:NO];
137 if (!string) {
138 const unichar *characters = ckalloc(numBytes*sizeof(unichar));
139 const char *in = source;
140 unichar *out = (unichar *) characters;
141 while (in < source + numBytes) {
142 in += Tcl_UtfToUniChar(in, out++);
143 }
144 string = [[NSString alloc] initWithCharacters:characters
145 length:(out - characters)];
146 ckfree(characters);
147 }
148 return string;
149 }
150
151 /*
152 *---------------------------------------------------------------------------
153 *
154 * TclUniAtIndex --
155 *
156 * Write a sequence of bytes up to length 6 which is an encoding of a UTF-16
157 * character in an NSString. Also record the unicode code point of the character.
158 * this may be a non-BMP character constructed by reading two surrogates from
159 * the NSString.
160 *
161 * Results:
162 * Returns the number of bytes written.
163 *
164 * Side effects:
165 * Bytes are written to the char array referenced by the pointer uni and
166 * the unicode code point is written to the integer referenced by the
167 * pointer code.
168 *
169 */
170
171 MODULE_SCOPE int
172 TclUniAtIndex(
173 NSString *string,
174 int index,
175 char *uni,
176 unsigned int *code)
177 {
178 char *ptr = uni;
179 UniChar uniChar = [string characterAtIndex: index];
180 if (CFStringIsSurrogateHighCharacter(uniChar)) {
181 UniChar lowChar = [string characterAtIndex: ++index];
182 *code = CFStringGetLongCharacterForSurrogatePair(
183 uniChar, lowChar);
184 ptr += Tcl_UniCharToUtf(uniChar, ptr);
185 ptr += Tcl_UniCharToUtf(lowChar, ptr);
186 return ptr - uni;
187 } else {
188 *code = (int) uniChar;
189 [[string substringWithRange: NSMakeRange(index, 1)]
190 getCString: uni
191 maxLength: XMaxTransChars
192 encoding: NSUTF8StringEncoding];
193 return strlen(uni);
194 }
195 }
196
197 /*
198 *---------------------------------------------------------------------------
199 *
200 * NSStringToTclUni --
201 *
202 * Encodes the unicode string represented by an NSString object with the
203 * internal encoding that Tcl uses when TCL_UTF_MAX = 3. This encoding
204 * is similar to UTF-8 except that non-BMP characters are encoded as two
205 * successive 3-byte sequences which are constructed from UTF-16 surrogates
206 * by applying the UTF-8 algorithm. Even though the UTF-8 encoding does not
207 * allow encoding surrogates, the algorithm does produce a well-defined
208 * 3-byte sequence.
209 *
210 * Results:
211 * Returns a pointer to a null-terminated byte array which encodes the
212 * NSString.
213 *
214 * Side effects:
215 * Memory is allocated to hold the byte array, which must be freed with
216 * ckalloc. If the pointer numBytes is not NULL the number of non-null
217 * bytes written to the array is stored in the integer it references.
218 */
219
220 MODULE_SCOPE char*
221 NSStringToTclUni(
222 NSString *string,
223 int *numBytes)
224 {
225 unsigned int code;
226 int i;
227 char *ptr, *bytes = ckalloc(6*[string length] + 1);
228
229 ptr = bytes;
230 if (ptr) {
231 for (i = 0; i < [string length]; i++) {
232 ptr += TclUniAtIndex(string, i, ptr, &code);
233 if (code > 0xffff){
234 i++;
235 }
236 }
237 *ptr = '\0';
238 }
239 if (numBytes) {
240 *numBytes = ptr - bytes;
241 }
242 return bytes;
243 }
100 * To avoid an extra copy, a TKNSString object wraps a Tcl_DString with an
101 * NSString that uses the DString's buffer as its character buffer. It can be
102 * constructed from a Tcl_DString and it has a DString property that handles
103 * converting from an NSString to a Tcl_DString.
104 */
105
106 @implementation TKNSString
107
108 - (instancetype)initWithTclUtfBytes:(const void *)bytes
109 length:(NSUInteger)len
110 {
111 self = [self init];
112 if (self) {
113 Tcl_DStringInit(&_ds);
114 Tcl_UtfToUniCharDString(bytes, len, &_ds);
115 _string = [[NSString alloc]
116 initWithCharactersNoCopy:(unichar *)Tcl_DStringValue(&_ds)
117 length:Tcl_DStringLength(&_ds)>>1
118 freeWhenDone:NO];
119 self.UTF8String = _string.UTF8String;
120 }
121 return self;
122 }
123
124 - (instancetype)initWithString:(NSString *)aString
125 {
126 self = [self init];
127 if (self) {
128 _string = [[NSString alloc] initWithString:aString];
129 _UTF8String = _string.UTF8String;
130 }
131 return self;
132 }
133
134 - (void)dealloc
135 {
136 Tcl_DStringFree(&_ds);
137 [_string release];
138 [super dealloc];
139 }
140
141 - (NSUInteger)length
142 {
143 return _string.length;
144 }
145
146 - (unichar)characterAtIndex:(NSUInteger)index
147 {
148 return [_string characterAtIndex:index];
149 }
150
151 - (Tcl_DString)DString
152 {
153 if ( _ds.string == NULL) {
154
155 /*
156 * The DString has not been initialized. Construct it from
157 * our string's unicode characters.
158 */
159 char *p;
160 NSUInteger index;
161
162 Tcl_DStringInit(&_ds);
163 Tcl_DStringSetLength(&_ds, 3 * [_string length]);
164 p = Tcl_DStringValue(&_ds);
165 for (index = 0; index < [_string length]; index++) {
166 p += Tcl_UniCharToUtf([_string characterAtIndex: index], p);
167 }
168 Tcl_DStringSetLength(&_ds, p - Tcl_DStringValue(&_ds));
169 }
170 return _ds;
171 }
172
173 #ifndef __clang__
174 @synthesize UTF8String = _UTF8String;
175 @synthesize DString = _ds;
176 #endif
177 @end
244178
245179 #define GetNSFontTraitsFromTkFontAttributes(faPtr) \
246180 ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \
513447 TkMainInfo *mainPtr) /* The application being created. */
514448 {
515449 Tcl_Interp *interp = mainPtr->interp;
516 Tk_Window tkwin = (Tk_Window) mainPtr->winPtr;
450 Tk_Window tkwin = (Tk_Window)mainPtr->winPtr;
517451 const struct SystemFontMapEntry *systemFont = systemFontMap;
518452 NSFont *nsFont;
519453 TkFontAttributes fa;
612546
613547 TkFont *
614548 TkpGetNativeFont(
615 Tk_Window tkwin, /* For display where font will be used. */
549 TCL_UNUSED(Tk_Window), /* For display where font will be used. */
616550 const char *name) /* Platform-specific font name. */
617551 {
618552 MacFont *fontPtr = NULL;
631565 ctFont = CTFontCreateUIFontForLanguage(
632566 HIThemeGetUIFontType(themeFontId), 0, NULL);
633567 if (ctFont) {
634 fontPtr = ckalloc(sizeof(MacFont));
568 fontPtr = (MacFont *)ckalloc(sizeof(MacFont));
635569 InitFont((NSFont*) ctFont, NULL, fontPtr);
636570 }
637571
699633 Tcl_Panic("Could not determine NSFont from TkFontAttributes");
700634 }
701635 if (tkFontPtr == NULL) {
702 fontPtr = ckalloc(sizeof(MacFont));
636 fontPtr = (MacFont *)ckalloc(sizeof(MacFont));
703637 } else {
704638 fontPtr = (MacFont *) tkFontPtr;
705639 TkpDeleteFont(tkFontPtr);
761695 void
762696 TkpGetFontFamilies(
763697 Tcl_Interp *interp, /* Interp to hold result. */
764 Tk_Window tkwin) /* For display to query. */
698 TCL_UNUSED(Tk_Window)) /* For display to query. */
765699 {
766700 Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL);
767701 NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies];
834768
835769 void
836770 TkpGetFontAttrsForChar(
837 Tk_Window tkwin, /* Window on the font's display */
771 TCL_UNUSED(Tk_Window), /* Window on the font's display */
838772 Tk_Font tkfont, /* Font to query */
839773 int c, /* Character of interest */
840774 TkFontAttributes* faPtr) /* Output: Font attributes */
985919 if (maxLength > 32767) {
986920 maxLength = 32767;
987921 }
988 string = TclUniToNSString((const char *)source, numBytes);
922 string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes];
989923 if (!string) {
990924 length = 0;
991925 fit = rangeLength;
10971031 [attributedString release];
10981032 [string release];
10991033 length = ceil(width - offset);
1100 fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart;
1034 fit = (TkUtfAtIndex(source, index) - source) - rangeStart;
11011035 done:
11021036 #ifdef TK_MAC_DEBUG_FONTS
11031037 TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d "
11211055 * Draw a string of characters on the screen.
11221056 *
11231057 * With ATSUI we need the line context to do this right, so we have the
1124 * actual implementation in TkpDrawCharsInContext().
1058 * actual implementation in TkpDrawAngledCharsInContext().
11251059 *
11261060 * Results:
11271061 * None.
11501084 int x, int y) /* Coordinates at which to place origin of the
11511085 * string when drawing. */
11521086 {
1153 DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
1087 TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes,
11541088 0, numBytes, x, y, 0.0);
11551089 }
11561090
11731107 * string when drawing. */
11741108 double angle) /* What angle to put text at, in degrees. */
11751109 {
1176 DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
1110 TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes,
11771111 0, numBytes, x, y, angle);
11781112 }
11791113
12181152 * whole (not just the range) string when
12191153 * drawing. */
12201154 {
1221 DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
1155 TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes,
12221156 rangeStart, rangeLength, x, y, 0.0);
12231157 }
12241158
1225 static void
1226 DrawCharsInContext(
1227 Display *display, /* Display on which to draw. */
1159 void
1160 TkpDrawAngledCharsInContext(
1161 TCL_UNUSED(Display *), /* Display on which to draw. */
12281162 Drawable drawable, /* Window or pixmap in which to draw. */
12291163 GC gc, /* Graphics context for drawing characters. */
12301164 Tk_Font tkfont, /* Font in which characters will be drawn; must
12391173 int numBytes, /* Number of bytes in string. */
12401174 int rangeStart, /* Index of first byte to draw. */
12411175 int rangeLength, /* Length of range to draw in bytes. */
1242 int x, int y, /* Coordinates at which to place origin of the
1176 double x, double y, /* Coordinates at which to place origin of the
12431177 * whole (not just the range) string when
12441178 * drawing. */
1245 double angle)
1179 double angle) /* What angle to put text at, in degrees. */
12461180 {
12471181 const MacFont *fontPtr = (const MacFont *) tkfont;
12481182 NSString *string;
12491183 NSMutableDictionary *attributes;
12501184 NSAttributedString *attributedString;
12511185 CTTypesetterRef typesetter;
1252 CFIndex start, len;
1253 CTLineRef line;
1254 MacDrawable *macWin = (MacDrawable *) drawable;
1186 CFIndex start, length;
1187 CTLineRef line, full=nil;
1188 MacDrawable *macWin = (MacDrawable *)drawable;
12551189 TkMacOSXDrawingContext drawingContext;
12561190 CGContextRef context;
12571191 CGColorRef fg;
12581192 NSFont *nsFont;
12591193 CGAffineTransform t;
1260 int h;
1261
1262 if (rangeStart < 0 || rangeLength <= 0 ||
1263 rangeStart + rangeLength > numBytes ||
1264 !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) {
1194 CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;
1195
1196 if (rangeStart < 0 || rangeLength <= 0 ||
1197 rangeStart + rangeLength > numBytes ||
1198 !TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) {
12651199 return;
12661200 }
1267 string = TclUniToNSString((const char *)source, numBytes);
1201 string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes];
12681202 if (!string) {
12691203 return;
12701204 }
1205
12711206 context = drawingContext.context;
1272 fg = TkMacOSXCreateCGColor(gc, gc->foreground);
1207 TkSetMacColor(gc->foreground, &fg);
12731208 attributes = [fontPtr->nsAttributes mutableCopy];
12741209 [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
1275 CFRelease(fg);
12761210 nsFont = [attributes objectForKey:NSFontAttributeName];
1277 [nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort:
1278 context flipped:NO]];
1211 [nsFont setInContext:GET_NSCONTEXT(context, NO)];
12791212 CGContextSetTextMatrix(context, CGAffineTransformIdentity);
12801213 attributedString = [[NSAttributedString alloc] initWithString:string
12811214 attributes:attributes];
12821215 typesetter = CTTypesetterCreateWithAttributedString(
12831216 (CFAttributedStringRef)attributedString);
1284 x += macWin->xOff;
1285 y += macWin->yOff;
1286 h = drawingContext.portBounds.size.height;
1287 y = h - y;
1288 t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, h);
1217 textX += (CGFloat) macWin->xOff;
1218 textY += (CGFloat) macWin->yOff;
1219 height = drawingContext.portBounds.size.height;
1220 textY = height - textY;
1221 t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height);
12891222 if (angle != 0.0) {
1290 t = CGAffineTransformTranslate(CGAffineTransformRotate(
1291 CGAffineTransformTranslate(t, x, y), angle*PI/180.0), -x, -y);
1223 t = CGAffineTransformTranslate(
1224 CGAffineTransformRotate(
1225 CGAffineTransformTranslate(t, textX, textY), angle*PI/180.0),
1226 -textX, -textY);
12921227 }
12931228 CGContextConcatCTM(context, t);
1294 CGContextSetTextPosition(context, x, y);
12951229 start = Tcl_NumUtfChars(source, rangeStart);
1296 len = Tcl_NumUtfChars(source, rangeStart + rangeLength);
1230 length = Tcl_NumUtfChars(source, rangeStart + rangeLength) - start;
1231 line = CTTypesetterCreateLine(typesetter, CFRangeMake(start, length));
12971232 if (start > 0) {
1298 CGRect clipRect = CGRectInfinite, startBounds;
1299
1300 line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start));
1301 startBounds = CTLineGetImageBounds(line, context);
1302 CFRelease(line);
1303 clipRect.origin.x = startBounds.origin.x + startBounds.size.width;
1304 CGContextClipToRect(context, clipRect);
1305 }
1306 line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, len));
1233
1234 /*
1235 * We are only drawing part of the string. To compute the x coordinate
1236 * of the part we are drawing we subtract its typographical length from
1237 * the typographical length of the full string. This accounts for the
1238 * kerning after the initial part of the string.
1239 */
1240
1241 full = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start + length));
1242 width = CTLineGetTypographicBounds(full, NULL, NULL, NULL);
1243 CFRelease(full);
1244 textX += (width - CTLineGetTypographicBounds(line, NULL, NULL, NULL));
1245 }
1246 CGContextSetTextPosition(context, textX, textY);
13071247 CTLineDraw(line, context);
13081248 CFRelease(line);
13091249 CFRelease(typesetter);
13811321
13821322 int
13831323 TkMacOSXIsCharacterMissing(
1384 Tk_Font tkfont, /* The font we are looking in. */
1385 unsigned int searchChar) /* The character we are looking for. */
1324 TCL_UNUSED(Tk_Font), /* The font we are looking in. */
1325 TCL_UNUSED(unsigned int)) /* The character we are looking for. */
13861326 {
13871327 return 0;
13881328 }
14211361 NSStrikethroughStyleAttributeName];
14221362
14231363 objv[i++] = Tcl_NewStringObj(familyName, -1);
1424 objv[i++] = Tcl_NewIntObj([nsFont pointSize]);
1425 #define S(s) Tcl_NewStringObj(STRINGIFY(s),(int)(sizeof(STRINGIFY(s))-1))
1364 objv[i++] = Tcl_NewWideIntObj([nsFont pointSize]);
1365 #define S(s) Tcl_NewStringObj(STRINGIFY(s), (sizeof(STRINGIFY(s))-1))
14261366 objv[i++] = (traits & NSBoldFontMask) ? S(bold) : S(normal);
14271367 objv[i++] = (traits & NSItalicFontMask) ? S(italic) : S(roman);
14281368 if ([underline respondsToSelector:@selector(intValue)] &&
3838 const char *procedure;
3939 Tcl_DString command;
4040 NSAppleEventDescriptor *replyEvent; /* Only used for DoScriptText. */
41 int retryCount;
4142 } AppleEventInfo;
4243
4344 /*
6465 - (void) terminate: (id) sender
6566 {
6667 [self handleQuitApplicationEvent:Nil withReplyEvent:Nil];
68 }
69
70 - (void) superTerminate: (id) sender
71 {
72 [super terminate:nil];
6773 }
6874
6975 - (void) preferences: (id) sender
147153 AEKeyword keyword;
148154 Tcl_DString pathName;
149155
156
150157 /*
151158 * Do nothing if we don't have an interpreter.
152159 */
214221 AEInfo->interp = _eventInterp;
215222 AEInfo->procedure = openDocumentProc;
216223 AEInfo->replyEvent = nil;
217 Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
224 AEInfo->retryCount = 0;
225
226 if (Tcl_FindCommand(_eventInterp, "::tk::mac::OpenDocuments", NULL, 0)){
227 ProcessAppleEvent((ClientData)AEInfo);
228 } else {
229 Tcl_CreateTimerHandler(500, ProcessAppleEvent, (ClientData)AEInfo);
230 }
218231 }
219232
220233 - (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
231244 AEInfo->interp = _eventInterp;
232245 AEInfo->procedure = printDocProc;
233246 AEInfo->replyEvent = nil;
234 Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
247 AEInfo->retryCount = 0;
248 ProcessAppleEvent((ClientData)AEInfo);
235249 }
236250
237251 - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
292306 AEInfo->interp = _eventInterp;
293307 AEInfo->procedure = scriptFileProc;
294308 AEInfo->replyEvent = nil;
295 Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
309 AEInfo->retryCount = 0;
310 ProcessAppleEvent((ClientData)AEInfo);
296311 }
297312 }
298313 } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type,
308323 if (noErr == AEGetParamPtr(theDesc, keyDirectObject,
309324 typeUTF8Text, &type,
310325 data, actual, NULL)) {
326 data[actual] = '\0';
311327 AppleEventInfo *AEInfo = ckalloc(sizeof(AppleEventInfo));
312328 Tcl_DString *scriptTextCommand = &AEInfo->command;
313329 Tcl_DStringInit(scriptTextCommand);
315331 Tcl_DStringAppendElement(scriptTextCommand, data);
316332 AEInfo->interp = _eventInterp;
317333 AEInfo->procedure = scriptTextProc;
334 AEInfo->retryCount = 0;
318335 if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
319336 AEInfo->replyEvent = replyEvent;
320337 ProcessAppleEvent((ClientData)AEInfo);
321338 } else {
322339 AEInfo->replyEvent = nil;
323 Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
340 ProcessAppleEvent((ClientData)AEInfo);
324341 }
325342 }
326343 }
341358 AEInfo->interp = _eventInterp;
342359 AEInfo->procedure = launchURLProc;
343360 AEInfo->replyEvent = nil;
344 Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
361 AEInfo->retryCount = 0;
362 ProcessAppleEvent((ClientData)AEInfo);
345363 }
346364
347365 @end
376394 {
377395 int code;
378396 AppleEventInfo *AEInfo = (AppleEventInfo*) clientData;
379 if (!AEInfo->interp ||
380 !Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
397
398 if (!AEInfo->interp) {
399 return;
400 }
401
402 /*
403 * Apple events that are delivered during the app startup can arrive
404 * before the Tcl procedure for handling the events has been defined.
405 * If the command is not found we create a timer handler to process
406 * the event later, hopefully after the command has been created.
407 * We retry up to 2 times before giving up.
408 */
409
410 if (!Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
411 if (AEInfo->retryCount < 2) {
412 AEInfo->retryCount++;
413 Tcl_CreateTimerHandler(200, ProcessAppleEvent, clientData);
414 } else {
415 ckfree(clientData);
416 }
381417 return;
382418 }
383419 code = Tcl_EvalEx(AEInfo->interp, Tcl_DStringValue(&AEInfo->command),
384420 Tcl_DStringLength(&AEInfo->command), TCL_EVAL_GLOBAL);
385 if (code != TCL_OK) {
386 Tcl_BackgroundException(AEInfo->interp, code);
387 }
388421
389422 if (AEInfo->replyEvent && code >= 0) {
390423 int reslen;
399432 AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc],
400433 keyErrorNumber, typeSInt32, (Ptr) &code, sizeof(int));
401434 }
402 }
435 } else if (code != TCL_OK) {
436 Tcl_BackgroundException(AEInfo->interp, code);
437 }
438
403439 Tcl_DStringFree(&AEInfo->command);
404440 ckfree(clientData);
405441 }
533569 static int
534570 ReallyKillMe(
535571 Tcl_Event *eventPtr,
536 int flags)
572 TCL_UNUSED(int))
537573 {
538574 Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp;
539575 int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL;
540 int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL);
541
576
577 if (!quit) {
578 Tcl_Exit(0);
579 }
580
581 int code = Tcl_EvalEx(interp, "::tk::mac::Quit", -1, TCL_EVAL_GLOBAL);
542582 if (code != TCL_OK) {
583
543584 /*
544585 * Should be never reached...
545586 */
55 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
66 * Copyright 2001-2009, Apple Inc.
77 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
8 * Copyright 2017-2018 Marc Culler.
8 * Copyright (c) 2017-2020 Marc Culler.
99 *
1010 * See the file "license.terms" for information on usage and redistribution
1111 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1313
1414 #include "tkMacOSXPrivate.h"
1515 #include "xbytes.h"
16
17 static CGImageRef CreateCGImageFromPixmap(Drawable pixmap);
18 static CGImageRef CreateCGImageFromDrawableRect( Drawable drawable,
19 int x, int y, unsigned int width, unsigned int height);
1620
1721 #pragma mark XImage handling
1822
130134 /*
131135 *----------------------------------------------------------------------
132136 *
133 * XGetImage --
134 *
135 * This function copies data from a pixmap or window into an XImage. It
136 * is essentially never used. At one time it was called by
137 * pTkImgPhotoDisplay, but that is no longer the case. Currently it is
138 * called two places, one of which is requesting an XY image which we do
139 * not support. It probably does not work correctly -- see the comments
140 * for TkMacOSXBitmapRepFromDrawableRect.
141 *
142 * Results:
143 * Returns a newly allocated XImage containing the data from the given
144 * rectangle of the given drawable, or NULL if the XImage could not be
145 * constructed. NOTE: If we are copying from a window on a Retina
146 * display, the dimensions of the XImage will be 2*width x 2*height.
147 *
148 * Side effects:
149 * None.
150 *
151 *----------------------------------------------------------------------
152 */
153 struct pixel_fmt {int r; int g; int b; int a;};
154 static struct pixel_fmt bgra = {2, 1, 0, 3};
155 static struct pixel_fmt abgr = {3, 2, 1, 0};
156
157 XImage *
158 XGetImage(
159 Display *display,
160 Drawable drawable,
161 int x,
162 int y,
163 unsigned int width,
164 unsigned int height,
165 unsigned long plane_mask,
166 int format)
167 {
168 NSBitmapImageRep* bitmap_rep = NULL;
169 NSUInteger bitmap_fmt = 0;
170 XImage* imagePtr = NULL;
171 char* bitmap = NULL;
172 char R, G, B, A;
173 int depth = 32, offset = 0, bitmap_pad = 0;
174 unsigned int bytes_per_row, size, row, n, m;
175 unsigned int scalefactor=1, scaled_height=height, scaled_width=width;
176 NSWindow *win = TkMacOSXDrawableWindow(drawable);
177 static enum {unknown, no, yes} has_retina = unknown;
178
179 if (win && has_retina == unknown) {
180 #ifdef __clang__
181 has_retina = [win respondsToSelector:@selector(backingScaleFactor)] ?
182 yes : no;
183 #else
184 has_retina = no;
185 #endif
186 }
187
188 if (has_retina == yes) {
189 /*
190 * We only allow scale factors 1 or 2, as Apple currently does.
191 */
192
193 #ifdef __clang__
194 scalefactor = [win backingScaleFactor] == 2.0 ? 2 : 1;
195 #endif
196 scaled_height *= scalefactor;
197 scaled_width *= scalefactor;
198 }
199
200 if (format == ZPixmap) {
201 if (width == 0 || height == 0) {
202 return NULL;
203 }
204
205 bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(drawable,
206 x, y, width, height);
207 if (!bitmap_rep) {
208 TkMacOSXDbgMsg("XGetImage: Failed to construct NSBitmapRep");
209 return NULL;
210 }
211 bitmap_fmt = [bitmap_rep bitmapFormat];
212 size = [bitmap_rep bytesPerPlane];
213 bytes_per_row = [bitmap_rep bytesPerRow];
214 bitmap = ckalloc(size);
215 if (!bitmap
216 || (bitmap_fmt != 0 && bitmap_fmt != 1)
217 || [bitmap_rep samplesPerPixel] != 4
218 || [bitmap_rep isPlanar] != 0
219 || bytes_per_row < 4 * scaled_width
220 || size != bytes_per_row * scaled_height) {
221 TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format");
222 CFRelease(bitmap_rep);
223 return NULL;
224 }
225 memcpy(bitmap, (char *)[bitmap_rep bitmapData], size);
226 CFRelease(bitmap_rep);
227
228 /*
229 * When Apple extracts a bitmap from an NSView, it may be in either
230 * BGRA or ABGR format. For an XImage we need RGBA.
231 */
232
233 struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr;
234
235 for (row = 0, n = 0; row < scaled_height; row++, n += bytes_per_row) {
236 for (m = n; m < n + 4*scaled_width; m += 4) {
237 R = *(bitmap + m + pixel.r);
238 G = *(bitmap + m + pixel.g);
239 B = *(bitmap + m + pixel.b);
240 A = *(bitmap + m + pixel.a);
241
242 *(bitmap + m) = R;
243 *(bitmap + m + 1) = G;
244 *(bitmap + m + 2) = B;
245 *(bitmap + m + 3) = A;
246 }
247 }
248 imagePtr = XCreateImage(display, NULL, depth, format, offset,
249 (char*) bitmap, scaled_width, scaled_height,
250 bitmap_pad, bytes_per_row);
251 if (scalefactor == 2) {
252 imagePtr->pixelpower = 1;
253 }
254 } else {
255 /*
256 * There are some calls to XGetImage in the generic Tk code which pass
257 * an XYPixmap rather than a ZPixmap. XYPixmaps should be handled
258 * here.
259 */
260 TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment.");
261 }
262 return imagePtr;
263 }
264
265 /*
266 *----------------------------------------------------------------------
267 *
268137 * DestroyImage --
269138 *
270139 * Destroys storage associated with an image.
299168 * Get a single pixel from an image.
300169 *
301170 * Results:
302 * Returns the 32 bit pixel value.
171 * The XColor structure contains an unsigned long field named pixel which
172 * identifies the color. This function returns the unsigned long that
173 * would be used as the pixel value of an XColor that has the same red
174 * green and blue components as the XImage pixel at the specified
175 * location.
303176 *
304177 * Side effects:
305178 * None.
315188 {
316189 unsigned char r = 0, g = 0, b = 0;
317190
191 /*
192 * Compute 8 bit red green and blue values, which are passed as inputs to
193 * TkMacOSXRGBPixel to produce the pixel value.
194 */
195
318196 if (image && image->data) {
319197 unsigned char *srcPtr = ((unsigned char*) image->data)
320198 + (y * image->bytes_per_line)
321199 + (((image->xoffset + x) * image->bits_per_pixel) / NBBY);
322200
323201 switch (image->bits_per_pixel) {
324 case 32:
202 case 32: /* 8 bits per channel */
325203 r = (*((unsigned int*) srcPtr) >> 16) & 0xff;
326204 g = (*((unsigned int*) srcPtr) >> 8) & 0xff;
327205 b = (*((unsigned int*) srcPtr) ) & 0xff;
331209 r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3];
332210 }*/
333211 break;
334 case 16:
212 case 16: /* 5 bits per channel */
335213 r = (*((unsigned short*) srcPtr) >> 7) & 0xf8;
336214 g = (*((unsigned short*) srcPtr) >> 2) & 0xf8;
337215 b = (*((unsigned short*) srcPtr) << 3) & 0xf8;
338216 break;
339 case 8:
217 case 8: /* 2 bits per channel */
340218 r = (*srcPtr << 2) & 0xc0;
341219 g = (*srcPtr << 4) & 0xc0;
342220 b = (*srcPtr << 6) & 0xc0;
344222 g |= g >> 2 | g >> 4 | g >> 6;
345223 b |= b >> 2 | b >> 4 | b >> 6;
346224 break;
347 case 4: {
225 case 4: { /* 1 bit per channel */
348226 unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4);
349227
350228 r = (c & 0x04) ? 0xff : 0;
352230 b = (c & 0x01) ? 0xff : 0;
353231 break;
354232 }
355 case 1:
233 case 1: /* Black-white bitmap. */
356234 r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0;
357235 break;
358236 }
359237 }
360 return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b;
238
239 return TkMacOSXRGBPixel(r, g, b);
361240 }
362241
363242 /*
462341 ximage->data = data;
463342 ximage->obdata = NULL;
464343
465 /*
466 * The default pixelpower is 0. This must be explicitly set to 1 in the
467 * case of an XImage extracted from a Retina display.
468 */
469
470 ximage->pixelpower = 0;
471
472344 if (format == ZPixmap) {
473345 ximage->bits_per_pixel = 32;
474346 ximage->bitmap_unit = 32;
541413 int dest_x, /* Destination X & Y. */
542414 int dest_y,
543415 unsigned int width, /* Same width & height for both */
544 unsigned int height) /* distination and source. */
416 unsigned int height) /* destination and source. */
545417 {
546418 TkMacOSXDrawingContext dc;
547 MacDrawable *macDraw = (MacDrawable *) drawable;
419 MacDrawable *macDraw = (MacDrawable *)drawable;
548420
549421 display->request++;
550 if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) {
422 if (!TkMacOSXSetupDrawingContext(drawable, gc, &dc)) {
551423 return BadDrawable;
552424 }
553425 if (dc.context) {
563435 }
564436 if (img) {
565437
566 /*
567 * If the XImage has big pixels, the source is rescaled to reflect
568 * the actual pixel dimensions. This is not currently used, but
569 * could arise if the image were copied from a retina monitor and
570 * redrawn on an ordinary monitor.
571 */
572
573 int pp = image->pixelpower;
574
575438 bounds = CGRectMake(0, 0, image->width, image->height);
576 srcRect = CGRectMake(src_x<<pp, src_y<<pp, width<<pp, height<<pp);
439 srcRect = CGRectMake(src_x, src_y, width, height);
577440 dstRect = CGRectMake(dest_x, dest_y, width, height);
578441 TkMacOSXDrawCGImage(drawable, gc, dc.context,
579442 img, gc->foreground, gc->background,
607470 }
608471
609472 /*
473 *----------------------------------------------------------------------
474 *
475 * CreateCGImageFromDrawableRect
476 *
477 * Extract image data from a MacOSX drawable as a CGImage.
478 *
479 * This is only called by XGetImage and XCopyArea. The Tk core uses
480 * these functions on some platforms, but on macOS the core does not
481 * call them with a source drawable which is a window. Such calls are
482 * used only for double-buffered drawing. Since macOS defines the
483 * macro TK_NO_DOUBLE_BUFFERING, the generic code never calls XGetImage
484 * or XCopyArea on macOS. Nonetheless, these function are in the stubs
485 * table and therefore could be used by extensions.
486 *
487 * This implementation does not work correctly. Originally it relied on
488 * [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was
489 * deprecated by Apple in OSX 10.14 and also required the use of other
490 * deprecated functions such as [NSView lockFocus]. Apple's suggested
491 * replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that
492 * is what is being used here. However, that method only works when the
493 * view has a valid CGContext, and a view is only guaranteed to have a
494 * valid context during a call to [NSView drawRect]. To further complicate
495 * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is
496 * asking the view to draw a subrectangle of itself using a special
497 * graphics context which is linked to the BitmapImageRep. But our
498 * implementation of [NSView drawRect] does not allow recursive calls. If
499 * called recursively it returns immediately without doing any drawing.
500 * So the bottom line is that this function either returns a NULL pointer
501 * or a black image. To make it useful would require a significant amount
502 * of rewriting of the drawRect method. Perhaps the next release of OSX
503 * will include some more helpful ways of doing this.
504 *
505 * Results:
506 * Returns an NSBitmapRep representing the image of the given rectangle of
507 * the given drawable. This object is retained. The caller is responsible
508 * for releasing it.
509 *
510 * NOTE: The x,y coordinates should be relative to a coordinate system
511 * with origin at the top left, as used by XImage and CGImage, not bottom
512 * left as used by NSView.
513 *
514 * Side effects:
515 * None
516 *
517 *----------------------------------------------------------------------
518 */
519
520 static CGImageRef
521 CreateCGImageFromDrawableRect(
522 Drawable drawable,
523 int x,
524 int y,
525 unsigned int width,
526 unsigned int height)
527 {
528 MacDrawable *mac_drawable = (MacDrawable *)drawable;
529 CGContextRef cg_context = NULL;
530 CGImageRef cg_image = NULL, result = NULL;
531 NSBitmapImageRep *bitmapRep = nil;
532 NSView *view = nil;
533 if (mac_drawable->flags & TK_IS_PIXMAP) {
534 /*
535 * This MacDrawable is a bitmap, so its view is NULL.
536 */
537
538 CGRect image_rect = CGRectMake(x, y, width, height);
539
540 cg_context = TkMacOSXGetCGContextForDrawable(drawable);
541 cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context);
542 if (cg_image) {
543 result = CGImageCreateWithImageInRect(cg_image, image_rect);
544 CGImageRelease(cg_image);
545 }
546 } else if (TkMacOSXGetNSViewForDrawable(mac_drawable) != nil) {
547
548 /*
549 * Convert Tk top-left to NSView bottom-left coordinates.
550 */
551
552 int view_height = [view bounds].size.height;
553 NSRect view_rect = NSMakeRect(x + mac_drawable->xOff,
554 view_height - height - y - mac_drawable->yOff,
555 width, height);
556
557 /*
558 * Attempt to copy from the view to a bitmapImageRep. If the view does
559 * not have a valid CGContext, doing this will silently corrupt memory
560 * and make a big mess. So, in that case, we just return NULL.
561 */
562
563 if (view == [NSView focusView]) {
564 bitmapRep = [view bitmapImageRepForCachingDisplayInRect: view_rect];
565 [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmapRep];
566 result = [bitmapRep CGImage];
567 CFRelease(bitmapRep);
568 } else {
569 TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap.");
570 result = NULL;
571 }
572 } else {
573 TkMacOSXDbgMsg("Invalid source drawable");
574 }
575 return result;
576 }
577
578 /*
579 *----------------------------------------------------------------------
580 *
581 * CreateCGImageFromPixmap --
582 *
583 * Create a CGImage from an X Pixmap.
584 *
585 * Results:
586 * CGImage, release after use.
587 *
588 * Side effects:
589 * None.
590 *
591 *----------------------------------------------------------------------
592 */
593
594 static CGImageRef
595 CreateCGImageFromPixmap(
596 Drawable pixmap)
597 {
598 CGImageRef img = NULL;
599 CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap);
600
601 if (context) {
602 img = CGBitmapContextCreateImage(context);
603 }
604 return img;
605 }
606
607 /*
608 *----------------------------------------------------------------------
609 *
610 * XGetImage --
611 *
612 * This function copies data from a pixmap or window into an XImage. It
613 * is essentially never used. At one time it was called by
614 * pTkImgPhotoDisplay, but that is no longer the case. Currently it is
615 * called two places, one of which is requesting an XY image which we do
616 * not support. It probably does not work correctly -- see the comments
617 * for CGImageFromDrawableRect.
618 *
619 * Results:
620 * Returns a newly allocated XImage containing the data from the given
621 * rectangle of the given drawable, or NULL if the XImage could not be
622 * constructed.
623 *
624 * Side effects:
625 * None.
626 *
627 *----------------------------------------------------------------------
628 */
629 struct pixel_fmt {int r; int g; int b; int a;};
630 static struct pixel_fmt bgra = {2, 1, 0, 3};
631 static struct pixel_fmt abgr = {3, 2, 1, 0};
632
633 XImage *
634 XGetImage(
635 Display *display,
636 Drawable drawable,
637 int x,
638 int y,
639 unsigned int width,
640 unsigned int height,
641 unsigned long plane_mask,
642 int format)
643 {
644 NSBitmapImageRep* bitmapRep = nil;
645 NSUInteger bitmap_fmt = 0;
646 XImage* imagePtr = NULL;
647 char* bitmap = NULL;
648 char R, G, B, A;
649 int depth = 32, offset = 0, bitmap_pad = 0;
650 unsigned int bytes_per_row, size, row, n, m;
651
652 if (format == ZPixmap) {
653 CGImageRef cgImage;
654 if (width == 0 || height == 0) {
655 return NULL;
656 }
657
658 cgImage = CreateCGImageFromDrawableRect(drawable, x, y, width, height);
659 if (cgImage) {
660 bitmapRep = [NSBitmapImageRep alloc];
661 [bitmapRep initWithCGImage:cgImage];
662 CFRelease(cgImage);
663 } else {
664 TkMacOSXDbgMsg("XGetImage: Failed to construct CGImage");
665 return NULL;
666 }
667 bitmap_fmt = [bitmapRep bitmapFormat];
668 size = [bitmapRep bytesPerPlane];
669 bytes_per_row = [bitmapRep bytesPerRow];
670 bitmap = ckalloc(size);
671 if (!bitmap
672 || (bitmap_fmt != 0 && bitmap_fmt != 1)
673 || [bitmapRep samplesPerPixel] != 4
674 || [bitmapRep isPlanar] != 0
675 || bytes_per_row < 4 * width
676 || size != bytes_per_row * height) {
677 TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format");
678 CFRelease(bitmapRep);
679 return NULL;
680 }
681 memcpy(bitmap, (char *)[bitmapRep bitmapData], size);
682 CFRelease(bitmapRep);
683
684 /*
685 * When Apple extracts a bitmap from an NSView, it may be in either
686 * BGRA or ABGR format. For an XImage we need RGBA.
687 */
688
689 struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr;
690
691 for (row = 0, n = 0; row < height; row++, n += bytes_per_row) {
692 for (m = n; m < n + 4*width; m += 4) {
693 R = *(bitmap + m + pixel.r);
694 G = *(bitmap + m + pixel.g);
695 B = *(bitmap + m + pixel.b);
696 A = *(bitmap + m + pixel.a);
697
698 *(bitmap + m) = R;
699 *(bitmap + m + 1) = G;
700 *(bitmap + m + 2) = B;
701 *(bitmap + m + 3) = A;
702 }
703 }
704 imagePtr = XCreateImage(display, NULL, depth, format, offset,
705 (char*) bitmap, width, height,
706 bitmap_pad, bytes_per_row);
707 } else {
708 /*
709 * There are some calls to XGetImage in the generic Tk code which pass
710 * an XYPixmap rather than a ZPixmap. XYPixmaps should be handled
711 * here.
712 */
713 TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment.");
714 }
715 return imagePtr;
716 }
717
718 /*
719 *----------------------------------------------------------------------
720 *
721 * XCopyArea --
722 *
723 * Copies image data from one drawable to another.
724 *
725 * Results:
726 * None.
727 *
728 * Side effects:
729 * Image data is moved from a window or bitmap to a second window or bitmap.
730 *
731 *----------------------------------------------------------------------
732 */
733
734 int
735 XCopyArea(
736 Display *display, /* Display. */
737 Drawable src, /* Source drawable. */
738 Drawable dst, /* Destination drawable. */
739 GC gc, /* GC to use. */
740 int src_x, /* X & Y, width & height */
741 int src_y, /* define the source rectangle */
742 unsigned int width, /* that will be copied. */
743 unsigned int height,
744 int dest_x, /* Dest X & Y on dest rect. */
745 int dest_y)
746 {
747 TkMacOSXDrawingContext dc;
748 MacDrawable *srcDraw = (MacDrawable *)src;
749 CGImageRef img = NULL;
750 CGRect bounds, srcRect, dstRect;
751
752 display->request++;
753 if (!width || !height) {
754 return BadDrawable;
755 }
756
757 if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) {
758 TkMacOSXDbgMsg("Failed to setup drawing context.");
759 return BadDrawable;
760 }
761
762 if (!dc.context) {
763 TkMacOSXDbgMsg("Invalid destination drawable - no context.");
764 return BadDrawable;
765 }
766
767 if (srcDraw->flags & TK_IS_PIXMAP) {
768 img = CreateCGImageFromPixmap(src);
769 } else if (TkMacOSXGetNSWindowForDrawable(src)) {
770 img = CreateCGImageFromDrawableRect(src, src_x, src_y, width, height);
771 } else {
772 TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap.");
773 }
774
775 if (img) {
776 bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height);
777 srcRect = CGRectMake(src_x, src_y, width, height);
778 dstRect = CGRectMake(dest_x, dest_y, width, height);
779 TkMacOSXDrawCGImage(dst, gc, dc.context, img,
780 gc->foreground, gc->background, bounds, srcRect, dstRect);
781 CFRelease(img);
782 } else {
783 TkMacOSXDbgMsg("Failed to construct CGImage.");
784 }
785
786 TkMacOSXRestoreDrawingContext(&dc);
787 return Success;
788 }
789
790 /*
791 *----------------------------------------------------------------------
792 *
793 * XCopyPlane --
794 *
795 * Copies a bitmap from a source drawable to a destination drawable. The
796 * plane argument specifies which bit plane of the source contains the
797 * bitmap. Note that this implementation ignores the gc->function.
798 *
799 * Results:
800 * None.
801 *
802 * Side effects:
803 * Changes the destination drawable.
804 *
805 *----------------------------------------------------------------------
806 */
807
808 int
809 XCopyPlane(
810 Display *display, /* Display. */
811 Drawable src, /* Source drawable. */
812 Drawable dst, /* Destination drawable. */
813 GC gc, /* GC to use. */
814 int src_x, /* X & Y, width & height */
815 int src_y, /* define the source rectangle */
816 unsigned int width, /* that will be copied. */
817 unsigned int height,
818 int dest_x, /* Dest X & Y on dest rect. */
819 int dest_y,
820 unsigned long plane) /* Which plane to copy. */
821 {
822 TkMacOSXDrawingContext dc;
823 MacDrawable *srcDraw = (MacDrawable *)src;
824 MacDrawable *dstDraw = (MacDrawable *)dst;
825 CGRect bounds, srcRect, dstRect;
826 display->request++;
827 if (!width || !height) {
828 /* TkMacOSXDbgMsg("Drawing of empty area requested"); */
829 return BadDrawable;
830 }
831 if (plane != 1) {
832 Tcl_Panic("Unexpected plane specified for XCopyPlane");
833 }
834 if (srcDraw->flags & TK_IS_PIXMAP) {
835 if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) {
836 return BadDrawable;
837 }
838
839 CGContextRef context = dc.context;
840
841 if (context) {
842 CGImageRef img = CreateCGImageFromPixmap(src);
843
844 if (img) {
845 TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
846 unsigned long imageBackground = gc->background;
847
848 if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP) {
849 srcRect = CGRectMake(src_x, src_y, width, height);
850 CGImageRef mask = CreateCGImageFromPixmap(
851 clipPtr->value.pixmap);
852 CGImageRef submask = CGImageCreateWithImageInRect(
853 img, srcRect);
854 CGRect rect = CGRectMake(dest_x, dest_y, width, height);
855
856 rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff);
857 CGContextSaveGState(context);
858
859 /*
860 * Move the origin of the destination to top left.
861 */
862
863 CGContextTranslateCTM(context,
864 0, rect.origin.y + CGRectGetMaxY(rect));
865 CGContextScaleCTM(context, 1, -1);
866
867 /*
868 * Fill with the background color, clipping to the mask.
869 */
870
871 CGContextClipToMask(context, rect, submask);
872 TkMacOSXSetColorInContext(gc, gc->background, dc.context);
873 CGContextFillRect(context, rect);
874
875 /*
876 * Fill with the foreground color, clipping to the
877 * intersection of img and mask.
878 */
879
880 CGImageRef subimage = CGImageCreateWithImageInRect(
881 img, srcRect);
882 CGContextClipToMask(context, rect, subimage);
883 TkMacOSXSetColorInContext(gc, gc->foreground, context);
884 CGContextFillRect(context, rect);
885 CGContextRestoreGState(context);
886 CGImageRelease(img);
887 CGImageRelease(mask);
888 CGImageRelease(submask);
889 CGImageRelease(subimage);
890 } else {
891 bounds = CGRectMake(0, 0,
892 srcDraw->size.width, srcDraw->size.height);
893 srcRect = CGRectMake(src_x, src_y, width, height);
894 dstRect = CGRectMake(dest_x, dest_y, width, height);
895 TkMacOSXDrawCGImage(dst, gc, dc.context, img,
896 gc->foreground, imageBackground, bounds,
897 srcRect, dstRect);
898 CGImageRelease(img);
899 }
900 } else {
901 /* no image */
902 TkMacOSXDbgMsg("Invalid source drawable");
903 }
904 } else {
905 TkMacOSXDbgMsg("Invalid destination drawable - "
906 "could not get a bitmap context.");
907 }
908 TkMacOSXRestoreDrawingContext(&dc);
909 return Success;
910 } else {
911 /*
912 * Source drawable is a Window, not a Pixmap.
913 */
914
915 return XCopyArea(display, src, dst, gc, src_x, src_y, width, height,
916 dest_x, dest_y);
917 }
918 }
919
920 /*
610921 * Local Variables:
611922 * mode: objc
612923 * c-basic-offset: 4
1313 */
1414
1515 #include "tkMacOSXPrivate.h"
16
17 #include <sys/stat.h>
1816 #include <dlfcn.h>
1917 #include <objc/objc-auto.h>
18 #include <sys/stat.h>
2019
2120 static char tkLibPath[PATH_MAX + 1] = "";
2221
2726
2827 static char scriptPath[PATH_MAX + 1] = "";
2928
29 /*
30 * Forward declarations...
31 */
32
33 static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
34 int objc, Tcl_Obj *const objv[]);
35
3036 #pragma mark TKApplication(TKInit)
3137
3238 @implementation TKApplication
3339 @synthesize poolLock = _poolLock;
34 @synthesize macMinorVersion = _macMinorVersion;
40 @synthesize macOSVersion = _macOSVersion;
3541 @synthesize isDrawing = _isDrawing;
42 @synthesize needsToDraw = _needsToDraw;
3643 @end
3744
3845 /*
7481 #define observe(n, s) \
7582 [nc addObserver:self selector:@selector(s) name:(n) object:nil]
7683 observe(NSApplicationDidBecomeActiveNotification, applicationActivate:);
77 observe(NSApplicationDidResignActiveNotification, applicationDeactivate:);
84 observe(NSApplicationWillResignActiveNotification, applicationDeactivate:);
7885 observe(NSApplicationDidUnhideNotification, applicationShowHide:);
7986 observe(NSApplicationDidHideNotification, applicationShowHide:);
8087 observe(NSApplicationDidChangeScreenParametersNotification, displayChanged:);
8491
8592 -(void)applicationWillFinishLaunching:(NSNotification *)aNotification
8693 {
94 (void)aNotification;
8795
8896 /*
8997 * Initialize notifications.
94102 #endif
95103 [self _setupWindowNotifications];
96104 [self _setupApplicationNotifications];
105 }
106
107 -(void)applicationDidFinishLaunching:(NSNotification *)notification
108 {
109 (void)notification;
110
111 /*
112 * Initialize event processing.
113 */
114
115 TkMacOSXInitAppleEvents(_eventInterp);
116
117 /*
118 * Initialize the graphics context.
119 */
120 TkMacOSXUseAntialiasedText(_eventInterp, -1);
121 TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
97122
98123 /*
99124 * Construct the menu bar.
100125 */
126
101127 _defaultMainMenu = nil;
102128 [self _setupMenus];
103129
104 /*
105 * Initialize event processing.
106 */
107 TkMacOSXInitAppleEvents(_eventInterp);
108
109 /*
110 * Initialize the graphics context.
111 */
112 TkMacOSXUseAntialiasedText(_eventInterp, -1);
113 TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
114 }
115
116 -(void)applicationDidFinishLaunching:(NSNotification *)notification
117 {
118130 /*
119131 * It is not safe to force activation of the NSApp until this method is
120132 * called. Activating too early can cause the menu bar to be unresponsive.
121133 * The call to activateIgnoringOtherApps was moved here to avoid this.
122 * However, with the release of macOS 10.15 (Catalina) this was no longer
123 * sufficient. (See ticket bf93d098d7.) Apparently apps were being
124 * activated automatically, and this was sometimes being done too early.
125 * As a workaround we deactivate and then reactivate the app, even though
126 * Apple says that "Normally, you shouldn’t invoke this method".
127 */
128
129 [NSApp deactivate];
134 * However, with the release of macOS 10.15 (Catalina) that was no longer
135 * sufficient. (See ticket bf93d098d7.) The call to setActivationPolicy
136 * needed to be moved into this function as well.
137 */
138
139 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
130140 [NSApp activateIgnoringOtherApps: YES];
131141
132142 /*
135145 */
136146
137147 [NSApp _lockAutoreleasePool];
138 while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
148 while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}
139149 [NSApp _unlockAutoreleasePool];
140150 }
141151
155165 /*
156166 * Record the OS version we are running on.
157167 */
158 int minorVersion;
168
169 int minorVersion, majorVersion;
159170 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
160171 Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
172 majorVersion = 10;
161173 #else
162174 NSOperatingSystemVersion systemVersion;
163175 systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
176 majorVersion = systemVersion.majorVersion;
164177 minorVersion = systemVersion.minorVersion;
165178 #endif
166 [NSApp setMacMinorVersion: minorVersion];
179 [NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion];
167180
168181 /*
169182 * We are not drawing right now.
176189 */
177190
178191 [self setDelegate:self];
179
180 /*
181 * Make sure we are allowed to open windows.
182 */
183
184 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
185192
186193 /*
187194 * If no icon has been set from an Info.plist file, use the Wish icon from
264271 *----------------------------------------------------------------------
265272 */
266273
274 /*
275 * Helper function which closes the shared NSFontPanel and NSColorPanel.
276 */
277
278 static void closePanels(
279 void)
280 {
281 if ([NSFontPanel sharedFontPanelExists]) {
282 [[NSFontPanel sharedFontPanel] orderOut:nil];
283 }
284 if ([NSColorPanel sharedColorPanelExists]) {
285 [[NSColorPanel sharedColorPanel] orderOut:nil];
286 }
287 }
288
289 /*
290 * This custom exit procedure is called by Tcl_Exit in place of the exit
291 * function from the C runtime. It calls the terminate method of the
292 * NSApplication class (superTerminate for a TKApplication). The purpose of
293 * doing this is to ensure that the NSFontPanel and the NSColorPanel are closed
294 * before the process exits, and that the application state is recorded
295 * correctly for all termination scenarios.
296 *
297 * TkpWantsExitProc tells Tcl_AppInit whether to install our custom exit proc,
298 * which terminates the process by calling [NSApplication terminate]. This
299 * does not work correctly if the process is part of an exec pipeline, so it is
300 * only done if the process was launched by the launcher or if both stdin and
301 * stdout are ttys. To disable using the custom exit proc altogether, undefine
302 * USE_CUSTOM_EXIT_PROC.
303 */
304
305 #if defined(USE_CUSTOM_EXIT_PROC)
306 static Bool doCleanupFromExit = NO;
307
308 int TkpWantsExitProc(void) {
309 return doCleanupFromExit == YES;
310 }
311
312 TCL_NORETURN void TkpExitProc(
313 void *clientdata)
314 {
315 Bool doCleanup = doCleanupFromExit;
316 if (doCleanupFromExit) {
317 doCleanupFromExit = NO; /* prevent possible recursive call. */
318 closePanels();
319 }
320
321 /*
322 * Tcl_Exit does not call Tcl_Finalize if there is an exit proc installed.
323 */
324
325 Tcl_Finalize();
326 if (doCleanup == YES) {
327 [(TKApplication *)NSApp superTerminate:nil]; /* Should not return. */
328 }
329 exit((long)clientdata); /* Convince the compiler that we don't return. */
330 }
331 #endif
332
333 /*
334 * This signal handler is installed for the SIGINT, SIGHUP and SIGTERM signals
335 * so that normal finalization occurs when a Tk app is killed by one of these
336 * signals (e.g when ^C is pressed while running Wish in the shell). It calls
337 * Tcl_Exit instead of the C runtime exit function called by the default handler.
338 * This is consistent with the Tcl_Exit manual page, which says that Tcl_Exit
339 * should always be called instead of exit. When Tk is killed by a signal we
340 * return exit status 1.
341 */
342
343 static void TkMacOSXSignalHandler(TCL_UNUSED(int)) {
344
345 Tcl_Exit(1);
346 }
347
267348 int
268349 TkpInit(
269350 Tcl_Interp *interp)
271352 static int initialized = 0;
272353
273354 /*
274 * Since it is possible for TkInit to be called multiple times and we
275 * don't want to do the following initialization multiple times we protect
276 * against doing it more than once.
355 * TkpInit can be called multiple times with different interpreters. But
356 * The application initialization should only be done onece.
277357 */
278358
279359 if (!initialized) {
280360 struct stat st;
281
282 initialized = 1;
361 Bool shouldOpenConsole = NO;
362 Bool stdinIsNullish = (!isatty(0) &&
363 (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)));
283364
284365 /*
285366 * Initialize/check OS version variable for runtime checks.
289370 # error Mac OS X 10.6 required
290371 #endif
291372
373 initialized = 1;
374
292375 #ifdef TK_FRAMEWORK
376
293377 /*
294378 * When Tk is in a framework, force tcl_findLibrary to look in the
295379 * framework scripts directory.
304388 # endif
305389 }
306390 #endif
307
308 /*
309 * FIXME: Close stdin & stdout for remote debugging otherwise we will
310 * fight with gdb for stdin & stdout
311 */
312
313 if (getenv("XCNOSTDIN") != NULL) {
314 close(0);
315 close(1);
316 }
317391
318392 /*
319393 * Instantiate our NSApplication object. This needs to be done before
330404 nil]];
331405 [TKApplication sharedApplication];
332406 [pool drain];
407
408 /*
409 * WARNING: The finishLaunching method runs asynchronously. This
410 * creates a race between the initialization of the NSApplication and
411 * the initialization of Tk. If Tk wins the race bad things happen
412 * with the root window (see below). If the NSApplication wins then an
413 * AppleEvent created during launch, e.g. by dropping a file icon on
414 * the application icon, will be delivered before the procedure meant
415 * to to handle the AppleEvent has been defined. This is handled in
416 * tkMacOSXHLEvents.c by scheduling a timer event to handle the
417 * ApplEvent later, after the required procedure has been defined.
418 */
419
333420 [NSApp _setup:interp];
334
335 /*
336 * WARNING: The finishLaunching method runs asynchronously, apparently
337 * in a separate thread. This creates a race between the
338 * initialization of the NSApplication and the initialization of Tk.
339 * If Tk wins the race bad things happen with the root window (see
340 * below). If the NSApplication wins then an AppleEvent created during
341 * launch, e.g. by dropping a file icon on the application icon, will
342 * be delivered before the procedure meant to to handle the AppleEvent
343 * has been defined. This is now handled by processing the AppleEvent
344 * as an idle task. See tkMacOSXHLEvents.c.
345 */
346
347421 [NSApp finishLaunching];
348422
349423 /*
370444 Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT);
371445
372446 /*
373 * If we don't have a TTY and stdin is a special character file of
374 * length 0, (e.g. /dev/null, which is what Finder sets when double
375 * clicking Wish) then use the Tk based console interpreter.
376 */
377
378 if (getenv("TK_CONSOLE") ||
379 (!isatty(0) && (fstat(0, &st) ||
380 (S_ISCHR(st.st_mode) && st.st_blocks == 0)))) {
447 * Decide whether to open a console window. If the TK_CONSOLE
448 * environment variable is not defined we only show the console if
449 * stdin is not a tty and there is no startup script.
450 */
451
452 if (getenv("TK_CONSOLE")) {
453 shouldOpenConsole = YES;
454 } else if (stdinIsNullish && Tcl_GetStartupScript(NULL) == NULL) {
455 const char *intvar = Tcl_GetVar2(interp, "tcl_interactive",
456 NULL, TCL_GLOBAL_ONLY);
457 if (intvar == NULL) {
458 Tcl_SetVar2(interp, "tcl_interactive", NULL, "1",
459 TCL_GLOBAL_ONLY);
460 }
461
462 #if defined(USE_CUSTOM_EXIT_PROC)
463 doCleanupFromExit = YES;
464 #endif
465
466 shouldOpenConsole = YES;
467 }
468 if (shouldOpenConsole) {
381469 Tk_InitConsoleChannels(interp);
382470 Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN));
383471 Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT));
384472 Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR));
385
386 /*
387 * Only show the console if we don't have a startup script and
388 * tcl_interactive hasn't been set already.
389 */
390
391 if (Tcl_GetStartupScript(NULL) == NULL) {
392 const char *intvar = Tcl_GetVar2(interp,
393 "tcl_interactive", NULL, TCL_GLOBAL_ONLY);
394
395 if (intvar == NULL) {
396 Tcl_SetVar2(interp, "tcl_interactive", NULL, "1",
397 TCL_GLOBAL_ONLY);
398 }
399 }
400473 if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
401474 return TCL_ERROR;
402475 }
476 } else if (stdinIsNullish) {
477
478 /*
479 * When launched as a macOS application with no console,
480 * redirect stderr and stdout to /dev/null. This avoids waiting
481 * forever for those files to become writable if the underlying
482 * Tcl program tries to write to them with a puts command.
483 */
484
485 FILE *null = fopen("/dev/null", "w");
486 dup2(fileno(null), STDOUT_FILENO);
487 dup2(fileno(null), STDERR_FILENO);
488 #if defined(USE_CUSTOM_EXIT_PROC)
489 doCleanupFromExit = YES;
490 #endif
491 }
492
493 /*
494 * FIXME: Close stdin & stdout for remote debugging if XCNOSTDIN is
495 * set. Otherwise we will fight with gdb for stdin & stdout
496 */
497
498 if (getenv("XCNOSTDIN") != NULL) {
499 close(0);
500 close(1);
403501 }
404502
405503 /*
409507 */
410508
411509 TkMacOSXServices_Init(interp);
412 }
510
511 /*
512 * The root window has been created and mapped, but XMapWindow deferred its
513 * call to makeKeyAndOrderFront because the first call to XMapWindow
514 * occurs too early in the initialization process for that. Process idle
515 * tasks now, so the root window is configured, then order it front.
516 */
517
518 while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {};
519 for (NSWindow *window in [NSApp windows]) {
520 TkWindow *winPtr = TkMacOSXGetTkWindow(window);
521 if (winPtr && Tk_IsMapped(winPtr)) {
522 [window makeKeyAndOrderFront:NSApp];
523 break;
524 }
525 }
526
527 # if defined(USE_CUSTOM_EXIT_PROC)
528
529 if ((isatty(0) && isatty(1))) {
530 doCleanupFromExit = YES;
531 }
532
533 # endif
534
535 /*
536 * Install a signal handler for SIGINT, SIGHUP and SIGTERM which uses
537 * Tcl_Exit instead of exit so that normal cleanup takes place if a TK
538 * application is killed with one of these signals.
539 */
540
541 signal(SIGINT, TkMacOSXSignalHandler);
542 signal(SIGHUP, TkMacOSXSignalHandler);
543 signal(SIGTERM, TkMacOSXSignalHandler);
544 }
545
546 /*
547 * Initialization steps that are needed for all interpreters.
548 */
413549
414550 if (tkLibPath[0] != '\0') {
415551 Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
424560 TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
425561 Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
426562 TkMacOSXIconBitmapObjCmd, NULL, NULL);
427 Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath, NULL, NULL);
563 Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath",
564 TkMacOSXGetAppPathCmd, NULL, NULL);
565
428566 return TCL_OK;
429567 }
430568
464602 }
465603 Tcl_DStringAppend(namePtr, name, -1);
466604 }
467
468 /*
469 *----------------------------------------------------------------------
470 *
471 * TkMacOSXGetAppPath --
605
606 /*
607 *----------------------------------------------------------------------
608 *
609 * TkMacOSXGetAppPathCmd --
472610 *
473611 * Returns the path of the Wish application bundle.
474612 *
480618 *
481619 *----------------------------------------------------------------------
482620 */
483 int TkMacOSXGetAppPath(
484 ClientData cd,
485 Tcl_Interp *ip,
486 int objc,
487 Tcl_Obj *const objv[])
488 {
489
490 CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
491
492
493 /*
494 * Convert the URL reference into a string reference.
495 */
496
497 CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
498
499 /*
500 * Get the system encoding method.
501 */
502
503 CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
504
505 /*
506 * Convert the string reference into a C string.
507 */
508
509 char *path = (char *) CFStringGetCStringPtr(appPath, encodingMethod);
510
511 Tcl_SetResult(ip, path, NULL);
512
513 CFRelease(mainBundleURL);
514 CFRelease(appPath);
515 return TCL_OK;
516
517 }
518
621
622 static int
623 TkMacOSXGetAppPathCmd(
624 TCL_UNUSED(void *),
625 Tcl_Interp *interp,
626 int objc,
627 Tcl_Obj *const objv[])
628 {
629 if (objc != 1) {
630 Tcl_WrongNumArgs(interp, 1, objv, NULL);
631 return TCL_ERROR;
632 }
633
634 /*
635 * Get the application path URL and convert it to a string path reference.
636 */
637
638 CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
639 CFStringRef appPath =
640 CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
641
642 /*
643 * Convert (and copy) the string reference into a Tcl result.
644 */
645
646 Tcl_SetObjResult(interp, Tcl_NewStringObj(
647 CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
648
649 CFRelease(mainBundleURL);
650 CFRelease(appPath);
651 return TCL_OK;
652 }
653
519654 /*
520655 *----------------------------------------------------------------------
521656 *
582717 CFURLRef scriptFldrURL;
583718 char startupScript[PATH_MAX + 1];
584719
585 if (CFURLGetFileSystemRepresentation (appMainURL, true,
720 if (CFURLGetFileSystemRepresentation(appMainURL, true,
586721 (unsigned char *) startupScript, PATH_MAX)) {
587722 Tcl_SetStartupScript(Tcl_NewStringObj(startupScript,-1), NULL);
588723 scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent(NULL,
619754
620755 MODULE_SCOPE void*
621756 TkMacOSXGetNamedSymbol(
622 const char* module,
623 const char* symbol)
757 TCL_UNUSED(const char *),
758 const char *symbol)
624759 {
625760 void *addr = dlsym(RTLD_NEXT, symbol);
761
626762 if (!addr) {
627763 (void) dlerror(); /* Clear dlfcn error state */
628764 }
629765 return addr;
630 }
631
632 /*
633 *----------------------------------------------------------------------
634 *
635 * TkMacOSXGetStringObjFromCFString --
636 *
637 * Get a string object from a CFString as efficiently as possible.
638 *
639 * Results:
640 * New string object or NULL if conversion failed.
641 *
642 * Side effects:
643 * None.
644 *
645 *----------------------------------------------------------------------
646 */
647
648 MODULE_SCOPE Tcl_Obj*
649 TkMacOSXGetStringObjFromCFString(
650 CFStringRef str)
651 {
652 Tcl_Obj *obj = NULL;
653 const char *c = CFStringGetCStringPtr(str, kCFStringEncodingUTF8);
654
655 if (c) {
656 obj = Tcl_NewStringObj(c, -1);
657 } else {
658 CFRange all = CFRangeMake(0, CFStringGetLength(str));
659 CFIndex len;
660
661 if (CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false, NULL,
662 0, &len) > 0 && len < INT_MAX) {
663 obj = Tcl_NewObj();
664 Tcl_SetObjLength(obj, len);
665 CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false,
666 (UInt8*) obj->bytes, len, NULL);
667 }
668 }
669 return obj;
670766 }
671767
672768 /*
116116 MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
117117
118118 /*
119 * GC CGColorRef cache for tkMacOSXColor.c
120 */
121
122 typedef struct {
123 unsigned long cachedForeground;
124 CGColorRef cachedForegroundColor;
125 unsigned long cachedBackground;
126 CGColorRef cachedBackgroundColor;
127 } TkpGCCache;
128
129 MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc);
130 MODULE_SCOPE void TkpInitGCCache(GC gc);
131 MODULE_SCOPE void TkpFreeGCCache(GC gc);
132
133 /*
134119 * Undef compatibility platform types defined above.
135120 */
136121
179164 #define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024
180165
181166 /*
182 * Defines for tkTextDisp.c
167 * Defines for tkTextDisp.c and tkFont.c
183168 */
184169
185170 #define TK_LAYOUT_WITH_BASE_CHUNKS 1
190175 */
191176
192177 MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
193 #if 0
194 MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin,
195 int clip_y_origin, XRectangle* rectangles, int n, int ordering);
196 #endif
197178 MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
198179 int y, int width, int height);
199 MODULE_SCOPE void TkpRetainRegion(TkRegion r);
200 MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
201180 MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
202 MODULE_SCOPE Bool TkpAppIsDrawing(void);
203 MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin);
204 MODULE_SCOPE Bool TkTestLogDisplay(void);
205 MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
181 MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable);
206182
207183 /*
208184 * Include the stubbed internal platform-specific API.
66 * Copyright 2001-2009, Apple Inc.
77 * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
88 * Copyright (c) 2012 Adrian Robert.
9 * Copyright 2015-2019 Marc Culler.
9 * Copyright 2015-2020 Marc Culler.
1010 *
1111 * See the file "license.terms" for information on usage and redistribution of
1212 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
1515 #include "tkMacOSXPrivate.h"
1616 #include "tkMacOSXInt.h"
1717 #include "tkMacOSXConstants.h"
18 #include "tkMacOSXWm.h"
19
20 /*
21 * See tkMacOSXPrivate.h for macros related to key event processing.
22 */
1823
1924 /*
2025 #ifdef TK_MAC_DEBUG
2126 #define TK_MAC_DEBUG_KEYBOARD
2227 #endif
2328 */
29
2430 #define NS_KEYLOG 0
25
26 static Tk_Window keyboardGrabWinPtr = NULL;
27 /* Current keyboard grab window. */
28 static NSWindow *keyboardGrabNSWindow = nil;
29 /* NSWindow for the current keyboard grab
30 * window. */
31 #define XEVENT_MOD_MASK (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask)
32 static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */
33 static NSWindow *keyboardGrabNSWindow = nil; /* Its underlying NSWindow.*/
3134 static NSModalSession modalSession = nil;
3235 static BOOL processingCompose = NO;
3336 static Tk_Window composeWin = NULL;
3437 static int caret_x = 0, caret_y = 0, caret_height = 0;
35 static unsigned short releaseCode;
36
37 static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state);
38 static unsigned isFunctionKey(unsigned int code);
39
38 static void setupXEvent(XEvent *xEvent, Tk_Window tkwin, NSUInteger modifiers);
39 static void setXEventPoint(XEvent *xEvent, Tk_Window tkwin, NSWindow *w);
40 static NSUInteger textInputModifiers;
4041
4142 #pragma mark TKApplication(TKKeyEvent)
4243
4748 #ifdef TK_MAC_DEBUG_EVENTS
4849 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
4950 #endif
50 NSWindow *w;
51 NSWindow *w = [theEvent window];
52 TkWindow *winPtr = TkMacOSXGetTkWindow(w), *grabWinPtr, *focusWinPtr;
53 Tk_Window tkwin = (Tk_Window)winPtr;
5154 NSEventType type = [theEvent type];
55 NSUInteger virtual = [theEvent keyCode];
5256 NSUInteger modifiers = ([theEvent modifierFlags] &
5357 NSDeviceIndependentModifierFlagsMask);
54 NSUInteger len = 0;
55 BOOL repeat = NO;
56 unsigned short keyCode = [theEvent keyCode];
57 NSString *characters = nil, *charactersIgnoringModifiers = nil;
58 XEvent xEvent;
59 MacKeycode macKC;
60 UniChar keychar = 0;
61 Bool can_input_text, has_modifiers = NO, use_text_input = NO;
5862 static NSUInteger savedModifiers = 0;
59 static NSMutableArray *nsEvArray;
63 static NSMutableArray *nsEvArray = nil;
6064
6165 if (nsEvArray == nil) {
6266 nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
6367 processingCompose = NO;
6468 }
65
66 w = [theEvent window];
67 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
68 Tk_Window tkwin = (Tk_Window) winPtr;
69 XEvent xEvent;
70
7169 if (!winPtr) {
7270 return theEvent;
7371 }
7472
7573 /*
76 * Control-Tab and Control-Shift-Tab are used to switch tabs in a tabbed
77 * window. We do not want to generate an Xevent for these since that might
78 * cause the deselected tab to be reactivated.
79 */
80
81 if (keyCode == 48 && (modifiers & NSControlKeyMask) == NSControlKeyMask) {
82 return theEvent;
83 }
84
85 switch (type) {
86 case NSKeyUp:
87 /*Fix for bug #1ba71a86bb: key release firing on key press.*/
88 setupXEvent(&xEvent, w, 0);
89 xEvent.xany.type = KeyRelease;
90 xEvent.xkey.keycode = releaseCode;
91 xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
92 case NSKeyDown:
93 repeat = [theEvent isARepeat];
94 characters = [theEvent characters];
95 charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
96 len = [charactersIgnoringModifiers length];
97 case NSFlagsChanged:
98
99 #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
100 TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
101 #endif
102 break;
103
104 default:
105 return theEvent; /* Unrecognized key event. */
106 }
107
108 /*
109 * Create an Xevent to add to the Tk queue.
110 */
111
112 if (!processingCompose) {
113 unsigned int state = 0;
114
115 if (modifiers & NSAlphaShiftKeyMask) {
116 state |= LockMask;
117 }
118 if (modifiers & NSShiftKeyMask) {
119 state |= ShiftMask;
120 }
121 if (modifiers & NSControlKeyMask) {
122 state |= ControlMask;
123 }
124 if (modifiers & NSCommandKeyMask) {
125 state |= Mod1Mask; /* command key */
126 }
127 if (modifiers & NSAlternateKeyMask) {
128 state |= Mod2Mask; /* option key */
129 }
130 if (modifiers & NSNumericPadKeyMask) {
131 state |= Mod3Mask;
132 }
133 if (modifiers & NSFunctionKeyMask) {
134 state |= Mod4Mask;
135 }
136
137 /*
138 * Key events are only received for the front Window on the Macintosh. So
139 * to build an XEvent we look up the Tk window associated to the Front
140 * window.
141 */
142
143 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
144 Tk_Window tkwin = (Tk_Window) winPtr;
145
146 if (tkwin) {
147 TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
74 * If a local grab is in effect, key events for windows in the
75 * grabber's application are redirected to the grabber. Key events
76 * for other applications are delivered normally. If a global
77 * grab is in effect all key events are redirected to the grabber.
78 */
79
80 grabWinPtr = winPtr->dispPtr->grabWinPtr;
81 if (grabWinPtr) {
82 if (winPtr->dispPtr->grabFlags || /* global grab */
83 grabWinPtr->mainPtr == winPtr->mainPtr){ /* same application */
84 winPtr =winPtr->dispPtr->focusPtr;
85 tkwin = (Tk_Window)winPtr;
86 }
87 }
88
89 /*
90 * Extract the unicode character from KeyUp and KeyDown events.
91 */
92
93 if (type == NSKeyUp || type == NSKeyDown) {
94 if ([[theEvent characters] length] > 0) {
95 keychar = [[theEvent characters] characterAtIndex:0];
14896
14997 /*
150 * If a local grab is in effect, key events for windows in the
151 * grabber's application are redirected to the grabber. Key events
152 * for other applications are delivered normally. If a global
153 * grab is in effect all key events are redirected to the grabber.
98 * Currently, real keys always send BMP characters, but who knows?
15499 */
155100
156 if (grabWinPtr) {
157 if (winPtr->dispPtr->grabFlags || /* global grab */
158 grabWinPtr->mainPtr == winPtr->mainPtr){ /* same appl. */
159 tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
160 }
101 if (CFStringIsSurrogateHighCharacter(keychar)) {
102 UniChar lowChar = [[theEvent characters] characterAtIndex:1];
103 keychar = CFStringGetLongCharacterForSurrogatePair(
104 keychar, lowChar);
161105 }
162106 } else {
163 tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
164 }
165 if (!tkwin) {
166 TkMacOSXDbgMsg("tkwin == NULL");
167 return theEvent; /* Give up. No window for this event. */
168 }
169
170 /*
171 * If it's a function key, or we have modifiers other than Shift or
172 * Alt, pass it straight to Tk. Otherwise we'll send for input
173 * processing.
174 */
175
176 int code = (len == 0) ? 0 :
177 [charactersIgnoringModifiers characterAtIndex: 0];
178 if (type != NSKeyDown || isFunctionKey(code)
179 || (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) {
180 XEvent xEvent;
181
182 setupXEvent(&xEvent, w, state);
183 if (type == NSFlagsChanged) {
184 if (savedModifiers > modifiers) {
185 xEvent.xany.type = KeyRelease;
186 } else {
187 xEvent.xany.type = KeyPress;
188 }
189
190 /*
191 * Use special '-1' to signify a special keycode to our
192 * platform specific code in tkMacOSXKeyboard.c. This is rather
193 * like what happens on Windows.
194 */
195
196 xEvent.xany.send_event = -1;
197
198 /*
199 * Set keycode (which was zero) to the changed modifier
200 */
201
202 xEvent.xkey.keycode = (modifiers ^ savedModifiers);
203 } else {
204 if (type == NSKeyUp || repeat) {
205 xEvent.xany.type = KeyRelease;
206 } else {
207 xEvent.xany.type = KeyPress;
208 }
209
210 if ([characters length] > 0) {
211 xEvent.xkey.keycode = (keyCode << 16) |
212 (UInt16) [characters characterAtIndex:0];
213 if (![characters getCString:xEvent.xkey.trans_chars
214 maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) {
215 /* prevent SF bug 2907388 (crash on some composite chars) */
216 //PENDING: we might not need this anymore
217 TkMacOSXDbgMsg("characters too long");
218 return theEvent;
219 }
220 }
221
222 if (repeat) {
223 Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
224 xEvent.xany.type = KeyPress;
225 xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
226 }
227 }
228 Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
229 savedModifiers = modifiers;
230 return theEvent;
231 } /* if this is a function key or has modifiers */
232 } /* if not processing compose */
233
234 if (type == NSKeyDown) {
235 if (NS_KEYLOG) {
236 TKLog(@"keyDown: %s compose sequence.\n",
237 processingCompose == YES ? "Continue" : "Begin");
107
108 /*
109 * This is a dead key, such as Option-e, so it should go to the
110 * TextInputClient.
111 */
112
113 use_text_input = YES;
238114 }
239115
240116 /*
241 * Call the interpretKeyEvents method to interpret composition key
242 * strokes. When it detects a complete composition sequence it will
243 * call our implementation of insertText: replacementRange, which
244 * generates a key down XEvent with the appropriate character. In IME
245 * when multiple characters have the same composition sequence and the
246 * chosen character is not the default it may be necessary to hit the
247 * enter key multiple times before the character is accepted and
248 * rendered. We send enter key events until inputText has cleared
249 * the processingCompose flag.
117 * Apple uses 0x10 for unrecognized keys.
250118 */
251119
252 processingCompose = YES;
253 while(processingCompose) {
120 if (keychar == 0x10) {
121 keychar = UNKNOWN_KEYCHAR;
122 }
123
124 #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
125 TKLog(@"-[%@(%p) %s] repeat=%d mods=%x char=%x code=%lu c=%d type=%d",
126 [self class], self, _cmd,
127 (type == NSKeyDown) && [theEvent isARepeat], modifiers, keychar,
128 virtual, w, type);
129 #endif
130
131 }
132
133 /*
134 * Build a skeleton XEvent. We need to build it here, even if we will not
135 * send it, so we can pass it to TkFocusKeyEvent to determine whether the
136 * target widget can input text.
137 */
138
139 setupXEvent(&xEvent, tkwin, modifiers);
140 has_modifiers = xEvent.xkey.state & XEVENT_MOD_MASK;
141 focusWinPtr = TkFocusKeyEvent(winPtr, &xEvent);
142 if (focusWinPtr == NULL) {
143 TKContentView *contentView = [w contentView];
144
145 /*
146 * This NSEvent is being sent to a window which does not have focus.
147 * This could mean, for example, that the user deactivated the Tk app
148 * while the NSTextInputClient's popup character selection window was
149 * still open. We attempt to abandon any ongoing composition operation
150 * and discard the event.
151 */
152
153 [contentView cancelComposingText];
154 return theEvent;
155 }
156 can_input_text = ((focusWinPtr->flags & TK_CAN_INPUT_TEXT) != 0);
157
158 #if (NS_KEYLOG)
159 TKLog(@"keyDown: %s compose sequence.\n",
160 processingCompose == YES ? "Continue" : "Begin");
161 #endif
162
163 /*
164 * Decide whether this event should be processed with the NSTextInputClient
165 * protocol.
166 */
167
168 if (processingCompose ||
169 (type == NSKeyDown && can_input_text && !has_modifiers &&
170 IS_PRINTABLE(keychar))
171 ) {
172 use_text_input = YES;
173 }
174
175 /*
176 * If we are processing this KeyDown event as an NSTextInputClient we do
177 * not queue an XEvent. We pass the NSEvent to our interpretKeyEvents
178 * method. When the composition sequence is complete, the callback method
179 * insertText: replacementRange will be called. That method generates a
180 * keyPress XEvent with the selected character.
181 */
182
183 if (use_text_input) {
184 textInputModifiers = modifiers;
185
186 /*
187 * In IME the Enter key is used to terminate a composition sequence.
188 * When there are multiple choices of input text available, and the
189 * user's selected choice is not the default, it may be necessary to
190 * hit the Enter key multiple times before the text is accepted and
191 * rendered (See ticket 39de9677aa]). So when sending an Enter key
192 * during composition, we continue sending Enter keys until the
193 * inputText method has cleared the processingCompose flag.
194 */
195
196 if (processingCompose && [theEvent keyCode] == 36) {
197 [nsEvArray addObject: theEvent];
198 while(processingCompose) {
199 [[w contentView] interpretKeyEvents: nsEvArray];
200 }
201 [nsEvArray removeObject: theEvent];
202 } else {
254203 [nsEvArray addObject: theEvent];
255204 [[w contentView] interpretKeyEvents: nsEvArray];
256205 [nsEvArray removeObject: theEvent];
257 if ([theEvent keyCode] != 36) {
258 break;
259 }
260 }
261 }
262 savedModifiers = modifiers;
206 }
207 return theEvent;
208 }
209
210 /*
211 * We are not handling this event as an NSTextInputClient, so we need to
212 * finish constructing the XEvent and queue it.
213 */
214
215 macKC.v.o_s = ((modifiers & NSShiftKeyMask ? INDEX_SHIFT : 0) |
216 (modifiers & NSAlternateKeyMask ? INDEX_OPTION : 0));
217 macKC.v.virtual = virtual;
218 switch (type) {
219 case NSFlagsChanged:
220
221 /*
222 * This XEvent is a simulated KeyPress or KeyRelease event for a
223 * modifier key. To determine the type, note that the highest bit
224 * where the flags differ is 1 if and only if it is a KeyPress. The
225 * modifiers are saved so we can detect the next flag change.
226 */
227
228 xEvent.xany.type = modifiers > savedModifiers ? KeyPress : KeyRelease;
229 savedModifiers = modifiers;
230
231 /*
232 * Set the keychar to MOD_KEYCHAR as a signal to TkpGetKeySym (see
233 * tkMacOSXKeyboard.c) that this is a modifier key event.
234 */
235
236 keychar = MOD_KEYCHAR;
237 break;
238 case NSKeyUp:
239 xEvent.xany.type = KeyRelease;
240 break;
241 case NSKeyDown:
242 xEvent.xany.type = KeyPress;
243 break;
244 default:
245 return theEvent; /* Unrecognized key event. */
246 }
247 macKC.v.keychar = keychar;
248 xEvent.xkey.keycode = macKC.uint;
249 setXEventPoint(&xEvent, tkwin, w);
250
251 /*
252 * Finally we can queue the XEvent, inserting a KeyRelease before a
253 * repeated KeyPress.
254 */
255
256 if (type == NSKeyDown && [theEvent isARepeat]) {
257
258 xEvent.xany.type = KeyRelease;
259 Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
260 xEvent.xany.type = KeyPress;
261 }
262 Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
263263 return theEvent;
264264 }
265265 @end
266266
267267
268268 @implementation TKContentView
269
270 -(id)init {
271 self = [super init];
272 if (self) {
273 _needsRedisplay = NO;
274 }
275 return self;
276 }
269 @synthesize tkDirtyRect = _tkDirtyRect;
270 @synthesize tkNeedsDisplay = _tkNeedsDisplay;
277271
278272 /*
279273 * Implementation of the NSTextInputClient protocol.
281275
282276 /* [NSTextInputClient inputText: replacementRange:] is called by
283277 * interpretKeyEvents when a composition sequence is complete. It is also
284 * called when we delete over working text. In that case the call is followed
278 * called when we delete working text. In that case the call is followed
285279 * immediately by doCommandBySelector: deleteBackward:
286280 */
287281 - (void)insertText: (id)aString
288282 replacementRange: (NSRange)repRange
289283 {
290 int i, len;
284 int i, len, state;
291285 XEvent xEvent;
292 NSString *str;
286 NSString *str, *keystr, *lower;
287 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
288 Tk_Window tkwin = (Tk_Window)winPtr;
289 Bool sendingIMEText = NO;
293290
294291 str = ([aString isKindOfClass: [NSAttributedString class]]) ?
295292 [aString string] : aString;
299296 TKLog(@"insertText '%@'\tlen = %d", aString, len);
300297 }
301298
302 processingCompose = NO;
303
304299 /*
305300 * Clear any working text.
306301 */
307302
308303 if (privateWorkingText != nil) {
304 sendingIMEText = YES;
309305 [self deleteWorkingText];
310306 }
311307
313309 * Insert the string as a sequence of keystrokes.
314310 */
315311
316 setupXEvent(&xEvent, [self window], 0);
312 setupXEvent(&xEvent, tkwin, textInputModifiers);
313 setXEventPoint(&xEvent, tkwin, [self window]);
317314 xEvent.xany.type = KeyPress;
318315
319316 /*
324321 */
325322
326323 if (repRange.location == 0) {
327 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
328 Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
324 Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr;
329325 TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL);
330326 }
331327
332328 /*
333329 * Next we generate an XEvent for each unicode character in our string.
330 * This string could contain non-BMP characters, for example if the
331 * emoji palette was used.
334332 *
335333 * NSString uses UTF-16 internally, which means that a non-BMP character is
336 * represented by a sequence of two 16-bit "surrogates". In principle we
337 * could record this in the XEvent by setting the keycode to the 32-bit
338 * unicode code point and setting the trans_chars string to the 4-byte
339 * UTF-8 string for the non-BMP character. However, that will not work
340 * when TCL_UTF_MAX is set to 3, as is the case for Tcl 8.6. A workaround
341 * used internally by Tcl 8.6 is to encode each surrogate as a 3-byte
342 * sequence using the UTF-8 algorithm (ignoring the fact that the UTF-8
343 * encoding specification does not allow encoding UTF-16 surrogates).
344 * This gives a 6-byte encoding of the non-BMP character which we write into
345 * the trans_chars field of the XEvent.
346 */
347
334 * represented by a sequence of two 16-bit "surrogates". We record this in
335 * the XEvent by setting the low order 21-bits of the keycode to the UCS-32
336 * value value of the character and the virtual keycode in the high order
337 * byte to the special value NON_BMP.
338 */
339
340 state = xEvent.xkey.state;
348341 for (i = 0; i < len; i++) {
349 xEvent.xkey.nbytes = TclUniAtIndex(str, i, xEvent.xkey.trans_chars,
350 &xEvent.xkey.keycode);
351 if (xEvent.xkey.keycode > 0xffff){
352 i++;
353 }
342 UniChar keychar;
343 MacKeycode macKC = {0};
344
345 keychar = [str characterAtIndex:i];
346 macKC.v.keychar = keychar;
347 if (CFStringIsSurrogateHighCharacter(keychar)) {
348 UniChar lowChar = [str characterAtIndex:++i];
349 macKC.v.keychar = CFStringGetLongCharacterForSurrogatePair(
350 (UniChar)keychar, lowChar);
351 macKC.v.virtual = NON_BMP_VIRTUAL;
352 } else if (repRange.location == 0 || sendingIMEText) {
353 macKC.v.virtual = REPLACEMENT_VIRTUAL;
354 } else {
355 macKC.uint = TkMacOSXAddVirtual(macKC.uint);
356 xEvent.xkey.state |= INDEX2STATE(macKC.x.xvirtual);
357 }
358 keystr = [[NSString alloc] initWithCharacters:&keychar length:1];
359 lower = [keystr lowercaseString];
360 if (![keystr isEqual: lower]) {
361 macKC.v.o_s |= INDEX_SHIFT;
362 xEvent.xkey.state |= ShiftMask;
363 }
364 if (xEvent.xkey.state & Mod2Mask) {
365 macKC.v.o_s |= INDEX_OPTION;
366 }
367 xEvent.xkey.keycode = macKC.uint;
354368 xEvent.xany.type = KeyPress;
355369 Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
356 }
357 releaseCode = (UInt16) [str characterAtIndex: 0];
370 xEvent.xkey.state = state;
371 }
358372 }
359373
360374 /*
378392 replacementRange: (NSRange)repRange
379393 {
380394 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
381 Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
395 Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr;
382396 NSString *temp;
383397 NSString *str;
384398
385399 str = ([aString isKindOfClass: [NSAttributedString class]]) ?
386400 [aString string] : aString;
387
388401 if (focusWin) {
389402
390403 /*
415428 */
416429
417430 TkSendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL);
431 processingCompose = YES;
418432 temp = [str copy];
419433 [self insertText: temp replacementRange:repRange];
420434 privateWorkingText = temp;
421 processingCompose = YES;
422435 TkSendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL);
423436 }
424437
426439 {
427440 return privateWorkingText != nil;
428441 }
429
430442
431443 - (NSRange)markedRange
432444 {
440452 return rng;
441453 }
442454
443 - (void)cancelComposingText
455 - (void)unmarkText
444456 {
445457 if (NS_KEYLOG) {
446 TKLog(@"cancelComposingText");
458 TKLog(@"unmarkText");
447459 }
448460 [self deleteWorkingText];
449461 processingCompose = NO;
450462 }
451
452 - (void)unmarkText
453 {
454 if (NS_KEYLOG) {
455 TKLog(@"unmarkText");
456 }
457 [self deleteWorkingText];
458 processingCompose = NO;
459 }
460
461463
462464 /*
463465 * Called by the system to get a position for popup character selection windows
495497 processingCompose = NO;
496498 if (aSelector == @selector (deleteBackward:)) {
497499 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
498 Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
500 Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr;
499501 TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL);
500502 }
501503 }
542544 }
543545 /* End of NSTextInputClient implementation. */
544546
545 @synthesize needsRedisplay = _needsRedisplay;
546547 @end
547548
548549
572573 }
573574 }
574575 }
576
577 - (void)cancelComposingText
578 {
579 if (NS_KEYLOG) {
580 TKLog(@"cancelComposingText");
581 }
582 [self deleteWorkingText];
583 processingCompose = NO;
584 }
585
575586 @end
576587
577588 /*
579590 */
580591
581592 static void
582 setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state)
583 {
584 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
585 Tk_Window tkwin = (Tk_Window) winPtr;
586
587 if (!winPtr) {
593 setupXEvent(XEvent *xEvent, Tk_Window tkwin, NSUInteger modifiers)
594 {
595 unsigned int state = 0;
596 Display *display = Tk_Display(tkwin);
597
598 if (tkwin == NULL) {
588599 return;
589600 }
590
601 if (modifiers) {
602 state = (modifiers & NSAlphaShiftKeyMask ? LockMask : 0) |
603 (modifiers & NSShiftKeyMask ? ShiftMask : 0) |
604 (modifiers & NSControlKeyMask ? ControlMask : 0) |
605 (modifiers & NSCommandKeyMask ? Mod1Mask : 0) |
606 (modifiers & NSAlternateKeyMask ? Mod2Mask : 0) |
607 (modifiers & NSNumericPadKeyMask ? Mod3Mask : 0) |
608 (modifiers & NSFunctionKeyMask ? Mod4Mask : 0) ;
609 }
591610 memset(xEvent, 0, sizeof(XEvent));
592 xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
611 xEvent->xany.serial = LastKnownRequestProcessed(display);
593612 xEvent->xany.display = Tk_Display(tkwin);
594613 xEvent->xany.window = Tk_WindowId(tkwin);
595614
596 xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
615 xEvent->xkey.root = XRootWindow(display, 0);
597616 xEvent->xkey.time = TkpGetMS();
598617 xEvent->xkey.state = state;
599618 xEvent->xkey.same_screen = true;
600619 /* No need to initialize other fields implicitly here,
601620 * because of the memset() above. */
621 }
622
623 static void
624 setXEventPoint(
625 XEvent *xEvent,
626 Tk_Window tkwin,
627 NSWindow *w)
628 {
629 TkWindow *winPtr = (TkWindow *) tkwin;
630 NSPoint local = [w mouseLocationOutsideOfEventStream];
631 NSPoint global = [w tkConvertPointToScreen: local];
632 int win_x, win_y;
633
634 if (Tk_IsEmbedded(winPtr)) {
635 TkWindow *contPtr = TkpGetOtherWindow(winPtr);
636 if (Tk_IsTopLevel(contPtr)) {
637 local.x -= contPtr->wmInfoPtr->xInParent;
638 local.y -= contPtr->wmInfoPtr->yInParent;
639 } else {
640 TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
641 local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
642 local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
643 }
644 } else if (winPtr->wmInfoPtr != NULL) {
645 local.x -= winPtr->wmInfoPtr->xInParent;
646 local.y -= winPtr->wmInfoPtr->yInParent;
647 }
648 tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
649 local.x = win_x;
650 local.y = win_y;
651 global.y = TkMacOSXZeroScreenHeight() - global.y;
652 xEvent->xbutton.x = local.x;
653 xEvent->xbutton.y = local.y;
654 xEvent->xbutton.x_root = global.x;
655 xEvent->xbutton.y_root = global.y;
602656 }
603657
604658 #pragma mark -
632686 TkWindow *captureWinPtr = (TkWindow *) TkpGetCapture();
633687
634688 if (keyboardGrabWinPtr && captureWinPtr) {
635 NSWindow *w = TkMacOSXDrawableWindow(grab_window);
636 MacDrawable *macWin = (MacDrawable *) grab_window;
689 NSWindow *w = TkMacOSXGetNSWindowForDrawable(grab_window);
690 MacDrawable *macWin = (MacDrawable *)grab_window;
637691
638692 if (w && macWin->toplevel->winPtr == (TkWindow *) captureWinPtr) {
639693 if (modalSession) {
705759 *
706760 * Tk_SetCaretPos --
707761 *
708 * This enables correct placement of the XIM caret. This is called by
709 * widgets to indicate their cursor placement, and the caret location is
710 * used by TkpGetString to place the XIM caret.
762 * This enables correct placement of the popups used for character
763 * selection by the NSTextInputClient. It gets called by text entry
764 * widgets whenever the cursor is drawn. It does nothing if the widget's
765 * NSWindow is not the current KeyWindow. Otherwise it updates the
766 * display's caret structure and records the caret geometry in static
767 * variables for use by the NSTextInputClient implementation. Any
768 * widget passed to this function will be marked as being able to input
769 * text by setting the TK_CAN_INPUT_TEXT flag.
711770 *
712771 * Results:
713772 * None
714773 *
715774 * Side effects:
716 * None
775 * Sets the CAN_INPUT_TEXT flag on the widget passed as tkwin. May update
776 * the display's caret structure as well as the static variables caret_x,
777 * caret_y and caret_height.
717778 *
718779 *----------------------------------------------------------------------
719780 */
725786 int y,
726787 int height)
727788 {
728 TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
729
730 /*
731 * Prevent processing anything if the values haven't changed. Windows only
732 * has one display, so we can do this with statics.
733 */
734
735 if ((caretPtr->winPtr == ((TkWindow *) tkwin))
736 && (caretPtr->x == x) && (caretPtr->y == y)) {
789 TkWindow *winPtr = (TkWindow *) tkwin;
790 TkCaret *caretPtr = &(winPtr->dispPtr->caret);
791 NSWindow *w = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin));
792
793 /*
794 * Register this widget as being capable of text input, so we know we
795 * should process (appropriate) key events for this window with the
796 * NSTextInputClient protocol.
797 */
798
799 winPtr->flags |= TK_CAN_INPUT_TEXT;
800 if (w && ![w isKeyWindow]) {
737801 return;
738802 }
739
740 caretPtr->winPtr = ((TkWindow *) tkwin);
803 if ((caretPtr->winPtr == winPtr
804 && caretPtr->x == x) && (caretPtr->y == y)) {
805 return;
806 }
807
808 /*
809 * Update the display's caret information.
810 */
811
812 caretPtr->winPtr = winPtr;
741813 caretPtr->x = x;
742814 caretPtr->y = y;
743815 caretPtr->height = height;
744816
745817 /*
746 * As in Windows, adjust to the toplevel to get the coords right.
747 */
748
818 * Record the caret geometry in static variables for use when processing
819 * key events. We use the TKContextView coordinate system for this.
820 */
821
822 caret_height = height;
749823 while (!Tk_IsTopLevel(tkwin)) {
750824 x += Tk_X(tkwin);
751825 y += Tk_Y(tkwin);
754828 return;
755829 }
756830 }
757
758 /*
759 * But adjust for fact that NS uses flipped view.
760 */
761
762 y = Tk_Height(tkwin) - y;
763
764831 caret_x = x;
765 caret_y = y;
766 caret_height = height;
767 }
768
769
770 static unsigned convert_ns_to_X_keysym[] =
771 {
772 NSHomeFunctionKey, 0x50,
773 NSLeftArrowFunctionKey, 0x51,
774 NSUpArrowFunctionKey, 0x52,
775 NSRightArrowFunctionKey, 0x53,
776 NSDownArrowFunctionKey, 0x54,
777 NSPageUpFunctionKey, 0x55,
778 NSPageDownFunctionKey, 0x56,
779 NSEndFunctionKey, 0x57,
780 NSBeginFunctionKey, 0x58,
781 NSSelectFunctionKey, 0x60,
782 NSPrintFunctionKey, 0x61,
783 NSExecuteFunctionKey, 0x62,
784 NSInsertFunctionKey, 0x63,
785 NSUndoFunctionKey, 0x65,
786 NSRedoFunctionKey, 0x66,
787 NSMenuFunctionKey, 0x67,
788 NSFindFunctionKey, 0x68,
789 NSHelpFunctionKey, 0x6A,
790 NSBreakFunctionKey, 0x6B,
791
792 NSF1FunctionKey, 0xBE,
793 NSF2FunctionKey, 0xBF,
794 NSF3FunctionKey, 0xC0,
795 NSF4FunctionKey, 0xC1,
796 NSF5FunctionKey, 0xC2,
797 NSF6FunctionKey, 0xC3,
798 NSF7FunctionKey, 0xC4,
799 NSF8FunctionKey, 0xC5,
800 NSF9FunctionKey, 0xC6,
801 NSF10FunctionKey, 0xC7,
802 NSF11FunctionKey, 0xC8,
803 NSF12FunctionKey, 0xC9,
804 NSF13FunctionKey, 0xCA,
805 NSF14FunctionKey, 0xCB,
806 NSF15FunctionKey, 0xCC,
807 NSF16FunctionKey, 0xCD,
808 NSF17FunctionKey, 0xCE,
809 NSF18FunctionKey, 0xCF,
810 NSF19FunctionKey, 0xD0,
811 NSF20FunctionKey, 0xD1,
812 NSF21FunctionKey, 0xD2,
813 NSF22FunctionKey, 0xD3,
814 NSF23FunctionKey, 0xD4,
815 NSF24FunctionKey, 0xD5,
816
817 NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
818 NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
819 NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
820
821 NSTabCharacter, 0x09,
822 0x19, 0x09, /* left tab->regular since pass shift */
823 NSCarriageReturnCharacter, 0x0D,
824 NSNewlineCharacter, 0x0D,
825 NSEnterCharacter, 0x8D,
826
827 0x1B, 0x1B /* escape */
828 };
829
830
831 static unsigned
832 isFunctionKey(
833 unsigned code)
834 {
835 const unsigned last_keysym = (sizeof(convert_ns_to_X_keysym)
836 / sizeof(convert_ns_to_X_keysym[0]));
837 unsigned keysym;
838
839 for (keysym = 0; keysym < last_keysym; keysym += 2) {
840 if (code == convert_ns_to_X_keysym[keysym]) {
841 return 0xFF00 | convert_ns_to_X_keysym[keysym + 1];
842 }
843 }
844 return 0;
832 caret_y = Tk_Height(tkwin) - y;
845833 }
846834
847835 /*
55 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
66 * Copyright 2001-2009, Apple Inc.
77 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
8 * Copyright (c) 2020 Marc Culler
89 *
910 * See the file "license.terms" for information on usage and redistribution
1011 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1314 #include "tkMacOSXPrivate.h"
1415 #include "tkMacOSXEvent.h"
1516 #include "tkMacOSXConstants.h"
16 /*
17 * A couple of simple definitions to make code a bit more self-explaining.
18 *
19 * For the assignments of Mod1==meta==command and Mod2==alt==option, see also
20 * tkMacOSXMouseEvent.c.
21 */
22
23 #define LATIN1_MAX 255
24 #define MAC_KEYCODE_MAX 0x7F
25 #define MAC_KEYCODE_MASK 0x7F
26 #define COMMAND_MASK Mod1Mask
27 #define OPTION_MASK Mod2Mask
28
29
30 /*
31 * Tables enumerating the special keys defined on Mac keyboards. These are
32 * necessary for correct keysym mappings for all keys where the keysyms are
33 * not identical with their ASCII or Latin-1 code points.
34 */
35
36 typedef struct {
37 int keycode; /* Macintosh keycode. */
38 KeySym keysym; /* X windows keysym. */
39 } KeyInfo;
40
41 /*
42 * Notes on keyArray:
43 *
44 * 0x34, XK_Return - Powerbooks use this and some keymaps define it.
45 *
46 * 0x4C, XK_Return - XFree86 and Apple's X11 call this one XK_KP_Enter.
47 *
48 * 0x47, XK_Clear - This key is NumLock when used on PCs, but Mac
49 * applications don't use it like that, nor does Apple's X11.
50 *
51 * All other keycodes are taken from the published ADB keyboard layouts.
52 */
53
54 static KeyInfo keyArray[] = {
55 {0x24, XK_Return},
56 {0x30, XK_Tab},
57 {0x33, XK_BackSpace},
58 {0x34, XK_Return},
59 {0x35, XK_Escape},
60
61 {0x47, XK_Clear},
62 {0x4C, XK_KP_Enter},
63
64 {0x72, XK_Help},
65 {0x73, XK_Home},
66 {0x74, XK_Page_Up},
67 {0x75, XK_Delete},
68 {0x77, XK_End},
69 {0x79, XK_Page_Down},
70
71 {0x7B, XK_Left},
72 {0x7C, XK_Right},
73 {0x7D, XK_Down},
74 {0x7E, XK_Up},
75
76 {0, 0}
77 };
78
79 static KeyInfo virtualkeyArray[] = {
80 {122, XK_F1},
81 {120, XK_F2},
82 {99, XK_F3},
83 {118, XK_F4},
84 {96, XK_F5},
85 {97, XK_F6},
86 {98, XK_F7},
87 {100, XK_F8},
88 {101, XK_F9},
89 {109, XK_F10},
90 {103, XK_F11},
91 {111, XK_F12},
92 {105, XK_F13},
93 {107, XK_F14},
94 {113, XK_F15},
95 {0, 0}
96 };
97
98 #define NUM_MOD_KEYCODES 14
99 static KeyCode modKeyArray[NUM_MOD_KEYCODES] = {
100 XK_Shift_L,
101 XK_Shift_R,
102 XK_Control_L,
103 XK_Control_R,
104 XK_Caps_Lock,
105 XK_Shift_Lock,
106 XK_Meta_L,
107 XK_Meta_R,
108 XK_Alt_L,
109 XK_Alt_R,
110 XK_Super_L,
111 XK_Super_R,
112 XK_Hyper_L,
113 XK_Hyper_R,
114 };
115
116 static int initialized = 0;
117 static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */
118 static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual
119 * keycode value. */
120
121 static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for
122 * controls, ASCII and Latin-1. */
123
124 static int keyboardChanged = 1;
17 #include "tkMacOSXKeysyms.h"
18
19 /*
20 * About keyboards
21 * ---------------
22 * Keyboards are complicated. This long comment is an attempt to provide
23 * enough information about them to make it possible to read and understand
24 * the code in this file.
25 *
26 * Every key on a keyboard is identified by a number between 0 and 127. In
27 * macOS, pressing or releasing a key on the keyboard generates an NSEvent of
28 * type KeyDown, KeyUp or FlagsChanged. The 8-bit identifier of the key that
29 * was involved in this event is provided in the attribute [NSEvent keyCode].
30 * Apple also refers to this number as a "Virtual KeyCode". In this file, to
31 * avoid confusion with other uses of the word keycode, we will refer to this
32 * key identifier as a "virtual keycode", usually the value of a variable named
33 * "virtual".
34 *
35 * Some of the keys on a keyboard, such as the Shift, Option, Command or
36 * Control keys, are "modifier" keys. The effect of pressing or releasing a
37 * key depends on three quantities:
38 * - which key is being pressed or released
39 * - which modifier keys are being held down at the moment
40 * - the current keyboard layout
41 * If the key is a modifier key then the effect of pressing or releasing it is
42 * only to change the list of which modifier keys are being held down. Apple
43 * reports this by sending an NSEvent of type FlagsChanged. X11 reports this
44 * as a KeyPress or KeyRelease event for the modifier key. Note that there may
45 * be combinations of modifier key states and key presses which have no effect.
46 *
47 * In X11 every meaningful effect from a key action is identified by a 16 bit
48 * value known as a keysym. Every keysym has an associated string name, also
49 * known as a keysym. The Tk bind command uses the X11 keysym string to
50 * specify a key event which should invoke a certain action and it provides the
51 * numeric and symbolic keysyms to the bound proc as %N and %K respectively.
52 * An X11 XEvent which reports a KeyPress or KeyRelease does not include the
53 * keysym. Instead it includes a platform-specific numerical value called a
54 * keycode which is available to the bound procedure as %k. A platform port of
55 * Tk must provide functions which convert between keycodes and numerical
56 * keysyms. Conversion between numerical and symbolic keysyms is provided by
57 * the generic Tk code, although platforms are allowed to provide their own by
58 * defining the XKeysymToString and XStringToKeysym functions and undefining
59 * the macro REDO_KEYSYM_LOOKUP. This macOS port uses the conversion provided
60 * by the generic code.
61 *
62 * When the keyboard focus is on a Tk widget which provides text input, there
63 * are some X11 KeyPress events which cause text to be inserted. We will call
64 * these "printable" events. The UCS-32 character stored in the keycode field
65 * of an XKeyEvent depends on more than the three items above. It may also
66 * depend on the sequence of keypresses that preceded the one being reported by
67 * the XKeyEvent. For example, on macOS an <Alt-e> event does not cause text
68 * to be inserted but a following <a> event causes an accented 'a' to be
69 * inserted. The events in such a composition sequence, other than the final
70 * one, are known as "dead-key" events.
71 *
72 * MacOS packages the information described above in a different way. Every
73 * meaningful effect from a key action *other than changing the state of
74 * modifier keys* is identified by a unicode string which is provided as the
75 * [NSEvent characters] attribute of a KeyDown or KeyUp event. FlagsChanged
76 * events do not have characters. In principle, the characters attribute could
77 * be an arbitrary unicode string but in practice it is always a single UTF-16
78 * character which we usually store in a variable named keychar. While the
79 * keychar is a legal unicode code point, it does not necessarily represent a
80 * glyph. MacOS uses unicode code points in the private-use range 0xF700-0xF8FF
81 * for non-printable events which have no associated ASCII code point. For
82 * example, pressing the F2 key generates an NSEvent with the character 0xF705,
83 * the Backspace key produces 0x7F (ASCII del) and the Delete key produces
84 * 0xF728.
85 *
86 * With the exception of modifier keys, it is possible to translate between
87 * numerical X11 keysyms and macOS keychars; this file constructs Tcl hash
88 * tables to do this job, using data defined in the file tkMacOSXKeysyms.h.
89 * The code here adopts the convention that the keychar of any modifier key
90 * is MOD_KEYCHAR. Keys which do not appear on any Macintosh keyboard, such
91 * as the Menu key on PC keyboards, are assigned UNKNOWN_KEYCHAR.
92 *
93 * The macosx platform-specific scheme for generating a keycode when mapping an
94 * NSEvent of type KeyUp, KeyDown or FlagsChanged to an XEvent of type KeyPress
95 * or KeyRelease is as follows:
96 * keycode = (virtual << 24) | index << 22 | keychar
97 * where index is a 2-bit quantity whose bits indicate the state of the Option
98 * and Shift keys.
99 *
100 * A few remarks are in order. First, we are using 32 bits for the keycode and
101 * we are allowing room for up to 22 bits for the keychar. This means that
102 * there is enough room in the keycode to hold a UTF-32 character, which only
103 * requires 21 bits. Second, the KeyCode type for the keycode field in an
104 * XEvent is currently defined as unsigned int, which was modified from the
105 * unsigned short used in X11 in order to accomodate macOS. Finally, there is
106 * no obstruction to generating KeyPress events for keys that represent letters
107 * which do not exist on the current keyboard layout. And different keyboard
108 * layouts can assign a given letter to different keys. So we need a
109 * convention for what value to assign to "virtual" when computing the keycode
110 * for a generated event. The convention used here is as follows: If there is
111 * a key on the current keyboard which produces the keychar, use the virtual
112 * keycode of that key. Otherwise set virtual = NO_VIRTUAL.
113 */
114
115
116 /*
117 * See tkMacOSXPrivate.h for macros and structures related to key event processing.
118 */
119
120 /*
121 * Hash tables and array used to translate between various key attributes.
122 */
123
124 static Tcl_HashTable special2keysym; /* Special virtual keycode to keysym */
125 static Tcl_HashTable keysym2keycode; /* keysym to XEvent keycode */
126 static Tcl_HashTable keysym2unichar; /* keysym to unichar */
127 static Tcl_HashTable unichar2keysym; /* unichar to X11 keysym */
128 static Tcl_HashTable unichar2xvirtual; /* unichar to virtual with index */
129 static UniChar xvirtual2unichar[512]; /* virtual with index to unichar */
130
131 /*
132 * Flags.
133 */
134
135 static BOOL initialized = NO;
136 static BOOL keyboardChanged = YES;
125137
126138 /*
127139 * Prototypes for static functions used in this file.
128140 */
129141
130 static void InitKeyMaps (void);
131 static void InitLatin1Table(Display *display);
132 static int XKeysymToMacKeycode(Display *display, KeySym keysym);
133 static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
134 UInt16 keyaction, UInt32 keycode, UInt32 modifiers,
142 static void InitHashTables(void);
143 static void UpdateKeymaps(void);
144 static int KeyDataToUnicode(UniChar *uniChars, int maxChars,
145 UInt16 keyaction, UInt32 virtual, UInt32 modifiers,
135146 UInt32 * deadKeyStatePtr);
136147
137148 #pragma mark TKApplication(TKKeyboard)
139150 @implementation TKApplication(TKKeyboard)
140151 - (void) keyboardChanged: (NSNotification *) notification
141152 {
153 (void)notification;
142154 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
143155 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
156 #else
157 (void)notification;
144158 #endif
145 keyboardChanged = 1;
159 keyboardChanged = YES;
160 UpdateKeymaps();
146161 }
147162 @end
148163
151166 /*
152167 *----------------------------------------------------------------------
153168 *
154 * InitKeyMaps --
169 * InitHashTables --
155170 *
156171 * Creates hash tables used by some of the functions in this file.
157172 *
158 * FIXME: As keycodes are defined to be in the limited range 0-127, it
159 * would be easier and more efficient to use directly initialized plain
160 * arrays and drop this function.
161 *
162173 * Results:
163174 * None.
164175 *
169180 */
170181
171182 static void
172 InitKeyMaps(void)
183 InitHashTables(void)
173184 {
174185 Tcl_HashEntry *hPtr;
175 KeyInfo *kPtr;
176 int dummy;
177
178 Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS);
179 for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
180 hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode),
181 &dummy);
186 const KeyInfo *kPtr;
187 const KeysymInfo *ksPtr;
188 int dummy, index;
189
190 Tcl_InitHashTable(&special2keysym, TCL_ONE_WORD_KEYS);
191 Tcl_InitHashTable(&keysym2keycode, TCL_ONE_WORD_KEYS);
192 for (kPtr = keyArray; kPtr->virtual != 0; kPtr++) {
193 MacKeycode macKC;
194 macKC.v.o_s = 0;
195 hPtr = Tcl_CreateHashEntry(&special2keysym, INT2PTR(kPtr->virtual),
196 &dummy);
182197 Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
183 }
184 Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
185 for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
186 hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode),
187 &dummy);
188 Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
189 }
190 initialized = 1;
191 }
192
193 /*
194 *----------------------------------------------------------------------
195 *
196 * InitLatin1Table --
197 *
198 * Creates a simple table to be used for mapping from keysyms to keycodes.
199 * Always needs to be called before using latin1Table, because the
200 * keyboard layout may have changed, and than the table must be
201 * re-computed.
198 hPtr = Tcl_CreateHashEntry(&keysym2keycode, INT2PTR(kPtr->keysym),
199 &dummy);
200 macKC.v.virtual = kPtr->virtual;
201 macKC.v.keychar = kPtr->keychar;
202 Tcl_SetHashValue(hPtr, INT2PTR(macKC.uint));
203
204 /*
205 * The Carbon framework does not work for finding the unicode character
206 * of a special key. But that does not depend on the keyboard layout,
207 * so we can record the information here.
208 */
209
210 for (index = 3; index >= 0; index--) {
211 macKC.v.o_s = index;
212 xvirtual2unichar[macKC.x.xvirtual] = macKC.x.keychar;
213 }
214 }
215 Tcl_InitHashTable(&keysym2unichar, TCL_ONE_WORD_KEYS);
216 Tcl_InitHashTable(&unichar2keysym, TCL_ONE_WORD_KEYS);
217 for (ksPtr = keysymTable; ksPtr->keysym != 0; ksPtr++) {
218 hPtr = Tcl_CreateHashEntry(&keysym2unichar, INT2PTR(ksPtr->keysym),
219 &dummy);
220 Tcl_SetHashValue(hPtr, INT2PTR(ksPtr->keycode));
221 hPtr = Tcl_CreateHashEntry(&unichar2keysym, INT2PTR(ksPtr->keycode),
222 &dummy);
223 Tcl_SetHashValue(hPtr, INT2PTR(ksPtr->keysym));
224 }
225 UpdateKeymaps();
226 initialized = YES;
227 }
228
229 /*
230 *----------------------------------------------------------------------
231 *
232 * UpdateKeymaps --
233 *
234 * Called when the keyboard changes to update the hash tables that provide
235 * maps between unicode characters and virtual keycodes with indexes. In
236 * order for the map from characters to virtual keycodes to be
237 * well-defined we have to ignore virtual keycodes for keypad keys, since
238 * each keypad key has the same character as the corresponding key on the
239 * main keyboard.
202240 *
203241 * Results:
204242 * None.
205243 *
206244 * Side effects:
207 * Sets the global latin1Table.
245 * Initializes, if necessary, and updates the unichar2xvirtual hash table
246 * and the xvirtual2unichar array.
208247 *
209248 *----------------------------------------------------------------------
210249 */
211250
212251 static void
213 InitLatin1Table(
214 Display *display)
215 {
216 int keycode;
217 KeySym keysym;
218 int state;
219 int modifiers;
220
221 memset(latin1Table, 0, sizeof(latin1Table));
222
223 /*
224 * In the common X11 implementations, a keymap has four columns
225 * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't
226 * use "Mode_switch", but we use "Option" instead. (This is similar to
227 * Apple's X11 implementation, where "Mode_switch" is used as an alias
228 * for "Option".)
229 *
230 * So here we go through all 4 columns of the keymap and find all
231 * Latin-1 compatible keycodes. We go through the columns back-to-front
232 * from the more exotic columns to the more simple, so that simple
233 * keycode-modifier combinations are preferred in the resulting table.
234 */
235
236 for (state = 3; state >= 0; state--) {
237 modifiers = 0;
238 if (state & 1) {
239 modifiers |= shiftKey;
240 }
241 if (state & 2) {
242 modifiers |= optionKey;
243 }
244
245 for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) {
246 keysym = XKeycodeToKeysym(display,keycode<<16,state);
247 if (keysym <= LATIN1_MAX) {
248 latin1Table[keysym] = keycode | modifiers;
252 UpdateKeymaps()
253 {
254 static Bool keymapInitialized = false;
255 Tcl_HashEntry *hPtr;
256 int virtual, index, dummy;
257
258 if (!keymapInitialized) {
259 Tcl_InitHashTable(&unichar2xvirtual, TCL_ONE_WORD_KEYS);
260 keymapInitialized = true;
261 } else {
262 Tcl_DeleteHashTable(&unichar2xvirtual);
263 Tcl_InitHashTable(&unichar2xvirtual, TCL_ONE_WORD_KEYS);
264 }
265 /*
266 * This loop goes backwards so that a lookup by keychar will provide the
267 * minimal modifier mask. Simpler combinations will overwrite more complex
268 * ones when constructing the table.
269 */
270
271 for (index = 3; index >= 0; index--) {
272 for (virtual = 0; virtual < 128; virtual++) {
273 MacKeycode macKC;
274 macKC.v = (keycode_v) {.virtual = virtual, .o_s = index, .keychar = 0};
275 int modifiers = INDEX2CARBON(index), result;
276 UniChar keychar = 0;
277 result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virtual,
278 modifiers, NULL);
279 if (keychar == 0x10) {
280
281 /*
282 * This is a special key, handled in InitHashTables.
283 */
284
285 continue;
249286 }
250 }
251 }
252 }
253
254 /*
255 *----------------------------------------------------------------------
256 *
257 * KeycodeToUnicode --
258 *
259 * Given MacOS key event data this function generates the Unicode
260 * characters. It does this using OS resources and APIs.
287 macKC.v.keychar = keychar;
288 if (! ON_KEYPAD(virtual)) {
289 hPtr = Tcl_CreateHashEntry(&unichar2xvirtual,
290 INT2PTR(macKC.x.keychar), &dummy);
291 Tcl_SetHashValue(hPtr, INT2PTR(macKC.x.xvirtual));
292 }
293 xvirtual2unichar[macKC.x.xvirtual] = macKC.x.keychar;
294 }
295 }
296 }
297
298 /*
299 *----------------------------------------------------------------------
300 *
301 * KeyDataToUnicode --
302 *
303 * Given MacOS key event data this function generates the keychar. It
304 * does this by using OS resources from the Carbon framework. Note that
305 * the Carbon functions used here are not aware of the keychars in the
306 * private-use range which macOS now uses for special keys. For those
307 * keys this function returns 0x10 (ASCII dle).
261308 *
262309 * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
263 * needed.
264 *
265 * This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c.
310 * needed (which is always the case here).
311 *
312 * This function is called in XKeycodeToKeysym and UpdateKeymaps.
266313 *
267314 * Results:
268315 * The number of characters generated if any, 0 if we are waiting for
269 * another byte of a dead-key sequence. Fills in the uniChars array with a
270 * Unicode string.
316 * another byte of a dead-key sequence.
271317 *
272318 * Side Effects:
273 * None
274 *
275 *----------------------------------------------------------------------
276 */
319 * Fills in the uniChars array with a Unicode string.
320 *
321 *----------------------------------------------------------------------
322 */
323
277324
278325 static int
279 KeycodeToUnicode(
326 KeyDataToUnicode(
280327 UniChar *uniChars,
281328 int maxChars,
282329 UInt16 keyaction,
283 UInt32 keycode,
330 UInt32 virtual,
284331 UInt32 modifiers,
285332 UInt32 *deadKeyStatePtr)
286333 {
287 static const void *uchr = NULL;
334 static const void *layoutData = NULL;
288335 static UInt32 keyboardType = 0;
289336 UniCharCount actuallength = 0;
290337
297344 currentKeyboardLayout, kTISPropertyUnicodeKeyLayoutData);
298345
299346 if (keyLayoutData) {
300 uchr = CFDataGetBytePtr(keyLayoutData);
347 layoutData = CFDataGetBytePtr(keyLayoutData);
301348 keyboardType = LMGetKbdType();
302349 }
303350 CFRelease(currentKeyboardLayout);
304351 }
305352 keyboardChanged = 0;
306353 }
307 if (uchr) {
354 if (layoutData) {
308355 OptionBits options = 0;
309356 UInt32 dummyState;
310357 OSStatus err;
311358
312 keycode &= 0xFF;
359 virtual &= 0xFF;
313360 modifiers = (modifiers >> 8) & 0xFF;
314
315361 if (!deadKeyStatePtr) {
316362 options = kUCKeyTranslateNoDeadKeysMask;
317363 dummyState = 0;
318364 deadKeyStatePtr = &dummyState;
319365 }
320
321 err = ChkErr(UCKeyTranslate, uchr, keycode, keyaction, modifiers,
366 err = ChkErr(UCKeyTranslate, layoutData, virtual, keyaction, modifiers,
322367 keyboardType, options, deadKeyStatePtr, maxChars,
323368 &actuallength, uniChars);
324
325369 if (!actuallength && *deadKeyStatePtr) {
370
326371 /*
327 * More data later
372 * We are waiting for another key.
328373 */
329374
330375 return 0;
342387 *
343388 * XKeycodeToKeysym --
344389 *
345 * Translate from a system-dependent keycode to a system-independent
346 * keysym.
347 *
348 * Results:
349 * Returns the translated keysym, or NoSymbol on failure.
390 * This is a stub function which translates from the keycode used in an
391 * XEvent to a numerical keysym. On macOS, the display parameter is
392 * ignored and only the the virtual keycode stored in the .virtual bitfield
393 * of a MacKeycode.v.
394 *
395 * Results:
396 * Returns the corresponding numerical keysym, or NoSymbol if the keysym
397 * cannot be found.
350398 *
351399 * Side effects:
352400 * None.
353401 *
354402 *----------------------------------------------------------------------
355403 */
404
405 KeySym
406 XkbKeycodeToKeysym(
407 TCL_UNUSED(Display *),
408 unsigned int keycode,
409 TCL_UNUSED(int),
410 int index)
411 {
412 Tcl_HashEntry *hPtr;
413 MacKeycode macKC;
414 int modifiers, result;
415 UniChar keychar = 0;
416
417 if (!initialized) {
418 InitHashTables();
419 }
420 macKC.uint = keycode;
421 macKC.v.o_s = index;
422
423 /*
424 * First check if the virtual keycode corresponds to a special key, such as
425 * an Fn function key or Tab, Backspace, Home, End, etc.
426 */
427
428 hPtr = Tcl_FindHashEntry(&special2keysym, INT2PTR(macKC.v.virtual));
429 if (hPtr != NULL) {
430 return (KeySym) Tcl_GetHashValue(hPtr);
431 }
432
433 /*
434 * If the virtual value in this keycode does not correspond to an actual
435 * key in the current keyboard layout, try using its keychar to look up a
436 * keysym.
437 */
438
439 if (macKC.v.virtual > 127) {
440 hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(macKC.v.keychar));
441 if (hPtr != NULL) {
442 return (KeySym) Tcl_GetHashValue(hPtr);
443 }
444 }
445
446 /*
447 * If the virtual keycode does belong to a key, use the virtual and the
448 * Option-Shift from index to look up a keychar by using the Carbon
449 * Framework; then translate the keychar to a keysym using the
450 * unicode2keysym hash table.
451 */
452
453 modifiers = INDEX2CARBON(macKC.v.o_s);
454 result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, macKC.v.virtual,
455 modifiers, NULL);
456 if (result) {
457 hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(keychar));
458 if (hPtr != NULL) {
459 return (KeySym) Tcl_GetHashValue(hPtr);
460 }
461 }
462 return NoSymbol;
463 }
356464
357465 KeySym
358466 XKeycodeToKeysym(
359 Display* display,
467 TCL_UNUSED(Display *),
360468 KeyCode keycode,
361469 int index)
362470 {
363 register Tcl_HashEntry *hPtr;
364 int newKeycode;
365 UniChar newChar;
366
367 (void) display; /*unused*/
368
369 if (!initialized) {
370 InitKeyMaps();
371 }
372
373 /*
374 * When determining what keysym to produce we first check to see if the key
375 * is a function key. We then check to see if the character is another
376 * non-printing key. Finally, we return the key syms for all ASCII and
377 * Latin-1 chars.
378 */
379
380 newKeycode = keycode >> 16;
381
382 if ((keycode & 0xFFFF) >= 0xF700) { /* NSEvent.h function key unicodes */
383 hPtr = Tcl_FindHashEntry(&vkeyTable, INT2PTR(newKeycode));
384 if (hPtr != NULL) {
385 return (KeySym) Tcl_GetHashValue(hPtr);
386 }
387 }
388 hPtr = Tcl_FindHashEntry(&keycodeTable, INT2PTR(newKeycode));
389 if (hPtr != NULL) {
390 return (KeySym) Tcl_GetHashValue(hPtr);
391 }
392
393 /*
394 * Add in the Mac modifier flags for shift and option.
395 */
396
397 if (index & 1) {
398 newKeycode |= shiftKey;
399 }
400 if (index & 2) {
401 newKeycode |= optionKey;
402 }
403
404 newChar = 0;
405 KeycodeToUnicode(&newChar, 1, kUCKeyActionDown, newKeycode & 0x00FF,
406 newKeycode & 0xFF00, NULL);
407
408 /*
409 * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for
410 * other characters for now.
411 */
412
413 if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) {
414 return newChar;
415 }
416
417 return NoSymbol;
471 return XkbKeycodeToKeysym(NULL, keycode, 0, index);
418472 }
419473
420474 /*
422476 *
423477 * TkpGetString --
424478 *
425 * Retrieve the string equivalent for the given keyboard event.
426 *
427 * Results:
428 * Returns the UTF string.
479 * This is a stub function which retrieves the string stored in the
480 * transchars field of an XEvent and converts it to a Tcl_DString.
481 *
482 * Results:
483 * Returns a pointer to the string value of the DString.
429484 *
430485 * Side effects:
431486 * None.
435490
436491 const char *
437492 TkpGetString(
438 TkWindow *winPtr, /* Window where event occurred: Needed to get
493 TCL_UNUSED(TkWindow *), /* Window where event occurred: Needed to get
439494 * input context. */
440495 XEvent *eventPtr, /* X keyboard event. */
441496 Tcl_DString *dsPtr) /* Uninitialized or empty string to hold
442497 * result. */
443498 {
444 (void) winPtr; /*unused*/
445 int ch;
499 MacKeycode macKC;
500 char utfChars[8];
501 int length = 0;
502
503 macKC.uint = eventPtr->xkey.keycode;
504 if (IS_PRINTABLE(macKC.v.keychar)) {
505 length = TkUniCharToUtf(macKC.v.keychar, utfChars);
506 }
507 utfChars[length] = 0;
446508
447509 Tcl_DStringInit(dsPtr);
448 return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars,
449 TkUtfToUniChar(eventPtr->xkey.trans_chars, &ch));
510 return Tcl_DStringAppend(dsPtr, utfChars, length);
450511 }
451512
452513 /*
454515 *
455516 * XGetModifierMapping --
456517 *
457 * Fetch the current keycodes used as modifiers.
458 *
459 * Results:
460 * Returns a new modifier map.
518 * X11 stub function to get the keycodes used as modifiers. This
519 * is never called by the macOS port.
520 *
521 * Results:
522 * Returns a newly allocated modifier map.
461523 *
462524 * Side effects:
463525 * Allocates a new modifier map data structure.
467529
468530 XModifierKeymap *
469531 XGetModifierMapping(
470 Display *display)
532 TCL_UNUSED(Display *))
471533 {
472534 XModifierKeymap *modmap;
473535
474 (void) display; /*unused*/
475
476 /*
477 * MacOSX doesn't use the key codes for the modifiers for anything, and we
478 * don't generate them either. So there is no modifier map.
479 */
480 modmap = ckalloc(sizeof(XModifierKeymap));
536 modmap = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap));
481537 modmap->max_keypermod = 0;
482538 modmap->modifiermap = NULL;
483539 return modmap;
488544 *
489545 * XFreeModifiermap --
490546 *
491 * Deallocate a modifier map that was created by XGetModifierMapping.
547 * Deallocates a modifier map that was created by XGetModifierMapping.
548 * This is also never called by the macOS port.
492549 *
493550 * Results:
494551 * None.
515572 *
516573 * XKeysymToString, XStringToKeysym --
517574 *
518 * These X window functions map keysyms to strings & strings to keysyms.
519 * However, Tk already does this for the most common keysyms. Therefore,
520 * these functions only need to support keysyms that will be specific to
521 * the Macintosh. Currently, there are none.
575 * These X11 stub functions map keysyms to strings & strings to keysyms.
576 * A platform can do its own conversion by defining these and undefining
577 * REDO_KEYSYM_LOOKUP. The macOS port defines REDO_KEYSYM_LOOKUP so these
578 * are never called and Tk does the conversion for us.
522579 *
523580 * Results:
524581 * None.
531588
532589 char *
533590 XKeysymToString(
534 KeySym keysym)
591 TCL_UNUSED(KeySym))
535592 {
536593 return NULL;
537594 }
538595
539596 KeySym
540597 XStringToKeysym(
541 const char* string)
598 TCL_UNUSED(const char *))
542599 {
543600 return NoSymbol;
544601 }
546603 /*
547604 *----------------------------------------------------------------------
548605 *
549 * XKeysymToMacKeycode --
550 *
551 * An internal function like XKeysymToKeycode but only generating the Mac
552 * specific keycode plus the modifiers Shift and Option.
553 *
554 * Results:
555 * A Mac keycode with the actual keycode in the low byte and Mac-style
556 * modifier bits in the high byte.
557 *
558 * Side effects:
559 * None.
560 *
561 *----------------------------------------------------------------------
562 */
563
564 static int
565 XKeysymToMacKeycode(
566 Display *display,
567 KeySym keysym)
568 {
569 KeyInfo *kPtr;
570 if (keysym <= LATIN1_MAX) {
571 /*
572 * Handle keysyms in the Latin-1 range where keysym and Unicode
573 * character code point are the same.
574 */
575
576 if (keyboardChanged) {
577 InitLatin1Table(display);
578 keyboardChanged = 0;
579 }
580 return latin1Table[keysym];
581 }
582
583 /*
584 * Handle special keys from our exception tables. Don't mind if this is
585 * slow, neither the test suite nor [event generate] need to be optimized
586 * (we hope).
587 */
588
589 for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
590 if (kPtr->keysym == keysym) {
591 return kPtr->keycode;
592 }
593 }
594 for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
595 if (kPtr->keysym == keysym) {
596 return kPtr->keycode;
597 }
598 }
599
600 /*
601 * Modifier keycodes only come from generated events. No translation
602 * is needed.
603 */
604
605 for (int i=0; i < NUM_MOD_KEYCODES; i++) {
606 if (keysym == modKeyArray[i]) {
607 return keysym;
608 }
609 }
610
611 /*
612 * For other keysyms (not Latin-1 and not special keys), we'd need a
613 * generic keysym-to-unicode table. We don't have that, so we give up here.
614 */
615
616 return 0;
617 }
618
619 /*
620 *----------------------------------------------------------------------
621 *
622606 * XKeysymToKeycode --
623607 *
624 * The function XKeysymToKeycode takes an X11 keysym and converts it into
625 * a Mac keycode. It is in the stubs table for compatibility but not used
626 * anywhere in the core.
627 *
628 * Results:
629 * A 32 bit keycode with the the mac keycode (without modifiers) in the
630 * higher 16 bits of the keycode and the ASCII or Latin-1 code in the
631 * lower 8 bits of the keycode.
608 * This is a stub function which converts a numerical keysym to the
609 * platform-specific keycode used in a KeyPress or KeyRelease XEvent.
610 * For macOS the keycode is an unsigned int with bitfields described
611 * in the definition of the MacKeycode type.
612 *
613 * Results:
614 *
615 * A macOS KeyCode. See the description of keycodes at the top of this
616 * file and the definition of the MacKeycode type in tkMacOSXPrivate.h.
632617 *
633618 * Side effects:
634619 * None.
638623
639624 KeyCode
640625 XKeysymToKeycode(
641 Display* display,
626 TCL_UNUSED(Display *),
642627 KeySym keysym)
643628 {
644 int macKeycode = XKeysymToMacKeycode(display, keysym);
645 KeyCode result;
646
647 /*
648 * See also TkpSetKeycodeAndState. The 0x0010 magic is used in
649 * XKeycodeToKeysym. For special keys like XK_Return the lower 8 bits of
650 * the keysym are usually a related ASCII control code.
651 */
652
653 if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
654 result = 0x0010;
655 } else {
656 result = 0x00FF & keysym;
657 }
658 result |= (macKeycode & MAC_KEYCODE_MASK) << 16;
659
660 return result;
629 Tcl_HashEntry *hPtr;
630 MacKeycode macKC;
631 if (!initialized) {
632 InitHashTables();
633 }
634
635 /*
636 * First check for a special key.
637 */
638
639 hPtr = Tcl_FindHashEntry(&keysym2keycode, INT2PTR(keysym));
640 if (hPtr != NULL) {
641 return (KeyCode) Tcl_GetHashValue(hPtr);
642 }
643
644 /*
645 * Initialize the keycode as if the keysym cannot be converted to anything
646 * else.
647 */
648
649 macKC.v.virtual = NO_VIRTUAL;
650 macKC.v.o_s = 0;
651 macKC.v.keychar = 0;
652
653 /*
654 * If the keysym is recognized fill in the keychar. Also fill in the
655 * xvirtual field if the key exists on the current keyboard.
656 */
657
658 hPtr = (Tcl_HashEntry *) Tcl_FindHashEntry(&keysym2unichar,
659 INT2PTR(keysym));
660 if (hPtr != NULL) {
661 unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
662 macKC.x.keychar = (unsigned int) data;
663 hPtr = Tcl_FindHashEntry(&unichar2xvirtual, INT2PTR(macKC.x.keychar));
664 if (hPtr != NULL) {
665 data = (unsigned long) Tcl_GetHashValue(hPtr);
666 macKC.x.xvirtual = (unsigned int) data;
667 }
668 }
669 return (KeyCode) macKC.uint;
661670 }
662671
663672 /*
665674 *
666675 * TkpSetKeycodeAndState --
667676 *
668 * The function TkpSetKeycodeAndState takes a keysym and fills in the
669 * appropriate members of an XEvent. It is similar to XKeysymToKeycode,
670 * but it also sets the modifier mask in the XEvent. It is used by [event
671 * generate] and it is in the stubs table.
672 *
673 * Results:
674 * Fills an XEvent, sets the member xkey.keycode with a keycode
675 * formatted the same as XKeysymToKeycode and the member xkey.state with
676 * the modifiers implied by the keysym. Also fills in xkey.trans_chars,
677 * so that the actual characters can be retrieved later.
678 *
679 * Side effects:
680 * None.
681 *
682 *----------------------------------------------------------------------
683 */
684
677 * This function accepts a keysym and an XEvent and sets some fields of
678 * the XEvent. It is used by the event generate command.
679 *
680 * Results:
681 * None
682 *
683 * Side effects:
684 *
685 * Modifies the XEvent. Sets the xkey.keycode to a keycode value formatted
686 * by XKeysymToKeycode and updates the shift and option flags in
687 * xkey.state if either of those modifiers is required to generate the
688 * keysym.
689 *
690 *----------------------------------------------------------------------
691 */
685692 void
686693 TkpSetKeycodeAndState(
687 Tk_Window tkwin,
694 TCL_UNUSED(Tk_Window),
688695 KeySym keysym,
689696 XEvent *eventPtr)
690697 {
691698 if (keysym == NoSymbol) {
692699 eventPtr->xkey.keycode = 0;
693 } else if ( modKeyArray[0] <= keysym &&
694 keysym <= modKeyArray[NUM_MOD_KEYCODES - 1]) {
700 } else {
701 int eventIndex = STATE2INDEX(eventPtr->xkey.state);
702 MacKeycode macKC;
703 macKC.uint = XKeysymToKeycode(NULL, keysym);
704
695705 /*
696 * Keysyms for pure modifiers only arise in generated events.
697 * We should just copy them to the keycode.
706 * We have a virtual keycode and a minimal choice for Shift and Option
707 * modifiers which generates the keychar that corresponds to the
708 * specified keysym. But we might not have the correct keychar yet,
709 * because the xEvent may have specified modifiers beyond our minimal
710 * set. For example, the events described by <Oslash>, <Shift-oslash>,
711 * <Shift-Option-O> and <Shift-Option-o> should all produce the same
712 * uppercase Danish O. So we may need to add the extra modifiers and
713 * do another lookup for the keychar. We don't want to do this for
714 * special keys, however.
698715 */
699 eventPtr->xkey.keycode = keysym;
700 } else {
701 Display *display = Tk_Display(tkwin);
702 int macKeycode = XKeysymToMacKeycode(display, keysym);
703
704 /*
705 * See also XKeysymToKeycode.
706 */
707 if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
708 eventPtr->xkey.keycode = 0x0010;
709 } else {
710 eventPtr->xkey.keycode = 0x00FF & keysym;
711 }
712 eventPtr->xkey.keycode |= (macKeycode & MAC_KEYCODE_MASK) << 16;
713
714 if (shiftKey & macKeycode) {
715 eventPtr->xkey.state |= ShiftMask;
716 }
717 if (optionKey & macKeycode) {
718 eventPtr->xkey.state |= OPTION_MASK;
719 }
720
721 if (keysym <= LATIN1_MAX) {
722 int done = TkUniCharToUtf(keysym, eventPtr->xkey.trans_chars);
723
724 eventPtr->xkey.trans_chars[done] = 0;
725 } else {
726 eventPtr->xkey.trans_chars[0] = 0;
727 }
716
717 if (macKC.v.o_s != eventIndex) {
718 macKC.v.o_s |= eventIndex;
719 }
720 if (macKC.v.keychar < 0xF700) {
721 UniChar keychar = macKC.v.keychar;
722 NSString *str, *lower, *upper;
723 if (macKC.v.virtual != NO_VIRTUAL) {
724 macKC.x.keychar = xvirtual2unichar[macKC.x.xvirtual];
725 } else {
726 str = [[NSString alloc] initWithCharacters:&keychar length:1];
727 lower = [str lowercaseString];
728 upper = [str uppercaseString];
729 if (![str isEqual: lower]) {
730 macKC.v.o_s |= INDEX_SHIFT;
731 }
732 if (macKC.v.o_s & INDEX_SHIFT) {
733 macKC.v.keychar = [upper characterAtIndex:0];
734 }
735 }
736 }
737 eventPtr->xkey.keycode = macKC.uint;
738 eventPtr->xkey.state |= INDEX2STATE(macKC.v.o_s);
728739 }
729740 }
730741
733744 *
734745 * TkpGetKeySym --
735746 *
736 * Given an X KeyPress or KeyRelease event, map the keycode in the event
737 * into a keysym.
747 * This is a stub function called in tkBind.c. Given a KeyPress or
748 * KeyRelease XEvent, it maps the keycode in the event to a numerical
749 * keysym.
738750 *
739751 * Results:
740752 * The return value is the keysym corresponding to eventPtr, or NoSymbol
741753 * if no matching keysym could be found.
742754 *
743755 * Side effects:
744 * In the first call for a given display, keycode-to-keysym maps get
745 * loaded.
756 * In the first call for a given display, calls TkpInitKeymapInfo.
757 *
746758 *
747759 *----------------------------------------------------------------------
748760 */
754766 {
755767 KeySym sym;
756768 int index;
769 MacKeycode macKC;
770 macKC.uint = eventPtr->xkey.keycode;
757771
758772 /*
759773 * Refresh the mapping information if it's stale.
764778 }
765779
766780 /*
767 * Handle pure modifier keys specially. We use -1 as a signal for
768 * this.
769 */
770
771 if (eventPtr->xany.send_event == -1) {
772 int modifier = eventPtr->xkey.keycode & NSDeviceIndependentModifierFlagsMask;
773
774 if (modifier == NSCommandKeyMask) {
781 * Modifier key events have a special mac keycode (see tkProcessKeyEvent).
782 */
783
784 if (macKC.v.keychar == MOD_KEYCHAR) {
785 switch (macKC.v.virtual) {
786 case 54:
787 return XK_Meta_R;
788 case 55:
775789 return XK_Meta_L;
776 } else if (modifier == NSShiftKeyMask) {
790 case 56:
777791 return XK_Shift_L;
778 } else if (modifier == NSAlphaShiftKeyMask) {
792 case 57:
779793 return XK_Caps_Lock;
780 } else if (modifier == NSAlternateKeyMask) {
794 case 58:
781795 return XK_Alt_L;
782 } else if (modifier == NSControlKeyMask) {
796 case 59:
783797 return XK_Control_L;
784 } else if (modifier == NSNumericPadKeyMask) {
785 return XK_Num_Lock;
786 } else if (modifier == NSFunctionKeyMask) {
798 case 60:
799 return XK_Shift_R;
800 case 61:
801 return XK_Alt_R;
802 case 62:
803 return XK_Control_R;
804 case 63:
787805 return XK_Super_L;
788 /*
789 } else if (modifier == rightShiftKey) {
790 return XK_Shift_R;
791 } else if (modifier == rightOptionKey) {
792 return XK_Alt_R;
793 } else if (modifier == rightControlKey) {
794 return XK_Control_R;
795 */
796 } else {
797 /*
798 * If we get here, we probably need to implement something new.
799 */
800
806 default:
801807 return NoSymbol;
802808 }
803 }
804
805 /* If nbytes has been set, it's not a function key, but a regular key that
806 has been translated in tkMacOSXKeyEvent.c; just use that. */
807 if (eventPtr->xkey.nbytes) {
808 return eventPtr->xkey.keycode;
809809 }
810810
811811 /*
812812 * Figure out which of the four slots in the keymap vector to use for this
813813 * key. Refer to Xlib documentation for more info on how this computation
814 * works. (Note: We use "Option" in keymap columns 2 and 3 where other
815 * implementations have "Mode_switch".)
816 */
817
818 index = 0;
819
820 /*
821 * We want Option key combinations to use their base chars as keysyms, so
822 * we ignore the option modifier here.
823 */
824
825 #if 0
826 if (eventPtr->xkey.state & OPTION_MASK) {
827 index |= 2;
828 }
829 #endif
830
831 if ((eventPtr->xkey.state & ShiftMask)
832 || (/* (dispPtr->lockUsage != LU_IGNORE)
833 && */ (eventPtr->xkey.state & LockMask))) {
834 index |= 1;
835 }
836
837 /*
838 * First try of the actual translation.
839 */
840
841 sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
842
843 /*
844 * Special handling: If the key was shifted because of Lock, but lock is
845 * only caps lock, not shift lock, and the shifted keysym isn't upper-case
846 * alphabetic, then switch back to the unshifted keysym.
847 */
848
849 if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
850 /*&& (dispPtr->lockUsage == LU_CAPS)*/ ) {
851 /*
852 * FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1,
853 * so we can't use Tcl_UniCharIsUpper() for keysyms outside that range.
854 * This may be a serious problem here.
855 */
856
857 if ((sym == NoSymbol) || (sym > LATIN1_MAX)
858 || !Tcl_UniCharIsUpper(sym)) {
859 index &= ~1;
860 sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
861 index);
814 * works.
815 */
816
817 index = STATE2INDEX(eventPtr->xkey.state);
818 if (eventPtr->xkey.state & LockMask) {
819 index |= INDEX_SHIFT;
820 }
821
822 /*
823 * First do the straightforward lookup.
824 */
825
826 sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0, index);
827
828 /*
829 * Special handling: If the key was shifted because of Lock, which is only
830 * caps lock on macOS, not shift lock, and if the shifted keysym isn't
831 * upper-case alphabetic, then switch back to the unshifted keysym.
832 */
833
834 if ((index & INDEX_SHIFT) && !(eventPtr->xkey.state & ShiftMask)) {
835 if ((sym == NoSymbol) || !Tcl_UniCharIsUpper(sym)) {
836 sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0,
837 index & ~INDEX_SHIFT);
862838 }
863839 }
864840
867843 * no keysym defined, then use the keysym for the unshifted key.
868844 */
869845
870 if ((index & 1) && (sym == NoSymbol)) {
871 sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
872 index & ~1);
846 if ((index & INDEX_SHIFT) && (sym == NoSymbol)) {
847 sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0,
848 index & ~INDEX_SHIFT);
873849 }
874850 return sym;
875851 }
879855 *
880856 * TkpInitKeymapInfo --
881857 *
882 * This procedure is invoked to scan keymap information to recompute stuff
883 * that's important for binding, such as the modifier key (if any) that
884 * corresponds to the "Mode_switch" keysym.
858 * This procedure initializes fields in the display that pertain
859 * to modifier keys.
885860 *
886861 * Results:
887862 * None.
888863 *
889864 * Side effects:
890 * Keymap-related information in dispPtr is updated.
865 * Modifier key information in dispPtr is initialized.
891866 *
892867 *--------------------------------------------------------------
893868 */
900875 dispPtr->bindInfoStale = 0;
901876
902877 /*
903 * Behaviours that are variable on X11 are defined constant on MacOSX.
904 * lockUsage is only used above in TkpGetKeySym(), nowhere else currently.
878 * On macOS the caps lock key is always interpreted to mean that alphabetic
879 * keys become uppercase but other keys do not get shifted. (X11 allows
880 * a configuration option which makes the caps lock equivalent to holding
881 * down the shift key.)
905882 * There is no offical "Mode_switch" key.
906883 */
907884
908885 dispPtr->lockUsage = LU_CAPS;
886
887 /* This field is no longer used by tkBind.c */
888
909889 dispPtr->modeModMask = 0;
910890
911 #if 0
912 /*
913 * With this, <Alt> and <Meta> become synonyms for <Command> and <Option>
914 * in bindings like they are (and always have been) in the keysyms that
915 * are reported by KeyPress events. But the init scripts like text.tcl
916 * have some disabling bindings for <Meta>, so we don't want this without
917 * some changes in those scripts. See also bug #700311.
918 */
919
920 dispPtr->altModMask = OPTION_MASK;
921 dispPtr->metaModMask = COMMAND_MASK;
922 #else
891 /* The Alt and Meta keys are interchanged on Macintosh keyboards compared
892 * to PC keyboards. These fields could be set to make the Alt key on a PC
893 * keyboard behave likd an Alt key. That would also require interchanging
894 * Mod1Mask and Mod2Mask in tkMacOSXKeyEvent.c.
895 */
896
923897 dispPtr->altModMask = 0;
924898 dispPtr->metaModMask = 0;
925 #endif
926
927 /*
928 * MacOSX doesn't create a key event when a modifier key is pressed or
929 * released. However, it is possible to generate key events for
930 * modifier keys, and this is done in the tests. So we construct an array
931 * containing the keycodes of the standard modifier keys from static data.
899
900 /*
901 * The modKeyCodes table lists the keycodes that appear in KeyPress or
902 * KeyRelease XEvents for modifier keys. In tkBind.c this table is
903 * searched to determine whether an XEvent corresponds to a modifier key.
932904 */
933905
934906 if (dispPtr->modKeyCodes != NULL) {
937909 dispPtr->numModKeyCodes = NUM_MOD_KEYCODES;
938910 dispPtr->modKeyCodes = (KeyCode *)ckalloc(NUM_MOD_KEYCODES * sizeof(KeyCode));
939911 for (int i = 0; i < NUM_MOD_KEYCODES; i++) {
940 dispPtr->modKeyCodes[i] = modKeyArray[i];
941 }
942 }
943
912 dispPtr->modKeyCodes[i] = XKeysymToKeycode(NULL, modKeyArray[i]);
913 }
914 }
915
916 /*
917 *--------------------------------------------------------------
918 *
919 * TkMacOSXAddVirtual --
920 *
921 * This procedure is an internal utility which accepts an unsigned int
922 * that has been partially filled as a MacKeycode, having the Option and
923 * Shift state set in the o_s field and the keychar field set but with the
924 * virtual keycode blank. It looks up the virtual keycode for the keychar
925 * (possibly NO_VIRTUAL) and returns an unsigned int which is a complete
926 * MacKeycode with the looked up virtual keycode added. This is used when
927 * creating XEvents for the unicode characters which are generated by the
928 * NSTextInputClient.
929 *
930 * Results:
931 * An unsigned int which is a complete MacKeycode, including a virtual
932 * keycode which matches the Option-Shift state and keychar.
933 *
934 * Side effects:
935 * None
936 *
937 *--------------------------------------------------------------
938 */
939 unsigned
940 TkMacOSXAddVirtual(
941 unsigned int keycode)
942 {
943 MacKeycode macKC;
944 Tcl_HashEntry *hPtr;
945 macKC.uint = keycode;
946
947 if (!initialized) {
948 InitHashTables();
949 }
950
951 hPtr = (Tcl_HashEntry *) Tcl_FindHashEntry(&unichar2xvirtual,
952 INT2PTR(macKC.v.keychar));
953 if (hPtr != NULL) {
954 unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
955 macKC.x.xvirtual = (unsigned int) data;
956 } else {
957 macKC.v.virtual = NO_VIRTUAL;
958 }
959 return macKC.uint;
960 }
944961 /*
945962 * Local Variables:
946963 * mode: objc
0 /*
1 * tkMacOSXKeysyms.h --
2 *
3 * Contains data used for processing key events, some of which was
4 * moved from tkMacOSXKeyboard.c.
5 *
6 * Copyright (c) 1990-1994 The Regents of the University of California.
7 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
8 * Copyright 2001-2009, Apple Inc.
9 * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
10 * Copyright (c) 2020 Marc Culler
11 *
12 * See the file "license.terms" for information on usage and redistribution
13 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 */
15
16 #ifndef TKMACOSXKEYSYMS_H
17 #define TKMACOSXKEYSYMS_H 1
18
19 /*
20 * This table enumerates the keys on Mac keyboards which do not represent
21 * letters. This is static data -- these keys do not change when the keyboard
22 * layout changes. The unicode representation of a special key which is not a
23 * modifier and does not have an ASCII code point lies in the reserved range
24 * 0xF700 - 0xF8FF.
25 *
26 * The table includes every key listed in Apple's documentation of Function-Key
27 * Unicodes which is not marked as "Not on most Macintosh keyboards", as well
28 * as F20, which is reported to be usable in scripts even though it does not
29 * appear on any Macintosh keyboard.
30 */
31
32 typedef struct {
33 int virtual; /* value of [NSEvent keyCode] */
34 KeySym keysym; /* X11 keysym */
35 KeyCode keychar; /* XEvent keycode & 0xFFFF */
36 } KeyInfo;
37
38 static const KeyInfo keyArray[] = {
39 {36, XK_Return, NSNewlineCharacter},
40 {48, XK_Tab, NSTabCharacter},
41 {51, XK_BackSpace, NSDeleteCharacter},
42 {52, XK_Return, NSNewlineCharacter}, /* Used on some Powerbooks */
43 {53, XK_Escape, 0x1B},
44 {54, XK_Meta_R, MOD_KEYCHAR},
45 {55, XK_Meta_L, MOD_KEYCHAR},
46 {56, XK_Shift_L, MOD_KEYCHAR},
47 {57, XK_Caps_Lock, MOD_KEYCHAR},
48 {58, XK_Alt_L, MOD_KEYCHAR},
49 {59, XK_Control_L, MOD_KEYCHAR},
50 {60, XK_Shift_R, MOD_KEYCHAR},
51 {61, XK_Alt_R, MOD_KEYCHAR},
52 {62, XK_Control_R, MOD_KEYCHAR},
53 {63, XK_Super_L, MOD_KEYCHAR},
54 {64, XK_F17, NSF17FunctionKey},
55 {65, XK_KP_Decimal, '.'},
56 {67, XK_KP_Multiply, '*'},
57 {69, XK_KP_Add, '+'},
58 {71, XK_Clear, NSClearLineFunctionKey}, /* Numlock on PC */
59 {75, XK_KP_Divide, '/'},
60 {76, XK_KP_Enter, NSEnterCharacter}, /* Fn Return */
61 {78, XK_KP_Subtract, '-'},
62 {79, XK_F18, NSF18FunctionKey},
63 {80, XK_F19, NSF19FunctionKey},
64 {81, XK_KP_Equal, '='},
65 {82, XK_KP_0, '0'},
66 {83, XK_KP_1, '1'},
67 {84, XK_KP_2, '2'},
68 {85, XK_KP_3, '3'},
69 {86, XK_KP_4, '4'},
70 {87, XK_KP_5, '5'},
71 {88, XK_KP_6, '6'},
72 {89, XK_KP_7, '7'},
73 {90, XK_F20, NSF20FunctionKey}, /* For scripting only */
74 {91, XK_KP_8, '8'},
75 {92, XK_KP_9, '9'},
76 {96, XK_F5, NSF5FunctionKey},
77 {97, XK_F6, NSF6FunctionKey},
78 {98, XK_F7, NSF7FunctionKey},
79 {99, XK_F3, NSF3FunctionKey},
80 {100, XK_F8, NSF8FunctionKey},
81 {101, XK_F9, NSF9FunctionKey},
82 {103, XK_F11, NSF11FunctionKey},
83 {105, XK_F13, NSF13FunctionKey},
84 {106, XK_F16, NSF16FunctionKey},
85 {107, XK_F14, NSF14FunctionKey},
86 {109, XK_F10, NSF10FunctionKey},
87 {110, XK_Menu, UNKNOWN_KEYCHAR},
88 {111, XK_F12, NSF12FunctionKey},
89 {113, XK_F15, NSF15FunctionKey},
90 {114, XK_Help, NSHelpFunctionKey},
91 {115, XK_Home, NSHomeFunctionKey}, /* Fn Left */
92 {116, XK_Page_Up, NSPageUpFunctionKey}, /* Fn Up */
93 {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Delete */
94 {118, XK_F4, NSF4FunctionKey},
95 {119, XK_End, NSEndFunctionKey}, /* Fn Right */
96 {120, XK_F2, NSF2FunctionKey},
97 {121, XK_Page_Down, NSPageDownFunctionKey}, /* Fn Down */
98 {122, XK_F1, NSF1FunctionKey},
99 {123, XK_Left, NSLeftArrowFunctionKey},
100 {124, XK_Right, NSRightArrowFunctionKey},
101 {125, XK_Down, NSDownArrowFunctionKey},
102 {126, XK_Up, NSUpArrowFunctionKey},
103 {0, 0, 0}
104 };
105
106 /*
107 * X11 keysyms for modifier keys, in order. This list includes keys
108 * which do not appear on Apple keyboards, such as Shift_Lock and
109 * Super_R. While most systems don't provide events for the "fn"
110 * function key, Apple does. We map it to Super_L when processing a
111 * FlagsChanged NSEvent.
112 */
113
114 #define NUM_MOD_KEYCODES 14
115 static const KeyCode modKeyArray[NUM_MOD_KEYCODES] = {
116 XK_Shift_L,
117 XK_Shift_R,
118 XK_Control_L,
119 XK_Control_R,
120 XK_Caps_Lock,
121 XK_Shift_Lock,
122 XK_Meta_L,
123 XK_Meta_R,
124 XK_Alt_L,
125 XK_Alt_R,
126 XK_Super_L,
127 XK_Super_R,
128 XK_Hyper_L,
129 XK_Hyper_R,
130 };
131
132 /*
133 * This table pairs X11 Keysyms for alphanumeric characters with the
134 * unicode code point for that letter.
135 * The data comes from http://www.cl.cam.ac.uk/~mgk25/ucs/keysyms.txt
136 */
137
138 typedef struct KeysymInfo {
139 KeySym keysym;
140 KeyCode keycode;
141 } KeysymInfo;
142
143 const KeysymInfo keysymTable[] = {
144 {0x0020, 0x0020}, /* space */
145 {0x0021, 0x0021}, /* exclam */
146 {0x0022, 0x0022}, /* quotedbl */
147 {0x0023, 0x0023}, /* numbersign */
148 {0x0024, 0x0024}, /* dollar */
149 {0x0025, 0x0025}, /* percent */
150 {0x0026, 0x0026}, /* ampersand */
151 {0x0027, 0x0027}, /* apostrophe */
152 {0x0028, 0x0028}, /* parenleft */
153 {0x0029, 0x0029}, /* parenright */
154 {0x002a, 0x002a}, /* asterisk */
155 {0x002b, 0x002b}, /* plus */
156 {0x002c, 0x002c}, /* comma */
157 {0x002d, 0x002d}, /* minus */
158 {0x002e, 0x002e}, /* period */
159 {0x002f, 0x002f}, /* slash */
160 {0x0030, 0x0030}, /* 0 */
161 {0x0031, 0x0031}, /* 1 */
162 {0x0032, 0x0032}, /* 2 */
163 {0x0033, 0x0033}, /* 3 */
164 {0x0034, 0x0034}, /* 4 */
165 {0x0035, 0x0035}, /* 5 */
166 {0x0036, 0x0036}, /* 6 */
167 {0x0037, 0x0037}, /* 7 */
168 {0x0038, 0x0038}, /* 8 */
169 {0x0039, 0x0039}, /* 9 */
170 {0x003a, 0x003a}, /* colon */
171 {0x003b, 0x003b}, /* semicolon */
172 {0x003c, 0x003c}, /* less */
173 {0x003d, 0x003d}, /* equal */
174 {0x003e, 0x003e}, /* greater */
175 {0x003f, 0x003f}, /* question */
176 {0x0040, 0x0040}, /* at */
177 {0x0041, 0x0041}, /* A */
178 {0x0042, 0x0042}, /* B */
179 {0x0043, 0x0043}, /* C */
180 {0x0044, 0x0044}, /* D */
181 {0x0045, 0x0045}, /* E */
182 {0x0046, 0x0046}, /* F */
183 {0x0047, 0x0047}, /* G */
184 {0x0048, 0x0048}, /* H */
185 {0x0049, 0x0049}, /* I */
186 {0x004a, 0x004a}, /* J */
187 {0x004b, 0x004b}, /* K */
188 {0x004c, 0x004c}, /* L */
189 {0x004d, 0x004d}, /* M */
190 {0x004e, 0x004e}, /* N */
191 {0x004f, 0x004f}, /* O */
192 {0x0050, 0x0050}, /* P */
193 {0x0051, 0x0051}, /* Q */
194 {0x0052, 0x0052}, /* R */
195 {0x0053, 0x0053}, /* S */
196 {0x0054, 0x0054}, /* T */
197 {0x0055, 0x0055}, /* U */
198 {0x0056, 0x0056}, /* V */
199 {0x0057, 0x0057}, /* W */
200 {0x0058, 0x0058}, /* X */
201 {0x0059, 0x0059}, /* Y */
202 {0x005a, 0x005a}, /* Z */
203 {0x005b, 0x005b}, /* bracketleft */
204 {0x005c, 0x005c}, /* backslash */
205 {0x005d, 0x005d}, /* bracketright */
206 {0x005e, 0x005e}, /* asciicircum */
207 {0x005f, 0x005f}, /* underscore */
208 {0x0060, 0x0060}, /* grave */
209 {0x0061, 0x0061}, /* a */
210 {0x0062, 0x0062}, /* b */
211 {0x0063, 0x0063}, /* c */
212 {0x0064, 0x0064}, /* d */
213 {0x0065, 0x0065}, /* e */
214 {0x0066, 0x0066}, /* f */
215 {0x0067, 0x0067}, /* g */
216 {0x0068, 0x0068}, /* h */
217 {0x0069, 0x0069}, /* i */
218 {0x006a, 0x006a}, /* j */
219 {0x006b, 0x006b}, /* k */
220 {0x006c, 0x006c}, /* l */
221 {0x006d, 0x006d}, /* m */
222 {0x006e, 0x006e}, /* n */
223 {0x006f, 0x006f}, /* o */
224 {0x0070, 0x0070}, /* p */
225 {0x0071, 0x0071}, /* q */
226 {0x0072, 0x0072}, /* r */
227 {0x0073, 0x0073}, /* s */
228 {0x0074, 0x0074}, /* t */
229 {0x0075, 0x0075}, /* u */
230 {0x0076, 0x0076}, /* v */
231 {0x0077, 0x0077}, /* w */
232 {0x0078, 0x0078}, /* x */
233 {0x0079, 0x0079}, /* y */
234 {0x007a, 0x007a}, /* z */
235 {0x007b, 0x007b}, /* braceleft */
236 {0x007c, 0x007c}, /* bar */
237 {0x007d, 0x007d}, /* braceright */
238 {0x007e, 0x007e}, /* asciitilde */
239 {0x00a0, 0x00a0}, /* nobreakspace */
240 {0x00a1, 0x00a1}, /* exclamdown */
241 {0x00a2, 0x00a2}, /* cent */
242 {0x00a3, 0x00a3}, /* sterling */
243 {0x00a4, 0x00a4}, /* currency */
244 {0x00a5, 0x00a5}, /* yen */
245 {0x00a6, 0x00a6}, /* brokenbar */
246 {0x00a7, 0x00a7}, /* section */
247 {0x00a8, 0x00a8}, /* diaeresis */
248 {0x00a9, 0x00a9}, /* copyright */
249 {0x00aa, 0x00aa}, /* ordfeminine */
250 {0x00ab, 0x00ab}, /* guillemotleft */
251 {0x00ac, 0x00ac}, /* notsign */
252 {0x00ad, 0x00ad}, /* hyphen */
253 {0x00ae, 0x00ae}, /* registered */
254 {0x00af, 0x00af}, /* macron */
255 {0x00b0, 0x00b0}, /* degree */
256 {0x00b1, 0x00b1}, /* plusminus */
257 {0x00b2, 0x00b2}, /* twosuperior */
258 {0x00b3, 0x00b3}, /* threesuperior */
259 {0x00b4, 0x00b4}, /* acute */
260 {0x00b5, 0x00b5}, /* mu */
261 {0x00b6, 0x00b6}, /* paragraph */
262 {0x00b7, 0x00b7}, /* periodcentered */
263 {0x00b8, 0x00b8}, /* cedilla */
264 {0x00b9, 0x00b9}, /* onesuperior */
265 {0x00ba, 0x00ba}, /* masculine */
266 {0x00bb, 0x00bb}, /* guillemotright */
267 {0x00bc, 0x00bc}, /* onequarter */
268 {0x00bd, 0x00bd}, /* onehalf */
269 {0x00be, 0x00be}, /* threequarters */
270 {0x00bf, 0x00bf}, /* questiondown */
271 {0x00c0, 0x00c0}, /* Agrave */
272 {0x00c1, 0x00c1}, /* Aacute */
273 {0x00c2, 0x00c2}, /* Acircumflex */
274 {0x00c3, 0x00c3}, /* Atilde */
275 {0x00c4, 0x00c4}, /* Adiaeresis */
276 {0x00c5, 0x00c5}, /* Aring */
277 {0x00c6, 0x00c6}, /* AE */
278 {0x00c7, 0x00c7}, /* Ccedilla */
279 {0x00c8, 0x00c8}, /* Egrave */
280 {0x00c9, 0x00c9}, /* Eacute */
281 {0x00ca, 0x00ca}, /* Ecircumflex */
282 {0x00cb, 0x00cb}, /* Ediaeresis */
283 {0x00cc, 0x00cc}, /* Igrave */
284 {0x00cd, 0x00cd}, /* Iacute */
285 {0x00ce, 0x00ce}, /* Icircumflex */
286 {0x00cf, 0x00cf}, /* Idiaeresis */
287 {0x00d0, 0x00d0}, /* ETH */
288 {0x00d1, 0x00d1}, /* Ntilde */
289 {0x00d2, 0x00d2}, /* Ograve */
290 {0x00d3, 0x00d3}, /* Oacute */
291 {0x00d4, 0x00d4}, /* Ocircumflex */
292 {0x00d5, 0x00d5}, /* Otilde */
293 {0x00d6, 0x00d6}, /* Odiaeresis */
294 {0x00d7, 0x00d7}, /* multiply */
295 {0x00d8, 0x00d8}, /* Oslash */
296 {0x00d9, 0x00d9}, /* Ugrave */
297 {0x00da, 0x00da}, /* Uacute */
298 {0x00db, 0x00db}, /* Ucircumflex */
299 {0x00dc, 0x00dc}, /* Udiaeresis */
300 {0x00dd, 0x00dd}, /* Yacute */
301 {0x00de, 0x00de}, /* THORN */
302 {0x00df, 0x00df}, /* ssharp */
303 {0x00e0, 0x00e0}, /* agrave */
304 {0x00e1, 0x00e1}, /* aacute */
305 {0x00e2, 0x00e2}, /* acircumflex */
306 {0x00e3, 0x00e3}, /* atilde */
307 {0x00e4, 0x00e4}, /* adiaeresis */
308 {0x00e5, 0x00e5}, /* aring */
309 {0x00e6, 0x00e6}, /* ae */
310 {0x00e7, 0x00e7}, /* ccedilla */
311 {0x00e8, 0x00e8}, /* egrave */
312 {0x00e9, 0x00e9}, /* eacute */
313 {0x00ea, 0x00ea}, /* ecircumflex */
314 {0x00eb, 0x00eb}, /* ediaeresis */
315 {0x00ec, 0x00ec}, /* igrave */
316 {0x00ed, 0x00ed}, /* iacute */
317 {0x00ee, 0x00ee}, /* icircumflex */
318 {0x00ef, 0x00ef}, /* idiaeresis */
319 {0x00f0, 0x00f0}, /* eth */
320 {0x00f1, 0x00f1}, /* ntilde */
321 {0x00f2, 0x00f2}, /* ograve */
322 {0x00f3, 0x00f3}, /* oacute */
323 {0x00f4, 0x00f4}, /* ocircumflex */
324 {0x00f5, 0x00f5}, /* otilde */
325 {0x00f6, 0x00f6}, /* odiaeresis */
326 {0x00f7, 0x00f7}, /* division */
327 {0x00f8, 0x00f8}, /* oslash */
328 {0x00f9, 0x00f9}, /* ugrave */
329 {0x00fa, 0x00fa}, /* uacute */
330 {0x00fb, 0x00fb}, /* ucircumflex */
331 {0x00fc, 0x00fc}, /* udiaeresis */
332 {0x00fd, 0x00fd}, /* yacute */
333 {0x00fe, 0x00fe}, /* thorn */
334 {0x00ff, 0x00ff}, /* ydiaeresis */
335 {0x01a1, 0x0104}, /* Aogonek */
336 {0x01a2, 0x02d8}, /* breve */
337 {0x01a3, 0x0141}, /* Lstroke */
338 {0x01a5, 0x013d}, /* Lcaron */
339 {0x01a6, 0x015a}, /* Sacute */
340 {0x01a9, 0x0160}, /* Scaron */
341 {0x01aa, 0x015e}, /* Scedilla */
342 {0x01ab, 0x0164}, /* Tcaron */
343 {0x01ac, 0x0179}, /* Zacute */
344 {0x01ae, 0x017d}, /* Zcaron */
345 {0x01af, 0x017b}, /* Zabovedot */
346 {0x01b1, 0x0105}, /* aogonek */
347 {0x01b2, 0x02db}, /* ogonek */
348 {0x01b3, 0x0142}, /* lstroke */
349 {0x01b5, 0x013e}, /* lcaron */
350 {0x01b6, 0x015b}, /* sacute */
351 {0x01b7, 0x02c7}, /* caron */
352 {0x01b9, 0x0161}, /* scaron */
353 {0x01ba, 0x015f}, /* scedilla */
354 {0x01bb, 0x0165}, /* tcaron */
355 {0x01bc, 0x017a}, /* zacute */
356 {0x01bd, 0x02dd}, /* doubleacute */
357 {0x01be, 0x017e}, /* zcaron */
358 {0x01bf, 0x017c}, /* zabovedot */
359 {0x01c0, 0x0154}, /* Racute */
360 {0x01c3, 0x0102}, /* Abreve */
361 {0x01c5, 0x0139}, /* Lacute */
362 {0x01c6, 0x0106}, /* Cacute */
363 {0x01c8, 0x010c}, /* Ccaron */
364 {0x01ca, 0x0118}, /* Eogonek */
365 {0x01cc, 0x011a}, /* Ecaron */
366 {0x01cf, 0x010e}, /* Dcaron */
367 {0x01d0, 0x0110}, /* Dstroke */
368 {0x01d1, 0x0143}, /* Nacute */
369 {0x01d2, 0x0147}, /* Ncaron */
370 {0x01d5, 0x0150}, /* Odoubleacute */
371 {0x01d8, 0x0158}, /* Rcaron */
372 {0x01d9, 0x016e}, /* Uring */
373 {0x01db, 0x0170}, /* Udoubleacute */
374 {0x01de, 0x0162}, /* Tcedilla */
375 {0x01e0, 0x0155}, /* racute */
376 {0x01e3, 0x0103}, /* abreve */
377 {0x01e5, 0x013a}, /* lacute */
378 {0x01e6, 0x0107}, /* cacute */
379 {0x01e8, 0x010d}, /* ccaron */
380 {0x01ea, 0x0119}, /* eogonek */
381 {0x01ec, 0x011b}, /* ecaron */
382 {0x01ef, 0x010f}, /* dcaron */
383 {0x01f0, 0x0111}, /* dstroke */
384 {0x01f1, 0x0144}, /* nacute */
385 {0x01f2, 0x0148}, /* ncaron */
386 {0x01f5, 0x0151}, /* odoubleacute */
387 {0x01f8, 0x0159}, /* rcaron */
388 {0x01f9, 0x016f}, /* uring */
389 {0x01fb, 0x0171}, /* udoubleacute */
390 {0x01fe, 0x0163}, /* tcedilla */
391 {0x01ff, 0x02d9}, /* abovedot */
392 {0x02a1, 0x0126}, /* Hstroke */
393 {0x02a6, 0x0124}, /* Hcircumflex */
394 {0x02a9, 0x0130}, /* Iabovedot */
395 {0x02ab, 0x011e}, /* Gbreve */
396 {0x02ac, 0x0134}, /* Jcircumflex */
397 {0x02b1, 0x0127}, /* hstroke */
398 {0x02b6, 0x0125}, /* hcircumflex */
399 {0x02b9, 0x0131}, /* idotless */
400 {0x02bb, 0x011f}, /* gbreve */
401 {0x02bc, 0x0135}, /* jcircumflex */
402 {0x02c5, 0x010a}, /* Cabovedot */
403 {0x02c6, 0x0108}, /* Ccircumflex */
404 {0x02d5, 0x0120}, /* Gabovedot */
405 {0x02d8, 0x011c}, /* Gcircumflex */
406 {0x02dd, 0x016c}, /* Ubreve */
407 {0x02de, 0x015c}, /* Scircumflex */
408 {0x02e5, 0x010b}, /* cabovedot */
409 {0x02e6, 0x0109}, /* ccircumflex */
410 {0x02f5, 0x0121}, /* gabovedot */
411 {0x02f8, 0x011d}, /* gcircumflex */
412 {0x02fd, 0x016d}, /* ubreve */
413 {0x02fe, 0x015d}, /* scircumflex */
414 {0x03a2, 0x0138}, /* kra */
415 {0x03a3, 0x0156}, /* Rcedilla */
416 {0x03a5, 0x0128}, /* Itilde */
417 {0x03a6, 0x013b}, /* Lcedilla */
418 {0x03aa, 0x0112}, /* Emacron */
419 {0x03ab, 0x0122}, /* Gcedilla */
420 {0x03ac, 0x0166}, /* Tslash */
421 {0x03b3, 0x0157}, /* rcedilla */
422 {0x03b5, 0x0129}, /* itilde */
423 {0x03b6, 0x013c}, /* lcedilla */
424 {0x03ba, 0x0113}, /* emacron */
425 {0x03bb, 0x0123}, /* gcedilla */
426 {0x03bc, 0x0167}, /* tslash */
427 {0x03bd, 0x014a}, /* ENG */
428 {0x03bf, 0x014b}, /* eng */
429 {0x03c0, 0x0100}, /* Amacron */
430 {0x03c7, 0x012e}, /* Iogonek */
431 {0x03cc, 0x0116}, /* Eabovedot */
432 {0x03cf, 0x012a}, /* Imacron */
433 {0x03d1, 0x0145}, /* Ncedilla */
434 {0x03d2, 0x014c}, /* Omacron */
435 {0x03d3, 0x0136}, /* Kcedilla */
436 {0x03d9, 0x0172}, /* Uogonek */
437 {0x03dd, 0x0168}, /* Utilde */
438 {0x03de, 0x016a}, /* Umacron */
439 {0x03e0, 0x0101}, /* amacron */
440 {0x03e7, 0x012f}, /* iogonek */
441 {0x03ec, 0x0117}, /* eabovedot */
442 {0x03ef, 0x012b}, /* imacron */
443 {0x03f1, 0x0146}, /* ncedilla */
444 {0x03f2, 0x014d}, /* omacron */
445 {0x03f3, 0x0137}, /* kcedilla */
446 {0x03f9, 0x0173}, /* uogonek */
447 {0x03fd, 0x0169}, /* utilde */
448 {0x03fe, 0x016b}, /* umacron */
449 {0x047e, 0x203e}, /* overline */
450 {0x04a1, 0x3002}, /* kana_fullstop */
451 {0x04a2, 0x300c}, /* kana_openingbracket */
452 {0x04a3, 0x300d}, /* kana_closingbracket */
453 {0x04a4, 0x3001}, /* kana_comma */
454 {0x04a5, 0x30fb}, /* kana_conjunctive */
455 {0x04a6, 0x30f2}, /* kana_WO */
456 {0x04a7, 0x30a1}, /* kana_a */
457 {0x04a8, 0x30a3}, /* kana_i */
458 {0x04a9, 0x30a5}, /* kana_u */
459 {0x04aa, 0x30a7}, /* kana_e */
460 {0x04ab, 0x30a9}, /* kana_o */
461 {0x04ac, 0x30e3}, /* kana_ya */
462 {0x04ad, 0x30e5}, /* kana_yu */
463 {0x04ae, 0x30e7}, /* kana_yo */
464 {0x04af, 0x30c3}, /* kana_tsu */
465 {0x04b0, 0x30fc}, /* prolongedsound */
466 {0x04b1, 0x30a2}, /* kana_A */
467 {0x04b2, 0x30a4}, /* kana_I */
468 {0x04b3, 0x30a6}, /* kana_U */
469 {0x04b4, 0x30a8}, /* kana_E */
470 {0x04b5, 0x30aa}, /* kana_O */
471 {0x04b6, 0x30ab}, /* kana_KA */
472 {0x04b7, 0x30ad}, /* kana_KI */
473 {0x04b8, 0x30af}, /* kana_KU */
474 {0x04b9, 0x30b1}, /* kana_KE */
475 {0x04ba, 0x30b3}, /* kana_KO */
476 {0x04bb, 0x30b5}, /* kana_SA */
477 {0x04bc, 0x30b7}, /* kana_SHI */
478 {0x04bd, 0x30b9}, /* kana_SU */
479 {0x04be, 0x30bb}, /* kana_SE */
480 {0x04bf, 0x30bd}, /* kana_SO */
481 {0x04c0, 0x30bf}, /* kana_TA */
482 {0x04c1, 0x30c1}, /* kana_CHI */
483 {0x04c2, 0x30c4}, /* kana_TSU */
484 {0x04c3, 0x30c6}, /* kana_TE */
485 {0x04c4, 0x30c8}, /* kana_TO */
486 {0x04c5, 0x30ca}, /* kana_NA */
487 {0x04c6, 0x30cb}, /* kana_NI */
488 {0x04c7, 0x30cc}, /* kana_NU */
489 {0x04c8, 0x30cd}, /* kana_NE */
490 {0x04c9, 0x30ce}, /* kana_NO */
491 {0x04ca, 0x30cf}, /* kana_HA */
492 {0x04cb, 0x30d2}, /* kana_HI */
493 {0x04cc, 0x30d5}, /* kana_FU */
494 {0x04cd, 0x30d8}, /* kana_HE */
495 {0x04ce, 0x30db}, /* kana_HO */
496 {0x04cf, 0x30de}, /* kana_MA */
497 {0x04d0, 0x30df}, /* kana_MI */
498 {0x04d1, 0x30e0}, /* kana_MU */
499 {0x04d2, 0x30e1}, /* kana_ME */
500 {0x04d3, 0x30e2}, /* kana_MO */
501 {0x04d4, 0x30e4}, /* kana_YA */
502 {0x04d5, 0x30e6}, /* kana_YU */
503 {0x04d6, 0x30e8}, /* kana_YO */
504 {0x04d7, 0x30e9}, /* kana_RA */
505 {0x04d8, 0x30ea}, /* kana_RI */
506 {0x04d9, 0x30eb}, /* kana_RU */
507 {0x04da, 0x30ec}, /* kana_RE */
508 {0x04db, 0x30ed}, /* kana_RO */
509 {0x04dc, 0x30ef}, /* kana_WA */
510 {0x04dd, 0x30f3}, /* kana_N */
511 {0x04de, 0x309b}, /* voicedsound */
512 {0x04df, 0x309c}, /* semivoicedsound */
513 {0x05ac, 0x060c}, /* Arabic_comma */
514 {0x05bb, 0x061b}, /* Arabic_semicolon */
515 {0x05bf, 0x061f}, /* Arabic_question_mark */
516 {0x05c1, 0x0621}, /* Arabic_hamza */
517 {0x05c2, 0x0622}, /* Arabic_maddaonalef */
518 {0x05c3, 0x0623}, /* Arabic_hamzaonalef */
519 {0x05c4, 0x0624}, /* Arabic_hamzaonwaw */
520 {0x05c5, 0x0625}, /* Arabic_hamzaunderalef */
521 {0x05c6, 0x0626}, /* Arabic_hamzaonyeh */
522 {0x05c7, 0x0627}, /* Arabic_alef */
523 {0x05c8, 0x0628}, /* Arabic_beh */
524 {0x05c9, 0x0629}, /* Arabic_tehmarbuta */
525 {0x05ca, 0x062a}, /* Arabic_teh */
526 {0x05cb, 0x062b}, /* Arabic_theh */
527 {0x05cc, 0x062c}, /* Arabic_jeem */
528 {0x05cd, 0x062d}, /* Arabic_hah */
529 {0x05ce, 0x062e}, /* Arabic_khah */
530 {0x05cf, 0x062f}, /* Arabic_dal */
531 {0x05d0, 0x0630}, /* Arabic_thal */
532 {0x05d1, 0x0631}, /* Arabic_ra */
533 {0x05d2, 0x0632}, /* Arabic_zain */
534 {0x05d3, 0x0633}, /* Arabic_seen */
535 {0x05d4, 0x0634}, /* Arabic_sheen */
536 {0x05d5, 0x0635}, /* Arabic_sad */
537 {0x05d6, 0x0636}, /* Arabic_dad */
538 {0x05d7, 0x0637}, /* Arabic_tah */
539 {0x05d8, 0x0638}, /* Arabic_zah */
540 {0x05d9, 0x0639}, /* Arabic_ain */
541 {0x05da, 0x063a}, /* Arabic_ghain */
542 {0x05e0, 0x0640}, /* Arabic_tatweel */
543 {0x05e1, 0x0641}, /* Arabic_feh */
544 {0x05e2, 0x0642}, /* Arabic_qaf */
545 {0x05e3, 0x0643}, /* Arabic_kaf */
546 {0x05e4, 0x0644}, /* Arabic_lam */
547 {0x05e5, 0x0645}, /* Arabic_meem */
548 {0x05e6, 0x0646}, /* Arabic_noon */
549 {0x05e7, 0x0647}, /* Arabic_ha */
550 {0x05e8, 0x0648}, /* Arabic_waw */
551 {0x05e9, 0x0649}, /* Arabic_alefmaksura */
552 {0x05ea, 0x064a}, /* Arabic_yeh */
553 {0x05eb, 0x064b}, /* Arabic_fathatan */
554 {0x05ec, 0x064c}, /* Arabic_dammatan */
555 {0x05ed, 0x064d}, /* Arabic_kasratan */
556 {0x05ee, 0x064e}, /* Arabic_fatha */
557 {0x05ef, 0x064f}, /* Arabic_damma */
558 {0x05f0, 0x0650}, /* Arabic_kasra */
559 {0x05f1, 0x0651}, /* Arabic_shadda */
560 {0x05f2, 0x0652}, /* Arabic_sukun */
561 {0x06a1, 0x0452}, /* Serbian_dje */
562 {0x06a2, 0x0453}, /* Macedonia_gje */
563 {0x06a3, 0x0451}, /* Cyrillic_io */
564 {0x06a4, 0x0454}, /* Ukrainian_ie */
565 {0x06a5, 0x0455}, /* Macedonia_dse */
566 {0x06a6, 0x0456}, /* Ukrainian_i */
567 {0x06a7, 0x0457}, /* Ukrainian_yi */
568 {0x06a8, 0x0458}, /* Cyrillic_je */
569 {0x06a9, 0x0459}, /* Cyrillic_lje */
570 {0x06aa, 0x045a}, /* Cyrillic_nje */
571 {0x06ab, 0x045b}, /* Serbian_tshe */
572 {0x06ac, 0x045c}, /* Macedonia_kje */
573 {0x06ae, 0x045e}, /* Byelorussian_shortu */
574 {0x06af, 0x045f}, /* Cyrillic_dzhe */
575 {0x06b0, 0x2116}, /* numerosign */
576 {0x06b1, 0x0402}, /* Serbian_DJE */
577 {0x06b2, 0x0403}, /* Macedonia_GJE */
578 {0x06b3, 0x0401}, /* Cyrillic_IO */
579 {0x06b4, 0x0404}, /* Ukrainian_IE */
580 {0x06b5, 0x0405}, /* Macedonia_DSE */
581 {0x06b6, 0x0406}, /* Ukrainian_I */
582 {0x06b7, 0x0407}, /* Ukrainian_YI */
583 {0x06b8, 0x0408}, /* Cyrillic_JE */
584 {0x06b9, 0x0409}, /* Cyrillic_LJE */
585 {0x06ba, 0x040a}, /* Cyrillic_NJE */
586 {0x06bb, 0x040b}, /* Serbian_TSHE */
587 {0x06bc, 0x040c}, /* Macedonia_KJE */
588 {0x06be, 0x040e}, /* Byelorussian_SHORTU */
589 {0x06bf, 0x040f}, /* Cyrillic_DZHE */
590 {0x06c0, 0x044e}, /* Cyrillic_yu */
591 {0x06c1, 0x0430}, /* Cyrillic_a */
592 {0x06c2, 0x0431}, /* Cyrillic_be */
593 {0x06c3, 0x0446}, /* Cyrillic_tse */
594 {0x06c4, 0x0434}, /* Cyrillic_de */
595 {0x06c5, 0x0435}, /* Cyrillic_ie */
596 {0x06c6, 0x0444}, /* Cyrillic_ef */
597 {0x06c7, 0x0433}, /* Cyrillic_ghe */
598 {0x06c8, 0x0445}, /* Cyrillic_ha */
599 {0x06c9, 0x0438}, /* Cyrillic_i */
600 {0x06ca, 0x0439}, /* Cyrillic_shorti */
601 {0x06cb, 0x043a}, /* Cyrillic_ka */
602 {0x06cc, 0x043b}, /* Cyrillic_el */
603 {0x06cd, 0x043c}, /* Cyrillic_em */
604 {0x06ce, 0x043d}, /* Cyrillic_en */
605 {0x06cf, 0x043e}, /* Cyrillic_o */
606 {0x06d0, 0x043f}, /* Cyrillic_pe */
607 {0x06d1, 0x044f}, /* Cyrillic_ya */
608 {0x06d2, 0x0440}, /* Cyrillic_er */
609 {0x06d3, 0x0441}, /* Cyrillic_es */
610 {0x06d4, 0x0442}, /* Cyrillic_te */
611 {0x06d5, 0x0443}, /* Cyrillic_u */
612 {0x06d6, 0x0436}, /* Cyrillic_zhe */
613 {0x06d7, 0x0432}, /* Cyrillic_ve */
614 {0x06d8, 0x044c}, /* Cyrillic_softsign */
615 {0x06d9, 0x044b}, /* Cyrillic_yeru */
616 {0x06da, 0x0437}, /* Cyrillic_ze */
617 {0x06db, 0x0448}, /* Cyrillic_sha */
618 {0x06dc, 0x044d}, /* Cyrillic_e */
619 {0x06dd, 0x0449}, /* Cyrillic_shcha */
620 {0x06de, 0x0447}, /* Cyrillic_che */
621 {0x06df, 0x044a}, /* Cyrillic_hardsign */
622 {0x06e0, 0x042e}, /* Cyrillic_YU */
623 {0x06e1, 0x0410}, /* Cyrillic_A */
624 {0x06e2, 0x0411}, /* Cyrillic_BE */
625 {0x06e3, 0x0426}, /* Cyrillic_TSE */
626 {0x06e4, 0x0414}, /* Cyrillic_DE */
627 {0x06e5, 0x0415}, /* Cyrillic_IE */
628 {0x06e6, 0x0424}, /* Cyrillic_EF */
629 {0x06e7, 0x0413}, /* Cyrillic_GHE */
630 {0x06e8, 0x0425}, /* Cyrillic_HA */
631 {0x06e9, 0x0418}, /* Cyrillic_I */
632 {0x06ea, 0x0419}, /* Cyrillic_SHORTI */
633 {0x06eb, 0x041a}, /* Cyrillic_KA */
634 {0x06ec, 0x041b}, /* Cyrillic_EL */
635 {0x06ed, 0x041c}, /* Cyrillic_EM */
636 {0x06ee, 0x041d}, /* Cyrillic_EN */
637 {0x06ef, 0x041e}, /* Cyrillic_O */
638 {0x06f0, 0x041f}, /* Cyrillic_PE */
639 {0x06f1, 0x042f}, /* Cyrillic_YA */
640 {0x06f2, 0x0420}, /* Cyrillic_ER */
641 {0x06f3, 0x0421}, /* Cyrillic_ES */
642 {0x06f4, 0x0422}, /* Cyrillic_TE */
643 {0x06f5, 0x0423}, /* Cyrillic_U */
644 {0x06f6, 0x0416}, /* Cyrillic_ZHE */
645 {0x06f7, 0x0412}, /* Cyrillic_VE */
646 {0x06f8, 0x042c}, /* Cyrillic_SOFTSIGN */
647 {0x06f9, 0x042b}, /* Cyrillic_YERU */
648 {0x06fa, 0x0417}, /* Cyrillic_ZE */
649 {0x06fb, 0x0428}, /* Cyrillic_SHA */
650 {0x06fc, 0x042d}, /* Cyrillic_E */
651 {0x06fd, 0x0429}, /* Cyrillic_SHCHA */
652 {0x06fe, 0x0427}, /* Cyrillic_CHE */
653 {0x06ff, 0x042a}, /* Cyrillic_HARDSIGN */
654 {0x07a1, 0x0386}, /* Greek_ALPHAaccent */
655 {0x07a2, 0x0388}, /* Greek_EPSILONaccent */
656 {0x07a3, 0x0389}, /* Greek_ETAaccent */
657 {0x07a4, 0x038a}, /* Greek_IOTAaccent */
658 {0x07a5, 0x03aa}, /* Greek_IOTAdiaeresis */
659 {0x07a7, 0x038c}, /* Greek_OMICRONaccent */
660 {0x07a8, 0x038e}, /* Greek_UPSILONaccent */
661 {0x07a9, 0x03ab}, /* Greek_UPSILONdieresis */
662 {0x07ab, 0x038f}, /* Greek_OMEGAaccent */
663 {0x07ae, 0x0385}, /* Greek_accentdieresis */
664 {0x07af, 0x2015}, /* Greek_horizbar */
665 {0x07b1, 0x03ac}, /* Greek_alphaaccent */
666 {0x07b2, 0x03ad}, /* Greek_epsilonaccent */
667 {0x07b3, 0x03ae}, /* Greek_etaaccent */
668 {0x07b4, 0x03af}, /* Greek_iotaaccent */
669 {0x07b5, 0x03ca}, /* Greek_iotadieresis */
670 {0x07b6, 0x0390}, /* Greek_iotaaccentdieresis */
671 {0x07b7, 0x03cc}, /* Greek_omicronaccent */
672 {0x07b8, 0x03cd}, /* Greek_upsilonaccent */
673 {0x07b9, 0x03cb}, /* Greek_upsilondieresis */
674 {0x07ba, 0x03b0}, /* Greek_upsilonaccentdieresis */
675 {0x07bb, 0x03ce}, /* Greek_omegaaccent */
676 {0x07c1, 0x0391}, /* Greek_ALPHA */
677 {0x07c2, 0x0392}, /* Greek_BETA */
678 {0x07c3, 0x0393}, /* Greek_GAMMA */
679 {0x07c4, 0x0394}, /* Greek_DELTA */
680 {0x07c5, 0x0395}, /* Greek_EPSILON */
681 {0x07c6, 0x0396}, /* Greek_ZETA */
682 {0x07c7, 0x0397}, /* Greek_ETA */
683 {0x07c8, 0x0398}, /* Greek_THETA */
684 {0x07c9, 0x0399}, /* Greek_IOTA */
685 {0x07ca, 0x039a}, /* Greek_KAPPA */
686 {0x07cb, 0x039b}, /* Greek_LAMDA */
687 {0x07cc, 0x039c}, /* Greek_MU */
688 {0x07cd, 0x039d}, /* Greek_NU */
689 {0x07ce, 0x039e}, /* Greek_XI */
690 {0x07cf, 0x039f}, /* Greek_OMICRON */
691 {0x07d0, 0x03a0}, /* Greek_PI */
692 {0x07d1, 0x03a1}, /* Greek_RHO */
693 {0x07d2, 0x03a3}, /* Greek_SIGMA */
694 {0x07d4, 0x03a4}, /* Greek_TAU */
695 {0x07d5, 0x03a5}, /* Greek_UPSILON */
696 {0x07d6, 0x03a6}, /* Greek_PHI */
697 {0x07d7, 0x03a7}, /* Greek_CHI */
698 {0x07d8, 0x03a8}, /* Greek_PSI */
699 {0x07d9, 0x03a9}, /* Greek_OMEGA */
700 {0x07e1, 0x03b1}, /* Greek_alpha */
701 {0x07e2, 0x03b2}, /* Greek_beta */
702 {0x07e3, 0x03b3}, /* Greek_gamma */
703 {0x07e4, 0x03b4}, /* Greek_delta */
704 {0x07e5, 0x03b5}, /* Greek_epsilon */
705 {0x07e6, 0x03b6}, /* Greek_zeta */
706 {0x07e7, 0x03b7}, /* Greek_eta */
707 {0x07e8, 0x03b8}, /* Greek_theta */
708 {0x07e9, 0x03b9}, /* Greek_iota */
709 {0x07ea, 0x03ba}, /* Greek_kappa */
710 {0x07eb, 0x03bb}, /* Greek_lambda */
711 {0x07ec, 0x03bc}, /* Greek_mu */
712 {0x07ed, 0x03bd}, /* Greek_nu */
713 {0x07ee, 0x03be}, /* Greek_xi */
714 {0x07ef, 0x03bf}, /* Greek_omicron */
715 {0x07f0, 0x03c0}, /* Greek_pi */
716 {0x07f1, 0x03c1}, /* Greek_rho */
717 {0x07f2, 0x03c3}, /* Greek_sigma */
718 {0x07f3, 0x03c2}, /* Greek_finalsmallsigma */
719 {0x07f4, 0x03c4}, /* Greek_tau */
720 {0x07f5, 0x03c5}, /* Greek_upsilon */
721 {0x07f6, 0x03c6}, /* Greek_phi */
722 {0x07f7, 0x03c7}, /* Greek_chi */
723 {0x07f8, 0x03c8}, /* Greek_psi */
724 {0x07f9, 0x03c9}, /* Greek_omega */
725 {0x08a1, 0x23b7}, /* leftradical */
726 {0x08a4, 0x2320}, /* topintegral */
727 {0x08a5, 0x2321}, /* botintegral */
728 {0x08a7, 0x23a1}, /* topleftsqbracket */
729 {0x08a8, 0x23a3}, /* botleftsqbracket */
730 {0x08a9, 0x23a4}, /* toprightsqbracket */
731 {0x08aa, 0x23a6}, /* botrightsqbracket */
732 {0x08ab, 0x239b}, /* topleftparens */
733 {0x08ac, 0x239d}, /* botleftparens */
734 {0x08ad, 0x239e}, /* toprightparens */
735 {0x08ae, 0x23a0}, /* botrightparens */
736 {0x08af, 0x23a8}, /* leftmiddlecurlybrace */
737 {0x08b0, 0x23ac}, /* rightmiddlecurlybrace */
738 {0x08bc, 0x2264}, /* lessthanequal */
739 {0x08bd, 0x2260}, /* notequal */
740 {0x08be, 0x2265}, /* greaterthanequal */
741 {0x08bf, 0x222b}, /* integral */
742 {0x08c0, 0x2234}, /* therefore */
743 {0x08c1, 0x221d}, /* variation */
744 {0x08c2, 0x221e}, /* infinity */
745 {0x08c5, 0x2207}, /* nabla */
746 {0x08c8, 0x223c}, /* approximate */
747 {0x08c9, 0x2243}, /* similarequal */
748 {0x08cd, 0x21d4}, /* ifonlyif */
749 {0x08ce, 0x21d2}, /* implies */
750 {0x08cf, 0x2261}, /* identical */
751 {0x08d6, 0x221a}, /* radical */
752 {0x08da, 0x2282}, /* includedin */
753 {0x08db, 0x2283}, /* includes */
754 {0x08dc, 0x2229}, /* intersection */
755 {0x08dd, 0x222a}, /* union */
756 {0x08de, 0x2227}, /* logicaland */
757 {0x08df, 0x2228}, /* logicalor */
758 {0x08ef, 0x2202}, /* partialderivative */
759 {0x08f6, 0x0192}, /* function */
760 {0x08fb, 0x2190}, /* leftarrow */
761 {0x08fc, 0x2191}, /* uparrow */
762 {0x08fd, 0x2192}, /* rightarrow */
763 {0x08fe, 0x2193}, /* downarrow */
764 {0x09e0, 0x25c6}, /* soliddiamond */
765 {0x09e1, 0x2592}, /* checkerboard */
766 {0x09e2, 0x2409}, /* ht */
767 {0x09e3, 0x240c}, /* ff */
768 {0x09e4, 0x240d}, /* cr */
769 {0x09e5, 0x240a}, /* lf */
770 {0x09e8, 0x2424}, /* nl */
771 {0x09e9, 0x240b}, /* vt */
772 {0x09ea, 0x2518}, /* lowrightcorner */
773 {0x09eb, 0x2510}, /* uprightcorner */
774 {0x09ec, 0x250c}, /* upleftcorner */
775 {0x09ed, 0x2514}, /* lowleftcorner */
776 {0x09ee, 0x253c}, /* crossinglines */
777 {0x09ef, 0x23ba}, /* horizlinescan1 */
778 {0x09f0, 0x23bb}, /* horizlinescan3 */
779 {0x09f1, 0x2500}, /* horizlinescan5 */
780 {0x09f2, 0x23bc}, /* horizlinescan7 */
781 {0x09f3, 0x23bd}, /* horizlinescan9 */
782 {0x09f4, 0x251c}, /* leftt */
783 {0x09f5, 0x2524}, /* rightt */
784 {0x09f6, 0x2534}, /* bott */
785 {0x09f7, 0x252c}, /* topt */
786 {0x09f8, 0x2502}, /* vertbar */
787 {0x0aa1, 0x2003}, /* emspace */
788 {0x0aa2, 0x2002}, /* enspace */
789 {0x0aa3, 0x2004}, /* em3space */
790 {0x0aa4, 0x2005}, /* em4space */
791 {0x0aa5, 0x2007}, /* digitspace */
792 {0x0aa6, 0x2008}, /* punctspace */
793 {0x0aa7, 0x2009}, /* thinspace */
794 {0x0aa8, 0x200a}, /* hairspace */
795 {0x0aa9, 0x2014}, /* emdash */
796 {0x0aaa, 0x2013}, /* endash */
797 {0x0aae, 0x2026}, /* ellipsis */
798 {0x0aaf, 0x2025}, /* doubbaselinedot */
799 {0x0ab0, 0x2153}, /* onethird */
800 {0x0ab1, 0x2154}, /* twothirds */
801 {0x0ab2, 0x2155}, /* onefifth */
802 {0x0ab3, 0x2156}, /* twofifths */
803 {0x0ab4, 0x2157}, /* threefifths */
804 {0x0ab5, 0x2158}, /* fourfifths */
805 {0x0ab6, 0x2159}, /* onesixth */
806 {0x0ab7, 0x215a}, /* fivesixths */
807 {0x0ab8, 0x2105}, /* careof */
808 {0x0abb, 0x2012}, /* figdash */
809 {0x0ac3, 0x215b}, /* oneeighth */
810 {0x0ac4, 0x215c}, /* threeeighths */
811 {0x0ac5, 0x215d}, /* fiveeighths */
812 {0x0ac6, 0x215e}, /* seveneighths */
813 {0x0ac9, 0x2122}, /* trademark */
814 {0x0ad0, 0x2018}, /* leftsinglequotemark */
815 {0x0ad1, 0x2019}, /* rightsinglequotemark */
816 {0x0ad2, 0x201c}, /* leftdoublequotemark */
817 {0x0ad3, 0x201d}, /* rightdoublequotemark */
818 {0x0ad4, 0x211e}, /* prescription */
819 {0x0ad6, 0x2032}, /* minutes */
820 {0x0ad7, 0x2033}, /* seconds */
821 {0x0ad9, 0x271d}, /* latincross */
822 {0x0aec, 0x2663}, /* club */
823 {0x0aed, 0x2666}, /* diamond */
824 {0x0aee, 0x2665}, /* heart */
825 {0x0af0, 0x2720}, /* maltesecross */
826 {0x0af1, 0x2020}, /* dagger */
827 {0x0af2, 0x2021}, /* doubledagger */
828 {0x0af3, 0x2713}, /* checkmark */
829 {0x0af4, 0x2717}, /* ballotcross */
830 {0x0af5, 0x266f}, /* musicalsharp */
831 {0x0af6, 0x266d}, /* musicalflat */
832 {0x0af7, 0x2642}, /* malesymbol */
833 {0x0af8, 0x2640}, /* femalesymbol */
834 {0x0af9, 0x260e}, /* telephone */
835 {0x0afa, 0x2315}, /* telephonerecorder */
836 {0x0afb, 0x2117}, /* phonographcopyright */
837 {0x0afc, 0x2038}, /* caret */
838 {0x0afd, 0x201a}, /* singlelowquotemark */
839 {0x0afe, 0x201e}, /* doublelowquotemark */
840 {0x0bc2, 0x22a5}, /* downtack */
841 {0x0bc4, 0x230a}, /* downstile */
842 {0x0bca, 0x2218}, /* jot */
843 {0x0bcc, 0x2395}, /* quad */
844 {0x0bce, 0x22a4}, /* uptack */
845 {0x0bcf, 0x25cb}, /* circle */
846 {0x0bd3, 0x2308}, /* upstile */
847 {0x0bdc, 0x22a2}, /* lefttack */
848 {0x0bfc, 0x22a3}, /* righttack */
849 {0x0cdf, 0x2017}, /* hebrew_doublelowline */
850 {0x0ce0, 0x05d0}, /* hebrew_aleph */
851 {0x0ce1, 0x05d1}, /* hebrew_bet */
852 {0x0ce2, 0x05d2}, /* hebrew_gimel */
853 {0x0ce3, 0x05d3}, /* hebrew_dalet */
854 {0x0ce4, 0x05d4}, /* hebrew_he */
855 {0x0ce5, 0x05d5}, /* hebrew_waw */
856 {0x0ce6, 0x05d6}, /* hebrew_zain */
857 {0x0ce7, 0x05d7}, /* hebrew_chet */
858 {0x0ce8, 0x05d8}, /* hebrew_tet */
859 {0x0ce9, 0x05d9}, /* hebrew_yod */
860 {0x0cea, 0x05da}, /* hebrew_finalkaph */
861 {0x0ceb, 0x05db}, /* hebrew_kaph */
862 {0x0cec, 0x05dc}, /* hebrew_lamed */
863 {0x0ced, 0x05dd}, /* hebrew_finalmem */
864 {0x0cee, 0x05de}, /* hebrew_mem */
865 {0x0cef, 0x05df}, /* hebrew_finalnun */
866 {0x0cf0, 0x05e0}, /* hebrew_nun */
867 {0x0cf1, 0x05e1}, /* hebrew_samech */
868 {0x0cf2, 0x05e2}, /* hebrew_ayin */
869 {0x0cf3, 0x05e3}, /* hebrew_finalpe */
870 {0x0cf4, 0x05e4}, /* hebrew_pe */
871 {0x0cf5, 0x05e5}, /* hebrew_finalzade */
872 {0x0cf6, 0x05e6}, /* hebrew_zade */
873 {0x0cf7, 0x05e7}, /* hebrew_qoph */
874 {0x0cf8, 0x05e8}, /* hebrew_resh */
875 {0x0cf9, 0x05e9}, /* hebrew_shin */
876 {0x0cfa, 0x05ea}, /* hebrew_taw */
877 {0x0da1, 0x0e01}, /* Thai_kokai */
878 {0x0da2, 0x0e02}, /* Thai_khokhai */
879 {0x0da3, 0x0e03}, /* Thai_khokhuat */
880 {0x0da4, 0x0e04}, /* Thai_khokhwai */
881 {0x0da5, 0x0e05}, /* Thai_khokhon */
882 {0x0da6, 0x0e06}, /* Thai_khorakhang */
883 {0x0da7, 0x0e07}, /* Thai_ngongu */
884 {0x0da8, 0x0e08}, /* Thai_chochan */
885 {0x0da9, 0x0e09}, /* Thai_choching */
886 {0x0daa, 0x0e0a}, /* Thai_chochang */
887 {0x0dab, 0x0e0b}, /* Thai_soso */
888 {0x0dac, 0x0e0c}, /* Thai_chochoe */
889 {0x0dad, 0x0e0d}, /* Thai_yoying */
890 {0x0dae, 0x0e0e}, /* Thai_dochada */
891 {0x0daf, 0x0e0f}, /* Thai_topatak */
892 {0x0db0, 0x0e10}, /* Thai_thothan */
893 {0x0db1, 0x0e11}, /* Thai_thonangmontho */
894 {0x0db2, 0x0e12}, /* Thai_thophuthao */
895 {0x0db3, 0x0e13}, /* Thai_nonen */
896 {0x0db4, 0x0e14}, /* Thai_dodek */
897 {0x0db5, 0x0e15}, /* Thai_totao */
898 {0x0db6, 0x0e16}, /* Thai_thothung */
899 {0x0db7, 0x0e17}, /* Thai_thothahan */
900 {0x0db8, 0x0e18}, /* Thai_thothong */
901 {0x0db9, 0x0e19}, /* Thai_nonu */
902 {0x0dba, 0x0e1a}, /* Thai_bobaimai */
903 {0x0dbb, 0x0e1b}, /* Thai_popla */
904 {0x0dbc, 0x0e1c}, /* Thai_phophung */
905 {0x0dbd, 0x0e1d}, /* Thai_fofa */
906 {0x0dbe, 0x0e1e}, /* Thai_phophan */
907 {0x0dbf, 0x0e1f}, /* Thai_fofan */
908 {0x0dc0, 0x0e20}, /* Thai_phosamphao */
909 {0x0dc1, 0x0e21}, /* Thai_moma */
910 {0x0dc2, 0x0e22}, /* Thai_yoyak */
911 {0x0dc3, 0x0e23}, /* Thai_rorua */
912 {0x0dc4, 0x0e24}, /* Thai_ru */
913 {0x0dc5, 0x0e25}, /* Thai_loling */
914 {0x0dc6, 0x0e26}, /* Thai_lu */
915 {0x0dc7, 0x0e27}, /* Thai_wowaen */
916 {0x0dc8, 0x0e28}, /* Thai_sosala */
917 {0x0dc9, 0x0e29}, /* Thai_sorusi */
918 {0x0dca, 0x0e2a}, /* Thai_sosua */
919 {0x0dcb, 0x0e2b}, /* Thai_hohip */
920 {0x0dcc, 0x0e2c}, /* Thai_lochula */
921 {0x0dcd, 0x0e2d}, /* Thai_oang */
922 {0x0dce, 0x0e2e}, /* Thai_honokhuk */
923 {0x0dcf, 0x0e2f}, /* Thai_paiyannoi */
924 {0x0dd0, 0x0e30}, /* Thai_saraa */
925 {0x0dd1, 0x0e31}, /* Thai_maihanakat */
926 {0x0dd2, 0x0e32}, /* Thai_saraaa */
927 {0x0dd3, 0x0e33}, /* Thai_saraam */
928 {0x0dd4, 0x0e34}, /* Thai_sarai */
929 {0x0dd5, 0x0e35}, /* Thai_saraii */
930 {0x0dd6, 0x0e36}, /* Thai_saraue */
931 {0x0dd7, 0x0e37}, /* Thai_sarauee */
932 {0x0dd8, 0x0e38}, /* Thai_sarau */
933 {0x0dd9, 0x0e39}, /* Thai_sarauu */
934 {0x0dda, 0x0e3a}, /* Thai_phinthu */
935 {0x0ddf, 0x0e3f}, /* Thai_baht */
936 {0x0de0, 0x0e40}, /* Thai_sarae */
937 {0x0de1, 0x0e41}, /* Thai_saraae */
938 {0x0de2, 0x0e42}, /* Thai_sarao */
939 {0x0de3, 0x0e43}, /* Thai_saraaimaimuan */
940 {0x0de4, 0x0e44}, /* Thai_saraaimaimalai */
941 {0x0de5, 0x0e45}, /* Thai_lakkhangyao */
942 {0x0de6, 0x0e46}, /* Thai_maiyamok */
943 {0x0de7, 0x0e47}, /* Thai_maitaikhu */
944 {0x0de8, 0x0e48}, /* Thai_maiek */
945 {0x0de9, 0x0e49}, /* Thai_maitho */
946 {0x0dea, 0x0e4a}, /* Thai_maitri */
947 {0x0deb, 0x0e4b}, /* Thai_maichattawa */
948 {0x0dec, 0x0e4c}, /* Thai_thanthakhat */
949 {0x0ded, 0x0e4d}, /* Thai_nikhahit */
950 {0x0df0, 0x0e50}, /* Thai_leksun */
951 {0x0df1, 0x0e51}, /* Thai_leknung */
952 {0x0df2, 0x0e52}, /* Thai_leksong */
953 {0x0df3, 0x0e53}, /* Thai_leksam */
954 {0x0df4, 0x0e54}, /* Thai_leksi */
955 {0x0df5, 0x0e55}, /* Thai_lekha */
956 {0x0df6, 0x0e56}, /* Thai_lekhok */
957 {0x0df7, 0x0e57}, /* Thai_lekchet */
958 {0x0df8, 0x0e58}, /* Thai_lekpaet */
959 {0x0df9, 0x0e59}, /* Thai_lekkao */
960 {0x13bc, 0x0152}, /* OE */
961 {0x13bd, 0x0153}, /* oe */
962 {0x13be, 0x0178}, /* Ydiaeresis */
963 {0x20a0, 0x20a0}, /* EcuSign */
964 {0x20a1, 0x20a1}, /* ColonSign */
965 {0x20a2, 0x20a2}, /* CruzeiroSign */
966 {0x20a3, 0x20a3}, /* FFrancSign */
967 {0x20a4, 0x20a4}, /* LiraSign */
968 {0x20a5, 0x20a5}, /* MillSign */
969 {0x20a6, 0x20a6}, /* NairaSign */
970 {0x20a7, 0x20a7}, /* PesetaSign */
971 {0x20a8, 0x20a8}, /* RupeeSign */
972 {0x20a9, 0x20a9}, /* WonSign */
973 {0x20aa, 0x20aa}, /* NewSheqelSign */
974 {0x20ab, 0x20ab}, /* DongSign */
975 {0x20ac, 0x20ac}, /* EuroSign */
976 {0x06ad, 0x0491}, /* Ukrainian_ghe_with_upturn */
977 {0x06bd, 0x0490}, /* Ukrainian_GHE_WITH_UPTURN */
978 {0x14a2, 0x0587}, /* Armenian_ligature_ew */
979 {0x14a3, 0x0589}, /* Armenian_verjaket */
980 {0x14aa, 0x055d}, /* Armenian_but */
981 {0x14ad, 0x058a}, /* Armenian_yentamna */
982 {0x14af, 0x055c}, /* Armenian_amanak */
983 {0x14b0, 0x055b}, /* Armenian_shesht */
984 {0x14b1, 0x055e}, /* Armenian_paruyk */
985 {0x14b2, 0x0531}, /* Armenian_AYB */
986 {0x14b3, 0x0561}, /* Armenian_ayb */
987 {0x14b4, 0x0532}, /* Armenian_BEN */
988 {0x14b5, 0x0562}, /* Armenian_ben */
989 {0x14b6, 0x0533}, /* Armenian_GIM */
990 {0x14b7, 0x0563}, /* Armenian_gim */
991 {0x14b8, 0x0534}, /* Armenian_DA */
992 {0x14b9, 0x0564}, /* Armenian_da */
993 {0x14ba, 0x0535}, /* Armenian_YECH */
994 {0x14bb, 0x0565}, /* Armenian_yech */
995 {0x14bc, 0x0536}, /* Armenian_ZA */
996 {0x14bd, 0x0566}, /* Armenian_za */
997 {0x14be, 0x0537}, /* Armenian_E */
998 {0x14bf, 0x0567}, /* Armenian_e */
999 {0x14c0, 0x0538}, /* Armenian_AT */
1000 {0x14c1, 0x0568}, /* Armenian_at */
1001 {0x14c2, 0x0539}, /* Armenian_TO */
1002 {0x14c3, 0x0569}, /* Armenian_to */
1003 {0x14c4, 0x053a}, /* Armenian_ZHE */
1004 {0x14c5, 0x056a}, /* Armenian_zhe */
1005 {0x14c6, 0x053b}, /* Armenian_INI */
1006 {0x14c7, 0x056b}, /* Armenian_ini */
1007 {0x14c8, 0x053c}, /* Armenian_LYUN */
1008 {0x14c9, 0x056c}, /* Armenian_lyun */
1009 {0x14ca, 0x053d}, /* Armenian_KHE */
1010 {0x14cb, 0x056d}, /* Armenian_khe */
1011 {0x14cc, 0x053e}, /* Armenian_TSA */
1012 {0x14cd, 0x056e}, /* Armenian_tsa */
1013 {0x14ce, 0x053f}, /* Armenian_KEN */
1014 {0x14cf, 0x056f}, /* Armenian_ken */
1015 {0x14d0, 0x0540}, /* Armenian_HO */
1016 {0x14d1, 0x0570}, /* Armenian_ho */
1017 {0x14d2, 0x0541}, /* Armenian_DZA */
1018 {0x14d3, 0x0571}, /* Armenian_dza */
1019 {0x14d4, 0x0542}, /* Armenian_GHAT */
1020 {0x14d5, 0x0572}, /* Armenian_ghat */
1021 {0x14d6, 0x0543}, /* Armenian_TCHE */
1022 {0x14d7, 0x0573}, /* Armenian_tche */
1023 {0x14d8, 0x0544}, /* Armenian_MEN */
1024 {0x14d9, 0x0574}, /* Armenian_men */
1025 {0x14da, 0x0545}, /* Armenian_HI */
1026 {0x14db, 0x0575}, /* Armenian_hi */
1027 {0x14dc, 0x0546}, /* Armenian_NU */
1028 {0x14dd, 0x0576}, /* Armenian_nu */
1029 {0x14de, 0x0547}, /* Armenian_SHA */
1030 {0x14df, 0x0577}, /* Armenian_sha */
1031 {0x14e0, 0x0548}, /* Armenian_VO */
1032 {0x14e1, 0x0578}, /* Armenian_vo */
1033 {0x14e2, 0x0549}, /* Armenian_CHA */
1034 {0x14e3, 0x0579}, /* Armenian_cha */
1035 {0x14e4, 0x054a}, /* Armenian_PE */
1036 {0x14e5, 0x057a}, /* Armenian_pe */
1037 {0x14e6, 0x054b}, /* Armenian_JE */
1038 {0x14e7, 0x057b}, /* Armenian_je */
1039 {0x14e8, 0x054c}, /* Armenian_RA */
1040 {0x14e9, 0x057c}, /* Armenian_ra */
1041 {0x14ea, 0x054d}, /* Armenian_SE */
1042 {0x14eb, 0x057d}, /* Armenian_se */
1043 {0x14ec, 0x054e}, /* Armenian_VEV */
1044 {0x14ed, 0x057e}, /* Armenian_vev */
1045 {0x14ee, 0x054f}, /* Armenian_TYUN */
1046 {0x14ef, 0x057f}, /* Armenian_tyun */
1047 {0x14f0, 0x0550}, /* Armenian_RE */
1048 {0x14f1, 0x0580}, /* Armenian_re */
1049 {0x14f2, 0x0551}, /* Armenian_TSO */
1050 {0x14f3, 0x0581}, /* Armenian_tso */
1051 {0x14f4, 0x0552}, /* Armenian_VYUN */
1052 {0x14f5, 0x0582}, /* Armenian_vyun */
1053 {0x14f6, 0x0553}, /* Armenian_PYUR */
1054 {0x14f7, 0x0583}, /* Armenian_pyur */
1055 {0x14f8, 0x0554}, /* Armenian_KE */
1056 {0x14f9, 0x0584}, /* Armenian_ke */
1057 {0x14fa, 0x0555}, /* Armenian_O */
1058 {0x14fb, 0x0585}, /* Armenian_o */
1059 {0x14fc, 0x0556}, /* Armenian_FE */
1060 {0x14fd, 0x0586}, /* Armenian_fe */
1061 {0x14fe, 0x055a}, /* Armenian_apostrophe */
1062 {0x15d0, 0x10d0}, /* Georgian_an */
1063 {0x15d1, 0x10d1}, /* Georgian_ban */
1064 {0x15d2, 0x10d2}, /* Georgian_gan */
1065 {0x15d3, 0x10d3}, /* Georgian_don */
1066 {0x15d4, 0x10d4}, /* Georgian_en */
1067 {0x15d5, 0x10d5}, /* Georgian_vin */
1068 {0x15d6, 0x10d6}, /* Georgian_zen */
1069 {0x15d7, 0x10d7}, /* Georgian_tan */
1070 {0x15d8, 0x10d8}, /* Georgian_in */
1071 {0x15d9, 0x10d9}, /* Georgian_kan */
1072 {0x15da, 0x10da}, /* Georgian_las */
1073 {0x15db, 0x10db}, /* Georgian_man */
1074 {0x15dc, 0x10dc}, /* Georgian_nar */
1075 {0x15dd, 0x10dd}, /* Georgian_on */
1076 {0x15de, 0x10de}, /* Georgian_par */
1077 {0x15df, 0x10df}, /* Georgian_zhar */
1078 {0x15e0, 0x10e0}, /* Georgian_rae */
1079 {0x15e1, 0x10e1}, /* Georgian_san */
1080 {0x15e2, 0x10e2}, /* Georgian_tar */
1081 {0x15e3, 0x10e3}, /* Georgian_un */
1082 {0x15e4, 0x10e4}, /* Georgian_phar */
1083 {0x15e5, 0x10e5}, /* Georgian_khar */
1084 {0x15e6, 0x10e6}, /* Georgian_ghan */
1085 {0x15e7, 0x10e7}, /* Georgian_qar */
1086 {0x15e8, 0x10e8}, /* Georgian_shin */
1087 {0x15e9, 0x10e9}, /* Georgian_chin */
1088 {0x15ea, 0x10ea}, /* Georgian_can */
1089 {0x15eb, 0x10eb}, /* Georgian_jil */
1090 {0x15ec, 0x10ec}, /* Georgian_cil */
1091 {0x15ed, 0x10ed}, /* Georgian_char */
1092 {0x15ee, 0x10ee}, /* Georgian_xan */
1093 {0x15ef, 0x10ef}, /* Georgian_jhan */
1094 {0x15f0, 0x10f0}, /* Georgian_hae */
1095 {0x15f1, 0x10f1}, /* Georgian_he */
1096 {0x15f2, 0x10f2}, /* Georgian_hie */
1097 {0x15f3, 0x10f3}, /* Georgian_we */
1098 {0x15f4, 0x10f4}, /* Georgian_har */
1099 {0x15f5, 0x10f5}, /* Georgian_hoe */
1100 {0x15f6, 0x10f6}, /* Georgian_fi */
1101 {0x12a1, 0x1e02}, /* Babovedot */
1102 {0x12a2, 0x1e03}, /* babovedot */
1103 {0x12a6, 0x1e0a}, /* Dabovedot */
1104 {0x12a8, 0x1e80}, /* Wgrave */
1105 {0x12aa, 0x1e82}, /* Wacute */
1106 {0x12ab, 0x1e0b}, /* dabovedot */
1107 {0x12ac, 0x1ef2}, /* Ygrave */
1108 {0x12b0, 0x1e1e}, /* Fabovedot */
1109 {0x12b1, 0x1e1f}, /* fabovedot */
1110 {0x12b4, 0x1e40}, /* Mabovedot */
1111 {0x12b5, 0x1e41}, /* mabovedot */
1112 {0x12b7, 0x1e56}, /* Pabovedot */
1113 {0x12b8, 0x1e81}, /* wgrave */
1114 {0x12b9, 0x1e57}, /* pabovedot */
1115 {0x12ba, 0x1e83}, /* wacute */
1116 {0x12bb, 0x1e60}, /* Sabovedot */
1117 {0x12bc, 0x1ef3}, /* ygrave */
1118 {0x12bd, 0x1e84}, /* Wdiaeresis */
1119 {0x12be, 0x1e85}, /* wdiaeresis */
1120 {0x12bf, 0x1e61}, /* sabovedot */
1121 {0x12d0, 0x0174}, /* Wcircumflex */
1122 {0x12d7, 0x1e6a}, /* Tabovedot */
1123 {0x12de, 0x0176}, /* Ycircumflex */
1124 {0x12f0, 0x0175}, /* wcircumflex */
1125 {0x12f7, 0x1e6b}, /* tabovedot */
1126 {0x12fe, 0x0177}, /* ycircumflex */
1127 {0x0590, 0x06f0}, /* Farsi_0 */
1128 {0x0591, 0x06f1}, /* Farsi_1 */
1129 {0x0592, 0x06f2}, /* Farsi_2 */
1130 {0x0593, 0x06f3}, /* Farsi_3 */
1131 {0x0594, 0x06f4}, /* Farsi_4 */
1132 {0x0595, 0x06f5}, /* Farsi_5 */
1133 {0x0596, 0x06f6}, /* Farsi_6 */
1134 {0x0597, 0x06f7}, /* Farsi_7 */
1135 {0x0598, 0x06f8}, /* Farsi_8 */
1136 {0x0599, 0x06f9}, /* Farsi_9 */
1137 {0x05a5, 0x066a}, /* Arabic_percent */
1138 {0x05a6, 0x0670}, /* Arabic_superscript_alef */
1139 {0x05a7, 0x0679}, /* Arabic_tteh */
1140 {0x05a8, 0x067e}, /* Arabic_peh */
1141 {0x05a9, 0x0686}, /* Arabic_tcheh */
1142 {0x05aa, 0x0688}, /* Arabic_ddal */
1143 {0x05ab, 0x0691}, /* Arabic_rreh */
1144 {0x05ae, 0x06d4}, /* Arabic_fullstop */
1145 {0x05b0, 0x0660}, /* Arabic_0 */
1146 {0x05b1, 0x0661}, /* Arabic_1 */
1147 {0x05b2, 0x0662}, /* Arabic_2 */
1148 {0x05b3, 0x0663}, /* Arabic_3 */
1149 {0x05b4, 0x0664}, /* Arabic_4 */
1150 {0x05b5, 0x0665}, /* Arabic_5 */
1151 {0x05b6, 0x0666}, /* Arabic_6 */
1152 {0x05b7, 0x0667}, /* Arabic_7 */
1153 {0x05b8, 0x0668}, /* Arabic_8 */
1154 {0x05b9, 0x0669}, /* Arabic_9 */
1155 {0x05f3, 0x0653}, /* Arabic_madda_above */
1156 {0x05f4, 0x0654}, /* Arabic_hamza_above */
1157 {0x05f5, 0x0655}, /* Arabic_hamza_below */
1158 {0x05f6, 0x0698}, /* Arabic_jeh */
1159 {0x05f7, 0x06a4}, /* Arabic_veh */
1160 {0x05f8, 0x06a9}, /* Arabic_keheh */
1161 {0x05f9, 0x06af}, /* Arabic_gaf */
1162 {0x05fa, 0x06ba}, /* Arabic_noon_ghunna */
1163 {0x05fb, 0x06be}, /* Arabic_heh_doachashmee */
1164 {0x05fc, 0x06cc}, /* Farsi_yeh */
1165 {0x05fd, 0x06d2}, /* Arabic_yeh_baree */
1166 {0x05fe, 0x06c1}, /* Arabic_heh_goal */
1167 {0x0680, 0x0492}, /* Cyrillic_GHE_bar */
1168 {0x0681, 0x0496}, /* Cyrillic_ZHE_descender */
1169 {0x0682, 0x049a}, /* Cyrillic_KA_descender */
1170 {0x0683, 0x049c}, /* Cyrillic_KA_vertstroke */
1171 {0x0684, 0x04a2}, /* Cyrillic_EN_descender */
1172 {0x0685, 0x04ae}, /* Cyrillic_U_straight */
1173 {0x0686, 0x04b0}, /* Cyrillic_U_straight_bar */
1174 {0x0687, 0x04b2}, /* Cyrillic_HA_descender */
1175 {0x0688, 0x04b6}, /* Cyrillic_CHE_descender */
1176 {0x0689, 0x04b8}, /* Cyrillic_CHE_vertstroke */
1177 {0x068a, 0x04ba}, /* Cyrillic_SHHA */
1178 {0x068c, 0x04d8}, /* Cyrillic_SCHWA */
1179 {0x068d, 0x04e2}, /* Cyrillic_I_macron */
1180 {0x068e, 0x04e8}, /* Cyrillic_O_bar */
1181 {0x068f, 0x04ee}, /* Cyrillic_U_macron */
1182 {0x0690, 0x0493}, /* Cyrillic_ghe_bar */
1183 {0x0691, 0x0497}, /* Cyrillic_zhe_descender */
1184 {0x0692, 0x049b}, /* Cyrillic_ka_descender */
1185 {0x0693, 0x049d}, /* Cyrillic_ka_vertstroke */
1186 {0x0694, 0x04a3}, /* Cyrillic_en_descender */
1187 {0x0695, 0x04af}, /* Cyrillic_u_straight */
1188 {0x0696, 0x04b1}, /* Cyrillic_u_straight_bar */
1189 {0x0697, 0x04b3}, /* Cyrillic_ha_descender */
1190 {0x0698, 0x04b7}, /* Cyrillic_che_descender */
1191 {0x0699, 0x04b9}, /* Cyrillic_che_vertstroke */
1192 {0x069a, 0x04bb}, /* Cyrillic_shha */
1193 {0x069c, 0x04d9}, /* Cyrillic_schwa */
1194 {0x069d, 0x04e3}, /* Cyrillic_i_macron */
1195 {0x069e, 0x04e9}, /* Cyrillic_o_bar */
1196 {0x069f, 0x04ef}, /* Cyrillic_u_macron */
1197 {0x16a3, 0x1e8a}, /* Xabovedot */
1198 {0x16a6, 0x012c}, /* Ibreve */
1199 {0x16a9, 0x01b5}, /* Zstroke */
1200 {0x16aa, 0x01e6}, /* Gcaron */
1201 {0x16af, 0x019f}, /* Obarred */
1202 {0x16b3, 0x1e8b}, /* xabovedot */
1203 {0x16b6, 0x012d}, /* ibreve */
1204 {0x16b9, 0x01b6}, /* zstroke */
1205 {0x16ba, 0x01e7}, /* gcaron */
1206 {0x16bd, 0x01d2}, /* ocaron */
1207 {0x16bf, 0x0275}, /* obarred */
1208 {0x16c6, 0x018f}, /* SCHWA */
1209 {0x16f6, 0x0259}, /* schwa */
1210 {0x16d1, 0x1e36}, /* Lbelowdot */
1211 {0x16e1, 0x1e37}, /* lbelowdot */
1212 {0x1ea0, 0x1ea0}, /* Abelowdot */
1213 {0x1ea1, 0x1ea1}, /* abelowdot */
1214 {0x1ea2, 0x1ea2}, /* Ahook */
1215 {0x1ea3, 0x1ea3}, /* ahook */
1216 {0x1ea4, 0x1ea4}, /* Acircumflexacute */
1217 {0x1ea5, 0x1ea5}, /* acircumflexacute */
1218 {0x1ea6, 0x1ea6}, /* Acircumflexgrave */
1219 {0x1ea7, 0x1ea7}, /* acircumflexgrave */
1220 {0x1ea8, 0x1ea8}, /* Acircumflexhook */
1221 {0x1ea9, 0x1ea9}, /* acircumflexhook */
1222 {0x1eaa, 0x1eaa}, /* Acircumflextilde */
1223 {0x1eab, 0x1eab}, /* acircumflextilde */
1224 {0x1eac, 0x1eac}, /* Acircumflexbelowdot */
1225 {0x1ead, 0x1ead}, /* acircumflexbelowdot */
1226 {0x1eae, 0x1eae}, /* Abreveacute */
1227 {0x1eaf, 0x1eaf}, /* abreveacute */
1228 {0x1eb0, 0x1eb0}, /* Abrevegrave */
1229 {0x1eb1, 0x1eb1}, /* abrevegrave */
1230 {0x1eb2, 0x1eb2}, /* Abrevehook */
1231 {0x1eb3, 0x1eb3}, /* abrevehook */
1232 {0x1eb4, 0x1eb4}, /* Abrevetilde */
1233 {0x1eb5, 0x1eb5}, /* abrevetilde */
1234 {0x1eb6, 0x1eb6}, /* Abrevebelowdot */
1235 {0x1eb7, 0x1eb7}, /* abrevebelowdot */
1236 {0x1eb8, 0x1eb8}, /* Ebelowdot */
1237 {0x1eb9, 0x1eb9}, /* ebelowdot */
1238 {0x1eba, 0x1eba}, /* Ehook */
1239 {0x1ebb, 0x1ebb}, /* ehook */
1240 {0x1ebc, 0x1ebc}, /* Etilde */
1241 {0x1ebd, 0x1ebd}, /* etilde */
1242 {0x1ebe, 0x1ebe}, /* Ecircumflexacute */
1243 {0x1ebf, 0x1ebf}, /* ecircumflexacute */
1244 {0x1ec0, 0x1ec0}, /* Ecircumflexgrave */
1245 {0x1ec1, 0x1ec1}, /* ecircumflexgrave */
1246 {0x1ec2, 0x1ec2}, /* Ecircumflexhook */
1247 {0x1ec3, 0x1ec3}, /* ecircumflexhook */
1248 {0x1ec4, 0x1ec4}, /* Ecircumflextilde */
1249 {0x1ec5, 0x1ec5}, /* ecircumflextilde */
1250 {0x1ec6, 0x1ec6}, /* Ecircumflexbelowdot */
1251 {0x1ec7, 0x1ec7}, /* ecircumflexbelowdot */
1252 {0x1ec8, 0x1ec8}, /* Ihook */
1253 {0x1ec9, 0x1ec9}, /* ihook */
1254 {0x1eca, 0x1eca}, /* Ibelowdot */
1255 {0x1ecb, 0x1ecb}, /* ibelowdot */
1256 {0x1ecc, 0x1ecc}, /* Obelowdot */
1257 {0x1ecd, 0x1ecd}, /* obelowdot */
1258 {0x1ece, 0x1ece}, /* Ohook */
1259 {0x1ecf, 0x1ecf}, /* ohook */
1260 {0x1ed0, 0x1ed0}, /* Ocircumflexacute */
1261 {0x1ed1, 0x1ed1}, /* ocircumflexacute */
1262 {0x1ed2, 0x1ed2}, /* Ocircumflexgrave */
1263 {0x1ed3, 0x1ed3}, /* ocircumflexgrave */
1264 {0x1ed4, 0x1ed4}, /* Ocircumflexhook */
1265 {0x1ed5, 0x1ed5}, /* ocircumflexhook */
1266 {0x1ed6, 0x1ed6}, /* Ocircumflextilde */
1267 {0x1ed7, 0x1ed7}, /* ocircumflextilde */
1268 {0x1ed8, 0x1ed8}, /* Ocircumflexbelowdot */
1269 {0x1ed9, 0x1ed9}, /* ocircumflexbelowdot */
1270 {0x1eda, 0x1eda}, /* Ohornacute */
1271 {0x1edb, 0x1edb}, /* ohornacute */
1272 {0x1edc, 0x1edc}, /* Ohorngrave */
1273 {0x1edd, 0x1edd}, /* ohorngrave */
1274 {0x1ede, 0x1ede}, /* Ohornhook */
1275 {0x1edf, 0x1edf}, /* ohornhook */
1276 {0x1ee0, 0x1ee0}, /* Ohorntilde */
1277 {0x1ee1, 0x1ee1}, /* ohorntilde */
1278 {0x1ee2, 0x1ee2}, /* Ohornbelowdot */
1279 {0x1ee3, 0x1ee3}, /* ohornbelowdot */
1280 {0x1ee4, 0x1ee4}, /* Ubelowdot */
1281 {0x1ee5, 0x1ee5}, /* ubelowdot */
1282 {0x1ee6, 0x1ee6}, /* Uhook */
1283 {0x1ee7, 0x1ee7}, /* uhook */
1284 {0x1ee8, 0x1ee8}, /* Uhornacute */
1285 {0x1ee9, 0x1ee9}, /* uhornacute */
1286 {0x1eea, 0x1eea}, /* Uhorngrave */
1287 {0x1eeb, 0x1eeb}, /* uhorngrave */
1288 {0x1eec, 0x1eec}, /* Uhornhook */
1289 {0x1eed, 0x1eed}, /* uhornhook */
1290 {0x1eee, 0x1eee}, /* Uhorntilde */
1291 {0x1eef, 0x1eef}, /* uhorntilde */
1292 {0x1ef0, 0x1ef0}, /* Uhornbelowdot */
1293 {0x1ef1, 0x1ef1}, /* uhornbelowdot */
1294 {0x1ef4, 0x1ef4}, /* Ybelowdot */
1295 {0x1ef5, 0x1ef5}, /* ybelowdot */
1296 {0x1ef6, 0x1ef6}, /* Yhook */
1297 {0x1ef7, 0x1ef7}, /* yhook */
1298 {0x1ef8, 0x1ef8}, /* Ytilde */
1299 {0x1ef9, 0x1ef9}, /* ytilde */
1300 {0x1efa, 0x01a0}, /* Ohorn */
1301 {0x1efb, 0x01a1}, /* ohorn */
1302 {0x1efc, 0x01af}, /* Uhorn */
1303 {0x1efd, 0x01b0}, /* uhorn */
1304 {0, 0}
1305 };
1306
1307 #endif
3535 #define SPECIALMENU(n, f) {.name = "." #n, .len = sl(#n) + 1, \
3636 .flag = ENTRY_##f##_MENU }
3737 static const struct {
38 const char *name; const size_t len; const int flag;
38 const char *name; size_t len; int flag;
3939 } specialMenus[] = {
4040 SPECIALMENU(help, HELP),
4141 SPECIALMENU(apple, APPLE),
4242 SPECIALMENU(window, WINDOWS),
43 {NULL}
43 {NULL, 0, 0}
4444 };
4545 #undef SPECIALMENU
4646
4747 #define MODIFIER(n, f) {.name = #n, .len = sl(#n), .mask = f }
4848 static const struct {
49 const char *name; const size_t len; const NSUInteger mask;
50 } modifiers[] = {
49 const char *name; size_t len; NSUInteger mask;
50 } allModifiers[] = {
5151 MODIFIER(Control, NSControlKeyMask),
5252 MODIFIER(Ctrl, NSControlKeyMask),
5353 MODIFIER(Option, NSAlternateKeyMask),
5757 MODIFIER(Command, NSCommandKeyMask),
5858 MODIFIER(Cmd, NSCommandKeyMask),
5959 MODIFIER(Meta, NSCommandKeyMask),
60 {NULL}
60 {NULL, 0, 0}
6161 };
6262 #undef MODIFIER
6363
6464 #define ACCEL(n, c) {.name = #n, .len = sl(#n), .ch = c }
6565 static const struct {
66 const char *name; const size_t len; const UniChar ch;
66 const char *name; size_t len; UniChar ch;
6767 } specialAccelerators[] = {
6868 ACCEL(PageUp, NSPageUpFunctionKey),
6969 ACCEL(PageDown, NSPageDownFunctionKey),
8585 ACCEL(Help, NSHelpFunctionKey),
8686 ACCEL(Power, 0x233d),
8787 ACCEL(Eject, 0xf804),
88 {NULL}
88 {NULL, 0, 0}
8989 };
9090 #undef ACCEL
9191 #undef sl
9494 * the flag that Tk is not to draw any
9595 * menus. */
9696 static int inPostMenu = 0;
97 static unsigned long defaultBg = 0, defaultFg = 0;
9897 static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0;
9998 static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0;
10099 static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0;
106105 static void MenuSelectEvent(TkMenu *menuPtr);
107106 static void RecursivelyClearActiveMenu(TkMenu *menuPtr);
108107 static int ModifierCharWidth(Tk_Font tkfont);
108
109 #pragma mark TkBackgroundLoop
110
111 /*
112 * The function TkMacOSXEventsCheckProc (in tkMacOSXNotify.c) is the "check
113 * proc" for the macOS event source. Its job is to remove NSEvents from the
114 * default event queue of the NSApplication. It does this by calling the
115 * method [NSApp nextEventMatchingMask: untilDate: inMode: dequeue:]. As a
116 * rule, when the untilDate is set to the distant past this method returns
117 * immediately. An exception to that rule is when the next event is the button
118 * press on a menu button. In that case, the method starts running a nested
119 * event loop in the mode NSEventTrackingRunLoopMode which does not return
120 * until the menu has been dismissed. In Tk 8.6.10 and earlier, this meant
121 * that the Tk event loop would block in its call to the check proc as long as
122 * the menu was posted. For example, opening a menu during the Rube Goldberg
123 * demo would cause the animation to stop. This was also the case for
124 * menubuttons.
125 *
126 * The TKBackground object below works around this problem, and allows a Tk
127 * event loop to run while a menu is open. It is a subclass of NSThread which
128 * inserts requests to call [NSApp _runBackgroundLoop] onto the queue
129 * associated with the NSEventTrackingRunLoopMode. One of these threads gets
130 * started in the callback [NSApp menuBeginTracking] and cancelled in [NSApp
131 * menuEndTracking].
132 */
133
134 @interface TKBackgroundLoop: NSThread
135 @end
136
137 @implementation TKBackgroundLoop
138 - (void) main
139 {
140 NSAutoreleasePool *pool = [NSAutoreleasePool new];
141 NSArray *modeArray = [NSArray arrayWithObjects: NSEventTrackingRunLoopMode,
142 nil];
143 while(1) {
144
145 /*
146 * Queue a request to process Tk events during event tracking.
147 */
148
149 [NSApp performSelectorOnMainThread:@selector(_runBackgroundLoop)
150 withObject:nil
151 waitUntilDone:true
152 modes:modeArray];
153 if ([self isCancelled]) {
154 [NSThread exit];
155 }
156
157 /*
158 * Allow the tracked events to be processed too.
159 */
160
161 [NSThread sleepForTimeInterval:0.001];
162 }
163 [pool drain];
164 }
165 @end
166
167 TKBackgroundLoop *backgroundLoop = nil;
168
109169
110170 #pragma mark TKMenu
111171
258318 if (menuPtr && mePtr) {
259319 Tcl_Interp *interp = menuPtr->interp;
260320
261 /*
262 * Add time for errors to fire if necessary. This is sub-optimal
263 * but avoids issues with Tcl/Cocoa event loop integration.
264 */
265
266 //Tcl_Sleep(100);
267321 Tcl_Preserve(interp);
268322 Tcl_Preserve(menuPtr);
269323
286340 - (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event
287341 target: (id *) target action: (SEL *) action
288342 {
343 (void)menu;
344
289345 /*
290346 * Use lowercaseString when comparing keyEquivalents since the notion of
291347 * a shifted upper case letter does not make much sense.
342398
343399 - (void) menuWillOpen: (NSMenu *) menu
344400 {
401 (void)menu;
402
345403 if (_tkMenu) {
346404 //RecursivelyClearActiveMenu(_tkMenu);
347405 GenerateMenuSelectEvent((TKMenu *)[self supermenu],
351409
352410 - (void) menuDidClose: (NSMenu *) menu
353411 {
412 (void)menu;
413
354414 if (_tkMenu) {
355415 RecursivelyClearActiveMenu(_tkMenu);
356416 }
358418
359419 - (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item
360420 {
421 (void)menu;
422
361423 if (_tkMenu) {
362424 GenerateMenuSelectEvent(self, item);
363425 }
366428 - (void) menuNeedsUpdate: (NSMenu *) menu
367429 {
368430 TkMenu *menuPtr = (TkMenu *) _tkMenu;
431 (void)menu;
369432
370433 if (menuPtr) {
371434 Tcl_Interp *interp = menuPtr->interp;
391454
392455 - (void) menuBeginTracking: (NSNotification *) notification
393456 {
457 (void)notification;
394458 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
395459 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
396460 #endif
461 if (backgroundLoop) {
462 [backgroundLoop cancel];
463 [backgroundLoop release];
464 }
465 backgroundLoop = [[TKBackgroundLoop alloc] init];
466 [backgroundLoop start];
397467 //TkMacOSXClearMenubarActive();
398468 //TkMacOSXPreprocessMenu();
399469 }
400470
401471 - (void) menuEndTracking: (NSNotification *) notification
402472 {
473 (void)notification;
403474 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
404475 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
405476 #endif
477 if (backgroundLoop) {
478 [backgroundLoop cancel];
479 [backgroundLoop release];
480 backgroundLoop = nil;
481 }
406482 if (!inPostMenu) {
407483 TkMacOSXClearMenubarActive();
408484 }
609685 NSString *keyEquivalent = @"";
610686 NSUInteger modifierMask = NSCommandKeyMask;
611687 NSMenu *submenu = nil;
612 NSDictionary *attributes;
613688 int imageWidth, imageHeight;
614689 GC gc = (mePtr->textGC ? mePtr->textGC : mePtr->menuPtr->textGC);
615690 Tcl_Obj *fontPtr = (mePtr->fontPtr ? mePtr->fontPtr :
617692
618693 if (mePtr->image) {
619694 Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight);
620 image = TkMacOSXGetNSImageWithTkImage(mePtr->menuPtr->display,
695 image = TkMacOSXGetNSImageFromTkImage(mePtr->menuPtr->display,
621696 mePtr->image, imageWidth, imageHeight);
622697 } else if (mePtr->bitmapPtr != None) {
623698 Pixmap bitmap = Tk_GetBitmapFromObj(mePtr->menuPtr->tkwin,
625700
626701 Tk_SizeOfBitmap(mePtr->menuPtr->display, bitmap, &imageWidth,
627702 &imageHeight);
628 image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap,
703 image = TkMacOSXGetNSImageFromBitmap(mePtr->menuPtr->display, bitmap,
629704 gc, imageWidth, imageHeight);
630 if (gc->foreground == defaultFg) {
631 // Use a semantic foreground color by default
632 [image setTemplate:YES];
633 }
705 [image setTemplate:YES];
634706 }
635707 [menuItem setImage:image];
636708 if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr &&
644716 }
645717 }
646718 [menuItem setTitle:title];
647 if (strcmp(Tcl_GetString(fontPtr), "menu") || gc->foreground != defaultFg
648 || gc->background != defaultBg) {
649 attributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj(
650 mePtr->menuPtr->tkwin, fontPtr));
651 if (gc->foreground != defaultFg || gc->background != defaultBg) {
652 NSColor *color = TkMacOSXGetNSColor(gc,
653 gc->foreground!=defaultFg? gc->foreground:gc->background);
654
655 attributes = [[attributes mutableCopy] autorelease];
656 [(NSMutableDictionary *) attributes setObject:color
657 forKey:NSForegroundColorAttributeName];
658 }
659 if (attributes) {
660 attributedTitle = [[[NSAttributedString alloc]
661 initWithString:title attributes:attributes] autorelease];
662 }
663 }
719
720 #if 0
721
722 /*
723 * The -background and -foreground options are now ignored in Aqua.
724 * See ticket [635167af14].
725 */
726
727 NSDictionary fontAttributes = TkMacOSXNSFontAttributesForFont(
728 Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr));
729 NSMutableDictionary *attributes = [fontAttributes mutableCopy];
730 static unsigned long defaultBg = 0, defaultFg = 0;
731 if (defaultBg == 0) {
732 tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR);
733 defaultBg = tkColPtr->color.pixel;
734 ckfree(tkColPtr);
735 }
736 if (defaultFg == 0) {
737 tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_FG);
738 defaultFg = tkColPtr->color.pixel;
739 ckfree(tkColPtr);
740 }
741 if (gc->foreground != defaultFg) {
742 NSColor *fgcolor = TkMacOSXGetNSColor(gc, gc->foreground);
743 [attributes setObject:fgcolor
744 forKey:NSForegroundColorAttributeName];
745 }
746 if (gc->background != defaultBg) {
747 NSColor *bgcolor = TkMacOSXGetNSColor(gc, gc->background);
748 [attributes setObject:bgcolor
749 forKey:NSBackgroundColorAttributeName];
750 }
751
752 #else
753
754 NSDictionary *attributes = TkMacOSXNSFontAttributesForFont(
755 Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr));
756
757 #endif
758
759 attributedTitle = [[NSAttributedString alloc] initWithString:title
760 attributes:attributes];
664761 [menuItem setAttributedTitle:attributedTitle];
665 [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)];
762 [menuItem setEnabled:(mePtr->state != ENTRY_DISABLED)];
666763 [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY ||
667764 mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn &&
668765 (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)];
695792 if ([menuItem isEnabled]) {
696793
697794 /*
698 * This menuItem might have been previously disabled (XXX:
699 * track this), which would have disabled entries; we must
700 * re-enable the entries here.
795 * This menuItem might have been previously disabled which
796 * would have disabled all of its entries; we must re-enable the
797 * entries here. It is important to iterate though the Tk
798 * entries, not the NSMenuItems, since some NSMenuItems may
799 * have been added by the system. See [7185d26cf4].
701800 */
702801
703 int i = 0;
704 NSArray *itemArray = [submenu itemArray];
705
706 for (NSMenuItem *item in itemArray) {
802 for (int i = 0; i < menuRefPtr->menuPtr->numEntries; i++) {
707803 TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
708
709 /*
710 * Work around an apparent bug where itemArray can have
711 * more items than the menu's entries[] array.
712 */
713
714 if (i >= (int) menuRefPtr->menuPtr->numEntries) {
715 break;
716 }
717 [item setEnabled: !(submePtr->state == ENTRY_DISABLED)];
718 i++;
804 NSMenuItem *item = (NSMenuItem *) submePtr->platformEntryData;
805 [item setEnabled:(submePtr->state != ENTRY_DISABLED)];
719806 }
720807 }
721808 }
784871
785872 int
786873 TkpPostMenu(
787 Tcl_Interp *interp, /* The interpreter this menu lives in */
874 TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
788875 TkMenu *menuPtr, /* The menu we are posting */
789876 int x, int y, /* The screen coordinates where the top left
790877 * corner of the menu, or of the specified
808895 * rather than the appearance of the root window.
809896 */
810897 realWinPtr = (TkWindow*) realWin;
811 realWinView = TkMacOSXDrawableView(realWinPtr->privatePtr);
898 realWinView = TkMacOSXGetNSViewForDrawable(realWinPtr->privatePtr);
812899 if (realWinView != nil) {
813900 break;
814901 }
881968
882969 int
883970 TkpPostTearoffMenu(
884 Tcl_Interp *interp, /* The interpreter this menu lives in */
971 TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
885972 TkMenu *menuPtr, /* The menu we are posting */
886973 int x, int y, int index) /* The screen coordinates where the top left
887974 * corner of the menu, or of the specified
10921179 cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
10931180 if (cascadeEntryPtr->menuPtr->menuType == MENUBAR
10941181 && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) {
1095 TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr;
1182 TkMenu *mainMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr;
10961183 int i = 0;
10971184 Tcl_DString ds;
10981185
10991186 Tcl_DStringInit(&ds);
1100 Tcl_DStringAppend(&ds, Tk_PathName(masterMenuPtr->tkwin), -1);
1187 Tcl_DStringAppend(&ds, Tk_PathName(mainMenuPtr->tkwin), -1);
11011188 while (specialMenus[i].name) {
11021189 Tcl_DStringAppend(&ds, specialMenus[i].name,
11031190 specialMenus[i].len);
11441231 *maskPtr = 0;
11451232 while (1) {
11461233 i = 0;
1147 while (modifiers[i].name) {
1148 int l = modifiers[i].len;
1149
1150 if (!strncasecmp(accel, modifiers[i].name, l) &&
1234 while (allModifiers[i].name) {
1235 int l = allModifiers[i].len;
1236
1237 if (!strncasecmp(accel, allModifiers[i].name, l) &&
11511238 (accel[l] == '-' || accel[l] == '+')) {
1152 *maskPtr |= modifiers[i].mask;
1239 *maskPtr |= allModifiers[i].mask;
11531240 accel += l+1;
11541241 break;
11551242 }
11561243 i++;
11571244 }
1158 if (!modifiers[i].name || !*accel) {
1245 if (!allModifiers[i].name || !*accel) {
11591246 break;
11601247 }
11611248 }
13791466 }
13801467 } else {
13811468 NSUInteger modifMask = [menuItem keyEquivalentModifierMask];
1382 int i = 0;
1383
1384 while (modifiers[i].name) {
1385 if (modifMask & modifiers[i].mask) {
1386 modifMask &= ~modifiers[i].mask;
1469 int j = 0;
1470
1471 while (allModifiers[j].name) {
1472 if (modifMask & allModifiers[j].mask) {
1473 modifMask &= ~allModifiers[j].mask;
13871474 modifierWidth += modifierCharWidth;
13881475 }
1389 i++;
1476 j++;
13901477 }
13911478 accelWidth = [[menuItem keyEquivalent] sizeWithAttributes:
13921479 TkMacOSXNSFontAttributesForFont(tkfont)].width;
16121699 void
16131700 TkpMenuInit(void)
16141701 {
1615 TkColor *tkColPtr;
1616
16171702 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
16181703
16191704 #define observe(n, s) \
16231708 #undef observe
16241709
16251710 [NSMenuItem setUsesUserKeyEquivalents:NO];
1626 tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR);
1627 defaultBg = tkColPtr->color.pixel;
1628 ckfree(tkColPtr);
1629 tkColPtr = TkpGetColor(NULL, DEF_MENU_FG);
1630 defaultFg = tkColPtr->color.pixel;
1631 ckfree(tkColPtr);
1632
16331711 ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth,
16341712 &menuMarkColumnWidth);
16351713 ChkErr(GetThemeMetric, kThemeMetricMenuTextLeadingEdgeMargin,
16901768
16911769 void
16921770 TkpMenuNotifyToplevelCreate(
1693 Tcl_Interp *interp, /* The interp the menu lives in. */
1694 const char *menuName) /* The name of the menu to reconfigure. */
1771 TCL_UNUSED(Tcl_Interp *), /* The interp the menu lives in. */
1772 TCL_UNUSED(const char *)) /* The name of the menu to reconfigure. */
16951773 {
16961774 /*
16971775 * Nothing to do.
17191797
17201798 void
17211799 TkpInitializeMenuBindings(
1722 Tcl_Interp *interp, /* The interpreter to set. */
1723 Tk_BindingTable bindingTable)
1800 TCL_UNUSED(Tcl_Interp *), /* The interpreter to set. */
1801 TCL_UNUSED(Tk_BindingTable))
17241802 /* The table to add to. */
17251803 {
17261804 /*
17601838 * TkpDrawMenuEntry --
17611839 *
17621840 * Draws the given menu entry at the given coordinates with the given
1763 * attributes.
1764 *
1765 * Results:
1766 * None.
1767 *
1768 * Side effects:
1769 * X Server commands are executed to display the menu entry.
1841 * attributes. This is a no-op on macOS since the menus are drawn by
1842 * the Apple window manager, which also handles all events related to
1843 * selecting menu items. This function is only called for tearoff
1844 * menus, which are not supported on macOS but do get drawn as nearly
1845 * invisible 1 pixel wide windows on macOS
1846 *
1847 * Results:
1848 * None.
1849 *
1850 * Side effects:
1851 * None
17701852 *
17711853 *----------------------------------------------------------------------
17721854 */
17731855
17741856 void
17751857 TkpDrawMenuEntry(
1776 TkMenuEntry *mePtr, /* The entry to draw */
1777 Drawable d, /* What to draw into */
1778 Tk_Font tkfont, /* Precalculated font for menu */
1779 const Tk_FontMetrics *menuMetricsPtr,
1858 TCL_UNUSED(TkMenuEntry *), /* The entry to draw */
1859 TCL_UNUSED(Drawable), /* What to draw into */
1860 TCL_UNUSED(Tk_Font), /* Precalculated font for menu */
1861 TCL_UNUSED(const Tk_FontMetrics *),
17801862 /* Precalculated metrics for menu */
1781 int x, /* X-coordinate of topleft of entry */
1782 int y, /* Y-coordinate of topleft of entry */
1783 int width, /* Width of the entry rectangle */
1784 int height, /* Height of the current rectangle */
1785 int strictMotif, /* Boolean flag */
1786 int drawArrow) /* Whether or not to draw the cascade arrow
1863 TCL_UNUSED(int), /* X-coordinate of topleft of entry */
1864 TCL_UNUSED(int), /* Y-coordinate of topleft of entry */
1865 TCL_UNUSED(int), /* Width of the entry rectangle */
1866 TCL_UNUSED(int), /* Height of the current rectangle */
1867 TCL_UNUSED(int), /* Boolean flag */
1868 TCL_UNUSED(int)) /* Whether or not to draw the cascade arrow
17871869 * for cascade items. */
17881870 {
17891871 }
18321914
18331915 int
18341916 TkMacOSXUseMenuID(
1835 short macID) /* The id to take out of the table */
1917 TCL_UNUSED(short)) /* The id to take out of the table */
18361918 {
18371919 return TCL_OK;
18381920 }
18551937
18561938 int
18571939 TkMacOSXDispatchMenuEvent(
1858 int menuID, /* The menu id of the menu we are invoking */
1859 int index) /* The one-based index of the item that was
1940 TCL_UNUSED(int), /* The menu id of the menu we are invoking */
1941 TCL_UNUSED(int)) /* The one-based index of the item that was
18601942 * selected. */
18611943 {
18621944 return TCL_ERROR;
7575 Tk_ClassProcs tkpMenubuttonClass = {
7676 sizeof(Tk_ClassProcs), /* size */
7777 TkMenuButtonWorldChanged, /* worldChangedProc */
78 NULL,
79 NULL
7880 };
7981
8082 /*
132134 TkpCreateMenuButton(
133135 Tk_Window tkwin)
134136 {
135 MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton));
137 MacMenuButton *mbPtr = (MacMenuButton *)ckalloc(sizeof(MacMenuButton));
136138
137139 Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, mbPtr);
138140 mbPtr->flags = FIRST_DRAW;
178180 TkMacOSXComputeMenuButtonDrawParams(butPtr, dpPtr);
179181
180182 /*
181 * Set up clipping region. Make sure the we are using the port for this
182 * button, or we will set the wrong window's clip.
183 */
184
185 TkMacOSXSetUpClippingRgn(pixmap);
186
187 /*
188183 * Draw the native portion of the buttons.
189184 */
190185
221216
222217 void
223218 TkpDestroyMenuButton(
224 TkMenuButton *mbPtr)
219 TCL_UNUSED(TkMenuButton *))
225220 {
226221 }
227222
245240
246241 void
247242 TkpComputeMenuButtonGeometry(butPtr)
248 register TkMenuButton *butPtr; /* Widget record for menu button. */
243 TkMenuButton *butPtr; /* Widget record for menu button. */
249244 {
250245 int width, height, avgWidth, haveImage = 0, haveText = 0;
251246 int txtWidth, txtHeight;
361356 *
362357 * DrawMenuButtonImageAndText --
363358 *
364 * Draws the image and text associated witha button or label.
359 * Draws the image and text associated with a button or label.
365360 *
366361 * Results:
367362 * None.
392387 DrawParams *dpPtr = &mbPtr->drawParams;
393388 pixmap = (Pixmap) Tk_WindowId(tkwin);
394389
395 if (butPtr->image != None) {
390 if (butPtr->image != NULL) {
396391 Tk_SizeOfImage(butPtr->image, &width, &height);
397392 haveImage = 1;
398393 } else if (butPtr->bitmap != None) {
543538 static void
544539 TkMacOSXDrawMenuButton(
545540 MacMenuButton *mbPtr, /* Mac menubutton. */
546 GC gc, /* The GC we are drawing into - needed for the bevel
547 * button */
541 TCL_UNUSED(GC), /* The GC we are drawing into - not used */
548542 Pixmap pixmap) /* The pixmap we are drawing into - needed for the
549543 * bevel button */
550544 {
565559 static HIThemeButtonDrawInfo hiinfo;
566560
567561 MenuButtonBackgroundDrawCB(mbPtr, 32, true);
568 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
562 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
569563 return;
570564 }
571565
596590 MenuButtonContentDrawCB(mbPtr->btnkind, &mbPtr->drawinfo,
597591 mbPtr, 32, true);
598592 } else {
599 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
593 if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
600594 return;
601595 }
602596 TkMacOSXRestoreDrawingContext(&dc);
624618 static void
625619 MenuButtonBackgroundDrawCB (
626620 MacMenuButton *ptr,
627 SInt16 depth,
628 Boolean isColorDev)
621 TCL_UNUSED(SInt16),
622 TCL_UNUSED(Boolean))
629623 {
630624 TkMenuButton* butPtr = (TkMenuButton *) ptr;
631625 Tk_Window tkwin = butPtr->tkwin;
657651
658652 static void
659653 MenuButtonContentDrawCB (
660 ThemeButtonKind kind,
661 const HIThemeButtonDrawInfo *drawinfo,
654 TCL_UNUSED(ThemeButtonKind),
655 TCL_UNUSED(const HIThemeButtonDrawInfo *),
662656 MacMenuButton *ptr,
663 SInt16 depth,
664 Boolean isColorDev)
657 TCL_UNUSED(SInt16),
658 TCL_UNUSED(Boolean))
665659 {
666660 TkMenuButton *butPtr = (TkMenuButton *) ptr;
667661 Tk_Window tkwin = butPtr->tkwin;
708702 mbPtr->flags &= ~ACTIVE;
709703 }
710704 if ((buttonPtr->flags & REDRAW_PENDING) == 0) {
711 Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) buttonPtr);
705 Tcl_DoWhenIdle(TkpDisplayMenuButton, buttonPtr);
712706 buttonPtr->flags |= REDRAW_PENDING;
713707 }
714708 }
111111 * On OS X 10.12 we get duplicate tab control items if we create them here.
112112 */
113113
114 if ([NSApp macMinorVersion] > 12) {
114 if ([NSApp macOSVersion] > 101200) {
115115 _defaultWindowsMenuItems = [_defaultWindowsMenuItems
116116 arrayByAddingObjectsFromArray:
117117 [NSArray arrayWithObjects:
200200 {
201201 if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog",
202202 NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) {
203 TkAboutDlg();
203 [super orderFrontStandardAboutPanel:nil];
204204 } else {
205205 int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1,
206206 TCL_EVAL_GLOBAL);
414414 if (!winPtr) {
415415 return;
416416 }
417 tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
417 tkwin = (Tk_Window)winPtr->dispPtr->focusPtr;
418418 if (!tkwin) {
419419 return;
420420 }
2323 Point global;
2424 Point local;
2525 } MouseEventData;
26
2627 static Tk_Window captureWinPtr = NULL; /* Current capture window; may be
2728 * NULL. */
2829
4142 * window attribute pointing to the active window. As of 10.8 this behavior
4243 * had changed. The new behavior was that if the mouse were ever moved outside
4344 * of a window, all subsequent NSMouseMoved NSEvents would have a Nil window
44 * attribute. To work around this the TKApplication remembers the last non-Nil
45 * window that it received in a mouse event. If it receives an NSEvent with a
46 * Nil window attribute then the saved window is used.
45 * attribute until the mouse returned to the window. In 11.1 it changed again.
46 * The window attribute can be non-nil, but referencing a window which does not
47 * belong to the application.
4748 */
4849
4950 @implementation TKApplication(TKMouseEvent)
5152 {
5253 NSWindow *eventWindow = [theEvent window];
5354 NSEventType eventType = [theEvent type];
55 NSRect viewFrame = [[eventWindow contentView] frame];
56 NSPoint location = [theEvent locationInWindow];
5457 TkWindow *winPtr = NULL, *grabWinPtr;
55 Tk_Window tkwin;
58 Tk_Window tkwin = None, capture, target;
5659 NSPoint local, global;
57 #if 0
58 NSTrackingArea *trackingArea = nil;
59 NSInteger eventNumber, clickCount, buttonNumber;
60 #endif
61 [NSEvent stopPeriodicEvents];
60 NSInteger button;
61 Bool inTitleBar = NO;
62 int win_x, win_y;
63 unsigned int buttonState = 0;
64 static int validPresses = 0, ignoredPresses = 0;
6265
6366 #ifdef TK_MAC_DEBUG_EVENTS
6467 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
6568 #endif
69
70 /*
71 * If this event is not for a Tk toplevel, it should just be passed up the
72 * responder chain. However, there is an exception for synthesized events,
73 * which are used in testing. Those events are recognized by having their
74 * both the windowNumber and the eventNumber set to -1.
75 */
76
77 if (eventWindow && ![eventWindow isMemberOfClass:[TKWindow class]]) {
78 if ([theEvent windowNumber] != -1 || [theEvent eventNumber] != -1)
79 return theEvent;
80 }
81
82 /*
83 * Check if the event is located in the titlebar.
84 */
85
86 if (eventWindow) {
87 inTitleBar = viewFrame.size.height < location.y;
88 }
89
90 button = [theEvent buttonNumber] + Button1;
6691 switch (eventType) {
67 case NSMouseEntered:
68 case NSMouseExited:
69 case NSCursorUpdate:
70 case NSLeftMouseDown:
71 case NSLeftMouseUp:
72 case NSRightMouseDown:
7392 case NSRightMouseUp:
74 case NSOtherMouseDown:
7593 case NSOtherMouseUp:
94 buttonState &= ~TkGetButtonMask(button);
95 break;
7696 case NSLeftMouseDragged:
7797 case NSRightMouseDragged:
7898 case NSOtherMouseDragged:
99 case NSRightMouseDown:
100 case NSOtherMouseDown:
101 buttonState |= TkGetButtonMask(button);
102 break;
103 case NSMouseEntered:
104 if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
105 !inTitleBar) {
106 [(TKWindow *)eventWindow setMouseInResizeArea:YES];
107 }
108 break;
109 case NSMouseExited:
110 if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)]) {
111 [(TKWindow *)eventWindow setMouseInResizeArea:NO];
112 break;
113 }
114 case NSLeftMouseUp:
115 case NSLeftMouseDown:
79116 case NSMouseMoved:
117 case NSScrollWheel:
118 #if 0
119 case NSCursorUpdate:
80120 case NSTabletPoint:
81121 case NSTabletProximity:
82 case NSScrollWheel:
122 #endif
83123 break;
84 default: /* Unrecognized mouse event. */
124 default: /* This type of event is ignored. */
85125 return theEvent;
86126 }
87127
88128 /*
89 * Compute the mouse position in Tk screen coordinates (global) and in the
90 * Tk coordinates of its containing Tk Window (local). If a grab is in effect,
91 * the local coordinates should be relative to the grab window.
92 */
93
94 if (eventWindow) {
95 local = [theEvent locationInWindow];
96 global = [eventWindow tkConvertPointToScreen: local];
97 tkwin = TkMacOSXGetCapture();
98 if (tkwin) {
99 winPtr = (TkWindow *) tkwin;
100 eventWindow = TkMacOSXDrawableWindow(winPtr->window);
101 if (eventWindow) {
102 local = [eventWindow tkConvertPointFromScreen: global];
103 } else {
104 return theEvent;
105 }
106 }
107 local.y = [eventWindow frame].size.height - local.y;
108 global.y = TkMacOSXZeroScreenHeight() - global.y;
109 } else {
110
111 /*
112 * If the event has no NSWindow, the location is in screen coordinates.
113 */
114
115 global = [theEvent locationInWindow];
116 tkwin = TkMacOSXGetCapture();
117 if (tkwin) {
118 winPtr = (TkWindow *) tkwin;
119 eventWindow = TkMacOSXDrawableWindow(winPtr->window);
120 } else {
121 eventWindow = [NSApp mainWindow];
122 }
129 * Update the button state. We ignore left button presses that start a
130 * resize or occur in the title bar. See tickets [d72abe6b54] and
131 * [39cbacb9e8].
132 */
133
134 if (eventType == NSLeftMouseDown) {
135 if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
136 [(TKWindow *) eventWindow mouseInResizeArea]) {
137
138 /*
139 * When the left button is pressed in the resize area, we receive
140 * NSMouseDown, but when it is released we do not receive
141 * NSMouseUp. So ignore the event and clear the button state but
142 * do not change the ignoredPresses count.
143 */
144
145 buttonState &= ~TkGetButtonMask(Button1);
146 return theEvent;
147 }
148 if (inTitleBar) {
149 ignoredPresses++;
150 return theEvent;
151 }
152 validPresses++;
153 buttonState |= TkGetButtonMask(Button1);
154 }
155 if (eventType == NSLeftMouseUp) {
156 if (ignoredPresses > 0) {
157 ignoredPresses--;
158 } else if (validPresses > 0) {
159 validPresses--;
160 }
161 if (validPresses == 0) {
162 buttonState &= ~TkGetButtonMask(Button1);
163 }
164 }
165
166 /*
167 * Find an appropriate NSWindow to attach to this event, and its
168 * associated Tk window.
169 */
170
171 capture = TkMacOSXGetCapture();
172 if (capture) {
173 winPtr = (TkWindow *) capture;
174 eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
123175 if (!eventWindow) {
124176 return theEvent;
125177 }
126 local = [eventWindow tkConvertPointFromScreen: global];
127 local.y = [eventWindow frame].size.height - local.y;
128 global.y = TkMacOSXZeroScreenHeight() - global.y;
129 }
130
131 /*
132 * If we still don't have a window, try using the toplevel that
133 * manages the NSWindow.
134 */
135
136 if (!tkwin) {
137 winPtr = TkMacOSXGetTkWindow(eventWindow);
138 tkwin = (Tk_Window) winPtr;
139 }
140 if (!tkwin) {
178 } else {
179 if (eventWindow) {
180 winPtr = TkMacOSXGetTkWindow(eventWindow);
181 }
182 if (!winPtr) {
183 eventWindow = [NSApp mainWindow];
184 winPtr = TkMacOSXGetTkWindow(eventWindow);
185 }
186 }
187 if (!winPtr) {
141188
142189 /*
143 * We can't find a window for this event. We have to ignore it.
190 * We couldn't find a Tk window for this event. We have to ignore it.
144191 */
145192
146193 #ifdef TK_MAC_DEBUG_EVENTS
147 TkMacOSXDbgMsg("tkwin == NULL");
194 TkMacOSXDbgMsg("Event received with no Tk window.");
148195 #endif
149196 return theEvent;
150197 }
151
152 /*
153 * Ignore the event if a local grab is in effect and the Tk event window is
154 * not in the grabber's subtree.
155 */
156
157 grabWinPtr = winPtr->dispPtr->grabWinPtr;
158 if (grabWinPtr && /* There is a grab in effect ... */
159 !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */
160 grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */
161 Tk_Window tkwin2, tkEventWindow = Tk_CoordsToWindow(global.x, global.y, tkwin);
162 if (!tkEventWindow) {
163 return theEvent;
164 }
165 for (tkwin2 = tkEventWindow;
166 !Tk_IsTopLevel(tkwin2);
167 tkwin2 = Tk_Parent(tkwin2)) {
168 if (tkwin2 == (Tk_Window) grabWinPtr) {
169 break;
170 }
171 }
172 if (tkwin2 != (Tk_Window) grabWinPtr) {
173 return theEvent;
174 }
175 }
176
177 /*
178 * Convert local from NSWindow flipped coordinates to the toplevel's
179 * coordinates.
180 */
181
198 tkwin = (Tk_Window) winPtr;
199
200 /*
201 * Compute the mouse position in local (window) and global (screen)
202 * coordinates. These are Tk coordinates, meaning that the local origin is
203 * at the top left corner of the containing toplevel and the global origin
204 * is at top left corner of the primary screen.
205 */
206
207 global = [NSEvent mouseLocation];
208 local = [eventWindow tkConvertPointFromScreen: global];
209 global.x = floor(global.x);
210 global.y = floor(TkMacOSXZeroScreenHeight() - global.y);
211 local.x = floor(local.x);
212 local.y = floor([eventWindow frame].size.height - local.y);
182213 if (Tk_IsEmbedded(winPtr)) {
183214 TkWindow *contPtr = TkpGetOtherWindow(winPtr);
184215 if (Tk_IsTopLevel(contPtr)) {
195226 }
196227
197228 /*
198 * Use the toplevel coordinates to find the containing Tk window. Then
199 * convert local into the coordinates of that window. (The converted
200 * local coordinates are only needed for scrollwheel events.)
201 */
202
203 int win_x, win_y;
204 tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
205 local.x = win_x;
206 local.y = win_y;
229 * Use the local coordinates to find the Tk window which should receive
230 * this event. Also convert local into the coordinates of that window.
231 * (The converted local coordinates are only needed for scrollwheel
232 * events.)
233 */
234
235 target = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
236
237 /*
238 * Ignore the event if a local grab is in effect and the Tk window is
239 * not in the grabber's subtree.
240 */
241
242 grabWinPtr = winPtr->dispPtr->grabWinPtr;
243 if (grabWinPtr && /* There is a grab in effect ... */
244 !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */
245 grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */
246 Tk_Window tkwin2;
247 if (!target) {
248 return theEvent;
249 }
250 for (tkwin2 = target;
251 !Tk_IsTopLevel(tkwin2);
252 tkwin2 = Tk_Parent(tkwin2)) {
253 if (tkwin2 == (Tk_Window)grabWinPtr) {
254 break;
255 }
256 }
257 if (tkwin2 != (Tk_Window)grabWinPtr) {
258 return theEvent;
259 }
260 }
207261
208262 /*
209263 * Generate an XEvent for this mouse event.
210264 */
211265
212 unsigned int state = 0;
213 int button = [theEvent buttonNumber] + Button1;
214 EventRef eventRef = (EventRef)[theEvent eventRef];
215 UInt32 buttons;
216 OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
217 typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
218
219 if (err == noErr) {
220 state |= (buttons & 0x1F) * Button1Mask;
221 } else if (button <= Button5) {
222 switch (eventType) {
223 case NSLeftMouseDown:
224 case NSRightMouseDown:
225 case NSLeftMouseDragged:
226 case NSRightMouseDragged:
227 case NSOtherMouseDown:
228 state |= TkGetButtonMask(button);
229 break;
230 default:
231 break;
232 }
233 }
234
266 unsigned int state = buttonState;
235267 NSUInteger modifiers = [theEvent modifierFlags];
236268
237269 if (modifiers & NSAlphaShiftKeyMask) {
259291 if (eventType != NSScrollWheel) {
260292
261293 /*
262 * For normal mouse events, Tk_UpdatePointer will send the XEvent.
294 * For normal mouse events, Tk_UpdatePointer will send the appropriate
295 * XEvents using its cached state information. Unfortunately, it will
296 * also recompute the local coordinates.
263297 */
264298
265299 #ifdef TK_MAC_DEBUG_EVENTS
266 TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d",
267 tkwin, global.x, global.y, state);
300 TKLog(@"UpdatePointer %p x %.1f y %.1f %d",
301 target, global.x, global.y, state);
268302 #endif
269 Tk_UpdatePointer(tkwin, global.x, global.y, state);
303
304 Tk_UpdatePointer(target, global.x, global.y, state);
270305 } else {
306 CGFloat delta;
307 int coarseDelta;
308 XEvent xEvent;
271309
272310 /*
273311 * For scroll wheel events we need to send the XEvent here.
274312 */
275313
276 CGFloat delta;
277 int coarseDelta;
278 XEvent xEvent;
279
280314 xEvent.type = MouseWheelEvent;
281 xEvent.xbutton.x = local.x;
282 xEvent.xbutton.y = local.y;
315 xEvent.xbutton.x = win_x;
316 xEvent.xbutton.y = win_y;
283317 xEvent.xbutton.x_root = global.x;
284318 xEvent.xbutton.y_root = global.y;
285319 xEvent.xany.send_event = false;
286 xEvent.xany.display = Tk_Display(tkwin);
287 xEvent.xany.window = Tk_WindowId(tkwin);
320 xEvent.xany.display = Tk_Display(target);
321 xEvent.xany.window = Tk_WindowId(target);
288322
289323 delta = [theEvent deltaY];
290324 if (delta != 0.0) {
310344 @end
311345
312346 #pragma mark -
313
314 /*
315 *----------------------------------------------------------------------
316 *
317 * TkMacOSXKeyModifiers --
318 *
319 * Returns the current state of the modifier keys.
320 *
321 * Results:
322 * An OS Modifier state.
323 *
324 * Side effects:
325 * None.
326 *
327 *----------------------------------------------------------------------
328 */
329
330 EventModifiers
331 TkMacOSXModifierState(void)
332 {
333 UInt32 keyModifiers;
334 int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront());
335
336 keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
337 GetCurrentKeyModifiers();
338
339 return (EventModifiers) (keyModifiers & USHRT_MAX);
340 }
341347
342348 /*
343349 *----------------------------------------------------------------------
463469 NSPoint global = [NSEvent mouseLocation];
464470
465471 if (getLocal) {
466 MacDrawable *macWin = (MacDrawable *) w;
467 NSWindow *win = TkMacOSXDrawableWindow(w);
472 MacDrawable *macWin = (MacDrawable *)w;
473 NSWindow *win = TkMacOSXGetNSWindowForDrawable(w);
468474
469475 if (win) {
470476 NSPoint local;
502508 * True if event(s) are generated - false otherwise.
503509 *
504510 * Side effects:
505 * Additional events may be place on the Tk event queue. Grab state may
511 * Additional events may be placed on the Tk event queue. Grab state may
506512 * also change.
507513 *
508514 *----------------------------------------------------------------------
540546 * True if event(s) are generated, false otherwise.
541547 *
542548 * Side effects:
543 * Additional events may be place on the Tk event queue. Grab state may
549 * Additional events may be placed on the Tk event queue. Grab state may
544550 * also change.
545551 *
546552 *----------------------------------------------------------------------
553559 Window window, /* X Window containing button event. */
554560 unsigned int state) /* Button Key state suitable for X event. */
555561 {
556 MacDrawable *macWin = (MacDrawable *) window;
557 NSWindow *win = TkMacOSXDrawableWindow(window);
562 MacDrawable *macWin = (MacDrawable *)window;
563 NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
558564 MouseEventData med;
559565
560566 bzero(&med, sizeof(MouseEventData));
592598 * True if event(s) are generated - false otherwise.
593599 *
594600 * Side effects:
595 * Additional events may be place on the Tk event queue. Grab state may
601 * Additional events may be placed on the Tk event queue. Grab state may
596602 * also change.
597603 *
598604 *----------------------------------------------------------------------
635641 return true;
636642 }
637643
644 /*
645 *----------------------------------------------------------------------
646 *
647 * TkpWarpPointer --
648 *
649 * Move the mouse cursor to the screen location specified by the warpX and
650 * warpY fields of a TkDisplay.
651 *
652 * Results:
653 * None
654 *
655 * Side effects:
656 * The mouse cursor is moved.
657 *
658 *----------------------------------------------------------------------
659 */
660
638661 void
639662 TkpWarpPointer(
640663 TkDisplay *dispPtr)
641664 {
642665 CGPoint pt;
643 NSPoint loc;
644 int wNum;
645666
646667 if (dispPtr->warpWindow) {
647668 int x, y;
648 TkWindow *winPtr = (TkWindow *) dispPtr->warpWindow;
649 TkWindow *topPtr = winPtr->privatePtr->toplevel->winPtr;
650 NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
651 wNum = [w windowNumber];
652669 Tk_GetRootCoords(dispPtr->warpWindow, &x, &y);
653670 pt.x = x + dispPtr->warpX;
654671 pt.y = y + dispPtr->warpY;
655 loc.x = dispPtr->warpX;
656 loc.y = Tk_Height(topPtr) - dispPtr->warpY;
657672 } else {
658 wNum = 0;
659 pt.x = loc.x = dispPtr->warpX;
673 pt.x = dispPtr->warpX;
660674 pt.y = dispPtr->warpY;
661 loc.y = TkMacOSXZeroScreenHeight() - pt.y;
662 }
663
664 /*
665 * Generate an NSEvent of type NSMouseMoved.
666 *
667 * It is not clear why this is necessary. For example, calling
668 * event generate $w <Motion> -warp 1 -x $X -y $Y
669 * will cause two <Motion> events to be added to the Tcl queue.
670 */
675 }
671676
672677 CGWarpMouseCursorPosition(pt);
673 NSEvent *warpEvent = [NSEvent mouseEventWithType:NSMouseMoved
674 location:loc
675 modifierFlags:0
676 timestamp:GetCurrentEventTime()
677 windowNumber:wNum
678 context:nil
679 eventNumber:0
680 clickCount:1
681 pressure:0.0];
682 [NSApp postEvent:warpEvent atStart:NO];
683678 }
684679
685680 /*
707702 while (winPtr && !Tk_IsTopLevel(winPtr)) {
708703 winPtr = winPtr->parentPtr;
709704 }
710 [NSEvent stopPeriodicEvents];
711 captureWinPtr = (Tk_Window) winPtr;
705 captureWinPtr = (Tk_Window)winPtr;
712706 }
713707
714708 /*
140140 */
141141 - (void) sendEvent: (NSEvent *) theEvent
142142 {
143
144 /*
145 * Workaround for an Apple bug. When an accented character is selected
146 * from an NSTextInputClient popup character viewer with the mouse, Apple
147 * sends an event of type NSAppKitDefined and subtype 21. If that event is
148 * sent up the responder chain it causes Apple to print a warning to the
149 * console log and, extremely obnoxiously, also to stderr, which says
150 * "Window move completed without beginning." Apparently they are sending
151 * the "move completed" event without having sent the "move began" event of
152 * subtype 20, and then announcing their error on our stderr. Also, of
153 * course, no movement is occurring. The popup is not movable and is just
154 * being closed. The bug has been reported to Apple. If they ever fix it,
155 * this block should be removed.
156 */
157
158 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
159 if ([theEvent type] == NSAppKitDefined) {
160 static Bool aWindowIsMoving = NO;
161 switch([theEvent subtype]) {
162 case 20:
163 aWindowIsMoving = YES;
164 break;
165 case 21:
166 if (aWindowIsMoving) {
167 aWindowIsMoving = NO;
168 break;
169 } else {
170 // printf("Bug!!!!\n");
171 return;
172 }
173 default:
174 break;
175 }
176 }
177 #endif
178
143179 [super sendEvent:theEvent];
144180 [NSApp tkCheckPasteboard];
181
145182 #ifdef TK_MAC_DEBUG_EVENTS
146183 fprintf(stderr, "Sending event of type %d\n", (int)[theEvent type]);
147184 DebugPrintQueue();
148185 #endif
186
187 }
188
189 - (void) _runBackgroundLoop
190 {
191 while(Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)){
192 TkMacOSXDrawAllViews(NULL);
193 }
149194 }
150195 @end
151196
165210 *----------------------------------------------------------------------
166211 */
167212
168 NSString *
213 static NSString *
169214 GetRunLoopMode(NSModalSession modalSession)
170215 {
171216 NSString *runLoopMode = nil;
172217
173218 if (modalSession) {
174219 runLoopMode = NSModalPanelRunLoopMode;
175 } else if (TkMacOSXGetCapture()) {
176 runLoopMode = NSEventTrackingRunLoopMode;
177220 }
178221 if (!runLoopMode) {
179222 runLoopMode = [[NSRunLoop currentRunLoop] currentMode];
225268 Tcl_CreateEventSource(TkMacOSXEventsSetupProc,
226269 TkMacOSXEventsCheckProc, NULL);
227270 TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL);
228 Tcl_SetServiceMode(TCL_SERVICE_ALL);
229271 TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);
230272 TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode);
231273 }
263305 /*
264306 *----------------------------------------------------------------------
265307 *
308 * TkMacOSXDrawAllViews --
309 *
310 * This static function is meant to be run as an idle task. It attempts
311 * to redraw all views which have the tkNeedsDisplay property set to YES.
312 * This relies on a feature of [NSApp nextEventMatchingMask: ...] which
313 * is undocumented, namely that it sometimes blocks and calls drawRect
314 * for all views that need display before it returns. We call it with
315 * deQueue=NO so that it will not change anything on the AppKit event
316 * queue, because we only want the side effect that it runs drawRect. The
317 * only time when any NSViews have the needsDisplay property set to YES
318 * is during execution of this function.
319 *
320 * The reason for running this function as an idle task is to try to
321 * arrange that all widgets will be fully configured before they are
322 * drawn. Any idle tasks that might reconfigure them should be higher on
323 * the idle queue, so they should be run before the display procs are run
324 * by drawRect.
325 *
326 * If this function is called directly with non-NULL clientData parameter
327 * then the int which it references will be set to the number of windows
328 * that need display, but the needsDisplay property of those windows will
329 * not be changed.
330 *
331 * Results:
332 * None.
333 *
334 * Side effects:
335 * Parts of windows may get redrawn.
336 *
337 *----------------------------------------------------------------------
338 */
339
340 void
341 TkMacOSXDrawAllViews(
342 ClientData clientData)
343 {
344 int count = 0, *dirtyCount = (int *)clientData;
345
346 for (NSWindow *window in [NSApp windows]) {
347 if ([[window contentView] isMemberOfClass:[TKContentView class]]) {
348 TKContentView *view = [window contentView];
349 if ([view tkNeedsDisplay]) {
350 count++;
351 if (dirtyCount) {
352 continue;
353 }
354 [view setNeedsDisplayInRect:[view tkDirtyRect]];
355 }
356 } else {
357 [window displayIfNeeded];
358 }
359 }
360 if (dirtyCount) {
361 *dirtyCount = count;
362 }
363 [NSApp nextEventMatchingMask:NSAnyEventMask
364 untilDate:[NSDate distantPast]
365 inMode:GetRunLoopMode(TkMacOSXGetModalSession())
366 dequeue:NO];
367 for (NSWindow *window in [NSApp windows]) {
368 if ([[window contentView] isMemberOfClass:[TKContentView class]]) {
369 TKContentView *view = [window contentView];
370
371 /*
372 * If we did not run drawRect, we set needsDisplay back to NO.
373 * Note that if drawRect did run it may have added to Tk's dirty
374 * rect, due to attempts to draw outside of drawRect's dirty rect.
375 */
376
377 if ([view needsDisplay]) {
378 [view setNeedsDisplay: NO];
379 }
380 }
381 }
382 [NSApp setNeedsToDraw:NO];
383 }
384
385 /*
386 *----------------------------------------------------------------------
387 *
266388 * TkMacOSXEventsSetupProc --
267389 *
268390 * This procedure implements the setup part of the MacOSX event source. It
269 * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsProc to
391 * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsCheckProc to
270392 * process all queued NSEvents. In our case, all we need to do is to set
271393 * the Tcl MaxBlockTime to 0 before starting the loop to process all
272394 * queued NSEvents.
276398 *
277399 * Side effects:
278400 *
279 * If NSEvents are queued, then the maximum block time will be set to 0 to
280 * ensure that control returns immediately to Tcl.
281 *
282 *----------------------------------------------------------------------
283 */
401 * If NSEvents are queued, or if there is any drawing that needs to be
402 * done, then the maximum block time will be set to 0 to ensure that
403 * Tcl_WaitForEvent returns immediately.
404 *
405 *----------------------------------------------------------------------
406 */
407
408 #define TICK 200
409 static Tcl_TimerToken ticker = NULL;
410
411 static void
412 Heartbeat(
413 ClientData clientData)
414 {
415
416 if (ticker) {
417 ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL);
418 }
419 }
420
421 static const Tcl_Time zeroBlockTime = { 0, 0 };
284422
285423 static void
286424 TkMacOSXEventsSetupProc(
287425 ClientData clientData,
288426 int flags)
289427 {
290 static Bool havePeriodicEvents = NO;
291428 NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
292429
293430 /*
295432 */
296433
297434 if (flags & TCL_WINDOW_EVENTS && !runloopMode) {
298 static const Tcl_Time zeroBlockTime = { 0, 0 };
435
299436 [NSApp _resetAutoreleasePool];
300437
301 /*
302 * Call this with dequeue=NO -- just checking if the queue is empty.
303 */
438 /*
439 * After calling this setup proc, Tcl_DoOneEvent will call
440 * Tcl_WaitForEvent. Then it will call check proc to collect the
441 * events and translate them into XEvents.
442 *
443 * If we have any events waiting or if there is any drawing to be done
444 * we want Tcl_WaitForEvent to return immediately. So we set the block
445 * time to 0 and stop the heartbeat.
446 */
304447
305448 NSEvent *currentEvent =
306449 [NSApp nextEventMatchingMask:NSAnyEventMask
307450 untilDate:[NSDate distantPast]
308451 inMode:GetRunLoopMode(TkMacOSXGetModalSession())
309452 dequeue:NO];
310 if (currentEvent) {
311 if (currentEvent.type > 0) {
312 Tcl_SetMaxBlockTime(&zeroBlockTime);
313 [NSEvent stopPeriodicEvents];
314 havePeriodicEvents = NO;
315 }
316 } else if (!havePeriodicEvents){
453 if ((currentEvent) || [NSApp needsToDraw] ) {
454 Tcl_SetMaxBlockTime(&zeroBlockTime);
455 Tcl_DeleteTimerHandler(ticker);
456 ticker = NULL;
457 } else if (ticker == NULL) {
317458
318459 /*
319 * When the user is not generating events we schedule a "hearbeat"
320 * event to fire every 0.1 seconds. This helps to make the vwait
321 * command more responsive when there is no user input, e.g. when
322 * running the test suite.
460 * When the user is not generating events we schedule a "heartbeat"
461 * TimerHandler to fire every 200 milliseconds. The handler does
462 * nothing, but when its timer fires it causes Tcl_WaitForEvent to
463 * return. This helps avoid hangs when calling vwait during the
464 * non-regression tests.
323465 */
324466
325 havePeriodicEvents = YES;
326 [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1];
467 ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL);
327468 }
328469 }
329470 }
351492 int flags)
352493 {
353494 NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
495 int eventsFound = 0;
354496
355497 /*
356498 * runloopMode will be nil if we are in a Tcl event loop.
389531 inMode:GetRunLoopMode(modalSession)
390532 dequeue:YES];
391533 if (currentEvent) {
534
392535 /*
393536 * Generate Xevents.
394537 */
395538
396 int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
397539 NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent];
398 Tcl_SetServiceMode(oldServiceMode);
399540 if (processedEvent) {
541 eventsFound++;
542
400543 #ifdef TK_MAC_DEBUG_EVENTS
401544 TKLog(@" event: %@", currentEvent);
402545 #endif
546
403547 if (modalSession) {
404548 [NSApp _modalSession:modalSession sendEvent:currentEvent];
405549 } else {
416560 */
417561
418562 [NSApp _unlockAutoreleasePool];
563
564 /*
565 * Add an idle task to the end of the idle queue which will redisplay
566 * all of our dirty windows. We want this to happen after all other
567 * idle tasks have run so that all widgets will be configured before
568 * they are displayed. The drawRect method "borrows" the idle queue
569 * while drawing views. That is, it sends expose events which cause
570 * display procs to be posted as idle tasks and then runs an inner
571 * event loop to processes those idle tasks. We are trying to arrange
572 * for the idle queue to be empty when it starts that process and empty
573 * when it finishes.
574 */
575
576 int dirtyCount = 0;
577 TkMacOSXDrawAllViews(&dirtyCount);
578 if (dirtyCount > 0) {
579 Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL);
580 Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL);
581 }
419582 }
420583 }
421584
00 /*
11 * tkMacOSXPort.h --
22 *
3 * This file is included by all of the Tk C files. It contains
3 * This file is included by all of the Tk C files. It contains
44 * information that may be configuration-dependent, such as
55 * #includes for system include files and a few other things.
66 *
1616 #define _TKMACPORT
1717
1818 #include <stdio.h>
19 #include <pwd.h>
20 #include <assert.h>
21 #include <errno.h>
22 #include <fcntl.h>
1923 #include <ctype.h>
20 #include <fcntl.h>
24 #include <math.h>
25 #include <string.h>
2126 #include <limits.h>
22 #include <math.h>
23 #include <pwd.h>
2427 #include <stdlib.h>
25 #include <assert.h>
26 #include <string.h>
2728 #include <sys/types.h>
2829 #include <sys/file.h>
2930 #ifdef HAVE_SYS_SELECT_H
157158 */
158159
159160 #define TK_NO_DOUBLE_BUFFERING 1
161 #define TK_HAS_DYNAMIC_COLORS 1
162 #define TK_DYNAMIC_COLORMAP 0x0fffffff
160163
161164 /*
162 * Magic pixel code values for system colors.
163 *
164 * NOTE: values must be kept in sync with indices into the
165 * systemColorMap array in tkMacOSXColor.c !
165 * Inform tkImgPhInstance.c that our tkPutImage can render an image with an
166 * alpha channel directly into a window.
166167 */
167168
168 #define TRANSPARENT_PIXEL 30
169 #define APPEARANCE_PIXEL 52
170 #define PIXEL_MAGIC ((unsigned char) 0x69)
169 #define TKPUTIMAGE_CAN_BLEND
171170
172171 /*
173 * The following macro returns the pixel value that corresponds to the
174 * 16-bit RGB values in the given XColor structure.
175 * The format is: (PIXEL_MAGIC <<< 24) | (R << 16) | (G << 8) | B
176 * where each of R, G and B is the high order byte of a 16-bit component.
172 * Used by xcolor.c
177173 */
178174
179 #define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \
180 | (((p)->red >> 8) & 0xff)) << 8) \
181 | (((p)->green >> 8) & 0xff)) << 8) \
182 | (((p)->blue >> 8) & 0xff))
175 MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green,
176 unsigned long blue);
177 #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8))
183178
179 /*
180 * Used by tkWindow.c
181 */
182
183 MODULE_SCOPE void TkMacOSXHandleMapOrUnmap(Tk_Window tkwin, XEvent *event);
184
185 #define TkpHandleMapOrUnmap(tkwin, event) TkMacOSXHandleMapOrUnmap(tkwin, event)
186
187 /*
188 * Used by tkAppInit
189 */
190
191 #define USE_CUSTOM_EXIT_PROC
192 EXTERN int TkpWantsExitProc(void);
193 EXTERN TCL_NORETURN void TkpExitProc(void *);
184194
185195 #endif /* _TKMACPORT */
33 * Macros and declarations that are purely internal & private to TkAqua.
44 *
55 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
6 * Copyright 2008-2009, Apple Inc.
6 * Copyright (c) 2008-2009 Apple Inc.
7 * Copyright (c) 2020 Marc Culler
78 *
89 * See the file "license.terms" for information on usage and redistribution
910 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1617
1718 #if !__OBJC__
1819 #error Objective-C compiler required
20 #endif
21
22 #ifndef __clang__
23 #define instancetype id
1924 #endif
2025
2126 #define TextStyle MacTextStyle
97102 * debug message in case of failure.
98103 */
99104 #define ChkErr(f, ...) ({ \
100 OSStatus err = f(__VA_ARGS__); \
101 if (err != noErr) { \
102 TkMacOSXDbgOSErr(f, err); \
105 OSStatus err_ = f(__VA_ARGS__); \
106 if (err_ != noErr) { \
107 TkMacOSXDbgOSErr(f, err_); \
103108 } \
104 err;})
109 err_;})
105110
106111 #else /* TK_MAC_DEBUG */
107112 #define TKLog(f, ...)
122127 }
123128
124129 /*
130 * The structure of a 32-bit XEvent keycode on macOS. It may be viewed as
131 * an unsigned int or as having either two or three bitfields.
132 */
133
134 typedef struct keycode_v_t {
135 unsigned keychar: 22; /* UCS-32 character */
136 unsigned o_s: 2; /* State of Option and Shift keys. */
137 unsigned virtual: 8; /* 8-bit virtual keycode - identifies a key. */
138 } keycode_v;
139
140 typedef struct keycode_x_t {
141 unsigned keychar: 22; /* UCS-32 character */
142 unsigned xvirtual: 10; /* Combines o_s and virtual. This 10-bit integer
143 * is used as a key for looking up the character
144 * produced when pressing a key with a particular
145 * Shift and Option modifier state. */
146 } keycode_x;
147
148 typedef union MacKeycode_t {
149 unsigned int uint;
150 keycode_v v;
151 keycode_x x;
152 } MacKeycode;
153
154 /*
155 * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c.
156 * Note that 0x7f is del and 0xF8FF is the Apple Logo character.
157 */
158
159 #define ON_KEYPAD(virtual) ((virtual >= 0x41) && (virtual <= 0x5C))
160 #define IS_PRINTABLE(keychar) ((keychar >= 0x20) && (keychar != 0x7f) && \
161 ((keychar < 0xF700) || keychar >= 0xF8FF))
162
163 /*
164 * An "index" is 2-bit bitfield showing the state of the Option and Shift
165 * keys. It is used as an index when building the keymaps and it
166 * is the value of the o_s bitfield of a keycode_v.
167 */
168
169 #define INDEX_SHIFT 1
170 #define INDEX_OPTION 2
171 #define INDEX2STATE(index) ((index & INDEX_SHIFT ? ShiftMask : 0) | \
172 (index & INDEX_OPTION ? Mod2Mask : 0))
173 #define INDEX2CARBON(index) ((index & INDEX_SHIFT ? shiftKey : 0) | \
174 (index & INDEX_OPTION ? optionKey : 0))
175 #define STATE2INDEX(state) ((state & ShiftMask ? INDEX_SHIFT : 0) | \
176 (state & Mod2Mask ? INDEX_OPTION : 0))
177
178 /*
179 * Special values for the virtual bitfield. Actual virtual keycodes are < 128.
180 */
181
182 #define NO_VIRTUAL 0xFF /* Not generated by a key or the NSText"InputClient. */
183 #define REPLACEMENT_VIRTUAL 0x80 /* A BMP char sent by the NSTextInputClient. */
184 #define NON_BMP_VIRTUAL 0x81 /* A non-BMP char sent by the NSTextInputClient. */
185
186 /*
187 * A special character is used in the keycode for simulated modifier KeyPress
188 * or KeyRelease XEvents. It is near the end of the private-use range but
189 * different from the UniChar 0xF8FF which Apple uses for their logo character.
190 * A different special character is used for keys, like the Menu key, which do
191 * not appear on Macintosh keyboards.
192 */
193
194 #define MOD_KEYCHAR 0xF8FE
195 #define UNKNOWN_KEYCHAR 0xF8FD
196
197 /*
125198 * Structure encapsulating current drawing environment.
126199 */
127200
142215 * Prototypes for TkMacOSXRegion.c.
143216 */
144217
145 #if 0
146 MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r);
147 MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r);
148 #endif
149218 MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r);
150219 MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r,
151220 HIShapeRef rgn);
152 MODULE_SCOPE void TkMacOSXOffsetRegion(TkRegion r, short dx, short dy);
153221 MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void);
154222 MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect(
155223 const CGRect *inRect);
156224 MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape(
157225 HIMutableShapeRef inDestShape,
158226 HIShapeRef inSrcShape);
159 #if 0
160 MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape,
161 const CGRect *inRect);
162 #endif
163227 MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect(
164228 HIMutableShapeRef inShape, const CGRect *inRect);
165229 MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
180244 int enable);
181245 MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
182246 int antiAlias);
183 MODULE_SCOPE int TkMacOSXGenerateFocusEvent(TkWindow *winPtr,
184 int activeFlag);
185 MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
186247 MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
187248 MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
188 MODULE_SCOPE EventModifiers TkMacOSXModifierState(void);
189 MODULE_SCOPE NSBitmapImageRep* TkMacOSXBitmapRepFromDrawableRect(Drawable drawable,
190 int x, int y, unsigned int width, unsigned int height);
191 MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithXImage(XImage *image);
192249 MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef context,
193250 CGImageRef image, unsigned long imageForeground,
194251 unsigned long imageBackground, CGRect imageBounds,
195252 CGRect srcBounds, CGRect dstBounds);
196253 MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc,
197 int useCG, TkMacOSXDrawingContext *dcPtr);
254 TkMacOSXDrawingContext *dcPtr);
198255 MODULE_SCOPE void TkMacOSXRestoreDrawingContext(
199256 TkMacOSXDrawingContext *dcPtr);
200257 MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel,
201258 CGContextRef context);
202 MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr,
203 NSWindow *window, int fullscreen,
204 Tcl_Interp *interp);
205 MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr,
206 int active);
207 MODULE_SCOPE NSWindow* TkMacOSXDrawableWindow(Drawable drawable);
208 MODULE_SCOPE NSView* TkMacOSXDrawableView(MacDrawable *macWin);
259 #define TkMacOSXGetTkWindow(window) (TkWindow *)Tk_MacOSXGetTkWindow(window)
260 #define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow*)TkMacOSXDrawable(drawable))
261 #define TkMacOSXGetNSViewForDrawable(macWin) (NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin))
209262 MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
210263 MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
211264 MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view,
212265 HIShapeRef rgn);
213266 MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable);
214 MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithDrawable(Drawable drawable);
215 MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithTkImage(Display *display,
267 MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display,
216268 Tk_Image image, int width, int height);
217 MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display,
269 MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display,
218270 Pixmap bitmap, GC gc, int width, int height);
219 MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel);
220271 MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel);
221 MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str);
222 MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w);
223272 MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont);
224273 MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);
225274 MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void);
236285 int inset, int thickness);
237286 MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp);
238287 MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData,
239 Tcl_Interp *interp, int objc,
240 Tcl_Obj *const objv[]);
241 MODULE_SCOPE NSString* TclUniToNSString(const char *source, int numBytes);
242 MODULE_SCOPE int TclUniAtIndex(NSString *string, int index, char *uni,
243 unsigned int *code);
244 MODULE_SCOPE char* NSStringToTclUni(NSString *string, int *numBytes);
288 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
289 MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode);
290 MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view,
291 NSRect *bounds);
292 MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
293 MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData);
294 MODULE_SCOPE unsigned long TkMacOSXClearPixel(void);
245295
246296 #pragma mark Private Objective-C Classes
247297
272322 NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems;
273323 NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems;
274324 NSAutoreleasePool *_mainPool;
325 NSThread *_backgoundLoop;
326
275327 #ifdef __i386__
276328 /* The Objective C runtime used on i386 requires this. */
277329 int _poolLock;
278 int _macMinorVersion;
330 int _macOSVersion; /* 10000 * major + 100*minor */
279331 Bool _isDrawing;
280 #endif
332 Bool _needsToDraw;
333 #endif
334
281335 }
282336 @property int poolLock;
283 @property int macMinorVersion;
337 @property int macOSVersion;
284338 @property Bool isDrawing;
339 @property Bool needsToDraw;
285340
286341 @end
287342 @interface TKApplication(TKInit)
307362 @interface NSApplication(TKNotify)
308363 /* We need to declare this hidden method. */
309364 - (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event;
365 - (void) _runBackgroundLoop;
310366 @end
311367 @interface TKApplication(TKEvent)
312368 - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent;
323379 @end
324380 @interface TKApplication(TKHLEvents)
325381 - (void) terminate: (id) sender;
382 - (void) superTerminate: (id) sender;
326383 - (void) preferences: (id) sender;
327384 - (void) handleQuitApplicationEvent: (NSAppleEventDescriptor *)event
328385 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
352409 {
353410 @private
354411 NSString *privateWorkingText;
355 Bool _needsRedisplay;
356 }
357 @property Bool needsRedisplay;
412 Bool _tkNeedsDisplay;
413 NSRect _tkDirtyRect;
414 }
415 @property Bool tkNeedsDisplay;
416 @property NSRect tkDirtyRect;
358417 @end
359418
360419 @interface TKContentView(TKKeyEvent)
361420 - (void) deleteWorkingText;
421 - (void) cancelComposingText;
362422 @end
363423
364424 @interface TKContentView(TKWindowEvent)
365 - (void) generateExposeEvents: (HIShapeRef) shape;
425 - (void) addTkDirtyRect: (NSRect) rect;
426 - (void) clearTkDirtyRect;
427 - (void) generateExposeEvents: (NSRect) rect;
366428 - (void) tkToolbarButton: (id) sender;
367429 @end
368430
373435
374436 VISIBILITY_HIDDEN
375437 @interface TKWindow : NSWindow
438 {
439 #ifdef __i386__
440 /* The Objective C runtime used on i386 requires this. */
441 Bool _mouseInResizeArea;
442 Window _tkWindow;
443 #endif
444 }
445 @property Bool mouseInResizeArea;
446 @property Window tkWindow;
376447 @end
377448
378449 @interface TKWindow(TKWm)
379450 - (void) tkLayoutChanged;
380451 @end
381452
382 @interface NSDrawerWindow : NSWindow
453 @interface TKDrawerWindow : NSWindow
383454 {
384455 id _i1, _i2;
385 }
456 #ifdef __i386__
457 /* The Objective C runtime used on i386 requires this. */
458 Window _tkWindow;
459 #endif
460 }
461 @property Window tkWindow;
462 @end
463
464 @interface TKPanel : NSPanel
465 {
466 #ifdef __i386__
467 /* The Objective C runtime used on i386 requires this. */
468 Window _tkWindow;
469 #endif
470 }
471 @property Window tkWindow;
386472 @end
387473
388474 #pragma mark NSMenu & NSMenuItem Utilities
432518 - (void) setAppleMenu: (NSMenu *) menu;
433519 @end
434520
521 /*
522 * These methods are exposed because they are needed to prevent zombie windows
523 * on systems with a TouchBar. The TouchBar Key-Value observer holds a
524 * reference to the key window, which prevents deallocation of the key window
525 * when it is closed.
526 */
527
528 @interface NSApplication(TkWm)
529 - (id) _setKeyWindow: (NSWindow *) window;
530 - (id) _setMainWindow: (NSWindow *) window;
531 @end
532
533
534 /*
535 *---------------------------------------------------------------------------
536 *
537 * TKNSString --
538 *
539 * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot
540 * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8
541 * encoding requires 4 bytes. Instead, when using these versions of Tcl, Tk
542 * uses the CESU-8 encoding internally. This encoding is similar to UTF-8
543 * except that it allows encoding surrogate characters as 3-byte sequences
544 * using the same algorithm which UTF-8 uses for non-surrogates. This means
545 * that a non-BMP character is encoded as a string of length 6. Apple's
546 * NSString class does not provide a constructor which accepts a CESU-8 encoded
547 * byte sequence as initial data. So we add a new class which does provide
548 * such a constructor. It also has a DString property which is a DString whose
549 * string pointer is a byte sequence encoding the NSString with the current Tk
550 * encoding, namely UTF-8 if TCL_UTF_MAX >= 4 or CESU-8 if TCL_UTF_MAX = 3.
551 *
552 *---------------------------------------------------------------------------
553 */
554
555 @interface TKNSString:NSString {
556 @private
557 Tcl_DString _ds;
558 NSString *_string;
559 const char *_UTF8String;
560 }
561 @property const char *UTF8String;
562 @property (readonly) Tcl_DString DString;
563 - (instancetype)initWithTclUtfBytes:(const void *)bytes
564 length:(NSUInteger)len;
565 @end
566
435567 #endif /* _TKMACPRIV */
436
437 int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *const objv[]);
438
568
439569 /*
440570 * Local Variables:
441571 * mode: objc
1111 */
1212
1313 #include "tkMacOSXPrivate.h"
14 static void RetainRegion(TkRegion r);
15 static void ReleaseRegion(TkRegion r);
16
17 #ifdef DEBUG
18 static int totalRegions = 0;
19 static int totalRegionRetainCount = 0;
20 #define DebugLog(msg, ...) fprintf(stderr, (msg), ##__VA_ARGS__)
21 #else
22 #define DebugLog(msg, ...)
23 #endif
1424
1525
1626 /*
3343 TkRegion
3444 TkCreateRegion(void)
3545 {
36 return (TkRegion) HIShapeCreateMutable();
46 TkRegion region = (TkRegion) HIShapeCreateMutable();
47 DebugLog("Created region: total regions = %d\n", ++totalRegions);
48 RetainRegion(region);
49 return region;
3750 }
3851
3952 /*
5871 TkRegion r)
5972 {
6073 if (r) {
61 CFRelease(r);
74 DebugLog("Destroyed region: total regions = %d\n", --totalRegions);
75 ReleaseRegion(r);
6276 }
6377 return Success;
6478 }
174188 *----------------------------------------------------------------------
175189 */
176190
177 int
191 static int
178192 TkMacOSXIsEmptyRegion(
179193 TkRegion r)
180194 {
319333 /*
320334 *----------------------------------------------------------------------
321335 *
322 * TkpRetainRegion --
336 * RetainRegion --
323337 *
324338 * Increases reference count of region.
325339 *
332346 *----------------------------------------------------------------------
333347 */
334348
335 void
336 TkpRetainRegion(
349 static void
350 RetainRegion(
337351 TkRegion r)
338352 {
339353 CFRetain(r);
340 }
341
342 /*
343 *----------------------------------------------------------------------
344 *
345 * TkpReleaseRegion --
354 DebugLog("Retained region: total count is %d\n", ++totalRegionRetainCount);
355 }
356
357 /*
358 *----------------------------------------------------------------------
359 *
360 * ReleaseRegion --
346361 *
347362 * Decreases reference count of region.
348363 *
355370 *----------------------------------------------------------------------
356371 */
357372
358 void
359 TkpReleaseRegion(
373 static void
374 ReleaseRegion(
360375 TkRegion r)
361376 {
362377 CFRelease(r);
378 DebugLog("Released region: total count is %d\n", --totalRegionRetainCount);
363379 }
364380
365381 /*
435451 /*
436452 *----------------------------------------------------------------------
437453 *
438 * TkMacOSXOffsetRegion --
454 * XOffsetRegion --
439455 *
440456 * Offsets region by given distances.
441457 *
448464 *----------------------------------------------------------------------
449465 */
450466
451 void
452 TkMacOSXOffsetRegion(
453 TkRegion r,
454 short dx,
455 short dy)
467 int
468 XOffsetRegion(
469 void *r,
470 int dx,
471 int dy)
456472 {
457473 ChkErr(HIShapeOffset, (HIMutableShapeRef) r, dx, dy);
474 return Success;
458475 }
459476
460477 /*
461478 *----------------------------------------------------------------------
462479 *
463480 * TkMacOSXHIShapeCreateEmpty, TkMacOSXHIShapeCreateMutableWithRect,
464 * TkMacOSXHIShapeSetWithShape, TkMacOSXHIShapeSetWithRect,
481 * TkMacOSXHIShapeSetWithShape,
465482 * TkMacOSHIShapeDifferenceWithRect, TkMacOSHIShapeUnionWithRect,
466483 * TkMacOSHIShapeUnion --
467484 *
499516 result = HIShapeSetWithShape(inDestShape, inSrcShape);
500517 return result;
501518 }
502
503 #if 0
504 OSStatus
505 TkMacOSXHIShapeSetWithRect(
506 HIMutableShapeRef inShape,
507 const CGRect *inRect)
508 {
509 OSStatus result;
510 HIShapeRef rgn = HIShapeCreateWithRect(inRect);
511
512 result = TkMacOSXHIShapeSetWithShape(inShape, rgn);
513 CFRelease(rgn);
514
515 return result;
516 }
517 #endif
518519
519520 OSStatus
520521 TkMacOSHIShapeDifferenceWithRect(
7575 TkpCreateScale(
7676 Tk_Window tkwin)
7777 {
78 MacScale *macScalePtr = ckalloc(sizeof(MacScale));
78 MacScale *macScalePtr = (MacScale *)ckalloc(sizeof(MacScale));
7979
8080 macScalePtr->scaleHandle = NULL;
8181 if (scaleActionProc == NULL) {
148148 MacScale *macScalePtr = clientData;
149149 Rect r;
150150 WindowRef windowRef;
151 CGrafPtr destPort, savePort;
152 Boolean portChanged;
153151 MacDrawable *macDraw;
154152 SInt32 initialValue, minValue, maxValue;
155153 UInt16 numTicks;
178176 Tcl_DStringAppend(&buf, scalePtr->command, -1);
179177 Tcl_DStringAppend(&buf, " ", -1);
180178 Tcl_DStringAppend(&buf, string, -1);
181 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
179 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
182180 Tcl_DStringFree(&buf);
183181 if (result != TCL_OK) {
184182 Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
214212 * Set up port for drawing Macintosh control.
215213 */
216214
217 macDraw = (MacDrawable *) Tk_WindowId(tkwin);
218 destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
219 windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
220 portChanged = QDSwapPort(destPort, &savePort);
221 TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
215 macDraw = (MacDrawable *)Tk_WindowId(tkwin);
216 windowRef = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin));
222217
223218 /*
224219 * Create Macintosh control.
291286 SetControlVisibility(macScalePtr->scaleHandle, true, true);
292287 HiliteControl(macScalePtr->scaleHandle, 0);
293288 Draw1Control(macScalePtr->scaleHandle);
294
295 if (portChanged) {
296 QDSwapPort(savePort, NULL);
297 }
298289 done:
299290 scalePtr->flags &= ~REDRAW_ALL;
300291 }
326317 ControlPartCode part;
327318 Point where;
328319 Rect bounds;
329 CGrafPtr destPort, savePort;
330 Boolean portChanged;
331320
332321 #ifdef TK_MAC_DEBUG_SCALE
333322 TkMacOSXDbgMsg("TkpScaleElement");
334323 #endif
335 destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin));
336 portChanged = QDSwapPort(destPort, &savePort);
337324
338325 /*
339326 * All of the calculations in this procedure mirror those in
344331 where.h = x + bounds.left;
345332 where.v = y + bounds.top;
346333 part = TestControl(macScalePtr->scaleHandle, where);
347
348 if (portChanged) {
349 QDSwapPort(savePort, NULL);
350 }
351334
352335 #ifdef TK_MAC_DEBUG_SCALE
353336 fprintf (stderr,"ScalePart %d, pos ( %d %d )\n", part, where.h, where.v );
400383 Point where;
401384 Rect bounds;
402385 int part;
403 CGrafPtr destPort, savePort;
404 Boolean portChanged;
405386
406387 #ifdef TK_MAC_DEBUG_SCALE
407388 fprintf(stderr,"MacScaleEventProc\n" );
408389 #endif
409
410 /*
411 * To call Macintosh control routines we must have the port set to the
412 * window containing the control. We will then test which part of the
413 * control was hit and act accordingly.
414 */
415
416 destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin));
417 portChanged = QDSwapPort(destPort, &savePort);
418 TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin));
419390
420391 TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds);
421392 where.h = eventPtr->xbutton.x + bounds.left;
446417 */
447418
448419 TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin));
449
450 if (portChanged) {
451 QDSwapPort(savePort, NULL);
452 }
453420 }
454421
455422 /*
120120 TkpCreateScrollbar(
121121 Tk_Window tkwin)
122122 {
123 MacScrollbar *scrollPtr = ckalloc(sizeof(MacScrollbar));
123 MacScrollbar *scrollPtr = (MacScrollbar *)ckalloc(sizeof(MacScrollbar));
124124
125125 scrollPtr->troughGC = NULL;
126126 scrollPtr->copyGC = NULL;
173173 MacScrollbar *msPtr,
174174 CGContextRef context)
175175 {
176 MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
177 NSView *view = TkMacOSXDrawableView(macWin);
176 Drawable d = Tk_WindowId(scrollPtr->tkwin);
177 NSView *view = TkMacOSXGetNSViewForDrawable(d);
178178 CGPathRef path;
179179 CGPoint inner[2], outer[2], thumbOrigin;
180180 CGSize thumbSize;
245245 TkpDisplayScrollbar(
246246 ClientData clientData) /* Information about window. */
247247 {
248 register TkScrollbar *scrollPtr = clientData;
248 TkScrollbar *scrollPtr = clientData;
249249 MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
250 register Tk_Window tkwin = scrollPtr->tkwin;
250 Tk_Window tkwin = scrollPtr->tkwin;
251251 TkWindow *winPtr = (TkWindow *) tkwin;
252252 TkMacOSXDrawingContext dc;
253253
257257 return;
258258 }
259259
260 MacDrawable *macWin = (MacDrawable *) winPtr->window;
261 NSView *view = TkMacOSXDrawableView(macWin);
260 MacDrawable *macWin = (MacDrawable *)winPtr->window;
261 NSView *view = TkMacOSXGetNSViewForDrawable(macWin);
262262
263263 if ((view == NULL)
264264 || (macWin->flags & TK_DO_NOT_DRAW)
265 || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
265 || !TkMacOSXSetupDrawingContext((Drawable)macWin, NULL, &dc)) {
266266 return;
267267 }
268268
315315 if (SNOW_LEOPARD_STYLE) {
316316 HIThemeDrawTrack(&msPtr->info, 0, dc.context,
317317 kHIThemeOrientationInverted);
318 } else if ([NSApp macMinorVersion] <= 8) {
318 } else if ([NSApp macOSVersion] <= 100800) {
319319 HIThemeDrawTrack(&msPtr->info, 0, dc.context,
320320 kHIThemeOrientationNormal);
321321 } else {
353353
354354 extern void
355355 TkpComputeScrollbarGeometry(
356 register TkScrollbar *scrollPtr)
356 TkScrollbar *scrollPtr)
357357 /* Scrollbar whose geometry may have
358358 * changed. */
359359 {
376376 scrollPtr->highlightWidth = 0;
377377 }
378378 scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth;
379 if ([NSApp macMinorVersion] == 6) {
379 if ([NSApp macOSVersion] == 100600) {
380380 scrollPtr->arrowLength = scrollPtr->width;
381381 } else {
382382 scrollPtr->arrowLength = 0;
483483
484484 void
485485 TkpConfigureScrollbar(
486 register TkScrollbar *scrollPtr)
486 TkScrollbar *scrollPtr)
487487 {
488488 /* empty */
489489 }
508508
509509 int
510510 TkpScrollbarPosition(
511 register TkScrollbar *scrollPtr,
511 TkScrollbar *scrollPtr,
512512 /* Scrollbar widget record. */
513513 int x, int y) /* Coordinates within scrollPtr's window. */
514514 {
518518 */
519519
520520 int length, width, tmp;
521 register const int inset = scrollPtr->inset;
521 const int inset = scrollPtr->inset;
522522
523523 if (scrollPtr->vertical) {
524524 length = Tk_Height(scrollPtr->tkwin);
588588 {
589589 MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
590590 Tk_Window tkwin = scrollPtr->tkwin;
591 MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
591 MacDrawable *macWin = (MacDrawable *)Tk_WindowId(scrollPtr->tkwin);
592592 double dViewSize;
593593 HIRect contrlRect;
594594 short width, height;
595595
596 NSView *view = TkMacOSXDrawableView(macWin);
596 NSView *view = TkMacOSXGetNSViewForDrawable(macWin);
597597 CGFloat viewHeight = [view bounds].size.height;
598598 NSRect frame;
599599
22 *
33 * This file provides procedures that implement the "send" command,
44 * allowing commands to be passed from interpreter to interpreter. This
5 * current implementation for the Mac has most functionality stubed out.
5 * current implementation for the Mac has most functionality stubbed out.
66 *
77 * The current plan, which we have not had time to implement, is for the
88 * first Wish app to create a gestalt of type 'WIsH'. This gestalt will
1919
2020 static int
2121 ServicesEventProc(
22 Tcl_Event *event,
23 int flags)
22 TCL_UNUSED(Tcl_Event *),
23 TCL_UNUSED(int))
2424 {
2525 TkMainInfo *info = TkGetMainInfoList();
26
2627 Tcl_GlobalEval(info->interp, "::tk::mac::PerformService");
2728 return 1;
2829 }
4243 - (void) provideService:(NSPasteboard *)pboard
4344 userData:(NSString *)data
4445 error:(NSString **)error;
45 - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard
46 types:(NSArray *)types;
46 - (BOOL) writeSelectionToPasteboard:(NSPasteboard *)pboard
47 types:(NSArray *)types;
4748
4849 @end
4950
103104 NSString *pboardString = nil, *pboardType = nil;
104105 NSArray *types = [pboard types];
105106 Tcl_Event *event;
107 (void)data;
108 (void)error;
106109
107110 /*
108111 * Get a string from the private pasteboard and copy it to the general
122125 [generalpasteboard declareTypes:[NSArray arrayWithObjects:pboardType, nil]
123126 owner:nil];
124127 [generalpasteboard setString:pboardString forType:pboardType];
125 event = ckalloc(sizeof(Tcl_Event));
128 event = (Tcl_Event *)ckalloc(sizeof(Tcl_Event));
126129 event->proc = ServicesEventProc;
127130 Tcl_QueueEvent((Tcl_Event *)event, TCL_QUEUE_TAIL);
128131 }
136139
137140 int
138141 TkMacOSXServices_Init(
139 Tcl_Interp *interp)
142 TCL_UNUSED(Tcl_Interp *))
140143 {
141144 /*
142145 * Initialize an instance of TkService and register it with the NSApp.
1313 #include "tkMacOSXPrivate.h"
1414 #include "tkMacOSXDebug.h"
1515 #include "tkMacOSXWm.h"
16 #include "tkMacOSXConstants.h"
1617
1718 /*
1819 #ifdef TK_MAC_DEBUG
3738 *
3839 * XDestroyWindow --
3940 *
40 * Dealocates the given X Window.
41 * Deallocates the given X Window.
4142 *
4243 * Results:
4344 * The window id is returned.
5051
5152 int
5253 XDestroyWindow(
53 Display *display, /* Display. */
54 TCL_UNUSED(Display *), /* Display. */
5455 Window window) /* Window. */
5556 {
56 MacDrawable *macWin = (MacDrawable *) window;
57 MacDrawable *macWin = (MacDrawable *)window;
5758
5859 /*
5960 * Remove any dangling pointers that may exist if the window we are
6768 if (!Tk_IsTopLevel(macWin->winPtr)) {
6869 TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
6970 if (macWin->winPtr->parentPtr != NULL) {
70 TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
71 TkMacOSXInvalClipRgns((Tk_Window)macWin->winPtr->parentPtr);
7172 }
7273 if (macWin->visRgn) {
7374 CFRelease(macWin->visRgn);
118119 *
119120 * XMapWindow --
120121 *
121 * Map the given X Window to the screen. See X window documentation for
122 * more details.
123 *
124 * Results:
125 * None.
126 *
127 * Side effects:
128 * The subwindow or toplevel may appear on the screen.
122 * This X11 stub maps the given X11 Window but does not update any of
123 * the Tk structures describing the window. Tk applications should
124 * never call this directly, but it is called by Tk_MapWindow and
125 * Tk_WmMapWindow.
126 *
127 * Results:
128 * Returns Success or BadWindow.
129 *
130 * Side effects:
131 * The subwindow or toplevel may appear on the screen. VisibilityNotify
132 * events are generated.
133 *
129134 *
130135 *----------------------------------------------------------------------
131136 */
135140 Display *display, /* Display. */
136141 Window window) /* Window. */
137142 {
138 MacDrawable *macWin = (MacDrawable *) window;
143 if (!window) {
144 return BadWindow;
145 }
146 MacDrawable *macWin = (MacDrawable *)window;
139147 TkWindow *winPtr = macWin->winPtr;
140 NSWindow *win = TkMacOSXDrawableWindow(window);
141 XEvent event;
148 NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
149 static Bool initialized = NO;
142150
143151 /*
144152 * Under certain situations it's possible for this function to be called
153161 }
154162
155163 display->request++;
156 winPtr->flags |= TK_MAPPED;
157164 if (Tk_IsTopLevel(winPtr)) {
158165 if (!Tk_IsEmbedded(winPtr)) {
166 TKContentView *view = [win contentView];
159167
160168 /*
161169 * We want to activate Tk when a toplevel is mapped but we must not
167175
168176 TkMacOSXApplyWindowAttributes(winPtr, win);
169177 [win setExcludedFromWindowsMenu:NO];
170 [NSApp activateIgnoringOtherApps:NO];
171 [[win contentView] setNeedsDisplay:YES];
172 if ([win canBecomeKeyWindow]) {
173 [win makeKeyAndOrderFront:NSApp];
174 } else {
175 [win orderFrontRegardless];
178 [NSApp activateIgnoringOtherApps:initialized];
179 [view addTkDirtyRect: [view bounds]];
180 if (initialized) {
181 if ([win canBecomeKeyWindow]) {
182 [win makeKeyAndOrderFront:NSApp];
183 } else {
184 [win orderFrontRegardless];
185 }
176186 }
177187 } else {
178188 TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
182192 * the window.
183193 */
184194
185 TkMacOSXInvalClipRgns((Tk_Window) contWinPtr);
195 TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
186196 TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
187197 }
188
189 TkMacOSXInvalClipRgns((Tk_Window) winPtr);
190
191 /*
192 * We only need to send the MapNotify event for toplevel windows.
193 */
194
195 event.xany.serial = LastKnownRequestProcessed(display);
196 event.xany.send_event = False;
197 event.xany.display = display;
198
199 event.xmap.window = window;
200 event.xmap.type = MapNotify;
201 event.xmap.event = window;
202 event.xmap.override_redirect = winPtr->atts.override_redirect;
203 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
198 TkMacOSXInvalClipRgns((Tk_Window)winPtr);
204199 } else {
205200
206201 /*
208203 * and redisplay the window.
209204 */
210205
211 TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
212 }
213
214 if ([NSApp isDrawing]) {
215 [[win contentView] setNeedsRedisplay:YES];
216 } else {
217 [[win contentView] setNeedsDisplay:YES];
206 TkMacOSXInvalClipRgns((Tk_Window)winPtr->parentPtr);
207 }
208
209 /*
210 * Mark the toplevel as needing to be redrawn, unless the window is being
211 * mapped while drawing is taking place.
212 */
213
214 TKContentView *view = [win contentView];
215 if (view != [NSView focusView]) {
216 [view addTkDirtyRect:[view bounds]];
218217 }
219218
220219 /*
221220 * Generate VisibilityNotify events for window and all mapped children.
222221 */
223222
224 event.xany.send_event = False;
225 event.xany.display = display;
226 event.xvisibility.type = VisibilityNotify;
227 event.xvisibility.state = VisibilityUnobscured;
228 NotifyVisibility(winPtr, &event);
223 if (initialized) {
224 XEvent event;
225 event.xany.send_event = False;
226 event.xany.display = display;
227 event.xvisibility.type = VisibilityNotify;
228 event.xvisibility.state = VisibilityUnobscured;
229 NotifyVisibility(winPtr, &event);
230 } else {
231 initialized = YES;
232 }
229233 return Success;
230234 }
231235
268272 *
269273 * XUnmapWindow --
270274 *
271 * Unmap the given X Window to the screen. See X window documentation for
272 * more details.
273 *
274 * Results:
275 * None.
275 * This X11 stub maps the given X11 Window but does not update any of
276 * The Tk structures describing the window. Tk applications should
277 * never call this directly, but it is called by Tk_UnmapWindow and
278 * Tk_WmUnmapWindow.
279 *
280 * Results:
281 * Always returns Success or BadWindow.
276282 *
277283 * Side effects:
278284 * The subwindow or toplevel may be removed from the screen.
285291 Display *display, /* Display. */
286292 Window window) /* Window. */
287293 {
288 MacDrawable *macWin = (MacDrawable *) window;
294 MacDrawable *macWin = (MacDrawable *)window;
289295 TkWindow *winPtr = macWin->winPtr;
290296 TkWindow *parentPtr = winPtr->parentPtr;
291 NSWindow *win = TkMacOSXDrawableWindow(window);
292 XEvent event;
293
297 NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
298
299 if (!window) {
300 return BadWindow;
301 }
294302 display->request++;
295303 if (Tk_IsTopLevel(winPtr)) {
296304 if (!Tk_IsEmbedded(winPtr) &&
297305 winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
298306 [win orderOut:nil];
299 }
300 TkMacOSXInvalClipRgns((Tk_Window) winPtr);
301
302 /*
303 * We only need to send the UnmapNotify event for toplevel windows.
304 */
305
306 event.xany.serial = LastKnownRequestProcessed(display);
307 event.xany.send_event = False;
308 event.xany.display = display;
309
310 event.xunmap.type = UnmapNotify;
311 event.xunmap.window = window;
312 event.xunmap.event = window;
313 event.xunmap.from_configure = false;
314 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
307 [win setExcludedFromWindowsMenu:YES];
308 }
309 TkMacOSXInvalClipRgns((Tk_Window)winPtr);
315310 } else {
316311 /*
317312 * Rebuild the visRgn clip region for the parent so it will be allowed
321316
322317 if (parentPtr && parentPtr->privatePtr->visRgn) {
323318 TkMacOSXInvalidateViewRegion(
324 TkMacOSXDrawableView(parentPtr->privatePtr),
319 TkMacOSXGetNSViewForDrawable(parentPtr->privatePtr),
325320 parentPtr->privatePtr->visRgn);
326321 }
327 TkMacOSXInvalClipRgns((Tk_Window) parentPtr);
322 TkMacOSXInvalClipRgns((Tk_Window)parentPtr);
328323 TkMacOSXUpdateClipRgn(parentPtr);
329324 }
330 winPtr->flags &= ~TK_MAPPED;
331 if ([NSApp isDrawing]) {
332 [[win contentView] setNeedsRedisplay:YES];
333 } else {
334 [[win contentView] setNeedsDisplay:YES];
325 TKContentView *view = [win contentView];
326 if (view != [NSView focusView]) {
327 [view addTkDirtyRect:[view bounds]];
335328 }
336329 return Success;
337330 }
360353 unsigned int width,
361354 unsigned int height)
362355 {
363 MacDrawable *macWin = (MacDrawable *) window;
356 MacDrawable *macWin = (MacDrawable *)window;
364357
365358 display->request++;
366359 if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
367 NSWindow *w = macWin->winPtr->wmInfoPtr->window;
360 TKWindow *w = (TKWindow *)macWin->winPtr->wmInfoPtr->window;
368361
369362 if (w) {
370 NSRect r = [w contentRectForFrameRect:[w frame]];
371
372 r.origin.y += r.size.height - height;
373 r.size.width = width;
374 r.size.height = height;
375 [w setFrame:[w frameRectForContentRect:r] display:YES];
363 if ([w styleMask] & NSFullScreenWindowMask) {
364 [w tkLayoutChanged];
365 } else {
366 NSRect r = [w contentRectForFrameRect:[w frame]];
367
368 r.origin.y += r.size.height - height;
369 r.size.width = width;
370 r.size.height = height;
371 [w setFrame:[w frameRectForContentRect:r] display:NO];
372 }
376373 }
377374 } else {
378375 MoveResizeWindow(macWin);
405402 unsigned int width,
406403 unsigned int height)
407404 {
408 MacDrawable *macWin = (MacDrawable *) window;
405 MacDrawable *macWin = (MacDrawable *)window;
409406
410407 display->request++;
411408 if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
428425 X + XOff, TkMacOSXZeroScreenHeight() - Y - YOff - Height,
429426 Width, Height);
430427
431 [w setFrame:[w frameRectForContentRect:r] display:YES];
428 [w setFrame:[w frameRectForContentRect:r] display:NO];
432429 }
433430 } else {
434431 MoveResizeWindow(macWin);
458455 Window window, /* Window. */
459456 int x, int y)
460457 {
461 MacDrawable *macWin = (MacDrawable *) window;
458 MacDrawable *macWin = (MacDrawable *)window;
462459
463460 display->request++;
464461 if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
496493 {
497494 int deltaX = 0, deltaY = 0, parentBorderwidth = 0;
498495 MacDrawable *macParent = NULL;
499 NSWindow *macWindow = TkMacOSXDrawableWindow((Drawable) macWin);
496 NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable((Drawable)macWin);
500497
501498 /*
502499 * Find the Parent window, for an embedded window it will be its container.
533530 if (macWindow) {
534531 TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
535532 if (macParent) {
536 TkMacOSXInvalClipRgns((Tk_Window) macParent->winPtr);
533 TkMacOSXInvalClipRgns((Tk_Window)macParent->winPtr);
537534 }
538535 }
539536 UpdateOffsets(macWin->winPtr, deltaX, deltaY);
601598 Display *display, /* Display. */
602599 Window window) /* Window. */
603600 {
604 MacDrawable *macWin = (MacDrawable *) window;
601 MacDrawable *macWin = (MacDrawable *)window;
605602
606603 display->request++;
607604 if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
614611 return Success;
615612 }
616613
617 #if 0
618614 /*
619615 *----------------------------------------------------------------------
620616 *
631627 *----------------------------------------------------------------------
632628 */
633629
634 void
630 int
635631 XLowerWindow(
636632 Display *display, /* Display. */
637633 Window window) /* Window. */
638634 {
639 MacDrawable *macWin = (MacDrawable *) window;
635 MacDrawable *macWin = (MacDrawable *)window;
640636
641637 display->request++;
642638 if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
643639 TkWmRestackToplevel(macWin->winPtr, Below, NULL);
644640 } else {
645 /*
641 /*
646642 * TODO: this should generate damage
647643 */
648644 }
649 }
650 #endif
645 return Success;
646 }
651647
652648 /*
653649 *----------------------------------------------------------------------
672668 Display *display, /* Display. */
673669 Window w, /* Window. */
674670 unsigned int value_mask,
675 XWindowChanges *values)
676 {
677 MacDrawable *macWin = (MacDrawable *) w;
671 TCL_UNUSED(XWindowChanges *))
672 {
673 MacDrawable *macWin = (MacDrawable *)w;
678674 TkWindow *winPtr = macWin->winPtr;
679675
680676 display->request++;
696692 */
697693
698694 if (value_mask & CWStackMode) {
699 NSView *view = TkMacOSXDrawableView(macWin);
700 Rect bounds;
701 NSRect r;
695 NSView *view = TkMacOSXGetNSViewForDrawable(macWin);
702696
703697 if (view) {
704 TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
705 TkMacOSXWinBounds(winPtr, &bounds);
706 r = NSMakeRect(bounds.left,
707 [view bounds].size.height - bounds.bottom,
708 bounds.right - bounds.left, bounds.bottom - bounds.top);
709 [view setNeedsDisplayInRect:r];
698 TkMacOSXInvalClipRgns((Tk_Window)winPtr->parentPtr);
699 TkpRedrawWidget((Tk_Window)winPtr);
710700 }
711701 }
712702
825815
826816 /*
827817 * Clip away the area of any windows that may obscure this window.
828 * For a non-toplevel window, first, clip to the parents visible
818 * For a non-toplevel window, first, clip to the parent's visible
829819 * clip region. Second, clip away any siblings that are higher in
830820 * the stacking order. For an embedded toplevel, just clip to the
831821 * container's visible clip region. Remember, we only allow one
858848 TkRegion r = TkCreateRegion();
859849 HIShapeRef visRgn;
860850
861 tkMacOSXEmbedHandler->getClipProc((Tk_Window) winPtr, r);
851 tkMacOSXEmbedHandler->getClipProc((Tk_Window)winPtr, r);
862852 visRgn = TkMacOSXGetNativeRegion(r);
863853 ChkErr(HIShapeIntersect, visRgn, rgn, rgn);
864854 CFRelease(visRgn);
865 TkpReleaseRegion(r);
855 TkDestroyRegion(r);
866856 }
867857
868858 /*
986976 static OSStatus
987977 InvalViewRect(
988978 int msg,
989 HIShapeRef rgn,
979 TCL_UNUSED(HIShapeRef),
990980 const CGRect *rect,
991981 void *ref)
992982 {
993983 static CGAffineTransform t;
994 NSView *view = ref;
984 TKContentView *view = ref;
985 NSRect dirtyRect;
995986
996987 if (!view) {
997988 return paramErr;
1002993 NSHeight([view bounds]));
1003994 break;
1004995 case kHIShapeEnumerateRect:
1005 [view setNeedsDisplayInRect:NSRectFromCGRect(
1006 CGRectApplyAffineTransform(*rect, t))];
996 dirtyRect = NSRectFromCGRect(CGRectApplyAffineTransform(*rect, t));
997 [view addTkDirtyRect:dirtyRect];
1007998 break;
1008999 }
10091000 return noErr;
10491040 if (macWin->flags & TK_CLIP_INVALID) {
10501041 TkMacOSXUpdateClipRgn(macWin->winPtr);
10511042 }
1052 TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(macWin),
1043 TkMacOSXInvalidateViewRegion(TkMacOSXGetNSViewForDrawable(macWin),
10531044 (flag == TK_WINDOW_ONLY) ? macWin->visRgn : macWin->aboveVisRgn);
10541045 }
10551046
10561047 /*
10571048 *----------------------------------------------------------------------
10581049 *
1059 * TkMacOSXDrawableWindow --
1050 * TkMacOSXGetNSWindowForDrawable --
10601051 *
10611052 * This function returns the NSWindow for a given X drawable.
10621053 *
10691060 *----------------------------------------------------------------------
10701061 */
10711062
1072 NSWindow *
1073 TkMacOSXDrawableWindow(
1063 void *
1064 TkMacOSXDrawable(
10741065 Drawable drawable)
10751066 {
1076 MacDrawable *macWin = (MacDrawable *) drawable;
1067 MacDrawable *macWin = (MacDrawable *)drawable;
10771068 NSWindow *result = nil;
10781069
10791070 if (!macWin || macWin->flags & TK_IS_PIXMAP) {
10891080 TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
10901081
10911082 if (contWinPtr) {
1092 result = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr);
1083 result = TkMacOSXGetNSWindowForDrawable((Drawable)contWinPtr->privatePtr);
10931084 }
10941085 }
10951086 return result;
10961087 }
1097
1098 void *
1099 TkMacOSXDrawable(
1100 Drawable drawable)
1101 {
1102 return TkMacOSXDrawableWindow(drawable);
1103 }
11041088
11051089 /*
11061090 *----------------------------------------------------------------------
11071091 *
11081092 * TkMacOSXGetDrawablePort --
11091093 *
1110 * This function returns the Graphics Port for a given X drawable.
1094 * This function only exists because it is listed in the stubs table.
1095 * It is useless.
11111096 *
11121097 * Results:
11131098 * NULL.
11201105
11211106 void *
11221107 TkMacOSXGetDrawablePort(
1108 TCL_UNUSED(Drawable))
1109 {
1110 return NULL;
1111 }
1112
1113 /*
1114 *----------------------------------------------------------------------
1115 *
1116 * TkMacOSXGetNSViewForDrawable/TkMacOSXGetRootControl --
1117 *
1118 * The function name TkMacOSXGetRootControl is being preserved only
1119 * because it exists in a stubs table. Nobody knows what it means to
1120 * get a "RootControl". The macro TkMacOSXGetNSViewForDrawable calls
1121 * this function and should always be used rather than directly using
1122 * the obscure official name of this function.
1123 *
1124 * It returns the NSView for a given X drawable in the case that the
1125 * drawable is a window. If the drawable is a pixmap it returns nil.
1126 *
1127 * Results:
1128 * A NSView* or nil.
1129 *
1130 * Side effects:
1131 * None.
1132 *
1133 *----------------------------------------------------------------------
1134 */
1135
1136 void *
1137 TkMacOSXGetRootControl(
11231138 Drawable drawable)
11241139 {
1125 return NULL;
1126 }
1127
1128 /*
1129 *----------------------------------------------------------------------
1130 *
1131 * TkMacOSXDrawableView --
1132 *
1133 * This function returns the NSView for a given X drawable.
1134 *
1135 * Results:
1136 * A NSView* or nil.
1137 *
1138 * Side effects:
1139 * None.
1140 *
1141 *----------------------------------------------------------------------
1142 */
1143
1144 NSView *
1145 TkMacOSXDrawableView(
1146 MacDrawable *macWin)
1147 {
1148 NSView *result = nil;
1140 void *result = NULL;
1141 MacDrawable *macWin = (MacDrawable *)drawable;
11491142
11501143 if (!macWin) {
1151 result = nil;
1144 result = NULL;
11521145 } else if (!macWin->toplevel) {
11531146 result = macWin->view;
11541147 } else if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
11571150 TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
11581151
11591152 if (contWinPtr) {
1160 result = TkMacOSXDrawableView(contWinPtr->privatePtr);
1153 result = TkMacOSXGetRootControl((Drawable)contWinPtr->privatePtr);
11611154 }
11621155 }
11631156 return result;
1164 }
1165
1166 /*
1167 *----------------------------------------------------------------------
1168 *
1169 * TkMacOSXGetRootControl --
1170 *
1171 * This function returns the NSView for a given X drawable.
1172 *
1173 * Results:
1174 * A NSView* .
1175 *
1176 * Side effects:
1177 * None.
1178 *
1179 *----------------------------------------------------------------------
1180 */
1181
1182 void *
1183 TkMacOSXGetRootControl(
1184 Drawable drawable)
1185 {
1186 /*
1187 * will probably need to fix this up for embedding
1188 */
1189
1190 return TkMacOSXDrawableView((MacDrawable *) drawable);
11911157 }
11921158
11931159 /*
12531219 childPtr = winPtr->childList;
12541220 while (childPtr) {
12551221 if (!Tk_IsTopLevel(childPtr)) {
1256 TkMacOSXInvalClipRgns((Tk_Window) childPtr);
1222 TkMacOSXInvalClipRgns((Tk_Window)childPtr);
12571223 }
12581224 childPtr = childPtr->nextPtr;
12591225 }
12661232 childPtr = TkpGetOtherWindow(winPtr);
12671233
12681234 if (childPtr) {
1269 TkMacOSXInvalClipRgns((Tk_Window) childPtr);
1235 TkMacOSXInvalClipRgns((Tk_Window)childPtr);
12701236 }
12711237
12721238 /*
12801246 *
12811247 * TkMacOSXWinBounds --
12821248 *
1283 * Given a Tk window this function determines the windows bounds in
1249 * Given a Tk window this function determines the window's bounds in
12841250 * relation to the Macintosh window's coordinate system. This is also the
12851251 * same coordinate system as the Tk toplevel window in which this window
12861252 * is contained.
12891255 * None.
12901256 *
12911257 * Side effects:
1292 * None.
1258 * Fills in a Rect.
12931259 *
12941260 *----------------------------------------------------------------------
12951261 */
13121278 *
13131279 * TkMacOSXWinCGBounds --
13141280 *
1315 * Given a Tk window this function determines the windows bounds in
1316 * relation to the Macintosh window's coordinate system. This is also the
1317 * same coordinate system as the Tk toplevel window in which this window
1318 * is contained.
1319 *
1320 * Results:
1321 * None.
1322 *
1323 * Side effects:
1324 * None.
1281 * Given a Tk window this function determines the window's bounds in
1282 * the coordinate system of the Tk toplevel window in which this window
1283 * is contained. This fills in a CGRect struct.
1284 *
1285 * Results:
1286 * None.
1287 *
1288 * Side effects:
1289 * Fill in a CGRect.
13251290 *
13261291 *----------------------------------------------------------------------
13271292 */
13351300 bounds->origin.y = winPtr->privatePtr->yOff;
13361301 bounds->size.width = winPtr->changes.width;
13371302 bounds->size.height = winPtr->changes.height;
1303 }
1304 /*
1305 *----------------------------------------------------------------------
1306 *
1307 * TkMacOSXWinNSBounds --
1308 *
1309 * Given a Tk window this function determines the window's bounds in
1310 * the coordinate system of the TKContentView in which this Tk window
1311 * is contained, which has the origin at the lower left corner. This
1312 * fills in an NSRect struct and requires the TKContentView as a
1313 * parameter
1314 *
1315 * Results:
1316 * None.
1317 *
1318 * Side effects:
1319 * Fills in an NSRect.
1320 *
1321 *----------------------------------------------------------------------
1322 */
1323
1324 void
1325 TkMacOSXWinNSBounds(
1326 TkWindow *winPtr,
1327 NSView *view,
1328 NSRect *bounds)
1329 {
1330 bounds->size.width = winPtr->changes.width;
1331 bounds->size.height = winPtr->changes.height;
1332 bounds->origin.x = winPtr->privatePtr->xOff;
1333 bounds->origin.y = ([view bounds].size.height -
1334 bounds->size.height -
1335 winPtr->privatePtr->yOff);
13381336 }
13391337
13401338 /*
14161414 Pixmap
14171415 Tk_GetPixmap(
14181416 Display *display, /* Display for new pixmap (can be null). */
1419 Drawable d, /* Drawable where pixmap will be used (ignored). */
1417 TCL_UNUSED(Drawable), /* Drawable where pixmap will be used (ignored). */
14201418 int width, /* Dimensions of pixmap. */
14211419 int height,
14221420 int depth) /* Bits per pixel for pixmap. */
14261424 if (display != NULL) {
14271425 display->request++;
14281426 }
1429 macPix = ckalloc(sizeof(MacDrawable));
1427 macPix = (MacDrawable *)ckalloc(sizeof(MacDrawable));
14301428 macPix->winPtr = NULL;
14311429 macPix->xOff = 0;
14321430 macPix->yOff = 0;
14641462 Display *display, /* Display. */
14651463 Pixmap pixmap) /* Pixmap to destroy */
14661464 {
1467 MacDrawable *macPix = (MacDrawable *) pixmap;
1465 MacDrawable *macPix = (MacDrawable *)pixmap;
14681466
14691467 display->request++;
14701468 if (macPix->context) {
1313
1414 #include "tkMacOSXPrivate.h"
1515 #include "tkMacOSXConstants.h"
16 #include "tkMacOSXWm.h"
17
1618
1719 /*
1820 * Forward declarations of procedures defined later in this file:
2325 int objc, Tcl_Obj *const objv[]);
2426 #endif
2527 static int PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp,
26 int objc, Tcl_Obj *const objv[]);
28 int objc, Tcl_Obj *const *objv);
29 static int InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp,
30 int objc, Tcl_Obj *const *objv);
31 static int MenuBarHeightObjCmd (ClientData dummy, Tcl_Interp *interp,
32 int objc, Tcl_Obj *const *objv);
2733
2834
2935 /*
5561 Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd, NULL, NULL);
5662 #endif
5763 Tcl_CreateObjCommand(interp, "pressbutton", PressButtonObjCmd, NULL, NULL);
58
64 Tcl_CreateObjCommand(interp, "injectkeyevent", InjectKeyEventObjCmd, NULL, NULL);
65 Tcl_CreateObjCommand(interp, "menubarheight", MenuBarHeightObjCmd, NULL, NULL);
5966 return TCL_OK;
6067 }
6168
9299 /*
93100 *----------------------------------------------------------------------
94101 *
102 * MenuBarHeightObjCmd --
103 *
104 * This procedure calls [NSMenu menuBarHeight] and returns the result
105 * as an integer. Windows can never be placed to overlap the MenuBar,
106 * so tests need to be aware of its size.
107 *
108 * Results:
109 * A standard Tcl result.
110 *
111 * Side effects:
112 * None.
113 *
114 *----------------------------------------------------------------------
115 */
116
117 static int
118 MenuBarHeightObjCmd(
119 TCL_UNUSED(void *), /* Not used. */
120 Tcl_Interp *interp, /* Not used. */
121 TCL_UNUSED(int), /* Not used. */
122 TCL_UNUSED(Tcl_Obj *const *)) /* Not used. */
123 {
124 static int height = 0;
125 if (height == 0) {
126 height = (int) [[NSApp mainMenu] menuBarHeight];
127 }
128 Tcl_SetObjResult(interp, Tcl_NewIntObj(height));
129 return TCL_OK;
130 }
131
132 /*
133 *----------------------------------------------------------------------
134 *
95135 * TkTestLogDisplay --
96136 *
97137 * The test image display procedure calls this to determine whether it
98 * should write a log message recording that it has being run. On OSX
99 * 10.14 and later, only calls to the display procedure which occur inside
100 * of the drawRect method should be logged, since those are the only ones
101 * which actually draw anything. On earlier systems the opposite is true.
102 * The calls from within the drawRect method are redundant, since the
103 * first time the display procedure is run it will do the drawing and that
104 * first call will usually not occur inside of drawRect.
105 *
106 * Results:
107 * On OSX 10.14 and later, returns true if and only if called from
108 * within [NSView drawRect]. On earlier systems returns false if
109 * and only if called from with [NSView drawRect].
138 * should write a log message recording that it has being run.
139 *
140 * Results:
141 * Returns true if and only if the NSView of the drawable is the
142 * current focusView, which on 10.14 and newer systems can only be the
143 * case when within [NSView drawRect].
110144 *
111145 * Side effects:
112146 * None
114148 *----------------------------------------------------------------------
115149 */
116150 MODULE_SCOPE Bool
117 TkTestLogDisplay(void) {
118 if ([NSApp macMinorVersion] >= 14) {
119 return [NSApp isDrawing];
151 TkTestLogDisplay(
152 Drawable drawable)
153 {
154 MacDrawable *macWin = (MacDrawable *)drawable;
155 NSWindow *win = nil;
156 if (macWin->toplevel && macWin->toplevel->winPtr &&
157 macWin->toplevel->winPtr->wmInfoPtr &&
158 macWin->toplevel->winPtr->wmInfoPtr->window) {
159 win = macWin->toplevel->winPtr->wmInfoPtr->window;
160 } else if (macWin->winPtr && macWin->winPtr->wmInfoPtr &&
161 macWin->winPtr->wmInfoPtr->window) {
162 win = macWin->winPtr->wmInfoPtr->window;
163 }
164 if (win) {
165 return ([win contentView] == [NSView focusView]);
120166 } else {
121 return ![NSApp isDrawing];
167 return True;
122168 }
123169 }
124170
128174 * PressButtonObjCmd --
129175 *
130176 * This Tcl command simulates a button press at a specific screen
131 * location. It injects NSEvents into the NSApplication event queue,
132 * as opposed to adding events to the Tcl queue as event generate
133 * would do. One application is for testing the grab command.
177 * location. It injects NSEvents into the NSApplication event queue, as
178 * opposed to adding events to the Tcl queue as event generate would do.
179 * One application is for testing the grab command. These events have
180 * their unused context property set to 1 as a signal indicating that they
181 * should not be ignored by [NSApp tkProcessMouseEvent].
134182 *
135183 * Results:
136184 * A standard Tcl result.
141189 *----------------------------------------------------------------------
142190 */
143191
144 /* ARGSUSED */
145192 static int
146193 PressButtonObjCmd(
147 ClientData clientData,
194 TCL_UNUSED(void *),
148195 Tcl_Interp *interp,
149196 int objc,
150197 Tcl_Obj *const objv[])
151198 {
152 int x, y, i, value, wNum;
199 int x = 0, y = 0, i, value;
200 NSInteger signal = -1;
153201 CGPoint pt;
154202 NSPoint loc;
155203 NSEvent *motion, *press, *release;
183231 pt.x = loc.x = x;
184232 pt.y = y;
185233 loc.y = ScreenHeight - y;
186 wNum = 0;
234
235 /*
236 * We set the window number and the eventNumber to -1 as a signal to
237 * processMouseEvent.
238 */
239
187240 CGWarpMouseCursorPosition(pt);
188241 motion = [NSEvent mouseEventWithType:NSMouseMoved
189242 location:loc
190243 modifierFlags:0
191244 timestamp:GetCurrentEventTime()
192 windowNumber:wNum
245 windowNumber:signal
193246 context:nil
194 eventNumber:0
247 eventNumber:signal
195248 clickCount:1
196249 pressure:0.0];
197250 [NSApp postEvent:motion atStart:NO];
199252 location:loc
200253 modifierFlags:0
201254 timestamp:GetCurrentEventTime()
202 windowNumber:wNum
255 windowNumber:signal
203256 context:nil
204 eventNumber:1
257 eventNumber:signal
205258 clickCount:1
206259 pressure:0.0];
207260 [NSApp postEvent:press atStart:NO];
209262 location:loc
210263 modifierFlags:0
211264 timestamp:GetCurrentEventTime()
212 windowNumber:wNum
265 windowNumber:signal
213266 context:nil
214 eventNumber:2
267 eventNumber:signal
215268 clickCount:1
216 pressure:0.0];
269 pressure:-1.0];
217270 [NSApp postEvent:release atStart:NO];
218271 return TCL_OK;
219272 }
220273
221
274 static int
275 InjectKeyEventObjCmd(
276 TCL_UNUSED(void *),
277 Tcl_Interp *interp,
278 int objc,
279 Tcl_Obj *const objv[])
280 {
281 static const char *const optionStrings[] = {
282 "press", "release", "flagschanged", NULL};
283 NSUInteger types[3] = {NSKeyDown, NSKeyUp, NSFlagsChanged};
284 static const char *const argStrings[] = {
285 "-shift", "-control", "-option", "-command", "-function", "-x", "-y", NULL};
286 enum args {KEYEVENT_SHIFT, KEYEVENT_CONTROL, KEYEVENT_OPTION, KEYEVENT_COMMAND,
287 KEYEVENT_FUNCTION, KEYEVENT_X, KEYEVENT_Y};
288 int i, index, keysym, mods = 0, x = 0, y = 0;
289 NSString *chars = nil, *unmod = nil, *upper, *lower;
290 NSEvent *keyEvent;
291 NSUInteger type;
292 MacKeycode macKC;
293
294 if (objc < 3) {
295 wrongArgs:
296 Tcl_WrongNumArgs(interp, 1, objv, "option keysym ?arg?");
297 return TCL_ERROR;
298 }
299 if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
300 &index) != TCL_OK) {
301 return TCL_ERROR;
302 }
303 type = types[index];
304 if (Tcl_GetIntFromObj(interp, objv[2], &keysym) != TCL_OK) {
305 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
306 "keysym must be an integer"));
307 Tcl_SetErrorCode(interp, "TK", "TEST", "INJECT", "KEYSYM", NULL);
308 return TCL_ERROR;
309 }
310 macKC.uint = XKeysymToKeycode(NULL, keysym);
311 for (i = 3; i < objc; i++) {
312 if (Tcl_GetIndexFromObjStruct(interp, objv[i], argStrings,
313 sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
314 return TCL_ERROR;
315 }
316 switch ((enum args) index) {
317 case KEYEVENT_SHIFT:
318 mods |= NSShiftKeyMask;
319 break;
320 case KEYEVENT_CONTROL:
321 mods |= NSControlKeyMask;
322 break;
323 case KEYEVENT_OPTION:
324 mods |= NSAlternateKeyMask;
325 break;
326 case KEYEVENT_COMMAND:
327 mods |= NSCommandKeyMask;
328 break;
329 case KEYEVENT_FUNCTION:
330 mods |= NSFunctionKeyMask;
331 break;
332 case KEYEVENT_X:
333 if (++i >= objc) {
334 goto wrongArgs;
335 }
336 if (Tcl_GetIntFromObj(interp,objv[i], &x) != TCL_OK) {
337 return TCL_ERROR;
338 }
339 break;
340 case KEYEVENT_Y:
341 if (++i >= objc) {
342 goto wrongArgs;
343 }
344 if (Tcl_GetIntFromObj(interp,objv[i], &y) != TCL_OK) {
345 return TCL_ERROR;
346 }
347 break;
348 }
349 }
350 if (type != NSFlagsChanged) {
351 UniChar keychar = macKC.v.keychar;
352 chars = [[NSString alloc] initWithCharacters: &keychar length:1];
353 upper = [chars uppercaseString];
354 lower = [chars lowercaseString];
355 if (![upper isEqual: lower] && [chars isEqual: upper]) {
356 mods |= NSShiftKeyMask;
357 }
358 if (mods & NSShiftKeyMask) {
359 chars = upper;
360 unmod = lower;
361 macKC.v.o_s |= INDEX_SHIFT;
362 } else {
363 unmod = chars;
364 }
365 if (macKC.v.o_s & INDEX_OPTION) {
366 mods |= NSAlternateKeyMask;
367 }
368 }
369 keyEvent = [NSEvent keyEventWithType:type
370 location:NSMakePoint(x, y)
371 modifierFlags:mods
372 timestamp:GetCurrentEventTime()
373 windowNumber:0
374 context:nil
375 characters:chars
376 charactersIgnoringModifiers:unmod
377 isARepeat:NO
378 keyCode:macKC.v.virtual];
379 [NSApp postEvent:keyEvent atStart:NO];
380 return TCL_OK;
381 }
222382 /*
223383 * Local Variables:
224384 * mode: objc
2929 * Declaration of functions used only in this file
3030 */
3131
32 static int GenerateUpdates(HIShapeRef updateRgn,
33 CGRect *updateBounds, TkWindow *winPtr);
32 static int GenerateUpdates(
33 CGRect *updateBounds, TkWindow *winPtr);
3434 static int GenerateActivateEvents(TkWindow *winPtr,
3535 int activeFlag);
36 static void DoWindowActivate(ClientData clientData);
3736
3837 #pragma mark TKApplication(TKWindowEvent)
3938
40 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
39 extern NSString *NSWindowDidOrderOnScreenNotification;
4140 extern NSString *NSWindowWillOrderOnScreenNotification;
42 extern NSString *NSWindowDidOrderOnScreenNotification;
41
42 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
4343 extern NSString *NSWindowDidOrderOffScreenNotification;
4444 #endif
4545
8989 height = bounds.size.height - wmPtr->yInParent;
9090 flags |= TK_SIZE_CHANGED;
9191 }
92 if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
93 /*
94 * Propagate geometry changes immediately.
95 */
96
97 flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY;
98 }
99
100 TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags);
92 /*
93 * Propagate geometry changes immediately.
94 */
95
96 flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY;
97 TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width, height, flags);
10198 }
10299
103100 }
113110 if (winPtr) {
114111 winPtr->wmInfoPtr->hints.initial_state =
115112 TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState;
116 Tk_MapWindow((Tk_Window) winPtr);
117 if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
118
119 /*
120 * Process all Tk events generated by Tk_MapWindow().
121 */
122
123 while (Tcl_ServiceEvent(0)) {}
124 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}
125
126 /*
127 * NSWindowDidDeminiaturizeNotification is received after
128 * NSWindowDidBecomeKeyNotification, so activate manually
129 */
130
131 GenerateActivateEvents(winPtr, 1);
132 } else {
133 Tcl_DoWhenIdle(DoWindowActivate, winPtr);
134 }
113 Tk_MapWindow((Tk_Window)winPtr);
114
115 /*
116 * Process all Tk events generated by Tk_MapWindow().
117 */
118
119 while (Tcl_ServiceEvent(0)) {}
120 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
121
122 /*
123 * NSWindowDidDeminiaturizeNotification is received after
124 * NSWindowDidBecomeKeyNotification, so activate manually
125 */
126
127 GenerateActivateEvents(winPtr, 1);
135128 }
136129 }
137130
138131 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window
139132 defaultFrame:(NSRect)newFrame
140133 {
134 (void)window;
135
141136 /*
142137 * This method needs to be implemented in order for [NSWindow isZoomed] to
143138 * give the correct answer. But it suffices to always validate every
150145 - (NSSize)window:(NSWindow *)window
151146 willUseFullScreenContentSize:(NSSize)proposedSize
152147 {
148 (void)window;
149
153150 /*
154151 * We don't need to change the proposed size, but we do need to implement
155152 * this method. Otherwise the full screen window will be sized to the
184181 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
185182
186183 if (winPtr) {
187 Tk_UnmapWindow((Tk_Window) winPtr);
184 Tk_UnmapWindow((Tk_Window)winPtr);
188185 }
189186 }
190187
196193 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
197194
198195 if (winPtr) {
199 TkGenWMDestroyEvent((Tk_Window) winPtr);
196 TkGenWMDestroyEvent((Tk_Window)winPtr);
200197 }
201198
202199 /*
207204 return (winPtr ? NO : YES);
208205 }
209206
207 - (void) windowBecameVisible: (NSNotification *) notification
208 {
209 NSWindow *window = [notification object];
210 TkWindow *winPtr = TkMacOSXGetTkWindow(window);
211 if (winPtr) {
212 TKContentView *view = [window contentView];
213
214 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
215 if (@available(macOS 10.15, *)) {
216 [view viewDidChangeEffectiveAppearance];
217 }
218 #endif
219 [view addTkDirtyRect:[view bounds]];
220 Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL);
221 Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL);
222 }
223 }
224
225 - (void) windowMapped: (NSNotification *) notification
226 {
227 NSWindow *w = [notification object];
228 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
229
230 if (winPtr) {
231 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
232 }
233 }
234
210235 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
211236
212237 - (void) windowDragStart: (NSNotification *) notification
220245 //BOOL start = [[notification name] isEqualToString:NSWindowWillStartLiveResizeNotification];
221246 }
222247
223 - (void) windowMapped: (NSNotification *) notification
248 - (void) windowUnmapped: (NSNotification *) notification
224249 {
225250 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
226251 NSWindow *w = [notification object];
227252 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
228253
229254 if (winPtr) {
230 //Tk_MapWindow((Tk_Window) winPtr);
231 }
232 }
233
234 - (void) windowBecameVisible: (NSNotification *) notification
235 {
236 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
237 }
238
239 - (void) windowUnmapped: (NSNotification *) notification
240 {
241 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
242 NSWindow *w = [notification object];
243 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
244
245 if (winPtr) {
246 //Tk_UnmapWindow((Tk_Window) winPtr);
255 //Tk_UnmapWindow((Tk_Window)winPtr);
247256 }
248257 }
249258
262271 observe(NSWindowDidResizeNotification, windowBoundsChanged:);
263272 observe(NSWindowDidDeminiaturizeNotification, windowExpanded:);
264273 observe(NSWindowDidMiniaturizeNotification, windowCollapsed:);
274 observe(NSWindowWillOrderOnScreenNotification, windowMapped:);
275 observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:);
265276
266277 #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070)
267278 observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:);
272283 observe(NSWindowWillMoveNotification, windowDragStart:);
273284 observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:);
274285 observe(NSWindowDidEndLiveResizeNotification, windowLiveResize:);
275 observe(NSWindowWillOrderOnScreenNotification, windowMapped:);
276 observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:);
277286 observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:);
278287 #endif
279288 #undef observe
287296
288297 - (void) applicationActivate: (NSNotification *) notification
289298 {
299 (void)notification;
300
290301 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
291302 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
292303 #endif
311322
312323 - (void) applicationDeactivate: (NSNotification *) notification
313324 {
325 (void)notification;
326
314327 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
315328 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
316329 #endif
330
331 /*
332 * To prevent zombie windows on systems with a TouchBar, set the key window
333 * to nil if the current key window is not visible. This allows a closed
334 * Help or About window to be deallocated so it will not reappear as a
335 * zombie when the app is reactivated.
336 */
337
338 NSWindow *keywindow = [NSApp keyWindow];
339 if (keywindow && ![keywindow isVisible]) {
340 [NSApp _setKeyWindow:nil];
341 [NSApp _setMainWindow:nil];
342 }
343
317344 }
318345
319346 - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender
320347 hasVisibleWindows:(BOOL)flag
321348 {
349 (void)sender;
350 (void)flag;
351
322352 /*
323353 * Allowing the default response means that withdrawn windows will get
324354 * displayed on the screen with unresponsive title buttons. We don't
351381
352382 - (void) displayChanged: (NSNotification *) notification
353383 {
384 (void)notification;
385
354386 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
355387 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
356388 #endif
367399 /*
368400 *----------------------------------------------------------------------
369401 *
370 * TkpAppIsDrawing --
402 * TkpWillDrawWidget --
371403 *
372404 * A widget display procedure can call this to determine whether it is
373 * being run inside of the drawRect method. This is needed for some tests,
374 * especially of the Text widget, which record data in a global Tcl
375 * variable and assume that display procedures will be run in a
376 * predictable sequence as Tcl idle tasks.
405 * being run inside of the drawRect method. If not, it may be desirable
406 * for the display procedure to simply clear the REDRAW_PENDING flag
407 * and return. The widget can be recorded in order to schedule a
408 * redraw, via and Expose event, from within drawRect.
409 *
410 * This is also needed for some tests, especially of the Text widget,
411 * which record data in a global Tcl variable and assume that display
412 * procedures will be run in a predictable sequence as Tcl idle tasks.
377413 *
378414 * Results:
379 * True only while running the drawRect method of a TKContentView;
415 * True if called from the drawRect method of a TKContentView with
416 * tkwin NULL or pointing to a widget in the current focusView.
380417 *
381418 * Side effects:
382 * None
383 *
384 *----------------------------------------------------------------------
385 */
386
387 MODULE_SCOPE Bool
388 TkpAppIsDrawing(void) {
389 return [NSApp isDrawing];
419 * Currently none. One day the tkwin parameter may be recorded to
420 * handle redrawing the widget later.
421 *
422 *----------------------------------------------------------------------
423 */
424
425 int
426 TkpWillDrawWidget(Tk_Window tkwin) {
427 int result;
428 if (tkwin) {
429 TkWindow *winPtr = (TkWindow *)tkwin;
430 TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(
431 (Drawable)winPtr->privatePtr);
432 result = ([NSApp isDrawing] && view == [NSView focusView]);
433 #if 0
434 printf("TkpWillDrawWidget: %s %d %d \n", Tk_PathName(tkwin),
435 [NSApp isDrawing], (view == [NSView focusView]));
436 if (!result) {
437 NSRect dirtyRect;
438 TkMacOSXWinNSBounds(winPtr, view, &dirtyRect);
439 printf("TkpAppCanDraw: dirtyRect for %s is %s\n",
440 Tk_PathName(tkwin),
441 NSStringFromRect(dirtyRect).UTF8String);
442 [view addTkDirtyRect:dirtyRect];
443 }
444 #endif
445 } else {
446 result = [NSApp isDrawing];
447 }
448 return result;
390449 }
391450
392451 /*
394453 *
395454 * GenerateUpdates --
396455 *
397 * Given a Macintosh update region and a Tk window this function geneates
456 * Given an update rectangle and a Tk window, this function generates
398457 * an X Expose event for the window if it meets the update region. The
399 * function will then recursivly have each damaged window generate Expose
458 * function will then recursively have each damaged window generate Expose
400459 * events for its child windows.
401460 *
402461 * Results:
403462 * True if event(s) are generated - false otherwise.
404463 *
405464 * Side effects:
406 * Additional events may be place on the Tk event queue.
465 * Additional events may be placed on the Tk event queue.
407466 *
408467 *----------------------------------------------------------------------
409468 */
410469
411470 static int
412471 GenerateUpdates(
413 HIShapeRef updateRgn,
414472 CGRect *updateBounds,
415473 TkWindow *winPtr)
416474 {
417475 TkWindow *childPtr;
418476 XEvent event;
419477 CGRect bounds, damageBounds;
420 HIShapeRef boundsRgn, damageRgn;
421478
422479 TkMacOSXWinCGBounds(winPtr, &bounds);
423480 if (!CGRectIntersectsRect(bounds, *updateBounds)) {
424481 return 0;
425482 }
426 if (!HIShapeIntersectsRect(updateRgn, &bounds)) {
427 return 0;
428 }
429
430 /*
431 * Compute the bounding box of the area that the damage occured in.
432 */
433
434 boundsRgn = HIShapeCreateWithRect(&bounds);
435 damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn);
436 if (HIShapeIsEmpty(damageRgn)) {
437 CFRelease(damageRgn);
438 CFRelease(boundsRgn);
439 return 0;
440 }
441 HIShapeGetBounds(damageRgn, &damageBounds);
442
443 CFRelease(damageRgn);
444 CFRelease(boundsRgn);
445
483
484 /*
485 * Compute the bounding box of the area that the damage occurred in.
486 */
487
488 damageBounds = CGRectIntersection(bounds, *updateBounds);
446489 event.xany.serial = LastKnownRequestProcessed(Tk_Display(winPtr));
447490 event.xany.send_event = false;
448491 event.xany.window = Tk_WindowId(winPtr);
456499 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
457500
458501 #ifdef TK_MAC_DEBUG_DRAWING
459 TKLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x,
502 TKLog(@"Exposed %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x,
460503 event.xexpose.y, event.xexpose.width, event.xexpose.height);
461504 #endif
462505
469512 if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) {
470513 continue;
471514 }
472 GenerateUpdates(updateRgn, updateBounds, childPtr);
515 GenerateUpdates(updateBounds, childPtr);
473516 }
474517
475518 /*
479522 if (Tk_IsContainer(winPtr)) {
480523 childPtr = TkpGetOtherWindow(winPtr);
481524 if (childPtr != NULL && Tk_IsMapped(childPtr)) {
482 GenerateUpdates(updateRgn, updateBounds, childPtr);
525 GenerateUpdates(updateBounds, childPtr);
483526 }
484527
485528 /*
493536 /*
494537 *----------------------------------------------------------------------
495538 *
496 * GenerateActivateEvents --
497 *
498 * Given a Macintosh window activate event this function generates all the
499 * X Activate events needed by Tk.
539 * TkMacOSXGenerateFocusEvent --
540 *
541 * Given a Macintosh window activate event this function generates all
542 * the X Focus events needed by Tk.
500543 *
501544 * Results:
502545 * True if event(s) are generated - false otherwise.
503546 *
504547 * Side effects:
505 * Additional events may be place on the Tk event queue.
506 *
507 *----------------------------------------------------------------------
508 */
509
510 int
511 GenerateActivateEvents(
512 TkWindow *winPtr,
513 int activeFlag)
514 {
515 TkGenerateActivateEvents(winPtr, activeFlag);
516 if (activeFlag || ![NSApp isActive]) {
517 TkMacOSXGenerateFocusEvent(winPtr, activeFlag);
518 }
519 return true;
520 }
521
522 /*
523 *----------------------------------------------------------------------
524 *
525 * DoWindowActivate --
526 *
527 * Idle handler that calls GenerateActivateEvents().
528 *
529 * Results:
530 * None.
531 *
532 * Side effects:
533 * Additional events may be place on the Tk event queue.
534 *
535 *----------------------------------------------------------------------
536 */
537
538 void
539 DoWindowActivate(
540 ClientData clientData)
541 {
542 GenerateActivateEvents(clientData, 1);
543 }
544
545 /*
546 *----------------------------------------------------------------------
547 *
548 * TkMacOSXGenerateFocusEvent --
549 *
550 * Given a Macintosh window activate event this function generates all
551 * the X Focus events needed by Tk.
552 *
553 * Results:
554 * True if event(s) are generated - false otherwise.
555 *
556 * Side effects:
557 * Additional events may be place on the Tk event queue.
558 *
559 *----------------------------------------------------------------------
560 */
561
562 MODULE_SCOPE int
548 * Additional events may be placed on the Tk event queue.
549 *
550 *----------------------------------------------------------------------
551 */
552
553 static int
563554 TkMacOSXGenerateFocusEvent(
564555 TkWindow *winPtr, /* Root X window for event. */
565556 int activeFlag)
598589 return true;
599590 }
600591
592 /*
593 *----------------------------------------------------------------------
594 *
595 * GenerateActivateEvents --
596 *
597 * Given a Macintosh window activate event this function generates all the
598 * X Activate events needed by Tk.
599 *
600 * Results:
601 * True if event(s) are generated - false otherwise.
602 *
603 * Side effects:
604 * Additional events may be placed on the Tk event queue.
605 *
606 *----------------------------------------------------------------------
607 */
608
609 int
610 GenerateActivateEvents(
611 TkWindow *winPtr,
612 int activeFlag)
613 {
614 TkGenerateActivateEvents(winPtr, activeFlag);
615 if (activeFlag || ![NSApp isActive]) {
616 TkMacOSXGenerateFocusEvent(winPtr, activeFlag);
617 }
618 return true;
619 }
620
601621 /*
602622 *----------------------------------------------------------------------
603623 *
712732
713733 /*
714734 * Now set up the changes structure. Under X we wait for the
715 * ConfigureNotify to set these values. On the Mac we know imediatly that
735 * ConfigureNotify to set these values. On the Mac we know immediately that
716736 * this is what we want - so we just set them. However, we need to make
717737 * sure the windows clipping region is marked invalid so the change is
718738 * visible to the subwindow.
803823 if (result != TCL_OK) {
804824 Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
805825 "\n (command for \"%s\" window manager protocol)",
806 Tk_GetAtomName((Tk_Window) winPtr, protocol)));
826 Tk_GetAtomName((Tk_Window)winPtr, protocol)));
807827 Tcl_BackgroundException(interp, result);
808828 }
809829 Tcl_Release(interp);
817837 * message then just destroy the window.
818838 */
819839
820 if (protocol == Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW")) {
821 Tk_DestroyWindow((Tk_Window) winPtr);
840 if (protocol == Tk_InternAtom((Tk_Window)winPtr, "WM_DELETE_WINDOW")) {
841 Tk_DestroyWindow((Tk_Window)winPtr);
822842 }
823843 }
824844
886906
887907 static Tk_RestrictAction
888908 ConfigureRestrictProc(
889 ClientData arg,
909 TCL_UNUSED(void *),
890910 XEvent *eventPtr)
891911 {
892912 return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
893913 }
894914
895 /*
896 * If a window gets mapped inside the drawRect method, this will be run as an
897 * idle task, after drawRect returns, to clean up the mess.
898 */
899
900 static void
901 RedisplayView(
902 ClientData clientdata)
903 {
904 NSView *view = (NSView *) clientdata;
905
906 /*
907 * Make sure that we are not trying to displaying a view that no longer
908 * exists.
909 */
910
911 for (NSWindow *w in [NSApp orderedWindows]) {
912 if ([w contentView] == view) {
913 [view setNeedsDisplay:YES];
914 break;
915 }
916 }
917 }
918
919915 @implementation TKContentView(TKWindowEvent)
920916
917 - (void) addTkDirtyRect: (NSRect) rect
918 {
919 _tkNeedsDisplay = YES;
920 _tkDirtyRect = NSUnionRect(_tkDirtyRect, rect);
921 [NSApp setNeedsToDraw:YES];
922 }
923
924 - (void) clearTkDirtyRect
925 {
926 _tkNeedsDisplay = NO;
927 _tkDirtyRect = NSZeroRect;
928 [NSApp setNeedsToDraw:NO];
929 }
930
921931 - (void) drawRect: (NSRect) rect
922932 {
923 const NSRect *rectsBeingDrawn;
924 NSInteger rectsBeingDrawnCount;
933 (void)rect;
925934
926935 #ifdef TK_MAC_DEBUG_DRAWING
927936 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
928 if (winPtr) fprintf(stderr, "drawRect: drawing %s\n",
929 Tk_PathName(winPtr));
937 if (winPtr) {
938 fprintf(stderr, "drawRect: drawing %s in %s\n",
939 Tk_PathName(winPtr), NSStringFromRect(rect).UTF8String);
940 }
930941 #endif
931942
932943 /*
935946 */
936947
937948 if ([NSApp isDrawing]) {
938 if ([NSApp macMinorVersion] > 13) {
949 if ([NSApp macOSVersion] > 101300) {
939950 TKLog(@"WARNING: a recursive call to drawRect was aborted.");
940951 }
941952 return;
942953 }
943954
944955 [NSApp setIsDrawing: YES];
945
946 [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount];
947 CGFloat height = [self bounds].size.height;
948 HIMutableShapeRef drawShape = HIShapeCreateMutable();
949
950 while (rectsBeingDrawnCount--) {
951 CGRect r = NSRectToCGRect(*rectsBeingDrawn++);
952
953 #ifdef TK_MAC_DEBUG_DRAWING
954 fprintf(stderr, "drawRect: %dx%d@(%d,%d)\n", (int)r.size.width,
955 (int)r.size.height, (int)r.origin.x, (int)r.origin.y);
956 #endif
957
958 r.origin.y = height - (r.origin.y + r.size.height);
959 HIShapeUnionWithRect(drawShape, &r);
960 }
961 [self generateExposeEvents:(HIShapeRef)drawShape];
962 CFRelease(drawShape);
963 [NSApp setIsDrawing: NO];
964
965 if ([self needsRedisplay]) {
966 [self setNeedsRedisplay:NO];
967 Tcl_DoWhenIdle(RedisplayView, self);
968 }
956 [self clearTkDirtyRect];
957 [self generateExposeEvents:rect];
958 [NSApp setIsDrawing:NO];
969959
970960 #ifdef TK_MAC_DEBUG_DRAWING
971961 fprintf(stderr, "drawRect: done.\n");
977967 [super setFrameSize: newsize];
978968 NSWindow *w = [self window];
979969 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
980 Tk_Window tkwin = (Tk_Window) winPtr;
970 Tk_Window tkwin = (Tk_Window)winPtr;
981971
982972 if (![self inLiveResize] &&
983973 [w respondsToSelector: @selector (tkLayoutChanged)]) {
10221012 TkMacOSXUpdateClipRgn(winPtr);
10231013
10241014 /*
1025 * Generate and process expose events to redraw the window.
1015 * Generate and process expose events to redraw the window. To avoid
1016 * crashes, only do this if we are being called from drawRect. See
1017 * ticket [1fa8c3ed8d].
10261018 */
10271019
1028 HIRect bounds = NSRectToCGRect([self bounds]);
1029 HIShapeRef shape = HIShapeCreateWithRect(&bounds);
1030 [self generateExposeEvents: shape];
1031 [w displayIfNeeded];
1020 if([NSApp isDrawing] || [self inLiveResize]) {
1021 [self generateExposeEvents: [self bounds]];
1022 }
10321023
10331024 /*
10341025 * Finally, unlock the main autoreleasePool.
10451036 * pending idle events are processed so the drawing will actually take place.
10461037 */
10471038
1048 - (void) generateExposeEvents: (HIShapeRef) shape
1039 - (void) generateExposeEvents: (NSRect) rect
10491040 {
10501041 unsigned long serial;
1042 int updatesNeeded;
10511043 CGRect updateBounds;
1052 int updatesNeeded;
10531044 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
10541045 ClientData oldArg;
10551046 Tk_RestrictProc *oldProc;
10581049 }
10591050
10601051 /*
1061 * Generate Tk Expose events.
1062 */
1063
1064 HIShapeGetBounds(shape, &updateBounds);
1065
1066 /*
1067 * All of these events will share the same serial number.
1068 */
1069
1070 serial = LastKnownRequestProcessed(Tk_Display(winPtr));
1071 updatesNeeded = GenerateUpdates(shape, &updateBounds, winPtr);
1072
1052 * Generate Tk Expose events. All of these events will share the same
1053 * serial number.
1054 */
1055
1056 updateBounds = NSRectToCGRect(rect);
1057 updateBounds.origin.y = ([self bounds].size.height - updateBounds.origin.y
1058 - updateBounds.size.height);
1059 updatesNeeded = GenerateUpdates(&updateBounds, winPtr);
10731060 if (updatesNeeded) {
10741061
1062 serial = LastKnownRequestProcessed(Tk_Display(winPtr));
1063
10751064 /*
1076 * First process all of the Expose events.
1065 * Use the ExposeRestrictProc to process only the expose events. This
1066 * will create idle drawing tasks, which we handle before we return.
10771067 */
10781068
10791069 oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg);
1080 while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {};
1070 while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {};
10811071 Tk_RestrictEvents(oldProc, oldArg, &oldArg);
10821072
10831073 /*
10891079 * effect.)
10901080 *
10911081 * Fortunately, Tk schedules all drawing to be done while Tcl is idle.
1092 * So we can do the drawing by processing all of the idle events that
1093 * were created when the expose events were processed.
1082 * So to run any display procs which were scheduled by the expose
1083 * events we process all idle events before returning.
10941084 */
1085
10951086 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
10961087 }
10971088 }
10981089
10991090 /*
1100 * This method is called when a user changes between light and dark mode. The
1101 * implementation here generates a Tk virtual event which can be bound to a
1102 * function that redraws the window in an appropriate style.
1103 */
1091 * In macOS 10.14 and later this method is called when a user changes between
1092 * light and dark mode or changes the accent color. The implementation
1093 * generates two virtual events. The first is either <<LightAqua>> or
1094 * <<DarkAqua>>, depending on the view's current effective appearance. The
1095 * second is <<AppearnceChanged>> and has a data string describing the
1096 * effective appearance of the view and the current accent and highlight
1097 * colors.
1098 */
1099
1100 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
1101
1102 static const char *const accentNames[] = {
1103 "Graphite",
1104 "Red",
1105 "Orange",
1106 "Yellow",
1107 "Green",
1108 "Blue",
1109 "Purple",
1110 "Pink"
1111 };
11041112
11051113 - (void) viewDidChangeEffectiveAppearance
11061114 {
1107 XVirtualEvent event;
1108 int x, y;
1109 NSWindow *w = [self window];
1110 TkWindow *winPtr = TkMacOSXGetTkWindow(w);
1111 Tk_Window tkwin = (Tk_Window) winPtr;
1112
1113 if (!winPtr) {
1115 Tk_Window tkwin = (Tk_Window)TkMacOSXGetTkWindow([self window]);
1116 if (!tkwin) {
11141117 return;
11151118 }
1116 bzero(&event, sizeof(XVirtualEvent));
1117 event.type = VirtualEvent;
1118 event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
1119 event.send_event = false;
1120 event.display = Tk_Display(tkwin);
1121 event.event = Tk_WindowId(tkwin);
1122 event.root = XRootWindow(Tk_Display(tkwin), 0);
1123 event.subwindow = None;
1124 event.time = TkpGetMS();
1125 XQueryPointer(NULL, winPtr->window, NULL, NULL,
1126 &event.x_root, &event.y_root, &x, &y, &event.state);
1127 Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
1128 event.same_screen = true;
1129 if (TkMacOSXInDarkMode(tkwin)) {
1130 event.name = Tk_GetUid("DarkAqua");
1131 } else {
1132 event.name = Tk_GetUid("LightAqua");
1133 }
1134 Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
1135 }
1119 NSAppearanceName effectiveAppearanceName = [[self effectiveAppearance] name];
1120 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
1121 static const char *defaultColor = NULL;
1122
1123 if (effectiveAppearanceName == NSAppearanceNameAqua) {
1124 TkSendVirtualEvent(tkwin, "LightAqua", NULL);
1125 } else if (effectiveAppearanceName == NSAppearanceNameDarkAqua) {
1126 TkSendVirtualEvent(tkwin, "DarkAqua", NULL);
1127 }
1128 if ([NSApp macOSVersion] < 101500) {
1129
1130 /*
1131 * Mojave cannot handle the KVO shenanigans that we need for the
1132 * highlight and accent color notifications.
1133 */
1134
1135 return;
1136 }
1137 if (!defaultColor) {
1138 defaultColor = [NSApp macOSVersion] < 110000 ? "Blue" : "Multicolor";
1139 preferences = [[NSUserDefaults standardUserDefaults] retain];
1140
1141 /*
1142 * AppKit calls this method when the user changes the Accent Color
1143 * but not when the user changes the Highlight Color. So we register
1144 * to receive KVO notifications for Highlight Color as well.
1145 */
1146
1147 [preferences addObserver:self
1148 forKeyPath:@"AppleHighlightColor"
1149 options:NSKeyValueObservingOptionNew
1150 context:NULL];
1151 }
1152 NSString *accent = [preferences stringForKey:@"AppleAccentColor"];
1153 NSArray *words = [[preferences stringForKey:@"AppleHighlightColor"]
1154 componentsSeparatedByString: @" "];
1155 NSString *highlight = [words count] > 3 ? [words objectAtIndex:3] : nil;
1156 const char *accentName = accent ? accentNames[1 + accent.intValue] : defaultColor;
1157 const char *highlightName = highlight ? highlight.UTF8String: defaultColor;
1158 char data[256];
1159 snprintf(data, 256, "Appearance %s Accent %s Highlight %s",
1160 effectiveAppearanceName.UTF8String, accentName,
1161 highlightName);
1162 TkSendVirtualEvent(tkwin, "AppearanceChanged", Tcl_NewStringObj(data, -1));
1163 }
1164
1165 - (void)observeValueForKeyPath:(NSString *)keyPath
1166 ofObject:(id)object
1167 change:(NSDictionary *)change
1168 context:(void *)context
1169 {
1170 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
1171 if (object == preferences && [keyPath isEqualToString:@"AppleHighlightColor"]) {
1172 if (@available(macOS 10.14, *)) {
1173 [self viewDidChangeEffectiveAppearance];
1174 }
1175 }
1176 }
1177
1178 #endif
11361179
11371180 /*
11381181 * This is no-op on 10.7 and up because Apple has removed this widget, but we
11471190 XVirtualEvent event;
11481191 int x, y;
11491192 TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
1150 Tk_Window tkwin = (Tk_Window) winPtr;
1193 Tk_Window tkwin = (Tk_Window)winPtr;
1194 (void)sender;
1195
11511196 if (!winPtr){
11521197 return;
11531198 }
11681213 Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
11691214 }
11701215
1171 - (BOOL) isOpaque
1172 {
1173 NSWindow *w = [self window];
1174 return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) ||
1175 ![w isOpaque]) ? NO : YES);
1176 }
1216 /*
1217 * On Catalina this is never called and drawRect clips to the rect that
1218 * is passed to it by AppKit.
1219 */
11771220
11781221 - (BOOL) wantsDefaultClipping
11791222 {
11921235
11931236 - (void) keyDown: (NSEvent *) theEvent
11941237 {
1238 (void)theEvent;
1239
11951240 #ifdef TK_MAC_DEBUG_EVENTS
11961241 TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
11971242 #endif
11991244
12001245 /*
12011246 * When the services menu is opened this is called for each Responder in
1202 * the Responder chain until a service provider is found. The TkContentView
1247 * the Responder chain until a service provider is found. The TKContentView
12031248 * should be the first (and generally only) Responder in the chain. We
12041249 * return the TkServices object that was created in TkpInit.
12051250 */
2020 #include "tkMacOSXEvent.h"
2121 #include "tkMacOSXDebug.h"
2222 #include "tkMacOSXConstants.h"
23
24 /*
25 * Setting this to 1 prints when each window is freed, setting it to 2 adds
26 * dumps of the autorelease pools, and setting it to 3 also shows each retain
27 * and release.
28 */
2329
2430 #define DEBUG_ZOMBIES 0
2531
184190 */
185191
186192 static int tkMacOSXWmAttrNotifyVal = 0;
187
188 /*
189 * Hash table for Mac Window -> TkWindow mapping.
190 */
191
192 static Tcl_HashTable windowTable;
193 static int windowHashInit = false;
194193
195194 /*
196195 * Forward declarations for procedures defined in this file:
313312 static void ApplyWindowAttributeFlagChanges(TkWindow *winPtr,
314313 NSWindow *macWindow, UInt64 oldAttributes,
315314 int oldFlags, int create, int initial);
316 static void ApplyMasterOverrideChanges(TkWindow *winPtr,
315 static void ApplyContainerOverrideChanges(TkWindow *winPtr,
317316 NSWindow *macWindow);
318317 static void GetMinSize(TkWindow *winPtr, int *minWidthPtr,
319318 int *minHeightPtr);
353352
354353 #pragma mark -
355354
355 @implementation TKPanel: NSPanel
356 @synthesize tkWindow = _tkWindow;
357 @end
358
359 @implementation TKDrawerWindow: NSWindow
360 @synthesize tkWindow = _tkWindow;
361 @end
362
363 @implementation TKWindow: NSWindow
364 @synthesize mouseInResizeArea = _mouseInResizeArea;
365 @synthesize tkWindow = _tkWindow;
366 @end
367
356368 #pragma mark TKWindow(TKWm)
357
358 @implementation TKWindow: NSWindow
359
360 @end
361369
362370 @implementation TKWindow(TKWm)
363371
429437 - (BOOL) canBecomeKeyWindow
430438 {
431439 TkWindow *winPtr = TkMacOSXGetTkWindow(self);
432 if (!winPtr) {
440
441 if (!winPtr || !winPtr->wmInfoPtr) {
433442 return NO;
434443 }
435444 return (winPtr->wmInfoPtr &&
446455 if (title == nil) {
447456 title = "unnamed window";
448457 }
449 if (DEBUG_ZOMBIES > 1) {
458 if (DEBUG_ZOMBIES > 2) {
450459 fprintf(stderr, "Retained <%s>. Count is: %lu\n",
451460 title, [self retainCount]);
452461 }
460469 if (title == nil) {
461470 title = "unnamed window";
462471 }
463 if (DEBUG_ZOMBIES > 1) {
472 if (DEBUG_ZOMBIES > 2) {
464473 fprintf(stderr, "Autoreleased <%s>. Count is %lu\n",
465474 title, [self retainCount]);
466475 }
472481 if (title == nil) {
473482 title = "unnamed window";
474483 }
475 if (DEBUG_ZOMBIES > 1) {
484 if (DEBUG_ZOMBIES > 2) {
476485 fprintf(stderr, "Releasing <%s>. Count is %lu\n",
477486 title, [self retainCount]);
478487 }
516525 SetWindowSizeLimits(
517526 TkWindow *winPtr)
518527 {
519 NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window);
528 NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
520529 WmInfo *wmPtr = winPtr->wmInfoPtr;
521530 int minWidth, minHeight, maxWidth, maxHeight, base;
522531
658667 TkWmNewWindow(
659668 TkWindow *winPtr) /* Newly-created top-level window. */
660669 {
661 WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
670 WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
662671
663672 wmPtr->winPtr = winPtr;
664673 wmPtr->reparent = None;
665674 wmPtr->titleUid = NULL;
666675 wmPtr->iconName = NULL;
667 wmPtr->master = NULL;
676 wmPtr->container = NULL;
668677 wmPtr->hints.flags = InputHint | StateHint;
669678 wmPtr->hints.input = True;
670679 wmPtr->hints.initial_state = NormalState;
722731 * detect size and position changes caused by window managers.
723732 */
724733
725 Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask,
734 Tk_CreateEventHandler((Tk_Window)winPtr, StructureNotifyMask,
726735 TopLevelEventProc, winPtr);
727736
728737 /*
730739 * window manager.
731740 */
732741
733 Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0);
742 Tk_ManageGeometry((Tk_Window)winPtr, &wmMgrType, NULL);
743 }
744
745 /*
746 *----------------------------------------------------------------------
747 *
748 * TkMacOSXHandleMapOrUnmap --
749 *
750 * The mechanism used by a geometry manager to propogate the information
751 * about which of its content widgets are mapped is to call Tk_MapWindow
752 * or Tk_UnmapNotify. Those functions generate MapNotify or UnmapNotify
753 * events and then handle them immediately. Other platforms use
754 * Tk_HandleEvent to do this. But that does not work correctly on macOS
755 * due to the fact that the calls to Tk_MapNotify or Tk_UnmapNotify can
756 * occur in display procedures which are being run in the drawRect method
757 * of a TKContentView. The events will be processed after drawRect
758 * returns, but they need to be processed immediately in some cases.
759
760 * This function operates as a macOS alternative to Tk_HandleEvent, for
761 * processing MapNotify or UnmapNotify events only. It is called by
762 * Tk_MapWindow, Tk_UnmapWindow, TkWmMapWindow and TkWmUnmapWindow.
763 * Rather than using Tk_HandleEvent it installs a filter which restricts
764 * to the MapNotify or UnmapNotify events, it queues the event and then
765 * processes window events with the filter installed. This allows the
766 * event to be handled immediately even from within the drawRect method.
767 *
768 * Results:
769 * None.
770 *
771 * Side effects:
772 * Handles a MapNotify or UnMapNotify event.
773 *
774 *----------------------------------------------------------------------
775 */
776 static Tk_RestrictAction
777 MapUnmapRestrictProc(
778 ClientData arg,
779 XEvent *eventPtr)
780 {
781 return (eventPtr->type==MapNotify || eventPtr->type==UnmapNotify ?
782 TK_PROCESS_EVENT : TK_DEFER_EVENT);
783 }
784
785 MODULE_SCOPE
786 void TkMacOSXHandleMapOrUnmap(
787 Tk_Window tkwin,
788 XEvent *event)
789 {
790 ClientData oldArg;
791 Tk_RestrictProc *oldProc;
792 TkWindow *winPtr = (TkWindow *) tkwin;
793 const Tk_GeomMgr *geomMgrPtr = winPtr->geomMgrPtr;
794
795 /*
796 * Sadly, this approach does not work with the "text" geometry manager.
797 * The mysterious unexplained crash elicited by textDisp-5.2 occurs. So we
798 * have to check for the "text" manager and revert to using Tk_HandleEvent
799 * in that case. Hopefully this can be removed when the revised text
800 * widget is in place.
801 */
802
803 if (geomMgrPtr && strcmp(geomMgrPtr->name, "text") == 0) {
804 Tk_HandleEvent(event);
805 return;
806 }
807 oldProc = Tk_RestrictEvents(MapUnmapRestrictProc, NULL, &oldArg);
808 Tk_QueueWindowEvent(event, TCL_QUEUE_TAIL);
809 while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}
810 Tk_RestrictEvents(oldProc, oldArg, &oldArg);
734811 }
735812
736813 /*
762839 * mapped. */
763840 {
764841 WmInfo *wmPtr = winPtr->wmInfoPtr;
842 XEvent event;
843
765844 if (wmPtr->flags & WM_NEVER_MAPPED) {
766845 /*
767846 * Create the underlying Mac window for this Tk window.
777856 * Generate configure event when we first map the window.
778857 */
779858
780 TkGenWMConfigureEvent((Tk_Window) winPtr, wmPtr->x, wmPtr->y, -1, -1,
859 TkGenWMConfigureEvent((Tk_Window)winPtr, wmPtr->x, wmPtr->y, -1, -1,
781860 TK_LOCATION_CHANGED);
782861
783862 /*
825904 wmPtr->flags &= ~WM_ABOUT_TO_MAP;
826905
827906 /*
828 * Map the window.
907 * Map the window and process a MapNotify event for it.
829908 */
830909
910 winPtr->flags |= TK_MAPPED;
831911 XMapWindow(winPtr->display, winPtr->window);
912 event.xany.serial = LastKnownRequestProcessed(winPtr->display);
913 event.xany.send_event = False;
914 event.xany.display = winPtr->display;
915 event.xmap.window = winPtr->window;
916 event.xmap.type = MapNotify;
917 event.xmap.event = winPtr->window;
918 event.xmap.override_redirect = winPtr->atts.override_redirect;
919 TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
832920 }
833921
834922 /*
853941 TkWindow *winPtr) /* Top-level window that's about to be
854942 * unmapped. */
855943 {
944 XEvent event;
945
946 event.xany.serial = LastKnownRequestProcessed(winPtr->display);
947 event.xany.send_event = False;
948 event.xany.display = winPtr->display;
949 event.xunmap.type = UnmapNotify;
950 event.xunmap.window = winPtr->window;
951 event.xunmap.event = winPtr->window;
952 event.xunmap.from_configure = false;
953 winPtr->flags &= ~TK_MAPPED;
856954 XUnmapWindow(winPtr->display, winPtr->window);
955 TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
857956 }
858957
859958 /*
878977 TkWindow *winPtr) /* Top-level window that's being deleted. */
879978 {
880979 WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
980 TKWindow *deadNSWindow;
881981
882982 if (wmPtr == NULL) {
883983 return;
884984 }
885985
886986 /*
887 *If the dead window is a transient, remove it from the master's list.
987 *If the dead window is a transient, remove it from the container's list.
888988 */
889989
890990 RemoveTransient(winPtr);
891 Tk_ManageGeometry((Tk_Window) winPtr, NULL, NULL);
892 Tk_DeleteEventHandler((Tk_Window) winPtr, StructureNotifyMask,
991 Tk_ManageGeometry((Tk_Window)winPtr, NULL, NULL);
992 Tk_DeleteEventHandler((Tk_Window)winPtr, StructureNotifyMask,
893993 TopLevelEventProc, winPtr);
894994 if (wmPtr->hints.flags & IconPixmapHint) {
895995 Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
9041004 ckfree(wmPtr->leaderName);
9051005 }
9061006 if (wmPtr->icon != NULL) {
907 wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
1007 wmPtr2 = ((TkWindow *)wmPtr->icon)->wmInfoPtr;
9081008 wmPtr2->iconFor = NULL;
9091009 }
9101010 if (wmPtr->iconFor != NULL) {
911 wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr;
1011 wmPtr2 = ((TkWindow *)wmPtr->iconFor)->wmInfoPtr;
9121012 wmPtr2->icon = NULL;
9131013 wmPtr2->hints.flags &= ~IconWindowHint;
9141014 }
9351035 for (Transient *transientPtr = wmPtr->transientPtr;
9361036 transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
9371037 TkWindow *winPtr2 = transientPtr->winPtr;
938 TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
939
940 if (masterPtr == winPtr) {
1038 TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer(winPtr2);
1039
1040 if (containerPtr == winPtr) {
9411041 wmPtr2 = winPtr2->wmInfoPtr;
942 wmPtr2->master = NULL;
1042 wmPtr2->container = NULL;
9431043 }
9441044 }
9451045
9511051 }
9521052
9531053 /*
954 * Delete the Mac window and remove it from the windowTable. The window
955 * could be nil if the window was never mapped. However, we don't do this
956 * for embedded windows, they don't go in the window list, and they do not
957 * own their portPtr's.
1054 * Unregister the NSWindow and remove all references to it from the Tk
1055 * data structures. If the NSWindow is a child, disassociate it from
1056 * the parent. Then close and release the NSWindow.
9581057 */
9591058
960 NSWindow *window = wmPtr->window;
961
962 if (window && !Tk_IsEmbedded(winPtr)) {
963 NSWindow *parent = [window parentWindow];
1059 deadNSWindow = (TKWindow *)wmPtr->window;
1060 if (deadNSWindow && !Tk_IsEmbedded(winPtr)) {
1061 NSWindow *parent = [deadNSWindow parentWindow];
1062 [deadNSWindow setTkWindow:None];
1063 if (winPtr->window) {
1064 ((MacDrawable *)winPtr->window)->view = nil;
1065 }
1066 wmPtr->window = NULL;
9641067
9651068 if (parent) {
966 [parent removeChildWindow:window];
967 }
968 #if DEBUG_ZOMBIES > 0
1069 [parent removeChildWindow:deadNSWindow];
1070 }
1071
1072 #if DEBUG_ZOMBIES > 1
9691073 {
970 const char *title = [[window title] UTF8String];
1074 const char *title = [[deadNSWindow title] UTF8String];
9711075 if (title == nil) {
9721076 title = "unnamed window";
9731077 }
9741078 fprintf(stderr, ">>>> Closing <%s>. Count is: %lu\n", title,
975 [window retainCount]);
1079 [deadNSWindow retainCount]);
9761080 }
9771081 #endif
978 [window close];
979 TkMacOSXUnregisterMacWindow(window);
980 if (winPtr->window) {
981 ((MacDrawable *) winPtr->window)->view = nil;
982 }
983 wmPtr->window = NULL;
984 [window release];
985
986 /* Activate the highest window left on the screen. */
987 NSArray *windows = [NSApp orderedWindows];
988 for (id nswindow in windows) {
989 TkWindow *winPtr2 = TkMacOSXGetTkWindow(nswindow);
990
991 if (winPtr2 && nswindow != window) {
992 WmInfo *wmPtr = winPtr2->wmInfoPtr;
993 BOOL minimized = (wmPtr->hints.initial_state == IconicState
994 || wmPtr->hints.initial_state == WithdrawnState);
995
996 /*
997 * If no windows are left on the screen and the next window is
998 * iconified or withdrawn, we don't want to make it be the
999 * KeyWindow because that would cause it to be displayed on the
1000 * screen.
1001 */
1002
1003 if ([nswindow canBecomeKeyWindow] && !minimized) {
1004 [nswindow makeKeyAndOrderFront:NSApp];
1005 break;
1006 }
1082
1083 /*
1084 * When a window is closed we want to move the focus to the next
1085 * highest window. Apple's documentation says that calling the
1086 * orderOut method of the key window will accomplish this. But
1087 * experiment shows that this is not the case. So we have to reset the
1088 * key window ourselves. When the window is the last one on the screen
1089 * there is no choice for a new key window. Moreover, if the host
1090 * computer has a TouchBar then the TouchBar holds a reference to the
1091 * key window which prevents it from being deallocated until it stops
1092 * being the key window. On these systems the only option for
1093 * preventing zombies is to set the key window to nil.
1094 */
1095
1096 for (NSWindow *w in [NSApp orderedWindows]) {
1097 TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
1098 BOOL isOnScreen;
1099
1100 if (!winPtr2 || !winPtr2->wmInfoPtr) {
1101 continue;
10071102 }
1103 wmPtr2 = winPtr2->wmInfoPtr;
1104 isOnScreen = (wmPtr2->hints.initial_state != IconicState &&
1105 wmPtr2->hints.initial_state != WithdrawnState);
1106 if (w != deadNSWindow && isOnScreen && [w canBecomeKeyWindow]) {
1107 [w makeKeyAndOrderFront:NSApp];
1108 break;
1109 }
10081110 }
10091111
10101112 /*
1011 * Process all window events immediately to force the closed window to
1012 * be deallocated. But don't do this for the root window as that is
1013 * unnecessary and can lead to segfaults.
1113 * Prevent zombies on systems with a TouchBar.
10141114 */
10151115
1016 if (winPtr->parentPtr) {
1017 while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}
1018 }
1116 if (deadNSWindow == [NSApp keyWindow]) {
1117 [NSApp _setKeyWindow:nil];
1118 [NSApp _setMainWindow:nil];
1119 }
1120 [deadNSWindow close];
1121 [deadNSWindow release];
10191122 [NSApp _resetAutoreleasePool];
1020 #if DEBUG_ZOMBIES > 0
1123
1124 #if DEBUG_ZOMBIES > 1
10211125 fprintf(stderr, "================= Pool dump ===================\n");
10221126 [NSAutoreleasePool showPools];
10231127 #endif
1024 }
1128
1129 }
1130
1131 /*
1132 * Deallocate the wmInfo and clear the wmInfoPtr.
1133 */
1134
10251135 ckfree(wmPtr);
10261136 winPtr->wmInfoPtr = NULL;
10271137 }
10471157
10481158 void
10491159 TkWmSetClass(
1050 TkWindow *winPtr) /* Newly-created top-level window. */
1160 TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */
10511161 {
10521162 return;
10531163 }
10691179 *----------------------------------------------------------------------
10701180 */
10711181
1072 /* ARGSUSED */
10731182 int
10741183 Tk_WmObjCmd(
10751184 ClientData clientData, /* Main window associated with interpreter. */
10771186 int objc, /* Number of arguments. */
10781187 Tcl_Obj *const objv[]) /* Argument objects. */
10791188 {
1080 Tk_Window tkwin = (Tk_Window) clientData;
1189 Tk_Window tkwin = (Tk_Window)clientData;
10811190 static const char *const optionStrings[] = {
10821191 "aspect", "attributes", "client", "colormapwindows",
10831192 "command", "deiconify", "focusmodel", "forget",
12341343
12351344 static int
12361345 WmAspectCmd(
1237 Tk_Window tkwin, /* Main window of the application. */
1346 TCL_UNUSED(Tk_Window), /* Main window of the application. */
12381347 TkWindow *winPtr, /* Toplevel to work with */
12391348 Tcl_Interp *interp, /* Current interpreter. */
12401349 int objc, /* Number of arguments. */
12411350 Tcl_Obj *const objv[]) /* Argument objects. */
12421351 {
1243 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1352 WmInfo *wmPtr = winPtr->wmInfoPtr;
12441353 int numer1, denom1, numer2, denom2;
12451354
12461355 if ((objc != 3) && (objc != 7)) {
13381447 if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) {
13391448 return TCL_ERROR;
13401449 }
1341 if (boolean != ((wmPtr->flags & WM_FULLSCREEN) != 0)) {
1450 if (boolean != (([macWindow styleMask] & NSFullScreenWindowMask) != 0)) {
13421451 #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070)
13431452 [macWindow toggleFullScreen:macWindow];
13441453 #else
14161525 oldFlags, 1, 0);
14171526 [macWindow setBackgroundColor:boolean ? [NSColor clearColor] : nil];
14181527 [macWindow setOpaque:!boolean];
1419 TkMacOSXInvalidateWindow((MacDrawable *) winPtr->window,
1528 TkMacOSXInvalidateWindow((MacDrawable *)winPtr->window,
14201529 TK_PARENT_WINDOW);
14211530 }
14221531 break;
14551564 result = Tcl_NewDoubleObj([macWindow alphaValue]);
14561565 break;
14571566 case WMATT_FULLSCREEN:
1458 result = Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN);
1567 result = Tcl_NewBooleanObj([macWindow styleMask] & NSFullScreenWindowMask);
14591568 break;
14601569 case WMATT_MODIFIED:
14611570 result = Tcl_NewBooleanObj([macWindow isDocumentEdited]);
15021611
15031612 static int
15041613 WmAttributesCmd(
1505 Tk_Window tkwin, /* Main window of the application. */
1614 TCL_UNUSED(Tk_Window), /* Main window of the application. */
15061615 TkWindow *winPtr, /* Toplevel to work with */
15071616 Tcl_Interp *interp, /* Current interpreter. */
15081617 int objc, /* Number of arguments. */
15121621 NSWindow *macWindow;
15131622
15141623 if (winPtr->window == None) {
1515 Tk_MakeWindowExist((Tk_Window) winPtr);
1624 Tk_MakeWindowExist((Tk_Window)winPtr);
15161625 }
15171626 if (!TkMacOSXHostToplevelExists(winPtr)) {
15181627 TkMacOSXMakeRealWindowExist(winPtr);
15191628 }
1520 macWindow = TkMacOSXDrawableWindow(winPtr->window);
1629 macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
15211630
15221631 if (objc == 3) { /* wm attributes $win */
15231632 Tcl_Obj *result = Tcl_NewObj();
15741683
15751684 static int
15761685 WmClientCmd(
1577 Tk_Window tkwin, /* Main window of the application. */
1686 TCL_UNUSED(Tk_Window), /* Main window of the application. */
15781687 TkWindow *winPtr, /* Toplevel to work with */
15791688 Tcl_Interp *interp, /* Current interpreter. */
15801689 int objc, /* Number of arguments. */
15811690 Tcl_Obj *const objv[]) /* Argument objects. */
15821691 {
1583 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1692 WmInfo *wmPtr = winPtr->wmInfoPtr;
15841693 char *argv3;
15851694 int length;
15861695
16061715 if (wmPtr->clientMachine != NULL) {
16071716 ckfree(wmPtr->clientMachine);
16081717 }
1609 wmPtr->clientMachine = ckalloc(length + 1);
1718 wmPtr->clientMachine = (char *)ckalloc(length + 1);
16101719 strcpy(wmPtr->clientMachine, argv3);
16111720 return TCL_OK;
16121721 }
16361745 int objc, /* Number of arguments. */
16371746 Tcl_Obj *const objv[]) /* Argument objects. */
16381747 {
1639 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1748 WmInfo *wmPtr = winPtr->wmInfoPtr;
16401749 TkWindow **cmapList, *winPtr2;
16411750 int i, windowObjc, gotToplevel = 0;
16421751 Tcl_Obj **windowObjv, *resultObj;
16461755 return TCL_ERROR;
16471756 }
16481757 if (objc == 3) {
1649 Tk_MakeWindowExist((Tk_Window) winPtr);
1758 Tk_MakeWindowExist((Tk_Window)winPtr);
16501759 resultObj = Tcl_NewObj();
16511760 for (i = 0; i < wmPtr->cmapCount; i++) {
16521761 if ((i == (wmPtr->cmapCount-1))
16541763 break;
16551764 }
16561765 Tcl_ListObjAppendElement(NULL, resultObj,
1657 TkNewWindowObj((Tk_Window) wmPtr->cmapList[i]));
1766 TkNewWindowObj((Tk_Window)wmPtr->cmapList[i]));
16581767 }
16591768 Tcl_SetObjResult(interp, resultObj);
16601769 return TCL_OK;
16631772 != TCL_OK) {
16641773 return TCL_ERROR;
16651774 }
1666 cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*));
1775 cmapList = (TkWindow **)ckalloc((windowObjc+1) * sizeof(TkWindow*));
16671776 for (i = 0; i < windowObjc; i++) {
16681777 if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
16691778 (Tk_Window *) &winPtr2) != TCL_OK) {
16741783 gotToplevel = 1;
16751784 }
16761785 if (winPtr2->window == None) {
1677 Tk_MakeWindowExist((Tk_Window) winPtr2);
1786 Tk_MakeWindowExist((Tk_Window)winPtr2);
16781787 }
16791788 cmapList[i] = winPtr2;
16801789 }
16931802 wmPtr->cmapCount = windowObjc;
16941803
16951804 /*
1696 * On the Macintosh all of this is just an excercise in compatability as
1805 * On the Macintosh all of this is just an excercise in compatibility as
16971806 * we don't support colormaps. If we did they would be installed here.
16981807 */
16991808
17191828
17201829 static int
17211830 WmCommandCmd(
1722 Tk_Window tkwin, /* Main window of the application. */
1831 TCL_UNUSED(Tk_Window), /* Main window of the application. */
17231832 TkWindow *winPtr, /* Toplevel to work with */
17241833 Tcl_Interp *interp, /* Current interpreter. */
17251834 int objc, /* Number of arguments. */
17261835 Tcl_Obj *const objv[]) /* Argument objects. */
17271836 {
1728 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1837 WmInfo *wmPtr = winPtr->wmInfoPtr;
17291838 int len;
17301839
17311840 if ((objc != 3) && (objc != 4)) {
17761885
17771886 static int
17781887 WmDeiconifyCmd(
1779 Tk_Window tkwin, /* Main window of the application. */
1888 TCL_UNUSED(Tk_Window), /* Main window of the application. */
17801889 TkWindow *winPtr, /* Toplevel to work with */
17811890 Tcl_Interp *interp, /* Current interpreter. */
17821891 int objc, /* Number of arguments. */
17831892 Tcl_Obj *const objv[]) /* Argument objects. */
17841893 {
1785 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1786 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
1894 WmInfo *wmPtr = winPtr->wmInfoPtr;
1895 NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
17871896
17881897 if (objc != 3) {
17891898 Tcl_WrongNumArgs(interp, 2, objv, "window");
17901899 return TCL_ERROR;
17911900 }
1792
17931901 if (wmPtr->iconFor != NULL) {
17941902 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
17951903 "can't deiconify %s: it is an icon for %s",
18081916 ZoomState : NormalState);
18091917 [win setExcludedFromWindowsMenu:NO];
18101918 TkMacOSXApplyWindowAttributes(winPtr, win);
1811 [win orderFront:nil];
1919 [win orderFront:NSApp];
18121920 if (wmPtr->icon) {
18131921 Tk_UnmapWindow((Tk_Window)wmPtr->icon);
18141922 }
18151923
18161924 /*
18171925 * If this window has a transient, the transient must also be deiconified if
1818 * it was withdrawn by the master.
1926 * it was withdrawn by the container.
18191927 */
18201928
18211929 for (Transient *transientPtr = wmPtr->transientPtr;
18221930 transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
18231931 TkWindow *winPtr2 = transientPtr->winPtr;
18241932 WmInfo *wmPtr2 = winPtr2->wmInfoPtr;
1825 TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
1826
1827 if (masterPtr == winPtr) {
1933 TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer(winPtr2);
1934
1935 if (containerPtr == winPtr) {
18281936 if ((wmPtr2->hints.initial_state == WithdrawnState) &&
1829 ((transientPtr->flags & WITHDRAWN_BY_MASTER) != 0)) {
1937 ((transientPtr->flags & WITHDRAWN_BY_CONTAINER) != 0)) {
18301938 TkpWmSetState(winPtr2, NormalState);
1831 transientPtr->flags &= ~WITHDRAWN_BY_MASTER;
1939 transientPtr->flags &= ~WITHDRAWN_BY_CONTAINER;
18321940 }
18331941 }
18341942 }
18551963
18561964 static int
18571965 WmFocusmodelCmd(
1858 Tk_Window tkwin, /* Main window of the application. */
1966 TCL_UNUSED(Tk_Window), /* Main window of the application. */
18591967 TkWindow *winPtr, /* Toplevel to work with */
18601968 Tcl_Interp *interp, /* Current interpreter. */
18611969 int objc, /* Number of arguments. */
18621970 Tcl_Obj *const objv[]) /* Argument objects. */
18631971 {
1864 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1972 WmInfo *wmPtr = winPtr->wmInfoPtr;
18651973 static const char *const optionStrings[] = {
18661974 "active", "passive", NULL };
18671975 enum options {
19092017
19102018 static int
19112019 WmForgetCmd(
1912 Tk_Window tkwin, /* Main window of the application. */
2020 TCL_UNUSED(Tk_Window), /* Main window of the application. */
19132021 TkWindow *winPtr, /* Toplevel or Frame to work with */
1914 Tcl_Interp *interp, /* Current interpreter. */
1915 int objc, /* Number of arguments. */
1916 Tcl_Obj *const objv[]) /* Argument objects. */
1917 {
1918 register Tk_Window frameWin = (Tk_Window) winPtr;
2022 TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */
2023 TCL_UNUSED(int), /* Number of arguments. */
2024 TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
2025 {
2026 Tk_Window frameWin = (Tk_Window)winPtr;
19192027
19202028 if (Tk_IsTopLevel(frameWin)) {
19212029 MacDrawable *macWin;
19232031 Tk_MakeWindowExist(frameWin);
19242032 Tk_MakeWindowExist((Tk_Window)winPtr->parentPtr);
19252033
1926 macWin = (MacDrawable *) winPtr->window;
2034 macWin = (MacDrawable *)winPtr->window;
19272035
19282036 TkFocusJoin(winPtr);
19292037 Tk_UnmapWindow(frameWin);
19342042 macWin->flags &= ~TK_HOST_EXISTS;
19352043
19362044 TkWmDeadWindow(winPtr);
1937 RemapWindows(winPtr, (MacDrawable *) winPtr->parentPtr->window);
2045 RemapWindows(winPtr, (MacDrawable *)winPtr->parentPtr->window);
19382046
19392047 /*
19402048 * Make sure wm no longer manages this window
19752083
19762084 static int
19772085 WmFrameCmd(
1978 Tk_Window tkwin, /* Main window of the application. */
2086 TCL_UNUSED(Tk_Window), /* Main window of the application. */
19792087 TkWindow *winPtr, /* Toplevel to work with */
19802088 Tcl_Interp *interp, /* Current interpreter. */
19812089 int objc, /* Number of arguments. */
19822090 Tcl_Obj *const objv[]) /* Argument objects. */
19832091 {
1984 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2092 WmInfo *wmPtr = winPtr->wmInfoPtr;
19852093 Window window;
19862094 char buf[TCL_INTEGER_SPACE];
19872095
19912099 }
19922100 window = wmPtr->reparent;
19932101 if (window == None) {
1994 window = Tk_WindowId((Tk_Window) winPtr);
2102 window = Tk_WindowId((Tk_Window)winPtr);
19952103 }
19962104 sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window);
19972105 Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
20172125
20182126 static int
20192127 WmGeometryCmd(
2020 Tk_Window tkwin, /* Main window of the application. */
2128 TCL_UNUSED(Tk_Window), /* Main window of the application. */
20212129 TkWindow *winPtr, /* Toplevel to work with */
20222130 Tcl_Interp *interp, /* Current interpreter. */
20232131 int objc, /* Number of arguments. */
20242132 Tcl_Obj *const objv[]) /* Argument objects. */
20252133 {
2026 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2027 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
2134 WmInfo *wmPtr = winPtr->wmInfoPtr;
2135 NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
20282136 char xSign = '+', ySign = '+';
20292137 int width, height, x = wmPtr->x, y= wmPtr->y;
20302138 char *argv3;
20882196
20892197 static int
20902198 WmGridCmd(
2091 Tk_Window tkwin, /* Main window of the application. */
2199 TCL_UNUSED(Tk_Window), /* Main window of the application. */
20922200 TkWindow *winPtr, /* Toplevel to work with */
20932201 Tcl_Interp *interp, /* Current interpreter. */
20942202 int objc, /* Number of arguments. */
20952203 Tcl_Obj *const objv[]) /* Argument objects. */
20962204 {
2097 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2205 WmInfo *wmPtr = winPtr->wmInfoPtr;
20982206 int reqWidth, reqHeight, widthInc, heightInc;
20992207 const char *errorMsg;
21002208
21502258 errorMsg = "heightInc can't be <= 0";
21512259 goto error;
21522260 }
2153 Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
2261 Tk_SetGrid((Tk_Window)winPtr, reqWidth, reqHeight, widthInc,
21542262 heightInc);
21552263 }
21562264 wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
21882296 int objc, /* Number of arguments. */
21892297 Tcl_Obj *const objv[]) /* Argument objects. */
21902298 {
2191 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2299 WmInfo *wmPtr = winPtr->wmInfoPtr;
21922300 Tk_Window tkwin2;
21932301 char *argv3;
21942302 int length;
22212329 }
22222330 wmPtr->hints.window_group = Tk_WindowId(tkwin2);
22232331 wmPtr->hints.flags |= WindowGroupHint;
2224 wmPtr->leaderName = ckalloc(length + 1);
2332 wmPtr->leaderName = (char *)ckalloc(length + 1);
22252333 strcpy(wmPtr->leaderName, argv3);
22262334 }
22272335 return TCL_OK;
22462354
22472355 static int
22482356 WmIconbitmapCmd(
2249 Tk_Window tkwin, /* Main window of the application. */
2357 TCL_UNUSED(Tk_Window), /* Main window of the application. */
22502358 TkWindow *winPtr, /* Toplevel to work with */
22512359 Tcl_Interp *interp, /* Current interpreter. */
22522360 int objc, /* Number of arguments. */
22532361 Tcl_Obj *const objv[]) /* Argument objects. */
22542362 {
2255 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2363 WmInfo *wmPtr = winPtr->wmInfoPtr;
22562364 Pixmap pixmap;
22572365 char *str;
22582366 int len;
22712379 }
22722380 str = Tcl_GetStringFromObj(objv[3], &len);
22732381 if (winPtr->window == None) {
2274 Tk_MakeWindowExist((Tk_Window) winPtr);
2382 Tk_MakeWindowExist((Tk_Window)winPtr);
22752383 }
22762384 if (!TkMacOSXHostToplevelExists(winPtr)) {
22772385 TkMacOSXMakeRealWindowExist(winPtr);
22782386 }
2279 if (WmSetAttribute(winPtr, TkMacOSXDrawableWindow(winPtr->window), interp,
2387 if (WmSetAttribute(winPtr, TkMacOSXGetNSWindowForDrawable(winPtr->window), interp,
22802388 WMATT_TITLEPATH, objv[3]) == TCL_OK) {
22812389 if (!len) {
22822390 if (wmPtr->hints.icon_pixmap != None) {
22862394 wmPtr->hints.flags &= ~IconPixmapHint;
22872395 }
22882396 } else {
2289 pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, Tk_GetUid(str));
2397 pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, Tk_GetUid(str));
22902398 if (pixmap == None) {
22912399 return TCL_ERROR;
22922400 }
23152423
23162424 static int
23172425 WmIconifyCmd(
2318 Tk_Window tkwin, /* Main window of the application. */
2426 TCL_UNUSED(Tk_Window), /* Main window of the application. */
23192427 TkWindow *winPtr, /* Toplevel to work with */
23202428 Tcl_Interp *interp, /* Current interpreter. */
23212429 int objc, /* Number of arguments. */
23222430 Tcl_Obj *const objv[]) /* Argument objects. */
23232431 {
2324 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2432 WmInfo *wmPtr = winPtr->wmInfoPtr;
23252433 if (objc != 3) {
23262434 Tcl_WrongNumArgs(interp, 2, objv, "window");
23272435 return TCL_ERROR;
23282436 }
23292437
2330 if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
2438 if (Tk_Attributes((Tk_Window)winPtr)->override_redirect) {
23312439 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
23322440 "can't iconify \"%s\": override-redirect flag is set",
23332441 winPtr->pathName));
23342442 Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT",
23352443 NULL);
23362444 return TCL_ERROR;
2337 } else if (wmPtr->master != NULL) {
2445 } else if (wmPtr->container != NULL) {
23382446 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
23392447 "can't iconify \"%s\": it is a transient", winPtr->pathName));
23402448 Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL);
23602468
23612469 /*
23622470 * If this window has a transient the transient must be withdrawn when
2363 * the master is iconified.
2471 * the container is iconified.
23642472 */
23652473
23662474 for (Transient *transientPtr = wmPtr->transientPtr;
23672475 transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
23682476 TkWindow *winPtr2 = transientPtr->winPtr;
2369 TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
2370 if (masterPtr == winPtr &&
2477 TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer(winPtr2);
2478 if (containerPtr == winPtr &&
23712479 winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
23722480 TkpWmSetState(winPtr2, WithdrawnState);
2373 transientPtr->flags |= WITHDRAWN_BY_MASTER;
2481 transientPtr->flags |= WITHDRAWN_BY_CONTAINER;
23742482 }
23752483 }
23762484
24022510 int objc, /* Number of arguments. */
24032511 Tcl_Obj *const objv[]) /* Argument objects. */
24042512 {
2405 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2513 WmInfo *wmPtr = winPtr->wmInfoPtr;
24062514 Pixmap pixmap;
24072515 char *argv3;
24082516
24562564
24572565 static int
24582566 WmIconnameCmd(
2459 Tk_Window tkwin, /* Main window of the application. */
2567 TCL_UNUSED(Tk_Window), /* Main window of the application. */
24602568 TkWindow *winPtr, /* Toplevel to work with */
24612569 Tcl_Interp *interp, /* Current interpreter. */
24622570 int objc, /* Number of arguments. */
24632571 Tcl_Obj *const objv[]) /* Argument objects. */
24642572 {
2465 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2573 WmInfo *wmPtr = winPtr->wmInfoPtr;
24662574 const char *argv3;
24672575 int length;
24682576
24812589 ckfree(wmPtr->iconName);
24822590 }
24832591 argv3 = Tcl_GetStringFromObj(objv[3], &length);
2484 wmPtr->iconName = ckalloc(length + 1);
2592 wmPtr->iconName = (char *)ckalloc(length + 1);
24852593 strcpy(wmPtr->iconName, argv3);
24862594 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
24872595 XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
25332641 isDefault = 1;
25342642 if (objc == 4) {
25352643 Tcl_WrongNumArgs(interp, 2, objv,
2536 "window ?-default? image1 ?image2 ...?");
2644 "window ?-default? image1 ?image2 ...?");
25372645 return TCL_ERROR;
25382646 }
25392647 }
25652673
25662674 Tk_SizeOfImage(tk_icon, &width, &height);
25672675 if (width != 0 && height != 0) {
2568 newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon,
2676 newIcon = TkMacOSXGetNSImageFromTkImage(winPtr->display, tk_icon,
25692677 width, height);
25702678 }
25712679 Tk_FreeImage(tk_icon);
25982706
25992707 static int
26002708 WmIconpositionCmd(
2601 Tk_Window tkwin, /* Main window of the application. */
2709 TCL_UNUSED(Tk_Window), /* Main window of the application. */
26022710 TkWindow *winPtr, /* Toplevel to work with */
26032711 Tcl_Interp *interp, /* Current interpreter. */
26042712 int objc, /* Number of arguments. */
26052713 Tcl_Obj *const objv[]) /* Argument objects. */
26062714 {
2607 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2715 WmInfo *wmPtr = winPtr->wmInfoPtr;
26082716 int x, y;
26092717
26102718 if ((objc != 3) && (objc != 5)) {
26622770 int objc, /* Number of arguments. */
26632771 Tcl_Obj *const objv[]) /* Argument objects. */
26642772 {
2665 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2773 WmInfo *wmPtr = winPtr->wmInfoPtr;
26662774 Tk_Window tkwin2;
26672775 WmInfo *wmPtr2;
26682776
26812789 if (*Tcl_GetString(objv[3]) == '\0') {
26822790 wmPtr->hints.flags &= ~IconWindowHint;
26832791 if (wmPtr->icon != NULL) {
2684 wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
2792 wmPtr2 = ((TkWindow *)wmPtr->icon)->wmInfoPtr;
26852793 wmPtr2->iconFor = NULL;
26862794 wmPtr2->hints.initial_state = WithdrawnState;
26872795 }
26982806 NULL);
26992807 return TCL_ERROR;
27002808 }
2701 wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
2809 wmPtr2 = ((TkWindow *)tkwin2)->wmInfoPtr;
27022810 if (wmPtr2->iconFor != NULL) {
27032811 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
27042812 "%s is already an icon for %s",
27092817 if (wmPtr->icon != NULL) {
27102818 TkWindow *oldIcon = (TkWindow *)wmPtr->icon;
27112819 WmInfo *wmPtr3 = oldIcon->wmInfoPtr;
2712 NSWindow *win = TkMacOSXDrawableWindow(oldIcon->window);
2820 NSWindow *win = TkMacOSXGetNSWindowForDrawable(oldIcon->window);
27132821
27142822 /*
27152823 * The old icon should be withdrawn.
27242832 wmPtr->hints.icon_window = Tk_WindowId(tkwin2);
27252833 wmPtr->hints.flags |= IconWindowHint;
27262834 wmPtr->icon = tkwin2;
2727 wmPtr2->iconFor = (Tk_Window) winPtr;
2835 wmPtr2->iconFor = (Tk_Window)winPtr;
27282836 if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
27292837 /*
27302838 * If the window is in normal or zoomed state, the icon should be
27592867
27602868 static int
27612869 WmManageCmd(
2762 Tk_Window tkwin, /* Main window of the application. */
2763 TkWindow *winPtr, /* Toplevel or Frame to work with */
2764 Tcl_Interp *interp, /* Current interpreter. */
2765 int objc, /* Number of arguments. */
2766 Tcl_Obj *const objv[]) /* Argument objects. */
2767 {
2768 register Tk_Window frameWin = (Tk_Window) winPtr;
2769 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2870 TCL_UNUSED(Tk_Window), /* Main window of the application. */
2871 TkWindow *winPtr, /* Toplevel or Frame to work with */
2872 Tcl_Interp *interp, /* Current interpreter. */
2873 TCL_UNUSED(int), /* Number of arguments. */
2874 TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
2875 {
2876 Tk_Window frameWin = (Tk_Window)winPtr;
2877 WmInfo *wmPtr = winPtr->wmInfoPtr;
27702878
27712879 if (!Tk_IsTopLevel(frameWin)) {
2772 MacDrawable *macWin = (MacDrawable *) winPtr->window;
2880 MacDrawable *macWin = (MacDrawable *)winPtr->window;
27732881
27742882 if (!Tk_IsManageable(frameWin)) {
27752883 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
27792887 Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL);
27802888 return TCL_ERROR;
27812889 }
2890
2891 /*
2892 * Draw the managed widget at the top left corner of its toplevel.
2893 * See [4a40c6cace].
2894 */
2895
2896 if (macWin) {
2897 winPtr->changes.x -= macWin->xOff;
2898 winPtr->changes.y -= macWin->yOff;
2899 XMoveWindow(winPtr->display, winPtr->window, 0, 0);
2900 }
2901
27822902 TkFocusSplit(winPtr);
27832903 Tk_UnmapWindow(frameWin);
27842904 if (wmPtr == NULL) {
27852905 TkWmNewWindow(winPtr);
27862906 if (winPtr->window == None) {
2787 Tk_MakeWindowExist((Tk_Window) winPtr);
2788 macWin = (MacDrawable *) winPtr->window;
2907 Tk_MakeWindowExist((Tk_Window)winPtr);
2908 macWin = (MacDrawable *)winPtr->window;
27892909 }
27902910 }
27912911 wmPtr = winPtr->wmInfoPtr;
28232943
28242944 static int
28252945 WmMaxsizeCmd(
2826 Tk_Window tkwin, /* Main window of the application. */
2946 TCL_UNUSED(Tk_Window), /* Main window of the application. */
28272947 TkWindow *winPtr, /* Toplevel to work with */
28282948 Tcl_Interp *interp, /* Current interpreter. */
28292949 int objc, /* Number of arguments. */
28302950 Tcl_Obj *const objv[]) /* Argument objects. */
28312951 {
2832 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2952 WmInfo *wmPtr = winPtr->wmInfoPtr;
28332953 int width, height;
28342954
28352955 if ((objc != 3) && (objc != 5)) {
28772997
28782998 static int
28792999 WmMinsizeCmd(
2880 Tk_Window tkwin, /* Main window of the application. */
3000 TCL_UNUSED(Tk_Window), /* Main window of the application. */
28813001 TkWindow *winPtr, /* Toplevel to work with */
28823002 Tcl_Interp *interp, /* Current interpreter. */
28833003 int objc, /* Number of arguments. */
28843004 Tcl_Obj *const objv[]) /* Argument objects. */
28853005 {
2886 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3006 WmInfo *wmPtr = winPtr->wmInfoPtr;
28873007 int width, height;
28883008
28893009 if ((objc != 3) && (objc != 5)) {
29313051
29323052 static int
29333053 WmOverrideredirectCmd(
2934 Tk_Window tkwin, /* Main window of the application. */
3054 TCL_UNUSED(Tk_Window), /* Main window of the application. */
29353055 TkWindow *winPtr, /* Toplevel to work with */
29363056 Tcl_Interp *interp, /* Current interpreter. */
29373057 int objc, /* Number of arguments. */
29393059 {
29403060 int flag;
29413061 XSetWindowAttributes atts;
2942 TKWindow *win = (TKWindow *)TkMacOSXDrawableWindow(winPtr->window);
3062 TKWindow *win = (TKWindow *)TkMacOSXGetNSWindowForDrawable(winPtr->window);
29433063
29443064 if ((objc != 3) && (objc != 4)) {
29453065 Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
29483068
29493069 if (objc == 3) {
29503070 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
2951 Tk_Attributes((Tk_Window) winPtr)->override_redirect));
3071 Tk_Attributes((Tk_Window)winPtr)->override_redirect));
29523072 return TCL_OK;
29533073 }
29543074
29563076 return TCL_ERROR;
29573077 }
29583078 atts.override_redirect = flag ? True : False;
2959 Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts);
2960 ApplyMasterOverrideChanges(winPtr, win);
3079 Tk_ChangeWindowAttributes((Tk_Window)winPtr, CWOverrideRedirect, &atts);
3080 ApplyContainerOverrideChanges(winPtr, win);
29613081 return TCL_OK;
29623082 }
29633083
29803100
29813101 static int
29823102 WmPositionfromCmd(
2983 Tk_Window tkwin, /* Main window of the application. */
3103 TCL_UNUSED(Tk_Window), /* Main window of the application. */
29843104 TkWindow *winPtr, /* Toplevel to work with */
29853105 Tcl_Interp *interp, /* Current interpreter. */
29863106 int objc, /* Number of arguments. */
29873107 Tcl_Obj *const objv[]) /* Argument objects. */
29883108 {
2989 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3109 WmInfo *wmPtr = winPtr->wmInfoPtr;
29903110 static const char *const optionStrings[] = {
29913111 "program", "user", NULL };
29923112 enum options {
30463166
30473167 static int
30483168 WmProtocolCmd(
3049 Tk_Window tkwin, /* Main window of the application. */
3169 TCL_UNUSED(Tk_Window), /* Main window of the application. */
30503170 TkWindow *winPtr, /* Toplevel to work with */
30513171 Tcl_Interp *interp, /* Current interpreter. */
30523172 int objc, /* Number of arguments. */
30533173 Tcl_Obj *const objv[]) /* Argument objects. */
30543174 {
3055 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3056 register ProtocolHandler *protPtr, *prevPtr;
3175 WmInfo *wmPtr = winPtr->wmInfoPtr;
3176 ProtocolHandler *protPtr, *prevPtr;
30573177 Atom protocol;
30583178 char *cmd;
30593179 int cmdLength;
30793199 return TCL_OK;
30803200 }
30813201
3082 protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3]));
3202 protocol = Tk_InternAtom((Tk_Window)winPtr, Tcl_GetString(objv[3]));
30833203 if (objc == 4) {
30843204 /*
30853205 * Return the command to handle a given protocol.
31173237 }
31183238 cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
31193239 if (cmdLength > 0) {
3120 protPtr = ckalloc(sizeof(ProtocolHandler));
3240 protPtr = (ProtocolHandler *)ckalloc(sizeof(ProtocolHandler));
31213241 protPtr->protocol = protocol;
31223242 protPtr->nextPtr = wmPtr->protPtr;
31233243 wmPtr->protPtr = protPtr;
31243244 protPtr->interp = interp;
3125 protPtr->command = ckalloc(cmdLength+1);
3245 protPtr->command = (char *)ckalloc(cmdLength+1);
31263246 strcpy(protPtr->command, cmd);
31273247 }
31283248 return TCL_OK;
31473267
31483268 static int
31493269 WmResizableCmd(
3150 Tk_Window tkwin, /* Main window of the application. */
3270 TCL_UNUSED(Tk_Window), /* Main window of the application. */
31513271 TkWindow *winPtr, /* Toplevel to work with */
31523272 Tcl_Interp *interp, /* Current interpreter. */
31533273 int objc, /* Number of arguments. */
31543274 Tcl_Obj *const objv[]) /* Argument objects. */
31553275 {
3156 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3276 WmInfo *wmPtr = winPtr->wmInfoPtr;
31573277 int width, height;
31583278 UInt64 oldAttributes = wmPtr->attributes;
31593279 int oldFlags = wmPtr->flags;
32243344
32253345 static int
32263346 WmSizefromCmd(
3227 Tk_Window tkwin, /* Main window of the application. */
3347 TCL_UNUSED(Tk_Window), /* Main window of the application. */
32283348 TkWindow *winPtr, /* Toplevel to work with */
32293349 Tcl_Interp *interp, /* Current interpreter. */
32303350 int objc, /* Number of arguments. */
32313351 Tcl_Obj *const objv[]) /* Argument objects. */
32323352 {
3233 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3353 WmInfo *wmPtr = winPtr->wmInfoPtr;
32343354 static const char *const optionStrings[] = {
32353355 "program", "user", NULL };
32363356 enum options {
33173437 resultObj = Tcl_NewObj();
33183438 for (windowPtr = windows; *windowPtr ; windowPtr++) {
33193439 Tcl_ListObjAppendElement(NULL, resultObj,
3320 TkNewWindowObj((Tk_Window) *windowPtr));
3440 TkNewWindowObj((Tk_Window)*windowPtr));
33213441 }
33223442 Tcl_SetObjResult(interp, resultObj);
33233443 ckfree(windows);
34163536
34173537 static int
34183538 WmStateCmd(
3419 Tk_Window tkwin, /* Main window of the application. */
3539 TCL_UNUSED(Tk_Window), /* Main window of the application. */
34203540 TkWindow *winPtr, /* Toplevel to work with */
34213541 Tcl_Interp *interp, /* Current interpreter. */
34223542 int objc, /* Number of arguments. */
34233543 Tcl_Obj *const objv[]) /* Argument objects. */
34243544 {
3425 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3545 WmInfo *wmPtr = winPtr->wmInfoPtr;
34263546 static const char *const optionStrings[] = {
34273547 "normal", "iconic", "withdrawn", "zoomed", NULL };
34283548 enum options {
34663586
34673587 break;
34683588 case OPT_ICONIC:
3469 if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
3589 if (Tk_Attributes((Tk_Window)winPtr)->override_redirect) {
34703590 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
34713591 "can't iconify \"%s\": override-redirect flag is set",
34723592 winPtr->pathName));
34743594 "OVERRIDE_REDIRECT", NULL);
34753595 return TCL_ERROR;
34763596 }
3477 if (wmPtr->master != NULL) {
3597 if (wmPtr->container != NULL) {
34783598 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
34793599 "can't iconify \"%s\": it is a transient",
34803600 winPtr->pathName));
35363656
35373657 static int
35383658 WmTitleCmd(
3539 Tk_Window tkwin, /* Main window of the application. */
3659 TCL_UNUSED(Tk_Window), /* Main window of the application. */
35403660 TkWindow *winPtr, /* Toplevel to work with */
35413661 Tcl_Interp *interp, /* Current interpreter. */
35423662 int objc, /* Number of arguments. */
35433663 Tcl_Obj *const objv[]) /* Argument objects. */
35443664 {
3545 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3665 WmInfo *wmPtr = winPtr->wmInfoPtr;
35463666 char *argv3;
35473667 int length;
35483668
35903710 int objc, /* Number of arguments. */
35913711 Tcl_Obj *const objv[]) /* Argument objects. */
35923712 {
3593 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3594 Tk_Window master;
3595 TkWindow *masterPtr, *w;
3713 WmInfo *wmPtr = winPtr->wmInfoPtr;
3714 Tk_Window container;
3715 TkWindow *containerPtr, *w;
35963716 WmInfo *wmPtr2;
35973717 Transient *transient;
35983718
36013721 return TCL_ERROR;
36023722 }
36033723 if (objc == 3) {
3604 if (wmPtr->master != NULL) {
3724 if (wmPtr->container != NULL) {
36053725 Tcl_SetObjResult(interp,
3606 Tcl_NewStringObj(Tk_PathName(wmPtr->master), -1));
3726 Tcl_NewStringObj(Tk_PathName(wmPtr->container), -1));
36073727 }
36083728 return TCL_OK;
36093729 }
36103730 if (*Tcl_GetString(objv[3]) == '\0') {
36113731 RemoveTransient(winPtr);
36123732 } else {
3613 if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
3733 if (TkGetWindowFromObj(interp, tkwin, objv[3], &container) != TCL_OK) {
36143734 return TCL_ERROR;
36153735 }
3616 masterPtr = (TkWindow*) master;
3617 while (!Tk_TopWinHierarchy(masterPtr)) {
3736 containerPtr = (TkWindow*) container;
3737 while (!Tk_TopWinHierarchy(containerPtr)) {
36183738 /*
3619 * Ensure that the master window is actually a Tk toplevel.
3739 * Ensure that the container window is actually a Tk toplevel.
36203740 */
36213741
3622 masterPtr = masterPtr->parentPtr;
3742 containerPtr = containerPtr->parentPtr;
36233743 }
3624 Tk_MakeWindowExist((Tk_Window)masterPtr);
3744 Tk_MakeWindowExist((Tk_Window)containerPtr);
36253745
36263746 if (wmPtr->iconFor != NULL) {
36273747 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
36313751 return TCL_ERROR;
36323752 }
36333753
3634 wmPtr2 = masterPtr->wmInfoPtr;
3754 wmPtr2 = containerPtr->wmInfoPtr;
36353755
36363756 /*
36373757 * Under some circumstances, wmPtr2 is NULL here.
36453765 return TCL_ERROR;
36463766 }
36473767
3648 for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL;
3649 w = (TkWindow *)w->wmInfoPtr->master) {
3768 for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
3769 w = (TkWindow *)w->wmInfoPtr->container) {
36503770 if (w == winPtr) {
36513771 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
36523772 "setting \"%s\" as master creates a transient/master cycle",
3653 Tk_PathName(masterPtr)));
3773 Tk_PathName(containerPtr)));
36543774 Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
36553775 return TCL_ERROR;
36563776 }
36573777 }
36583778
36593779 /*
3660 * Add the transient to the master's list, if it not already there.
3780 * Add the transient to the container's list, if it not already there.
36613781 */
36623782
36633783 for (transient = wmPtr2->transientPtr;
36643784 transient != NULL && transient->winPtr != winPtr;
36653785 transient = transient->nextPtr) {}
36663786 if (transient == NULL) {
3667 transient = ckalloc(sizeof(Transient));
3787 transient = (Transient *)ckalloc(sizeof(Transient));
36683788 transient->winPtr = winPtr;
36693789 transient->flags = 0;
36703790 transient->nextPtr = wmPtr2->transientPtr;
36723792 }
36733793
36743794 /*
3675 * If the master is withdrawn or iconic then withdraw the transient.
3795 * If the container is withdrawn or iconic then withdraw the transient.
36763796 */
36773797
36783798 if ((wmPtr2->hints.initial_state == WithdrawnState ||
36793799 wmPtr2->hints.initial_state == IconicState) &&
36803800 wmPtr->hints.initial_state != WithdrawnState) {
36813801 TkpWmSetState(winPtr, WithdrawnState);
3682 transient->flags |= WITHDRAWN_BY_MASTER;
3683 }
3684
3685 wmPtr->master = (Tk_Window) masterPtr;
3686 }
3687 ApplyMasterOverrideChanges(winPtr, NULL);
3802 transient->flags |= WITHDRAWN_BY_CONTAINER;
3803 }
3804
3805 wmPtr->container = (Tk_Window)containerPtr;
3806 }
3807 ApplyContainerOverrideChanges(winPtr, NULL);
36883808 return TCL_OK;
36893809 }
36903810
36933813 *
36943814 * RemoveTransient --
36953815 *
3696 * Clears the transient's master record and removes the transient from the
3697 * master's list.
3816 * Clears the transient's container record and removes the transient from the
3817 * container's list.
36983818 *
36993819 * Results:
37003820 * None
37013821 *
37023822 * Side effects:
3703 * References to a master are removed from the transient's wmInfo
3704 * structure and references to the transient are removed from its master's
3823 * References to a container are removed from the transient's wmInfo
3824 * structure and references to the transient are removed from its container's
37053825 * wmInfo.
37063826 *
37073827 *----------------------------------------------------------------------
37123832 TkWindow *winPtr)
37133833 {
37143834 WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
3715 TkWindow *masterPtr;
3835 TkWindow *containerPtr;
37163836 Transient *transPtr, *temp;
37173837
3718 if (wmPtr == NULL || wmPtr->master == NULL) {
3838 if (wmPtr == NULL || wmPtr->container == NULL) {
37193839 return;
37203840 }
3721 masterPtr = (TkWindow*)wmPtr->master;
3722 wmPtr2 = masterPtr->wmInfoPtr;
3841 containerPtr = (TkWindow *)wmPtr->container;
3842 wmPtr2 = containerPtr->wmInfoPtr;
37233843 if (wmPtr2 == NULL) {
37243844 return;
37253845 }
3726 wmPtr->master = NULL;
3846 wmPtr->container= NULL;
37273847 transPtr = wmPtr2->transientPtr;
37283848 while (transPtr != NULL) {
37293849 if (transPtr->winPtr != winPtr) {
37643884
37653885 static int
37663886 WmWithdrawCmd(
3767 Tk_Window tkwin, /* Main window of the application. */
3887 TCL_UNUSED(Tk_Window), /* Main window of the application. */
37683888 TkWindow *winPtr, /* Toplevel to work with */
37693889 Tcl_Interp *interp, /* Current interpreter. */
37703890 int objc, /* Number of arguments. */
37713891 Tcl_Obj *const objv[]) /* Argument objects. */
37723892 {
3773 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3893 WmInfo *wmPtr = winPtr->wmInfoPtr;
37743894
37753895 if (objc != 3) {
37763896 Tcl_WrongNumArgs(interp, 2, objv, "window");
37873907
37883908 TkpWmSetState(winPtr, WithdrawnState);
37893909
3790 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
3791 [win orderOut:nil];
3792 [win setExcludedFromWindowsMenu:YES];
3793
37943910 /*
37953911 * If this window has a transient, the transient must also be withdrawn.
37963912 */
37983914 for (Transient *transientPtr = wmPtr->transientPtr;
37993915 transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
38003916 TkWindow *winPtr2 = transientPtr->winPtr;
3801 TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
3802
3803 if (masterPtr == winPtr &&
3917 TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer(winPtr2);
3918
3919 if (containerPtr == winPtr &&
38043920 winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
38053921 TkpWmSetState(winPtr2, WithdrawnState);
3806 transientPtr->flags |= WITHDRAWN_BY_MASTER;
3922 transientPtr->flags |= WITHDRAWN_BY_CONTAINER;
38073923 }
38083924 }
38093925
38603976 int widthInc, int heightInc)/* Pixel increments corresponding to a change
38613977 * of one grid unit. */
38623978 {
3863 TkWindow *winPtr = (TkWindow *) tkwin;
3979 TkWindow *winPtr = (TkWindow *)tkwin;
38643980 WmInfo *wmPtr;
38653981
38663982 /*
39544070 Tk_Window tkwin) /* Token for window that is currently
39554071 * controlling gridding. */
39564072 {
3957 TkWindow *winPtr = (TkWindow *) tkwin;
4073 TkWindow *winPtr = (TkWindow *)tkwin;
39584074 WmInfo *wmPtr;
39594075
39604076 /*
40274143 Tk_ErrorHandler handler = Tk_CreateErrorHandler(winPtr->display,
40284144 -1, -1, -1, NULL, NULL);
40294145
4030 Tk_DestroyWindow((Tk_Window) winPtr);
4146 Tk_DestroyWindow((Tk_Window)winPtr);
40314147 Tk_DeleteErrorHandler(handler);
40324148 }
40334149 if (wmTracing) {
40344150 TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName);
40354151 }
40364152 } else if (eventPtr->type == ReparentNotify) {
4037 Tcl_Panic("recieved unwanted reparent event");
4153 Tcl_Panic("received unwanted reparent event");
40384154 }
40394155 }
40404156
40564172 *----------------------------------------------------------------------
40574173 */
40584174
4059 /* ARGSUSED */
40604175 static void
40614176 TopLevelReqProc(
4062 ClientData dummy, /* Not used. */
4177 TCL_UNUSED(void *), /* Not used. */
40634178 Tk_Window tkwin) /* Information about window. */
40644179 {
4065 TkWindow *winPtr = (TkWindow *) tkwin;
4180 TkWindow *winPtr = (TkWindow *)tkwin;
40664181 WmInfo *wmPtr;
40674182
40684183 wmPtr = winPtr->wmInfoPtr;
42424357
42434358 wmPtr->x = wmPtr->y = 0;
42444359 wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
4245 Tk_GeometryRequest((Tk_Window) contWinPtr, width, height);
4360 Tk_GeometryRequest((Tk_Window)contWinPtr, width, height);
42464361 }
42474362 return;
42484363 }
44954610 int *yPtr) /* Where to store y-displacement of (0,0). */
44964611 {
44974612 int x, y;
4498 TkWindow *winPtr = (TkWindow *) tkwin;
4613 TkWindow *winPtr = (TkWindow *)tkwin;
44994614
45004615 /*
45014616 * Search back through this window's parents all the way to a top-level
45224637
45234638 /*
45244639 * We do not require that the changes.x & changes.y for a
4525 * non-Tk master window be kept up to date. So we first
4526 * subtract off the possibly bogus values that have been
4527 * added on at the top of this pass through the loop, and
4528 * then call out to the getOffsetProc to give us the
4529 * correct offset.
4640 * non-Tk container window be kept up to date. So we
4641 * first subtract off the possibly bogus values that have
4642 * been added on at the top of this pass through the
4643 * loop, and then call out to the getOffsetProc to give
4644 * us the correct offset.
45304645 */
45314646
45324647 x -= winPtr->changes.x + winPtr->changes.border_width;
45334648 y -= winPtr->changes.y + winPtr->changes.border_width;
45344649
4535 tkMacOSXEmbedHandler->getOffsetProc((Tk_Window) winPtr,
4650 tkMacOSXEmbedHandler->getOffsetProc((Tk_Window)winPtr,
45364651 &theOffset);
45374652
45384653 x += theOffset.h;
46594774 }
46604775 winPtr = nextPtr;
46614776 }
4662 if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) {
4777 if (winPtr->mainPtr != ((TkWindow *)tkwin)->mainPtr) {
46634778 return NULL;
46644779 }
4665 return (Tk_Window) winPtr;
4780 return (Tk_Window)winPtr;
46664781 }
46674782
46684783 /*
47024817 int x, y; /* Coordinates in winPtr. */
47034818 Window *children; /* Children of winPtr, or NULL. */
47044819
4705 winPtr = (TkWindow *) tkwin;
4820 winPtr = (TkWindow *)tkwin;
47064821 x = rootX;
47074822 y = rootY;
47084823 while (1) {
47554870 }
47564871 *newX = x;
47574872 *newY = y;
4758 return (Tk_Window) winPtr;
4873 return (Tk_Window)winPtr;
47594874 }
47604875
47614876 /*
48564971 int *heightPtr)
48574972 {
48584973 WmInfo *wmPtr;
4859 TkWindow *winPtr = (TkWindow *) tkwin;
4974 TkWindow *winPtr = (TkWindow *)tkwin;
48604975
48614976 /*
48624977 * Find the top-level window for tkwin, and locate the window manager
49075022 Tk_Window tkwin, /* Window to move. */
49085023 int x, int y) /* New location for window (within parent). */
49095024 {
4910 TkWindow *winPtr = (TkWindow *) tkwin;
5025 TkWindow *winPtr = (TkWindow *)tkwin;
49115026 WmInfo *wmPtr = winPtr->wmInfoPtr;
49125027
49135028 if (!(winPtr->flags & TK_TOP_LEVEL)) {
49775092 wmPtr->hints.initial_state == WithdrawnState) {
49785093 return;
49795094 }
4980 macWindow = TkMacOSXDrawableWindow(winPtr->window);
5095 macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
49815096 if (macWindow == nil) {
49825097 return;
49835098 }
49935108 otherWmPtr->hints.initial_state == WithdrawnState) {
49945109 return;
49955110 }
4996 otherMacWindow = TkMacOSXDrawableWindow(otherPtr->window);
5111 otherMacWindow = TkMacOSXGetNSWindowForDrawable(otherPtr->window);
49975112 if (otherMacWindow == nil) {
49985113 return;
49995114 }
50825197 * add the toplevel itself as the last element of the list.
50835198 */
50845199
5085 newPtr = ckalloc((count+2) * sizeof(TkWindow *));
5200 newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *));
50865201 if (count > 0) {
50875202 memcpy(newPtr, oldPtr, count * sizeof(TkWindow *));
50885203 }
50995214 topPtr->wmInfoPtr->cmapCount = count+1;
51005215
51015216 /*
5102 * On the Macintosh all of this is just an excercise in compatability as
5217 * On the Macintosh all of this is just an excercise in compatibility as
51035218 * we don't support colormaps. If we did they would be installed here.
51045219 */
51055220 }
51945309
51955310 void
51965311 TkGetPointerCoords(
5197 Tk_Window tkwin, /* Toplevel window that identifies screen on
5312 TCL_UNUSED(Tk_Window), /* Toplevel window that identifies screen on
51985313 * which lookup is to be done. */
51995314 int *xPtr, int *yPtr) /* Store pointer coordinates here. */
52005315 {
53025417
53035418 int
53045419 TkMacOSXGrowToplevel(
5305 void *whichWindow,
5306 XPoint start)
5420 TCL_UNUSED(void *),
5421 TCL_UNUSED(XPoint))
53075422 {
53085423 return false;
53095424 }
53355450 }
53365451
53375452 NSString *title = [[NSString alloc] initWithUTF8String:titleUid];
5338 [TkMacOSXDrawableWindow(winPtr->window) setTitle:title];
5453 [TkMacOSXGetNSWindowForDrawable(winPtr->window) setTitle:title];
53395454 [title release];
53405455 }
53415456
53425457 /*
53435458 *----------------------------------------------------------------------
53445459 *
5345 * TkGetTransientMaster --
5460 * TkMacOSXGetContainer --
53465461 *
53475462 * If the passed window has the TRANSIENT_FOR property set this will
5348 * return the master window. Otherwise it will return None.
5349 *
5350 * Results:
5351 * The master window or None.
5463 * return the container window. Otherwise it will return None.
5464 *
5465 * Results:
5466 * The container window or None.
53525467 *
53535468 * Side effects:
53545469 * None.
53575472 */
53585473
53595474 Tk_Window
5360 TkGetTransientMaster(
5475 TkMacOSXGetContainer(
53615476 TkWindow *winPtr)
53625477 {
53635478 if (winPtr->wmInfoPtr != NULL) {
5364 return (Tk_Window)winPtr->wmInfoPtr->master;
5479 return (Tk_Window)winPtr->wmInfoPtr->container;
53655480 }
53665481 return NULL;
53675482 }
53715486 *
53725487 * TkMacOSXGetXWindow --
53735488 *
5374 * Returns the X window Id associated with the given NSWindow*.
5489 * Stub function that returns the X window Id associated with the
5490 * given NSWindow*.
53755491 *
53765492 * Results:
53775493 * The window id is returned. None is returned if not a Tk window.
53865502 TkMacOSXGetXWindow(
53875503 void *macWinPtr)
53885504 {
5389 Tcl_HashEntry *hPtr;
5390
5391 if (!macWinPtr || !windowHashInit) {
5392 return None;
5393 }
5394 hPtr = Tcl_FindHashEntry(&windowTable, macWinPtr);
5395 if (hPtr == NULL) {
5396 return None;
5397 }
5398 return (Window) Tcl_GetHashValue(hPtr);
5399 }
5400
5401 /*
5402 *----------------------------------------------------------------------
5403 *
5404 * TkMacOSXGetTkWindow --
5405 *
5406 * Returns the TkWindow* associated with the given NSWindow*.
5407 *
5408 * Results:
5409 * The TkWindow* returned. NULL is returned if not a Tk window.
5505 Window window = None;
5506 TKWindow *w = (TKWindow *)macWinPtr;
5507 if ([w respondsToSelector: @selector (tkWindow)]) {
5508 window = [w tkWindow];
5509 }
5510 return window ? window : None;
5511 }
5512
5513 /*
5514 *----------------------------------------------------------------------
5515 *
5516 * Tk_MacOSXGetTkWindow --
5517 *
5518 * Returns the Tk_Window associated with the given NSWindow*. This
5519 * function is a stub, so the NSWindow* parameter must be declared as
5520 * void*.
5521 *
5522 * Results:
5523 * A Tk_Window, or NULL if the NSWindow is not associated with
5524 * any Tk window.
54105525 *
54115526 * Side effects:
54125527 * None.
54145529 *----------------------------------------------------------------------
54155530 */
54165531
5417 TkWindow*
5418 TkMacOSXGetTkWindow(
5419 NSWindow *w)
5420 {
5421 Window window = TkMacOSXGetXWindow(w);
5532 Tk_Window
5533 Tk_MacOSXGetTkWindow(
5534 void *w)
5535 {
5536 Window window = None;
54225537 TkDisplay *dispPtr = TkGetDisplayList();
5423
5538 if ([(NSWindow *)w respondsToSelector: @selector (tkWindow)]) {
5539 window = [(TKWindow *)w tkWindow];
5540 }
54245541 return (window != None ?
5425 (TkWindow *)Tk_IdToWindow(dispPtr->display, window) : NULL);
5542 Tk_IdToWindow(dispPtr->display, window) : NULL);
54265543 }
54275544
54285545 /*
54475564 TkMacOSXIsWindowZoomed(
54485565 TkWindow *winPtr)
54495566 {
5450 NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window);
5567 NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
54515568 return [macWindow isZoomed];
54525569 }
54535570
55205637 *----------------------------------------------------------------------
55215638 */
55225639
5523 /* ARGSUSED */
55245640 int
55255641 TkUnsupported1ObjCmd(
55265642 ClientData clientData, /* Main window associated with interpreter. */
55675683 }
55685684 return WmWinStyle(interp, winPtr, objc, objv);
55695685 case TKMWS_TABID:
5570 if ([NSApp macMinorVersion] < 12) {
5686 if ([NSApp macOSVersion] < 101200) {
55715687 Tcl_SetObjResult(interp, Tcl_NewStringObj(
55725688 "Tabbing identifiers did not exist until OSX 10.12.", -1));
55735689 Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TABBINGID", NULL);
55795695 }
55805696 return WmWinTabbingId(interp, winPtr, objc, objv);
55815697 case TKMWS_APPEARANCE:
5582 if ([NSApp macMinorVersion] < 9) {
5698 if ([NSApp macOSVersion] < 100900) {
55835699 Tcl_SetObjResult(interp, Tcl_NewStringObj(
55845700 "Window appearances did not exist until OSX 10.9.", -1));
55855701 Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL);
55895705 Tcl_WrongNumArgs(interp, 2, objv, "window ?appearancename?");
55905706 return TCL_ERROR;
55915707 }
5592 if (objc == 4 && [NSApp macMinorVersion] < 14) {
5708 if (objc == 4 && [NSApp macOSVersion] < 101400) {
55935709 Tcl_SetObjResult(interp, Tcl_NewStringObj(
55945710 "Window appearances cannot be changed before OSX 10.14.",
55955711 -1));
56035719 return TCL_ERROR;
56045720 }
56055721 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
5606 TkMacOSXInDarkMode((Tk_Window) winPtr)));
5722 TkMacOSXInDarkMode((Tk_Window)winPtr)));
56075723 return TCL_OK;
56085724 default:
56095725 return TCL_ERROR;
56565772 { "altPlain", kAltPlainWindowClass },
56575773 { "simple", kSimpleWindowClass },
56585774 { "drawer", kDrawerWindowClass },
5659 { NULL }
5775 { NULL, 0 }
56605776 };
56615777 static const struct StrIntMap compositeAttrMap[] = {
56625778 { "none", kWindowNoAttributes },
56635779 { "standardDocument", kWindowStandardDocumentAttributes },
56645780 { "standardFloating", kWindowStandardFloatingAttributes },
56655781 { "fullZoom", kWindowFullZoomAttribute },
5666 { NULL }
5782 { NULL, 0 }
56675783 };
56685784
56695785 /*
57005816 { "moveToActiveSpace", tkMoveToActiveSpaceAttribute },
57015817 { "nonActivating", tkNonactivatingPanelAttribute },
57025818 { "hud", tkHUDWindowAttribute },
5703 { NULL }
5819 { NULL, 0 }
57045820 };
57055821
57065822 int index, i;
58305946 #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200)
58315947 Tcl_Obj *result = NULL;
58325948 NSString *idString;
5833 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
5949 NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
58345950 if (win) {
58355951 idString = win.tabbingIdentifier;
58365952 result = Tcl_NewStringObj(idString.UTF8String, [idString length]);
58375953 }
58385954 if (result == NULL) {
5839 NSLog(@"Failed to read tabbing identifier; try calling update idletasks before getting/setting the tabbing identifier of the window.");
5955 NSLog(@"Failed to read tabbing identifier; try calling update idletasks"
5956 " before getting/setting the tabbing identifier of the window.");
58405957 return TCL_OK;
58415958 }
58425959 Tcl_SetObjResult(interp, result);
59206037 #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
59216038
59226039 const char *resultString = "unrecognized";
5923 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
6040 NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
59246041 if (win) {
59256042 appearance = win.appearance.name;
59266043 if (appearance == nil) {
59956112 * is always visible, e.g. as a floating
59966113 * menu. */
59976114 {
5998 TkWindow *winPtr = (TkWindow *) tkwin;
6115 TkWindow *winPtr = (TkWindow *)tkwin;
59996116
60006117 if (transient) {
60016118 winPtr->wmInfoPtr->macClass = kSimpleWindowClass;
60326149 WmInfo *wmPtr = winPtr->wmInfoPtr;
60336150 MacDrawable *macWin;
60346151 WindowClass macClass;
6035 Bool overrideRedirect = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
6152 Bool overrideRedirect = Tk_Attributes((Tk_Window)winPtr)->override_redirect;
60366153
60376154 if (TkMacOSXHostToplevelExists(winPtr)) {
60386155 return;
60396156 }
60406157
6041 macWin = (MacDrawable *) winPtr->window;
6158 macWin = (MacDrawable *)winPtr->window;
60426159
60436160 /*
60446161 * If this is embedded, make sure its container's toplevel exists, then
60596176 Tcl_Panic("TkMacOSXMakeRealWindowExist could not find container");
60606177 }
60616178 if (tkMacOSXEmbedHandler->containerExistProc &&
6062 tkMacOSXEmbedHandler->containerExistProc((Tk_Window) winPtr)
6179 tkMacOSXEmbedHandler->containerExistProc((Tk_Window)winPtr)
60636180 != TCL_OK) {
60646181 Tcl_Panic("ContainerExistProc could not make container");
60656182 }
60996216 NSUnifiedTitleAndToolbarWindowMask : 0) |
61006217 ((attributes & kWindowSideTitlebarAttribute) ? 1 << 9 : 0) |
61016218 (attributes >> WM_NSMASK_SHIFT);
6102 Class winClass = (macClass == kDrawerWindowClass ? [NSDrawerWindow class] :
6219 Class winClass = (macClass == kDrawerWindowClass ? [TKDrawerWindow class] :
61036220 (styleMask & (NSUtilityWindowMask|NSDocModalWindowMask|
6104 NSNonactivatingPanelMask|NSHUDWindowMask)) ? [NSPanel class] :
6221 NSNonactivatingPanelMask|NSHUDWindowMask)) ? [TKPanel class] :
61056222 [TKWindow class]);
61066223 NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect
61076224 styleMask:styleMask];
61086225 NSRect contentRect = NSMakeRect(5 - structureRect.origin.x,
61096226 TkMacOSXZeroScreenHeight() - (TkMacOSXZeroScreenTop() + 5 +
61106227 structureRect.origin.y + structureRect.size.height + 200), 200, 200);
6111 NSWindow *window = [[winClass alloc] initWithContentRect:contentRect
6228 if (wmPtr->hints.initial_state == WithdrawnState) {
6229 }
6230 TKWindow *window = [[winClass alloc] initWithContentRect:contentRect
61126231 styleMask:styleMask backing:NSBackingStoreBuffered defer:YES];
61136232 if (!window) {
61146233 Tcl_Panic("couldn't allocate new Mac window");
61216240 [window setAcceptsMouseMovedEvents:YES];
61226241 [window setReleasedWhenClosed:NO];
61236242 if (styleMask & NSUtilityWindowMask) {
6124 [(NSPanel*)window setFloatingPanel:YES];
6243 [(TKPanel*)window setFloatingPanel:YES];
61256244 }
61266245 if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) &&
61276246 !(styleMask & NSDocModalWindowMask)) {
61416260 geometry.origin.y = TkMacOSXZeroScreenHeight() - (geometry.origin.y +
61426261 geometry.size.height);
61436262 [window setFrame:geometry display:YES];
6144 TkMacOSXRegisterOffScreenWindow((Window) macWin, window);
6263 [window setTkWindow: (Window) macWin];
61456264
61466265 macWin->flags |= TK_HOST_EXISTS;
61476266 if (overrideRedirect) {
61486267 XSetWindowAttributes atts;
61496268
61506269 atts.override_redirect = True;
6151 Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts);
6152 ApplyMasterOverrideChanges(winPtr, NULL);
6153 }
6154 }
6155
6156 /*
6157 *----------------------------------------------------------------------
6158 *
6159 * TkpDisplayWindow --
6160 *
6161 * Mark the contentView of this window as needing display so the window
6162 * will be drawn by the window manager. If this is called within the
6163 * drawRect method, do nothing.
6270 Tk_ChangeWindowAttributes((Tk_Window)winPtr, CWOverrideRedirect, &atts);
6271 ApplyContainerOverrideChanges(winPtr, NULL);
6272 }
6273 }
6274
6275 /*
6276 *----------------------------------------------------------------------
6277 *
6278 * TkpRedrawWidget --
6279 *
6280 * Mark the bounding rectangle of this widget as needing display so the
6281 * widget will be drawn by [NSView drawRect:]. If this is called within
6282 * the drawRect method, do nothing.
61646283 *
61656284 * Results:
61666285 * None.
61676286 *
61686287 * Side effects:
6169 * The window's contentView is marked as needing display.
6170 *
6171 *----------------------------------------------------------------------
6172 */
6173
6174 MODULE_SCOPE void
6175 TkpDisplayWindow(Tk_Window tkwin) {
6176 if (![NSApp isDrawing]) {
6177 TkWindow *winPtr = (TkWindow *) tkwin;
6178 NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
6179
6180 [[w contentView] setNeedsDisplay: YES];
6181 }
6182 }
6183
6184 /*
6185 *----------------------------------------------------------------------
6186 *
6187 * TkMacOSXRegisterOffScreenWindow --
6188 *
6189 * This function adds the passed in Off Screen Port to the hash table that
6190 * maps Mac windows to root X windows.
6191 *
6192 * Results:
6193 * None.
6194 *
6195 * Side effects:
6196 * An entry is added to the windowTable hash table.
6288 * The widget's bounding rectangle is marked as dirty.
61976289 *
61986290 *----------------------------------------------------------------------
61996291 */
62006292
62016293 void
6202 TkMacOSXRegisterOffScreenWindow(
6203 Window window, /* Window structure. */
6204 void *portPtr) /* Pointer to a Mac Window. */
6205 {
6206 Tcl_HashEntry *valueHashPtr;
6207 int isNew;
6208
6209 if (!windowHashInit) {
6210 Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS);
6211 windowHashInit = true;
6212 }
6213 valueHashPtr = Tcl_CreateHashEntry(&windowTable, (char *) portPtr, &isNew);
6214 if (!isNew) {
6215 Tcl_Panic("Same macintosh window allocated twice!");
6216 }
6217 Tcl_SetHashValue(valueHashPtr, window);
6218 }
6219
6220 /*
6221 *----------------------------------------------------------------------
6222 *
6223 * TkMacOSXUnregisterMacWindow --
6224 *
6225 * Given a macintosh port window, this function removes the association
6226 * between this window and the root X window that Tk cares about.
6227 *
6228 * Results:
6229 * None.
6230 *
6231 * Side effects:
6232 * An entry is removed from the windowTable hash table.
6233 *
6234 *----------------------------------------------------------------------
6235 */
6236
6237 void
6238 TkMacOSXUnregisterMacWindow(
6239 void *macWinPtr) /* Reference to a Mac Window */
6240 {
6241 Tcl_HashEntry *entryPtr;
6242
6243 if (!windowHashInit) {
6244 Tcl_Panic("TkMacOSXUnregisterMacWindow: unmapping before inited");
6245 }
6246 entryPtr = Tcl_FindHashEntry(&windowTable, macWinPtr);
6247 if (!entryPtr) {
6248 TkMacOSXDbgMsg("Failed to find window %p", macWinPtr);
6249 } else {
6250 Tcl_DeleteHashEntry(entryPtr);
6251 }
6252 }
6294 TkpRedrawWidget(Tk_Window tkwin) {
6295 TkWindow *winPtr = (TkWindow *)tkwin;
6296 NSWindow *w;
6297 Rect tkBounds;
6298 NSRect bounds;
6299
6300 if ([NSApp isDrawing]) {
6301 return;
6302 }
6303 w = TkMacOSXGetNSWindowForDrawable(winPtr->window);
6304 if (w) {
6305 TKContentView *view = [w contentView];
6306 TkMacOSXWinBounds(winPtr, &tkBounds);
6307 bounds = NSMakeRect(tkBounds.left,
6308 [view bounds].size.height - tkBounds.bottom,
6309 tkBounds.right - tkBounds.left,
6310 tkBounds.bottom - tkBounds.top);
6311 [view setTkNeedsDisplay:YES];
6312 [view setTkDirtyRect:bounds];
6313 }
6314 }
6315
62536316
62546317 /*
62556318 *----------------------------------------------------------------------
63776440 return;
63786441 }
63796442
6380 macWin = TkMacOSXDrawableWindow(winPtr->window);
6443 macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window);
63816444
63826445 if (state == WithdrawnState) {
6383 Tk_UnmapWindow((Tk_Window) winPtr);
6446 Tk_UnmapWindow((Tk_Window)winPtr);
63846447 } else if (state == IconicState) {
6448
63856449 /*
63866450 * The window always gets unmapped. If we can show the icon version of
63876451 * the window we also collapse it.
63916455 ![macWin isMiniaturized]) {
63926456 [macWin miniaturize:NSApp];
63936457 }
6394 Tk_UnmapWindow((Tk_Window) winPtr);
6458 Tk_UnmapWindow((Tk_Window)winPtr);
63956459 } else if (state == NormalState || state == ZoomState) {
6396 Tk_MapWindow((Tk_Window) winPtr);
6397 if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) &&
6398 [macWin isMiniaturized]) {
6399 [macWin deminiaturize:NSApp];
6400 }
6401 TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn :
6402 inZoomOut);
6403 }
6460 Tk_MapWindow((Tk_Window)winPtr);
6461 [macWin deminiaturize:NSApp];
6462 [macWin orderFront:NSApp];
6463 TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut);
6464 }
6465 /*
6466 * Make sure windows are updated after the state change.
6467 */
6468
6469 while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){}
64046470 }
64056471
64066472 /*
64246490 void *wRef)
64256491 {
64266492 return [(NSWindow *)wRef level] == kCGFloatingWindowLevel;
6427 }
6428
6429 /*
6430 *----------------------------------------------------------------------
6431 *
6432 * TkMacOSXWindowClass --
6433 *
6434 * Returns OS X window class of window
6435 *
6436 * Results:
6437 * 1 or 0 depending on window's floating attribute.
6438 *
6439 * Side effects:
6440 * None.
6441 *
6442 *----------------------------------------------------------------------
6443 */
6444
6445 MODULE_SCOPE WindowClass
6446 TkMacOSXWindowClass(
6447 TkWindow *winPtr)
6448 {
6449 return winPtr->wmInfoPtr->macClass;
64506493 }
64516494
64526495 /*
65286571
65296572 int
65306573 XSetInputFocus(
6531 Display* display,
6532 Window focus,
6533 int revert_to,
6534 Time time)
6574 TCL_UNUSED(Display *),
6575 TCL_UNUSED(Window),
6576 TCL_UNUSED(int),
6577 TCL_UNUSED(Time))
65356578 {
65366579 /*
65376580 * Don't need to do a thing. Tk manages the focus for us.
65736616 }
65746617
65756618 if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)) {
6576 NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
6619 NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
65776620
65786621 TkWmRestackToplevel(winPtr, Above, NULL);
65796622 if (force) {
66286671 if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)
66296672 && (winPtr->display == display)) {
66306673 hPtr = Tcl_CreateHashEntry(table,
6631 (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry);
6674 (void *)TkMacOSXGetNSWindowForDrawable(winPtr->window), &newEntry);
66326675 Tcl_SetHashValue(hPtr, winPtr);
66336676 }
66346677
66666709 NSArray* backToFront = [[macWindows reverseObjectEnumerator] allObjects];
66676710 NSInteger windowCount = [macWindows count];
66686711
6669 windows = windowPtr = ckalloc((windowCount + 1) * sizeof(TkWindow *));
6712 windows = windowPtr = (TkWindow **)ckalloc((windowCount + 1) * sizeof(TkWindow *));
66706713 if (windows != NULL) {
66716714 Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
66726715 WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
67076750 WmInfo *wmPtr = winPtr->wmInfoPtr;
67086751
67096752 ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1);
6710 if (wmPtr->master != NULL || winPtr->atts.override_redirect) {
6711 ApplyMasterOverrideChanges(winPtr, macWindow);
6753 if (wmPtr->container != NULL || winPtr->atts.override_redirect) {
6754 ApplyContainerOverrideChanges(winPtr, macWindow);
67126755 }
67136756 }
67146757
67486791 if (!create) {
67496792 return;
67506793 }
6751 Tk_MakeWindowExist((Tk_Window) winPtr);
6794 Tk_MakeWindowExist((Tk_Window)winPtr);
67526795 }
67536796 if (!TkMacOSXHostToplevelExists(winPtr)) {
67546797 if (!create) {
67566799 }
67576800 TkMacOSXMakeRealWindowExist(winPtr);
67586801 }
6759 macWindow = TkMacOSXDrawableWindow(winPtr->window);
6802 macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
67606803 }
67616804 if ((changedAttributes & kWindowCloseBoxAttribute) || initial) {
67626805 [[macWindow standardWindowButton:NSWindowCloseButton]
68336876 * after 10.10.
68346877 */
68356878
6836 #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101000)
6879 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
68376880 if (!(macWindow.styleMask & NSUtilityWindowMask)) {
68386881 /*
68396882 * Exclude overrideredirect, transient, and "help"-styled
68416884 */
68426885
68436886 if ((winPtr->atts.override_redirect) ||
6844 (wmPtr->master != NULL) ||
6887 (wmPtr->container != NULL) ||
68456888 (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) {
68466889 b |= (NSWindowCollectionBehaviorCanJoinAllSpaces |
68476890 NSWindowCollectionBehaviorFullScreenAuxiliary);
68486891 } else {
6849 NSSize screenSize = [[macWindow screen] frame].size;
68506892 b |= NSWindowCollectionBehaviorFullScreenPrimary;
68516893
68526894 /*
68566898 * window. To work around this we make the max size equal
68576899 * to the screen size. (For 10.11 and up, only)
68586900 */
6859 if ([NSApp macMinorVersion] > 10) {
6901
6902 if ([NSApp macOSVersion] >= 101100) {
6903 NSSize screenSize = [[macWindow screen] frame].size;
68606904 [macWindow setMaxFullScreenContentSize:screenSize];
68616905 }
68626906 }
68786922 if ((wmPtr->flags & WM_TOPMOST) != (oldFlags & WM_TOPMOST)) {
68796923 [macWindow setLevel:(wmPtr->flags & WM_TOPMOST) ?
68806924 kCGUtilityWindowLevel : ([macWindow isKindOfClass:
6881 [NSPanel class]] && [macWindow isFloatingPanel] ?
6925 [TKPanel class]] && [macWindow isFloatingPanel] ?
68826926 kCGFloatingWindowLevel : kCGNormalWindowLevel)];
68836927 }
68846928
68996943 /*
69006944 *----------------------------------------------------------------------
69016945 *
6902 * ApplyMasterOverrideChanges --
6903 *
6904 * This procedure applies changes to override_redirect or master.
6946 * ApplyContainerOverrideChanges --
6947 *
6948 * This procedure applies changes to override_redirect or container.
69056949 *
69066950 * Results:
69076951 * None.
69136957 */
69146958
69156959 static void
6916 ApplyMasterOverrideChanges(
6960 ApplyContainerOverrideChanges(
69176961 TkWindow *winPtr,
69186962 NSWindow *macWindow)
69196963 {
69266970
69276971 if (!macWindow && winPtr->window != None &&
69286972 TkMacOSXHostToplevelExists(winPtr)) {
6929 macWindow = TkMacOSXDrawableWindow(winPtr->window);
6973 macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
69306974 }
69316975 styleMask = [macWindow styleMask];
69326976
69406984 wmPtr->attributes = macClassAttrs[kSimpleWindowClass].defaultAttrs;
69416985 }
69426986 wmPtr->attributes |= kWindowNoActivatesAttribute;
6943 if ([NSApp macMinorVersion] == 6) {
6987 if ([NSApp macOSVersion] == 100600) {
69446988 styleMask = 0;
69456989 } else {
69466990 styleMask &= ~NSTitledWindowMask;
69476991 }
69486992 } else {
69496993 if (wmPtr->macClass == kSimpleWindowClass &&
6950 oldAttributes == kWindowNoActivatesAttribute) {
6994 (oldAttributes & kWindowNoActivatesAttribute)) {
69516995 wmPtr->macClass = kDocumentWindowClass;
69526996 wmPtr->attributes =
69536997 macClassAttrs[kDocumentWindowClass].defaultAttrs;
69546998 }
69556999 wmPtr->attributes &= ~kWindowNoActivatesAttribute;
6956 if ([NSApp macMinorVersion] == 6) {
7000 if ([NSApp macOSVersion] == 100600) {
69577001 styleMask = NSTitledWindowMask |
69587002 NSClosableWindowMask |
69597003 NSMiniaturizableWindowMask |
69797023 [macWindow setExcludedFromWindowsMenu:YES];
69807024 [macWindow setStyleMask:styleMask];
69817025 if (wmPtr->hints.initial_state == NormalState) {
6982 [macWindow orderFront:nil];
7026 [macWindow orderFront:NSApp];
69837027 }
6984 if (wmPtr->master != NULL) {
7028 if (wmPtr->container != NULL) {
69857029 wmPtr->flags |= WM_TOPMOST;
69867030 } else {
69877031 wmPtr->flags &= ~WM_TOPMOST;
69977041 [macWindow setExcludedFromWindowsMenu:NO];
69987042 wmPtr->flags &= ~WM_TOPMOST;
69997043 }
7000 if (wmPtr->master != None) {
7001 TkWindow *masterWinPtr = (TkWindow *) wmPtr->master;
7002
7003 if (masterWinPtr && (masterWinPtr->window != None)
7004 && TkMacOSXHostToplevelExists(masterWinPtr)) {
7005 NSWindow *masterMacWin = TkMacOSXDrawableWindow(
7006 masterWinPtr->window);
7044 if (wmPtr->container != None) {
7045 TkWindow *containerWinPtr = (TkWindow *)wmPtr->container;
7046
7047 if (containerWinPtr && (containerWinPtr->window != None)
7048 && TkMacOSXHostToplevelExists(containerWinPtr)) {
7049 NSWindow *containerMacWin = TkMacOSXGetNSWindowForDrawable(
7050 containerWinPtr->window);
70077051
70087052 /*
70097053 * Try to add the transient window as a child window of the
7010 * master. A child NSWindow retains its relative position with
7011 * respect to the parent when the parent is moved. This is
7012 * pointless if the parent is offscreen, and adding a child to
7013 * an offscreen window causes the parent to be displayed as a
7014 * zombie. So we only do this if the parent is visible.
7054 * container. A child NSWindow retains its relative position
7055 * with respect to the parent when the parent is moved. This
7056 * is pointless if the parent is offscreen, and adding a child
7057 * to an offscreen window causes the parent to be displayed as
7058 * a zombie. So we only do this if the parent is visible.
70157059 */
70167060
7017 if (masterMacWin && [masterMacWin isVisible]
7061 if (containerMacWin && [containerMacWin isVisible]
70187062 && (winPtr->flags & TK_MAPPED)) {
70197063 /*
70207064 * If the transient is already a child of some other window,
70227066 */
70237067
70247068 parentWindow = [macWindow parentWindow];
7025 if (parentWindow && parentWindow != masterMacWin) {
7069 if (parentWindow && parentWindow != containerMacWin) {
70267070 [parentWindow removeChildWindow:macWindow];
70277071 }
7028
7029 [masterMacWin addChildWindow:macWindow
7030 ordered:NSWindowAbove];
7072 [macWindow orderFront:NSApp];
7073 [containerMacWin addChildWindow:macWindow
7074 ordered:NSWindowAbove];
70317075 }
70327076 }
70337077 } else {
72267270 */
72277271
72287272 if (winPtr->window != None) {
7229 MacDrawable *macWin = (MacDrawable *) winPtr->window;
7273 MacDrawable *macWin = (MacDrawable *)winPtr->window;
72307274
72317275 macWin->toplevel->referenceCount--;
72327276 macWin->toplevel = parentWin->toplevel;
72437287
72447288 for (childPtr = winPtr->childList; childPtr != NULL;
72457289 childPtr = childPtr->nextPtr) {
7246 RemapWindows(childPtr, (MacDrawable *) winPtr->window);
7290 RemapWindows(childPtr, (MacDrawable *)winPtr->window);
72477291 }
72487292 }
72497293
3636 } ProtocolHandler;
3737
3838 /* The following data structure is used in the TkWmInfo to maintain a list of all of the
39 * transient windows belonging to a given master.
39 * transient windows belonging to a given container.
4040 */
4141
4242 typedef struct Transient {
4545 struct Transient *nextPtr;
4646 } Transient;
4747
48 #define WITHDRAWN_BY_CONTAINER 0x1
4849 #define WITHDRAWN_BY_MASTER 0x1
4950
5051 /*
6465 Tk_Uid titleUid; /* Title to display in window caption. If NULL,
6566 * use name of widget. */
6667 char *iconName; /* Name to display in icon. */
67 Tk_Window master; /* Master window for TRANSIENT_FOR property, or
68 * None. */
68 Tk_Window container; /* Container window for TRANSIENT_FOR property,
69 * or None. */
6970 XWMHints hints; /* Various pieces of information for window
7071 * manager. */
7172 char *leaderName; /* Path name of leader of window group
200200 }
201201 }
202202
203 display = ckalloc(sizeof(Display));
204 screen = ckalloc(sizeof(Screen));
203 display = (Display *)ckalloc(sizeof(Display));
204 screen = (Screen *)ckalloc(sizeof(Screen));
205205 bzero(display, sizeof(Display));
206206 bzero(screen, sizeof(Screen));
207207
249249 */
250250 screen->root = ROOT_ID;
251251 screen->display = display;
252 screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24;
253 screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24;
252 screen->black_pixel = 0x00000000;
253 screen->white_pixel = 0x00FFFFFF;
254254 screen->ext_data = (XExtData *) &maxBounds;
255255
256 screen->root_visual = ckalloc(sizeof(Visual));
256 screen->root_visual = (Visual *)ckalloc(sizeof(Visual));
257257 screen->root_visual->visualid = 0;
258258 screen->root_visual->c_class = TrueColor;
259259 screen->root_visual->red_mask = 0x00FF0000;
268268
269269 TkMacOSXDisplayChanged(display);
270270
271 gMacDisplay = ckalloc(sizeof(TkDisplay));
271 gMacDisplay = (TkDisplay *)ckalloc(sizeof(TkDisplay));
272272
273273 /*
274274 * This is the quickest way to make sure that all the *Init flags get
386386
387387 static XID
388388 MacXIdAlloc(
389 Display *display) /* Display for which to allocate. */
389 TCL_UNUSED(Display *)) /* Display for which to allocate. */
390390 {
391391 static long int cur_id = 100;
392392 /*
416416
417417 static int
418418 DefaultErrorHandler(
419 Display* display,
420 XErrorEvent* err_evt)
419 TCL_UNUSED(Display *),
420 TCL_UNUSED(XErrorEvent *))
421421 {
422422 /*
423423 * This call should never be called. Tk replaces it with its own error
430430
431431 char *
432432 XGetAtomName(
433 Display * display,
434 Atom atom)
433 Display *display,
434 TCL_UNUSED(Atom))
435435 {
436436 display->request++;
437437 return NULL;
439439
440440 XErrorHandler
441441 XSetErrorHandler(
442 XErrorHandler handler)
442 TCL_UNUSED(XErrorHandler))
443443 {
444444 return DefaultErrorHandler;
445445 }
447447 Window
448448 XRootWindow(
449449 Display *display,
450 int screen_number)
450 TCL_UNUSED(int))
451451 {
452452 display->request++;
453453 return ROOT_ID;
465465 unsigned int *border_width_return,
466466 unsigned int *depth_return)
467467 {
468 TkWindow *winPtr = ((MacDrawable *) d)->winPtr;
468 TkWindow *winPtr = ((MacDrawable *)d)->winPtr;
469469
470470 display->request++;
471471 *root_return = ROOT_ID;
477477 *border_width_return = winPtr->changes.border_width;
478478 *depth_return = Tk_Depth(winPtr);
479479 } else {
480 CGSize size = ((MacDrawable *) d)->size;
480 CGSize size = ((MacDrawable *)d)->size;
481481 *x_return = 0;
482482 *y_return = 0;
483483 *width_return = size.width;
490490
491491 int
492492 XChangeProperty(
493 Display* display,
494 Window w,
495 Atom property,
496 Atom type,
497 int format,
498 int mode,
499 _Xconst unsigned char* data,
500 int nelements)
493 TCL_UNUSED(Display *),
494 TCL_UNUSED(Window),
495 TCL_UNUSED(Atom),
496 TCL_UNUSED(Atom),
497 TCL_UNUSED(int),
498 TCL_UNUSED(int),
499 TCL_UNUSED(_Xconst unsigned char *),
500 TCL_UNUSED(int))
501501 {
502502 Debugger();
503503 return Success;
505505
506506 int
507507 XSelectInput(
508 Display* display,
509 Window w,
510 long event_mask)
508 TCL_UNUSED(Display *),
509 TCL_UNUSED(Window),
510 TCL_UNUSED(long))
511511 {
512512 Debugger();
513513 return Success;
515515
516516 int
517517 XBell(
518 Display* display,
519 int percent)
518 TCL_UNUSED(Display *),
519 TCL_UNUSED(int))
520520 {
521521 NSBeep();
522522 return Success;
523523 }
524
525 #if 0
526 void
527 XSetWMNormalHints(
528 Display* display,
529 Window w,
530 XSizeHints* hints)
531 {
532 /*
533 * Do nothing. Shouldn't even be called.
534 */
535 }
536
537 XSizeHints *
538 XAllocSizeHints(void)
539 {
540 /*
541 * Always return NULL. Tk code checks to see if NULL is returned & does
542 * nothing if it is.
543 */
544
545 return NULL;
546 }
547 #endif
548524
549525 GContext
550526 XGContextFromGC(
551 GC gc)
527 TCL_UNUSED(GC))
552528 {
553529 /*
554530 * TODO: currently a no-op
559535
560536 Status
561537 XSendEvent(
562 Display* display,
563 Window w,
564 Bool propagate,
565 long event_mask,
566 XEvent* event_send)
538 TCL_UNUSED(Display *),
539 TCL_UNUSED(Window),
540 TCL_UNUSED(Bool),
541 TCL_UNUSED(long),
542 TCL_UNUSED(XEvent *))
567543 {
568544 Debugger();
569545 return 0;
571547
572548 int
573549 XClearWindow(
574 Display* display,
575 Window w)
576 {
577 return Success;
578 }
579
580 /*
581 int
582 XDrawPoint(
583 Display* display,
584 Drawable d,
585 GC gc,
586 int x,
587 int y)
588 {
589 return Success;
590 }
591
592 int
593 XDrawPoints(
594 Display* display,
595 Drawable d,
596 GC gc,
597 XPoint* points,
598 int npoints,
599 int mode)
600 {
601 return Success;
602 }
603 */
550 TCL_UNUSED(Display *),
551 TCL_UNUSED(Window))
552 {
553 return Success;
554 }
604555
605556 int
606557 XWarpPointer(
607 Display* display,
608 Window src_w,
609 Window dest_w,
610 int src_x,
611 int src_y,
612 unsigned int src_width,
613 unsigned int src_height,
614 int dest_x,
615 int dest_y)
558 TCL_UNUSED(Display *),
559 TCL_UNUSED(Window),
560 TCL_UNUSED(Window),
561 TCL_UNUSED(int),
562 TCL_UNUSED(int),
563 TCL_UNUSED(unsigned int),
564 TCL_UNUSED(unsigned int),
565 TCL_UNUSED(int),
566 TCL_UNUSED(int))
616567 {
617568 return Success;
618569 }
619570
620571 int
621572 XQueryColor(
622 Display* display,
623 Colormap colormap,
573 TCL_UNUSED(Display *),
574 TCL_UNUSED(Colormap),
624575 XColor* def_in_out)
625576 {
626577 unsigned long p;
641592
642593 int
643594 XQueryColors(
644 Display* display,
645 Colormap colormap,
595 TCL_UNUSED(Display *),
596 TCL_UNUSED(Colormap),
646597 XColor* defs_in_out,
647598 int ncolors)
648599 {
666617 }
667618
668619 int
669 XQueryTree(display, w, root_return, parent_return, children_return,
670 nchildren_return)
671 Display* display;
672 Window w;
673 Window* root_return;
674 Window* parent_return;
675 Window** children_return;
676 unsigned int* nchildren_return;
620 XQueryTree(
621 TCL_UNUSED(Display *),
622 TCL_UNUSED(Window),
623 TCL_UNUSED(Window *),
624 TCL_UNUSED(Window *),
625 TCL_UNUSED(Window **),
626 TCL_UNUSED(unsigned int *))
677627 {
678628 return 0;
679629 }
682632 int
683633 XGetWindowProperty(
684634 Display *display,
685 Window w,
686 Atom property,
687 long long_offset,
688 long long_length,
689 Bool delete,
690 Atom req_type,
635 TCL_UNUSED(Window),
636 TCL_UNUSED(Atom),
637 TCL_UNUSED(long),
638 TCL_UNUSED(long),
639 TCL_UNUSED(Bool),
640 TCL_UNUSED(Atom),
691641 Atom *actual_type_return,
692642 int *actual_format_return,
693643 unsigned long *nitems_return,
694644 unsigned long *bytes_after_return,
695 unsigned char ** prop_return)
645 TCL_UNUSED(unsigned char **))
696646 {
697647 display->request++;
698648 *actual_type_return = None;
703653
704654 int
705655 XRefreshKeyboardMapping(
706 XMappingEvent *x)
656 TCL_UNUSED(XMappingEvent *))
707657 {
708658 /* used by tkXEvent.c */
709659 Debugger();
713663 int
714664 XSetIconName(
715665 Display* display,
716 Window w,
717 const char *icon_name)
666 TCL_UNUSED(Window),
667 TCL_UNUSED(const char *))
718668 {
719669 /*
720670 * This is a no-op, no icon name for Macs.
726676 int
727677 XForceScreenSaver(
728678 Display* display,
729 int mode)
679 TCL_UNUSED(int))
730680 {
731681 /*
732682 * This function is just a no-op. It is defined to reset the screen saver.
740690
741691 void
742692 Tk_FreeXId(
743 Display *display,
744 XID xid)
693 TCL_UNUSED(Display *),
694 TCL_UNUSED(XID))
745695 {
746696 /* no-op function needed for stubs implementation. */
747697 }
749699 int
750700 XSync(
751701 Display *display,
752 Bool discard)
753 {
754 TkMacOSXFlushWindows();
702 TCL_UNUSED(Bool))
703 {
704 /*
705 * The main use of XSync is by the update command, which alternates
706 * between running an event loop to process all events without waiting and
707 * calling XSync on all displays until no events are left. There is
708 * nothing for the mac to do with respect to syncing its one display but
709 * it can (and, during regression testing, frequently does) happen that
710 * timer events fire during the event loop. Processing those here seems
711 * to make the update command work in a way that is more consistent with
712 * its behavior on other platforms.
713 */
714
715 while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_DONT_WAIT)){}
755716 display->request++;
756717 return 0;
757718 }
758719
759 #if 0
760720 int
761721 XSetClipRectangles(
762722 Display *d,
770730 TkRegion clipRgn = TkCreateRegion();
771731
772732 while (n--) {
773 XRectangle rect = *rectangles;
774
775 rect.x += clip_x_origin;
776 rect.y += clip_y_origin;
777 TkUnionRectWithRegion(&rect, clipRgn, clipRgn);
778 rectangles++;
733 XRectangle rect = *rectangles;
734
735 rect.x += clip_x_origin;
736 rect.y += clip_y_origin;
737 TkUnionRectWithRegion(&rect, clipRgn, clipRgn);
738 rectangles++;
779739 }
780740 TkSetRegion(d, gc, clipRgn);
781741 TkDestroyRegion(clipRgn);
782742 return 1;
783743 }
784 #endif
785
786744 /*
787745 *----------------------------------------------------------------------
788746 *
841799
842800 int
843801 XChangeWindowAttributes(
844 Display *display,
845 Window w,
846 unsigned long value_mask,
847 XSetWindowAttributes *attributes)
802 TCL_UNUSED(Display *),
803 TCL_UNUSED(Window),
804 TCL_UNUSED(unsigned long),
805 TCL_UNUSED(XSetWindowAttributes *))
848806 {
849807 return Success;
850808 }
851809
852810 int
853811 XSetWindowBackground(
854 Display *display,
855 Window window,
856 unsigned long value)
812 TCL_UNUSED(Display *),
813 TCL_UNUSED(Window),
814 TCL_UNUSED(unsigned long))
857815 {
858816 return Success;
859817 }
860818
861819 int
862820 XSetWindowBackgroundPixmap(
863 Display *display,
864 Window w,
865 Pixmap background_pixmap)
821 TCL_UNUSED(Display *),
822 TCL_UNUSED(Window),
823 TCL_UNUSED(Pixmap))
866824 {
867825 return Success;
868826 }
869827
870828 int
871829 XSetWindowBorder(
872 Display *display,
873 Window w,
874 unsigned long border_pixel)
830 TCL_UNUSED(Display *),
831 TCL_UNUSED(Window),
832 TCL_UNUSED(unsigned long))
875833 {
876834 return Success;
877835 }
878836
879837 int
880838 XSetWindowBorderPixmap(
881 Display *display,
882 Window w,
883 Pixmap border_pixmap)
839 TCL_UNUSED(Display *),
840 TCL_UNUSED(Window),
841 TCL_UNUSED(Pixmap))
884842 {
885843 return Success;
886844 }
887845
888846 int
889847 XSetWindowBorderWidth(
890 Display *display,
891 Window w,
892 unsigned int width)
848 TCL_UNUSED(Display *),
849 TCL_UNUSED(Window),
850 TCL_UNUSED(unsigned int))
893851 {
894852 return Success;
895853 }
896854
897855 int
898856 XSetWindowColormap(
899 Display *display,
900 Window w,
901 Colormap colormap)
857 TCL_UNUSED(Display *),
858 TCL_UNUSED(Window),
859 TCL_UNUSED(Colormap))
902860 {
903861 Debugger();
904862 return Success;
906864
907865 Status
908866 XStringListToTextProperty(
909 char **list,
910 int count,
911 XTextProperty *text_prop_return)
867 TCL_UNUSED(char **),
868 TCL_UNUSED(int),
869 TCL_UNUSED(XTextProperty *))
912870 {
913871 Debugger();
914 return (Status) 0;
872 return Success;
915873 }
916874
917875 void
918876 XSetWMClientMachine(
919 Display *display,
920 Window w,
921 XTextProperty *text_prop)
877 TCL_UNUSED(Display *),
878 TCL_UNUSED(Window),
879 TCL_UNUSED(XTextProperty *))
922880 {
923881 Debugger();
924882 }
925883
926884 XIC
927 XCreateIC(XIM xim, ...)
885 XCreateIC(TCL_UNUSED(XIM), ...)
928886 {
929887 Debugger();
930888 return (XIC) 0;
942900 XAfterFunction
943901 XSynchronize(
944902 Display *display,
945 Bool onoff)
946 {
947 display->request++;
903 TCL_UNUSED(Bool))
904 {
905 display->request++;
948906 return NULL;
949907 }
950908
951909 #undef XUngrabServer
952910 int
953911 XUngrabServer(
954 Display *display)
912 TCL_UNUSED(Display *))
955913 {
956914 return 0;
957915 }
968926 #undef XGrabServer
969927 int
970928 XGrabServer(
971 Display *display)
929 TCL_UNUSED(Display *))
972930 {
973931 return 0;
974932 }
986944 #undef XFlush
987945 int
988946 XFlush(
989 Display *display)
947 TCL_UNUSED(Display *))
990948 {
991949 return 0;
992950 }
1010968
1011969 const char *
1012970 TkGetDefaultScreenName(
1013 Tcl_Interp *interp, /* Not used. */
971 TCL_UNUSED(Tcl_Interp *),
1014972 const char *screenName) /* If NULL, use default string. */
1015973 {
1016974 if ((screenName == NULL) || (screenName[0] == '\0')) {
1037995
1038996 long
1039997 Tk_GetUserInactiveTime(
1040 Display *dpy)
998 TCL_UNUSED(Display *))
1041999 {
10421000 io_registry_entry_t regEntry;
10431001 CFMutableDictionaryRef props = NULL;
10461004 uint64_t time;
10471005 IOReturn result;
10481006
1049 regEntry = IOServiceGetMatchingService(kIOMasterPortDefault,
1007 regEntry = IOServiceGetMatchingService(0,
10501008 IOServiceMatching("IOHIDSystem"));
10511009
10521010 if (regEntry == 0) {
11031061
11041062 void
11051063 Tk_ResetUserInactiveTime(
1106 Display *dpy)
1064 TCL_UNUSED(Display *))
11071065 {
11081066 lastInactivityReset = TkpGetMS();
11091067 }
3030
3131 #include "tkMacOSXPrivate.h"
3232 #include "ttk/ttkTheme.h"
33 #include <math.h>
3433
3534 /*
3635 * Macros for handling drawing contexts.
3837
3938 #define BEGIN_DRAWING(d) { \
4039 TkMacOSXDrawingContext dc; \
41 if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;}
40 if (!TkMacOSXSetupDrawingContext((d), NULL, &dc)) {return;}
4241 #define END_DRAWING \
4342 TkMacOSXRestoreDrawingContext(&dc);}
4443
152151 Drawable d,
153152 Ttk_Box b)
154153 {
155 MacDrawable *md = (MacDrawable *) d;
154 MacDrawable *md = (MacDrawable *)d;
156155 CGRect rect;
157156
158157 rect.origin.y = b.y + md->yOff;
168167 */
169168
170169 static Ttk_StateTable ThemeStateTable[] = {
171 {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND},
170 {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
172171 {kThemeStateUnavailable, TTK_STATE_DISABLED, 0},
173172 {kThemeStatePressed, TTK_STATE_PRESSED, 0},
174173 {kThemeStateInactive, TTK_STATE_BACKGROUND, 0},
231230 * support Dark Mode anyway.
232231 */
233232
234 static CGFloat windowBackground[4] = {
233 static const CGFloat WINDOWBACKGROUND[4] = {
235234 235.0 / 255, 235.0 / 255, 235.0 / 255, 1.0
236235 };
237 static CGFloat whiteRGBA[4] = {1.0, 1.0, 1.0, 1.0};
238 static CGFloat blackRGBA[4] = {0.0, 0.0, 0.0, 1.0};
236 static const CGFloat WHITERGBA[4] = {1.0, 1.0, 1.0, 1.0};
237 static const CGFloat BLACKRGBA[4] = {0.0, 0.0, 0.0, 1.0};
239238
240239 /*----------------------------------------------------------------------
241240 * GetBackgroundColor --
242241 *
243242 * Fills the array rgba with the color coordinates for a background color.
244 * Start with the background color of a window's geometry master, or the
245 * standard ttk window background if there is no master. If the contrast
246 * parameter is nonzero, modify this color to be darker, for the aqua
247 * appearance, or lighter for the DarkAqua appearance. This is primarily
248 * used by the Fill and Background elements.
243 * Start with the background color of a window's geometry container, or
244 * the standard ttk window background if there is no container. If the
245 * contrast parameter is nonzero, modify this color to be darker, for the
246 * aqua appearance, or lighter for the DarkAqua appearance. This is
247 * primarily used by the Fill and Background elements.
249248 */
250249
251250 static void GetBackgroundColor(
252 CGContextRef context,
251 TCL_UNUSED(CGContextRef),
253252 Tk_Window tkwin,
254253 int contrast,
255254 CGFloat *rgba)
256255 {
257 TkWindow *winPtr = (TkWindow *) tkwin;
258 TkWindow *masterPtr = (TkWindow *) TkGetGeomMaster(tkwin);
259
260 while (masterPtr && masterPtr->privatePtr) {
261 if (masterPtr->privatePtr->flags & TTK_HAS_CONTRASTING_BG) {
256 TkWindow *winPtr = (TkWindow *)tkwin;
257 TkWindow *containerPtr = (TkWindow *)TkGetContainer(tkwin);
258
259 while (containerPtr && containerPtr->privatePtr) {
260 if (containerPtr->privatePtr->flags & TTK_HAS_CONTRASTING_BG) {
262261 break;
263262 }
264 masterPtr = (TkWindow *) TkGetGeomMaster(masterPtr);
265 }
266 if (masterPtr && masterPtr->privatePtr) {
263 containerPtr = (TkWindow *)TkGetContainer(containerPtr);
264 }
265 if (containerPtr && containerPtr->privatePtr) {
267266 for (int i = 0; i < 4; i++) {
268 rgba[i] = masterPtr->privatePtr->fillRGBA[i];
267 rgba[i] = containerPtr->privatePtr->fillRGBA[i];
269268 }
270269 } else {
271 if ([NSApp macMinorVersion] > 13) {
270 if ([NSApp macOSVersion] > 101300) {
272271 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
273272 NSColor *windowColor = [[NSColor windowBackgroundColor]
274273 colorUsingColorSpace: deviceRGB];
275274 [windowColor getComponents: rgba];
276275 } else {
277276 for (int i = 0; i < 4; i++) {
278 rgba[i] = windowBackground[i];
277 rgba[i] = WINDOWBACKGROUND[i];
279278 }
280279 }
281280 }
302301
303302
304303 /*----------------------------------------------------------------------
305 * +++ Single Arrow Buttons --
306 *
307 * Used in ListHeaders and Comboboxes.
304 * +++ Single Arrow Images --
305 *
306 * Used in ListHeaders and Comboboxes as well as disclosure triangles in
307 * macOS 11.
308308 */
309309
310310 static void DrawDownArrow(
312312 CGRect bounds,
313313 CGFloat inset,
314314 CGFloat size,
315 CGFloat *rgba)
315 const CGFloat *rgba)
316316 {
317317 CGFloat x, y;
318318
334334 CGRect bounds,
335335 CGFloat inset,
336336 CGFloat size,
337 CGFloat *rgba)
337 const CGFloat *rgba)
338338 {
339339 CGFloat x, y;
340340
351351 CGContextStrokePath(context);
352352 }
353353
354 static void DrawClosedDisclosure(
355 CGContextRef context,
356 CGRect bounds,
357 CGFloat inset,
358 CGFloat size,
359 CGFloat *rgba)
360 {
361 CGFloat x, y;
362
363 CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
364 CGContextSetLineWidth(context, 1.5);
365 x = bounds.origin.x + inset;
366 y = bounds.origin.y + trunc(bounds.size.height / 2);
367 CGContextBeginPath(context);
368 CGPoint arrow[3] = {
369 {x, y - size / 4 - 1}, {x + size / 2, y}, {x, y + size / 4 + 1}
370 };
371 CGContextAddLines(context, arrow, 3);
372 CGContextStrokePath(context);
373 }
374
375 static void DrawOpenDisclosure(
376 CGContextRef context,
377 CGRect bounds,
378 CGFloat inset,
379 CGFloat size,
380 CGFloat *rgba)
381 {
382 CGFloat x, y;
383
384 CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
385 CGContextSetLineWidth(context, 1.5);
386 x = bounds.origin.x + inset;
387 y = bounds.origin.y + trunc(bounds.size.height / 2);
388 CGContextBeginPath(context);
389 CGPoint arrow[3] = {
390 {x, y - size / 4}, {x + size / 2, y + size / 2}, {x + size, y - size / 4}
391 };
392 CGContextAddLines(context, arrow, 3);
393 CGContextStrokePath(context);
394 }
395
354396 /*----------------------------------------------------------------------
355397 * +++ Double Arrow Buttons --
356398 *
362404 CGRect bounds,
363405 CGFloat inset,
364406 CGFloat size,
365 CGFloat *rgba)
407 const CGFloat *rgba)
366408 {
367409 CGFloat x, y;
368410
500542 NSColor *color)
501543 {
502544 CGPathRef path;
545
503546 CHECK_RADIUS(radius, bounds)
504
547 path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
548 if (!path) {
549 return;
550 }
505551 CGContextSetFillColorWithColor(context, CGCOLOR(color));
506 path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
507552 CGContextBeginPath(context);
508553 CGContextAddPath(context, path);
509554 CGContextFillPath(context);
546591 * So we have to query the Apple window manager.
547592 */
548593
549 NSWindow *win = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
594 NSWindow *win = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin));
550595 CGFloat *bgRGBA = [win isKeyWindow] ? activeBgRGBA : inactiveBgRGBA;
551596 CGFloat x = bounds.origin.x, y = bounds.origin.y;
552597 CGFloat w = bounds.size.width, h = bounds.size.height;
586631 arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
587632 arrowBounds.size.width = 16;
588633 if (state & TTK_STATE_ALTERNATE) {
589 DrawUpArrow(context, arrowBounds, 3, 8, blackRGBA);
634 DrawUpArrow(context, arrowBounds, 3, 8, BLACKRGBA);
590635 } else if (state & TTK_STATE_SELECTED) {
591 DrawDownArrow(context, arrowBounds, 3, 8, blackRGBA);
636 DrawDownArrow(context, arrowBounds, 3, 8, BLACKRGBA);
592637 }
593638 }
594639 }
710755 darkSelectedGradient, 2);
711756 }
712757 if (kind == kThemePopupButton) {
713 DrawUpDownArrows(context, arrowBounds, 3, 7, whiteRGBA);
758 DrawUpDownArrows(context, arrowBounds, 3, 7, WHITERGBA);
714759 } else {
715 DrawDownArrow(context, arrowBounds, 4, 8, whiteRGBA);
760 DrawDownArrow(context, arrowBounds, 4, 8, WHITERGBA);
716761 }
717762 }
718763
771816 darkSelectedGradient, 2);
772817 CGContextRestoreGState(context);
773818 }
774 DrawUpDownArrows(context, bounds, 3, 5, whiteRGBA);
819 DrawUpDownArrows(context, bounds, 3, 5, WHITERGBA);
775820 HighlightButtonBorder(context, bounds);
776821 }
777822
10381083 static void DrawDarkSeparator(
10391084 CGRect bounds,
10401085 CGContextRef context,
1041 Tk_Window tkwin)
1086 TCL_UNUSED(Tk_Window))
10421087 {
10431088 static CGFloat fill[4] = {1.0, 1.0, 1.0, 0.3};
10441089 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
11641209 static void DrawDarkListHeader(
11651210 CGRect bounds,
11661211 CGContextRef context,
1167 Tk_Window tkwin,
1212 TCL_UNUSED(Tk_Window),
11681213 int state)
11691214 {
11701215 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
11731218 CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
11741219 CGFloat x = bounds.origin.x, y = bounds.origin.y;
11751220 CGFloat w = bounds.size.width, h = bounds.size.height;
1176 CGPoint top[2] = {{x, y}, {x + w, y}};
1221
1222 CGPoint top[2] = {{x, y + 1}, {x + w, y + 1}};
11771223 CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
1178 CGPoint separator[2] = {{x + w, y + 3}, {x + w, y + h - 3}};
1179
1224 CGPoint separator[2] = {{x + w - 1, y + 3}, {x + w - 1, y + h - 3}};
11801225 CGContextSaveGState(context);
11811226 CGContextSetShouldAntialias(context, false);
11821227 stroke = [NSColor colorWithColorSpace: deviceRGB
11981243 arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
11991244 arrowBounds.size.width = 16;
12001245 if (state & TTK_STATE_ALTERNATE) {
1201 DrawUpArrow(context, arrowBounds, 3, 8, whiteRGBA);
1246 DrawUpArrow(context, arrowBounds, 3, 8, WHITERGBA);
12021247 } else if (state & TTK_STATE_SELECTED) {
1203 DrawDownArrow(context, arrowBounds, 3, 8, whiteRGBA);
1248 DrawDownArrow(context, arrowBounds, 3, 8, WHITERGBA);
12041249 }
12051250 }
12061251 }
12301275 ListHeaderParams =
12311276 {kThemeListHeaderButton, kThemeMetricListHeaderHeight};
12321277 static Ttk_StateTable ButtonValueTable[] = {
1233 {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND},
1278 {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
12341279 {kThemeButtonMixed, TTK_STATE_ALTERNATE, 0},
12351280 {kThemeButtonOn, TTK_STATE_SELECTED, 0},
12361281 {kThemeButtonOff, 0, 0}
12591304 static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
12601305 ThemeButtonParams *params,
12611306 Ttk_State state,
1262 Tk_Window tkwin)
1307 TCL_UNUSED(Tk_Window))
12631308 {
12641309
12651310 /*
12951340
12961341 static void ButtonElementMinSize(
12971342 void *clientData,
1298 void *elementRecord,
1299 Tk_Window tkwin,
1343 TCL_UNUSED(void *),
1344 TCL_UNUSED(Tk_Window),
13001345 int *minWidth,
13011346 int *minHeight,
1302 Ttk_Padding *paddingPtr)
1303 {
1304 ThemeButtonParams *params = clientData;
1347 TCL_UNUSED(Ttk_Padding *))
1348 {
1349 ThemeButtonParams *params = (ThemeButtonParams *)clientData;
13051350
13061351 if (params->heightMetric != NoThemeMetric) {
1307 ChkErr(GetThemeMetric, params->heightMetric, minHeight);
1352 ChkErr(GetThemeMetric, params->heightMetric, (SInt *) minHeight);
13081353
13091354 /*
13101355 * The theme height does not include the 1-pixel border around
13731418
13741419 static void ButtonElementDraw(
13751420 void *clientData,
1376 void *elementRecord,
1421 TCL_UNUSED(void *),
13771422 Tk_Window tkwin,
13781423 Drawable d,
13791424 Ttk_Box b,
14081453 } else if (info.kind == kThemePushButton &&
14091454 (state & TTK_STATE_PRESSED)) {
14101455 bounds.size.height += 2;
1411 if ([NSApp macMinorVersion] > 8) {
1456 if ([NSApp macOSVersion] > 100800) {
14121457 GradientFillRoundedRectangle(dc.context, bounds, 4,
14131458 pressedPushButtonGradient, 2);
14141459 }
14631508
14641509 /* Tab position logic, c.f. ttkNotebook.c TabState() */
14651510 static Ttk_StateTable TabStyleTable[] = {
1466 {kThemeTabFrontInactive, TTK_STATE_SELECTED | TTK_STATE_BACKGROUND},
1467 {kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND},
1468 {kThemeTabFrontUnavailable, TTK_STATE_DISABLED | TTK_STATE_SELECTED},
1469 {kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED},
1470 {kThemeTabFront, TTK_STATE_SELECTED},
1471 {kThemeTabNonFrontPressed, TTK_STATE_PRESSED},
1472 {kThemeTabNonFront, 0}
1511 {kThemeTabFrontInactive, TTK_STATE_SELECTED | TTK_STATE_BACKGROUND, 0},
1512 {kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND, 0},
1513 {kThemeTabFrontUnavailable, TTK_STATE_DISABLED | TTK_STATE_SELECTED, 0},
1514 {kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED, 0},
1515 {kThemeTabFront, TTK_STATE_SELECTED, 0},
1516 {kThemeTabNonFrontPressed, TTK_STATE_PRESSED, 0},
1517 {kThemeTabNonFront, 0, 0}
14731518 };
14741519 static Ttk_StateTable TabAdornmentTable[] = {
1475 {kHIThemeTabAdornmentNone, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB},
1476 {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST_TAB},
1477 {kHIThemeTabAdornmentNone, TTK_STATE_LAST_TAB},
1478 {kHIThemeTabAdornmentTrailingSeparator, 0},
1520 {kHIThemeTabAdornmentNone, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
1521 {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST_TAB, 0},
1522 {kHIThemeTabAdornmentNone, TTK_STATE_LAST_TAB, 0},
1523 {kHIThemeTabAdornmentTrailingSeparator, 0, 0},
14791524 };
14801525 static Ttk_StateTable TabPositionTable[] = {
1481 {kHIThemeTabPositionOnly, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB},
1482 {kHIThemeTabPositionFirst, TTK_STATE_FIRST_TAB},
1483 {kHIThemeTabPositionLast, TTK_STATE_LAST_TAB},
1484 {kHIThemeTabPositionMiddle, 0},
1526 {kHIThemeTabPositionOnly, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
1527 {kHIThemeTabPositionFirst, TTK_STATE_FIRST_TAB, 0},
1528 {kHIThemeTabPositionLast, TTK_STATE_LAST_TAB, 0},
1529 {kHIThemeTabPositionMiddle, 0, 0},
14851530 };
14861531
14871532 /*
15251570 */
15261571
15271572 static void TabElementSize(
1528 void *clientData,
1529 void *elementRecord,
1530 Tk_Window tkwin,
1531 int *minWidth,
1573 TCL_UNUSED(void *),
1574 TCL_UNUSED(void *),
1575 TCL_UNUSED(Tk_Window),
1576 TCL_UNUSED(int *),
15321577 int *minHeight,
15331578 Ttk_Padding *paddingPtr)
15341579 {
15381583 }
15391584
15401585 static void TabElementDraw(
1541 void *clientData,
1542 void *elementRecord,
1586 TCL_UNUSED(void *),
1587 TCL_UNUSED(void *),
15431588 Tk_Window tkwin,
15441589 Drawable d,
15451590 Ttk_Box b,
15791624 */
15801625
15811626 static void PaneElementSize(
1582 void *clientData,
1583 void *elementRecord,
1584 Tk_Window tkwin,
1585 int *minWidth,
1586 int *minHeight,
1627 TCL_UNUSED(void *),
1628 TCL_UNUSED(void *),
1629 TCL_UNUSED(Tk_Window),
1630 TCL_UNUSED(int *),
1631 TCL_UNUSED(int *),
15871632 Ttk_Padding *paddingPtr)
15881633 {
15891634 *paddingPtr = Ttk_MakePadding(9, 5, 9, 9);
15901635 }
15911636
15921637 static void PaneElementDraw(
1593 void *clientData,
1594 void *elementRecord,
1638 TCL_UNUSED(void *),
1639 TCL_UNUSED(void *),
15951640 Tk_Window tkwin,
15961641 Drawable d,
15971642 Ttk_Box b,
16021647 bounds.origin.y -= kThemeMetricTabFrameOverlap;
16031648 bounds.size.height += kThemeMetricTabFrameOverlap;
16041649 BEGIN_DRAWING(d)
1605 if ([NSApp macMinorVersion] > 8) {
1650 if ([NSApp macOSVersion] > 100800) {
16061651 DrawGroupBox(bounds, dc.context, tkwin);
16071652 } else {
16081653 HIThemeTabPaneDrawInfo info = {
16401685 */
16411686
16421687 static void GroupElementSize(
1643 void *clientData,
1644 void *elementRecord,
1645 Tk_Window tkwin,
1646 int *minWidth,
1647 int *minHeight,
1688 TCL_UNUSED(void *),
1689 TCL_UNUSED(void *),
1690 TCL_UNUSED(Tk_Window),
1691 TCL_UNUSED(int *),
1692 TCL_UNUSED(int *),
16481693 Ttk_Padding *paddingPtr)
16491694 {
16501695 *paddingPtr = Ttk_UniformPadding(4);
16511696 }
16521697
16531698 static void GroupElementDraw(
1654 void *clientData,
1655 void *elementRecord,
1699 TCL_UNUSED(void *),
1700 TCL_UNUSED(void *),
16561701 Tk_Window tkwin,
16571702 Drawable d,
16581703 Ttk_Box b,
16611706 CGRect bounds = BoxToRect(d, b);
16621707
16631708 BEGIN_DRAWING(d)
1664 if ([NSApp macMinorVersion] > 8) {
1709 if ([NSApp macOSVersion] > 100800) {
16651710 DrawGroupBox(bounds, dc.context, tkwin);
16661711 } else {
16671712 const HIThemeGroupBoxDrawInfo info = {
17011746 Tk_Offset(EntryElement, backgroundObj), ENTRY_DEFAULT_BACKGROUND},
17021747 {"-fieldbackground", TK_OPTION_BORDER,
17031748 Tk_Offset(EntryElement, fieldbackgroundObj), ENTRY_DEFAULT_BACKGROUND},
1704 {0}
1749 {NULL, TK_OPTION_BOOLEAN, 0, NULL}
17051750 };
17061751
17071752 static void EntryElementSize(
1708 void *clientData,
1709 void *elementRecord,
1710 Tk_Window tkwin,
1711 int *minWidth,
1712 int *minHeight,
1753 TCL_UNUSED(void *),
1754 TCL_UNUSED(void *),
1755 TCL_UNUSED(Tk_Window),
1756 TCL_UNUSED(int *),
1757 TCL_UNUSED(int *),
17131758 Ttk_Padding *paddingPtr)
17141759 {
17151760 *paddingPtr = Ttk_MakePadding(7, 5, 7, 6);
17161761 }
17171762
17181763 static void EntryElementDraw(
1719 void *clientData,
1764 TCL_UNUSED(void *),
17201765 void *elementRecord,
17211766 Tk_Window tkwin,
17221767 Drawable d,
17841829 }
17851830 BEGIN_DRAWING(d)
17861831 if (backgroundPtr == NULL) {
1787 if ([NSApp macMinorVersion] > 8) {
1832 if ([NSApp macOSVersion] > 100800) {
17881833 background = [NSColor textBackgroundColor];
17891834 CGContextSetFillColorWithColor(dc.context, CGCOLOR(background));
17901835 } else {
18251870 * 1 pixel to account for the fact that the button is not centered.
18261871 */
18271872
1828 static Ttk_Padding ComboboxPadding = {4, 2, 20, 2};
1873 static Ttk_Padding ComboboxPadding = {4, 4, 20, 4};
1874 static Ttk_Padding DarkComboboxPadding = {6, 6, 22, 6};
18291875
18301876 static void ComboboxElementSize(
1831 void *clientData,
1832 void *elementRecord,
1877 TCL_UNUSED(void *),
1878 TCL_UNUSED(void *),
18331879 Tk_Window tkwin,
18341880 int *minWidth,
18351881 int *minHeight,
18371883 {
18381884 *minWidth = 24;
18391885 *minHeight = 23;
1840 *paddingPtr = ComboboxPadding;
1886 if (TkMacOSXInDarkMode(tkwin)) {
1887 *paddingPtr = DarkComboboxPadding;
1888 } else {
1889 *paddingPtr = ComboboxPadding;
1890 }
18411891 }
18421892
18431893 static void ComboboxElementDraw(
1844 void *clientData,
1845 void *elementRecord,
1894 TCL_UNUSED(void *),
1895 TCL_UNUSED(void *),
18461896 Tk_Window tkwin,
18471897 Drawable d,
18481898 Ttk_Box b,
18581908 };
18591909
18601910 BEGIN_DRAWING(d)
1861 bounds.origin.y += 1;
18621911 if (TkMacOSXInDarkMode(tkwin)) {
1863 bounds.size.height += 1;
1912 bounds = CGRectInset(bounds, 3, 3);
1913 if (state & TTK_STATE_FOCUS) {
1914 DrawDarkFocusRing(bounds, dc.context);
1915 }
18641916 DrawDarkButton(bounds, info.kind, state, dc.context);
1865 } else if ([NSApp macMinorVersion] > 8) {
1866 if ((state & TTK_STATE_BACKGROUND) &&
1867 !(state & TTK_STATE_DISABLED)) {
1868 NSColor *background = [NSColor textBackgroundColor];
1869 CGRect innerBounds = CGRectInset(bounds, 1, 2);
1870 SolidFillRoundedRectangle(dc.context, innerBounds, 4, background);
1871 }
1872 }
1873 ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
1917 } else {
1918 if ([NSApp macOSVersion] > 100800) {
1919 if ((state & TTK_STATE_BACKGROUND) &&
1920 !(state & TTK_STATE_DISABLED)) {
1921 NSColor *background = [NSColor textBackgroundColor];
1922 CGRect innerBounds = CGRectInset(bounds, 1, 4);
1923 bounds.origin.y += 1;
1924 SolidFillRoundedRectangle(dc.context, innerBounds, 4, background);
1925 }
1926 }
1927 ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
1928 }
18741929 END_DRAWING
18751930 }
18761931
19061961 static Ttk_Padding SpinbuttonMargins = {0, 0, 2, 0};
19071962
19081963 static void SpinButtonUpElementSize(
1909 void *clientData,
1910 void *elementRecord,
1911 Tk_Window tkwin,
1964 TCL_UNUSED(void *),
1965 TCL_UNUSED(void *),
1966 TCL_UNUSED(Tk_Window),
19121967 int *minWidth,
19131968 int *minHeight,
1914 Ttk_Padding *paddingPtr)
1969 TCL_UNUSED(Ttk_Padding *))
19151970 {
19161971 SInt32 s;
19171972
19221977 }
19231978
19241979 static void SpinButtonUpElementDraw(
1925 void *clientData,
1926 void *elementRecord,
1980 TCL_UNUSED(void *),
1981 TCL_UNUSED(void *),
19271982 Tk_Window tkwin,
19281983 Drawable d,
19291984 Ttk_Box b,
19632018 SpinButtonUpElementDraw
19642019 };
19652020 static void SpinButtonDownElementSize(
1966 void *clientData,
1967 void *elementRecord,
1968 Tk_Window tkwin,
2021 TCL_UNUSED(void *),
2022 TCL_UNUSED(void *),
2023 TCL_UNUSED(Tk_Window),
19692024 int *minWidth,
19702025 int *minHeight,
1971 Ttk_Padding *paddingPtr)
2026 TCL_UNUSED(Ttk_Padding *))
19722027 {
19732028 SInt32 s;
19742029
19792034 }
19802035
19812036 static void SpinButtonDownElementDraw(
1982 void *clientData,
1983 void *elementRecord,
2037 TCL_UNUSED(void *),
2038 TCL_UNUSED(void *),
19842039 Tk_Window tkwin,
19852040 Drawable d,
19862041 Ttk_Box b,
20572112 } TrackElement;
20582113
20592114 static Ttk_ElementOptionSpec TrackElementOptions[] = {
2060 {"-from", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, fromObj)},
2061 {"-to", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, toObj)},
2062 {"-value", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, valueObj)},
2063 {"-orient", TK_OPTION_STRING, Tk_Offset(TrackElement, orientObj)},
2064 {0, 0, 0}
2115 {"-from", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, fromObj), NULL},
2116 {"-to", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, toObj), NULL},
2117 {"-value", TK_OPTION_DOUBLE, Tk_Offset(TrackElement, valueObj), NULL},
2118 {"-orient", TK_OPTION_STRING, Tk_Offset(TrackElement, orientObj), NULL},
2119 {NULL, TK_OPTION_BOOLEAN, 0, NULL}
20652120 };
20662121 static void TrackElementSize(
20672122 void *clientData,
2068 void *elementRecord,
2069 Tk_Window tkwin,
2123 TCL_UNUSED(void *),
2124 TCL_UNUSED(Tk_Window),
20702125 int *minWidth,
20712126 int *minHeight,
2072 Ttk_Padding *paddingPtr)
2073 {
2074 TrackElementData *data = clientData;
2127 TCL_UNUSED(Ttk_Padding *))
2128 {
2129 TrackElementData *data = (TrackElementData *)clientData;
20752130 SInt32 size = 24; /* reasonable default ... */
20762131
20772132 ChkErr(GetThemeMetric, data->thicknessMetric, &size);
20902145 TrackElement *elem = elementRecord;
20912146 int orientation = TTK_ORIENT_HORIZONTAL;
20922147 double from = 0, to = 100, value = 0, factor;
2148 CGRect bounds;
20932149
20942150 Ttk_GetOrientFromObj(NULL, elem->orientObj, &orientation);
20952151 Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from);
20972153 Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value);
20982154 factor = RangeToFactor(to);
20992155
2156 /*
2157 * HIThemeTrackDrawInfo uses 2-byte alignment; assigning to a separate
2158 * bounds variable avoids UBSan (-fsanitize=alignment) complaints.
2159 */
2160
2161 bounds = BoxToRect(d, b);
21002162 HIThemeTrackDrawInfo info = {
21012163 .version = 0,
21022164 .kind = data->kind,
2103 .bounds = BoxToRect(d, b),
2165 .bounds = bounds,
21042166 .min = from * factor,
21052167 .max = to * factor,
21062168 .value = value * factor,
21222184 }
21232185 BEGIN_DRAWING(d)
21242186 if (TkMacOSXInDarkMode(tkwin)) {
2125 CGRect bounds = BoxToRect(d, b);
2187 bounds = BoxToRect(d, b);
21262188 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
21272189 NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
21282190 components: darkTrack
21562218 */
21572219
21582220 static void SliderElementSize(
2159 void *clientData,
2160 void *elementRecord,
2161 Tk_Window tkwin,
2221 TCL_UNUSED(void *),
2222 TCL_UNUSED(void *),
2223 TCL_UNUSED(Tk_Window),
21622224 int *minWidth,
21632225 int *minHeight,
2164 Ttk_Padding *paddingPtr)
2226 TCL_UNUSED(Ttk_Padding *))
21652227 {
21662228 *minWidth = *minHeight = 24;
21672229 }
22012263 Tk_Offset(PbarElement, phaseObj), "0"},
22022264 {"-mode", TK_OPTION_STRING,
22032265 Tk_Offset(PbarElement, modeObj), "determinate"},
2204 {0, 0, 0, 0}
2266 {NULL, TK_OPTION_BOOLEAN, 0, NULL}
22052267 };
22062268 static void PbarElementSize(
2207 void *clientData,
2208 void *elementRecord,
2209 Tk_Window tkwin,
2269 TCL_UNUSED(void *),
2270 TCL_UNUSED(void *),
2271 TCL_UNUSED(Tk_Window),
22102272 int *minWidth,
22112273 int *minHeight,
2212 Ttk_Padding *paddingPtr)
2274 TCL_UNUSED(Ttk_Padding *))
22132275 {
22142276 SInt32 size = 24; /* @@@ Check HIG for correct default */
22152277
22182280 }
22192281
22202282 static void PbarElementDraw(
2221 void *clientData,
2283 TCL_UNUSED(void *),
22222284 void *elementRecord,
22232285 Tk_Window tkwin,
22242286 Drawable d,
22262288 Ttk_State state)
22272289 {
22282290 PbarElement *pbar = elementRecord;
2229 int orientation = TTK_ORIENT_HORIZONTAL, phase = 0;
2230 double value = 0, maximum = 100, factor;
2291 int orientation = TTK_ORIENT_HORIZONTAL, phase = 0, kind;
2292
2293 /*
2294 * Using 1000 as the maximum should give better than 1 pixel
2295 * resolution for most progress bars.
2296 */
2297
2298 int ivalue, imaximum = 1000;
2299 CGRect bounds;
22312300
22322301 Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orientation);
2233 Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
2234 Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum);
2235 Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase);
2236 factor = RangeToFactor(maximum);
2237
2302 kind = !strcmp("indeterminate", Tcl_GetString(pbar->modeObj)) ?
2303 kThemeIndeterminateBar : kThemeProgressBar;
2304 if (kind == kThemeIndeterminateBar) {
2305 Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase);
2306
2307 /*
2308 * On macOS 11 the fraction of an indeterminate progress bar which is
2309 * traversed by the oscillating thumb is value / maximum. The phase
2310 * determines the position of the moving thumb in that range and is
2311 * apparently expected to vary between 0 and 120. On earlier systems
2312 * it is unclear how the phase is used in generating the animation.
2313 */
2314
2315 ivalue = imaximum;
2316 } else {
2317 double value, maximum;
2318 Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
2319 Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum);
2320 ivalue = (value / maximum)*1000;
2321 }
2322
2323 /*
2324 * HIThemeTrackDrawInfo uses 2-byte alignment; assigning to a separate
2325 * bounds variable avoids UBSan (-fsanitize=alignment) complaints.
2326 */
2327
2328 bounds = BoxToRect(d, b);
22382329 HIThemeTrackDrawInfo info = {
22392330 .version = 0,
2240 .kind =
2241 (!strcmp("indeterminate",
2242 Tcl_GetString(pbar->modeObj)) && value) ?
2243 kThemeIndeterminateBar : kThemeProgressBar,
2244 .bounds = BoxToRect(d, b),
2331 .kind = kind,
2332 .bounds = bounds,
22452333 .min = 0,
2246 .max = maximum * factor,
2247 .value = value * factor,
2334 .max = imaximum,
2335 .value = ivalue,
22482336 .attributes = kThemeTrackShowThumb |
2249 (orientation == TTK_ORIENT_HORIZONTAL ?
2250 kThemeTrackHorizontal : 0),
2337 (orientation == TTK_ORIENT_HORIZONTAL ? kThemeTrackHorizontal : 0),
22512338 .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state),
2252 .trackInfo.progress.phase = phase,
2339 .trackInfo.progress.phase = phase
22532340 };
2254
22552341 BEGIN_DRAWING(d)
22562342 if (TkMacOSXInDarkMode(tkwin)) {
2257 CGRect bounds = BoxToRect(d, b);
2343 bounds = BoxToRect(d, b);
22582344 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
22592345 NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
22602346 components: darkTrack
22902376 static Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
22912377 {"-orient", TK_OPTION_STRING,
22922378 Tk_Offset(ScrollbarElement, orientObj), "horizontal"},
2293 {0, 0, 0, 0}
2379 {NULL, TK_OPTION_BOOLEAN, 0, NULL}
22942380 };
22952381 static void TroughElementSize(
2296 void *clientData,
2382 TCL_UNUSED(void *),
22972383 void *elementRecord,
2298 Tk_Window tkwin,
2384 TCL_UNUSED(Tk_Window),
22992385 int *minWidth,
23002386 int *minHeight,
23012387 Ttk_Padding *paddingPtr)
23082394 ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &thickness);
23092395 if (orientation == TTK_ORIENT_HORIZONTAL) {
23102396 *minHeight = thickness;
2311 if ([NSApp macMinorVersion] > 7) {
2397 if ([NSApp macOSVersion] > 100700) {
23122398 *paddingPtr = Ttk_MakePadding(4, 4, 4, 3);
23132399 }
23142400 } else {
23152401 *minWidth = thickness;
2316 if ([NSApp macMinorVersion] > 7) {
2402 if ([NSApp macOSVersion] > 100700) {
23172403 *paddingPtr = Ttk_MakePadding(4, 4, 3, 4);
23182404 }
23192405 }
23342420 158.0 / 255, 158.0 / 255, 159.0 / 255, 1.0
23352421 };
23362422 static void TroughElementDraw(
2337 void *clientData,
2423 TCL_UNUSED(void *),
23382424 void *elementRecord,
23392425 Tk_Window tkwin,
23402426 Drawable d,
23412427 Ttk_Box b,
2342 Ttk_State state)
2428 TCL_UNUSED(Ttk_State))
23432429 {
23442430 ScrollbarElement *scrollbar = elementRecord;
23452431 int orientation = TTK_ORIENT_HORIZONTAL;
23582444 components: rgba
23592445 count: 4];
23602446 BEGIN_DRAWING(d)
2361 if ([NSApp macMinorVersion] > 8) {
2447 if ([NSApp macOSVersion] > 100800) {
23622448 CGContextSetFillColorWithColor(dc.context, CGCOLOR(troughColor));
23632449 } else {
23642450 ChkErr(HIThemeSetFill, kThemeBrushDocumentWindowBackground, NULL,
23762462 TroughElementDraw
23772463 };
23782464 static void ThumbElementSize(
2379 void *clientData,
2465 TCL_UNUSED(void *),
23802466 void *elementRecord,
2381 Tk_Window tkwin,
2467 TCL_UNUSED(Tk_Window),
23822468 int *minWidth,
23832469 int *minHeight,
2384 Ttk_Padding *paddingPtr)
2470 TCL_UNUSED(Ttk_Padding *))
23852471 {
23862472 ScrollbarElement *scrollbar = elementRecord;
23872473 int orientation = TTK_ORIENT_HORIZONTAL;
23972483 }
23982484
23992485 static void ThumbElementDraw(
2400 void *clientData,
2486 TCL_UNUSED(void *),
24012487 void *elementRecord,
24022488 Tk_Window tkwin,
24032489 Drawable d,
24212507 * draw the thumb directly.
24222508 */
24232509
2424 if ([NSApp macMinorVersion] > 8) {
2510 if ([NSApp macOSVersion] > 100800) {
24252511 CGRect thumbBounds = BoxToRect(d, b);
24262512 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
24272513 NSColor *thumbColor;
24472533 END_DRAWING
24482534 } else {
24492535 double thumbSize, trackSize, visibleSize, factor, fraction;
2450 MacDrawable *macWin = (MacDrawable *) Tk_WindowId(tkwin);
2536 MacDrawable *macWin = (MacDrawable *)Tk_WindowId(tkwin);
24512537 CGRect troughBounds = {{macWin->xOff, macWin->yOff},
24522538 {Tk_Width(tkwin), Tk_Height(tkwin)}};
24532539
24812567 visibleSize = (thumbSize / trackSize) * factor;
24822568 info.max = factor - visibleSize;
24832569 info.trackInfo.scrollbar.viewsize = visibleSize;
2484 if ([NSApp macMinorVersion] < 8 ||
2570 if ([NSApp macOSVersion] < 100800 ||
24852571 orientation == TTK_ORIENT_HORIZONTAL) {
24862572 info.value = factor * fraction;
24872573 } else {
25122598 ThumbElementDraw
25132599 };
25142600 static void ArrowElementSize(
2515 void *clientData,
2516 void *elementRecord,
2517 Tk_Window tkwin,
2601 TCL_UNUSED(void *),
2602 TCL_UNUSED(void *),
2603 TCL_UNUSED(Tk_Window),
25182604 int *minWidth,
25192605 int *minHeight,
2520 Ttk_Padding *paddingPtr)
2521 {
2522 if ([NSApp macMinorVersion] < 8) {
2606 TCL_UNUSED(Ttk_Padding *))
2607 {
2608 if ([NSApp macOSVersion] < 100800) {
25232609 *minHeight = *minWidth = 14;
25242610 } else {
25252611 *minHeight = *minWidth = -1;
25432629 */
25442630
25452631 static void SeparatorElementSize(
2546 void *clientData,
2547 void *elementRecord,
2548 Tk_Window tkwin,
2632 TCL_UNUSED(void *),
2633 TCL_UNUSED(void *),
2634 TCL_UNUSED(Tk_Window),
25492635 int *minWidth,
25502636 int *minHeight,
2551 Ttk_Padding *paddingPtr)
2637 TCL_UNUSED(Ttk_Padding *))
25522638 {
25532639 *minWidth = *minHeight = 1;
25542640 }
25552641
25562642 static void SeparatorElementDraw(
2557 void *clientData,
2558 void *elementRecord,
2643 TCL_UNUSED(void *),
2644 TCL_UNUSED(void *),
25592645 Tk_Window tkwin,
25602646 Drawable d,
25612647 Ttk_Box b,
25952681 = kThemeGrowRight | kThemeGrowDown;
25962682
25972683 static void SizegripElementSize(
2598 void *clientData,
2599 void *elementRecord,
2600 Tk_Window tkwin,
2684 TCL_UNUSED(void *),
2685 TCL_UNUSED(void *),
2686 TCL_UNUSED(Tk_Window),
26012687 int *minWidth,
26022688 int *minHeight,
2603 Ttk_Padding *paddingPtr)
2689 TCL_UNUSED(Ttk_Padding *))
26042690 {
26052691 HIThemeGrowBoxDrawInfo info = {
26062692 .version = 0,
26172703 }
26182704
26192705 static void SizegripElementDraw(
2620 void *clientData,
2621 void *elementRecord,
2622 Tk_Window tkwin,
2706 TCL_UNUSED(void *),
2707 TCL_UNUSED(void *),
2708 TCL_UNUSED(Tk_Window),
26232709 Drawable d,
26242710 Ttk_Box b,
26252711 unsigned int state)
26942780 */
26952781
26962782 static void FillElementDraw(
2697 void *clientData,
2698 void *elementRecord,
2783 TCL_UNUSED(void *),
2784 TCL_UNUSED(void *),
26992785 Tk_Window tkwin,
27002786 Drawable d,
27012787 Ttk_Box b,
27032789 {
27042790 CGRect bounds = BoxToRect(d, b);
27052791
2706 if ([NSApp macMinorVersion] > 8) {
2792 if ([NSApp macOSVersion] > 100800) {
27072793 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
27082794 NSColor *bgColor;
27092795 CGFloat fill[4];
27322818 void *elementRecord,
27332819 Tk_Window tkwin,
27342820 Drawable d,
2735 Ttk_Box b,
2821 TCL_UNUSED(Ttk_Box),
27362822 unsigned int state)
27372823 {
27382824 FillElementDraw(clientData, elementRecord, tkwin, d, Ttk_WinBox(tkwin),
27692855 */
27702856
27712857 static void ToolbarBackgroundElementDraw(
2772 void *clientData,
2773 void *elementRecord,
2858 TCL_UNUSED(void *),
2859 TCL_UNUSED(void *),
27742860 Tk_Window tkwin,
27752861 Drawable d,
2776 Ttk_Box b,
2777 Ttk_State state)
2862 TCL_UNUSED(Ttk_Box),
2863 TCL_UNUSED(Ttk_State))
27782864 {
27792865 ThemeBrush brush = kThemeBrushToolbarBackground;
27802866 CGRect bounds = BoxToRect(d, Ttk_WinBox(tkwin));
27982884 * +++ Field elements --
27992885 *
28002886 * Used for the Treeview widget. This is like the BackgroundElement
2801 * except that the fieldbackground color is configureable.
2887 * except that the fieldbackground color is configurable.
28022888 */
28032889
28042890 typedef struct {
28082894 static Ttk_ElementOptionSpec FieldElementOptions[] = {
28092895 {"-fieldbackground", TK_OPTION_BORDER,
28102896 Tk_Offset(FieldElement, backgroundObj), "white"},
2811 {NULL, 0, 0, NULL}
2897 {NULL, TK_OPTION_BOOLEAN, 0, NULL}
28122898 };
28132899
28142900 static void FieldElementDraw(
2815 void *clientData,
2901 TCL_UNUSED(void *),
28162902 void *elementRecord,
28172903 Tk_Window tkwin,
28182904 Drawable d,
28192905 Ttk_Box b,
2820 Ttk_State state)
2906 TCL_UNUSED(Ttk_State))
28212907 {
28222908 FieldElement *e = elementRecord;
28232909 Tk_3DBorder backgroundPtr =
28452931 */
28462932
28472933 static Ttk_StateTable TreeHeaderValueTable[] = {
2848 {kThemeButtonOn, TTK_STATE_ALTERNATE},
2849 {kThemeButtonOn, TTK_STATE_SELECTED},
2850 {kThemeButtonOff, 0}
2934 {kThemeButtonOn, TTK_STATE_ALTERNATE, 0},
2935 {kThemeButtonOn, TTK_STATE_SELECTED, 0},
2936 {kThemeButtonOff, 0, 0}
28512937 };
28522938
28532939 static Ttk_StateTable TreeHeaderAdornmentTable[] = {
28542940 {kThemeAdornmentHeaderButtonSortUp,
2855 TTK_STATE_ALTERNATE | TTK_TREEVIEW_STATE_SORTARROW},
2941 TTK_STATE_ALTERNATE | TTK_TREEVIEW_STATE_SORTARROW, 0},
28562942 {kThemeAdornmentDefault,
2857 TTK_STATE_SELECTED | TTK_TREEVIEW_STATE_SORTARROW},
2858 {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE},
2859 {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED},
2860 {kThemeAdornmentFocus, TTK_STATE_FOCUS},
2861 {kThemeAdornmentNone, 0}
2943 TTK_STATE_SELECTED | TTK_TREEVIEW_STATE_SORTARROW, 0},
2944 {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE, 0},
2945 {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED, 0},
2946 {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
2947 {kThemeAdornmentNone, 0, 0}
28622948 };
28632949
28642950 static void TreeAreaElementSize (
2865 void *clientData,
2866 void *elementRecord,
2867 Tk_Window tkwin,
2868 int *minWidth,
2869 int *minHeight,
2951 TCL_UNUSED(void *),
2952 TCL_UNUSED(void *),
2953 TCL_UNUSED(Tk_Window),
2954 TCL_UNUSED(int *),
2955 TCL_UNUSED(int *),
28702956 Ttk_Padding *paddingPtr)
28712957 {
28722958
28752961 * widget expects the heading to be the same height as a row.
28762962 */
28772963
2878 if ([NSApp macMinorVersion] > 8) {
2964 if ([NSApp macOSVersion] > 100800) {
28792965 paddingPtr->top = 4;
28802966 }
28812967 }
28952981 int *minHeight,
28962982 Ttk_Padding *paddingPtr)
28972983 {
2898 if ([NSApp macMinorVersion] > 8) {
2984 if ([NSApp macOSVersion] > 100800) {
28992985 *minHeight = 24;
29002986 } else {
29012987 ButtonElementSize(clientData, elementRecord, tkwin, minWidth,
29052991
29062992 static void TreeHeaderElementDraw(
29072993 void *clientData,
2908 void *elementRecord,
2994 TCL_UNUSED(void *),
29092995 Tk_Window tkwin,
29102996 Drawable d,
29112997 Ttk_Box b,
29223008 };
29233009
29243010 BEGIN_DRAWING(d)
2925 if ([NSApp macMinorVersion] > 8) {
3011 if ([NSApp macOSVersion] > 100800) {
29263012
29273013 /*
29283014 * Compensate for the padding added in TreeHeaderElementSize, so
29613047 {kThemeDisclosureRight, 0, 0},
29623048 };
29633049 static void DisclosureElementSize(
2964 void *clientData,
2965 void *elementRecord,
2966 Tk_Window tkwin,
3050 TCL_UNUSED(void *),
3051 TCL_UNUSED(void *),
3052 TCL_UNUSED(Tk_Window),
29673053 int *minWidth,
29683054 int *minHeight,
2969 Ttk_Padding *paddingPtr)
3055 TCL_UNUSED(Ttk_Padding *))
29703056 {
29713057 SInt32 s;
29723058
29773063 }
29783064
29793065 static void DisclosureElementDraw(
2980 void *clientData,
2981 void *elementRecord,
3066 TCL_UNUSED(void *),
3067 TCL_UNUSED(void *),
29823068 Tk_Window tkwin,
29833069 Drawable d,
29843070 Ttk_Box b,
29973083 };
29983084
29993085 BEGIN_DRAWING(d)
3000 ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
3086 if ([NSApp macOSVersion] >= 110000) {
3087 CGFloat rgba[4];
3088 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
3089 NSColor *stroke = [[NSColor textColor]
3090 colorUsingColorSpace: deviceRGB];
3091 [stroke getComponents: rgba];
3092 if (state & TTK_TREEVIEW_STATE_OPEN) {
3093 DrawOpenDisclosure(dc.context, bounds, 2, 8, rgba);
3094 } else {
3095 DrawClosedDisclosure(dc.context, bounds, 2, 12, rgba);
3096 }
3097 } else {
3098 ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
30013099 NULL);
3100 }
30023101 END_DRAWING
30033102 }
30043103 }
30483147 /* Notebook tabs -- no focus ring */
30493148 TTK_LAYOUT("Tab",
30503149 TTK_GROUP("Notebook.tab", TTK_FILL_BOTH,
3051 TTK_GROUP("Notebook.padding", TTK_EXPAND | TTK_FILL_BOTH,
3052 TTK_NODE("Notebook.label", TTK_EXPAND | TTK_FILL_BOTH))))
3150 TTK_GROUP("Notebook.padding", TTK_FILL_BOTH,
3151 TTK_NODE("Notebook.label", TTK_FILL_BOTH))))
30533152
30543153 /* Spinbox -- buttons 2px to the right of the field. */
30553154 TTK_LAYOUT("TSpinbox",
30563155 TTK_GROUP("Spinbox.buttons", TTK_PACK_RIGHT,
30573156 TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP | TTK_STICK_E)
30583157 TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM | TTK_STICK_E))
3059 TTK_GROUP("Spinbox.field", TTK_EXPAND | TTK_FILL_X,
3060 TTK_NODE("Spinbox.textarea", TTK_EXPAND | TTK_FILL_X)))
3158 TTK_GROUP("Spinbox.field", TTK_FILL_X,
3159 TTK_NODE("Spinbox.textarea", TTK_FILL_X)))
30613160
30623161 /* Progress bars -- track only */
30633162 TTK_LAYOUT("TProgressbar",
3064 TTK_NODE("Progressbar.track", TTK_EXPAND | TTK_FILL_BOTH))
3163 TTK_NODE("Progressbar.track", TTK_FILL_BOTH))
30653164
30663165 /* Treeview -- no border. */
30673166 TTK_LAYOUT("Treeview",
30863185
30873186 TTK_LAYOUT("Vertical.TScrollbar",
30883187 TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y,
3089 TTK_NODE("Vertical.Scrollbar.thumb",
3090 TTK_PACK_TOP | TTK_EXPAND | TTK_FILL_BOTH)
3188 TTK_NODE("Vertical.Scrollbar.thumb", TTK_FILL_BOTH)
30913189 TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM)
30923190 TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_BOTTOM)))
30933191
30943192 TTK_LAYOUT("Horizontal.TScrollbar",
30953193 TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X,
3096 TTK_NODE("Horizontal.Scrollbar.thumb",
3097 TTK_PACK_LEFT | TTK_EXPAND | TTK_FILL_BOTH)
3194 TTK_NODE("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH)
30983195 TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT)
30993196 TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_RIGHT)))
31003197
0 e5018b5568fabd6185794db597c53676ae54dc1fa79125233f262b582883bb12
33 # tests. Execute it by invoking "source all.tcl" when running tktest
44 # in this directory.
55 #
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
6 # Copyright © 1998-1999 by Scriptics Corporation.
77 #
88 # See the file "license.terms" for information on usage and redistribution
99 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1313 tcltest::configure {*}$argv
1414 tcltest::configure -testdir [file normalize [file dirname [info script]]]
1515 tcltest::configure -loadfile \
16 [file join [tcltest::testsDirectory] constraints.tcl]
16 [file join [tcltest::testsDirectory] constraints.tcl]
1717 tcltest::configure -singleproc 1
18 tcltest::runAllTests
18 set ErrorOnFailures [info exists env(ERROR_ON_FAILURES)]
19 encoding system utf-8
20 if {[tcltest::runAllTests] && $ErrorOnFailures} {exit 1}
1414 } -returnCodes {error} -result {bad option "a": must be -displayof or -nice}
1515
1616 test bell-1.2 {bell command} -body {
17 bell a b
17 bell a b
1818 } -returnCodes {error} -result {bad option "a": must be -displayof or -nice}
1919
2020 test bell-1.3 {bell command} -body {
3535
3636 # move the mouse pointer away of the testing area
3737 # otherwise some spurious events may pollute the tests
38 toplevel .top
39 wm geometry .top 50x50-50-50
40 update
41 event generate .top <Button-1> -warp 1
42 update
43 destroy .top
38 # also, this will procure a known grab state at startup
39 # for tests mixing grabs and pointer warps
40 proc pointerAway {} {
41 toplevel .top
42 wm geometry .top 50x50-50-50
43 update
44 # On KDE/Plasma _with_the_Aurorae_theme_ (at least), setting up the toplevel
45 # will not be finished right after the above 'update'. The WM still
46 # needs some time before the window is fully ready. For me 50 ms is enough,
47 # but let's wait more (it depends on computer performance).
48 after 100 ; update
49 event generate .top <Button-1> -warp 1
50 update
51 destroy .top
52 }
53 pointerAway
4454
4555 test bind-1.1 {bind command} -body {
4656 bind
66236633 # because both bindings are homogeneous equal, so the most recently defined
66246634 # must be preferred.
66256635 } -result {last}
6636 test bind-33.16 {simulate use of the keyboard to trigger a pattern sequence with modifier - bug [16ef161925]} -setup {
6637 pack [frame .t.f]
6638 focus -force .t.f
6639 update
6640 set x {}
6641 } -body {
6642 bind .t.f <Escape><Control-c> { lappend x "Esc_Control-c" }
6643 event generate .t.f <Escape>
6644 event generate .t.f <Control_L>
6645 event generate .t.f <Control_L>
6646 event generate .t.f <Control_L>
6647 event generate .t.f <Control-c>
6648 set x
6649 } -cleanup {
6650 destroy .t.f
6651 } -result {Esc_Control-c}
6652 test bind-33.17 {simulate use of the keyboard to trigger a pattern sequence with modifier - bug [16ef161925]} -setup {
6653 pack [frame .t.f]
6654 focus -force .t.f
6655 update
6656 set x {}
6657 } -body {
6658 bind .t.f <Escape><Control-c> { lappend x "Esc_Control-c" }
6659 bind .t.f <Escape><Control_L><Control-c> { lappend x "Esc_Ctrl_L_Control-c" }
6660 event generate .t.f <Escape>
6661 event generate .t.f <Control_L>
6662 event generate .t.f <Control_L>
6663 event generate .t.f <Control_L>
6664 event generate .t.f <Control-c>
6665 set x
6666 } -cleanup {
6667 destroy .t.f
6668 } -result {Esc_Ctrl_L_Control-c}
6669 test bind-33.18 {simulate use of the keyboard to trigger a pattern sequence with modifier - bug [16ef161925]} -setup {
6670 pack [frame .t.f]
6671 focus -force .t.f
6672 update
6673 set x {}
6674 } -body {
6675 bind .t.f <Escape><Control-c> { lappend x "Esc_Control-c" }
6676 bind .t.f <Escape><Control_L><Control-c> { lappend x "Esc_Ctrl_L_Control-c" }
6677 bind .t.f <Escape><Control_L><Control_L><Control-c> { lappend x "Esc_Ctrl_L(2)_Control-c" }
6678 event generate .t.f <Escape>
6679 event generate .t.f <Control_L>
6680 event generate .t.f <Control_L>
6681 event generate .t.f <Control_L>
6682 event generate .t.f <Control-c>
6683 set x
6684 } -cleanup {
6685 destroy .t.f
6686 } -result {Esc_Ctrl_L(2)_Control-c}
6687 test bind-33.19 {simulate use of the keyboard to trigger a pattern sequence with modifier - bug [16ef161925]} -setup {
6688 pack [frame .t.f]
6689 focus -force .t.f
6690 update
6691 set x {}
6692 } -body {
6693 bind .t.f <Escape><Control-c> { lappend x "Esc_Control-c" }
6694 bind .t.f <Escape><KeyPress><KeyPress><Control-c> { lappend x "Esc_Key(2)_Control-c" }
6695 event generate .t.f <Escape>
6696 event generate .t.f <Alt_L>
6697 event generate .t.f <Control_L>
6698 event generate .t.f <Control-c>
6699 set x
6700 } -cleanup {
6701 destroy .t.f
6702 } -result {Esc_Key(2)_Control-c}
6703 test bind-33.20 {simulate use of the keyboard to trigger a pattern sequence with mixed Key and Button types - bug [16ef161925]} -setup {
6704 pack [frame .t.f]
6705 focus -force .t.f
6706 update
6707 set x {}
6708 } -body {
6709 bind .t.f <Key-1><Button-1> { lappend x "1_Button1" }
6710 event generate .t.f <Key-1>
6711 event generate .t.f <KeyRelease-1>
6712 event generate .t.f <Button-1>
6713 set x
6714 } -cleanup {
6715 destroy .t.f
6716 } -result {1_Button1}
6717 test bind-33.21 {simulate use of the keyboard to trigger a pattern sequence with mixed Key and Button types - bug [16ef161925]} -setup {
6718 pack [frame .t.f]
6719 focus -force .t.f
6720 update
6721 set x {}
6722 } -body {
6723 bind .t.f <Key-1><Button-1> { lappend x "1_Button1" }
6724 bind .t.f <Key-1><Button-1><Key-2> { lappend x "1_Button1_2" }
6725 event generate .t.f <Key-1>
6726 event generate .t.f <KeyRelease-1>
6727 event generate .t.f <Button-1>
6728 event generate .t.f <Key-2>
6729 event generate .t.f <KeyRelease-2>
6730 set x
6731 } -cleanup {
6732 destroy .t.f
6733 } -result {1_Button1 1_Button1_2}
66266734
66276735 test bind-34.1 {-warp works relatively to a window} -setup {
66286736 toplevel .top
6737 wm geometry .top +100+100
6738 update
66296739 } -body {
66306740 # In order to avoid platform-dependent coordinate results due to
6631 # decorations and borders, this test warps the pointer twice
6741 # decorations and borders, this test warps the pointer twice
66326742 # relatively to a window that moved in the meantime, and checks
66336743 # how much the pointer moved
66346744 wm geometry .top +200+200
66366746 event generate .top <Motion> -x 20 -y 20 -warp 1
66376747 update idletasks ; # DoWarp is an idle callback
66386748 after 50 ; # Win specific - wait for SendInput to be executed
6639 set pointerPos1 [winfo pointerxy .t]
6749 set pointerPos1 [winfo pointerxy .top]
66406750 wm geometry .top +600+600
66416751 update
66426752 event generate .top <Motion> -x 20 -y 20 -warp 1
66436753 update idletasks ; # DoWarp is an idle callback
66446754 after 50 ; # Win specific - wait for SendInput to be executed
6645 set pointerPos2 [winfo pointerxy .t]
6755 set pointerPos2 [winfo pointerxy .top]
66466756 # from the first warped position to the second one, the mouse
66476757 # pointer should have moved the same amount as the window moved
66486758 set res 1
66696779 } -cleanup {
66706780 } -result {20 20 200 200}
66716781 test bind-34.3 {-warp works with null or negative coordinates} -setup {
6782 # On some OS/WM, at least Linux with KDE, the "Screen edges" feature
6783 # provides hot spots that can be associated with some action.
6784 # When activated, the WM will not allow warping to happen on top of
6785 # a hot spot (which would trigger the corresponding action as an
6786 # unwanted effect) but will warp the pointer to the hot spot limit only.
6787 if {[tk windowingsystem] eq "x11"} {
6788 set halo 1
6789 } else {
6790 set halo 0
6791 }
6792 set res {}
66726793 } -body {
66736794 event generate {} <Motion> -x 0 -y 0 -warp 1
66746795 update idletasks ; # DoWarp is an idle callback
66756796 after 50 ; # Win specific - wait for SendInput to be executed
6676 set res [winfo pointerxy .]
6797 foreach dim [winfo pointerxy .] {
6798 if {$dim <= $halo} {
6799 lappend res ok
6800 } else {
6801 lappend res $dim
6802 }
6803 }
6804 event generate {} <Motion> -x 100 -y 100 -warp 1
6805 update idletasks ; after 50
66776806 event generate {} <Motion> -x -1 -y -1 -warp 1
6678 update idletasks ; # DoWarp is an idle callback
6679 after 50 ; # Win specific - wait for SendInput to be executed
6807 update idletasks ; after 50
66806808 foreach dim [winfo pointerxy .] {
6681 if {$dim <= 0} {
6809 if {$dim <= $halo} {
66826810 lappend res ok
66836811 } else {
66846812 lappend res $dim
66866814 }
66876815 set res
66886816 } -cleanup {
6689 } -result {0 0 ok ok}
6817 } -result {ok ok ok ok}
6818
6819 set keyInfo {}
6820 set numericKeysym {}
6821 proc testKey {window event type mods} {
6822 global keyInfo numericKeysym
6823 set keyInfo {}
6824 set numericKeysym {}
6825 bind $window <KeyPress> {
6826 set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
6827 set numericKeysym %N
6828 }
6829 focus -force $window
6830 update
6831 event generate $window $event
6832 if {$keyInfo == {}} {
6833 vwait keyInfo
6834 }
6835 set save $keyInfo
6836 set keyInfo {}
6837 set injectcmd [list injectkeyevent $type $numericKeysym]
6838 foreach {option} $mods {
6839 lappend injectcmd $option
6840 }
6841 eval $injectcmd
6842 if {$keyInfo == {}} {
6843 vwait keyInfo
6844 }
6845 if {$save != $keyInfo} {
6846 return "[format "0x%x" $numericKeysym] ($mods): $save != $keyInfo"
6847 }
6848 return pass
6849 }
6850 proc testKeyWithMods {window keysym type} {
6851 set result [testKey $window "<$keysym>" $type {}]
6852 if {$result != {pass}} {
6853 return $result
6854 }
6855 set result [testKey $window "<Shift-$keysym>" $type {-shift}]
6856 if {$result != {pass}} {
6857 return $result
6858 }
6859 set result [testKey $window "<Option-$keysym>" $type {-option}]
6860 if {$result != {pass}} {
6861 return $result
6862 }
6863 set result [testKey $window "<Shift-Option-$keysym>" $type {-shift -option}]
6864 if {$result != {pass}} {
6865 return $result
6866 }
6867 return pass
6868 }
6869 test bind-35.0 {Generated and real key events agree} -constraints {aqua} -body {
6870 foreach k {o O F2 Home Right Greek_sigma Greek_ALPHA} {
6871 set result [testKeyWithMods . $k press]
6872 if {$result != "pass"} {
6873 return $result
6874 }
6875 }
6876 return pass
6877 } -cleanup {
6878 } -result pass
6879
6880 test bind-35.1 {Key events agree for entry widgets} -constraints {aqua} -setup {
6881 toplevel .new
6882 entry .new.e
6883 pack .new.e
6884 } -body {
6885 foreach k {o O F2 Home Right Greek_sigma Greek_ALPHA Menu} {
6886 set result [testKeyWithMods .new.e $k press]
6887 if {$result != "pass"} {
6888 return $result
6889 }
6890 }
6891 return pass
6892 } -cleanup {
6893 destroy .new.e
6894 destroy .new
6895 } -result pass
6896
6897 test bind-35.2 {Can bind to function keys} -constraints {aqua} -body {
6898 global keyInfo numericKeysym
6899 bind . <KeyPress> {}
6900 bind . <KeyPress> {
6901 lappend keyInfo %K
6902 set numericKeysym %N
6903 }
6904 set keyInfo {}
6905 set numericKeysym {}
6906 focus -force .
6907 event generate . <F2>
6908 injectkeyevent press $numericKeysym -function
6909 vwait keyInfo
6910 return $keyInfo
6911 } -cleanup {
6912 } -result {F2 F2}
6913
6914 test bind-35.3 {Events agree for modifier keys} -constraints {aqua} -setup {
6915 } -body {
6916 global keyInfo numericalKeysym
6917 set result {}
6918 bind . <KeyPress> {
6919 set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
6920 set numericalKeysym [format "0x%x" %N]
6921 }
6922 foreach event {
6923 {<Control_L> -control}
6924 {<Control_R> -control}
6925 {<Alt_L> -option}
6926 {<Alt_R> -option}
6927 {<Meta_L> -command}
6928 {<Meta_R> -command}
6929 {<Shift_L> -shift}
6930 {<Shift_R> -shift}
6931 } {
6932 set keyInfo {}
6933 event generate . [lindex $event 0]
6934 if {$keyInfo == {}} {
6935 vwait keyInfo
6936 }
6937 set save $keyInfo
6938 injectkeyevent flagschanged $numericKeysym [lindex $event 1]
6939 if {$keyInfo == {}} {
6940 vwait keyInfo
6941 }
6942 if {$save != $keyInfo} {
6943 return "$save != $keyInfo"
6944 }
6945 }
6946 return pass
6947 } -cleanup {
6948 } -result pass
6949
6950 test bind-36.1 {pointer warp with grab on toplevel, bug [e3888d5820]} -setup {
6951 pointerAway
6952 toplevel .top
6953 grab release .top
6954 wm geometry .top 200x200+300+300
6955 label .top.l -height 5 -width 20 -highlightthickness 2 \
6956 -highlightbackground black -bg yellow -text "My label"
6957 pack .top.l -side bottom
6958 update
6959 # On KDE/Plasma _with_the_Aurorae_theme_ (at least), setting up the toplevel
6960 # and the label will not be finished after the above 'update'. The WM still
6961 # needs some time before the window is fully ready. For me 50 ms is enough,
6962 # but let's wait more (it depends on computer performance).
6963 after 100 ; update
6964 } -body {
6965 grab .top ; # this will queue events
6966 after 50
6967 update
6968 event generate .top.l <Motion> -warp 1 -x 10 -y 10
6969 update idletasks ; after 50
6970 foreach {x1 y1} [winfo pointerxy .top.l] {}
6971 event generate {} <Motion> -warp 1 -x 50 -y 50
6972 update idletasks ; after 50
6973 grab release .top ; # this will queue events
6974 after 50
6975 update
6976 event generate .top.l <Motion> -warp 1 -x 10 -y 10
6977 update idletasks ; after 50
6978 foreach {x2 y2} [winfo pointerxy .top.l] {}
6979 # success if the coords are the same with or without the grab, and if they
6980 # are at (10,10) inside the label widget as requested by the warping
6981 expr {$x1==$x2 && $y1==$y2 && $x1==[winfo rootx .top.l]+10 \
6982 && $y1==[winfo rooty .top.l]+10}
6983 } -cleanup {
6984 destroy .top
6985 unset x1 y1 x2 y2
6986 } -result {1}
66906987
66916988 # cleanup
66926989 cleanupTests
1414 testbitmap
1515 } -body {
1616 set x gray25
17 lindex $x 0
17 lindex $x 0
1818 button .b -bitmap $x
1919 lindex $x 0
2020 testbitmap gray25
5353 test bitmap-2.1 {Tk_GetBitmap procedure} -body {
5454 button .b1 -bitmap bad_name
5555 } -cleanup {
56 destroy .b1
56 destroy .b1
5757 } -returnCodes error -result {bitmap "bad_name" not defined}
5858 test bitmap-2.2 {Tk_GetBitmap procedure} -body {
5959 button .b1 -bitmap @xyzzy
6060 } -cleanup {
61 destroy .b1
61 destroy .b1
6262 } -returnCodes error -result {error reading bitmap file "xyzzy"}
6363
6464 test bitmap-3.1 {Tk_FreeBitmapFromObj - reference counts} -constraints {
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111
12 test border-1.1 {Tk_AllocBorderFromObj - converting internal reps} -constraints {
13 testborder
12 test border-1.1 {Tk_AllocBorderFromObj - converting internal reps} -constraints {
13 testborder
1414 } -body {
1515 set x orange
1616 lindex $x 0
2020 } -cleanup {
2121 destroy .b1
2222 } -result {{1 0}}
23 test border-1.2 {Tk_AllocBorderFromObj - discard stale border} -constraints {
24 testborder
23 test border-1.2 {Tk_AllocBorderFromObj - discard stale border} -constraints {
24 testborder
2525 } -setup {
2626 set result {}
2727 } -body {
3434 } -cleanup {
3535 destroy .b1 .b2
3636 } -result {{} {{1 1}}}
37 test border-1.3 {Tk_AllocBorderFromObj - reuse existing border} -constraints {
38 testborder
37 test border-1.3 {Tk_AllocBorderFromObj - reuse existing border} -constraints {
38 testborder
3939 } -setup {
4040 set result {}
4141 } -body {
4848 } -cleanup {
4949 destroy .b1 .b2
5050 } -result {{{1 1}} {{2 1}}}
51 test border-1.4 {Tk_AllocBorderFromObj - try other borders in list} -constraints {
51 test border-1.4 {Tk_AllocBorderFromObj - try other borders in list} -constraints {
5252 testborder pseudocolor8
5353 } -setup {
5454 toplevel .t -visual {pseudocolor 8} -colormap new
6969 destroy .b1 .b2 .t
7070 } -result {{{1 1}} {{1 1} {1 0}} {{1 0} {2 1}}}
7171
72 test border-2.1 {Tk_Free3DBorder - reference counts} -constraints {
72 test border-2.1 {Tk_Free3DBorder - reference counts} -constraints {
7373 testborder pseudocolor8
7474 } -setup {
7575 toplevel .t -visual {pseudocolor 8} -colormap new
9393 } -cleanup {
9494 destroy .b1 .b2 .t
9595 } -result {{{1 0} {2 1}} {{1 0} {1 1}} {{1 0}} {}}
96 test border-2.2 {Tk_Free3DBorder - unlinking from list} -constraints {
96 test border-2.2 {Tk_Free3DBorder - unlinking from list} -constraints {
9797 testborder pseudocolor8
9898 } -setup {
9999 toplevel .t -visual {pseudocolor 8} -colormap new
126126 destroy .b .t2 .t3 .t
127127 } -result {{{4 1} {3 0} {2 0} {1 0}} {{4 1} {2 0} {1 0}} {{4 1} {2 0}} {{2 0}} {}}
128128
129 test border-3.1 {FreeBorderObjProc} -constraints {
130 testborder
129 test border-3.1 {FreeBorderObjProc} -constraints {
130 testborder
131131 } -setup {
132132 set result {}
133133 proc copy {s} {return [string index $s 0][string range $s 1 end]}
55 #
66 # Copyright (c) 1998-2000 by Jos Decoster. All rights reserved.
77
8 package require tcltest 2.1
8 package require tcltest 2.2
99 tcltest::configure {*}$argv
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
77 wm geom .t +0+0
88 wm minsize .t 1 1
99
10 label .t.l -text {This screen exercises the color options for various flavors of buttons. Select display options below, and they will be applied to the appropiate button widgets.} -wraplength 5i
10 label .t.l -text {This screen exercises the color options for various flavors of buttons. Select display options below, and they will be applied to the appropriate button widgets.} -wraplength 5i
1111 pack .t.l -side top -fill both
1212
1313 button .t.quit -text Quit -command {destroy .t}
561561 update
562562 } -body {
563563 .l configure -borderwidth 1.3
564 .l cget -borderwidth
564 .l cget -borderwidth
565565 } -cleanup {
566566 destroy .l
567567 } -result {1.3}
580580 update
581581 } -body {
582582 .b configure -borderwidth 1.3
583 .b cget -borderwidth
583 .b cget -borderwidth
584584 } -cleanup {
585585 destroy .b
586586 } -result {1.3}
599599 update
600600 } -body {
601601 .c configure -borderwidth 1.3
602 .c cget -borderwidth
602 .c cget -borderwidth
603603 } -cleanup {
604604 destroy .c
605605 } -result {1.3}
618618 update
619619 } -body {
620620 .r configure -borderwidth 1.3
621 .r cget -borderwidth
621 .r cget -borderwidth
622622 } -cleanup {
623623 destroy .r
624624 } -result {1.3}
10021002 } -returnCodes {error} -result {unknown color name "non-existent"}
10031003
10041004 test button-1.103 {configuration option: "font" for label} -setup {
1005 label .l -borderwidth 2 -highlightthickness 2
1005 label .l -borderwidth 2 -highlightthickness 2
10061006 pack .l
10071007 update
10081008 } -body {
10121012 destroy .l
10131013 } -result {Helvetica -12}
10141014 test button-1.104 {configuration option: "activebackground" for label} -setup {
1015 label .l -borderwidth 2 -highlightthickness 2
1015 label .l -borderwidth 2 -highlightthickness 2
10161016 pack .l
10171017 update
10181018 } -body {
10211021 destroy .l
10221022 } -returnCodes {error} -result {font "" doesn't exist}
10231023 test button-1.105 {configuration option: "font" for button} -setup {
1024 button .b -borderwidth 2 -highlightthickness 2
1024 button .b -borderwidth 2 -highlightthickness 2
10251025 pack .b
10261026 update
10271027 } -body {
10311031 destroy .b
10321032 } -result {Helvetica -12}
10331033 test button-1.106 {configuration option: "activebackground" for button} -setup {
1034 button .b -borderwidth 2 -highlightthickness 2
1034 button .b -borderwidth 2 -highlightthickness 2
10351035 pack .b
10361036 update
10371037 } -body {
10401040 destroy .b
10411041 } -returnCodes {error} -result {font "" doesn't exist}
10421042 test button-1.107 {configuration option: "font" for checkbutton} -setup {
1043 checkbutton .c -borderwidth 2 -highlightthickness 2
1043 checkbutton .c -borderwidth 2 -highlightthickness 2
10441044 pack .c
10451045 update
10461046 } -body {
10501050 destroy .c
10511051 } -result {Helvetica -12}
10521052 test button-1.108 {configuration option: "activebackground" for checkbutton} -setup {
1053 checkbutton .c -borderwidth 2 -highlightthickness 2
1053 checkbutton .c -borderwidth 2 -highlightthickness 2
10541054 pack .c
10551055 update
10561056 } -body {
10591059 destroy .c
10601060 } -returnCodes {error} -result {font "" doesn't exist}
10611061 test button-1.109 {configuration option: "font" for radiobutton} -setup {
1062 radiobutton .r -borderwidth 2 -highlightthickness 2
1062 radiobutton .r -borderwidth 2 -highlightthickness 2
10631063 pack .r
10641064 update
10651065 } -body {
10691069 destroy .r
10701070 } -result {Helvetica -12}
10711071 test button-1.110 {configuration option: "activebackground" for radiobutton} -setup {
1072 radiobutton .r -borderwidth 2 -highlightthickness 2
1072 radiobutton .r -borderwidth 2 -highlightthickness 2
10731073 pack .r
10741074 update
10751075 } -body {
26682668 } -result {}
26692669
26702670 # ex-tests 3.*
2671 test button-2.1 {ButtonCreate - not enough arguments} -body {
2671 test button-2.1 {ButtonCreate - not enough arguments} -body {
26722672 button
26732673 } -returnCodes {error} -result {wrong # args: should be "button pathName ?-option value ...?"}
26742674
27082708 test button-2.7 {ButtonCreate - bad window name} -body {
27092709 button foo
27102710 } -cleanup {
2711 destroy foo
2711 destroy foo
27122712 } -returnCodes {error} -result {bad window path name "foo"}
2713 ######### test ex 3.8
2714 test button-2.8 {ButtonCreate procedure - error in default option value} -body {
2713 ######### test ex 3.8
2714 test button-2.8 {ButtonCreate procedure - error in default option value} -body {
27152715 option add *funny.background bogus
27162716 button .funny
27172717 } -cleanup {
27182718 option clear
27192719 destroy .funny
2720 } -returnCodes {error} -result {unknown color name "bogus"}
2720 } -returnCodes {error} -result {unknown color name "bogus"}
27212721 test button-2.9 {ButtonCreate procedure - error in default option value} -body {
27222722 option add *funny.background bogus
27232723 catch {button .funny}
27302730 invoked from within
27312731 "button .funny"}
27322732
2733 test button-2.10 {ButtonCreate procedure - option error} -body {
2733 test button-2.10 {ButtonCreate procedure - option error} -body {
27342734 button .x -gorp foo
27352735 } -cleanup {
27362736 destroy .x
2737 } -returnCodes {error} -result {unknown option "-gorp"}
2737 } -returnCodes {error} -result {unknown option "-gorp"}
27382738 test button-2.11 {ButtonCreate procedure - option error} -body {
2739 catch {button .x -gorp foo}
2739 catch {button .x -gorp foo}
27402740 winfo exists .x
27412741 } -cleanup {
27422742 destroy .x
27872787 .l cget -disabledforeground
27882788 } -cleanup {
27892789 destroy .l
2790 } -returnCodes {ok} -match {glob} -result {*}
2790 } -returnCodes {ok} -match {glob} -result {*}
27912791 test button-3.7 {ButtonWidgetCmd procedure, "cget" option} -body {
27922792 button .b
27932793 .b cget -disabledforeground
27942794 } -cleanup {
27952795 destroy .b
2796 } -returnCodes {ok} -match {glob} -result {*}
2796 } -returnCodes {ok} -match {glob} -result {*}
27972797 test button-3.8 {ButtonWidgetCmd procedure, "cget" option} -body {
27982798 button .b
27992799 .b cget -variable
28062806 .c cget -variable
28072807 } -cleanup {
28082808 destroy .c
2809 } -returnCodes {ok} -match {glob} -result {*}
2809 } -returnCodes {ok} -match {glob} -result {*}
28102810 test button-3.10 {ButtonWidgetCmd procedure, "cget" option} -body {
28112811 checkbutton .c
28122812 .c cget -value
28192819 .r cget -value
28202820 } -cleanup {
28212821 destroy .r
2822 } -returnCodes {ok} -match {glob} -result {*}
2822 } -returnCodes {ok} -match {glob} -result {*}
28232823 test button-3.12 {ButtonWidgetCmd procedure, "cget" option} -body {
28242824 radiobutton .r
28252825 .r cget -onvalue
28392839 llength [.c configure]
28402840 } -cleanup {
28412841 destroy .c
2842 } -result {41}
2842 } -result {41}
28432843 test button-3.15 {ButtonWidgetCmd procedure, "configure" option} -body {
28442844 button .b
28452845 .b configure -gorp
28882888 return $checkvar
28892889 } -cleanup {
28902890 destroy .c
2891 } -result {0}
2891 } -result {0}
28922892 test button-3.22 {ButtonWidgetCmd procedure, "deselect" option} -body {
28932893 radiobutton .r -variable radiovar -value red
28942894 set radiovar green
28962896 return $radiovar
28972897 } -cleanup {
28982898 destroy .r
2899 } -result {green}
2899 } -result {green}
29002900 test button-3.23 {ButtonWidgetCmd procedure, "deselect" option} -body {
29012901 radiobutton .r -variable radiovar -value red
29022902 set radiovar red
29042904 return $radiovar
29052905 } -cleanup {
29062906 destroy .r
2907 } -result {}
2908
2909 test button-3.24 {ButtonWidgetCmd procedure, "deselect" option} -body {
2907 } -result {}
2908
2909 test button-3.24 {ButtonWidgetCmd procedure, "deselect" option} -body {
29102910 checkbutton .c -variable checkvar -onvalue 1 -offvalue 0
29112911 set checkvar 1
29122912 trace variable checkvar w bogusTrace
29142914 } -cleanup {
29152915 destroy .c
29162916 trace vdelete checkvar w bogusTrace
2917 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
2917 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
29182918 test button-3.25 {ButtonWidgetCmd procedure, "deselect" option} -body {
29192919 checkbutton .c -variable checkvar -onvalue 1 -offvalue 0
29202920 set checkvar 1
29362936 } -cleanup {
29372937 destroy .r
29382938 trace vdelete radiovar w bogusTrace
2939 } -match {glob} -returnCodes {error} -result {can't set "radiovar": trace aborted}
2939 } -match {glob} -returnCodes {error} -result {can't set "radiovar": trace aborted}
29402940 test button-3.27 {ButtonWidgetCmd procedure, "deselect" option} -body {
29412941 radiobutton .r -variable radiovar -value red
29422942 set radiovar red
29632963 } -cleanup {
29642964 destroy .l
29652965 } -returnCodes {error} -result {bad option "flash": must be cget or configure}
2966 test button-3.30 {ButtonWidgetCmd procedure, "flash" option} -body {
2966 test button-3.30 {ButtonWidgetCmd procedure, "flash" option} -body {
29672967 button .b
29682968 catch {.b flash}
29692969 } -cleanup {
29702970 destroy .b
29712971 } -returnCodes {ok} -match {glob} -result {*}
2972 test button-3.31 {ButtonWidgetCmd procedure, "flash" option} -body {
2972 test button-3.31 {ButtonWidgetCmd procedure, "flash" option} -body {
29732973 checkbutton .c
29742974 catch {.c flash}
29752975 } -cleanup {
29762976 destroy .c
29772977 } -returnCodes {ok} -match {glob} -result {*}
2978 test button-3.32 {ButtonWidgetCmd procedure, "flash" option} -body {
2978 test button-3.32 {ButtonWidgetCmd procedure, "flash" option} -body {
29792979 radiobutton .r
29802980 catch {.r f}
29812981 } -cleanup {
30593059 destroy .c
30603060 } -result {lovely}
30613061 test button-3.43 {ButtonWidgetCmd procedure, "select" option} -body {
3062 radiobutton .r -variable radiovar -value red
3062 radiobutton .r -variable radiovar -value red
30633063 set radiovar green
30643064 .r select
30653065 return $radiovar
30663066 } -cleanup {
30673067 destroy .r
30683068 } -result {red}
3069 test button-3.44 {ButtonWidgetCmd procedure, "select" option} -body {
3069 test button-3.44 {ButtonWidgetCmd procedure, "select" option} -body {
30703070 radiobutton .r -variable radiovar -value red
30713071 set radiovar yellow
30723072 trace variable radiovar w bogusTrace
30743074 } -cleanup {
30753075 destroy .r
30763076 trace vdelete radiovar w bogusTrace
3077 } -returnCodes {error} -result {can't set "radiovar": trace aborted}
3077 } -returnCodes {error} -result {can't set "radiovar": trace aborted}
30783078 test button-3.45 {ButtonWidgetCmd procedure, "select" option} -body {
30793079 radiobutton .r -variable radiovar -value red
30803080 set radiovar yellow
31273127 } -cleanup {
31283128 destroy .c
31293129 } -result {sunshine rain sunshine}
3130 test button-3.51 {ButtonWidgetCmd procedure, "toggle" option} -body {
3130 test button-3.51 {ButtonWidgetCmd procedure, "toggle" option} -body {
31313131 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31323132 set checkvar xyz
31333133 trace variable checkvar w bogusTrace
31353135 } -cleanup {
31363136 destroy .c
31373137 trace vdelete checkvar w bogusTrace
3138 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
3138 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
31393139 test button-3.52 {ButtonWidgetCmd procedure, "toggle" option} -body {
31403140 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31413141 set checkvar xyz
31423142 trace variable checkvar w bogusTrace
3143 catch {.c toggle}
3143 catch {.c toggle}
31443144 list $errorInfo $checkvar
31453145 } -cleanup {
31463146 trace vdelete checkvar w bogusTrace
31493149 while executing
31503150 *
31513151 ".c toggle"} abc}
3152 test button-3.53 {ButtonWidgetCmd procedure, "toggle" option} -body {
3152 test button-3.53 {ButtonWidgetCmd procedure, "toggle" option} -body {
31533153 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31543154 set checkvar abc
31553155 trace variable checkvar w bogusTrace
31573157 } -cleanup {
31583158 trace vdelete checkvar w bogusTrace
31593159 destroy .c
3160 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
3160 } -returnCodes {error} -result {can't set "checkvar": trace aborted}
31613161 test button-3.54 {ButtonWidgetCmd procedure, "toggle" option} -body {
31623162 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31633163 set checkvar abc
31643164 trace variable checkvar w bogusTrace
3165 catch {.c toggle}
3165 catch {.c toggle}
31663166 list $errorInfo $checkvar
31673167 } -cleanup {
31683168 trace vdelete checkvar w bogusTrace
31733173 ".c toggle"} xyz}
31743174 test button-3.55 {ButtonWidgetCmd procedure, "toggle" option} -setup {
31753175 unset -nocomplain checkvar
3176 } -body {
3176 } -body {
31773177 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31783178 unset checkvar
31793179 set checkvar(1) 1
31803180 .c toggle
31813181 } -cleanup {
31823182 destroy .c
3183 } -returnCodes {error} -result {can't set "checkvar": variable is array}
3183 } -returnCodes {error} -result {can't set "checkvar": variable is array}
31843184 test button-3.56 {ButtonWidgetCmd procedure, "toggle" option} -setup {
31853185 unset -nocomplain checkvar
3186 } -body {
3186 } -body {
31873187 checkbutton .c -variable checkvar -onvalue xyz -offvalue abc
31883188 unset checkvar
31893189 set checkvar(1) 1
32083208 checkbutton .b5 -variable x -text "Checkbutton 5"
32093209 set x 1
32103210 pack .b1 .b2 .b3 .b4 .b5
3211 update
3212 deleteWindows
3211 update
3212 deleteWindows
32133213 } -cleanup {
32143214 destroy .b1 .b2 .b3 .b4 .b5
32153215 image delete image1
3216 } -result {}
3216 } -result {}
32173217
32183218 test button-5.1 {ConfigureButton - textvariable trace} -body {
32193219 button .b -bd 4 -bg green
32203220 .b configure -bd 7 -bg red -fg bogus
32213221 } -cleanup {
32223222 destroy .b
3223 } -returnCodes {error} -result {unknown color name "bogus"}
3223 } -returnCodes {error} -result {unknown color name "bogus"}
32243224 test button-5.2 {ConfigureButton - textvariable trace} -body {
32253225 button .b -bd 4 -bg green
3226 catch {.b configure -bd 7 -bg red -fg bogus}
3226 catch {.b configure -bd 7 -bg red -fg bogus}
32273227 list [.b cget -bd] [.b cget -bg]
32283228 } -cleanup {
32293229 destroy .b
32703270 checkbutton .c
32713271 .c cget -variable
32723272 } -cleanup {
3273 destroy .c
3273 destroy .c
32743274 } -result {c}
32753275 test button-5.7 {ConfigureButton - setting selected state from variable} -body {
32763276 set x 0
33043304 unset -nocomplain x
33053305 } -body {
33063306 trace variable x w bogusTrace
3307 radiobutton .r -variable x
3307 radiobutton .r -variable x
33083308 } -cleanup {
33093309 destroy .r
33103310 trace vdelete x w bogusTrace
33413341 } -cleanup {
33423342 trace vdelete x w bogusTrace
33433343 destroy .r
3344 } -returnCodes {error} -result {can't set "x": trace aborted}
3344 } -returnCodes {error} -result {can't set "x": trace aborted}
33453345 test button-5.15 {ConfigureButton - variable handling} -setup {
33463346 unset -nocomplain x
33473347 } -body {
33543354 } -result {foo}
33553355
33563356 #ex 6.14
3357 test button-5.16 {ConfigureButton - -width option} -body {
3357 test button-5.16 {ConfigureButton - -width option} -body {
33583358 button .b -text "Button 1"
33593359 .b configure -width 1i
33603360 } -cleanup {
33613361 destroy .b
3362 } -returnCodes {error} -result {expected integer but got "1i"}
3362 } -returnCodes {error} -result {expected integer but got "1i"}
33633363 test button-5.17 {ConfigureButton - -width option} -body {
33643364 button .b -text "Button 1"
33653365 catch {.b configure -width 1i}
33703370 (processing -width option)
33713371 invoked from within
33723372 ".b configure -width 1i"}
3373 test button-5.18 {ConfigureButton - -height option} -body {
3373 test button-5.18 {ConfigureButton - -height option} -body {
33743374 button .b -text "Button 1"
33753375 .b configure -height 0.5c
33763376 } -cleanup {
33773377 destroy .b
3378 } -returnCodes {error} -result {expected integer but got "0.5c"}
3379 test button-5.19 {ConfigureButton - -height option} -body {
3378 } -returnCodes {error} -result {expected integer but got "0.5c"}
3379 test button-5.19 {ConfigureButton - -height option} -body {
33803380 button .b -text "Button 1"
3381 catch {.b configure -height 0.5c}
3381 catch {.b configure -height 0.5c}
33823382 return $errorInfo
33833383 } -cleanup {
33843384 destroy .b
33923392 .b configure -width abc
33933393 } -cleanup {
33943394 destroy .b
3395 } -returnCodes {error} -result {bad screen distance "abc"}
3395 } -returnCodes {error} -result {bad screen distance "abc"}
33963396 test button-5.21 {ConfigureButton - -width option} -body {
33973397 button .b -bitmap questhead
3398 catch {.b configure -width abc}
3398 catch {.b configure -width abc}
33993399 return $errorInfo
34003400 } -cleanup {
34013401 destroy .b
34133413 } -cleanup {
34143414 destroy .b
34153415 image delete image1
3416 } -returnCodes {error} -result {bad screen distance "0.5x"}
3416 } -returnCodes {error} -result {bad screen distance "0.5x"}
34173417 test button-5.23 {ConfigureButton - -height option} -constraints {
34183418 testImageType
34193419 } -setup {
34213421 } -body {
34223422 #ztestImageType
34233423 button .b -image image1
3424 catch {.b configure -height 0.5x}
3424 catch {.b configure -height 0.5x}
34253425 return $errorInfo
34263426 } -cleanup {
34273427 destroy .b
35223522
35233523 test button-8.1 {TkInvokeButton procedure} -setup {
35243524 set x 0
3525 } -body {
3525 } -body {
35263526 checkbutton .c -variable x
35273527 set result $x
35283528 .c invoke
35333533 destroy .c
35343534 } -result {0 1 0}
35353535
3536 test button-8.2 {TkInvokeButton procedure} -setup {
3536 test button-8.2 {TkInvokeButton procedure} -setup {
35373537 set x 0
3538 } -body {
3538 } -body {
35393539 checkbutton .c -variable x
35403540 trace variable x w bogusTrace
35413541 .c invoke
35453545 } -returnCodes {error} -result {can't set "x": trace aborted}
35463546 test button-8.3 {TkInvokeButton procedure} -setup {
35473547 set x 0
3548 } -body {
3548 } -body {
35493549 checkbutton .c -variable x
35503550 trace variable x w bogusTrace
35513551 catch {.c invoke}
35543554 destroy .c
35553555 trace vdelete x w bogusTrace
35563556 } -result {1}
3557 test button-8.4 {TkInvokeButton procedure} -setup {
3557 test button-8.4 {TkInvokeButton procedure} -setup {
35583558 set x 1
3559 } -body {
3559 } -body {
35603560 checkbutton .c -variable x
35613561 trace variable x w bogusTrace
35623562 .c invoke
35663566 } -returnCodes {error} -result {can't set "x": trace aborted}
35673567 test button-8.5 {TkInvokeButton procedure} -setup {
35683568 set x 1
3569 } -body {
3569 } -body {
35703570 checkbutton .c -variable x
35713571 trace variable x w bogusTrace
35723572 catch {.c invoke}
35783578
35793579 test button-8.6 {TkInvokeButton procedure} -setup {
35803580 set x 0
3581 } -body {
3581 } -body {
35823582 radiobutton .r -variable x -value red
35833583 set result $x
35843584 .r invoke
35893589 destroy .r
35903590 } -result {0 red red}
35913591
3592 test button-8.7 {TkInvokeButton procedure} -body {
3592 test button-8.7 {TkInvokeButton procedure} -body {
35933593 radiobutton .r -variable x -value red
35943594 set x green
35953595 trace variable x w bogusTrace
35983598 destroy .r
35993599 trace vdelete x w bogusTrace
36003600 } -returnCodes {error} -result {can't set "x": trace aborted}
3601 test button-8.8 {TkInvokeButton procedure} -body {
3601 test button-8.8 {TkInvokeButton procedure} -body {
36023602 radiobutton .r -variable x -value red
36033603 set x green
36043604 trace variable x w bogusTrace
37533753 } -result {0}
37543754
37553755 test button-11.1 {ButtonImageProc procedure} -constraints {
3756 testImageType
3756 testImageType
37573757 } -setup {
37583758 label .l -highlightthickness 0 -font {Helvetica -12 bold}
37593759 image create test image1
37873787 label .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
37883788 set result {}
37893789 } -body {
3790 .a configure -text Hej
3790 .a configure -text Hej
37913791 .b configure -text Hej -width 10 -height 1
37923792 .c configure -text "" -width 10 -height 1
37933793
37993799 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38003800 } -cleanup {
38013801 destroy .a .b .c
3802 } -result {1 1 1}
3802 } -result {1 1 1}
38033803 test button-13.2 {size behavior: label} -setup {
38043804 label .a -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38053805 label .b -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38063806 label .c -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38073807 set result {}
38083808 } -body {
3809 .a configure -text Hej
3809 .a configure -text Hej
38103810 .b configure -text Hej -width 10 -height 1
38113811 .c configure -text "" -width 10 -height 1
38123812
38183818 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38193819 } -cleanup {
38203820 destroy .a .b .c
3821 } -result {1 1 1}
3821 } -result {1 1 1}
38223822
38233823 test button-13.3 {size behavior: button} -setup {
38243824 button .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
38263826 button .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
38273827 set result {}
38283828 } -body {
3829 .a configure -text Hej
3829 .a configure -text Hej
38303830 .b configure -text Hej -width 10 -height 1
38313831 .c configure -text "" -width 10 -height 1
38323832
38383838 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38393839 } -cleanup {
38403840 destroy .a .b .c
3841 } -result {1 1 1}
3841 } -result {1 1 1}
38423842 test button-13.4 {size behavior: button} -setup {
38433843 button .a -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38443844 button .b -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38453845 button .c -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38463846 set result {}
38473847 } -body {
3848 .a configure -text Hej
3848 .a configure -text Hej
38493849 .b configure -text Hej -width 10 -height 1
38503850 .c configure -text "" -width 10 -height 1
38513851
38573857 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38583858 } -cleanup {
38593859 destroy .a .b .c
3860 } -result {1 1 1}
3860 } -result {1 1 1}
38613861
38623862 test button-13.5 {size behavior: radiobutton} -setup {
38633863 radiobutton .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
38653865 radiobutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
38663866 set result {}
38673867 } -body {
3868 .a configure -text Hej
3868 .a configure -text Hej
38693869 .b configure -text Hej -width 10 -height 1
38703870 .c configure -text "" -width 10 -height 1
38713871
38773877 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38783878 } -cleanup {
38793879 destroy .a .b .c
3880 } -result {1 1 1}
3880 } -result {1 1 1}
38813881
38823882 test button-13.6 {size behavior: radiobutton} -setup {
38833883 radiobutton .a -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38853885 radiobutton .c -borderwidth 2 -highlightthickness 2 -font {Arial 20}
38863886 set result {}
38873887 } -body {
3888 .a configure -text Hej
3888 .a configure -text Hej
38893889 .b configure -text Hej -width 10 -height 1
38903890 .c configure -text "" -width 10 -height 1
38913891
38973897 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
38983898 } -cleanup {
38993899 destroy .a .b .c
3900 } -result {1 1 1}
3900 } -result {1 1 1}
39013901
39023902 test button-13.7 {size behavior: checkbutton} -setup {
39033903 checkbutton .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
39053905 checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
39063906 set result {}
39073907 } -body {
3908 .a configure -text Hej
3908 .a configure -text Hej
39093909 .b configure -text Hej -width 10 -height 1
39103910 .c configure -text "" -width 10 -height 1
39113911
39173917 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
39183918 } -cleanup {
39193919 destroy .a .b .c
3920 } -result {1 1 1}
3920 } -result {1 1 1}
39213921
39223922 test button-13.8 {size behavior: checkbutton} -setup {
39233923 checkbutton .a -borderwidth 2 -highlightthickness 2 -font {Arial 20}
39253925 checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Arial 20}
39263926 set result {}
39273927 } -body {
3928 .a configure -text Hej
3928 .a configure -text Hej
39293929 .b configure -text Hej -width 10 -height 1
39303930 .c configure -text "" -width 10 -height 1
39313931
39373937 lappend result [expr {[winfo reqheight .a] == [winfo reqheight .b]}]
39383938 } -cleanup {
39393939 destroy .a .b .c
3940 } -result {1 1 1}
3940 } -result {1 1 1}
39413941
39423942 test button-14.1 {bug fix: [011706ec42] tk::ButtonInvoke unsafe wrt widget destruction} -body {
39433943 proc destroy_button {} {
39553955 update ; # shall not trigger error invalid command name ".top.b"
39563956 } -cleanup {
39573957 destroy .top.b .top
3958 } -result {}
3958 } -result {}
39593959
39603960 test button-15.1 {Bug [5d991b822e]} {
39613961 # Want this not to segfault
173173 while {"timed out" ni $y && [lindex $y end 1] ne "display"} {
174174 vwait y
175175 }
176 after cancel timer
176 after cancel $timer
177177 list $x $y [.c bbox i1]
178178 } -cleanup {
179179 .c delete all
321321 imageCleanup
322322 } -result {5 15 35 30}
323323 test canvImg-6.10 {ComputeImageBbox procedure} -constraints {
324 testImageType
324 testImageType
325325 } -setup {
326326 image create test foo
327327 .c delete all
334334 image delete foo
335335 } -result {20 15 50 30}
336336 test canvImg-6.11 {ComputeImageBbox procedure} -constraints {
337 testImageType
337 testImageType
338338 } -setup {
339339 image create test foo
340340 .c delete all
347347 image delete foo
348348 } -result {20 23 50 38}
349349 test canvImg-6.12 {ComputeImageBbox procedure} -constraints {
350 testImageType
350 testImageType
351351 } -setup {
352352 image create test foo
353353 .c delete all
726726 image delete foo
727727 } -result {75 150 105 165}
728728
729 if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
730 # Aqua >= 10.14 will redraw the entire image.
731 set result_10_1 {{foo display 0 0 30 15}}
732 } else {
733 set result_10_1 {{foo display 2 4 6 8}}
734 }
735729 test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup {
736730 .c delete all
737731 update
744738 foo changed 2 4 6 8 30 15
745739 vwait x
746740 after cancel $timer
747 update
748741 return $x
749742 } -cleanup {
750743 .c delete all
751744 image delete foo
752 } -result $result_10_1
745 } -result {{foo display 2 4 6 8}}
753746
754747 test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup {
755748 .c delete all
761754 set x {}
762755 set timer [after 500 {lappend x "timed out"}]
763756 foo changed 2 4 6 8 40 50
764 vwait x
757 vwait x
765758 after cancel $timer
766759 update
767760 return $x
770763 image delete foo
771764 } -result {{foo display 0 0 40 50}}
772765 test canvImg-11.2 {ImageChangedProc procedure} -constraints {
773 testImageType
766 testImageType
774767 } -setup {
775768 .c delete all
776769 } -body {
784777 .c delete all
785778 image delete foo
786779 } -result {30 75 70 125}
787 if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
788 # Aqua >= 10.14 will redraw the entire image.
789 set result_11_3 {{foo2 display 0 0 80 60}}
790 } else {
791 set result_11_3 {{foo2 display 0 0 20 40}}
792 }
780
793781 test canvImg-11.3 {ImageChangedProc procedure} -constraints {
794 testImageType
782 testImageType
795783 } -setup {
796784 .c delete all
797 update
785 update idletasks
798786 } -body {
799787 image create test foo -variable x
800788 image create test foo2 -variable z
802790 foo2 changed 0 0 0 0 80 60
803791 .c create image 50 100 -image foo -tags image -anchor nw
804792 .c create image 70 110 -image foo2 -anchor nw
805 update
806793 set z {}
807794 set timer [after 500 {lappend z "timed out"}]
808 image create test foo -variable x
809 vwait x
795 image delete foo
796 vwait z
810797 after cancel $timer
811798 return $z
812799 } -cleanup {
813800 .c delete all
814 image delete foo foo2
815 } -result $result_11_3
801 image delete foo2
802 } -result {{foo2 display 0 0 80 60}}
816803
817804 # cleanup
818805 imageFinish
55 # Copyright (c) 2004 Neil McKay.
66 # All rights reserved.
77
8 package require tcltest 2.1
8 package require tcltest 2.2
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111
3232 test canvMoveto-2.1 {Canvas "moveto" command coordinates} {
3333 .c moveto test 200 150
3434 .c bbox test
35 } {200 150 272 232}
35 } {200 150 272 232}
3636 test canvMoveto-2.2 {Canvas "moveto" command, blank y coordinate} {
3737 .c moveto test 200 150
3838 .c moveto test 150 {}
1818 update
1919
2020 test canvPs-1.1 {test writing to a file} -constraints {
21 unixOrPc
21 unixOrWin
2222 } -setup {
2323 set foo [makeFile {} foo.ps]
2424 } -body {
25 .c postscript -file $foo
26 file exists $foo
25 set res [.c postscript -file $foo]
26 lappend res [file exists $foo]
2727 } -cleanup {
2828 removeFile foo.ps
2929 } -result 1
3030 test canvPs-1.2 {test writing to a file, idempotency} -constraints {
31 unixOrPc
31 unixOrWin
3232 } -setup {
3333 set foo [makeFile {} foo.ps]
3434 set bar [makeFile {} bar.ps]
4747
4848
4949 test canvPs-2.1 {test writing to a channel} -constraints {
50 unixOrPc
50 unixOrWin
5151 } -setup {
5252 set foo [makeFile {} foo.ps]
5353 file delete $foo
5454 } -body {
5555 set chan [open $foo w]
5656 fconfigure $chan -translation lf
57 .c postscript -channel $chan
57 set res [.c postscript -channel $chan]
5858 close $chan
59 file exists $foo
59 lappend res [file exists $foo]
6060 } -cleanup {
6161 removeFile foo.ps
6262 } -result 1
6363 test canvPs-2.2 {test writing to channel, idempotency} -constraints {
64 unixOrPc
64 unixOrWin
6565 } -setup {
6666 set foo [makeFile {} foo.ps]
6767 set bar [makeFile {} bar.ps]
227227 [expr {[.c find closest 20 25.1] eq $yId}] \
228228 [expr {[.c find closest 20 29.9] eq $yId}] \
229229 [expr {[.c find closest 20 30.1] eq $xId}]
230
230
231231 } -cleanup {
232232 .c delete all
233233 } -result {1 1 1 1}
249249 list [expr {[.c find closest 20 24.4] eq $xId}] \
250250 [expr {[.c find closest 20 24.6] eq $yId}] \
251251 [expr {[.c find closest 20 30.4] eq $yId}] \
252 [expr {[.c find closest 20 30.6] eq $xId}]
252 [expr {[.c find closest 20 30.6] eq $xId}]
253253 } -cleanup {
254254 .c delete all
255255 } -result {1 1 1 1}
274274 list [expr {[.c find closest 20 23.2] eq $xId}] \
275275 [expr {[.c find closest 20 23.3] eq $yId}] \
276276 [expr {[.c find closest 20 31.7] eq $yId}] \
277 [expr {[.c find closest 20 31.8] eq $xId}]
278 } -cleanup {
279 .c delete all
280 } -result {1 1 1 1}
281
277 [expr {[.c find closest 20 31.8] eq $xId}]
278 } -cleanup {
279 .c delete all
280 } -result {1 1 1 1}
281
282282 test canvRect-6.7 {RectToPoint procedure} -body {
283 set xId [.c create rectangle 10 20 30 40 -outline {} -fill black]
283 set xId [.c create rectangle 10 20 30 40 -outline {} -fill black]
284284 set yId [.c create rectangle 40 40 50 50 -outline {} -fill black]
285285 list [expr {[.c find closest 35 35] eq $xId}] \
286286 [expr {[.c find closest 36 36] eq $yId}] \
287287 [expr {[.c find closest 37 37] eq $yId}] \
288 [expr {[.c find closest 38 38] eq $yId}]
288 [expr {[.c find closest 38 38] eq $yId}]
289289 } -cleanup {
290290 .c delete all
291291 } -result {1 1 1 1}
99 namespace import ::tcltest::*
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
12
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1215
1316 # Canvas used in 1.* - 17.* tests
1417 canvas .c -width 400 -height 300 -bd 2 -relief sunken
802805 } -cleanup {
803806 .c delete test
804807 } -returnCodes error -result "wrong \# args: should be \".c select clear\""
808 test canvText-14.7 {GetTextIndex procedure: pixel index with non-default scrollregion} -setup {
809 canvas .cc
810 .cc create text 50 80 -tag test -text Hello -anchor nw -font "Arial 30"
811 foreach {xmin ymin xmax ymax} [.cc bbox test] {}
812 } -body {
813 # default -scrollregion
814 set res [.cc index test @$xmin,$ymin]
815 lappend res [.cc index test @$xmax,$ymax]
816 # -scrollregion with positive upper left corner
817 .cc configure -scrollregion {50 50 700 900}
818 lappend res [.cc index test @$xmin,$ymin]
819 lappend res [.cc index test @$xmax,$ymax]
820 # -scrollregion with negative upper left corner
821 .cc configure -scrollregion {-100 -100 700 900}
822 lappend res [.cc index test @$xmin,$ymin]
823 lappend res [.cc index test @$xmax,$ymax]
824 } -cleanup {
825 destroy .cc
826 } -result {0 5 0 5 0 5}
805827
806828 test canvText-15.1 {SetTextCursor procedure} -setup {
807829 .c create text 0 0 -tag test
920942 destroy .c
921943 } -result {{Yeah } Yeah- 4 4}
922944
923 test canvText-20.1 {angled text bounding box} -setup {
945 test canvText-20.1 {angled text bounding box} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
924946 destroy .c
925947 canvas .c
926948 proc transpose {bbox} {
944966 rename transpose {}
945967 } -result {ok ok ok}
946968
969 test canvText-20.2 {crash on angled text selection (X11, without xft) - bug 2712f43f6e} -setup {
970 destroy .c
971 canvas .c -background bisque -selectforeground green2
972 grid .c
973 set id [.c create text 50 150 -anchor w -text "Angled text" \
974 -angle 30 -font {Helvetica 32} -fill darkblue]
975 } -body {
976 .c select clear
977 .c select from $id 0
978 .c select to $id 8 ; update ; # used to crash on X11 (--disable-xft build only)
979 } -cleanup {
980 destroy .c
981 } -result {}
982
947983 # cleanup
948984 cleanupTests
949985 return
66 # Copyright (c) 2008 Donal K. Fellows
77 # All rights reserved.
88
9 package require tcltest 2.1
9 package require tcltest 2.2
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212 imageInit
536536 destroy .c
537537 pack [canvas .c]
538538 } -body {
539 set qx [expr {1.+1.}]
540 # qx has type double and no string representation
539 set qx [expr {1.+1.}]
540 # qx has type double and no string representation
541541 .c scale all $qx 0 1. 1.
542 # qx has now type MMRep and no string representation
542 # qx has now type MMRep and no string representation
543543 list $qx [string length $qx]
544544 } -result {2.0 3}
545545 test canvas-12.2 {canvas mm obj, patch SF-403327, 102471} -setup {
548548 } -body {
549549 set val 10
550550 incr val
551 # qx has type double and no string representation
551 # qx has type double and no string representation
552552 .c scale all $val 0 1 1
553 # qx has now type MMRep and no string representation
553 # qx has now type MMRep and no string representation
554554 incr val
555555 } -result 12
556556
726726 destroy .c
727727 canvas .c
728728 } -body {
729 set id [.c create rect 0 0 1cm 1cm]
729 set id [.c create rect 0 0 1cm 1cm]
730730 expr {[lindex [.c coords $id] 2]>1}
731731 } -result {1}
732732 destroy .c
949949 destroy .c
950950 } -returnCodes error -result {bad index "foo"}
951951
952 test canvas-20.1 {addtag/dtag - no shuffling of tag sequence} -setup {
953 canvas .c
954 .c create text 100 100 -text Hello
955 } -body {
956 for {set i 1} {$i < 5} {incr i} {
957 .c addtag tag$i all
958 }
959 # [.c addtags] only adds tags that are not already present
960 .c addtag tag1 all ; # no effect
961 set res [list [.c gettags 1]]
962 .c dtag 1 tag2
963 lappend res [.c gettags 1]
964 } -cleanup {
965 destroy .c
966 } -result {{tag1 tag2 tag3 tag4} {tag1 tag3 tag4}}
967 test canvas-20.2 {tag deletion - multiple tags with same name, no shuffling} -setup {
968 canvas .c
969 .c create text 100 100 -text Hello
970 } -body {
971 # [.c itemconfigure -tags] lets the user add duplicate tags
972 # this is not a problem although inconsistent with [.c addtags]
973 .c itemconfigure 1 -tags {tagA tagB tagA tagA tagC tagA}
974 set res [list [.c gettags 1]]
975 .c dtag 1 tagA
976 lappend res [.c gettags 1]
977 } -cleanup {
978 destroy .c
979 } -result {{tagA tagB tagA tagA tagC tagA} {tagB tagC}}
980 test canvas-20.3 {tag deletion - all tags match} -setup {
981 canvas .c
982 .c create text 100 100 -text Hello
983 } -body {
984 # [.c itemconfigure -tags] lets the user add duplicate tags
985 # this is not a problem although inconsistent with [.c addtags]
986 .c itemconfigure 1 -tags {tagA tagA tagA tagA tagA tagA}
987 set res [list [.c gettags 1]]
988 .c dtag 1 tagA
989 lappend res [.c gettags 1]
990 } -cleanup {
991 destroy .c
992 } -result {{tagA tagA tagA tagA tagA tagA} {}}
993
952994 # cleanup
953995 imageCleanup
954996 cleanupTests
2020 eval tcltest::configure $argv
2121 tcltest::loadTestedCommands
2222
23 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
24
2325 # set up a very large buffer to test INCR retrievals
2426 set longValue ""
2527 foreach i {a b c d e f g j h i j k l m o p q r s t u v w x y z} {
179181 clipboard get
180182 } -cleanup {
181183 clipboard clear
182 } -returnCodes error -result {CLIPBOARD selection doesn't exist or form "STRING" not defined}
184 } -returnCodes error -result {CLIPBOARD selection doesn't exist or form "STRING" not defined}
183185 test clipboard-4.5 {ClipboardLostSel procedure} -setup {
184186 clipboard clear
185187 } -body {
232234 } -cleanup {
233235 clipboard clear
234236 } -returnCodes ok -result {first chunk second chunk}
235 test clipboard-6.2 {Tk_ClipboardAppend procedure} -constraints x11 -setup {
237 test clipboard-6.2 {Tk_ClipboardAppend procedure} -constraints {x11 failsOnXQuarz} -setup {
236238 clipboard clear
237239 } -body {
238240 setupbg
3838 } -body {
3939 after 100 {set x deleted; destroy .f}
4040 tkwait visibility .f.b
41 } -returnCodes {error} -result {window ".f.b" was deleted before its visibility changed}
41 } -returnCodes {error} -result {window ".f.b" was deleted before its visibility changed}
4242 test cmds-1.6 {tkwait visibility, window gets deleted} -setup {
4343 frame .f
4444 button .f.b -text "Test"
44 # Copyright (c) 1998-1999 by Scriptics Corporation.
55 # All rights reserved.
66
7 package require tcltest 2.1
7 package require tcltest 2.2
88 eval tcltest::configure $argv
99 tcltest::loadTestedCommands
1010
161161 test color-1.5 {Color table} nonPortable {
162162 set fd [open ../xlib/rgb.txt]
163163 set result {}
164 while {[gets $fd line] != -1} {
164 while {[gets $fd line] >= 0} {
165165 if {[string index $line 0] == "!"} continue
166166 set rgb [c255 [winfo rgb . [lrange $line 3 end]]]
167167 if {$rgb != [lrange $line 0 2] } {
195195 testobjconfig
196196 } -body {
197197 option add *a.color non-existent
198 catch {testobjconfig alltypes .a}
198 catch {testobjconfig alltypes .a}
199199 return $errorInfo
200200 } -cleanup {
201201 killTables
557557 killTables
558558 } -returnCodes ok
559559 test config-4.42 {DoObjConfig - getting rid of old color} -constraints {
560 testobjconfig
560 testobjconfig
561561 } -body {
562562 testobjconfig alltypes .foo -color #333333
563563 .foo configure -color #444444
565565 killTables
566566 } -returnCodes ok -result {32}
567567 test config-4.43 {DoObjConfig - getting rid of old color} -constraints {
568 testobjconfig
568 testobjconfig
569569 } -body {
570570 testobjconfig alltypes .foo -color #333333
571571 .foo configure -color #444444
574574 killTables
575575 } -returnCodes ok -result {#444444}
576576 test config-4.44 {DoObjConfig - getting rid of old color} -constraints {
577 testobjconfig
577 testobjconfig
578578 } -body {
579579 testobjconfig alltypes .foo -color #333333
580580 .foo configure -color #444444
664664 } -returnCodes ok -result {gray75}
665665 test config-4.55 {DoObjConfig - new bitmap} -constraints testobjconfig -body {
666666 testobjconfig alltypes .foo -bitmap gray75
667 .foo configure -bitmap gray50
667 .foo configure -bitmap gray50
668668 } -cleanup {
669669 killTables
670670 } -returnCodes ok -result {128}
671671 test config-4.56 {DoObjConfig - new bitmap} -constraints testobjconfig -body {
672672 testobjconfig alltypes .foo -bitmap gray75
673 .foo configure -bitmap gray50
673 .foo configure -bitmap gray50
674674 .foo cget -bitmap
675675 } -cleanup {
676676 killTables
744744 killTables
745745 } -result {#123456}
746746 test config-4.67 {DoObjConfig - getting rid of old border} -constraints {
747 testobjconfig
747 testobjconfig
748748 } -body {
749749 testobjconfig alltypes .foo -border #333333
750750 .foo configure -border #444444
752752 killTables
753753 } -returnCodes ok -result {256}
754754 test config-4.68 {DoObjConfig - getting rid of old border} -constraints {
755 testobjconfig
755 testobjconfig
756756 } -body {
757757 testobjconfig alltypes .foo -border #333333
758758 .foo configure -border #444444
789789 } -result {ridge}
790790 test config-4.73 {DoObjConfig - new relief} -constraints testobjconfig -body {
791791 testobjconfig alltypes .foo -relief raised
792 .foo configure -relief flat
792 .foo configure -relief flat
793793 } -cleanup {
794794 killTables
795795 } -returnCodes ok -result {512}
796796 test config-4.74 {DoObjConfig - new relief} -constraints testobjconfig -body {
797797 testobjconfig alltypes .foo -relief raised
798 .foo configure -relief flat
798 .foo configure -relief flat
799799 .foo cget -relief
800800 } -cleanup {
801801 killTables
914914 } -returnCodes error -result {bad anchor "foo": must be n, ne, e, se, s, sw, w, nw, or center}
915915 test config-4.92 {DoObjConfig - new anchor} -constraints testobjconfig -body {
916916 testobjconfig alltypes .foo -anchor e
917 .foo configure -anchor n
917 .foo configure -anchor n
918918 } -cleanup {
919919 killTables
920920 } -returnCodes ok -result {4096}
992992 } -returnCodes ok -result {.bar}
993993 test config-4.103 {DoObjConfig - invalid window} -constraints testobjconfig -body {
994994 toplevel .bar
995 testobjconfig twowindows .foo -window foo
995 testobjconfig twowindows .foo -window foo
996996 } -cleanup {
997997 killTables
998998 } -returnCodes error -result {bad window path name "foo"}
12041204 test config-7.4 {Tk_SetOptions - missing value} -constraints {
12051205 testobjconfig
12061206 } -body {
1207 .a configure -color green -relief
1207 .a configure -color green -relief
12081208 } -returnCodes error -result {value for "-relief" missing}
12091209 test config-7.5 {Tk_SetOptions - missing value} -constraints {
12101210 testobjconfig
12111211 } -body {
1212 catch {.a configure -color green -relief}
1212 catch {.a configure -color green -relief}
12131213 .a cget -color
12141214 } -result {green}
12151215 test config-7.6 {Tk_SetOptions - saving old values} -constraints {
12161216 testobjconfig
12171217 } -body {
12181218 .a configure -color red -int 7 -relief raised -double 3.14159
1219 .a csave -color green -int 432 -relief sunken -double 2.0 -color bogus
1219 .a csave -color green -int 432 -relief sunken -double 2.0 -color bogus
12201220 } -returnCodes error -result {unknown color name "bogus"}
12211221 test config-7.7 {Tk_SetOptions - saving old values} -constraints {
12221222 testobjconfig
12291229 test config-7.8 {Tk_SetOptions - error in DoObjConfig call} -constraints {
12301230 testobjconfig
12311231 } -body {
1232 .a configure -color bogus
1232 .a configure -color bogus
12331233 } -returnCodes error -result {unknown color name "bogus"}
12341234 test config-7.9 {Tk_SetOptions - error in DoObjConfig call} -constraints {
12351235 testobjconfig
12611261 test config-7.13 {Tk_SetOptions - error in DoObjConfig with custom option} -constraints {
12621262 testobjconfig
12631263 } -body {
1264 .a configure -custom bad
1264 .a configure -custom bad
12651265 } -returnCodes error -result {expected good value, got "BAD"}
12661266 test config-7.14 {Tk_SetOptions - error in DoObjConfig with custom option} -constraints {
12671267 testobjconfig
44 return
55 }
66
7 package require Tk 8.4
7 package require Tk
88 tk appname tktest
99 wm title . tktest
1010 # If the main window isn't already mapped (e.g. because the tests are
1616 update
1717 }
1818
19 package require tcltest 2.1
19 package require tcltest 2.2
2020
2121 namespace eval tk {
2222 namespace eval test {
3636
3737 namespace eval bg {
3838 # Manage a background process.
39 # Replace with slave interp or thread?
39 # Replace with child interp or thread?
4040 namespace import ::tcltest::interpreter
4141 namespace import ::tk::test::loadTkCommand
4242 namespace export setup cleanup do
196196 }]
197197
198198 # constraints for testing facilities defined in the tktest executable...
199 testConstraint testImageType [expr {[lsearch [image types] test] >= 0}]
200 testConstraint testOldImageType [expr {[lsearch [image types] oldtest] >= 0}]
199 testConstraint testImageType [expr {"test" in [image types]}]
200 testConstraint testOldImageType [expr {"oldtest" in [image types]}]
201201 testConstraint testbitmap [llength [info commands testbitmap]]
202202 testConstraint testborder [llength [info commands testborder]]
203203 testConstraint testcbind [llength [info commands testcbind]]
246246 }]
247247 destroy .t
248248 testConstraint haveTruecolor24 [expr {
249 [lsearch -exact [winfo visualsavailable .] {truecolor 24}] >= 0
249 {truecolor 24} in [winfo visualsavailable .]
250250 }]
251251 testConstraint haveGrayscale8 [expr {
252 [lsearch -exact [winfo visualsavailable .] {grayscale 8}] >= 0
252 {grayscale 8} in [winfo visualsavailable .]
253253 }]
254254 testConstraint defaultPseudocolor8 [expr {
255255 ([winfo visual .] eq "pseudocolor") && ([winfo depth .] == 8)
107107 } -cleanup {
108108 destroy .b
109109 removeDirectory $wincur(dir)
110 unset wincur
110 unset wincur
111111 } -result {.b}
112112 test cursor-2.4 {Tk_GetCursor procedure: cursor specs are lists} -constraints {
113113 win
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
15 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
16
1317 # For xscrollcommand
18 set scrollInfo {}
1419 proc scroll args {
1520 global scrollInfo
1621 set scrollInfo $args
1722 }
18 # For trace variable
23 # For trace variable
1924 proc override args {
2025 global x
2126 set x 12345
6873 .e cget -bd
6974 } -cleanup {
7075 destroy .e
71 } -result {4}
76 } -result 4
7277 test entry-1.4 {configuration option: "bd" for entry} -setup {
7378 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
7479 pack .e
105110 update
106111 } -body {
107112 .e configure -borderwidth 1.3
108 .e cget -borderwidth
109 } -cleanup {
110 destroy .e
111 } -result {1}
113 .e cget -borderwidth
114 } -cleanup {
115 destroy .e
116 } -result 1
112117 test entry-1.8 {configuration option: "borderwidth" for entry} -setup {
113118 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
114119 pack .e
188193 .e cget -exportselection
189194 } -cleanup {
190195 destroy .e
191 } -result {1}
196 } -result 1
192197 test entry-1.16 {configuration option: "exportselection" for entry} -setup {
193198 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
194199 pack .e
220225 } -returnCodes {error} -result {unknown color name "non-existent"}
221226
222227 test entry-1.19 {configuration option: "font" for entry} -setup {
223 entry .e -borderwidth 2 -highlightthickness 2
228 entry .e -borderwidth 2 -highlightthickness 2
224229 pack .e
225230 update
226231 } -body {
230235 destroy .e
231236 } -result {Helvetica -12}
232237 test entry-1.20 {configuration option: "font" for entry} -setup {
233 entry .e -borderwidth 2 -highlightthickness 2
238 entry .e -borderwidth 2 -highlightthickness 2
234239 pack .e
235240 update
236241 } -body {
308313 .e cget -highlightthickness
309314 } -cleanup {
310315 destroy .e
311 } -result {6}
316 } -result 6
312317 test entry-1.28 {configuration option: "highlightthickness" for entry} -setup {
313318 entry .e -borderwidth 2 -font {Helvetica -12 bold}
314319 pack .e
318323 .e cget -highlightthickness
319324 } -cleanup {
320325 destroy .e
321 } -result {0}
326 } -result 0
322327 test entry-1.29 {configuration option: "highlightthickness" for entry} -setup {
323328 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
324329 pack .e
358363 .e cget -insertborderwidth
359364 } -cleanup {
360365 destroy .e
361 } -result {1}
366 } -result 1
362367 test entry-1.33 {configuration option: "insertborderwidth" for entry} -setup {
363368 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
364369 pack .e
378383 .e cget -insertofftime
379384 } -cleanup {
380385 destroy .e
381 } -result {100}
386 } -result 100
382387 test entry-1.35 {configuration option: "insertofftime" for entry} -setup {
383388 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
384389 pack .e
398403 .e cget -insertontime
399404 } -cleanup {
400405 destroy .e
401 } -result {100}
406 } -result 100
402407 test entry-1.37 {configuration option: "insertontime" for entry} -setup {
403408 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
404409 pack .e
511516 .e cget -selectborderwidth
512517 } -cleanup {
513518 destroy .e
514 } -result {1}
519 } -result 1
515520 test entry-1.48 {configuration option: "selectborderwidth" for entry} -setup {
516521 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
517522 pack .e
604609 .e cget -width
605610 } -cleanup {
606611 destroy .e
607 } -result {402}
612 } -result 402
608613 test entry-1.57 {configuration option: "width" for entry} -setup {
609614 entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
610615 pack .e
661666
662667
663668 test entry-3.1 {EntryWidgetCmd procedure} -setup {
664 entry .e
669 entry .e
665670 pack .e
666671 update
667672 } -body {
670675 destroy .e
671676 } -returnCodes error -result {wrong # args: should be ".e option ?arg ...?"}
672677 test entry-3.2 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
673 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
678 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
674679 pack .e
675680 update
676681 } -body {
679684 destroy .e
680685 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
681686 test entry-3.3 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
682 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
687 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
683688 pack .e
684689 update
685690 } -body {
688693 destroy .e
689694 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
690695 test entry-3.4 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
691 entry .e
696 entry .e
692697 pack .e
693698 update
694699 } -body {
697702 destroy .e
698703 } -returnCodes error -result {bad entry index "bogus"}
699704 test entry-3.5 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
700 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
705 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
701706 pack .e
702707 update
703708 } -body {
706711 destroy .e
707712 } -result [list 5 5 0 $cy]
708713
709 # Previously the result was count using previousli counted font measurements
714 # Previously the result was count using previousli counted font measurements
710715 # and metrics. It was changed to less verbose solution - the result is the one
711716 # that passes fonts constraint (this concerns tests 3.6, 3.7, 3.8, 3.10)
712717 test entry-3.6 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
725730 test entry-3.7 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
726731 fonts
727732 } -setup {
728 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
733 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
729734 pack .e
730735 update
731736 } -body {
738743 test entry-3.8 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
739744 fonts
740745 } -setup {
741 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
746 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
742747 pack .e
743748 update
744749 } -body {
749754 destroy .e
750755 } -result {31 5 7 13}
751756 test entry-3.9 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
752 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
757 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
753758 pack .e
754759 update
755760 } -body {
761766 test entry-3.10 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
762767 fonts
763768 } -setup {
764 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
769 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
765770 pack .e
766771 update
767772 } -body {
771776 destroy .e
772777 } -result {{5 5 7 13} {12 5 7 13} {75 5 12 13} {122 5 7 13}}
773778 test entry-3.11 {EntryWidgetCmd procedure, "cget" widget command} -setup {
774 entry .e
779 entry .e
775780 } -body {
776781 .e cget
777782 } -cleanup {
778783 destroy .e
779784 } -returnCodes error -result {wrong # args: should be ".e cget option"}
780785 test entry-3.12 {EntryWidgetCmd procedure, "cget" widget command} -setup {
781 entry .e
786 entry .e
782787 } -body {
783788 .e cget a b
784789 } -cleanup {
785790 destroy .e
786791 } -returnCodes error -result {wrong # args: should be ".e cget option"}
787792 test entry-3.13 {EntryWidgetCmd procedure, "cget" widget command} -setup {
788 entry .e
793 entry .e
789794 } -body {
790795 .e cget -gorp
791796 } -cleanup {
792797 destroy .e
793798 } -returnCodes error -result {unknown option "-gorp"}
794799 test entry-3.14 {EntryWidgetCmd procedure, "cget" widget command} -setup {
795 entry .e
800 entry .e
796801 } -body {
797802 .e configure -bd 4
798803 .e cget -bd
799804 } -cleanup {
800805 destroy .e
801 } -result {4}
806 } -result 4
802807 test entry-3.15 {EntryWidgetCmd procedure, "configure" widget command} -setup {
803 entry .e
808 entry .e
804809 pack .e
805810 update
806811 } -body {
807812 llength [.e configure]
808813 } -cleanup {
809814 destroy .e
810 } -result {36}
815 } -result 36
811816 test entry-3.16 {EntryWidgetCmd procedure, "configure" widget command} -setup {
812 entry .e
817 entry .e
813818 } -body {
814819 .e configure -foo
815820 } -cleanup {
816821 destroy .e
817822 } -returnCodes error -result {unknown option "-foo"}
818823 test entry-3.17 {EntryWidgetCmd procedure, "configure" widget command} -setup {
819 entry .e
824 entry .e
820825 } -body {
821826 .e configure -bd 4
822827 .e configure -bg #ffffff
823828 lindex [.e configure -bd] 4
824829 } -cleanup {
825830 destroy .e
826 } -result {4}
831 } -result 4
827832 test entry-3.18 {EntryWidgetCmd procedure, "delete" widget command} -setup {
828 entry .e
833 entry .e
829834 } -body {
830835 .e delete
831836 } -cleanup {
832837 destroy .e
833838 } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"}
834839 test entry-3.19 {EntryWidgetCmd procedure, "delete" widget command} -setup {
835 entry .e
840 entry .e
836841 } -body {
837842 .e delete a b c
838843 } -cleanup {
839844 destroy .e
840845 } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"}
841846 test entry-3.20 {EntryWidgetCmd procedure, "delete" widget command} -setup {
842 entry .e
847 entry .e
843848 } -body {
844849 .e delete foo
845850 } -cleanup {
846851 destroy .e
847852 } -returnCodes error -result {bad entry index "foo"}
848853 test entry-3.21 {EntryWidgetCmd procedure, "delete" widget command} -setup {
849 entry .e
854 entry .e
850855 } -body {
851856 .e delete 0 bar
852857 } -cleanup {
855860 test entry-3.22 {EntryWidgetCmd procedure, "delete" widget command} -setup {
856861 entry .e
857862 pack .e
858 update
863 update
859864 } -body {
860865 .e insert end "01234567890"
861866 .e delete 2 4
862867 .e get
863868 } -cleanup {
864869 destroy .e
865 } -result {014567890}
870 } -result 014567890
866871 test entry-3.23 {EntryWidgetCmd procedure, "delete" widget command} -setup {
867 entry .e
872 entry .e
868873 } -body {
869874 .e insert end "01234567890"
870875 .e delete 6
871876 .e get
872877 } -cleanup {
873878 destroy .e
874 } -result {0123457890}
879 } -result 0123457890
875880 test entry-3.24 {EntryWidgetCmd procedure, "delete" widget command} -setup {
876881 entry .e
877882 pack .e
878 update
883 update
879884 set x {}
880885 } -body {
881886 # UTF
896901 test entry-3.25 {EntryWidgetCmd procedure, "delete" widget command} -setup {
897902 entry .e
898903 pack .e
899 update
904 update
900905 } -body {
901906 .e insert end "01234567890"
902907 .e delete 6 5
903908 .e get
904909 } -cleanup {
905910 destroy .e
906 } -result {01234567890}
911 } -result 01234567890
907912 test entry-3.26 {EntryWidgetCmd procedure, "delete" widget command} -setup {
908913 entry .e
909914 pack .e
910 update
915 update
911916 } -body {
912917 .e insert end "01234567890"
913918 .e configure -state disabled
916921 .e get
917922 } -cleanup {
918923 destroy .e
919 } -result {01234567890}
924 } -result 01234567890
920925 test entry-3.26a {EntryWidgetCmd procedure, "delete" widget command} -setup {
921926 entry .e
922927 pack .e
923 update
928 update
924929 } -body {
925930 .e insert end "01234567890"
926931 .e configure -state readonly
929934 .e get
930935 } -cleanup {
931936 destroy .e
932 } -result {01234567890}
937 } -result 01234567890
933938 test entry-3.27 {EntryWidgetCmd procedure, "get" widget command} -setup {
934 entry .e
939 entry .e
935940 } -body {
936941 .e get foo
937942 } -cleanup {
938943 destroy .e
939944 } -returnCodes error -result {wrong # args: should be ".e get"}
940945 test entry-3.28 {EntryWidgetCmd procedure, "icursor" widget command} -setup {
941 entry .e
946 entry .e
942947 } -body {
943948 .e icursor
944949 } -cleanup {
945950 destroy .e
946951 } -returnCodes error -result {wrong # args: should be ".e icursor pos"}
947952 test entry-3.29 {EntryWidgetCmd procedure, "icursor" widget command} -setup {
948 entry .e
953 entry .e
949954 } -body {
950955 .e icursor foo
951956 } -cleanup {
952957 destroy .e
953958 } -returnCodes error -result {bad entry index "foo"}
954959 test entry-3.30 {EntryWidgetCmd procedure, "icursor" widget command} -setup {
955 entry .e
960 entry .e
956961 } -body {
957962 .e insert end "01234567890"
958963 .e icursor 4
959964 .e index insert
960965 } -cleanup {
961966 destroy .e
962 } -result {4}
967 } -result 4
963968 test entry-3.31 {EntryWidgetCmd procedure, "index" widget command} -setup {
964 entry .e
969 entry .e
965970 } -body {
966971 .e in
967972 } -cleanup {
968973 destroy .e
969974 } -returnCodes error -result {ambiguous option "in": must be bbox, cget, configure, delete, get, icursor, index, insert, scan, selection, validate, or xview}
970975 test entry-3.32 {EntryWidgetCmd procedure, "index" widget command} -setup {
971 entry .e
976 entry .e
972977 } -body {
973978 .e index
974979 } -cleanup {
975980 destroy .e
976981 } -returnCodes error -result {wrong # args: should be ".e index string"}
977982 test entry-3.33 {EntryWidgetCmd procedure, "index" widget command} -setup {
978 entry .e
983 entry .e
979984 } -body {
980985 .e index foo
981986 } -cleanup {
984989 test entry-3.34 {EntryWidgetCmd procedure, "index" widget command} -setup {
985990 entry .e
986991 pack .e
987 update
992 update
988993 } -body {
989994 .e index 0
990995 } -cleanup {
993998 test entry-3.35 {EntryWidgetCmd procedure, "index" widget command} -setup {
994999 entry .e
9951000 pack .e
996 update
1001 update
9971002 } -body {
9981003 # UTF
9991004 .e insert 0 abc\u4e4e\u0153def
10021007 destroy .e
10031008 } -result {3 4 8}
10041009 test entry-3.36 {EntryWidgetCmd procedure, "insert" widget command} -setup {
1005 entry .e
1010 entry .e
10061011 } -body {
10071012 .e insert a
10081013 } -cleanup {
10091014 destroy .e
10101015 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
10111016 test entry-3.37 {EntryWidgetCmd procedure, "insert" widget command} -setup {
1012 entry .e
1017 entry .e
10131018 } -body {
10141019 .e insert a b c
10151020 } -cleanup {
10161021 destroy .e
10171022 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
10181023 test entry-3.38 {EntryWidgetCmd procedure, "insert" widget command} -setup {
1019 entry .e
1024 entry .e
10201025 } -body {
10211026 .e insert foo Text
10221027 } -cleanup {
10251030 test entry-3.39 {EntryWidgetCmd procedure, "insert" widget command} -setup {
10261031 entry .e
10271032 pack .e
1028 update
1033 update
10291034 } -body {
10301035 .e insert end "01234567890"
10311036 .e insert 3 xxx
10361041 test entry-3.40 {EntryWidgetCmd procedure, "insert" widget command} -setup {
10371042 entry .e
10381043 pack .e
1039 update
1044 update
10401045 } -body {
10411046 .e insert end "01234567890"
10421047 .e configure -state disabled
10451050 .e get
10461051 } -cleanup {
10471052 destroy .e
1048 } -result {01234567890}
1053 } -result 01234567890
10491054 test entry-3.40a {EntryWidgetCmd procedure, "insert" widget command} -setup {
10501055 entry .e
10511056 pack .e
1052 update
1057 update
10531058 } -body {
10541059 .e insert end "01234567890"
10551060 .e configure -state readonly
10581063 .e get
10591064 } -cleanup {
10601065 destroy .e
1061 } -result {01234567890}
1066 } -result 01234567890
10621067 test entry-3.41 {EntryWidgetCmd procedure, "insert" widget command} -setup {
1063 entry .e
1068 entry .e
10641069 } -body {
10651070 .e insert a b c
10661071 } -cleanup {
10671072 destroy .e
10681073 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
10691074 test entry-3.42 {EntryWidgetCmd procedure, "scan" widget command} -setup {
1070 entry .e
1075 entry .e
10711076 pack .e
10721077 update
10731078 } -body {
10781083 test entry-3.43 {EntryWidgetCmd procedure, "scan" widget command} -setup {
10791084 entry .e
10801085 pack .e
1081 update
1086 update
10821087 } -body {
10831088 .e scan a b c
10841089 } -cleanup {
10871092 test entry-3.44 {EntryWidgetCmd procedure, "scan" widget command} -setup {
10881093 entry .e
10891094 pack .e
1090 update
1095 update
10911096 } -body {
10921097 .e scan foobar 20
10931098 } -cleanup {
10961101 test entry-3.45 {EntryWidgetCmd procedure, "scan" widget command} -setup {
10971102 entry .e
10981103 pack .e
1099 update
1104 update
11001105 } -body {
11011106 .e scan mark 20.1
11021107 } -cleanup {
11071112 test entry-3.46 {EntryWidgetCmd procedure, "scan" widget command} -constraints {
11081113 fonts
11091114 } -setup {
1110 entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
1115 entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
11111116 pack .e
11121117 update
11131118 } -body {
11181123 .e index @0
11191124 } -cleanup {
11201125 destroy .e
1121 } -result {2}
1126 } -result 2
11221127 test entry-3.47 {EntryWidgetCmd procedure, "select" widget command} -setup {
1123 entry .e
1128 entry .e
11241129 } -body {
11251130 .e select
11261131 } -cleanup {
11271132 destroy .e
11281133 } -returnCodes error -result {wrong # args: should be ".e selection option ?index?"}
11291134 test entry-3.48 {EntryWidgetCmd procedure, "select" widget command} -setup {
1130 entry .e
1135 entry .e
11311136 } -body {
11321137 .e select foo
11331138 } -cleanup {
11351140 } -returnCodes error -result {bad selection option "foo": must be adjust, clear, from, present, range, or to}
11361141
11371142 test entry-3.49 {EntryWidgetCmd procedure, "select clear" widget command} -setup {
1138 entry .e
1143 entry .e
11391144 } -body {
11401145 .e select clear gorp
11411146 } -cleanup {
11421147 destroy .e
11431148 } -returnCodes error -result {wrong # args: should be ".e selection clear"}
11441149 test entry-3.50 {EntryWidgetCmd procedure, "select clear" widget command} -setup {
1145 entry .e
1150 entry .e
11461151 } -body {
11471152 .e insert end "0123456789"
11481153 .e select from 1
11491154 .e select to 4
11501155 update
11511156 .e select clear
1152 selection get
1157 selection get
11531158 } -cleanup {
11541159 destroy .e
11551160 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
11561161 test entry-3.50.1 {EntryWidgetCmd procedure, "select clear" widget command} -setup {
11571162 entry .e
11581163 pack .e
1159 update
1164 update
11601165 } -body {
11611166 .e insert end "0123456789"
11621167 .e select from 1
11701175 } -result {.e}
11711176
11721177 test entry-3.51 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
1173 entry .e
1178 entry .e
11741179 } -body {
11751180 .e selection present foo
11761181 } -cleanup {
11791184 test entry-3.52 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
11801185 entry .e
11811186 pack .e
1182 update
1187 update
11831188 } -body {
11841189 .e insert end 0123456789
11851190 .e select from 3
11871192 .e selection present
11881193 } -cleanup {
11891194 destroy .e
1190 } -result {1}
1195 } -result 1
11911196 test entry-3.53 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
11921197 entry .e
11931198 pack .e
1194 update
1199 update
11951200 } -body {
11961201 .e insert end 0123456789
11971202 .e select from 3
12001205 .e selection present
12011206 } -cleanup {
12021207 destroy .e
1203 } -result {1}
1208 } -result 1
12041209 test entry-3.54 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
12051210 entry .e
12061211 pack .e
1207 update
1212 update
12081213 } -body {
12091214 .e insert end 0123456789
12101215 .e select from 3
12131218 .e selection present
12141219 } -cleanup {
12151220 destroy .e
1216 } -result {0}
1221 } -result 0
12171222 test entry-3.55 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup {
12181223 entry .e
12191224 } -body {
12411246 selection get
12421247 } -cleanup {
12431248 destroy .e
1244 } -result {123}
1249 } -result 123
12451250 test entry-3.58 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup {
12461251 entry .e
12471252 pack .e
12551260 selection get
12561261 } -cleanup {
12571262 destroy .e
1258 } -result {234}
1263 } -result 234
12591264 test entry-3.59 {EntryWidgetCmd procedure, "selection from" widget command} -setup {
12601265 entry .e
12611266 } -body {
13431348 } -returnCodes error -result {wrong # args: should be ".e selection to index"}
13441349
13451350 test entry-3.65 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1346 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1351 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
13471352 pack .e
13481353 update
13491354 } -body {
13551360 destroy .e
13561361 } -result {0.0537634 0.2688172}
13571362 test entry-3.66 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1358 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1363 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
13591364 pack .e
13601365 update
13611366 } -body {
13641369 destroy .e
13651370 } -returnCodes error -result {bad entry index "gorp"}
13661371 test entry-3.67 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1367 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1372 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
13681373 pack .e
13691374 update
13701375 } -body {
13781383 destroy .e
13791384 } -result {0.107527 0.322581}
13801385 test entry-3.68 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1381 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1386 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
13821387 pack .e
13831388 update
13841389 } -body {
13871392 destroy .e
13881393 } -returnCodes error -result {wrong # args: should be ".e xview moveto fraction"}
13891394 test entry-3.69 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1390 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1395 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
13911396 pack .e
13921397 update
13931398 } -body {
13961401 destroy .e
13971402 } -returnCodes error -result {expected floating-point number but got "foo"}
13981403 test entry-3.70 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1399 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1404 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14001405 pack .e
14011406 update
14021407 } -body {
14081413 destroy .e
14091414 } -result {0.505376 0.720430}
14101415 test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1411 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1416 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14121417 pack .e
14131418 update
14141419 } -body {
14191424 destroy .e
14201425 } -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"}
14211426 test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1422 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1427 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14231428 pack .e
14241429 } -body {
14251430 .e insert end "This is quite a long text string, so long that it "
14301435 destroy .e
14311436 } -returnCodes error -result {expected integer but got "gorp"}
14321437 test entry-3.73 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1433 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1438 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14341439 pack .e
14351440 } -body {
14361441 .e insert end "This is quite a long text string, so long that it "
14431448 destroy .e
14441449 } -result {0.193548 0.408602}
14451450 test entry-3.74 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1446 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1451 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14471452 pack .e
14481453 update
14491454 } -body {
14571462 destroy .e
14581463 } -result {0.397849 0.612903}
14591464 test entry-3.75 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1460 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1465 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14611466 pack .e
14621467 } -body {
14631468 .e insert end "This is quite a long text string, so long that it "
14651470 update
14661471 .e xview 30
14671472 update
1468 .e xview scroll 2 units
1473 .e xview scroll 2 units
14691474 .e index @0
14701475 } -cleanup {
14711476 destroy .e
1472 } -result {32}
1477 } -result 32
14731478 test entry-3.76 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1474 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1479 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14751480 pack .e
14761481 } -body {
14771482 .e insert end "This is quite a long text string, so long that it "
14791484 update
14801485 .e xview 30
14811486 update
1482 .e xview scroll -1 units
1487 .e xview scroll -1 units
14831488 .e index @0
14841489 } -cleanup {
14851490 destroy .e
1486 } -result {29}
1491 } -result 29
14871492 test entry-3.77 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1488 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1493 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
14891494 pack .e
14901495 } -body {
14911496 .e insert end "This is quite a long text string, so long that it "
14961501 destroy .e
14971502 } -returnCodes error -result {bad argument "foobars": must be units or pages}
14981503 test entry-3.78 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1499 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1504 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
15001505 pack .e
15011506 } -body {
15021507 .e insert end "This is quite a long text string, so long that it "
15071512 destroy .e
15081513 } -returnCodes error -result {unknown option "eat": must be moveto or scroll}
15091514 test entry-3.79 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1510 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1515 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
15111516 pack .e
15121517 update
15131518 } -body {
15151520 .e insert end "runs off the end of the window quite a bit."
15161521 .e xview 0
15171522 update
1518 .e xview -4
1523 .e xview -1
15191524 .e index @0
15201525 } -cleanup {
15211526 destroy .e
1522 } -result {0}
1527 } -result 0
15231528 test entry-3.80 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1524 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1529 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
15251530 pack .e
15261531 } -body {
15271532 .e insert end "This is quite a long text string, so long that it "
15311536 .e index @0
15321537 } -cleanup {
15331538 destroy .e
1534 } -result {73}
1539 } -result 73
15351540 test entry-3.86 {EntryWidgetCmd procedure, "xview" widget command} -setup {
1536 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1541 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
15371542 pack .e
15381543 } -body {
15391544 .e insert end "This is quite a long text string, so long that it "
15551560 } -result {0.095745 0.106383 0.117021}
15561561
15571562 test entry-3.82 {EntryWidgetCmd procedure} -setup {
1558 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1563 entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
15591564 pack .e
15601565 update
15611566 } -body {
15821587 .e get
15831588 } -cleanup {
15841589 destroy .e
1585 } -result {12345}
1590 } -result 12345
15861591 test entry-5.2 {ConfigureEntry procedure, -textvariable} -body {
15871592 set x 12345
15881593 entry .e -textvariable x
15991604 } -body {
16001605 .e insert 0 "Some text"
16011606 .e configure -textvariable x
1602 return $x
1607 set x
16031608 } -cleanup {
16041609 destroy .e
16051610 } -result {Some text}
16141619 } -cleanup {
16151620 destroy .e
16161621 trace vdelete x w override
1617 unset x;
1622 unset x;
16181623 } -result {12345 12345}
16191624
16201625 test entry-5.5 {ConfigureEntry procedure} -setup {
16341639 lappend x [selection get]
16351640 .e1 configure -exportselection 1
16361641 lappend x [selection get]
1637 return $x
1642 set x
16381643 } -cleanup {
16391644 destroy .e1 .e2
16401645 } -result {{This is so} {This is so} 1234}
16411646 test entry-5.6 {ConfigureEntry procedure} -setup {
1642 entry .e
1647 entry .e
16431648 pack .e
16441649 } -body {
16451650 .e insert end "0123456789"
16461651 .e select from 1
16471652 .e select to 5
16481653 .e configure -exportselection 0
1649 selection get
1654 selection get
16501655 } -cleanup {
16511656 destroy .e
16521657 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
16581663 .e select from 1
16591664 .e select to 5
16601665 .e configure -exportselection 0
1661 catch {selection get}
1666 catch {selection get}
16621667 list [.e index sel.first] [.e index sel.last]
16631668 } -cleanup {
16641669 destroy .e
16651670 } -result {1 5}
16661671
16671672 test entry-5.7 {ConfigureEntry procedure} -setup {
1668 entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
1673 entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
16691674 pack .e
16701675 } -body {
16711676 .e configure -font {Courier -12} -width 4 -xscrollcommand scroll
16721677 .e insert end "01234567890"
1673 set timeout [after 500 {set $scrollInfo "timeout"}]
1678 update idletasks
1679 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
1680 .e configure -width 5
16741681 vwait scrollInfo
1675 .e configure -width 5
16761682 format {%.6f %.6f} {*}$scrollInfo
16771683 } -cleanup {
16781684 destroy .e
16811687
16821688
16831689 test entry-5.8 {ConfigureEntry procedure} -constraints {
1684 fonts
1690 fonts failsOnXQuarz
16851691 } -setup {
1686 entry .e -borderwidth 2 -highlightthickness 2
1692 entry .e -borderwidth 2 -highlightthickness 2
16871693 pack .e
16881694 } -body {
16891695 .e configure -width 0 -font {Helvetica -12}
17381744 test entry-6.1 {EntryComputeGeometry procedure} -constraints {
17391745 fonts
17401746 } -setup {
1741 entry .e
1747 entry .e
17421748 pack .e
17431749 } -body {
17441750 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
17521758 test entry-6.2 {EntryComputeGeometry procedure} -constraints {
17531759 fonts
17541760 } -setup {
1755 entry .e
1761 entry .e
17561762 pack .e
17571763 } -body {
17581764 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
17661772 test entry-6.3 {EntryComputeGeometry procedure} -constraints {
17671773 fonts
17681774 } -setup {
1769 entry .e
1775 entry .e
17701776 pack .e
17711777 } -body {
17721778 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
17781784 destroy .e
17791785 } -result {3 4}
17801786 test entry-6.4 {EntryComputeGeometry procedure} -setup {
1781 entry .e
1787 entry .e
17821788 pack .e
17831789 } -body {
17841790 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
17881794 .e index @0
17891795 } -cleanup {
17901796 destroy .e
1791 } -result {6}
1797 } -result 6
17921798 test entry-6.5 {EntryComputeGeometry procedure} -setup {
17931799 entry .e -highlightthickness 2
17941800 pack .e
17951801 } -body {
1796 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
1802 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
17971803 .e insert end "01234567890"
17981804 update
17991805 .e xview 7
18001806 .e index @0
18011807 } -cleanup {
18021808 destroy .e
1803 } -result {6}
1809 } -result 6
18041810 test entry-6.6 {EntryComputeGeometry procedure} -constraints {
18051811 fonts
18061812 } -setup {
18071813 entry .e -highlightthickness 2
18081814 pack .e
18091815 } -body {
1810 .e configure -font {Courier -12} -bd 2 -relief raised -width 10
1816 .e configure -font {Courier -12} -bd 2 -relief raised -width 10
18111817 .e insert end "01234\t67890"
18121818 update
18131819 .e xview 3
18471853 entry .e -highlightthickness 2
18481854 pack .e
18491855 } -body {
1850 .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
1856 .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
18511857 update
18521858 list [winfo reqwidth .e] [winfo reqheight .e]
18531859 } -cleanup {
18541860 destroy .e
18551861 } -result {25 39}
18561862 test entry-6.10 {EntryComputeGeometry procedure} -constraints {
1857 unix fonts
1863 unix fonts
18581864 } -setup {
18591865 entry .e -highlightthickness 2 -font {Helvetica -12}
18601866 pack .e
19091915
19101916
19111917 test entry-7.1 {InsertChars procedure} -setup {
1912 unset -nocomplain contents
1918 unset -nocomplain contents
19131919 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
19141920 pack .e
19151921 focus .e
19161922 } -body {
19171923 .e configure -textvariable contents -xscrollcommand scroll
1924 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
19181925 .e insert 0 abcde
19191926 .e insert 2 XXX
1920 set timeout [after 500 {set $scrollInfo "timeout"}]
19211927 vwait scrollInfo
19221928 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
19231929 } -cleanup {
19261932 } -result {abXXXcde abXXXcde {0.000000 1.000000}}
19271933
19281934 test entry-7.2 {InsertChars procedure} -setup {
1929 unset -nocomplain contents
1930 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
1935 unset -nocomplain contents
1936 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
19311937 pack .e
19321938 focus .e
19331939 } -body {
19341940 .e configure -textvariable contents -xscrollcommand scroll
1941 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
19351942 .e insert 0 abcde
19361943 .e insert 500 XXX
1937 set timeout [after 500 {set $scrollInfo "timeout"}]
19381944 vwait scrollInfo
19391945 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
19401946 } -cleanup {
19982004 destroy .e
19992005 } -result {2 6 2 5}
20002006 test entry-7.7 {InsertChars procedure} -setup {
2001 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2007 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20022008 pack .e
20032009 } -body {
20042010 .e configure -xscrollcommand scroll
20082014 .e index insert
20092015 } -cleanup {
20102016 destroy .e
2011 } -result {7}
2017 } -result 7
20122018 test entry-7.8 {InsertChars procedure} -setup {
2013 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2019 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20142020 pack .e
20152021 } -body {
20162022 .e insert 0 0123456789
20192025 .e index insert
20202026 } -cleanup {
20212027 destroy .e
2022 } -result {4}
2028 } -result 4
20232029 test entry-7.9 {InsertChars procedure} -setup {
2024 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2030 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20252031 pack .e
20262032 } -body {
20272033 .e insert 0 "This is a very long string"
20312037 .e index @0
20322038 } -cleanup {
20332039 destroy .e
2034 } -result {7}
2040 } -result 7
20352041 test entry-7.10 {InsertChars procedure} -setup {
2036 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2042 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20372043 pack .e
20382044 } -body {
20392045 .e insert 0 "This is a very long string"
20432049 .e index @0
20442050 } -cleanup {
20452051 destroy .e
2046 } -result {4}
2052 } -result 4
20472053
20482054 test entry-7.11 {InsertChars procedure} -constraints {
20492055 fonts
20502056 } -setup {
2051 entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
2057 entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
20522058 pack .e
20532059 } -body {
20542060 .e insert 0 "xyzzy"
20572063 winfo reqwidth .e
20582064 } -cleanup {
20592065 destroy .e
2060 } -result {59}
2066 } -result 59
20612067
20622068 test entry-8.1 {DeleteChars procedure} -setup {
20632069 unset -nocomplain contents
2064 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2070 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20652071 pack .e
20662072 focus .e
20672073 } -body {
20682074 .e configure -textvariable contents -xscrollcommand scroll
2075 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
20692076 .e insert 0 abcde
20702077 .e delete 2 4
2071 set timeout [after 500 {set $scrollInfo "timeout"}]
20722078 vwait scrollInfo
20732079 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
20742080 } -cleanup {
20772083 } -result {abe abe {0.000000 1.000000}}
20782084 test entry-8.2 {DeleteChars procedure} -setup {
20792085 unset -nocomplain contents
2080 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2086 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20812087 pack .e
20822088 focus .e
20832089 } -body {
20842090 .e configure -textvariable contents -xscrollcommand scroll
2091 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
20852092 .e insert 0 abcde
2086 .e delete -2 2
2087 set timeout [after 500 {set $scrollInfo "timeout"}]
2093 .e delete -1 2
20882094 vwait scrollInfo
20892095 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
20902096 } -cleanup {
20932099 } -result {cde cde {0.000000 1.000000}}
20942100 test entry-8.3 {DeleteChars procedure} -setup {
20952101 unset -nocomplain contents
2096 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2102 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
20972103 pack .e
20982104 focus .e
20992105 } -body {
21002106 .e configure -textvariable contents -xscrollcommand scroll
2107 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
21012108 .e insert 0 abcde
21022109 .e delete 3 1000
2103 set timeout [after 500 {set $scrollInfo "timeout"}]
21042110 vwait scrollInfo
21052111 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
21062112 } -cleanup {
21082114 after cancel $timeout
21092115 } -result {abc abc {0.000000 1.000000}}
21102116 test entry-8.4 {DeleteChars procedure} -setup {
2111 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2117 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21122118 pack .e
21132119 focus .e
21142120 } -body {
21242130 destroy .e
21252131 } -result {1 6 1 5}
21262132 test entry-8.5 {DeleteChars procedure} -setup {
2127 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2133 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21282134 pack .e
21292135 focus .e
21302136 } -body {
21402146 destroy .e
21412147 } -result {1 5 1 4}
21422148 test entry-8.6 {DeleteChars procedure} -setup {
2143 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2149 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21442150 pack .e
21452151 focus .e
21462152 } -body {
21562162 destroy .e
21572163 } -result {1 2 1 5}
21582164 test entry-8.7 {DeleteChars procedure} -setup {
2159 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2165 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21602166 pack .e
21612167 focus .e
21622168 } -body {
21702176 destroy .e
21712177 } -returnCodes error -result {selection isn't in widget .e}
21722178 test entry-8.8 {DeleteChars procedure} -setup {
2173 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2179 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21742180 pack .e
21752181 focus .e
21762182 } -body {
21862192 destroy .e
21872193 } -result {3 4 3 8}
21882194 test entry-8.9 {DeleteChars procedure} -setup {
2189 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2195 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
21902196 pack .e
21912197 } -body {
21922198 .e insert 0 0123456789abcde
21992205 destroy .e
22002206 } -returnCodes error -result {selection isn't in widget .e}
22012207 test entry-8.10 {DeleteChars procedure} -setup {
2202 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2208 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22032209 pack .e
22042210 focus .e
22052211 } -body {
22152221 destroy .e
22162222 } -result {3 5 5 8}
22172223 test entry-8.11 {DeleteChars procedure} -setup {
2218 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2224 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22192225 pack .e
22202226 focus .e
22212227 } -body {
22312237 destroy .e
22322238 } -result {3 8 4 8}
22332239 test entry-8.12 {DeleteChars procedure} -setup {
2234 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2240 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22352241 pack .e
22362242 focus .e
22372243 } -body {
22422248 .e index insert
22432249 } -cleanup {
22442250 destroy .e
2245 } -result {1}
2251 } -result 1
22462252 test entry-8.13 {DeleteChars procedure} -setup {
2247 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2253 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22482254 pack .e
22492255 focus .e
22502256 } -body {
22552261 .e index insert
22562262 } -cleanup {
22572263 destroy .e
2258 } -result {1}
2264 } -result 1
22592265 test entry-8.14 {DeleteChars procedure} -setup {
2260 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2266 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22612267 pack .e
22622268 focus .e
22632269 } -body {
22682274 .e index insert
22692275 } -cleanup {
22702276 destroy .e
2271 } -result {4}
2277 } -result 4
22722278 test entry-8.15 {DeleteChars procedure} -setup {
2273 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2279 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22742280 pack .e
22752281 focus .e
22762282 } -body {
22812287 .e index @0
22822288 } -cleanup {
22832289 destroy .e
2284 } -result {1}
2290 } -result 1
22852291 test entry-8.16 {DeleteChars procedure} -setup {
2286 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2292 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22872293 pack .e
22882294 focus .e
22892295 } -body {
22942300 .e index @0
22952301 } -cleanup {
22962302 destroy .e
2297 } -result {1}
2303 } -result 1
22982304 test entry-8.17 {DeleteChars procedure} -setup {
2299 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2305 entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23002306 pack .e
23012307 focus .e
23022308 } -body {
23072313 .e index @0
23082314 } -cleanup {
23092315 destroy .e
2310 } -result {4}
2311 test entry-8.18 {DeleteChars procedure} -setup {
2312 entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
2316 } -result 4
2317 test entry-8.18 {DeleteChars procedure} -constraints failsOnUbuntuNoXft -setup {
2318 entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
23132319 pack .e
23142320 focus .e
23152321 } -body {
23192325 winfo reqwidth .e
23202326 } -cleanup {
23212327 destroy .e
2322 } -result {31}
2328 } -result 31
23232329
23242330 test entry-9.1 {EntryValueChanged procedure} -setup {
23252331 unset -nocomplain x
23402346 set y ab
23412347 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2 -width 0
23422348 pack .e
2343 .e configure -textvariable x
2349 .e configure -textvariable x
23442350 .e configure -textvariable y
23452351 update
23462352 list [.e get] [winfo reqwidth .e]
23492355 } -result {ab 24}
23502356 test entry-10.2 {EntrySetValue procedure, updating selection} -setup {
23512357 unset -nocomplain x
2352 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2358 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
23532359 pack .e
23542360 } -body {
23552361 .e configure -textvariable x
23622368 } -returnCodes error -result {selection isn't in widget .e}
23632369 test entry-10.3 {EntrySetValue procedure, updating selection} -setup {
23642370 unset -nocomplain x
2365 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2371 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
23662372 pack .e
23672373 } -body {
23682374 .e configure -textvariable x
23752381 } -result {4 7}
23762382 test entry-10.4 {EntrySetValue procedure, updating selection} -setup {
23772383 unset -nocomplain x
2378 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2384 entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
23792385 pack .e
23802386 } -body {
23812387 .e configure -textvariable x
23882394 } -result {4 10}
23892395 test entry-10.5 {EntrySetValue procedure, updating display position} -setup {
23902396 unset -nocomplain x
2391 entry .e -highlightthickness 2 -bd 2
2397 entry .e -highlightthickness 2 -bd 2
23922398 pack .e
23932399 } -body {
23942400 .e configure -width 10 -font {Courier -12} -textvariable x
24002406 .e index @0
24012407 } -cleanup {
24022408 destroy .e
2403 } -result {0}
2409 } -result 0
24042410 test entry-10.6 {EntrySetValue procedure, updating display position} -setup {
24052411 unset -nocomplain x
2406 entry .e -highlightthickness 2 -bd 2
2412 entry .e -highlightthickness 2 -bd 2
24072413 pack .e
24082414 } -body {
24092415 .e configure -width 10 -font {Courier -12} -textvariable x
24162422 .e index @0
24172423 } -cleanup {
24182424 destroy .e
2419 } -result {10}
2425 } -result 10
24202426 test entry-10.7 {EntrySetValue procedure, updating insertion cursor} -setup {
24212427 unset -nocomplain x
2422 entry .e -highlightthickness 2 -bd 2
2428 entry .e -highlightthickness 2 -bd 2
24232429 pack .e
24242430 update
24252431 } -body {
24312437 .e index insert
24322438 } -cleanup {
24332439 destroy .e
2434 } -result {3}
2440 } -result 3
24352441 test entry-10.8 {EntrySetValue procedure, updating insertion cursor} -setup {
24362442 unset -nocomplain x
2437 entry .e -highlightthickness 2 -bd 2
2443 entry .e -highlightthickness 2 -bd 2
24382444 pack .e
24392445 } -body {
24402446 .e configure -width 10 -font {Courier -12} -textvariable x
24452451 .e index insert
24462452 } -cleanup {
24472453 destroy .e
2448 } -result {5}
2454 } -result 5
24492455
24502456 test entry-11.1 {EntryEventProc procedure} -setup {
24512457 entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12}
24892495 .e index end
24902496 } -cleanup {
24912497 destroy .e
2492 } -result {21}
2498 } -result 21
24932499 test entry-13.2 {GetEntryIndex procedure} -body {
2494 entry .e
2500 entry .e
24952501 .e index abogus
24962502 } -cleanup {
24972503 destroy .e
25082514 .e index anchor
25092515 } -cleanup {
25102516 destroy .e
2511 } -result {1}
2517 } -result 1
25122518 test entry-13.4 {GetEntryIndex procedure} -setup {
25132519 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
25142520 pack .e
25212527 .e index anchor
25222528 } -cleanup {
25232529 destroy .e
2524 } -result {4}
2530 } -result 4
25252531 test entry-13.5 {GetEntryIndex procedure} -setup {
25262532 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
25272533 pack .e
25352541 .e index anchor
25362542 } -cleanup {
25372543 destroy .e
2538 } -result {15}
2544 } -result 15
25392545 test entry-13.6 {GetEntryIndex procedure} -setup {
25402546 entry .e
25412547 } -body {
25542560 .e index insert
25552561 } -cleanup {
25562562 destroy .e
2557 } -result {2}
2563 } -result 2
25582564 test entry-13.8 {GetEntryIndex procedure} -setup {
25592565 entry .e
25602566 } -body {
25822588
25832589
25842590 test entry-13.10 {GetEntryIndex procedure} -constraints x11 -body {
2585 # On unix, when selection is cleared, entry widget's internal
2591 # On unix, when selection is cleared, entry widget's internal
25862592 # selection range is reset.
25872593 # Previous settings:
25882594 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
26022608
26032609 test entry-13.11 {GetEntryIndex procedure} -constraints aquaOrWin32 -body {
26042610 # On mac and pc, when selection is cleared, entry widget remembers
2605 # last selected range. When selection ownership is restored to
2611 # last selected range. When selection ownership is restored to
26062612 # entry, the old range will be rehighlighted.
26072613 # Previous settings:
26082614 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
26192625 .e index sel.first
26202626 } -cleanup {
26212627 destroy .e
2622 } -result {1}
2628 } -result 1
26232629
26242630 test entry-13.12 {GetEntryIndex procedure} -constraints x11 -body {
26252631 # Previous settings:
26382644 destroy .e
26392645 } -returnCodes error -result {selection isn't in widget .e}
26402646
2641 # why when string in .e index changed to not beginning with s,
2647 # why when string in .e index changed to not beginning with s,
26422648 # it behaves differently?
26432649 test entry-13.12.1 {GetEntryIndex procedure} -constraints unix -body {
26442650 # Previous settings:
26762682
26772683 test entry-13.14 {GetEntryIndex procedure} -constraints win -body {
26782684 # On mac and pc, when selection is cleared, entry widget remembers
2679 # last selected range. When selection ownership is restored to
2685 # last selected range. When selection ownership is restored to
26802686 # entry, the old range will be rehighlighted.
26812687 # Previous settings:
26822688 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
26892695 list [.e index sel.first] [.e index sel.last]
26902696 # Testing:
26912697 selection clear .e
2692 selection get
2698 selection get
26932699 } -cleanup {
26942700 destroy .e
26952701 } -returnCodes error -match glob -result {*}
26962702
26972703 test entry-13.14.1 {GetEntryIndex procedure} -constraints win -body {
26982704 # On mac and pc, when selection is cleared, entry widget remembers
2699 # last selected range. When selection ownership is restored to
2705 # last selected range. When selection ownership is restored to
27002706 # entry, the old range will be rehighlighted.
27012707 # Previous settings:
27022708 entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
27082714 .e select to 6
27092715 list [.e index sel.first] [.e index sel.last]
27102716 # Testing:
2711 selection clear .e
2712 catch {selection get}
2713 .e index sbogus
2717 selection clear .e
2718 catch {selection get}
2719 .e index sbogus
27142720 } -cleanup {
27152721 destroy .e
27162722 } -returnCodes error -match glob -result {*}
27252731
27262732 test entry-13.16 {GetEntryIndex procedure} -constraints fonts -body {
27272733 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
2728 -font {Courier -12}
2734 -font {Courier -12}
27292735 pack .e
27302736 .e insert 0 012345678901234567890
27312737 .e xview 4
27332739 .e index @4
27342740 } -cleanup {
27352741 destroy .e
2736 } -result {4}
2742 } -result 4
27372743 test entry-13.17 {GetEntryIndex procedure} -constraints fonts -body {
27382744 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
27392745 -font {Courier -12}
27442750 .e index @11
27452751 } -cleanup {
27462752 destroy .e
2747 } -result {4}
2753 } -result 4
27482754 test entry-13.18 {GetEntryIndex procedure} -constraints fonts -body {
27492755 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
27502756 -font {Courier -12}
27552761 .e index @12
27562762 } -cleanup {
27572763 destroy .e
2758 } -result {5}
2764 } -result 5
27592765 test entry-13.19 {GetEntryIndex procedure} -constraints fonts -body {
27602766 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
2761 -font {Courier -12}
2767 -font {Courier -12}
27622768 pack .e
27632769 .e insert 0 012345678901234567890
27642770 .e xview 4
27662772 .e index @[expr {[winfo width .e] - 6}]
27672773 } -cleanup {
27682774 destroy .e
2769 } -result {8}
2775 } -result 8
27702776 test entry-13.20 {GetEntryIndex procedure} -constraints fonts -body {
27712777 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
27722778 -font {Courier -12}
27772783 .e index @[expr {[winfo width .e] - 5}]
27782784 } -cleanup {
27792785 destroy .e
2780 } -result {9}
2786 } -result 9
27812787 test entry-13.21 {GetEntryIndex procedure} -body {
27822788 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
27832789 -font {Courier -12}
27882794 .e index @1000
27892795 } -cleanup {
27902796 destroy .e
2791 } -result {9}
2797 } -result 9
27922798 test entry-13.22 {GetEntryIndex procedure} -setup {
2793 entry .e
2799 entry .e
27942800 pack .e
27952801 update
27962802 } -body {
28002806 } -returnCodes error -result {bad entry index "1xyz"}
28012807 test entry-13.23 {GetEntryIndex procedure} -body {
28022808 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
2803 -font {Courier -12}
2809 -font {Courier -12}
28042810 pack .e
28052811 .e insert 0 012345678901234567890
28062812 .e xview 4
28072813 update
2808 .e index -10
2809 } -cleanup {
2810 destroy .e
2811 } -result {0}
2814 .e index -1
2815 } -cleanup {
2816 destroy .e
2817 } -result 0
28122818 test entry-13.24 {GetEntryIndex procedure} -body {
28132819 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
2814 -font {Courier -12}
2820 -font {Courier -12}
28152821 pack .e
28162822 .e insert 0 012345678901234567890
28172823 .e xview 4
28192825 .e index 12
28202826 } -cleanup {
28212827 destroy .e
2822 } -result {12}
2828 } -result 12
28232829 test entry-13.25 {GetEntryIndex procedure} -body {
28242830 entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
2825 -font {Courier -12}
2831 -font {Courier -12}
28262832 pack .e
28272833 .e insert 0 012345678901234567890
28282834 .e xview 4
28302836 .e index 49
28312837 } -cleanup {
28322838 destroy .e
2833 } -result {21}
2839 } -result 21
28342840 test entry-13.26 {GetEntryIndex procedure} -constraints fonts -body {
28352841 entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12}
28362842 selection clear .e
28712877 }
28722878 } -body {
28732879 entry .e
2874 .e insert end $x
2880 .e insert end $x
28752881 .e select from 0
28762882 .e select to end
28772883 string compare [selection get] $x
28782884 } -cleanup {
28792885 destroy .e
2880 } -result {0}
2886 } -result 0
28812887
28822888 test entry-15.1 {EntryLostSelection} -body {
28832889 entry .e
28982904 entry .e -width 10 -font {Helvetica -12}
28992905 pack .e
29002906 update
2901 .e insert 0 "............................."
2907 .e insert 0 "............................."
29022908 format {%.6f %.6f} {*}[.e xview]
29032909 } -cleanup {
29042910 destroy .e
29362942 test entry-17.1 {EntryUpdateScrollbar procedure} -body {
29372943 entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
29382944 pack .e
2945 update idletasks
2946 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
29392947 .e delete 0 end
29402948 .e insert 0 123
2941 set timeout [after 500 {set $scrollInfo "timeout"}]
29422949 vwait scrollInfo
29432950 format {%.6f %.6f} {*}$scrollInfo
29442951 } -cleanup {
29482955 test entry-17.2 {EntryUpdateScrollbar procedure} -body {
29492956 entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
29502957 pack .e
2958 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
29512959 .e insert 0 0123456789abcdef
29522960 .e xview 3
2953 set timeout [after 500 {set $scrollInfo "timeout"}]
29542961 vwait scrollInfo
29552962 format {%.6f %.6f} {*}$scrollInfo
29562963 } -cleanup {
29602967 test entry-17.3 {EntryUpdateScrollbar procedure} -body {
29612968 entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
29622969 pack .e
2970 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
29632971 .e insert 0 abcdefghijklmnopqrs
29642972 .e xview 6
2965 set timeout [after 500 {set $scrollInfo "timeout"}]
29662973 vwait scrollInfo
29672974 format {%.6f %.6f} {*}$scrollInfo
29682975 } -cleanup {
29752982 set x $msg
29762983 }
29772984 } -body {
2978 entry .e -width 5 -xscrollcommand thisisnotacommand
2979 pack .e
2985 entry .e -width 5
2986 pack .e
2987 update idletasks
2988 .e configure -xscrollcommand thisisnotacommand
29802989 vwait x
29812990 list $x $errorInfo
29822991 } -cleanup {
29973006 set res1 [list [winfo children .] [interp hidden]]
29983007 set res2 [list {} $l]
29993008 expr {$res1 == $res2}
3000 } -result {1}
3009 } -result 1
30013010
30023011 ##
30033012 ## Entry widget VALIDATION tests
30193028 -background red -foreground white
30203029 pack .e
30213030 .e insert 0 a
3022 return $::vVals
3031 set ::vVals
30233032 } -cleanup {
30243033 destroy .e
30253034 } -result {.e 1 0 a {} a all key}
30513060 pack .e
30523061 .e insert 0 ab ;# previous settings
30533062 .e insert end c
3054 return $::vVals
3063 set ::vVals
30553064 } -cleanup {
30563065 destroy .e
30573066 } -result {.e 1 2 abc ab c all key}
30833092 pack .e
30843093 .e insert 0 a123bc ;# previous settings
30853094 .e delete 2
3086 return $::vVals
3095 set ::vVals
30873096 } -cleanup {
30883097 destroy .e
30893098 } -result {.e 0 2 a13bc a123bc 2 all key}
31003109 .e insert 0 a13bc ;# previous settings
31013110 .e configure -validate key
31023111 .e delete 1 3
3103 return $::vVals
3112 set ::vVals
31043113 } -cleanup {
31053114 destroy .e
31063115 } -result {.e 0 1 abc a13bc 13 key key}
31173126 .e insert end abc ;# previous settings
31183127 set ::vVals {}
31193128 .e insert end d
3120 return $::vVals
3129 set ::vVals
31213130 } -cleanup {
31223131 destroy .e
31233132 } -result {}
31363145 focus -force .e
31373146 # update necessary to process FocusIn event
31383147 update
3139 return $::vVals
3148 set ::vVals
31403149 } -cleanup {
31413150 destroy .e
31423151 } -result {.e -1 -1 abcd abcd {} focus focusin}
31573166 focus -force .
31583167 # update necessary to process FocusOut event
31593168 update
3160 return $::vVals
3169 set ::vVals
31613170 } -cleanup {
31623171 destroy .e
31633172 } -result {.e -1 -1 abcd abcd {} focus focusout}
31753184 focus -force .e
31763185 # update necessary to process FocusIn event
31773186 update
3178 return $::vVals
3187 set ::vVals
31793188 } -cleanup {
31803189 destroy .e
31813190 } -result {.e -1 -1 abcd abcd {} all focusin}
31963205 focus -force .
31973206 # update necessary to process FocusOut event
31983207 update
3199 return $::vVals
3208 set ::vVals
32003209 } -cleanup {
32013210 destroy .e
32023211 } -result {.e -1 -1 abcd abcd {} all focusout}
32143223 focus -force .e
32153224 # update necessary to process FocusIn event
32163225 update
3217 return $::vVals
3226 set ::vVals
32183227 } -cleanup {
32193228 destroy .e
32203229 } -result {.e -1 -1 abcd abcd {} focusin focusin}
32333242 focus -force .
32343243 # update necessary to process FocusOut event
32353244 update
3236 return $::vVals
3245 set ::vVals
32373246 } -cleanup {
32383247 destroy .e
32393248 } -result {}
32523261 focus -force .e
32533262 # update necessary to process FocusIn event
32543263 update
3255 return $::vVals
3264 set ::vVals
32563265 } -cleanup {
32573266 destroy .e
32583267 } -result {}
32743283 focus -force .
32753284 # update necessary to process FocusOut event
32763285 update
3277 return $::vVals
3286 set ::vVals
32783287 } -cleanup {
32793288 destroy .e
32803289 } -result {.e -1 -1 abcd abcd {} focusout focusout}
33513360 -background red -foreground white
33523361 pack .e
33533362 set ::e nextdata ;# previous settings
3354
3363
33553364 .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V]
33563365 .e validate
33573366 list [.e cget -validate] [.e get] $::vVals
33583367 } -cleanup {
33593368 destroy .e
3360 } -result {none mydata {.e -1 -1 nextdata nextdata {} all forced}}
3369 } -result {none nextdata {.e -1 -1 nextdata nextdata {} all forced}}
33613370
33623371 ## This leaves validate alone because we trigger validation through the
33633372 ## textvar (a write trace), and the write during validation triggers
33763385 set ::e nextdata ;# previous settings
33773386 .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V] ;# prev
33783387 .e validate ;# previous settings
3379
3388
33803389 .e configure -validate all
33813390 set ::e testdata
33823391 list [.e cget -validate] [.e get] $::e $::vVals
33833392 } -cleanup {
33843393 destroy .e
33853394 } -result {all testdata mydata {.e -1 -1 testdata mydata {} all forced}}
3395
3396 ## This leaves validate alone because we trigger validation through the
3397 ## textvar (a write trace), and the write during validation triggers
3398 ## nothing (by definition of avoiding loops on var traces). This is
3399 ## one of those "dangerous" conditions where the user will have a
3400 ## different value in the entry widget shown as is in the textvar.
3401 test entry-19.21 {entry widget validation - bug 40e4bf6198} -setup {
3402 unset -nocomplain ::e ::vVals
3403 } -body {
3404 entry .e -validate key \
3405 -validatecommand [list doval2 %W %d %i %P %s %S %v %V] \
3406 -textvariable ::e
3407 pack .e
3408 set ::e origdata
3409 .e insert 0 A
3410 list [.e cget -validate] [.e get] $::e $::vVals
3411 } -cleanup {
3412 destroy .e
3413 } -result {none origdata mydata {.e 1 0 Aorigdata origdata A key key}}
3414
33863415 ##
33873416 ## End validation tests
33883417 ##
33963425 winfo exists .e
33973426 } -cleanup {
33983427 destroy .e
3399 } -result {0}
3428 } -result 0
34003429
34013430 test entry-20.2 {widget deletion while active} -body {
34023431 entry .e -validate all \
34063435 winfo exists .e
34073436 } -cleanup {
34083437 destroy .e
3409 } -result {0}
3438 } -result 0
34103439
34113440 test entry-20.3 {widget deletion while active} -body {
34123441 entry .e -validate all \
34153444 winfo exists .e
34163445 } -cleanup {
34173446 destroy .e
3418 } -result {0}
3447 } -result 0
34193448
34203449 test entry-20.4 {widget deletion while active} -body {
34213450 entry .e -validate all \
34253454 winfo exists .e
34263455 } -cleanup {
34273456 destroy .e
3428 } -result {0}
3457 } -result 0
34293458
34303459 test entry-20.5 {widget deletion while active} -body {
34313460 entry .e -validatecommand { destroy .e ; return 0 }
34333462 winfo exists .e
34343463 } -cleanup {
34353464 destroy .e
3436 } -result {0}
3465 } -result 0
34373466
34383467 test entry-20.6 {widget deletion while active} -body {
34393468 pack [entry .e]
34433472 winfo exists .e
34443473 } -cleanup {
34453474 destroy .e
3446 } -result {0}
3475 } -result 0
34473476
34483477 test entry-20.7 {widget deletion with textvariable active} -body {
34493478 # SF bugs 607390 and 617446
34553484 winfo exists .e
34563485 } -cleanup {
34573486 destroy .e
3458 } -result {0}
3487 } -result 0
34593488
34603489
34613490 test entry-21.1 {selection present while disabled, bug 637828} -body {
244244 set e [entry $t.e]
245245 pack $e
246246 tkwait visibility $e
247 # Avoid a hang when macOS puts the mouse pointer on the green button
247 # Avoid a hang when macOS puts the mouse pointer on the green button
248248 wm geometry .t +200+100
249249 _keypress_string $e MELLO
250250 _keypress $e BackSpace
358358
359359 # Save the position of the insert cursor
360360 lappend result [$e index insert]
361
361
362362 # Now drag until selend is highlighted, then click up
363363
364364 set current $anchor
425425
426426 # Save the position of the insert cursor
427427 lappend result [$e index insert]
428
428
429429 # Now drag until selend is highlighted, then click up
430430
431431 set current $anchor
611611 deleteWindows
612612 } -result {select 11 7 select 4 { select} {Word select} 2}
613613
614 test event-5.1(triple-click-drag) {Triple click and drag across lines in a
614 test event-5.1(triple-click-drag) {Triple click and drag across lines in a
615615 text widget, this should extend the selection to the new line} -setup {
616616 deleteWindows
617617 } -body {
796796 set result [list]
797797 lappend result [$e index insert]
798798 lappend result [_get_selection $e]
799
799
800800 # Clear selection by clicking at 0,0
801801
802802 event generate $e <ButtonPress-1> -x 0 -y 0
824824 } -result {4 A 4 A}
825825
826826 test event-8 {event generate with keysyms corresponding to
827 multi-byte virtual keycodes - bug
827 multi-byte virtual keycodes - bug
828828 e36963bfe8df9f5e528134707a91b9c0051de723} -constraints nonPortable -setup {
829829 deleteWindows
830830 set res [list ]
859859 } -result {OK}
860860
861861 # cleanup
862 update
862863 unset -nocomplain keypress_lookup
863864 rename _init_keypress_lookup {}
864865 rename _keypress_lookup {}
55 # Copyright (c) 1998-1999 by Scriptics Corporation.
66 # All rights reserved.
77
8 package require tcltest 2.1
8 package require tcltest 2.2
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111
166166 catch {tk_getOpenFile -foo 1} msg
167167 regsub -all , $msg "" options
168168 regsub \"-foo\" $options "" options
169
169
170170 foreach option $options {
171171 if {[string index $option 0] eq "-"} {
172172 test filebox-1.2-$mode$option "tk_getOpenFile command" -body {
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
12
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1215
1316 proc focusSetup {} {
1417 destroy .t
103106 focus .gorp a
104107 } -returnCodes error -result {bad option ".gorp": must be -displayof, -force, or -lastfor}
105108 test focus-1.8 {Tk_FocusCmd procedure, focussing on dead window} -constraints {
106 unix
109 unix
107110 } -setup {
108111 destroy .t2
109112 } -body {
129132 destroy .t2
130133 } -result {.t2.f2 .t2 .t2}
131134 test focus-1.9 {Tk_FocusCmd procedure, -displayof option} -constraints {
132 unix
135 unix
133136 } -body {
134137 focus -displayof
135138 } -returnCodes error -result {wrong # args: should be "focus -displayof window"}
136139 test focus-1.10 {Tk_FocusCmd procedure, -displayof option} -constraints {
137 unix
140 unix
138141 } -body {
139142 focus -displayof a b
140143 } -returnCodes error -result {wrong # args: should be "focus -displayof window"}
141144 test focus-1.11 {Tk_FocusCmd procedure, -displayof option} -constraints {
142 unix
145 unix
143146 } -body {
144147 focus -displayof .lousy
145148 } -returnCodes error -result {bad window path name ".lousy"}
146149 test focus-1.12 {Tk_FocusCmd procedure, -displayof option} -constraints {
147 unix
150 unix
148151 } -body {
149152 focusClear
150153 focus .t
151154 focus -displayof .t.b3
152155 } -result {}
153156 test focus-1.13 {Tk_FocusCmd procedure, -displayof option} -constraints {
154 unix
157 unix
155158 } -body {
156159 focusClear
157160 focus -force .t
184187 lappend x [focus]
185188 } -result {{} .t.b1}
186189 test focus-1.20 {Tk_FocusCmd procedure, -lastfor option} -constraints {
187 unix
190 unix
188191 } -body {
189192 focus -lastfor
190193 } -returnCodes error -result {wrong # args: should be "focus -lastfor window"}
191194 test focus-1.21 {Tk_FocusCmd procedure, -lastfor option} -constraints {
192 unix
195 unix
193196 } -body {
194197 focus -lastfor 1 2
195198 } -returnCodes error -result {wrong # args: should be "focus -lastfor window"}
196199 test focus-1.22 {Tk_FocusCmd procedure, -lastfor option} -constraints {
197 unix
200 unix
198201 } -body {
199202 focus -lastfor who_knows?
200203 } -returnCodes error -result {bad window path name "who_knows?"}
201204 test focus-1.23 {Tk_FocusCmd procedure, -lastfor option} -constraints {
202 unix
205 unix
203206 } -body {
204207 focusClear
205208 focusSetup
208211 list [focus -lastfor .] [focus -lastfor .t.b3]
209212 } -result {.b .t.b1}
210213 test focus-1.24 {Tk_FocusCmd procedure, -lastfor option} -constraints {
211 unix
214 unix
212215 } -body {
213216 focusClear
214217 focusSetup
307310 } .t.b1}
308311
309312 test focus-2.6 {TkFocusFilterEvent procedure, FocusIn events} -constraints {
310 unix testwrapper
313 unix testwrapper failsOnUbuntu failsOnXQuarz
311314 } -body {
312315 focus .t.b1
313316 focus .
319322 list $x $focusInfo
320323 } -result {.t.b1 {press .t.b1 x}}
321324 test focus-2.7 {TkFocusFilterEvent procedure, FocusOut events} -constraints {
322 unix testwrapper
325 unix testwrapper failsOnUbuntu failsOnXQuarz
323326 } -body {
324327 set result {}
325328 foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
340343 focus
341344 } -result {.t.b1}
342345 test focus-2.9 {TkFocusFilterEvent procedure, FocusOut events} -constraints {
343 unix testwrapper
346 unix testwrapper failsOnUbuntu failsOnXQuarz
344347 } -body {
345348 focus .t.b1
346349 event gen [testwrapper .] <FocusOut> -detail NotifyAncestor
598601
599602 # Test 5.1 fails (before and after update)
600603 test focus-5.1 {ChangeXFocus procedure, don't take focus unless have it} -constraints {
601 unix testwrapper secureserver
604 unix testwrapper secureserver failsOnUbuntu failsOnXQuarz
602605 } -body {
603606 setupbg
604607 focusSetup
729732 bind all <FocusOut> {}
730733 } -result {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
731734
735 test focus-7.1 {TkSetFocusWin procedure, unmapped windows} -setup {
736 # TkSetFocusWin handles the case of not yet mapped windows
737 # by not setting the focus on them right at the time it is
738 # requested, but by scheduling an event handler that will
739 # set the focus later once it gets mapped. The purpose of
740 # this test is to check that event scheduling and deletion
741 # work as expected (bug [08e2f8e6f0]).
742 toplevel .top
743 spinbox .top.s1
744 spinbox .top.s2
745 spinbox .top.s3
746 grid .top.s1 .top.s2 .top.s3
747 } -body {
748 focus -force .top.s2
749 focus -force .top.s3
750 update
751 focus
752 } -cleanup {
753 destroy .top
754 } -result {.top.s3}
732755
733756
734757 deleteWindows
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212
13 # Some tests require support for 4-byte UTF-8 sequences
14 testConstraint fullutf [expr {[format %c 0x010000] != "\uFFFD"}]
15
16 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
17 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
1318
1419 set defaultfontlist [font names]
1520
5762 } -body {
5863 interp create foo
5964 foo eval {
60 load {} Tk
61 wm geometry . +0+0
62 update
65 load {} Tk
66 wm geometry . +0+0
67 update
6368 }
6469 interp delete foo
6570 } -result {}
7378
7479 # Makes sure that named font was visible only to child interp.
7580 foo eval {
76 load {} Tk
77 wm geometry . +0+0
78 button .b -font {times 16} -text "hi"
79 pack .b
80 font create wiggles -family courier -underline 1
81 update
81 load {} Tk
82 wm geometry . +0+0
83 button .b -font {times 16} -text "hi"
84 pack .b
85 font create wiggles -family courier -underline 1
86 update
8287 }
8388 lappend x [catch {font configure wiggles} msg; set msg]
8489
8590 # Tests cancelling the idle handler for TheWorldHasChanged,
8691 # because app goes away before idle serviced.
8792 foo eval {
88 .b config -font wiggles
89 font config wiggles -size 24
90 destroy .
93 .b config -font wiggles
94 font config wiggles -size 24
95 destroy .
9196 }
9297 lappend x [foo eval {catch {font families} msg; set msg}]
9398 } -cleanup {
94 interp delete foo
99 interp delete foo
95100 } -result {{named font "wiggles" doesn't exist} {can't invoke "font" command: application has been destroyed}}
96101
97102
133138 # not (objc > 3) so objPtr = NULL
134139 lindex [font actual {-family times}] 0
135140 } -result {-family}
136 test font-4.9 {font command: actual} -constraints {unix noExceed} -body {
141 test font-4.9 {font command: actual} -constraints {unix noExceed failsOnUbuntu} -body {
137142 # (objc > 3) so objPtr = objv[3 + skip]
138143 string tolower [font actual {-family times} -family]
139144 } -result {times}
151156 font actual {-family times} -- \udc00
152157 } -match glob -result {*}
153158 test font-4.14 {font command: actual} -constraints win -body {
154 font actual {-family times} -family -- \ud800\udc00
159 font actual {-family times} -family -- \uD800\uDC00
155160 } -result {Times New Roman}
156161 test font-4.15 {font command: actual} -body {
157162 font actual {-family times} -- \udc00\ud800
158163 } -returnCodes 1 -match glob -result {expected a single character but got "*"}
164 test font-4.16 {font command: actual} -constraints {fullutf win} -body {
165 font actual {-family times} -family -- \U10000
166 } -result {Times New Roman}
159167
160168
161169 test font-5.1 {font command: configure} -body {
187195 font create xyz -family xyz
188196 lindex [font configure xyz] 1
189197 } -cleanup {
190 font delete xyz
198 font delete xyz
191199 } -result xyz
192200 test font-5.5 {font command: configure: get one option} -setup {
193201 clearnondefaultfonts
195203 # (objc == 4) so objPtr = objv[3]
196204 font create xyz -family xyz
197205 font configure xyz -family
198 getnondefaultfonts
199 } -cleanup {
200 font delete xyz
206 getnondefaultfonts
207 } -cleanup {
208 font delete xyz
201209 } -result xyz
202210 test font-5.6 {font command: configure: update existing font} -setup {
203211 catch {font delete xyz}
208216 update
209217 font configure xyz -family
210218 } -cleanup {
211 font delete xyz
219 font delete xyz
212220 } -result xyz
213221 test font-5.7 {font command: configure: bad option} -setup {
214222 catch {font delete xyz}
216224 font create xyz
217225 font configure xyz -style
218226 } -cleanup {
219 font delete xyz
227 font delete xyz
220228 } -returnCodes error -result {bad option "-style": must be -family, -size, -weight, -slant, -underline, or -overstrike}
221229
222230
236244 font create xyz
237245 getnondefaultfonts
238246 } -cleanup {
239 font delete xyz
247 font delete xyz
240248 } -result {xyz}
241249 test font-6.3 {font command: create: name not really specified} -setup {
242250 clearnondefaultfonts
278286 font create xyz
279287 font create xyz
280288 } -cleanup {
281 font delete xyz
289 font delete xyz
282290 } -returnCodes error -result {named font "xyz" already exists}
283291
284292 test font-7.1 {font command: delete: arguments} -body {
287295 } -returnCodes error -result {wrong # args: should be "font delete fontname ?fontname ...?"}
288296 test font-7.2 {font command: delete: loop test} -setup {
289297 clearnondefaultfonts
290 set x {}
298 set x {}
291299 } -body {
292300 # for (i = 2; i < objc; i++)
293301 font create a -underline 1
303311 } -result {{a b c d e} d}
304312 test font-7.3 {font command: delete: loop test} -setup {
305313 clearnondefaultfonts
306 set x {}
314 set x {}
307315 } -body {
308316 # (namedHashPtr == NULL) in middle of loop
309317 font create a -underline 1
336344 font actual xyz
337345 font configure xyz
338346 } -cleanup {
339 destroy .t.f
347 destroy .t.f
340348 } -returnCodes error -result {named font "xyz" doesn't exist}
341349 test font-7.6 {font command: delete: mark for later deletion} -setup {
342350 destroy .t.f
350358 font delete xyz
351359 font actual xyz
352360 catch {font configure xyz}
353 .t.f cget -font
361 .t.f cget -font
354362 } -cleanup {
355363 destroy .t.f
356364 } -result xyz
376384 # (objc - skip != 2) when skip == 2
377385 font families -displayof . xyz
378386 } -returnCodes error -result {wrong # args: should be "font families ?-displayof window?"}
379 test font-8.4 {font command: families} -body {
387 test font-8.4 {font command: families} -constraints failsOnUbuntu -body {
380388 # TkpGetFontFamilies()
381389 regexp -nocase times [font families]
382390 } -result 1
508516 font create xyz
509517 font configure xyz -family times
510518 } -cleanup {
511 font delete xyz
519 font delete xyz
512520 } -result {}
513521 test font-12.2 {UpdateDependantFonts procedure: pings the widgets} -setup {
514522 destroy .t.f
527535 set b2 [winfo reqwidth .t.f]
528536 expr {$a1==$b1 && $a2==$b2}
529537 } -cleanup {
530 destroy .t.f
538 destroy .t.f
531539 font delete xyz
532540 } -result {1}
533541
534542
535543 test font-13.1 {CreateNamedFont: new named font} -setup {
536544 catch {font delete xyz}
537 set x {}
545 set x {}
538546 } -body {
539547 # not (new == 0)
540548 lappend x [getnondefaultfonts]
541549 font create xyz
542550 lappend x [getnondefaultfonts]
543551 } -cleanup {
544 font delete xyz
552 font delete xyz
545553 } -result {{} xyz}
546554 test font-13.2 {CreateNamedFont: named font already exists} -setup {
547555 catch {font delete xyz}
550558 font create xyz
551559 font create xyz
552560 } -cleanup {
553 font delete xyz
561 font delete xyz
554562 } -returnCodes error -result {named font "xyz" already exists}
555563 test font-13.3 {CreateNamedFont: named font already exists} -setup {
556564 catch {font delete xyz}
559567 font create xyz
560568 font create xyz
561569 } -cleanup {
562 font delete xyz
570 font delete xyz
563571 } -returnCodes error -result {named font "xyz" already exists}
564572 test font-13.4 {CreateNamedFont: recreate "deleted" font} -setup {
565573 destroy .t.f
574582 font create xyz -family courier
575583 font configure xyz -family
576584 } -cleanup {
577 font delete xyz
578 destroy .t.f
585 font delete xyz
586 destroy .t.f
579587 } -result {courier}
580588
581589
584592
585593
586594 test font-15.1 {Tk_AllocFontFromObj - converting internal reps} -constraints {
587 testfont
595 testfont
588596 } -setup {
589597 destroy .b1 .b2
590598 } -body {
597605 destroy .b1 .b2
598606 } -result {{1 0}}
599607 test font-15.2 {Tk_AllocFontFromObj - discard stale font} -constraints {
600 testfont
608 testfont
601609 } -setup {
602610 destroy .b1 .b2
603611 set result {}
612620 destroy .b2
613621 } -result {{} {{1 1}}}
614622 test font-15.3 {Tk_AllocFontFromObj - reuse existing font} -constraints {
615 testfont
623 testfont
616624 } -setup {
617625 destroy .b1 .b2
618626 set result {}
635643 .t.f config -font {-family fixed}
636644 lindex [font actual {-family fixed}] 0
637645 } -cleanup {
638 destroy .t.f
646 destroy .t.f
639647 } -result {-family}
640648 test font-15.5 {Tk_AllocFontFromObj procedure: get named font} -setup {
641649 destroy .t.f
647655 font create xyz
648656 .t.f config -font xyz
649657 } -cleanup {
650 destroy .t.f
658 destroy .t.f
651659 font delete xyz
652660 } -result {}
653661 test font-15.6 {Tk_AllocFontFromObj procedure: not a named font} -setup {
658666 # not (namedHashPtr != NULL)
659667 .t.f config -font {times 20}
660668 } -cleanup {
661 destroy .t.f
669 destroy .t.f
662670 } -result {-family} -result {}
663671 test font-15.7 {Tk_AllocFontFromObj procedure: get native font} -constraints {
664672 unix
702710 lindex [font actual {plan 9}] 0
703711 } -result {-family}
704712 test font-15.12 {Tk_AllocFontFromObj procedure: setup tab width} -setup {
705 destroy .l
713 destroy .l
706714 } -body {
707715 # Tk_MeasureChars(fontPtr, "0", ...)
708716 label .l -bd 0 -padx 0 -highlightthickness 0 -font $fixed -text "a\tb"
711719 set res2 [expr [font measure $fixed "0"]*9]
712720 expr {$res1 eq $res2}
713721 } -cleanup {
714 destroy .l
722 destroy .l
715723 } -result 1
716724 test font-15.13 {Tk_AllocFontFromObj procedure: underline position} -setup {
717725 destroy .t.f
722730 .t.f config -text "underline" -font "times -8 underline"
723731 update
724732 } -cleanup {
725 destroy .t.f
733 destroy .t.f
726734 } -result {}
727735
728736
734742 .t.f config -font -family\ fixed
735743 .t.f cget -font
736744 } -cleanup {
737 destroy .t.f
745 destroy .t.f
738746 } -result {-family fixed}
739747
740748
920928 }
921929 } -result {LucidaBright}
922930 test font-21.6 {Tk_PostscriptFontName procedure: spaces} -constraints {
923 x11
931 x11 failsOnUbuntu
924932 } -body {
925933 psfontname "{new century schoolbook} 10"
926934 } -result {NewCenturySchlbk-Roman}
14421450
14431451
14441452 test font-22.1 {Tk_TextWidth procedure} -setup {
1445 destroy .t.l
1446 } -body {
1447 label .t.l -padx 0 -pady 0 -bd 0 -highlightthickness 0 -justify left \
1448 -text "0" -font "Courier -12"
1449 pack .t.l
1450 set ax [winfo reqwidth .t.l]
1453 destroy .t.l
1454 } -body {
1455 label .t.l -padx 0 -pady 0 -bd 0 -highlightthickness 0 -justify left \
1456 -text "0" -font "Courier -12"
1457 pack .t.l
1458 set ax [winfo reqwidth .t.l]
14511459 expr {[font measure [.t.l cget -font] "000"] eq $ax*3}
14521460 } -cleanup {
1453 destroy .t.l
1461 destroy .t.l
14541462 } -result 1
14551463
14561464
14571465 test font-23.1 {Tk_UnderlineChars procedure} -setup {
1458 destroy .t.t
1466 destroy .t.t
14591467 } -body {
14601468 text .t.t
14611469 .t.t insert 1.0 abc\tdefg
14631471 .t.t tag add sel 1.0 end
14641472 update
14651473 } -cleanup {
1466 destroy .t.t
1474 destroy .t.t
14671475 } -result {}
14681476
14691477
14801488 } -result {}
14811489 test font-24.2 {Tk_ComputeTextLayout: simple string} -body {
14821490 .t.l config -text "000"
1483 update
1484 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1485 [expr {[winfo reqheight .t.l] eq $ay}]
1491 update
1492 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1493 [expr {[winfo reqheight .t.l] eq $ay}]
14861494 } -result {1 1}
14871495 test font-24.3 {Tk_ComputeTextLayout: find special chars} -body {
14881496 .t.l config -text "000\n000"
1489 update
1490 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1491 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1497 update
1498 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1499 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
14921500 } -result {1 1}
14931501 test font-24.4 {Tk_ComputeTextLayout: calls Tk_MeasureChars} -body {
14941502 .t.l config -text "000\n000"
1495 update
1496 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1497 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1503 update
1504 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}] \
1505 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
14981506 } -result {1 1}
14991507 test font-24.5 {Tk_ComputeTextLayout: break line} -body {
15001508 .t.l config -text "000\t00000" -wrap [expr 9 * $ax]
1501 update
1502 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 8}]}] \
1503 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1509 update
1510 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 8}]}] \
1511 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15041512 } -cleanup {
15051513 .t.l config -wrap 0
15061514 } -result {1 1}
15091517 } -result {}
15101518 test font-24.7 {Tk_ComputeTextLayout: special char was \n} -body {
15111519 .t.l config -text "000\n0000"
1512 update
1513 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}] \
1514 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1520 update
1521 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}] \
1522 [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15151523 } -result {1 1}
15161524 test font-24.8 {Tk_ComputeTextLayout: special char was \t} -body {
15171525 .t.l config -text "000\t00"
1518 update
1519 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 10}]}] \
1520 [expr {[winfo reqheight .t.l] eq $ay}]
1526 update
1527 list [expr {[winfo reqwidth .t.l] eq [expr {$ax * 10}]}] \
1528 [expr {[winfo reqheight .t.l] eq $ay}]
15211529 } -result {1 1}
15221530 test font-24.9 {Tk_ComputeTextLayout: tab didn't cause break} -body {
15231531 set x {}
15241532 .t.l config -text "000\t000"
1525 update
1533 update
15261534 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 11}]}]
1527 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1535 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
15281536 .t.l config -text "000\t000" -wrap [expr 100 * $ax]
1529 update
1537 update
15301538 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 11}]}]
1531 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1539 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
15321540 return $x
15331541 } -cleanup {
15341542 .t.l config -wrap 0
15361544 test font-24.10 {Tk_ComputeTextLayout: tab caused break} -body {
15371545 set x {}
15381546 .t.l config -text "000\t"
1539 update
1547 update
15401548 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 8}]}]
1541 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1549 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
15421550 .t.l config -text "000\t00" -wrap [expr $ax * 6]
1543 update
1544 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 8}]}]
1545 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1551 update
1552 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 8}]}]
1553 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15461554 return $x
15471555 } -cleanup {
15481556 .t.l config -wrap 0
15501558 test font-24.11 {Tk_ComputeTextLayout: absorb spaces at eol} -body {
15511559 set x {}
15521560 .t.l config -text "000 000" -wrap [expr {$ax * 5}]
1553 update
1554 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}]
1555 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1561 update
1562 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}]
1563 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15561564 .t.l config -text "000 "
1557 update
1558 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}]
1559 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1565 update
1566 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 3}]}]
1567 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
15601568 return $x
15611569 } -cleanup {
15621570 .t.l config -wrap 0
15641572 test font-24.12 {Tk_ComputeTextLayout: append non-printing spaces to chunk} -body {
15651573 set x {}
15661574 .t.l config -text "000 0000" -wrap [expr {$ax * 5}]
1567 update
1568 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1569 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1575 update
1576 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1577 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15701578 .t.l config -text "000\t00 0000" -wrap [expr {$ax * 12}]
1571 update
1572 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 10}]}]
1573 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1579 update
1580 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 10}]}]
1581 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
15741582 return $x
15751583 } -cleanup {
15761584 .t.l config -wrap 0
15771585 } -result {1 1 1 1}
15781586 test font-24.13 {Tk_ComputeTextLayout: many lines -> realloc line array} -body {
15791587 .t.l config -text "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
1580 update
1581 list [expr {[winfo reqwidth .t.l] eq 1}] \
1582 [expr {[winfo reqheight .t.l] eq [expr {$ay * 129}]}]
1588 update
1589 list [expr {[winfo reqwidth .t.l] eq 1}] \
1590 [expr {[winfo reqheight .t.l] eq [expr {$ay * 129}]}]
15831591 } -result {1 1}
15841592 test font-24.14 {Tk_ComputeTextLayout: text ended with \n} -body {
15851593 set x {}
1586 .t.l config -text "0000"
1587 update
1588 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1589 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1590 .t.l config -text "0000\n"
1591 update
1592 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1593 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1594 return $x
1594 .t.l config -text "0000"
1595 update
1596 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1597 lappend x [expr {[winfo reqheight .t.l] eq $ay}]
1598 .t.l config -text "0000\n"
1599 update
1600 lappend x [expr {[winfo reqwidth .t.l] eq [expr {$ax * 4}]}]
1601 lappend x [expr {[winfo reqheight .t.l] eq [expr {$ay * 2}]}]
1602 set x
15951603 } -result {1 1 1 1}
15961604 destroy .t.l
15971605
15981606 test font-24.15 {Tk_ComputeTextLayout: justification} -setup {
15991607 set x {}
1600 destroy .t.c
1601 canvas .t.c -closeenough 0
1602 .t.c create text 0 0 -tags text -anchor nw -just left -font "Courier -12"
1603 pack .t.c
1604 update
1608 destroy .t.c
1609 canvas .t.c -closeenough 0
1610 .t.c create text 0 0 -tags text -anchor nw -just left -font "Courier -12"
1611 pack .t.c
1612 update
16051613 } -body {
16061614 csetup "000\n00000"
16071615 .t.c itemconfig text -just left
16131621 .t.c itemconfig text -just left
16141622 return $x
16151623 } -cleanup {
1616 destroy .t.c
1624 destroy .t.c
16171625 } -result {2 1 0}
16181626
16191627
16251633 .t.f config -text foo
16261634 .t.f config -text boo
16271635 } -cleanup {
1628 destroy .t.f
1636 destroy .t.f
16291637 } -result {}
16301638
16311639
16421650 } -body {
16431651 .t.f config -text foo
16441652 } -cleanup {
1645 destroy .t.f
1653 destroy .t.f
16461654 } -result {}
16471655 test font-26.2 {Tk_DrawTextLayout procedure: multiple chunks} -body {
16481656 csetup "000\t00\n000"
17871795 update
17881796 test font-30.1 {Tk_DistanceToTextLayout procedure: loop once} -body {
17891797 csetup "000\n000\n000"
1790 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1798 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
17911799 set x {}
17921800 event generate .t.c <Leave>
17931801 event generate .t.c <Enter> -x 0 -y 0
17941802 return $x
17951803 } -cleanup {
1796 bind all <Enter> {}
1804 bind all <Enter> {}
17971805 } -result {0}
17981806 test font-30.2 {Tk_DistanceToTextLayout procedure: loop multiple} -body {
17991807 csetup "000\n000\n000"
1800 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1808 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18011809 set x {}
18021810 event generate .t.c <Leave>
18031811 event generate .t.c <Enter> -x $ax -y $ay
18041812 return $x
18051813 } -cleanup {
1806 bind all <Enter> {}
1814 bind all <Enter> {}
18071815 } -result {5}
18081816 test font-30.3 {Tk_DistanceToTextLayout procedure: loop to end} -body {
18091817 csetup "000\n0\n000"
1810 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1818 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18111819 set x {}
18121820 event generate .t.c <Leave>
18131821 event generate .t.c <Enter> -x [expr $ax*2] -y $ay
18141822 return $x
18151823 } -cleanup {
1816 bind all <Enter> {}
1824 bind all <Enter> {}
18171825 } -result {}
18181826 test font-30.4 {Tk_DistanceToTextLayout procedure: hit a special char (tab)} -body {
18191827 csetup "000\t000\n000"
1820 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1828 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18211829 set x {}
18221830 event generate .t.c <Leave>
18231831 event generate .t.c <Enter> -x [expr $ax*6] -y 0
18241832 return $x
18251833 } -cleanup {
1826 bind all <Enter> {}
1834 bind all <Enter> {}
18271835 } -result {3}
18281836 test font-30.5 {Tk_DistanceToTextLayout procedure: ignore newline} -body {
18291837 csetup "000\n0\n000"
1830 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1838 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18311839 set x {}
18321840 event generate .t.c <Leave>
18331841 event generate .t.c <Enter> -x [expr $ax*2] -y $ay
18341842 return $x
18351843 } -cleanup {
1836 bind all <Enter> {}
1844 bind all <Enter> {}
18371845 } -result {}
18381846 test font-30.6 {Tk_DistanceToTextLayout procedure: ignore spaces at eol} -body {
18391847 csetup "000\n000 000000000"
18401848 .t.c itemconfig text -width [expr $ax*10]
1841 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1849 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18421850 set x {}
18431851 event generate .t.c <Leave>
18441852 event generate .t.c <Enter> -x [expr $ax*5] -y $ay
18451853 .t.c itemconfig text -width 0
18461854 return $x
18471855 } -cleanup {
1848 bind all <Enter> {}
1856 bind all <Enter> {}
18491857 } -result {}
18501858 .t.c itemconfig text -justify center
18511859 test font-30.7 {Tk_DistanceToTextLayout procedure: on left side} -body {
18521860 csetup "0\n000"
1853 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1861 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18541862 set x {}
18551863 event generate .t.c <Leave>
18561864 event generate .t.c <Enter> -x 0 -y 0
18571865 return $x
18581866 } -cleanup {
1859 bind all <Enter> {}
1867 bind all <Enter> {}
18601868 } -result {}
18611869 test font-30.8 {Tk_DistanceToTextLayout procedure: on right side} -body {
18621870 csetup "0\n000"
1863 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1871 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18641872 set x {}
18651873 event generate .t.c <Leave>
18661874 event generate .t.c <Enter> -x [expr $ax*2] -y 0
18671875 return $x
18681876 } -cleanup {
1869 bind all <Enter> {}
1877 bind all <Enter> {}
18701878 } -result {}
18711879 test font-30.9 {Tk_DistanceToTextLayout procedure: inside line} -body {
18721880 csetup "0\n000"
1873 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1881 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18741882 set x {}
18751883 event generate .t.c <Leave>
18761884 event generate .t.c <Enter> -x $ax -y 0
18771885 return $x
18781886 } -cleanup {
1879 bind all <Enter> {}
1887 bind all <Enter> {}
18801888 } -result {0}
18811889 test font-30.10 {Tk_DistanceToTextLayout procedure: above line} -body {
18821890 csetup "0\n000"
1883 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1891 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18841892 set x {}
18851893 event generate .t.c <Leave>
18861894 event generate .t.c <Enter> -x 0 -y 0
18871895 return $x
18881896 } -cleanup {
1889 bind all <Enter> {}
1897 bind all <Enter> {}
18901898 } -result {}
18911899 test font-30.11 {Tk_DistanceToTextLayout procedure: below line} -body {
18921900 csetup "000\n0"
1893 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1901 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
18941902 set x {}
18951903 event generate .t.c <Leave>
18961904 event generate .t.c <Enter> -x 0 -y $ay
19001908 } -result {}
19011909 test font-30.12 {Tk_DistanceToTextLayout procedure: in line} -body {
19021910 csetup "0\n000"
1903 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1911 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
19041912 set x {}
19051913 event generate .t.c <Leave>
19061914 event generate .t.c <Enter> -x $ax -y $ay
19111919 .t.c itemconfig text -justify left
19121920 test font-30.13 {Tk_DistanceToTextLayout procedure: exact hit} -body {
19131921 csetup "000"
1914 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
1922 .t.c bind all <Enter> {lappend x [.t.c index current @%x,%y]}
19151923 set x {}
19161924 event generate .t.c <Leave>
19171925 event generate .t.c <Enter> -x $ax -y 0
19181926 return $x
19191927 } -cleanup {
1920 bind all <Enter> {}
1928 bind all <Enter> {}
19211929 } -result {1}
19221930 destroy .t.c
19231931
19691977
19701978
19711979 test font-32.1 {Tk_TextLayoutToPostscript: ensure buffer doesn't overflow} -setup {
1972 destroy .t.c
1973 canvas .t.c -closeenough 0
1974 .t.c create text 0 0 -tags text -anchor nw -just left -font "Courier -12"
1975 pack .t.c
1976 update
1980 destroy .t.c
1981 canvas .t.c -closeenough 0
1982 .t.c create text 0 0 -tags text -anchor nw -just left -font "Courier -12"
1983 pack .t.c
1984 update
19771985 } -body {
19781986 # If there were a whole bunch of returns or tabs in a row, then the
19791987 # temporary buffer could overflow and write on the stack.
19861994 set i [string first "(qwerty" $x]
19871995 string range $x $i [expr {$i + 278}]
19881996 } -cleanup {
1989 destroy .t.c
1997 destroy .t.c
19901998 } -result {(qwertyuiopasdfghjklzxcvbnm1234qwertyuiopasdfghjklzxcvbnm)]
19911999 [(qwertyuiopasdfghjklzxcvbnm1234qwertyuiopasdfghjklzxcvbnm)]
19922000 [()]
20442052
20452053 test font-34.3 {ConfigAttributesObj procedure: family} -setup {
20462054 catch {font delete xyz}
2047 set x {}
2048 } -body {
2049 font create xyz -family xyz
2050 lappend x [font config xyz -family]
2051 font config xyz -family times
2052 lappend x [font config xyz -family]
2055 set x {}
2056 } -body {
2057 font create xyz -family xyz
2058 lappend x [font config xyz -family]
2059 font config xyz -family times
2060 lappend x [font config xyz -family]
20532061 } -cleanup {
20542062 font delete xyz
20552063 } -result {xyz times}
20562064 test font-34.4 {ConfigAttributesObj procedure: size} -setup {
20572065 catch {font delete xyz}
2058 set x {}
2059 } -body {
2060 font create xyz -size 20
2061 lappend x [font config xyz -size]
2062 font config xyz -size 40
2063 lappend x [font config xyz -size]
2064 } -cleanup {
2065 font delete xyz
2066 set x {}
2067 } -body {
2068 font create xyz -size 20
2069 lappend x [font config xyz -size]
2070 font config xyz -size 40
2071 lappend x [font config xyz -size]
2072 } -cleanup {
2073 font delete xyz
20662074 } -result {20 40}
20672075 test font-34.5 {ConfigAttributesObj procedure: weight} -setup {
20682076 catch {font delete xyz}
2069 set x {}
2070 } -body {
2071 font create xyz -weight normal
2072 lappend x [font config xyz -weight]
2073 font config xyz -weight bold
2074 lappend x [font config xyz -weight]
2075 } -cleanup {
2076 font delete xyz
2077 set x {}
2078 } -body {
2079 font create xyz -weight normal
2080 lappend x [font config xyz -weight]
2081 font config xyz -weight bold
2082 lappend x [font config xyz -weight]
2083 } -cleanup {
2084 font delete xyz
20772085 } -result {normal bold}
20782086 test font-34.6 {ConfigAttributesObj procedure: slant} -setup {
20792087 catch {font delete xyz}
2080 set x {}
2081 } -body {
2082 font create xyz -slant roman
2083 lappend x [font config xyz -slant]
2084 font config xyz -slant italic
2085 lappend x [font config xyz -slant]
2086 } -cleanup {
2087 font delete xyz
2088 set x {}
2089 } -body {
2090 font create xyz -slant roman
2091 lappend x [font config xyz -slant]
2092 font config xyz -slant italic
2093 lappend x [font config xyz -slant]
2094 } -cleanup {
2095 font delete xyz
20882096 } -result {roman italic}
20892097 test font-34.7 {ConfigAttributesObj procedure: underline} -setup {
20902098 catch {font delete xyz}
2091 set x {}
2092 } -body {
2093 font create xyz -underline 0
2094 lappend x [font config xyz -underline]
2095 font config xyz -underline 1
2096 lappend x [font config xyz -underline]
2097 } -cleanup {
2098 font delete xyz
2099 set x {}
2100 } -body {
2101 font create xyz -underline 0
2102 lappend x [font config xyz -underline]
2103 font config xyz -underline 1
2104 lappend x [font config xyz -underline]
2105 } -cleanup {
2106 font delete xyz
20992107 } -result {0 1}
21002108 test font-34.8 {ConfigAttributesObj procedure: overstrike} -setup {
21012109 catch {font delete xyz}
2102 set x {}
2103 } -body {
2104 font create xyz -overstrike 0
2105 lappend x [font config xyz -overstrike]
2106 font config xyz -overstrike 1
2107 lappend x [font config xyz -overstrike]
2108 } -cleanup {
2109 font delete xyz
2110 set x {}
2111 } -body {
2112 font create xyz -overstrike 0
2113 lappend x [font config xyz -overstrike]
2114 font config xyz -overstrike 1
2115 lappend x [font config xyz -overstrike]
2116 } -cleanup {
2117 font delete xyz
21102118 } -result {0 1}
21112119
21122120 test font-34.9 {ConfigAttributesObj procedure: size} -body {
2113 font create xyz -size xyz
2121 font create xyz -size xyz
21142122 } -returnCodes error -result {expected integer but got "xyz"}
21152123 test font-34.10 {ConfigAttributesObj procedure: weight} -body {
2116 font create xyz -weight xyz
2124 font create xyz -weight xyz
21172125 } -returnCodes error -result {bad -weight value "xyz": must be normal, or bold}
21182126 test font-34.11 {ConfigAttributesObj procedure: slant} -body {
2119 font create xyz -slant xyz
2127 font create xyz -slant xyz
21202128 } -returnCodes error -result {bad -slant value "xyz": must be roman, or italic}
21212129 test font-34.12 {ConfigAttributesObj procedure: underline} -body {
2122 font create xyz -underline xyz
2130 font create xyz -underline xyz
21232131 } -returnCodes error -result {expected boolean value but got "xyz"}
21242132 test font-34.13 {ConfigAttributesObj procedure: overstrike} -body {
2125 font create xyz -overstrike xyz
2133 font create xyz -overstrike xyz
21262134 } -returnCodes error -result {expected boolean value but got "xyz"}
21272135
21282136
21332141 font create xyz -family xyz
21342142 font config xyz -family
21352143 } -cleanup {
2136 font delete xyz
2144 font delete xyz
21372145 } -result {xyz}
21382146
21392147
21442152 font create xyz
21452153 font config xyz -xyz
21462154 } -cleanup {
2147 font delete xyz
2155 font delete xyz
21482156 } -returnCodes {
21492157 error
21502158 } -result {bad option "-xyz": must be -family, -size, -weight, -slant, -underline, or -overstrike}
21572165 font create xyz -family xyz
21582166 font config xyz
21592167 } -cleanup {
2160 font delete xyz
2168 font delete xyz
21612169 } -result {-family xyz -size 0 -weight normal -slant roman -underline 0 -overstrike 0}
21622170 test font-37.2 {GetAttributeInfo procedure: family} -setup {
21632171 catch {font delete xyz}
21642172 } -body {
2165 font create xyz -family xyz
2166 font config xyz -family
2167 } -cleanup {
2168 font delete xyz
2173 font create xyz -family xyz
2174 font config xyz -family
2175 } -cleanup {
2176 font delete xyz
21692177 } -result {xyz}
21702178 test font-37.3 {GetAttributeInfo procedure: size} -setup {
21712179 catch {font delete xyz}
2172 set x {}
2173 } -body {
2174 font create xyz -size 20
2175 font config xyz -size
2176 } -cleanup {
2177 font delete xyz
2180 set x {}
2181 } -body {
2182 font create xyz -size 20
2183 font config xyz -size
2184 } -cleanup {
2185 font delete xyz
21782186 } -result {20}
21792187 test font-37.4 {GetAttributeInfo procedure: weight} -setup {
21802188 catch {font delete xyz}
2181 set x {}
2182 } -body {
2183 font create xyz -weight normal
2184 font config xyz -weight
2185 } -cleanup {
2186 font delete xyz
2189 set x {}
2190 } -body {
2191 font create xyz -weight normal
2192 font config xyz -weight
2193 } -cleanup {
2194 font delete xyz
21872195 } -result {normal}
21882196 test font-37.5 {GetAttributeInfo procedure: slant} -setup {
21892197 catch {font delete xyz}
2190 set x {}
2191 } -body {
2192 font create xyz -slant italic
2193 font config xyz -slant
2194 } -cleanup {
2195 font delete xyz
2198 set x {}
2199 } -body {
2200 font create xyz -slant italic
2201 font config xyz -slant
2202 } -cleanup {
2203 font delete xyz
21962204 } -result {italic}
21972205 test font-37.6 {GetAttributeInfo procedure: underline} -setup {
21982206 catch {font delete xyz}
2199 set x {}
2200 } -body {
2201 font create xyz -underline yes
2202 font config xyz -underline
2203 } -cleanup {
2204 font delete xyz
2207 set x {}
2208 } -body {
2209 font create xyz -underline yes
2210 font config xyz -underline
2211 } -cleanup {
2212 font delete xyz
22052213 } -result {1}
22062214 test font-37.7 {GetAttributeInfo procedure: overstrike} -setup {
22072215 catch {font delete xyz}
2208 set x {}
2209 } -body {
2210 font create xyz -overstrike no
2211 font config xyz -overstrike
2212 } -cleanup {
2213 font delete xyz
2216 set x {}
2217 } -body {
2218 font create xyz -overstrike no
2219 font config xyz -overstrike
2220 } -cleanup {
2221 font delete xyz
22142222 } -result {0}
22152223
22162224
22492257 font actual {times xyz xyz}
22502258 } -returnCodes error -result {expected integer but got "xyz"}
22512259 test font-38.11 {ParseFontNameObj procedure: stylelist loop} -constraints {
2252 unixOrPc
2260 unixOrWin failsOnUbuntuNoXft
22532261 } -body {
22542262 lrange [font actual {times 12 bold italic overstrike underline}] 4 end
22552263 } -result {-weight bold -slant italic -underline 1 -overstrike 1}
23312339 } -result [font actual {times 0} -family]
23322340
23332341
2334 test font-44.1 {TkFontGetPixels: size < 0} -setup {
2335 set oldscale [tk scaling]
2336 } -body {
2337 tk scaling 0.5
2342 test font-44.1 {TkFontGetPixels: size < 0} -constraints failsOnUbuntu -setup {
2343 set oldscale [tk scaling]
2344 } -body {
2345 tk scaling 0.5
23382346 font actual {times -12} -size
23392347 } -cleanup {
2340 tk scaling $oldscale
2348 tk scaling $oldscale
23412349 } -result {24}
2342 test font-44.2 {TkFontGetPoints: size >= 0} -constraints noExceed -setup {
2343 set oldscale [tk scaling]
2344 } -body {
2345 tk scaling 0.5
2350 test font-44.2 {TkFontGetPoints: size >= 0} -constraints {noExceed failsOnUbuntuNoXft} -setup {
2351 set oldscale [tk scaling]
2352 } -body {
2353 tk scaling 0.5
23462354 font actual {times 12} -size
23472355 } -cleanup {
2348 tk scaling $oldscale
2356 tk scaling $oldscale
23492357 } -result {12}
23502358
23512359
23552363 test font-45.2 {TkFontGetAliasList: match} -constraints win -body {
23562364 font actual {times 10} -family
23572365 } -result {Times New Roman}
2358 test font-45.3 {TkFontGetAliasList: match} -constraints {noExceed} -body {
2366 test font-45.3 {TkFontGetAliasList: match} -constraints {noExceed failsOnUbuntu} -body {
23592367 if {[font actual {{times new roman} 10} -family] eq "Times New Roman"} {
23602368 # avoid test failure on systems that have a real "times new roman" font
23612369 set res 1
23672375
23682376
23692377 test font-46.1 {font actual, with character, no option, no --} -body {
2370 font actual {times 10} a
2378 font actual {times 10} a
23712379 } -match glob -result [list -family [font actual {times 10} -family] -size *\
23722380 -slant roman -underline 0 -overstrike 0]
23732381
23742382 test font-46.2 {font actual, with character introduced by --} -body {
2375 font actual {times 10} -- -
2383 font actual {times 10} -- -
23762384 } -match glob -result [list -family [font actual {times 10} -family] -size *\
23772385 -slant roman -underline 0 -overstrike 0]
23782386
11 #
22 # Copyright (c) 2008 Pat Thoyts
33
4 package require tcltest 2.1
4 package require tcltest 2.2
55 eval tcltest::configure $argv
66 tcltest::loadTestedCommands
77
8 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
9 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
10
811 # the following helper functions are related to the functions used
912 # in winDialog.test where they are used to send messages to the win32
10 # dialog (hence the wierdness).
13 # dialog (hence the weirdness).
1114
1215 proc start {cmd} {
1316 set ::tk_dialog {}
178181 expr {$::testfont ne {}}
179182 } -result {1}
180183
181 test fontchooser-4.4 {fontchooser -font} -constraints scriptImpl -body {
184 test fontchooser-4.4 {fontchooser -font} -constraints {scriptImpl failsOnUbuntuNoXft} -body {
182185 start {
183186 tk::fontchooser::Configure -command ApplyFont -font {times 14 bold}
184187 tk::fontchooser::Show
188191 }
189192 lrange $::testfont 1 end
190193 } -result {14 bold}
194
195 test fontchooser-5.1 {fontchooser multiple configure} -constraints {scriptImpl} -body {
196 tk fontchooser configure -title TestTitle -command foo
197 tk fontchooser configure -command bar
198 tk fontchooser configure -title
199 } -result {TestTitle}
191200
192201 # -------------------------------------------------------------------------
193202
672672 } -body {
673673 toplevel .t -container 1 -width 300 -height 120
674674 wm geometry .t +0+0
675 if {[tk windowingsystem] eq "aqua"} {
676 update idletasks
677 } else {
678 update
679 }
675680 option add *x.use [winfo id .t]
676 update
677681 toplevel .x -width 140 -height 300 -bg green
678 tkwait visibility .x
679 update
682 if {[tk windowingsystem] eq "aqua"} {
683 update idletasks
684 } else {
685 tkwait visibility .x
686 update
687 }
680688 list [expr {[winfo rootx .x] - [winfo rootx .t]}] \
681689 [expr {[winfo rooty .x] - [winfo rooty .t]}] \
682690 [winfo width .t] [winfo height .t]
11531161 } -result {1 1 1 1 1 1 1 1 1 1 1 1}
11541162 test frame-12.3 {FrameWorldChanged procedure} -setup {
11551163 deleteWindows
1164 update idletasks
11561165 } -body {
11571166 # Check reaction on font change
11581167 font create myfont -family courier -size 10
11591168 labelframe .f -font myfont -text Mupp
11601169 place .f -x 0 -y 0 -width 40 -height 40
11611170 pack [frame .f.f] -fill both -expand 1
1162 update
1171 if {[tk windowingsystem] eq "aqua"} {
1172 update idletasks
1173 } else {
1174 update
1175 }
11631176 set h1 [font metrics myfont -linespace]
11641177 set y1 [winfo y .f.f]
11651178 font configure myfont -size 20
1166 update
1179 if {[tk windowingsystem] eq "aqua"} {
1180 update idletasks
1181 } else {
1182 update
1183 }
11671184 set h2 [font metrics myfont -linespace]
11681185 set y2 [winfo y .f.f]
11691186 expr {($h2 - $h1) - ($y2 - $y1)}
269269 wm geometry .t +0+0
270270 tkwait visibility .t
271271 update
272 pack [frame .t.f]
272 pack [frame .t.f]
273273 button .t.quit -text Quit -command exit
274274 pack .t.quit -in .t.f
275275 wm iconify .t
4444 } -returnCodes error -result {wrong # args: should be "grid option arg ?arg ...?"}
4545 test grid-1.2 {basic argument checking} -body {
4646 grid foo bar
47 } -returnCodes error -result {bad option "foo": must be anchor, bbox, columnconfigure, configure, forget, info, location, propagate, remove, rowconfigure, size, or slaves}
47 } -returnCodes error -result {bad option "foo": must be anchor, bbox, columnconfigure, configure, content, forget, info, location, propagate, remove, rowconfigure, size, or slaves}
4848 test grid-1.3 {basic argument checking} -body {
4949 button .b
5050 grid .b -row 0 -column
144144 test grid-3.2 {configure: basic argument checking} -body {
145145 button .b
146146 grid configure .b
147 grid slaves .
147 grid content .
148148 } -cleanup {
149149 grid_reset 3.2
150150 } -result {.b}
182182 test grid-3.8 {configure: basic argument checking} -body {
183183 button .b
184184 grid configure x .b
185 grid slaves .
185 grid content .
186186 } -cleanup {
187187 grid_reset 3.8
188188 } -result {.b}
192192 } -cleanup {
193193 grid_reset 3.9
194194 } -returnCodes error -result {invalid window shortcut, "y" should be '-', 'x', or '^'}
195 test grid-3.10 {ConfigureSlave procedure, bad -in option} -body {
195 test grid-3.10 {ConfigureContent procedure, bad -in option} -body {
196196 frame .f
197197 grid .f -in .f
198198 } -cleanup {
223223 test grid-4.2 {forget} -body {
224224 button .c
225225 grid [button .b]
226 set a [grid slaves .]
226 set a [grid content .]
227227 grid forget .b .c
228 lappend a [grid slaves .]
228 lappend a [grid content .]
229229 return $a
230230 } -cleanup {
231231 grid_reset 4.2
515515 grid_reset 8.6
516516 } -result {{51 11} {51 11} {31 11} {21 11} {16 1} {1 1}}
517517
518 test grid-9.1 {slaves} -body {
519 grid slaves .
518 test grid-9.1 {content} -body {
519 grid content .
520520 } -returnCodes ok -result {}
521 test grid-9.2 {slaves} -body {
522 grid slaves .foo
521 test grid-9.2 {content} -body {
522 grid content .foo
523523 } -returnCodes error -result {bad window path name ".foo"}
524 test grid-9.3 {slaves} -body {
525 grid slaves a b
526 } -returnCodes error -result {wrong # args: should be "grid slaves window ?-option value ...?"}
527 test grid-9.4 {slaves} -body {
528 grid slaves . a b
524 test grid-9.3 {content} -body {
525 grid content a b
526 } -returnCodes error -result {wrong # args: should be "grid content window ?-option value ...?"}
527 test grid-9.4 {content} -body {
528 grid content . a b
529529 } -returnCodes error -result {bad option "a": must be -column or -row}
530 test grid-9.5 {slaves} -body {
531 grid slaves . -column x
530 test grid-9.5 {content} -body {
531 grid content . -column x
532532 } -returnCodes error -result {expected integer but got "x"}
533 test grid-9.6 {slaves} -body {
534 grid slaves . -row -3
533 test grid-9.6 {content} -body {
534 grid content . -row -3
535535 } -returnCodes error -result {-3 is an invalid value: should NOT be < 0}
536 test grid-9.7 {slaves} -body {
537 grid slaves . -foo 3
536 test grid-9.7 {content} -body {
537 grid content . -foo 3
538538 } -returnCodes error -result {bad option "-foo": must be -column or -row}
539 test grid-9.8 {slaves} -body {
540 grid slaves .x -row 3
539 test grid-9.8 {content} -body {
540 grid content .x -row 3
541541 } -returnCodes error -result {bad window path name ".x"}
542 test grid-9.9 {slaves} -body {
543 grid slaves . -row 3
542 test grid-9.9 {content} -body {
543 grid content . -row 3
544544 } -returnCodes ok -result {}
545 test grid-9.10 {slaves} -body {
545 test grid-9.10 {content} -body {
546546 foreach i {0 1 2} {
547547 label .$i -text $i
548548 grid .$i -row $i -column $i
549549 }
550 grid slaves .
550 grid content .
551551 } -cleanup {
552552 grid_reset 9.10
553553 } -result {.2 .1 .0}
554 test grid-9.11 {slaves} -body {
554 test grid-9.11 {content} -body {
555555 catch {unset a}
556556 foreach i {0 1 2} {
557557 label .$i -text $i
560560 grid .$i-x -row $i -column [incr i]
561561 }
562562 foreach row {0 1 2 3} {
563 lappend a $row{[grid slaves . -row $row]}
563 lappend a $row{[grid content . -row $row]}
564564 }
565565 foreach col {0 1 2 3} {
566 lappend a $col{[grid slaves . -column $col]}
566 lappend a $col{[grid content . -column $col]}
567567 }
568568 return $a
569569 } -cleanup {
13041304 grid .b -in .1
13051305 set a ""
13061306 catch {unset info}; array set info [grid info .b]
1307 lappend a [grid slaves .1],[grid slaves .2],$info(-in)
1307 lappend a [grid content .1],[grid content .2],$info(-in)
13081308 grid .b -in .2
13091309 catch {unset info}; array set info [grid info .b]
1310 lappend a [grid slaves .1],[grid slaves .2],$info(-in)
1310 lappend a [grid content .1],[grid content .2],$info(-in)
13111311 unset info
13121312 return $a
13131313 } -cleanup {
13681368 grid_reset 14.3
13691369 } -result {.2 2 .0 1 . 2 .1 1}
13701370
1371 test grid-15.1 {lost slave} -body {
1371 test grid-15.1 {lost content} -body {
13721372 button .b
13731373 grid .b
1374 set a [grid slaves .]
1374 set a [grid content .]
13751375 pack .b
1376 lappend a [grid slaves .]
1376 lappend a [grid content .]
13771377 grid .b
1378 lappend a [grid slaves .]
1378 lappend a [grid content .]
13791379 } -cleanup {
13801380 grid_reset 15.1
13811381 } -result {.b {} .b}
1382 test grid-15.2 {lost slave} -body {
1382 test grid-15.2 {lost content} -body {
13831383 frame .f
13841384 grid .f
13851385 button .b
13861386 grid .b -in .f
1387 set a [grid slaves .f]
1387 set a [grid content .f]
13881388 pack .b -in .f
1389 lappend a [grid slaves .f]
1389 lappend a [grid content .f]
13901390 grid .b -in .f
1391 lappend a [grid slaves .f]
1391 lappend a [grid content .f]
13921392 } -cleanup {
13931393 grid_reset 15.2
13941394 } -result {.b {} .b}
19741974 test grid-22.2 {remove} {
19751975 button .c
19761976 grid [button .b]
1977 set a [grid slaves .]
1977 set a [grid content .]
19781978 grid remove .b .c
1979 lappend a [grid slaves .]
1979 lappend a [grid content .]
19801980 return $a
19811981 } {.b {}}
19821982 grid_reset 22.2
20232023 } {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns}
20242024 grid_reset 22.5
20252025
2026 test grid-23 {grid configure -in leaked from previous master - bug
2026 test grid-23 {grid configure -in leaked from previous container window - bug
20272027 6aea69fccbb266b7f0437686379fbe5b55442958} {
20282028 frame .f
20292029 frame .g
310310 test image-6.1 {Tk_ImageCmd procedure, "types" option} -body {
311311 image types x
312312 } -returnCodes error -result {wrong # args: should be "image types"}
313 test image-6.2 {Tk_ImageCmd procedure, "types" option} -constraints {
314 testImageType
315 } -body {
313 test image-6.2 {Tk_ImageCmd procedure, "types" option} -body {
316314 lsort [image types]
317 } -result {bitmap oldtest photo test}
315 } -match glob -result {bitmap*photo test}
318316
319317
320318 test image-7.1 {Tk_ImageCmd procedure, "width" option} -body {
356354 catch {destroy .b}
357355 } -result [list 0 1]
358356
359 if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
360 # Aqua >= 10.14 will redraw the entire image in drawRect.
361 set result_9_1 {{foo display 0 0 30 15}}
362 } else {
363 set result_9_1 {{foo display 5 6 7 8}}
364 }
365357 test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup {
366358 .c delete all
367359 imageCleanup
384376 } -cleanup {
385377 .c delete all
386378 imageCleanup
387 } -result $result_9_1
388 if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
389 # Aqua >= 10.14 will redraw the entire image.
390 set result_9_2 {{foo display 0 0 30 15} {foo display 0 0 30 15}}
391 } else {
392 set result_9_2 {{foo display 5 6 25 9} {foo display 0 0 12 14}}
393 }
379 } -result {{foo display 5 6 7 8}}
380
394381 test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup {
395382 .c delete all
396383 imageCleanup
410397 } -cleanup {
411398 .c delete all
412399 imageCleanup
413 } -result $result_9_2
400 } -result {{foo display 5 6 25 9} {foo display 0 0 12 14}}
414401
415402 test image-10.1 {Tk_GetImage procedure} -setup {
416403 imageCleanup
136136 } -result {image1 image1 0 0 #000000 {}}
137137
138138
139 test imageBmap-3.1 {ImgBmapConfigureMaster procedure, memory de-allocation} -body {
139 test imageBmap-3.1 {ImgBmapConfigureModel procedure, memory de-allocation} -body {
140140 image create bitmap i1 -data $data1
141141 i1 configure -data $data1
142142 } -cleanup {
143143 image delete i1
144144 } -result {}
145 test imageBmap-3.2 {ImgBmapConfigureMaster procedure} -body {
145 test imageBmap-3.2 {ImgBmapConfigureModel procedure} -body {
146146 image create bitmap i1 -data $data1
147147 list [catch {i1 configure -data bogus} msg] $msg [image width i1] \
148148 [image height i1]
149149 } -result {1 {format error in bitmap data} 16 16}
150 test imageBmap-3.3 {ImgBmapConfigureMaster procedure, memory de-allocation} -body {
150 test imageBmap-3.3 {ImgBmapConfigureModel procedure, memory de-allocation} -body {
151151 image create bitmap i1 -data $data1 -maskdata $data2
152152 i1 configure -maskdata $data2
153153 } -cleanup {
154154 image delete i1
155155 } -result {}
156 test imageBmap-3.4 {ImgBmapConfigureMaster procedure} -body {
156 test imageBmap-3.4 {ImgBmapConfigureModel procedure} -body {
157157 image create bitmap i1
158158 i1 configure -maskdata $data2
159159 } -returnCodes error -result {can't have mask without bitmap}
160 test imageBmap-3.5 {ImgBmapConfigureMaster procedure} -body {
160 test imageBmap-3.5 {ImgBmapConfigureModel procedure} -body {
161161 image create bitmap i1 -data $data1 -maskdata {
162162 #define foo_width 8
163163 #define foo_height 16
166166 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81};
167167 }
168168 } -returnCodes error -result {bitmap and mask have different sizes}
169 test imageBmap-3.6 {ImgBmapConfigureMaster procedure} -body {
169 test imageBmap-3.6 {ImgBmapConfigureModel procedure} -body {
170170 image create bitmap i1 -data $data1 -maskdata {
171171 #define foo_width 16
172172 #define foo_height 8
175175 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81};
176176 }
177177 } -returnCodes error -result {bitmap and mask have different sizes}
178 test imageBmap-3.7 {ImgBmapConfigureMaster procedure} -setup {
178 test imageBmap-3.7 {ImgBmapConfigureModel procedure} -setup {
179179 destroy .c
180180 pack [canvas .c]
181181 } -body {
502502 test imageBmap-12.1 {ImgBmapCmdDeletedProc procedure} -body {
503503 image create bitmap i2 -file foo.bm -maskfile foo2.bm
504504 rename i2 {}
505 list [lsearch -exact [imageNames] i2] [catch {i2 foo} msg] $msg
506 } -result {-1 1 {invalid command name "i2"}}
505 list [expr {"i2" in [imageNames]}] [catch {i2 foo} msg] $msg
506 } -result {0 1 {invalid command name "i2"}}
507507
508508 removeFile foo.bm
509509 removeFile foo2.bm
5858 set teapotPhotoFile [file join [file dirname [info script]] teapot.ppm]
5959 testConstraint hasTeapotPhoto [file exists $teapotPhotoFile]
6060
61 proc base64ok {} {
62 expr {
63 ![catch {package require base64}]
64 }
65 }
66
67 testConstraint base64PackageNeeded [base64ok]
68
6961 test imgPhoto-1.1 {options for photo images} -body {
7062 image create photo photo1 -width 79 -height 83
7163 list [photo1 cget -width] [photo1 cget -height] \
138130 # set msg
139131 # } {couldn't open "bogus.img": no such file or directory}
140132
141 test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} -constraints {
133 test imgPhoto-3.1 {ImgPhotoConfigureModel procedure} -constraints {
142134 hasTeapotPhoto
143135 } -body {
144136 image create photo photo1 -file $teapotPhotoFile
146138 } -cleanup {
147139 image delete photo1
148140 } -result {}
149 test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} -constraints {
141 test imgPhoto-3.2 {ImgPhotoConfigureModel procedure} -constraints {
150142 hasTeapotPhoto
151143 } -body {
152144 image create photo photo1 -file $teapotPhotoFile
155147 } -cleanup {
156148 image delete photo1
157149 } -result {1 {couldn't open "bogus": no such file or directory} 256 256}
158 test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} -constraints {
150 test imgPhoto-3.3 {ImgPhotoConfigureModel procedure} -constraints {
159151 hasTeapotPhoto
160152 } -setup {
161153 destroy .c
820812 file delete ./-teapotPhotoFile
821813 } -result {}
822814 test imgPhoto-4.76 {ImgPhotoCmd procedure: copy to same image} -constraints {
823 hasTeapotPhoto
815 hasTeapotPhoto
824816 } -setup {
825817 imageCleanup
826818 image create photo photo1 -file $teapotPhotoFile
959951 } -body {
960952 image create photo photo2 -file $teapotPhotoFile
961953 rename photo2 {}
962 list [lsearch -exact [imageNames] photo2] [catch {photo2 foo} msg] $msg
963 } -result {-1 1 {invalid command name "photo2"}}
954 list [expr {"photo2" in [imageNames]}] [catch {photo2 foo} msg] $msg
955 } -result {0 1 {invalid command name "photo2"}}
964956
965957 test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} -setup {
966958 imageCleanup
13051297 # Reject corrupted or truncated image [Bug b601ce3ab1].
13061298 # WARNING - tests 18.1-18.9 will cause a segfault on 8.5.19 and lower,
13071299 # and on 8.6.6 and lower.
1308 test imgPhoto-18.1 {Reject corrupted GIF (binary string)} -constraints {
1309 base64PackageNeeded
1310 } -setup {
1311 package require base64
1312 set data [base64::decode {
1300 test imgPhoto-18.1 {Reject corrupted GIF (binary string)} -setup {
1301 set data [binary decode base64 {
13131302 R0lGODlhAAQABP8zM/8z/zP/MzP/////M////yH5CiwheLrcLTBCd6Tv2qW16tdK4jhV
13141303 5qpraXIvM1JlNyAgOw==
13151304 }]
13351324 } -cleanup {
13361325 catch {image delete gif1}
13371326 } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp
1338 test imgPhoto-18.4 {Reject truncated GIF (binary string)} -constraints {
1339 base64PackageNeeded
1340 } -setup {
1341 package require base64
1342 set data [base64::decode {
1327 test imgPhoto-18.4 {Reject truncated GIF (binary string)} -setup {
1328 set data [binary decode base64 {
13431329 R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP///8=
13441330 }]
13451331 } -body {
13641350 catch {image delete gif1}
13651351 } -returnCodes error -result {error reading color map}
13661352 test imgPhoto-18.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints {
1367 base64PackageNeeded nonPortable
1353 nonPortable
13681354 } -setup {
13691355 # About the non portability constraint of this test: see ticket [cc42cc18a5]
13701356 # If there is insufficient memory, the error message
13711357 # {not enough free memory for image buffer} should be returned.
13721358 # Instead, some systems (e.g. FreeBSD 11.1) terminate the test interpreter.
1373 package require base64
1374 set data [base64::decode {
1359 set data [binary decode base64 {
13751360 R0lGODlhwmYz//8zM/8z/zP/MzP/////M////yH5Ciwhe
13761361 LrcLTBCd6Tv2qW16tdK4jhV5qpraXIvM1JlNyAgOw==
13771362 }]
14091394 } -cleanup {
14101395 catch {image delete gif1}
14111396 } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp
1412 test imgPhoto-18.10 {Valid GIF (binary string)} -constraints {
1413 base64PackageNeeded
1414 } -setup {
1397 test imgPhoto-18.10 {Valid GIF (binary string)} -setup {
14151398 # Test the binary string reader with a valid GIF.
14161399 # This is not tested elsewhere.
14171400 # Tests 18.11, 18.12, with matching data, are included for completeness.
1418 package require base64
1419 set data [base64::decode {
1401 set data [binary decode base64 {
14201402 R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP/////M////yH5BAEKAAcALAAA
14211403 AAAQABAAAAMheLrcLTBCd6QV79qlterXB0riOFXmmapraXIvM1IdZTcJADs=
14221404 }]
375375 test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} -body {
376376 .l activate -1
377377 .l index active
378 } -result {0}
378 } -result 0
379379 test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} -body {
380380 .l activate 30
381381 .l index active
382 } -result {17}
382 } -result 17
383383 test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} -body {
384384 .l activate end
385385 .l index active
386 } -result {17}
386 } -result 17
387387 test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} -body {
388388 .l bbox
389389 } -returnCodes error -result {wrong # args: should be ".l bbox index"}
507507 } -cleanup {
508508 destroy .top.l .top
509509 unset -nocomplain lres res
510 } -result {1}
510 } -result 1
511511 test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body {
512512 .l cget
513513 } -returnCodes error -result {wrong # args: should be ".l cget option"}
519519 } -returnCodes error -result {unknown option "-gorp"}
520520 test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body {
521521 .l cget -setgrid
522 } -result {0}
522 } -result 0
523523 test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body {
524524 llength [.l configure]
525 } -result {28}
525 } -result 28
526526 test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} -body {
527527 .l configure -gorp
528528 } -returnCodes error -result {unknown option "-gorp"}
586586 } -body {
587587 listbox .l2
588588 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
589 .l2 delete -3 2
589 .l2 delete -1 2
590590 .l2 get 0 end
591591 } -cleanup {
592592 destroy .l2
596596 } -body {
597597 listbox .l2
598598 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
599 .l2 delete -3 -1
599 .l2 delete -1 -1
600600 .l2 get 0 end
601601 } -cleanup {
602602 destroy .l2
683683 .l get -1
684684 } -result {}
685685 test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} -body {
686 .l get -2 -1
686 .l get -1 -1
687687 } -result {}
688688 test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} -body {
689 .l get -2 3
689 .l get -1 3
690690 } -result {el0 el1 el2 el3}
691691 test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} -body {
692692 .l get 12 end
782782 test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} -body {
783783 .l yview 3
784784 .l nearest 1000
785 } -result {7}
785 } -result 7
786786 test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} -body {
787787 .l scan a b
788788 } -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"}
829829 .l yview 7
830830 .l see 7
831831 .l index @0,0
832 } -result {7}
832 } -result 7
833833 test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} -body {
834834 .l yview 7
835835 .l see 11
836836 .l index @0,0
837 } -result {7}
837 } -result 7
838838 test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} -body {
839839 .l yview 7
840840 .l see 6
841841 .l index @0,0
842 } -result {6}
842 } -result 6
843843 test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} -body {
844844 .l yview 7
845845 .l see 5
846846 .l index @0,0
847 } -result {3}
847 } -result 3
848848 test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} -body {
849849 .l yview 7
850850 .l see 12
851851 .l index @0,0
852 } -result {8}
852 } -result 8
853853 test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} -body {
854854 .l yview 7
855855 .l see 13
856856 .l index @0,0
857 } -result {11}
857 } -result 11
858858 test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} -body {
859859 .l yview 7
860860 .l see -1
861861 .l index @0,0
862 } -result {0}
862 } -result 0
863863 test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} -body {
864864 .l yview 7
865865 .l see end
866866 .l index @0,0
867 } -result {13}
867 } -result 13
868868 test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} -body {
869869 .l yview 7
870870 .l see 322
871871 .l index @0,0
872 } -result {13}
872 } -result 13
873873 test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} -body {
874874 mkPartial
875875 .partial.l see 4
876876 .partial.l index @0,0
877 } -result {1}
877 } -result 1
878878 test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} -body {
879879 .l select a
880880 } -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
897897 test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} -body {
898898 .l selection anchor -1
899899 .l index anchor
900 } -result {0}
900 } -result 0
901901 test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} -body {
902902 .l selection anchor end
903903 .l index anchor
904 } -result {17}
904 } -result 17
905905 test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} -body {
906906 .l selection anchor 44
907907 .l index anchor
908 } -result {17}
908 } -result 17
909909 test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} -body {
910910 .l selection clear 0 end
911911 .l selection set 2 8
925925 test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} -body {
926926 .l selection set 0 end
927927 .l selection includes -1
928 } -result {0}
928 } -result 0
929929 test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} -body {
930930 .l selection clear 0 end
931931 .l selection set end
932932 .l selection includes end
933 } -result {1}
933 } -result 1
934934 test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} -body {
935935 .l selection set 0 end
936936 .l selection includes 44
937 } -result {0}
937 } -result 0
938938 test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} -setup {
939939 destroy .l2
940940 } -body {
942942 .l2 selection includes 0
943943 } -cleanup {
944944 destroy .l2
945 } -result {0}
945 } -result 0
946946 test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} -body {
947947 .l selection clear 0 end
948948 .l selection set 2
964964 } -returnCodes error -result {wrong # args: should be ".l size"}
965965 test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} -body {
966966 .l size
967 } -result {18}
967 } -result 18
968968 test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} -setup {
969969 destroy .l2
970970 } -body {
12411241 .l cget -highlightthickness
12421242 } -cleanup {
12431243 deleteWindows
1244 } -result {0}
1244 } -result 0
12451245 test listbox-4.3 {ConfigureListbox procedure} -setup {
12461246 deleteWindows
12471247 destroy .l
15721572 .l selection anchor 2
15731573 .l insert 2 A B
15741574 .l index anchor
1575 } -result {4}
1575 } -result 4
15761576 test listbox-6.3 {InsertEls procedure} -body {
15771577 .l delete 0 end
15781578 .l insert 0 a b c d e f g h i j
15791579 .l selection anchor 2
15801580 .l insert 3 A B
15811581 .l index anchor
1582 } -result {2}
1582 } -result 2
15831583 test listbox-6.4 {InsertEls procedure} -body {
15841584 .l delete 0 end
15851585 .l insert 0 a b c d e f g h i j
15871587 update
15881588 .l insert 2 A B
15891589 .l index @0,0
1590 } -result {5}
1590 } -result 5
15911591 test listbox-6.5 {InsertEls procedure} -body {
15921592 .l delete 0 end
15931593 .l insert 0 a b c d e f g h i j
15951595 update
15961596 .l insert 3 A B
15971597 .l index @0,0
1598 } -result {3}
1598 } -result 3
15991599 test listbox-6.6 {InsertEls procedure} -body {
16001600 .l delete 0 end
16011601 .l insert 0 a b c d e f g h i j
16021602 .l activate 5
16031603 .l insert 5 A B
16041604 .l index active
1605 } -result {7}
1605 } -result 7
16061606 test listbox-6.7 {InsertEls procedure} -body {
16071607 .l delete 0 end
16081608 .l insert 0 a b c d e f g h i j
16091609 .l activate 5
16101610 .l insert 6 A B
16111611 .l index active
1612 } -result {5}
1612 } -result 5
16131613 test listbox-6.8 {InsertEls procedure} -body {
16141614 .l delete 0 end
16151615 .l insert 0 a b c
16161616 .l index active
1617 } -result {2}
1617 } -result 2
16181618 test listbox-6.9 {InsertEls procedure} -body {
16191619 .l delete 0 end
16201620 .l insert 0
16211621 .l index active
1622 } -result {0}
1622 } -result 0
16231623 test listbox-6.10 {InsertEls procedure} -body {
16241624 .l delete 0 end
16251625 .l insert 0 a b "two words" c d e f g h i j
17271727 .l selection anchor 2
17281728 .l delete 0 1
17291729 .l index anchor
1730 } -result {0}
1730 } -result 0
17311731 test listbox-7.6 {DeleteEls procedure} -body {
17321732 .l delete 0 end
17331733 .l insert 0 a b c d e f g h i j
17341734 .l selection anchor 2
17351735 .l delete 2
17361736 .l index anchor
1737 } -result {2}
1737 } -result 2
17381738 test listbox-7.7 {DeleteEls procedure} -body {
17391739 .l delete 0 end
17401740 .l insert 0 a b c d e f g h i j
17411741 .l selection anchor 4
17421742 .l delete 2 5
17431743 .l index anchor
1744 } -result {2}
1744 } -result 2
17451745 test listbox-7.8 {DeleteEls procedure} -body {
17461746 .l delete 0 end
17471747 .l insert 0 a b c d e f g h i j
17481748 .l selection anchor 3
17491749 .l delete 4 5
17501750 .l index anchor
1751 } -result {3}
1751 } -result 3
17521752 test listbox-7.9 {DeleteEls procedure} -body {
17531753 .l delete 0 end
17541754 .l insert 0 a b c d e f g h i j
17561756 update
17571757 .l delete 1 2
17581758 .l index @0,0
1759 } -result {1}
1759 } -result 1
17601760 test listbox-7.10 {DeleteEls procedure} -body {
17611761 .l delete 0 end
17621762 .l insert 0 a b c d e f g h i j
17641764 update
17651765 .l delete 3 4
17661766 .l index @0,0
1767 } -result {3}
1767 } -result 3
17681768 test listbox-7.11 {DeleteEls procedure} -body {
17691769 .l delete 0 end
17701770 .l insert 0 a b c d e f g h i j
17721772 update
17731773 .l delete 4 6
17741774 .l index @0,0
1775 } -result {3}
1775 } -result 3
17761776 test listbox-7.12 {DeleteEls procedure} -body {
17771777 .l delete 0 end
17781778 .l insert 0 a b c d e f g h i j
17801780 update
17811781 .l delete 3 end
17821782 .l index @0,0
1783 } -result {1}
1783 } -result 1
17841784 test listbox-7.13 {DeleteEls procedure, updating view with partial last line} -body {
17851785 mkPartial
17861786 .partial.l yview 8
17871787 update
17881788 .partial.l delete 10 13
17891789 .partial.l index @0,0
1790 } -result {7}
1790 } -result 7
17911791 test listbox-7.14 {DeleteEls procedure} -body {
17921792 .l delete 0 end
17931793 .l insert 0 a b c d e f g h i j
17941794 .l activate 6
17951795 .l delete 3 4
17961796 .l index active
1797 } -result {4}
1797 } -result 4
17981798 test listbox-7.15 {DeleteEls procedure} -body {
17991799 .l delete 0 end
18001800 .l insert 0 a b c d e f g h i j
18011801 .l activate 6
18021802 .l delete 5 7
18031803 .l index active
1804 } -result {5}
1804 } -result 5
18051805 test listbox-7.16 {DeleteEls procedure} -body {
18061806 .l delete 0 end
18071807 .l insert 0 a b c d e f g h i j
18081808 .l activate 6
18091809 .l delete 5 end
18101810 .l index active
1811 } -result {4}
1811 } -result 4
18121812 test listbox-7.17 {DeleteEls procedure} -body {
18131813 .l delete 0 end
18141814 .l insert 0 a b c d e f g h i j
18151815 .l activate 6
18161816 .l delete 0 end
18171817 .l index active
1818 } -result {0}
1818 } -result 0
18191819 test listbox-7.18 {DeleteEls procedure} -body {
18201820 .l delete 0 end
18211821 .l insert 0 a b c "two words" d e f g h i j
19861986 .l index end
19871987 } -cleanup {
19881988 destroy .l
1989 } -result {12}
1989 } -result 12
19901990 test listbox-10.6 {GetListboxIndex procedure} -setup {
19911991 destroy .l
19921992 } -body {
21012101 .l index 3
21022102 } -cleanup {
21032103 destroy .l
2104 } -result {3}
2104 } -result 3
21052105 test listbox-10.17 {GetListboxIndex procedure} -setup {
21062106 destroy .l
21072107 } -body {
21112111 .l index 20
21122112 } -cleanup {
21132113 destroy .l
2114 } -result {20}
2114 } -result 20
21152115 test listbox-10.18 {GetListboxIndex procedure} -setup {
21162116 destroy .l
21172117 } -body {
21282128 pack [listbox .l]
21292129 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
21302130 update
2131 .l index -2
2132 } -cleanup {
2133 destroy .l
2134 } -result -2
2131 .l index -1
2132 } -cleanup {
2133 destroy .l
2134 } -result -1
21352135 test listbox-10.20 {GetListboxIndex procedure} -setup {
21362136 destroy .l
21372137 } -body {
22252225 .partial.l index @0,0
22262226 } -cleanup {
22272227 destroy .l
2228 } -result {11}
2228 } -result 11
22292229
22302230
22312231 # Listbox used in 12.* tests
23132313 test listbox-14.1 {NearestListboxElement procedure, partial last line} -body {
23142314 mkPartial
23152315 .partial.l nearest [winfo height .partial.l]
2316 } -result {4}
2316 } -result 4
23172317 # Listbox used in 14.* tests
23182318 destroy .l
23192319 listbox .l -font $fixed -width 20 -height 10
23252325 fonts
23262326 } -body {
23272327 .l index @50,0
2328 } -result {4}
2328 } -result 4
23292329 test listbox-14.3 {NearestListboxElement procedure} -constraints {
23302330 fonts
23312331 } -body {
23352335 fonts
23362336 } -body {
23372337 .l index @50,200
2338 } -result {13}
2338 } -result 13
23392339
23402340
23412341 # Listbox used in 15.* 16.* and 17.* tests
23772377 .l delete 0 end
23782378 .l insert 0 a b c d e f
23792379 .l select clear 0 end
2380 .l select set -2 -1
2380 .l select set -1 -1
23812381 .l curselection
23822382 } -result {}
23832383 test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} -body {
24142414 .l select clear 0 end
24152415 .l select set end 30
24162416 .l curselection
2417 } -result {5}
2417 } -result 5
24182418 test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} -body {
24192419 .l delete 0 end
24202420 .l insert 0 a b c d e f
24502450 string compare 1$long\n2$long\n3$long\n4$long\n5$long $sel
24512451 } -cleanup {
24522452 catch {unset long sel}
2453 } -result {0}
2453 } -result 0
24542454
24552455
24562456 test listbox-17.1 {ListboxLostSelection procedure} -setup {
26612661 test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
26622662 destroy .l
26632663 } -body {
2664 set x {}
2665 listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
2666 pack .l
2667 update idletasks
2668 set log {}
2669 lappend x "0000000000"
2670 update idletasks
2671 lappend x "00000000000000000000"
2672 update idletasks
2673 set log
2674 } -cleanup {
2675 destroy .l
2676 } -result [list {x 0 1} {x 0 0.5}]
2677 test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
2678 destroy .l
2679 } -body {
26642680 catch {unset x}
26652681 listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
2682 pack .l
2683 update idletasks
26662684 set log {}
2667 pack .l
2668 set timeout [after 500 {set log timeout}]
2669 vwait log
26702685 lappend x "0000000000"
2671 update
2686 update idletasks
26722687 lappend x "00000000000000000000"
2673 update
2688 update idletasks
2689 set x [list "0000000000"]
2690 update idletasks
26742691 set log
26752692 } -cleanup {
26762693 destroy .l
2677 after cancel $timeout
2678 } -result [list {x 0 1} {x 0 1} {x 0 0.5}]
2679 test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
2680 destroy .l
2681 } -body {
2682 catch {unset x}
2683 listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
2684 set log {}
2685 pack .l
2686 set timeout [after 500 {set log timeout}]
2687 vwait log
2688 lappend x "0000000000"
2689 update
2690 lappend x "00000000000000000000"
2691 update
2692 set x [list "0000000000"]
2693 update
2694 set log
2695 } -cleanup {
2696 destroy .l
2697 after cancel timeout
2698 } -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
2694 } -result [list {x 0 1} {x 0 0.5} {x 0 1}]
26992695 test listbox-21.11 {ListboxListVarProc, bad list} -setup {
27002696 destroy .l
27012697 } -body {
27632759 update
27642760 set log {}
27652761 pack .l
2766 set timeout [after 500 {set log timeout}]
2762 set timeout [after 500 {lappend log timeout3}]
27672763 vwait log
27682764 update
27692765 lappend x a b c d e f
28002796 destroy .l
28012797 } -body {
28022798 listbox .l -font $fixed -width 10 -xscrollcommand "record x"
2799 pack .l
2800 update idletasks
28032801 set log {}
2804 pack .l
2805 set timeout [after 500 {set log timeout}]
2802 set timeout [after 500 {lappend log timeout4}]
2803 .l insert end "0000000000"
28062804 vwait log
2807 .l insert end "0000000000"
2808 update
28092805 .l insert end "00000000000000000000"
28102806 vwait log
28112807 set log
28122808 } -cleanup {
28132809 destroy .l
28142810 after cancel $timeout
2815 } -result [list {x 0 1} {x 0 1} {x 0 0.5}]
2811 } -result [list {x 0 1} {x 0 0.5}]
28162812
28172813
28182814 # ConfigureListboxItem
32203216 # cleanup
32213217 cleanupTests
32223218 return
3223
3224
3225
3226
3227
5454 removeFile script
5555 } -result "script {} 0\n0\n"
5656
57 # Procedure to simulate interactive typing of commands, line by line,
57 # Procedure to simulate interactive typing of commands, line by line,
5858 # for test 2.3
5959 proc type {chan script} {
6060 foreach line [split $script \n] {
9393 test main-3.1 {Tk_ParseArgv: -help option} -constraints unix -body {
9494 # Run only on unix as Win32 pops up native dialog
9595 exec [interpreter] -help
96 } -returnCodes error -match glob -result {% application-specific initialization failed: Command-specific options:*}
96 } -returnCodes error -match glob -result {*application-specific initialization failed: Command-specific options:*}
9797
9898 test main-3.2 {Tk_ParseArgv: -help option} -setup {
9999 set maininterp [interp create]
275275 # We need to test all of the options with all of the different types of
276276 # menu entries. The following code sets up .m1 with 6 items. It then
277277 # runs through the 2.31 - 2.228 tests below
278 # index 0 is tearoff, 1 command, 2 cascade, 3 separator, 4 checkbutton,
278 # index 0 is tearoff, 1 command, 2 cascade, 3 separator, 4 checkbutton,
279279 # 5 radiobutton
280280 deleteWindows
281281 menu .m1 -tearoff 1
770770 } -returnCodes error -result {image "bogus" doesn't exist}
771771
772772 test menu-2.133 {entry configuration options 0 -image {} tearoff} -body {
773 .m1 entryconfigure 0 -image
773 .m1 entryconfigure 0 -image
774774 } -returnCodes error -result {unknown option "-image"}
775775
776776 test menu-2.134 {entry configuration options 1 -image {} command} -setup {
777777 .m1 entryconfigure 1 -image {}
778778 } -body {
779 .m1 entryconfigure 1 -image
779 .m1 entryconfigure 1 -image
780780 lindex [.m1 entryconfigure 1 -image] 4
781781 } -result {}
782782
783783 test menu-2.135 {entry configuration options 2 -image {} cascade} -setup {
784784 .m1 entryconfigure 2 -image {}
785785 } -body {
786 .m1 entryconfigure 2 -image
786 .m1 entryconfigure 2 -image
787787 lindex [.m1 entryconfigure 2 -image] 4
788788 } -result {}
789789
790790 test menu-2.136 {entry configuration options 3 -image {} separator} -body {
791 .m1 entryconfigure 3 -image
791 .m1 entryconfigure 3 -image
792792 } -returnCodes error -result {unknown option "-image"}
793793
794794 test menu-2.137 {entry configuration options 4 -image {} checkbutton} -body {
795 .m1 entryconfigure 4 -image
795 .m1 entryconfigure 4 -image
796796 lindex [.m1 entryconfigure 4 -image] 4
797797 } -result {}
798798
799799 test menu-2.138 {entry configuration options 5 -image {} radiobutton} -body {
800 .m1 entryconfigure 5 -image
800 .m1 entryconfigure 5 -image
801801 lindex [.m1 entryconfigure 5 -image] 4
802802 } -result {}
803803
10511051 } -returnCodes error -result {image "bogus" doesn't exist}
10521052
10531053 test menu-2.193 {entry configuration options 0 -selectimage {} tearoff} -body {
1054 .m1 entryconfigure 0 -selectimage
1054 .m1 entryconfigure 0 -selectimage
10551055 } -returnCodes error -result {unknown option "-selectimage"}
10561056
10571057 test menu-2.194 {entry configuration options 1 -selectimage {} command} -body {
1058 .m1 entryconfigure 1 -selectimage
1058 .m1 entryconfigure 1 -selectimage
10591059 } -returnCodes error -result {unknown option "-selectimage"}
10601060
10611061 test menu-2.195 {entry configuration options 2 -selectimage {} cascade} -body {
1062 .m1 entryconfigure 2 -selectimage
1062 .m1 entryconfigure 2 -selectimage
10631063 } -returnCodes error -result {unknown option "-selectimage"}
10641064
10651065 test menu-2.196 {entry configuration options 3 -selectimage {} separator} -body {
1066 .m1 entryconfigure 3 -selectimage
1066 .m1 entryconfigure 3 -selectimage
10671067 } -returnCodes error -result {unknown option "-selectimage"}
10681068
10691069 test menu-2.197 {entry configuration options 4 -selectimage {} checkbutton} -body {
1070 .m1 entryconfigure 4 -selectimage
1070 .m1 entryconfigure 4 -selectimage
10711071 lindex [.m1 entryconfigure 4 -selectimage] 4
10721072 } -result {}
10731073
10741074 test menu-2.198 {entry configuration options 5 -selectimage {} radiobutton} -body {
1075 .m1 entryconfigure 5 -selectimage
1075 .m1 entryconfigure 5 -selectimage
10761076 lindex [.m1 entryconfigure 5 -selectimage] 4
10771077 } -result {}
10781078
12241224 destroy .m1
12251225 } -returnCodes error -result {wrong # args: should be ".m1 option ?arg ...?"}
12261226 test menu-3.2 {MenuWidgetCmd, Tcl_Preserve and Tcl_Release} -constraints {
1227 nonUnixUserInteraction
1227 nonUnixUserInteraction
12281228 } -setup {
12291229 destroy .m1
12301230 } -body {
12361236 } -returnCodes ok -result {}
12371237 test menu-3.3 {MenuWidgetCmd procedure, "activate" option} -setup {
12381238 destroy .m1
1239 } -body {
1239 } -body {
12401240 menu .m1
12411241 .m1 add command -label "test"
12421242 .m1 activate
14131413 } -body {
14141414 menu .m1
14151415 .m1 add command -label "foo"
1416 .m1 delete 1 0
1416 .m1 delete 1 0
14171417 } -cleanup {
14181418 destroy .m1
14191419 } -result {}
16261626 nonUnixUserInteraction
16271627 } -setup {
16281628 destroy .m1
1629 } -body {
1629 } -body {
16301630 menu .m1
16311631 .m1 add command -label "menu-3.53: hit Escape" -command "puts hello"
16321632 .m1 post 40 40
16531653 nonUnixUserInteraction
16541654 } -setup {
16551655 destroy .m1 .m2
1656 } -body {
1656 } -body {
16571657 menu .m1
16581658 .m1 add command -label "menu-3.56 - hit Escape"
16591659 menu .m2
17551755 nonUnixUserInteraction
17561756 } -setup {
17571757 destroy .m1
1758 } -body {
1758 } -body {
17591759 menu .m1
17601760 .m1 add command -label "menu-3.68 - hit Escape"
1761 .m1 post 40 40
1761 .m1 post 40 40
17621762 .m1 unpost
17631763 } -cleanup {
17641764 destroy .m1
18971897 } -body {
18981898 catch {unset foo}
18991899 menu .m1
1900 .m1 add checkbutton -label "test" -variable foo(1) -onvalue on
1900 .m1 add checkbutton -label "test" -variable foo(1) -onvalue on
19011901 list [catch {.m1 invoke 1} msg] $msg [catch {set foo(1)} msg2] $msg2 [catch {unset foo} msg3] $msg3
19021902 } -cleanup {
19031903 destroy .m1
19651965 } -body {
19661966 menu .m1
19671967 .m1 add cascade -label "test" -menu .m1.m2
1968 list [catch {.m1 invoke 1} msg] $msg
1968 list [catch {.m1 invoke 1} msg] $msg
19691969 } -cleanup {
19701970 destroy .m1
19711971 } -result {0 {}}
20512051 set tearoff2 [tk::TearOffMenu .m1]
20522052 list [destroy $tearoff1] [destroy .m1]
20532053 } -returnCodes ok -result {{} {}}
2054 test menu-5.9 {DestroyMenuInstace - master menu} -setup {
2054 test menu-5.9 {DestroyMenuInstace - main menu} -setup {
20552055 destroy .m1
20562056 } -body {
20572057 menu .m1
21222122 destroy .m1
21232123 } -cleanup {
21242124 deleteWindows
2125 } -returnCodes ok
2125 } -returnCodes ok
21262126 test menu-6.5 {TkDestroyMenu} -setup {
21272127 destroy .m1 .m2
21282128 } -body {
23492349 menu .m1
23502350 .m1 add checkbutton -variable foo
23512351 list [.m1 delete 1] [destroy .m1]
2352 } -result {{} {}}
2352 } -result {{} {}}
23532353 test menu-8.5 {DestroyMenuEntry} -setup {
23542354 destroy .m1
23552355 } -body {
23812381 destroy .m1
23822382 } -body {
23832383 menu .m1
2384 list [.m1 configure -postcommand "beep"] [.m1 cget -postcommand]
2384 list [.m1 configure -postcommand "beep"] [.m1 cget -postcommand]
23852385 } -cleanup {
23862386 deleteWindows
23872387 } -result {{} beep}
25142514 test menu-11.4 {ConfigureMenuEntry} -setup {
25152515 deleteWindows
25162516 } -body {
2517 menu .m1
2517 menu .m1
25182518 .m1 add command
25192519 list [.m1 entryconfigure 1 -accel "S"] [.m1 entrycget 1 -accel]
25202520 } -cleanup {
25882588 deleteWindows
25892589 } -body {
25902590 menu .m1
2591 menu .m2
2591 menu .m2
25922592 .m2 add cascade -menu .m1
2593 menu .m3
2593 menu .m3
25942594 .m3 add cascade -menu .m1
2595 menu .m4
2595 menu .m4
25962596 .m4 add cascade -menu .m1
2597 menu .m5
2597 menu .m5
25982598 .m5 add cascade
25992599 .m5 entryconfigure 1 -label "test" -menu .m1
26002600 } -cleanup {
26042604 deleteWindows
26052605 } -body {
26062606 menu .m1
2607 menu .m2
2607 menu .m2
26082608 .m2 add cascade -menu .m1
2609 menu .m3
2609 menu .m3
26102610 .m3 add cascade -menu .m1
2611 menu .m4
2611 menu .m4
26122612 .m4 add cascade -menu .m1
26132613 .m3 entryconfigure 1 -label "test" -menu .m1
26142614 } -cleanup {
32353235
32363236 test menu-19.1 {TkPostCommand} -constraints nonUnixUserInteraction -setup {
32373237 deleteWindows
3238 } -body {
3238 } -body {
32393239 menu .m1 -postcommand "set menu_test menu-19.1"
32403240 .m1 add command -label "menu-19.1 - hit Escape"
32413241 list [.m1 post 40 40] [.m1 unpost] [set menu_test]
32443244 } -result {menu-19.1 {} menu-19.1}
32453245 test menu-19.2 {TkPostCommand} -constraints nonUnixUserInteraction -setup {
32463246 deleteWindows
3247 } -body {
3247 } -body {
32483248 menu .m1
32493249 .m1 add command -label "menu-19.2 - hit Escape"
32503250 list [.m1 post 40 40] [.m1 unpost]
37653765 test menu-32.2 {DeleteMenuCloneEntries} -setup {
37663766 deleteWindows
37673767 } -body {
3768
3768
37693769 menu .m1
37703770 .m1 add command -label one
37713771 .m1 add command -label two
7575 menu .m1 -disabledforeground ""
7676 } -cleanup {
7777 deleteWindows
78 } -result {.m1}
78 } -result {.m1}
7979
8080
8181 test menuDraw-6.1 {TkMenuConfigureEntryDrawOptions - no tkfont specified} -setup {
320320
321321
322322 test menuDraw-11.1 {TkMenuSelectImageProc - entry selected; redraw not pending} -constraints {
323 testImageType
323 testImageType
324324 } -setup {
325325 deleteWindows
326326 imageCleanup
337337 imageCleanup
338338 } -result {{} {}}
339339 test menuDraw-11.2 {TkMenuSelectImageProc - entry selected; redraw pending} -constraints {
340 testImageType
340 testImageType
341341 } -setup {
342342 deleteWindows
343343 imageCleanup
353353 imageCleanup
354354 } -result {{} {}}
355355 test menuDraw-11.3 {TkMenuSelectImageProc - entry not selected} -constraints {
356 testImageType
356 testImageType
357357 } -setup {
358358 deleteWindows
359359 imageCleanup
450450 deleteWindows
451451 } -result {}
452452 test menuDraw-12.6 {Display menu - testing for extra space and menubars} -constraints {
453 unix
453 unix
454454 } -setup {
455455 deleteWindows
456456 } -body {
667667 menu .m2
668668 .m2 add command -label "Hit ESCAPE to get rid of this menu"
669669 set tearoff [tk::TearOffMenu .m1 40 40]
670 $tearoff postcascade 0
670 $tearoff postcascade 0
671671 } -cleanup {
672672 deleteWindows
673673 } -result {}
393393 .mb1 configure -width 1i
394394 } -cleanup {
395395 deleteWindows
396 } -returnCodes error -result {expected integer but got "1i"}
396 } -returnCodes error -result {expected integer but got "1i"}
397397 test menubutton-4.2 {ConfigureMenuButton procedure} -setup {
398398 deleteWindows
399399 } -body {
450450 ".mb1 configure -width abc"}
451451
452452 test menubutton-4.7 {ConfigureMenuButton procedure} -constraints {
453 testImageType
453 testImageType
454454 } -setup {
455455 deleteWindows
456456 imageCleanup
463463 imageCleanup
464464 } -returnCodes error -result {bad screen distance "0.5x"}
465465 test menubutton-4.8 {ConfigureMenuButton procedure} -constraints {
466 testImageType
466 testImageType
467467 } -setup {
468468 deleteWindows
469469 imageCleanup
498498 deleteWindows
499499 } -body {
500500 menubutton .mb -text "Test"
501 .mb configure -direction badValue
501 .mb configure -direction badValue
502502 } -cleanup {
503503 deleteWindows
504504 } -returnCodes error -result {bad direction "badValue": must be above, below, flush, left, or right}
547547 set extraWidth 0
548548 }
549549 test menubutton-7.1 {ComputeMenuButtonGeometry procedure} -constraints {
550 testImageType
550 testImageType
551551 } -setup {
552552 deleteWindows
553553 image create test image1
560560 imageCleanup
561561 } -result [list [expr {38 + $extraWidth}] 23]
562562 test menubutton-7.2 {ComputeMenuButtonGeometry procedure} -constraints {
563 testImageType
563 testImageType
564564 } -setup {
565565 deleteWindows
566566 image create test image1
573573 imageCleanup
574574 } -result [list [expr {38 + $extraWidth}] 23]
575575 test menubutton-7.3 {ComputeMenuButtonGeometry procedure} -constraints {
576 testImageType
576 testImageType
577577 } -setup {
578578 deleteWindows
579579 image create test image1
586586 imageCleanup
587587 } -result [list [expr {38 + $extraWidth}] 23]
588588 test menubutton-7.4 {ComputeMenuButtonGeometry procedure} -constraints {
589 testImageType
589 testImageType
590590 } -setup {
591591 deleteWindows
592592 image create test image1
600600 imageCleanup
601601 } -result [list [expr {48 + $extraWidth}] 23]
602602 test menubutton-7.5 {ComputeMenuButtonGeometry procedure} -constraints {
603 testImageType
603 testImageType
604604 } -setup {
605605 deleteWindows
606606 image create test image1
1111 eval tcltest::configure $argv
1212
1313
14 test message-1.1 {configuration option: "anchor"} -setup {
15 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
14 test message-1.1 {configuration option: "anchor"} -setup {
15 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
1616 pack .m
1717 update
1818 } -body {
3131 destroy .m
3232 } -returnCodes {error} -result {bad anchor "bogus": must be n, ne, e, se, s, sw, w, nw, or center}
3333
34 test message-1.3 {configuration option: "aspect"} -setup {
35 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
36 pack .m
37 update
34 test message-1.3 {configuration option: "aspect"} -setup {
35 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
36 pack .m
37 update
3838 } -body {
3939 .m configure -aspect 3
4040 .m cget -aspect
5151 destroy .m
5252 } -returnCodes {error} -result {expected integer but got "bogus"}
5353
54 test message-1.5 {configuration option: "background"} -setup {
55 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
56 pack .m
57 update
54 test message-1.5 {configuration option: "background"} -setup {
55 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
56 pack .m
57 update
5858 } -body {
5959 .m configure -background #ff0000
6060 .m cget -background
7171 destroy .m
7272 } -returnCodes {error} -result {unknown color name "non-existent"}
7373
74 test message-1.7 {configuration option: "bd"} -setup {
75 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
76 pack .m
77 update
74 test message-1.7 {configuration option: "bd"} -setup {
75 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
76 pack .m
77 update
7878 } -body {
7979 .m configure -bd 4
8080 .m cget -bd
9191 destroy .m
9292 } -returnCodes {error} -result {bad screen distance "badValue"}
9393
94 test message-1.9 {configuration option: "bg"} -setup {
95 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
96 pack .m
97 update
98 } -body {
99 .m configure -bg #ff0000
94 test message-1.9 {configuration option: "bg"} -setup {
95 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
96 pack .m
97 update
98 } -body {
99 .m configure -bg #ff0000
100100 .m cget -bg
101101 } -cleanup {
102102 destroy .m
111111 destroy .m
112112 } -returnCodes {error} -result {unknown color name "non-existent"}
113113
114 test message-1.11 {configuration option: "borderwidth"} -setup {
115 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
116 pack .m
117 update
114 test message-1.11 {configuration option: "borderwidth"} -setup {
115 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
116 pack .m
117 update
118118 } -body {
119119 .m configure -borderwidth 1.3
120120 .m cget -borderwidth
131131 destroy .m
132132 } -returnCodes {error} -result {bad screen distance "badValue"}
133133
134 test message-1.13 {configuration option: "cursor"} -setup {
135 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
136 pack .m
137 update
134 test message-1.13 {configuration option: "cursor"} -setup {
135 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
136 pack .m
137 update
138138 } -body {
139139 .m configure -cursor arrow
140140 .m cget -cursor
151151 destroy .m
152152 } -returnCodes {error} -result {bad cursor spec "badValue"}
153153
154 test message-1.15 {configuration option: "fg"} -setup {
155 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
156 pack .m
157 update
154 test message-1.15 {configuration option: "fg"} -setup {
155 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
156 pack .m
157 update
158158 } -body {
159159 .m configure -fg #00ff00
160160 .m cget -fg
171171 destroy .m
172172 } -returnCodes {error} -result {unknown color name "badValue"}
173173
174 test message-1.17 {configuration option: "font"} -setup {
175 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
176 pack .m
177 update
174 test message-1.17 {configuration option: "font"} -setup {
175 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
176 pack .m
177 update
178178 } -body {
179179 .m configure -font fixed
180180 .m cget -font
191191 destroy .m
192192 } -returnCodes {error} -result {font "" doesn't exist}
193193
194 test message-1.19 {configuration option: "-foreground"} -setup {
195 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
196 pack .m
197 update
194 test message-1.19 {configuration option: "-foreground"} -setup {
195 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
196 pack .m
197 update
198198 } -body {
199199 .m configure -foreground green
200 .m cget -foreground
200 .m cget -foreground
201201 } -cleanup {
202202 destroy .m
203203 } -result {green}
211211 destroy .m
212212 } -returnCodes {error} -result {unknown color name "badValue"}
213213
214 test message-1.21 {configuration option: "highlightbackground"} -setup {
215 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
216 pack .m
217 update
214 test message-1.21 {configuration option: "highlightbackground"} -setup {
215 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
216 pack .m
217 update
218218 } -body {
219219 .m configure -highlightbackground #112233
220220 .m cget -highlightbackground
231231 destroy .m
232232 } -returnCodes {error} -result {unknown color name "ugly"}
233233
234 test message-1.23 {configuration option: "highlightcolor"} -setup {
235 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
236 pack .m
237 update
234 test message-1.23 {configuration option: "highlightcolor"} -setup {
235 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
236 pack .m
237 update
238238 } -body {
239239 .m configure -highlightcolor #123456
240 .m cget -highlightcolor
240 .m cget -highlightcolor
241241 } -cleanup {
242242 destroy .m
243243 } -result {#123456}
251251 destroy .m
252252 } -returnCodes {error} -result {unknown color name "non-existent"}
253253
254 test message-1.25 {configuration option: "highlightthickness"} -setup {
255 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
256 pack .m
257 update
254 test message-1.25 {configuration option: "highlightthickness"} -setup {
255 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
256 pack .m
257 update
258258 } -body {
259259 .m configure -highlightthickness 2
260 .m cget -highlightthickness
260 .m cget -highlightthickness
261261 } -cleanup {
262262 destroy .m
263263 } -result {2}
271271 destroy .m
272272 } -returnCodes {error} -result {bad screen distance "badValue"}
273273
274 test message-1.27 {configuration option: "justify"} -setup {
275 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
276 pack .m
277 update
274 test message-1.27 {configuration option: "justify"} -setup {
275 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
276 pack .m
277 update
278278 } -body {
279279 .m configure -justify right
280280 .m cget -justify
291291 destroy .m
292292 } -returnCodes {error} -result {bad justification "bogus": must be left, right, or center}
293293
294 test message-1.29 {configuration option: "padx"} -setup {
295 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
296 pack .m
297 update
294 test message-1.29 {configuration option: "padx"} -setup {
295 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
296 pack .m
297 update
298298 } -body {
299299 .m configure -padx 12m
300 .m cget -padx
300 .m cget -padx
301301 } -cleanup {
302302 destroy .m
303303 } -result {12m}
311311 destroy .m
312312 } -returnCodes {error} -result {bad screen distance "420x"}
313313
314 test message-1.31 {configuration option: "pady"} -setup {
315 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
316 pack .m
317 update
314 test message-1.31 {configuration option: "pady"} -setup {
315 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
316 pack .m
317 update
318318 } -body {
319319 .m configure -pady 12m
320320 .m cget -pady
331331 destroy .m
332332 } -returnCodes {error} -result {bad screen distance "420x"}
333333
334 test message-1.33 {configuration option: "relief"} -setup {
335 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
336 pack .m
337 update
334 test message-1.33 {configuration option: "relief"} -setup {
335 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
336 pack .m
337 update
338338 } -body {
339339 .m configure -relief ridge
340 .m cget -relief
340 .m cget -relief
341341 } -cleanup {
342342 destroy .m
343343 } -result {ridge}
351351 destroy .m
352352 } -returnCodes {error} -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
353353
354 test message-1.35 {configuration options: "text"} -setup {
355 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
356 pack .m
357 update
354 test message-1.35 {configuration options: "text"} -setup {
355 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
356 pack .m
357 update
358358 } -body {
359359 .m configure -text "Sample text"
360360 .m cget -text
362362 destroy .m
363363 } -result {Sample text}
364364
365 test message-1.36 {configuration option: "textvariable"} -setup {
366 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
367 pack .m
368 update
365 test message-1.36 {configuration option: "textvariable"} -setup {
366 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
367 pack .m
368 update
369369 } -body {
370370 .m configure -textvariable i
371 .m cget -textvariable
371 .m cget -textvariable
372372 } -cleanup {
373373 destroy .m
374374 } -result {i}
375375
376 test message-1.37 {configuration option: "width"} -setup {
377 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
378 pack .m
379 update
376 test message-1.37 {configuration option: "width"} -setup {
377 message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
378 pack .m
379 update
380380 } -body {
381381 .m configure -width 2
382 .m cget -width
382 .m cget -width
383383 } -cleanup {
384384 destroy .m
385385 } -result {2}
402402 message foo
403403 } -returnCodes {error} -result {bad window path name "foo"}
404404 test message-2.3 {Tk_MessageObjCmd procedure} -body {
405 catch {message foo}
405 catch {message foo}
406406 winfo child .
407407 } -result {}
408408
410410 message .s -gorp dump
411411 } -returnCodes {error} -result {unknown option "-gorp"}
412412 test message-2.5 {Tk_MessageObjCmd procedure} -body {
413 catch {message .s -gorp dump}
413 catch {message .s -gorp dump}
414414 winfo child .
415 } -result {}
415 } -result {}
416416
417417
418418 test message-3.1 {MessageWidgetObjCmd procedure} -setup {
419419 message .m
420420 } -body {
421 .m
421 .m
422422 } -cleanup {
423423 destroy .m
424424 } -returnCodes error -result {wrong # args: should be ".m option ?arg ...?"}
441441 message .m
442442 } -body {
443443 .m configure -text foobar
444 lindex [.m configure -text] 4
444 lindex [.m configure -text] 4
445445 } -cleanup {
446446 destroy .m
447447 } -result {foobar}
120120 # (type) x (icon).
121121 #
122122 test msgbox-2.1 {tk_messageBox command} -constraints {
123 nonUnixUserInteraction
123 nonUnixUserInteraction
124124 } -body {
125125 ChooseMsg . abort
126126 tk_messageBox -title Hi -message "Please press abort" -type abortretryignore
127127 } -result {abort}
128128 test msgbox-2.2 {tk_messageBox command -icon option} -constraints {
129 nonUnixUserInteraction
129 nonUnixUserInteraction
130130 } -body {
131131 ChooseMsg . abort
132132 tk_messageBox -title Hi -message "Please press abort" \
133133 -type abortretryignore -icon warning
134134 } -result {abort}
135135 test msgbox-2.3 {tk_messageBox command -icon option} -constraints {
136 nonUnixUserInteraction
136 nonUnixUserInteraction
137137 } -body {
138138 ChooseMsg . abort
139139 tk_messageBox -title Hi -message "Please press abort" \
140140 -type abortretryignore -icon error
141141 } -result {abort}
142142 test msgbox-2.4 {tk_messageBox command -icon option} -constraints {
143 nonUnixUserInteraction
143 nonUnixUserInteraction
144144 } -body {
145145 ChooseMsg . abort
146146 tk_messageBox -title Hi -message "Please press abort" \
147147 -type abortretryignore -icon info
148148 } -result {abort}
149149 test msgbox-2.5 {tk_messageBox command -icon option} -constraints {
150 nonUnixUserInteraction
150 nonUnixUserInteraction
151151 } -body {
152152 ChooseMsg . abort
153153 tk_messageBox -title Hi -message "Please press abort" \
154154 -type abortretryignore -icon question
155155 } -result {abort}
156156 test msgbox-2.6 {tk_messageBox command} -constraints {
157 nonUnixUserInteraction
157 nonUnixUserInteraction
158158 } -body {
159159 ChooseMsg . abort
160160 tk_messageBox -title Hi -message "Please press abort" \
161161 -type abortretryignore -default abort
162162 } -result {abort}
163163 test msgbox-2.7 {tk_messageBox command} -constraints {
164 nonUnixUserInteraction
164 nonUnixUserInteraction
165165 } -body {
166166 ChooseMsg . retry
167167 tk_messageBox -title Hi -message "Please press retry" \
168168 -type abortretryignore -default retry
169169 } -result {retry}
170170 test msgbox-2.8 {tk_messageBox command} -constraints {
171 nonUnixUserInteraction
171 nonUnixUserInteraction
172172 } -body {
173173 ChooseMsg . ignore
174174 tk_messageBox -title Hi -message "Please press ignore" \
175175 -type abortretryignore -default ignore
176176 } -result {ignore}
177177 test msgbox-2.9 {tk_messageBox command} -constraints {
178 nonUnixUserInteraction
178 nonUnixUserInteraction
179179 } -body {
180180 ChooseMsg . ok
181181 tk_messageBox -title Hi -message "Please press ok" -type ok
182182 } -result {ok}
183183 test msgbox-2.10 {tk_messageBox command -icon option} -constraints {
184 nonUnixUserInteraction
184 nonUnixUserInteraction
185185 } -body {
186186 ChooseMsg . ok
187187 tk_messageBox -title Hi -message "Please press ok" \
188188 -type ok -icon warning
189189 } -result {ok}
190190 test msgbox-2.11 {tk_messageBox command -icon option} -constraints {
191 nonUnixUserInteraction
191 nonUnixUserInteraction
192192 } -body {
193193 ChooseMsg . ok
194194 tk_messageBox -title Hi -message "Please press ok" \
195195 -type ok -icon error
196196 } -result {ok}
197197 test msgbox-2.12 {tk_messageBox command -icon option} -constraints {
198 nonUnixUserInteraction
198 nonUnixUserInteraction
199199 } -body {
200200 ChooseMsg . ok
201201 tk_messageBox -title Hi -message "Please press ok" \
202202 -type ok -icon info
203203 } -result {ok}
204204 test msgbox-2.13 {tk_messageBox command -icon option} -constraints {
205 nonUnixUserInteraction
205 nonUnixUserInteraction
206206 } -body {
207207 ChooseMsg . ok
208208 tk_messageBox -title Hi -message "Please press ok" \
209209 -type ok -icon question
210210 } -result {ok}
211211 test msgbox-2.14 {tk_messageBox command} -constraints {
212 nonUnixUserInteraction
212 nonUnixUserInteraction
213213 } -body {
214214 ChooseMsg . ok
215215 tk_messageBox -title Hi -message "Please press ok" \
216216 -type ok -default ok
217217 } -result {ok}
218218 test msgbox-2.15 {tk_messageBox command} -constraints {
219 nonUnixUserInteraction
219 nonUnixUserInteraction
220220 } -body {
221221 ChooseMsg . ok
222222 tk_messageBox -title Hi -message "Please press ok" -type okcancel
223223 } -result {ok}
224224 test msgbox-2.16 {tk_messageBox command -icon option} -constraints {
225 nonUnixUserInteraction
225 nonUnixUserInteraction
226226 } -body {
227227 ChooseMsg . ok
228228 tk_messageBox -title Hi -message "Please press ok" \
229229 -type okcancel -icon warning
230230 } -result {ok}
231231 test msgbox-2.17 {tk_messageBox command -icon option} -constraints {
232 nonUnixUserInteraction
232 nonUnixUserInteraction
233233 } -body {
234234 ChooseMsg . ok
235235 tk_messageBox -title Hi -message "Please press ok" \
236236 -type okcancel -icon error
237237 } -result {ok}
238238 test msgbox-2.18 {tk_messageBox command -icon option} -constraints {
239 nonUnixUserInteraction
239 nonUnixUserInteraction
240240 } -body {
241241 ChooseMsg . ok
242242 tk_messageBox -title Hi -message "Please press ok" \
243243 -type okcancel -icon info
244244 } -result {ok}
245245 test msgbox-2.19 {tk_messageBox command -icon option} -constraints {
246 nonUnixUserInteraction
246 nonUnixUserInteraction
247247 } -body {
248248 ChooseMsg . ok
249249 tk_messageBox -title Hi -message "Please press ok" \
250250 -type okcancel -icon question
251251 } -result {ok}
252252 test msgbox-2.20 {tk_messageBox command} -constraints {
253 nonUnixUserInteraction
253 nonUnixUserInteraction
254254 } -body {
255255 ChooseMsg . ok
256256 tk_messageBox -title Hi -message "Please press ok" \
257257 -type okcancel -default ok
258258 } -result {ok}
259259 test msgbox-2.21 {tk_messageBox command} -constraints {
260 nonUnixUserInteraction
260 nonUnixUserInteraction
261261 } -body {
262262 ChooseMsg . cancel
263263 tk_messageBox -title Hi -message "Please press cancel" \
264264 -type okcancel -default cancel
265265 } -result {cancel}
266266 test msgbox-2.22 {tk_messageBox command} -constraints {
267 nonUnixUserInteraction
267 nonUnixUserInteraction
268268 } -body {
269269 ChooseMsg . retry
270270 tk_messageBox -title Hi -message "Please press retry" -type retrycancel
271271 } -result {retry}
272272 test msgbox-2.23 {tk_messageBox command -icon option} -constraints {
273 nonUnixUserInteraction
273 nonUnixUserInteraction
274274 } -body {
275275 ChooseMsg . retry
276276 tk_messageBox -title Hi -message "Please press retry" \
277277 -type retrycancel -icon warning
278278 } -result {retry}
279279 test msgbox-2.24 {tk_messageBox command -icon option} -constraints {
280 nonUnixUserInteraction
280 nonUnixUserInteraction
281281 } -body {
282282 ChooseMsg . retry
283283 tk_messageBox -title Hi -message "Please press retry" \
284284 -type retrycancel -icon error
285285 } -result {retry}
286286 test msgbox-2.25 {tk_messageBox command -icon option} -constraints {
287 nonUnixUserInteraction
287 nonUnixUserInteraction
288288 } -body {
289289 ChooseMsg . retry
290290 tk_messageBox -title Hi -message "Please press retry" \
291291 -type retrycancel -icon info
292292 } -result {retry}
293293 test msgbox-2.26 {tk_messageBox command -icon option} -constraints {
294 nonUnixUserInteraction
294 nonUnixUserInteraction
295295 } -body {
296296 ChooseMsg . retry
297297 tk_messageBox -title Hi -message "Please press retry" \
298298 -type retrycancel -icon question
299299 } -result {retry}
300300 test msgbox-2.27 {tk_messageBox command} -constraints {
301 nonUnixUserInteraction
301 nonUnixUserInteraction
302302 } -body {
303303 ChooseMsg . retry
304304 tk_messageBox -title Hi -message "Please press retry" \
305305 -type retrycancel -default retry
306306 } -result {retry}
307307 test msgbox-2.28 {tk_messageBox command} -constraints {
308 nonUnixUserInteraction
308 nonUnixUserInteraction
309309 } -body {
310310 ChooseMsg . cancel
311311 tk_messageBox -title Hi -message "Please press cancel" \
312312 -type retrycancel -default cancel
313313 } -result {cancel}
314314 test msgbox-2.29 {tk_messageBox command} -constraints {
315 nonUnixUserInteraction
315 nonUnixUserInteraction
316316 } -body {
317317 ChooseMsg . yes
318318 tk_messageBox -title Hi -message "Please press yes" -type yesno
319319 } -result {yes}
320320 test msgbox-2.30 {tk_messageBox command -icon option} -constraints {
321 nonUnixUserInteraction
321 nonUnixUserInteraction
322322 } -body {
323323 ChooseMsg . yes
324324 tk_messageBox -title Hi -message "Please press yes" \
325325 -type yesno -icon warning
326326 } -result {yes}
327327 test msgbox-2.31 {tk_messageBox command -icon option} -constraints {
328 nonUnixUserInteraction
328 nonUnixUserInteraction
329329 } -body {
330330 ChooseMsg . yes
331331 tk_messageBox -title Hi -message "Please press yes" \
332332 -type yesno -icon error
333333 } -result {yes}
334334 test msgbox-2.32 {tk_messageBox command -icon option} -constraints {
335 nonUnixUserInteraction
335 nonUnixUserInteraction
336336 } -body {
337337 ChooseMsg . yes
338338 tk_messageBox -title Hi -message "Please press yes" \
339339 -type yesno -icon info
340340 } -result {yes}
341341 test msgbox-2.33 {tk_messageBox command -icon option} -constraints {
342 nonUnixUserInteraction
342 nonUnixUserInteraction
343343 } -body {
344344 ChooseMsg . yes
345345 tk_messageBox -title Hi -message "Please press yes" \
346346 -type yesno -icon question
347347 } -result {yes}
348348 test msgbox-2.34 {tk_messageBox command} -constraints {
349 nonUnixUserInteraction
349 nonUnixUserInteraction
350350 } -body {
351351 ChooseMsg . yes
352352 tk_messageBox -title Hi -message "Please press yes" \
353353 -type yesno -default yes
354354 } -result {yes}
355355 test msgbox-2.35 {tk_messageBox command} -constraints {
356 nonUnixUserInteraction
356 nonUnixUserInteraction
357357 } -body {
358358 ChooseMsg . no
359359 tk_messageBox -title Hi -message "Please press no" \
360360 -type yesno -default no
361361 } -result {no}
362362 test msgbox-2.36 {tk_messageBox command} -constraints {
363 nonUnixUserInteraction
363 nonUnixUserInteraction
364364 } -body {
365365 ChooseMsg . yes
366366 tk_messageBox -title Hi -message "Please press yes" -type yesnocancel
367367 } -result {yes}
368368 test msgbox-2.37 {tk_messageBox command -icon option} -constraints {
369 nonUnixUserInteraction
369 nonUnixUserInteraction
370370 } -body {
371371 ChooseMsg . yes
372372 tk_messageBox -title Hi -message "Please press yes" \
373373 -type yesnocancel -icon warning
374374 } -result {yes}
375375 test msgbox-2.38 {tk_messageBox command -icon option} -constraints {
376 nonUnixUserInteraction
376 nonUnixUserInteraction
377377 } -body {
378378 ChooseMsg . yes
379379 tk_messageBox -title Hi -message "Please press yes" \
380380 -type yesnocancel -icon error
381381 } -result {yes}
382382 test msgbox-2.39 {tk_messageBox command -icon option} -constraints {
383 nonUnixUserInteraction
383 nonUnixUserInteraction
384384 } -body {
385385 ChooseMsg . yes
386386 tk_messageBox -title Hi -message "Please press yes" \
387387 -type yesnocancel -icon info
388388 } -result {yes}
389389 test msgbox-2.40 {tk_messageBox command -icon option} -constraints {
390 nonUnixUserInteraction
390 nonUnixUserInteraction
391391 } -body {
392392 ChooseMsg . yes
393393 tk_messageBox -title Hi -message "Please press yes" \
394394 -type yesnocancel -icon question
395395 } -result {yes}
396396 test msgbox-2.41 {tk_messageBox command} -constraints {
397 nonUnixUserInteraction
397 nonUnixUserInteraction
398398 } -body {
399399 ChooseMsg . yes
400400 tk_messageBox -title Hi -message "Please press yes" \
401401 -type yesnocancel -default yes
402402 } -result {yes}
403403 test msgbox-2.42 {tk_messageBox command} -constraints {
404 nonUnixUserInteraction
404 nonUnixUserInteraction
405405 } -body {
406406 ChooseMsg . no
407407 tk_messageBox -title Hi -message "Please press no" \
408408 -type yesnocancel -default no
409409 } -result {no}
410410 test msgbox-2.43 {tk_messageBox command} -constraints {
411 nonUnixUserInteraction
411 nonUnixUserInteraction
412412 } -body {
413413 ChooseMsg . cancel
414414 tk_messageBox -title Hi -message "Please press cancel" \
418418
419419 # These tests will hang your test suite if they fail.
420420 test msgbox-3.1 {tk_messageBox handles withdrawn parent} -constraints {
421 nonUnixUserInteraction
421 nonUnixUserInteraction
422422 } -body {
423423 wm withdraw .
424424 ChooseMsg . "ok"
429429 } -result {ok}
430430
431431 test msgbox-3.2 {tk_messageBox handles iconified parent} -constraints {
432 nonUnixUserInteraction
432 nonUnixUserInteraction
433433 } -body {
434434 wm iconify .
435435 ChooseMsg . "ok"
451451 } -returnCodes error -result {wrong # args: should be "pack option arg ?arg ...?"}
452452 test oldpack-8.3 {syntax errors} -body {
453453 pack gorp foo
454 } -returnCodes error -result {bad option "gorp": must be configure, forget, info, propagate, or slaves}
454 } -returnCodes error -result {bad option "gorp": must be configure, content, forget, info, propagate, or slaves}
455455 test oldpack-8.4 {syntax errors} -body {
456456 pack a .pack
457 } -returnCodes error -result {bad option "a": must be configure, forget, info, propagate, or slaves}
457 } -returnCodes error -result {bad option "a": must be configure, content, forget, info, propagate, or slaves}
458458 test oldpack-8.5 {syntax errors} -body {
459459 pack after foobar
460460 } -returnCodes error -result {bad window path name "foobar"}
526526 pack append .pack .pack.blue {top fillx frame n} \
527527 .pack.red {bottom filly frame s} .pack.green {left fill frame w} \
528528 .pack.violet {right expand frame e}
529 list [pack slaves .pack] [pack info .pack.blue] [pack info .pack.red] \
529 list [pack content .pack] [pack info .pack.blue] [pack info .pack.red] \
530530 [pack info .pack.green] [pack info .pack.violet]
531531 } -result {{.pack.blue .pack.red .pack.green .pack.violet} {-in .pack -anchor n -expand 0 -fill x -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top} {-in .pack -anchor s -expand 0 -fill y -ipadx 0 -ipady 0 -padx 0 -pady 0 -side bottom} {-in .pack -anchor w -expand 0 -fill both -ipadx 0 -ipady 0 -padx 0 -pady 0 -side left} {-in .pack -anchor e -expand 1 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side right}}
532532 test oldpack-9.2 {information output} -body {
533533 pack append .pack .pack.blue {padx 10 frame nw} \
534534 .pack.red {pady 20 frame ne} .pack.green {frame se} \
535535 .pack.violet {frame sw}
536 list [pack slaves .pack] [pack info .pack.blue] [pack info .pack.red] \
536 list [pack content .pack] [pack info .pack.blue] [pack info .pack.red] \
537537 [pack info .pack.green] [pack info .pack.violet]
538538 } -result {{.pack.blue .pack.red .pack.green .pack.violet} {-in .pack -anchor nw -expand 0 -fill none -ipadx 0 -ipady 0 -padx 5 -pady 0 -side top} {-in .pack -anchor ne -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 10 -side top} {-in .pack -anchor se -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top} {-in .pack -anchor sw -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top}}
539539 test oldpack-9.3 {information output} -body {
540540 pack append .pack .pack.blue {frame center} .pack.red {frame center} \
541541 .pack.green {frame c} .pack.violet {frame c}
542 list [pack slaves .pack] [pack info .pack.blue] [pack info .pack.red] \
542 list [pack content .pack] [pack info .pack.blue] [pack info .pack.red] \
543543 [pack info .pack.green] [pack info .pack.violet]
544544 } -result {{.pack.blue .pack.red .pack.green .pack.violet} {-in .pack -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top} {-in .pack -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top} {-in .pack -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top} {-in .pack -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top}}
545545
1212 *x 4: brown
1313 # More comments, this time delimited by hash-marks.
1414 # Comment-line with space.
15 *x6:
15 *x6:
1616 *x9: \ \ \\\101\n
1717 # comment line as last line of file.
1212 *x 4: brówn
1313 # More comments, this time delimited by hash-marks.
1414 # Comment-line with space.
15 *x6:
15 *x6:
1616 *x9: \ \ \\\101\n
1717 # comment line as last line of file.
284284
285285 # Test the major priority levels (widgetDefault, etc.)
286286
287 # Configurations for tests 13.*
287 # Configurations for tests 13.*
288288 option clear
289289 option add $appName.op1.a 100 100
290290 option add $appName.op1.A interactive interactive
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1315
1416 # Create some test windows.
1517
877879 } -body {
878880 pack .pack.a .pack.b .pack.c .pack.d -side top
879881 pack .pack.a -after .pack.b
880 pack slaves .pack
882 pack content .pack
881883 } -result {.pack.b .pack.a .pack.c .pack.d}
882884 test pack-9.2 {window ordering} -setup {
883885 pack forget .pack.a .pack.b .pack.c .pack.d
884886 } -body {
885887 pack .pack.a .pack.b .pack.c .pack.d -side top
886888 pack .pack.a -after .pack.a
887 pack slaves .pack
889 pack content .pack
888890 } -result {.pack.a .pack.b .pack.c .pack.d}
889891 test pack-9.3 {window ordering} -setup {
890892 pack forget .pack.a .pack.b .pack.c .pack.d
891893 } -body {
892894 pack .pack.a .pack.b .pack.c .pack.d -side top
893895 pack .pack.a -before .pack.d
894 pack slaves .pack
896 pack content .pack
895897 } -result {.pack.b .pack.c .pack.a .pack.d}
896898 test pack-9.4 {window ordering} -setup {
897899 pack forget .pack.a .pack.b .pack.c .pack.d
898900 } -body {
899901 pack .pack.a .pack.b .pack.c .pack.d -side top
900902 pack .pack.d -before .pack.a
901 pack slaves .pack
903 pack content .pack
902904 } -result {.pack.d .pack.a .pack.b .pack.c}
903905 test pack-9.5 {window ordering} -setup {
904906 pack forget .pack.a .pack.b .pack.c .pack.d
906908 pack .pack.a .pack.b .pack.c .pack.d -side top
907909 pack propagate .pack.c 0
908910 pack .pack.a -in .pack.c
909 list [pack slaves .pack] [pack slaves .pack.c]
911 list [pack content .pack] [pack content .pack.c]
910912 } -result {{.pack.b .pack.c .pack.d} .pack.a}
911913 test pack-9.6 {window ordering} -setup {
912914 pack forget .pack.a .pack.b .pack.c .pack.d
913915 } -body {
914916 pack .pack.a .pack.b .pack.c .pack.d -side top
915917 pack .pack.a -in .pack
916 pack slaves .pack
918 pack content .pack
917919 } -result {.pack.b .pack.c .pack.d .pack.a}
918920 test pack-9.7 {window ordering} -setup {
919921 pack forget .pack.a .pack.b .pack.c .pack.d
920922 } -body {
921923 pack .pack.a .pack.b .pack.c .pack.d -side top
922924 pack .pack.a -padx 0
923 pack slaves .pack
925 pack content .pack
924926 } -result {.pack.a .pack.b .pack.c .pack.d}
925927 test pack-9.8 {window ordering} -setup {
926928 pack forget .pack.a .pack.b .pack.c .pack.d
927929 } -body {
928930 pack .pack.a .pack.b .pack.c
929931 pack .pack.d
930 pack slaves .pack
932 pack content .pack
931933 } -result {.pack.a .pack.b .pack.c .pack.d}
932934 test pack-9.9 {window ordering} -setup {
933935 pack forget .pack.a .pack.b .pack.c .pack.d
934936 } -body {
935937 pack .pack.a .pack.b .pack.c .pack.d
936938 pack .pack.b .pack.d .pack.c -before .pack.a
937 pack slaves .pack
939 pack content .pack
938940 } -result {.pack.b .pack.d .pack.c .pack.a}
939941 test pack-9.10 {window ordering} -setup {
940942 pack forget .pack.a .pack.b .pack.c .pack.d
941943 } -body {
942944 pack .pack.a .pack.b .pack.c .pack.d
943945 pack .pack.a .pack.c .pack.d .pack.b -after .pack.a
944 pack slaves .pack
946 pack content .pack
945947 } -result {.pack.a .pack.c .pack.d .pack.b}
946948
947949
962964 pack .pack.a -pady 14
963965 pack info .pack.a
964966 } -result {-in .pack -anchor n -expand 1 -fill both -ipadx 3 -ipady 4 -padx 1 -pady 14 -side bottom}
965 test pack-10.3 {bad -in window does not change master} -setup {
967 test pack-10.3 {bad -in window does not change container window} -setup {
966968 pack forget .pack.a .pack.b .pack.c .pack.d
967969 } -body {
968970 set result [list [winfo manager .pack.a]]
969971 catch {pack .pack.a -in .pack.a}
970972 lappend result [winfo manager .pack.a]
971973 } -result {{} {}}
972 test pack-10.4 {bad -in window does not change master} -setup {
974 test pack-10.4 {bad -in window does not change container window} -setup {
973975 pack forget .pack.a .pack.b .pack.c .pack.d
974976 } -body {
975977 winfo manager .pack.a
11461148 pack forget .pack.a .pack.b .pack.c .pack.d
11471149 } -body {
11481150 pack configure .pack.b .pack.c
1149 pack slaves .pack
1151 pack content .pack
11501152 } -result {.pack.b .pack.c}
11511153 test pack-12.5 {command options and errors} -setup {
11521154 pack forget .pack.a .pack.b .pack.c .pack.d
13101312 } -body {
13111313 pack .pack.a .pack.b .pack.c .pack.d
13121314 pack forget .pack.a .pack.d
1313 pack slaves .pack
1315 pack content .pack
13141316 } -result {.pack.b .pack.c}
13151317 test pack-12.37 {command options and errors} -setup {
13161318 pack forget .pack.a .pack.b .pack.c .pack.d
13511353 test pack-12.42 {command options and errors} -setup {
13521354 pack forget .pack.a .pack.b .pack.c .pack.d
13531355 } -body {
1354 pack slaves
1356 pack content
13551357 } -returnCodes error -result {wrong # args: should be "pack option arg ?arg ...?"}
13561358 test pack-12.43 {command options and errors} -setup {
13571359 pack forget .pack.a .pack.b .pack.c .pack.d
13581360 } -body {
1359 pack slaves a b
1360 } -returnCodes error -result {wrong # args: should be "pack slaves window"}
1361 pack content a b
1362 } -returnCodes error -result {wrong # args: should be "pack content window"}
13611363 test pack-12.44 {command options and errors} -setup {
13621364 pack forget .pack.a .pack.b .pack.c .pack.d
13631365 } -body {
1364 pack slaves .x
1366 pack content .x
13651367 } -returnCodes error -result {bad window path name ".x"}
13661368 test pack-12.45 {command options and errors} -setup {
13671369 pack forget .pack.a .pack.b .pack.c .pack.d
13681370 } -body {
1369 pack slaves .pack.a
1371 pack content .pack.a
13701372 } -returnCodes ok -result {}
13711373 test pack-12.46 {command options and errors} -setup {
13721374 pack forget .pack.a .pack.b .pack.c .pack.d
13731375 } -body {
13741376 pack lousy .pack
1375 } -returnCodes error -result {bad option "lousy": must be configure, forget, info, propagate, or slaves}
1377 } -returnCodes error -result {bad option "lousy": must be configure, content, forget, info, propagate, or slaves}
13761378
13771379
13781380 test pack-13.1 {window deletion} -setup {
13841386 update
13851387 destroy .pack.d
13861388 update
1387 set result [list [pack slaves .pack] [winfo geometry .pack.a] \
1389 set result [list [pack content .pack] [winfo geometry .pack.a] \
13881390 [winfo geometry .pack.b] [winfo geometry .pack.c]]
13891391 } -result {{.pack.right .pack.bottom .pack.a .pack.b .pack.c} 20x40+30+0 50x30+15+40 80x80+0+70}
13901392
15271529 } -result {{} pack {}}
15281530
15291531
1530 test pack-17.1 {PackLostSlaveProc procedure} -setup {
1532 test pack-17.1 {PackLostContentProc procedure} -setup {
15311533 pack forget .pack.a .pack.b .pack.c .pack.d
15321534 } -body {
15331535 pack .pack.a
15361538 update
15371539 list [winfo manager .pack.a] [winfo geometry .pack.a]
15381540 } -result {place 20x40+40+10}
1539 test pack-17.2 {PackLostSlaveProc procedure} -setup {
1541 test pack-17.2 {PackLostContentProc procedure} -setup {
15401542 pack forget .pack.a .pack.b .pack.c .pack.d
15411543 } -body {
15421544 pack .pack.a
15481550 pack info .pack.a
15491551 } -returnCodes error -result {window ".pack.a" isn't packed}
15501552
1551
1552 test pack-18.1 {unmap slaves when master unmapped} -constraints {
1553 tempNotPc
1553 if {[tk windowingsystem] ne "aqua"} {
1554 proc packUpdate {} {
1555 update
1556 }
1557 } else {
1558 proc packUpdate {} {
1559 }
1560 }
1561
1562 test pack-18.1 {unmap content when container unmapped} -constraints {
1563 tempNotPc failsOnUbuntu failsOnXQuarz
15541564 } -setup {
15551565 eval destroy [winfo child .pack]
15561566 } -body {
15681578 eval destroy [winfo child .pack]
15691579 frame .pack.a -width 100 -height 50 -relief raised -bd 2
15701580 pack .pack.a
1571 update
1581 update idletasks
15721582 set result [winfo ismapped .pack.a]
15731583 wm iconify .pack
1574 update
15751584 lappend result [winfo ismapped .pack.a]
15761585 .pack.a configure -width 200 -height 75
1577 update
1586 update idletasks
15781587 lappend result [winfo width .pack.a ] [winfo height .pack.a] \
15791588 [winfo ismapped .pack.a]
15801589 wm deiconify .pack
1581 update
1590 packUpdate
15821591 lappend result [winfo ismapped .pack.a]
15831592 } -result {1 0 200 75 0 1}
1584 test pack-18.2 {unmap slaves when master unmapped} -setup {
1593
1594 test pack-18.2 {unmap content when container unmapped} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
15851595 eval destroy [winfo child .pack]
15861596 } -body {
15871597
15941604 frame .pack.b -width 70 -height 30 -relief sunken -bd 2
15951605 pack .pack.a
15961606 pack .pack.b -in .pack.a
1597 update
1607 update idletasks
15981608 set result [winfo ismapped .pack.b]
15991609 wm iconify .pack
1600 update
16011610 lappend result [winfo ismapped .pack.b]
16021611 .pack.b configure -width 100 -height 30
1603 update
1612 update idletasks
16041613 lappend result [winfo width .pack.b ] [winfo height .pack.b] \
16051614 [winfo ismapped .pack.b]
16061615 wm deiconify .pack
1607 update
1616 packUpdate
16081617 lappend result [winfo ismapped .pack.b]
16091618 } -result {1 0 100 30 0 1}
16101619
16111620
16121621 test pack-19.1 {test respect for internalborder} -setup {
1613 catch {eval pack forget [pack slaves .pack]}
1622 catch {eval pack forget [pack content .pack]}
16141623 destroy .pack.l .pack.lf
16151624 } -body {
16161625 wm geometry .pack 200x200
16281637 destroy .pack.l .pack.lf
16291638 } -result {196x188+2+10 177x186+5+7}
16301639 test pack-19.2 {test support for minreqsize} -setup {
1631 catch {eval pack forget [pack slaves .pack]}
1640 catch {eval pack forget [pack content .pack]}
16321641 destroy .pack.l .pack.lf
16331642 } -body {
16341643 wm geometry .pack {}
99 tcltest::loadTestedCommands
1010 namespace import -force tcltest::*
1111
12 test packgrid-1.1 {pack and grid in same master} -setup {
12 test packgrid-1.1 {pack and grid in same container window} -setup {
1313 grid propagate . true
1414 pack propagate . true
1515 label .p -text PACK
2323 destroy .g
2424 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
2525
26 test packgrid-1.2 {pack and grid in same master} -setup {
26 test packgrid-1.2 {pack and grid in same container window} -setup {
2727 grid propagate . true
2828 pack propagate . true
2929 label .p -text PACK
3737 destroy .g
3838 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
3939
40 test packgrid-1.3 {pack and grid in same master} -setup {
41 grid propagate . false
42 pack propagate . true
43 label .p -text PACK
44 label .g -text GRID
45 } -body {
46 # Ok if one is non-propagating
47 grid .g
48 pack .p
49 } -cleanup {
50 destroy .p
51 destroy .g
52 } -result {}
53
54 test packgrid-1.4 {pack and grid in same master} -setup {
55 grid propagate . false
56 pack propagate . true
57 label .p -text PACK
58 label .g -text GRID
59 } -body {
60 # Ok if one is non-propagating
61 pack .p
62 grid .g
63 } -cleanup {
64 destroy .p
65 destroy .g
66 } -result {}
67
68 test packgrid-1.5 {pack and grid in same master} -setup {
69 grid propagate . true
70 pack propagate . false
71 label .p -text PACK
72 label .g -text GRID
73 } -body {
74 # Ok if one is non-propagating
75 grid .g
76 pack .p
77 } -cleanup {
78 destroy .p
79 destroy .g
80 } -result {}
81
82 test packgrid-1.6 {pack and grid in same master} -setup {
83 grid propagate . true
84 pack propagate . false
85 label .p -text PACK
86 label .g -text GRID
87 } -body {
88 # Ok if one is non-propagating
89 pack .p
90 grid .g
91 } -cleanup {
92 destroy .p
93 destroy .g
94 } -result {}
95
96 test packgrid-1.7 {pack and grid in same master} -setup {
40 test packgrid-1.3 {pack and grid in same container window} -setup {
41 grid propagate . false
42 pack propagate . true
43 label .p -text PACK
44 label .g -text GRID
45 } -body {
46 # Ok if one is non-propagating
47 grid .g
48 pack .p
49 } -cleanup {
50 destroy .p
51 destroy .g
52 } -result {}
53
54 test packgrid-1.4 {pack and grid in same container window} -setup {
55 grid propagate . false
56 pack propagate . true
57 label .p -text PACK
58 label .g -text GRID
59 } -body {
60 # Ok if one is non-propagating
61 pack .p
62 grid .g
63 } -cleanup {
64 destroy .p
65 destroy .g
66 } -result {}
67
68 test packgrid-1.5 {pack and grid in same container window} -setup {
69 grid propagate . true
70 pack propagate . false
71 label .p -text PACK
72 label .g -text GRID
73 } -body {
74 # Ok if one is non-propagating
75 grid .g
76 pack .p
77 } -cleanup {
78 destroy .p
79 destroy .g
80 } -result {}
81
82 test packgrid-1.6 {pack and grid in same container window} -setup {
83 grid propagate . true
84 pack propagate . false
85 label .p -text PACK
86 label .g -text GRID
87 } -body {
88 # Ok if one is non-propagating
89 pack .p
90 grid .g
91 } -cleanup {
92 destroy .p
93 destroy .g
94 } -result {}
95
96 test packgrid-1.7 {pack and grid in same container window} -setup {
9797 grid propagate . true
9898 pack propagate . true
9999 label .p -text PACK
102102 # Basic conflict should stop widget from being handled
103103 grid .g
104104 catch { pack .p }
105 pack slaves .
106 } -cleanup {
107 destroy .p
108 destroy .g
109 } -result {}
110
111 test packgrid-1.8 {pack and grid in same master} -setup {
105 pack content .
106 } -cleanup {
107 destroy .p
108 destroy .g
109 } -result {}
110
111 test packgrid-1.8 {pack and grid in same container window} -setup {
112112 grid propagate . true
113113 pack propagate . true
114114 label .p -text PACK
117117 # Basic conflict should stop widget from being handled
118118 pack .p
119119 catch { grid .g }
120 grid slaves .
121 } -cleanup {
122 destroy .p
123 destroy .g
124 } -result {}
125
126 test packgrid-2.1 {pack and grid in same master, change propagation} -setup {
127 grid propagate . false
128 pack propagate . true
129 label .p -text PACK
130 label .g -text GRID
131 pack .p
132 grid .g
133 update
134 } -body {
135 grid propagate . true
136 } -returnCodes error -cleanup {
137 destroy .p
138 destroy .g
139 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
140
141 test packgrid-2.2 {pack and grid in same master, change propagation} -setup {
142 grid propagate . true
143 pack propagate . false
144 label .p -text PACK
145 label .g -text GRID
146 pack .p
147 grid .g
148 update
149 } -body {
150 pack propagate . true
151 } -returnCodes error -cleanup {
152 destroy .p
153 update
154 destroy .g
155 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
156
157 test packgrid-2.3 {pack and grid in same master, change propagation} -setup {
158 grid propagate . false
159 pack propagate . false
160 label .p -text PACK
161 label .g -text GRID
162 pack .p
163 grid .g
164 update
165 } -body {
166 grid propagate . true
167 update
168 pack propagate . true
169 } -returnCodes error -cleanup {
170 destroy .p
171 destroy .g
172 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
173
174 test packgrid-2.4 {pack and grid in same master, change propagation} -setup {
175 grid propagate . false
176 pack propagate . false
177 label .p -text PACK
178 label .g -text GRID
179 pack .p
180 grid .g
181 update
182 } -body {
183 pack propagate . true
184 grid propagate . true
185 } -returnCodes error -cleanup {
186 destroy .p
187 destroy .g
188 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
189
190 test packgrid-3.1 {stealing slave} -setup {
120 grid content .
121 } -cleanup {
122 destroy .p
123 destroy .g
124 } -result {}
125
126 test packgrid-2.1 {pack and grid in same container window, change propagation} -setup {
127 grid propagate . false
128 pack propagate . true
129 label .p -text PACK
130 label .g -text GRID
131 pack .p
132 grid .g
133 update
134 } -body {
135 grid propagate . true
136 } -returnCodes error -cleanup {
137 destroy .p
138 destroy .g
139 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
140
141 test packgrid-2.2 {pack and grid in same container window, change propagation} -setup {
142 grid propagate . true
143 pack propagate . false
144 label .p -text PACK
145 label .g -text GRID
146 pack .p
147 grid .g
148 update
149 } -body {
150 pack propagate . true
151 } -returnCodes error -cleanup {
152 destroy .p
153 update
154 destroy .g
155 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
156
157 test packgrid-2.3 {pack and grid in same container window, change propagation} -setup {
158 grid propagate . false
159 pack propagate . false
160 label .p -text PACK
161 label .g -text GRID
162 pack .p
163 grid .g
164 update
165 } -body {
166 grid propagate . true
167 update
168 pack propagate . true
169 } -returnCodes error -cleanup {
170 destroy .p
171 destroy .g
172 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
173
174 test packgrid-2.4 {pack and grid in same container window, change propagation} -setup {
175 grid propagate . false
176 pack propagate . false
177 label .p -text PACK
178 label .g -text GRID
179 pack .p
180 grid .g
181 update
182 } -body {
183 pack propagate . true
184 grid propagate . true
185 } -returnCodes error -cleanup {
186 destroy .p
187 destroy .g
188 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
189
190 test packgrid-3.1 {stealing content} -setup {
191191 grid propagate . true
192192 pack propagate . true
193193 label .p -text PACK
201201 destroy .g
202202 } -result {}
203203
204 test packgrid-3.2 {stealing slave} -setup {
204 test packgrid-3.2 {stealing content} -setup {
205205 grid propagate . true
206206 pack propagate . true
207207 label .p -text PACK
215215 destroy .g
216216 } -result {}
217217
218 test packgrid-3.3 {stealing slave} -setup {
218 test packgrid-3.3 {stealing content} -setup {
219219 grid propagate . true
220220 pack propagate . true
221221 label .p -text PACK
230230 destroy .g
231231 } -result {cannot use geometry manager pack inside . which already has slaves managed by grid}
232232
233 test packgrid-3.4 {stealing slave} -setup {
233 test packgrid-3.4 {stealing content} -setup {
234234 grid propagate . true
235235 pack propagate . true
236236 label .p -text PACK
245245 destroy .g
246246 } -result {cannot use geometry manager grid inside . which already has slaves managed by pack}
247247
248 test packgrid-4.1 {slave stolen after master destruction - bug [aa7679685e]} -setup {
248 test packgrid-4.1 {content stolen after container destruction - bug [aa7679685e]} -setup {
249249 frame .f
250250 button .b -text hello
251251 } -body {
260260 destroy .b
261261 } -result {}
262262
263 test packgrid-4.2 {slave stolen after master destruction - bug [aa7679685e]} -setup {
263 test packgrid-4.2 {content stolen after container destruction - bug [aa7679685e]} -setup {
264264 frame .f
265265 button .b -text hello
266266 } -body {
497497 .p add [frame .p.f]
498498 list [catch {.p sash coord -1} msg] $msg \
499499 [catch {.p sash coord 0} msg] $msg \
500 [catch {.p sash coord 1} msg] $msg
500 [catch {.p sash coord 1} msg] $msg
501501 } -cleanup {
502502 deleteWindows
503503 } -result [list 1 "invalid sash index" 1 "invalid sash index" 1 "invalid sash index"]
510510 list [catch {.p sash coord -1} msg] $msg \
511511 [catch {.p sash coord 0} msg] \
512512 [catch {.p sash coord 1} msg] $msg \
513 [catch {.p sash coord 2} msg] $msg
513 [catch {.p sash coord 2} msg] $msg
514514 } -cleanup {
515515 deleteWindows
516516 } -result [list 1 "invalid sash index" 0 1 "invalid sash index" 1 "invalid sash index"]
621621 } -cleanup {
622622 deleteWindows
623623 } -returnCodes error -result {expected integer but got "bar"}
624
624
625625
626626 test panedwindow-9.1 {sash mark/sash dragto interaction} -setup {
627627 deleteWindows
924924 } -cleanup {
925925 deleteWindows
926926 } -result {68 100}
927
927
928928
929929 test panedwindow-12.1 {horizontal panedwindow lays out widgets properly} -setup {
930930 deleteWindows
10211021 } -cleanup {
10221022 deleteWindows
10231023 } -result [list 20 20]
1024 test panedwindow-12.7 {horizontal panedwindow reqheight is max slave height} -setup {
1024 test panedwindow-12.7 {horizontal panedwindow reqheight is max pane height} -setup {
10251025 deleteWindows
10261026 } -body {
10271027 panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
10321032 } -cleanup {
10331033 deleteWindows
10341034 } -result {20 40}
1035 test panedwindow-12.8 {horizontal panedwindow reqheight is max slave height} -setup {
1035 test panedwindow-12.8 {horizontal panedwindow reqheight is max pane height} -setup {
10361036 deleteWindows
10371037 } -body {
10381038 panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
10861086 } -cleanup {
10871087 deleteWindows
10881088 } -result [list 20 20]
1089 test panedwindow-12.12 {vertical panedwindow reqwidth is max slave width} -setup {
1089 test panedwindow-12.12 {vertical panedwindow reqwidth is max pane width} -setup {
10901090 deleteWindows
10911091 } -body {
10921092 panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
10981098 } -cleanup {
10991099 deleteWindows
11001100 } -result {20 40}
1101 test panedwindow-12.13 {vertical panedwindow reqwidth is max slave width} -setup {
1101 test panedwindow-12.13 {vertical panedwindow reqwidth is max pane width} -setup {
11021102 deleteWindows
11031103 } -body {
11041104 panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
11321132 deleteWindows
11331133 } -body {
11341134 # Check that the panedwindow correctly yields geometry management of
1135 # a slave when the slave is destroyed.
1135 # a pane when the pane is destroyed.
11361136
11371137 # This test should not cause a core dump, and it should not cause
11381138 # a memory leak.
11431143 destroy .b
11441144 set result ""
11451145 } -result {}
1146 test panedwindow-13.2 {PanedWindowLostSlaveProc, widget yields management} -setup {
1146 test panedwindow-13.2 {PanedWindowLostPaneProc, widget yields management} -setup {
11471147 deleteWindows
11481148 } -body {
11491149 # Check that the paned window correctly yields geometry management of
1150 # a slave when some other geometry manager steals the slave from us.
1151
1150 # a pane when some other geometry manager steals the pane from us.
1151
11521152 # This test should not cause a core dump, and it should not cause a
11531153 # memory leak.
11541154 panedwindow .p
15171517
15181518 # Get the requested width of the paned window
15191519 lappend result [winfo reqwidth .p]
1520
1520
15211521 .p sash place 0 30 0
1522
1522
15231523 # Get the reqwidth again, to make sure it hasn't changed
15241524 lappend result [winfo reqwidth .p]
15251525
15371537 }
15381538
15391539 .p sash place 0 100 0
1540
1540
15411541 # Get the new sash coord; it should be clipped by the reqwidth of
15421542 # the panedwindow.
15431543 .p sash coord 0
15511551 foreach w {.f1 .f2} c {red blue} {
15521552 .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
15531553 }
1554
1554
15551555 # Put the panedwindow up on the display and give it a width < reqwidth
15561556 place .p -x 0 -y 0 -width 32
15571557 update
15581558
15591559 .p sash place 0 100 0
1560
1560
15611561 # Get the new sash coord; it should be clipped by the visible width of
15621562 # the panedwindow.
15631563 .p sash coord 0
15711571 foreach w {.f1 .f2} c {red blue} {
15721572 .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
15731573 }
1574
1574
15751575 # Put the panedwindow up on the display and give it a width > reqwidth
15761576 place .p -x 0 -y 0 -width 102
15771577 update
15781578
15791579 .p sash place 0 200 0
1580
1580
15811581 # Get the new sash coord; it should be clipped by the visible width of
15821582 # the panedwindow.
15831583 .p sash coord 0
15931593 }
15941594
15951595 .p sash place 0 100 0
1596
1596
15971597 # Get the new sash coord; it should have moved as far as possible while
15981598 # respecting minsizes.
15991599 .p sash coord 0
16091609 }
16101610
16111611 .p sash place 0 100 0
1612
1612
16131613 # Get the new sash coord; it should have moved as far as possible.
16141614 .p sash coord 0
16151615 } -cleanup {
16241624 }
16251625
16261626 .p sash place 0 100 0
1627
1627
16281628 # Get the new sash coord; it should have moved as far as possible while
16291629 # respecting minsizes.
16301630 .p sash coord 1
16401640 }
16411641
16421642 .p sash place 0 100 0
1643
1643
16441644 # Get the new sash coord; it should have moved as far as possible while
16451645 # respecting minsizes.
16461646 .p sash coord 1
16571657 }
16581658
16591659 .p sash place 0 100 0
1660
1661 # Get the new sash coord; it should have moved as far as possible,
1660
1661 # Get the new sash coord; it should have moved as far as possible,
16621662 # respecting minsizes.
16631663 .p sash coord 0
16641664 } -cleanup {
16741674 }
16751675
16761676 .p sash place 0 50 0
1677
1678 # Get the new sash coord; it should have moved as far as possible,
1677
1678 # Get the new sash coord; it should have moved as far as possible,
16791679 # respecting minsizes.
16801680 list [.p sash coord 0] [.p sash coord 1]
16811681 } -cleanup {
16921692
16931693 # Get the requested width of the paned window
16941694 lappend result [winfo reqwidth .p]
1695
1695
16961696 .p sash place 0 10 0
1697
1697
16981698 # Get the reqwidth again, to make sure it hasn't changed
16991699 lappend result [winfo reqwidth .p]
17001700
17121712 }
17131713
17141714 .p sash place 0 -100 0
1715
1715
17161716 # Get the new sash coord; it should be clipped by the reqwidth of
17171717 # the panedwindow.
17181718 .p sash coord 0
17281728 }
17291729
17301730 .p sash place 0 0 0
1731
1731
17321732 # Get the new sash coord; it should have moved as far as possible while
17331733 # respecting minsizes.
17341734 .p sash coord 0
17441744 }
17451745
17461746 .p sash place 1 0 0
1747
1747
17481748 # Get the new sash coord; it should have moved as far as possible.
17491749 .p sash coord 1
17501750 } -cleanup {
17591759 }
17601760
17611761 .p sash place 1 0 0
1762
1762
17631763 # Get the new sash coord; it should have moved as far as possible while
17641764 # respecting minsizes.
17651765 .p sash coord 0
17751775 }
17761776
17771777 .p sash place 1 0 0
1778
1778
17791779 # Get the new sash coord; it should have moved as far as possible while
17801780 # respecting minsizes.
17811781 .p sash coord 0
17921792 }
17931793
17941794 .p sash place 1 0 0
1795
1796 # Get the new sash coord; it should have moved as far as possible,
1795
1796 # Get the new sash coord; it should have moved as far as possible,
17971797 # respecting minsizes.
17981798 .p sash coord 1
17991799 } -cleanup {
18091809 }
18101810
18111811 .p sash place 1 10 0
1812
1813 # Get the new sash coord; it should have moved as far as possible,
1812
1813 # Get the new sash coord; it should have moved as far as possible,
18141814 # respecting minsizes.
18151815 list [.p sash coord 0] [.p sash coord 1]
18161816 } -cleanup {
18301830
18311831 # Get the requested width of the paned window
18321832 lappend result [winfo reqheight .p]
1833
1833
18341834 .p sash place 0 0 30
1835
1835
18361836 # Get the reqwidth again, to make sure it hasn't changed
18371837 lappend result [winfo reqheight .p]
18381838
18511851 }
18521852
18531853 .p sash place 0 0 100
1854
1854
18551855 # Get the new sash coord; it should be clipped by the reqheight of
18561856 # the panedwindow.
18571857 .p sash coord 0
18661866 foreach w {.f1 .f2} c {red blue} {
18671867 .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
18681868 }
1869
1869
18701870 # Put the panedwindow up on the display and give it a height < reqheight
18711871 place .p -x 0 -y 0 -height 32
18721872 update
18731873
18741874 .p sash place 0 0 100
1875
1875
18761876 # Get the new sash coord; it should be clipped by the visible height of
18771877 # the panedwindow.
18781878 .p sash coord 0
18871887 foreach w {.f1 .f2} c {red blue} {
18881888 .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
18891889 }
1890
1890
18911891 # Put the panedwindow up on the display and give it a width > reqwidth
18921892 place .p -x 0 -y 0 -height 102
18931893 update
18941894
18951895 .p sash place 0 0 200
1896
1896
18971897 # Get the new sash coord; it should be clipped by the visible width of
18981898 # the panedwindow.
18991899 .p sash coord 0
19101910 }
19111911
19121912 .p sash place 0 0 100
1913
1913
19141914 # Get the new sash coord; it should have moved as far as possible while
19151915 # respecting minsizes.
19161916 .p sash coord 0
19271927 }
19281928
19291929 .p sash place 0 0 100
1930
1930
19311931 # Get the new sash coord; it should have moved as far as possible while
19321932 # respecting minsizes.
19331933 .p sash coord 0
19441944 }
19451945
19461946 .p sash place 0 0 100
1947
1947
19481948 # Get the new sash coord; it should have moved as far as possible while
19491949 # respecting minsizes.
19501950 .p sash coord 1
19611961 }
19621962
19631963 .p sash place 0 0 100
1964
1964
19651965 # Get the new sash coord; it should have moved as far as possible while
19661966 # respecting minsizes.
19671967 .p sash coord 1
19791979 }
19801980
19811981 .p sash place 0 0 100
1982
1983 # Get the new sash coord; it should have moved as far as possible,
1982
1983 # Get the new sash coord; it should have moved as far as possible,
19841984 # respecting minsizes.
19851985 .p sash coord 0
19861986 } -cleanup {
19971997 }
19981998
19991999 .p sash place 0 0 50
2000
2001 # Get the new sash coord; it should have moved as far as possible,
2000
2001 # Get the new sash coord; it should have moved as far as possible,
20022002 # respecting minsizes.
20032003 list [.p sash coord 0] [.p sash coord 1]
20042004 } -cleanup {
20162016
20172017 # Get the requested width of the paned window
20182018 lappend result [winfo reqheight .p]
2019
2019
20202020 .p sash place 0 0 10
2021
2021
20222022 # Get the reqwidth again, to make sure it hasn't changed
20232023 lappend result [winfo reqheight .p]
20242024
20372037 }
20382038
20392039 .p sash place 0 0 -100
2040
2040
20412041 # Get the new sash coord; it should be clipped by the reqwidth of
20422042 # the panedwindow.
20432043 .p sash coord 0
20542054 }
20552055
20562056 .p sash place 0 0 0
2057
2057
20582058 # Get the new sash coord; it should have moved as far as possible while
20592059 # respecting minsizes.
20602060 .p sash coord 0
20712071 }
20722072
20732073 .p sash place 1 0 0
2074
2074
20752075 # Get the new sash coord; it should have moved as far as possible.
20762076 .p sash coord 1
20772077 } -cleanup {
20872087 }
20882088
20892089 .p sash place 1 0 0
2090
2090
20912091 # Get the new sash coord; it should have moved as far as possible while
20922092 # respecting minsizes.
20932093 .p sash coord 0
21042104 }
21052105
21062106 .p sash place 1 0 0
2107
2107
21082108 # Get the new sash coord; it should have moved as far as possible while
21092109 # respecting minsizes.
21102110 .p sash coord 0
21222122 }
21232123
21242124 .p sash place 1 0 0
2125
2126 # Get the new sash coord; it should have moved as far as possible,
2125
2126 # Get the new sash coord; it should have moved as far as possible,
21272127 # respecting minsizes.
21282128 .p sash coord 1
21292129 } -cleanup {
21402140 }
21412141
21422142 .p sash place 1 0 10
2143
2144 # Get the new sash coord; it should have moved as far as possible,
2143
2144 # Get the new sash coord; it should have moved as far as possible,
21452145 # respecting minsizes.
21462146 list [.p sash coord 0] [.p sash coord 1]
21472147 } -cleanup {
22402240 deleteWindows
22412241 } -result [list [list 60 60] [list 80 60]]
22422242
2243 test panedwindow-19.7 {ComputeGeometry, one slave, reqsize set properly} -setup {
2244 deleteWindows
2245 } -body {
2246 # With just one slave, sashpad and sashwidth should not
2243 test panedwindow-19.7 {ComputeGeometry, one pane, reqsize set properly} -setup {
2244 deleteWindows
2245 } -body {
2246 # With just one pane, sashpad and sashwidth should not
22472247 # affect the panedwindow's geometry, since no sash should
22482248 # ever be drawn.
22492249 panedwindow .p -borderwidth 0 -sashpad 0 \
22812281 deleteWindows
22822282 } -result {{20 0} {40 0}}
22832283
2284 test panedwindow-19.10 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2284 test panedwindow-19.10 {ComputeGeometry/ArrangePanes, pane coords} -setup {
22852285 deleteWindows
22862286 } -body {
22872287 panedwindow .p -borderwidth 0 -sashpad 0 \
23022302 deleteWindows
23032303 } -result {{11 3 20 20} {53 3 20 20} {95 3 20 20}}
23042304
2305 test panedwindow-19.11 {ComputeGeometry, one slave, vertical} -setup {
2306 deleteWindows
2307 } -body {
2308 # With just one slave, sashpad and sashwidth should not
2305 test panedwindow-19.11 {ComputeGeometry, one pane, vertical} -setup {
2306 deleteWindows
2307 } -body {
2308 # With just one pane, sashpad and sashwidth should not
23092309 # affect the panedwindow's geometry, since no sash should
23102310 # ever be drawn.
23112311 panedwindow .p -borderwidth 0 -sashpad 0 \
23482348 deleteWindows
23492349 } -result {{0 20} {0 40}}
23502350
2351 test panedwindow-19.14 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2351 test panedwindow-19.14 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
23522352 deleteWindows
23532353 } -body {
23542354 panedwindow .p -borderwidth 0 -sashpad 0 \
23692369 } -cleanup {
23702370 deleteWindows
23712371 } -result {{3 11 20 20} {3 53 20 20} {3 95 20 20}}
2372 test panedwindow-19.15 {ComputeGeometry, one slave, reqsize set properly} -setup {
2373 deleteWindows
2374 } -body {
2375 # With just one slave, sashpad and sashwidth should not
2372 test panedwindow-19.15 {ComputeGeometry, one pane, reqsize set properly} -setup {
2373 deleteWindows
2374 } -body {
2375 # With just one pane, sashpad and sashwidth should not
23762376 # affect the panedwindow's geometry, since no sash should
23772377 # ever be drawn.
23782378 panedwindow .p -borderwidth 0 -sashpad 0 \
24102410 deleteWindows
24112411 } -result {{23 0} {49 0}}
24122412
2413 test panedwindow-19.18 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2413 test panedwindow-19.18 {ComputeGeometry/ArrangePanes, pane coords} -setup {
24142414 deleteWindows
24152415 } -body {
24162416 panedwindow .p -borderwidth 0 -sashpad 0 \
24312431 deleteWindows
24322432 } -result {{11 3 20 20} {59 3 20 20} {107 3 20 20}}
24332433
2434 test panedwindow-19.19 {ComputeGeometry, one slave, vertical} -setup {
2435 deleteWindows
2436 } -body {
2437 # With just one slave, sashpad and sashwidth should not
2434 test panedwindow-19.19 {ComputeGeometry, one pane, vertical} -setup {
2435 deleteWindows
2436 } -body {
2437 # With just one pane, sashpad and sashwidth should not
24382438 # affect the panedwindow's geometry, since no sash should
24392439 # ever be drawn.
24402440 panedwindow .p -borderwidth 0 -sashpad 0 \
24772477 deleteWindows
24782478 } -result {{0 23} {0 49}}
24792479
2480 test panedwindow-19.22 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2480 test panedwindow-19.22 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
24812481 deleteWindows
24822482 } -body {
24832483 panedwindow .p -borderwidth 0 -sashpad 0 \
24982498 } -cleanup {
24992499 deleteWindows
25002500 } -result {{3 11 20 20} {3 59 20 20} {3 107 20 20}}
2501 test panedwindow-19.23 {ComputeGeometry, one slave, reqsize set properly} -setup {
2502 deleteWindows
2503 } -body {
2504 # With just one slave, sashpad and sashwidth should not
2501 test panedwindow-19.23 {ComputeGeometry, one pane, reqsize set properly} -setup {
2502 deleteWindows
2503 } -body {
2504 # With just one pane, sashpad and sashwidth should not
25052505 # affect the panedwindow's geometry, since no sash should
25062506 # ever be drawn.
25072507 panedwindow .p -borderwidth 0 -sashpad 0 \
25392539 deleteWindows
25402540 } -result {{20 0} {43 0}}
25412541
2542 test panedwindow-19.26 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2542 test panedwindow-19.26 {ComputeGeometry/ArrangePanes, pane coords} -setup {
25432543 deleteWindows
25442544 } -body {
25452545 panedwindow .p -borderwidth 0 -sashpad 0 \
25602560 deleteWindows
25612561 } -result {{11 3 20 20} {56 3 20 20} {101 3 20 20}}
25622562
2563 test panedwindow-19.27 {ComputeGeometry, one slave, vertical} -setup {
2564 deleteWindows
2565 } -body {
2566 # With just one slave, sashpad and sashwidth should not
2563 test panedwindow-19.27 {ComputeGeometry, one pane, vertical} -setup {
2564 deleteWindows
2565 } -body {
2566 # With just one pane, sashpad and sashwidth should not
25672567 # affect the panedwindow's geometry, since no sash should
25682568 # ever be drawn.
25692569 panedwindow .p -borderwidth 0 -sashpad 0 \
26062606 deleteWindows
26072607 } -result {{0 20} {0 43}}
26082608
2609 test panedwindow-19.30 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2609 test panedwindow-19.30 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
26102610 deleteWindows
26112611 } -body {
26122612 panedwindow .p -borderwidth 0 -sashpad 0 \
26272627 } -cleanup {
26282628 deleteWindows
26292629 } -result {{3 11 20 20} {3 56 20 20} {3 101 20 20}}
2630 test panedwindow-19.31 {ComputeGeometry, one slave, reqsize set properly} -setup {
2631 deleteWindows
2632 } -body {
2633 # With just one slave, sashpad and sashwidth should not
2630 test panedwindow-19.31 {ComputeGeometry, one pane, reqsize set properly} -setup {
2631 deleteWindows
2632 } -body {
2633 # With just one pane, sashpad and sashwidth should not
26342634 # affect the panedwindow's geometry, since no sash should
26352635 # ever be drawn.
26362636 panedwindow .p -borderwidth 0 -sashpad 0 \
26682668 deleteWindows
26692669 } -result {{21 0} {47 0}}
26702670
2671 test panedwindow-19.34 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2671 test panedwindow-19.34 {ComputeGeometry/ArrangePanes, pane coords} -setup {
26722672 deleteWindows
26732673 } -body {
26742674 panedwindow .p -borderwidth 0 -sashpad 0 \
26892689 deleteWindows
26902690 } -result {{11 3 20 20} {59 3 20 20} {107 3 20 20}}
26912691
2692 test panedwindow-19.35 {ComputeGeometry, one slave, vertical} -setup {
2693 deleteWindows
2694 } -body {
2695 # With just one slave, sashpad and sashwidth should not
2692 test panedwindow-19.35 {ComputeGeometry, one pane, vertical} -setup {
2693 deleteWindows
2694 } -body {
2695 # With just one pane, sashpad and sashwidth should not
26962696 # affect the panedwindow's geometry, since no sash should
26972697 # ever be drawn.
26982698 panedwindow .p -borderwidth 0 -sashpad 0 \
27352735 deleteWindows
27362736 } -result {{0 21} {0 47}}
27372737
2738 test panedwindow-19.38 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2738 test panedwindow-19.38 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
27392739 deleteWindows
27402740 } -body {
27412741 panedwindow .p -borderwidth 0 -sashpad 0 \
27562756 } -cleanup {
27572757 deleteWindows
27582758 } -result {{3 11 20 20} {3 59 20 20} {3 107 20 20}}
2759 test panedwindow-19.39 {ComputeGeometry, one slave, reqsize set properly} -setup {
2760 deleteWindows
2761 } -body {
2762 # With just one slave, sashpad and sashwidth should not
2759 test panedwindow-19.39 {ComputeGeometry, one pane, reqsize set properly} -setup {
2760 deleteWindows
2761 } -body {
2762 # With just one pane, sashpad and sashwidth should not
27632763 # affect the panedwindow's geometry, since no sash should
27642764 # ever be drawn.
27652765 panedwindow .p -borderwidth 0 -sashpad 5 \
27972797 deleteWindows
27982798 } -result {{25 0} {55 0}}
27992799
2800 test panedwindow-19.42 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2800 test panedwindow-19.42 {ComputeGeometry/ArrangePanes, pane coords} -setup {
28012801 deleteWindows
28022802 } -body {
28032803 panedwindow .p -borderwidth 0 -sashpad 5 \
28182818 deleteWindows
28192819 } -result {{11 3 20 20} {63 3 20 20} {115 3 20 20}}
28202820
2821 test panedwindow-19.43 {ComputeGeometry, one slave, vertical} -setup {
2822 deleteWindows
2823 } -body {
2824 # With just one slave, sashpad and sashwidth should not
2821 test panedwindow-19.43 {ComputeGeometry, one pane, vertical} -setup {
2822 deleteWindows
2823 } -body {
2824 # With just one pane, sashpad and sashwidth should not
28252825 # affect the panedwindow's geometry, since no sash should
28262826 # ever be drawn.
28272827 panedwindow .p -borderwidth 0 -sashpad 5 \
28642864 deleteWindows
28652865 } -result {{0 25} {0 55}}
28662866
2867 test panedwindow-19.46 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2867 test panedwindow-19.46 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
28682868 deleteWindows
28692869 } -body {
28702870 panedwindow .p -borderwidth 0 -sashpad 5 \
28852885 } -cleanup {
28862886 deleteWindows
28872887 } -result {{3 11 20 20} {3 63 20 20} {3 115 20 20}}
2888 test panedwindow-19.47 {ComputeGeometry, one slave, reqsize set properly} -setup {
2889 deleteWindows
2890 } -body {
2891 # With just one slave, sashpad and sashwidth should not
2888 test panedwindow-19.47 {ComputeGeometry, one pane, reqsize set properly} -setup {
2889 deleteWindows
2890 } -body {
2891 # With just one pane, sashpad and sashwidth should not
28922892 # affect the panedwindow's geometry, since no sash should
28932893 # ever be drawn.
28942894 panedwindow .p -borderwidth 0 -sashpad 5 \
29262926 deleteWindows
29272927 } -result {{28 0} {64 0}}
29282928
2929 test panedwindow-19.50 {ComputeGeometry/ArrangePanes, slave coords} -setup {
2929 test panedwindow-19.50 {ComputeGeometry/ArrangePanes, pane coords} -setup {
29302930 deleteWindows
29312931 } -body {
29322932 panedwindow .p -borderwidth 0 -sashpad 5 \
29472947 deleteWindows
29482948 } -result {{11 3 20 20} {69 3 20 20} {127 3 20 20}}
29492949
2950 test panedwindow-19.51 {ComputeGeometry, one slave, vertical} -setup {
2951 deleteWindows
2952 } -body {
2953 # With just one slave, sashpad and sashwidth should not
2950 test panedwindow-19.51 {ComputeGeometry, one pane, vertical} -setup {
2951 deleteWindows
2952 } -body {
2953 # With just one pane, sashpad and sashwidth should not
29542954 # affect the panedwindow's geometry, since no sash should
29552955 # ever be drawn.
29562956 panedwindow .p -borderwidth 0 -sashpad 5 \
29932993 deleteWindows
29942994 } -result {{0 28} {0 64}}
29952995
2996 test panedwindow-19.54 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
2996 test panedwindow-19.54 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
29972997 deleteWindows
29982998 } -body {
29992999 panedwindow .p -borderwidth 0 -sashpad 5 \
30143014 } -cleanup {
30153015 deleteWindows
30163016 } -result {{3 11 20 20} {3 69 20 20} {3 127 20 20}}
3017 test panedwindow-19.55 {ComputeGeometry, one slave, reqsize set properly} -setup {
3018 deleteWindows
3019 } -body {
3020 # With just one slave, sashpad and sashwidth should not
3017 test panedwindow-19.55 {ComputeGeometry, one pane, reqsize set properly} -setup {
3018 deleteWindows
3019 } -body {
3020 # With just one pane, sashpad and sashwidth should not
30213021 # affect the panedwindow's geometry, since no sash should
30223022 # ever be drawn.
30233023 panedwindow .p -borderwidth 0 -sashpad 5 \
30553055 deleteWindows
30563056 } -result {{25 0} {58 0}}
30573057
3058 test panedwindow-19.58 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3058 test panedwindow-19.58 {ComputeGeometry/ArrangePanes, pane coords} -setup {
30593059 deleteWindows
30603060 } -body {
30613061 panedwindow .p -borderwidth 0 -sashpad 5 \
30763076 deleteWindows
30773077 } -result {{11 3 20 20} {66 3 20 20} {121 3 20 20}}
30783078
3079 test panedwindow-19.59 {ComputeGeometry, one slave, vertical} -setup {
3080 deleteWindows
3081 } -body {
3082 # With just one slave, sashpad and sashwidth should not
3079 test panedwindow-19.59 {ComputeGeometry, one pane, vertical} -setup {
3080 deleteWindows
3081 } -body {
3082 # With just one pane, sashpad and sashwidth should not
30833083 # affect the panedwindow's geometry, since no sash should
30843084 # ever be drawn.
30853085 panedwindow .p -borderwidth 0 -sashpad 5 \
31223122 deleteWindows
31233123 } -result {{0 25} {0 58}}
31243124
3125 test panedwindow-19.62 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3125 test panedwindow-19.62 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
31263126 deleteWindows
31273127 } -body {
31283128 panedwindow .p -borderwidth 0 -sashpad 5 \
31433143 } -cleanup {
31443144 deleteWindows
31453145 } -result {{3 11 20 20} {3 66 20 20} {3 121 20 20}}
3146 test panedwindow-19.63 {ComputeGeometry, one slave, reqsize set properly} -setup {
3147 deleteWindows
3148 } -body {
3149 # With just one slave, sashpad and sashwidth should not
3146 test panedwindow-19.63 {ComputeGeometry, one pane, reqsize set properly} -setup {
3147 deleteWindows
3148 } -body {
3149 # With just one pane, sashpad and sashwidth should not
31503150 # affect the panedwindow's geometry, since no sash should
31513151 # ever be drawn.
31523152 panedwindow .p -borderwidth 0 -sashpad 5 \
31843184 deleteWindows
31853185 } -result {{26 0} {62 0}}
31863186
3187 test panedwindow-19.66 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3187 test panedwindow-19.66 {ComputeGeometry/ArrangePanes, pane coords} -setup {
31883188 deleteWindows
31893189 } -body {
31903190 panedwindow .p -borderwidth 0 -sashpad 5 \
32053205 deleteWindows
32063206 } -result {{11 3 20 20} {69 3 20 20} {127 3 20 20}}
32073207
3208 test panedwindow-19.67 {ComputeGeometry, one slave, vertical} -setup {
3209 deleteWindows
3210 } -body {
3211 # With just one slave, sashpad and sashwidth should not
3208 test panedwindow-19.67 {ComputeGeometry, one pane, vertical} -setup {
3209 deleteWindows
3210 } -body {
3211 # With just one pane, sashpad and sashwidth should not
32123212 # affect the panedwindow's geometry, since no sash should
32133213 # ever be drawn.
32143214 panedwindow .p -borderwidth 0 -sashpad 5 \
32513251 deleteWindows
32523252 } -result {{0 26} {0 62}}
32533253
3254 test panedwindow-19.70 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3254 test panedwindow-19.70 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
32553255 deleteWindows
32563256 } -body {
32573257 panedwindow .p -borderwidth 0 -sashpad 5 \
32723272 } -cleanup {
32733273 deleteWindows
32743274 } -result {{3 11 20 20} {3 69 20 20} {3 127 20 20}}
3275 test panedwindow-19.71 {ComputeGeometry, one slave, reqsize set properly} -setup {
3276 deleteWindows
3277 } -body {
3278 # With just one slave, sashpad and sashwidth should not
3275 test panedwindow-19.71 {ComputeGeometry, one pane, reqsize set properly} -setup {
3276 deleteWindows
3277 } -body {
3278 # With just one pane, sashpad and sashwidth should not
32793279 # affect the panedwindow's geometry, since no sash should
32803280 # ever be drawn.
32813281 panedwindow .p -borderwidth 2 -sashpad 0 \
33133313 deleteWindows
33143314 } -result {{22 2} {42 2}}
33153315
3316 test panedwindow-19.74 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3316 test panedwindow-19.74 {ComputeGeometry/ArrangePanes, pane coords} -setup {
33173317 deleteWindows
33183318 } -body {
33193319 panedwindow .p -borderwidth 2 -sashpad 0 \
33343334 deleteWindows
33353335 } -result {{13 5 20 20} {55 5 20 20} {97 5 20 20}}
33363336
3337 test panedwindow-19.75 {ComputeGeometry, one slave, vertical} -setup {
3338 deleteWindows
3339 } -body {
3340 # With just one slave, sashpad and sashwidth should not
3337 test panedwindow-19.75 {ComputeGeometry, one pane, vertical} -setup {
3338 deleteWindows
3339 } -body {
3340 # With just one pane, sashpad and sashwidth should not
33413341 # affect the panedwindow's geometry, since no sash should
33423342 # ever be drawn.
33433343 panedwindow .p -borderwidth 2 -sashpad 0 \
33803380 deleteWindows
33813381 } -result {{2 22} {2 42}}
33823382
3383 test panedwindow-19.78 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3383 test panedwindow-19.78 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
33843384 deleteWindows
33853385 } -body {
33863386 panedwindow .p -borderwidth 2 -sashpad 0 \
34013401 } -cleanup {
34023402 deleteWindows
34033403 } -result {{5 13 20 20} {5 55 20 20} {5 97 20 20}}
3404 test panedwindow-19.79 {ComputeGeometry, one slave, reqsize set properly} -setup {
3405 deleteWindows
3406 } -body {
3407 # With just one slave, sashpad and sashwidth should not
3404 test panedwindow-19.79 {ComputeGeometry, one pane, reqsize set properly} -setup {
3405 deleteWindows
3406 } -body {
3407 # With just one pane, sashpad and sashwidth should not
34083408 # affect the panedwindow's geometry, since no sash should
34093409 # ever be drawn.
34103410 panedwindow .p -borderwidth 2 -sashpad 0 \
34423442 deleteWindows
34433443 } -result {{25 2} {51 2}}
34443444
3445 test panedwindow-19.82 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3445 test panedwindow-19.82 {ComputeGeometry/ArrangePanes, pane coords} -setup {
34463446 deleteWindows
34473447 } -body {
34483448 panedwindow .p -borderwidth 2 -sashpad 0 \
34633463 deleteWindows
34643464 } -result {{13 5 20 20} {61 5 20 20} {109 5 20 20}}
34653465
3466 test panedwindow-19.83 {ComputeGeometry, one slave, vertical} -setup {
3467 deleteWindows
3468 } -body {
3469 # With just one slave, sashpad and sashwidth should not
3466 test panedwindow-19.83 {ComputeGeometry, one pane, vertical} -setup {
3467 deleteWindows
3468 } -body {
3469 # With just one pane, sashpad and sashwidth should not
34703470 # affect the panedwindow's geometry, since no sash should
34713471 # ever be drawn.
34723472 panedwindow .p -borderwidth 2 -sashpad 0 \
35093509 deleteWindows
35103510 } -result {{2 25} {2 51}}
35113511
3512 test panedwindow-19.86 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3512 test panedwindow-19.86 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
35133513 deleteWindows
35143514 } -body {
35153515 panedwindow .p -borderwidth 2 -sashpad 0 \
35303530 } -cleanup {
35313531 deleteWindows
35323532 } -result {{5 13 20 20} {5 61 20 20} {5 109 20 20}}
3533 test panedwindow-19.87 {ComputeGeometry, one slave, reqsize set properly} -setup {
3534 deleteWindows
3535 } -body {
3536 # With just one slave, sashpad and sashwidth should not
3533 test panedwindow-19.87 {ComputeGeometry, one pane, reqsize set properly} -setup {
3534 deleteWindows
3535 } -body {
3536 # With just one pane, sashpad and sashwidth should not
35373537 # affect the panedwindow's geometry, since no sash should
35383538 # ever be drawn.
35393539 panedwindow .p -borderwidth 2 -sashpad 0 \
35713571 deleteWindows
35723572 } -result {{22 2} {45 2}}
35733573
3574 test panedwindow-19.90 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3574 test panedwindow-19.90 {ComputeGeometry/ArrangePanes, pane coords} -setup {
35753575 deleteWindows
35763576 } -body {
35773577 panedwindow .p -borderwidth 2 -sashpad 0 \
35923592 deleteWindows
35933593 } -result {{13 5 20 20} {58 5 20 20} {103 5 20 20}}
35943594
3595 test panedwindow-19.91 {ComputeGeometry, one slave, vertical} -setup {
3596 deleteWindows
3597 } -body {
3598 # With just one slave, sashpad and sashwidth should not
3595 test panedwindow-19.91 {ComputeGeometry, one pane, vertical} -setup {
3596 deleteWindows
3597 } -body {
3598 # With just one pane, sashpad and sashwidth should not
35993599 # affect the panedwindow's geometry, since no sash should
36003600 # ever be drawn.
36013601 panedwindow .p -borderwidth 2 -sashpad 0 \
36383638 deleteWindows
36393639 } -result {{2 22} {2 45}}
36403640
3641 test panedwindow-19.94 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3641 test panedwindow-19.94 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
36423642 deleteWindows
36433643 } -body {
36443644 panedwindow .p -borderwidth 2 -sashpad 0 \
36593659 } -cleanup {
36603660 deleteWindows
36613661 } -result {{5 13 20 20} {5 58 20 20} {5 103 20 20}}
3662 test panedwindow-19.95 {ComputeGeometry, one slave, reqsize set properly} -setup {
3663 deleteWindows
3664 } -body {
3665 # With just one slave, sashpad and sashwidth should not
3662 test panedwindow-19.95 {ComputeGeometry, one pane, reqsize set properly} -setup {
3663 deleteWindows
3664 } -body {
3665 # With just one pane, sashpad and sashwidth should not
36663666 # affect the panedwindow's geometry, since no sash should
36673667 # ever be drawn.
36683668 panedwindow .p -borderwidth 2 -sashpad 0 \
37003700 deleteWindows
37013701 } -result {{23 2} {49 2}}
37023702
3703 test panedwindow-19.98 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3703 test panedwindow-19.98 {ComputeGeometry/ArrangePanes, pane coords} -setup {
37043704 deleteWindows
37053705 } -body {
37063706 panedwindow .p -borderwidth 2 -sashpad 0 \
37213721 deleteWindows
37223722 } -result {{13 5 20 20} {61 5 20 20} {109 5 20 20}}
37233723
3724 test panedwindow-19.99 {ComputeGeometry, one slave, vertical} -setup {
3725 deleteWindows
3726 } -body {
3727 # With just one slave, sashpad and sashwidth should not
3724 test panedwindow-19.99 {ComputeGeometry, one pane, vertical} -setup {
3725 deleteWindows
3726 } -body {
3727 # With just one pane, sashpad and sashwidth should not
37283728 # affect the panedwindow's geometry, since no sash should
37293729 # ever be drawn.
37303730 panedwindow .p -borderwidth 2 -sashpad 0 \
37673767 deleteWindows
37683768 } -result {{2 23} {2 49}}
37693769
3770 test panedwindow-19.102 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3770 test panedwindow-19.102 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
37713771 deleteWindows
37723772 } -body {
37733773 panedwindow .p -borderwidth 2 -sashpad 0 \
37883788 } -cleanup {
37893789 deleteWindows
37903790 } -result {{5 13 20 20} {5 61 20 20} {5 109 20 20}}
3791 test panedwindow-19.103 {ComputeGeometry, one slave, reqsize set properly} -setup {
3792 deleteWindows
3793 } -body {
3794 # With just one slave, sashpad and sashwidth should not
3791 test panedwindow-19.103 {ComputeGeometry, one pane, reqsize set properly} -setup {
3792 deleteWindows
3793 } -body {
3794 # With just one pane, sashpad and sashwidth should not
37953795 # affect the panedwindow's geometry, since no sash should
37963796 # ever be drawn.
37973797 panedwindow .p -borderwidth 2 -sashpad 5 \
38293829 deleteWindows
38303830 } -result {{27 2} {57 2}}
38313831
3832 test panedwindow-19.106 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3832 test panedwindow-19.106 {ComputeGeometry/ArrangePanes, pane coords} -setup {
38333833 deleteWindows
38343834 } -body {
38353835 panedwindow .p -borderwidth 2 -sashpad 5 \
38503850 deleteWindows
38513851 } -result {{13 5 20 20} {65 5 20 20} {117 5 20 20}}
38523852
3853 test panedwindow-19.107 {ComputeGeometry, one slave, vertical} -setup {
3854 deleteWindows
3855 } -body {
3856 # With just one slave, sashpad and sashwidth should not
3853 test panedwindow-19.107 {ComputeGeometry, one pane, vertical} -setup {
3854 deleteWindows
3855 } -body {
3856 # With just one pane, sashpad and sashwidth should not
38573857 # affect the panedwindow's geometry, since no sash should
38583858 # ever be drawn.
38593859 panedwindow .p -borderwidth 2 -sashpad 5 \
38963896 deleteWindows
38973897 } -result {{2 27} {2 57}}
38983898
3899 test panedwindow-19.110 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
3899 test panedwindow-19.110 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
39003900 deleteWindows
39013901 } -body {
39023902 panedwindow .p -borderwidth 2 -sashpad 5 \
39173917 } -cleanup {
39183918 deleteWindows
39193919 } -result {{5 13 20 20} {5 65 20 20} {5 117 20 20}}
3920 test panedwindow-19.111 {ComputeGeometry, one slave, reqsize set properly} -setup {
3921 deleteWindows
3922 } -body {
3923 # With just one slave, sashpad and sashwidth should not
3920 test panedwindow-19.111 {ComputeGeometry, one pane, reqsize set properly} -setup {
3921 deleteWindows
3922 } -body {
3923 # With just one pane, sashpad and sashwidth should not
39243924 # affect the panedwindow's geometry, since no sash should
39253925 # ever be drawn.
39263926 panedwindow .p -borderwidth 2 -sashpad 5 \
39583958 deleteWindows
39593959 } -result {{30 2} {66 2}}
39603960
3961 test panedwindow-19.114 {ComputeGeometry/ArrangePanes, slave coords} -setup {
3961 test panedwindow-19.114 {ComputeGeometry/ArrangePanes, pane coords} -setup {
39623962 deleteWindows
39633963 } -body {
39643964 panedwindow .p -borderwidth 2 -sashpad 5 \
39793979 deleteWindows
39803980 } -result {{13 5 20 20} {71 5 20 20} {129 5 20 20}}
39813981
3982 test panedwindow-19.115 {ComputeGeometry, one slave, vertical} -setup {
3983 deleteWindows
3984 } -body {
3985 # With just one slave, sashpad and sashwidth should not
3982 test panedwindow-19.115 {ComputeGeometry, one pane, vertical} -setup {
3983 deleteWindows
3984 } -body {
3985 # With just one pane, sashpad and sashwidth should not
39863986 # affect the panedwindow's geometry, since no sash should
39873987 # ever be drawn.
39883988 panedwindow .p -borderwidth 2 -sashpad 5 \
40254025 deleteWindows
40264026 } -result {{2 30} {2 66}}
40274027
4028 test panedwindow-19.118 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
4028 test panedwindow-19.118 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
40294029 deleteWindows
40304030 } -body {
40314031 panedwindow .p -borderwidth 2 -sashpad 5 \
40464046 } -cleanup {
40474047 deleteWindows
40484048 } -result {{5 13 20 20} {5 71 20 20} {5 129 20 20}}
4049 test panedwindow-19.119 {ComputeGeometry, one slave, reqsize set properly} -setup {
4050 deleteWindows
4051 } -body {
4052 # With just one slave, sashpad and sashwidth should not
4049 test panedwindow-19.119 {ComputeGeometry, one pane, reqsize set properly} -setup {
4050 deleteWindows
4051 } -body {
4052 # With just one pane, sashpad and sashwidth should not
40534053 # affect the panedwindow's geometry, since no sash should
40544054 # ever be drawn.
40554055 panedwindow .p -borderwidth 2 -sashpad 5 \
40874087 deleteWindows
40884088 } -result {{27 2} {60 2}}
40894089
4090 test panedwindow-19.122 {ComputeGeometry/ArrangePanes, slave coords} -setup {
4090 test panedwindow-19.122 {ComputeGeometry/ArrangePanes, pane coords} -setup {
40914091 deleteWindows
40924092 } -body {
40934093 panedwindow .p -borderwidth 2 -sashpad 5 \
41084108 deleteWindows
41094109 } -result {{13 5 20 20} {68 5 20 20} {123 5 20 20}}
41104110
4111 test panedwindow-19.123 {ComputeGeometry, one slave, vertical} -setup {
4112 deleteWindows
4113 } -body {
4114 # With just one slave, sashpad and sashwidth should not
4111 test panedwindow-19.123 {ComputeGeometry, one pane, vertical} -setup {
4112 deleteWindows
4113 } -body {
4114 # With just one pane, sashpad and sashwidth should not
41154115 # affect the panedwindow's geometry, since no sash should
41164116 # ever be drawn.
41174117 panedwindow .p -borderwidth 2 -sashpad 5 \
41544154 deleteWindows
41554155 } -result {{2 27} {2 60}}
41564156
4157 test panedwindow-19.126 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
4157 test panedwindow-19.126 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
41584158 deleteWindows
41594159 } -body {
41604160 panedwindow .p -borderwidth 2 -sashpad 5 \
41754175 } -cleanup {
41764176 deleteWindows
41774177 } -result {{5 13 20 20} {5 68 20 20} {5 123 20 20}}
4178 test panedwindow-19.127 {ComputeGeometry, one slave, reqsize set properly} -setup {
4179 deleteWindows
4180 } -body {
4181 # With just one slave, sashpad and sashwidth should not
4178 test panedwindow-19.127 {ComputeGeometry, one pane, reqsize set properly} -setup {
4179 deleteWindows
4180 } -body {
4181 # With just one pane, sashpad and sashwidth should not
41824182 # affect the panedwindow's geometry, since no sash should
41834183 # ever be drawn.
41844184 panedwindow .p -borderwidth 2 -sashpad 5 \
42164216 deleteWindows
42174217 } -result {{28 2} {64 2}}
42184218
4219 test panedwindow-19.130 {ComputeGeometry/ArrangePanes, slave coords} -setup {
4219 test panedwindow-19.130 {ComputeGeometry/ArrangePanes, pane coords} -setup {
42204220 deleteWindows
42214221 } -body {
42224222 panedwindow .p -borderwidth 2 -sashpad 5 \
42374237 deleteWindows
42384238 } -result {{13 5 20 20} {71 5 20 20} {129 5 20 20}}
42394239
4240 test panedwindow-19.131 {ComputeGeometry, one slave, vertical} -setup {
4241 deleteWindows
4242 } -body {
4243 # With just one slave, sashpad and sashwidth should not
4240 test panedwindow-19.131 {ComputeGeometry, one pane, vertical} -setup {
4241 deleteWindows
4242 } -body {
4243 # With just one pane, sashpad and sashwidth should not
42444244 # affect the panedwindow's geometry, since no sash should
42454245 # ever be drawn.
42464246 panedwindow .p -borderwidth 2 -sashpad 5 \
42834283 deleteWindows
42844284 } -result {{2 28} {2 64}}
42854285
4286 test panedwindow-19.134 {ComputeGeometry/ArrangePanes, slave coords, vert} -setup {
4286 test panedwindow-19.134 {ComputeGeometry/ArrangePanes, pane coords, vert} -setup {
42874287 deleteWindows
42884288 } -body {
42894289 panedwindow .p -borderwidth 2 -sashpad 5 \
43164316 } -cleanup {
43174317 deleteWindows
43184318 } -result {}
4319 test panedwindow-20.2 {destroyed slave causes geometry recomputation} -setup {
4319 test panedwindow-20.2 {destroyed pane causes geometry recomputation} -setup {
43204320 deleteWindows
43214321 } -body {
43224322 panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 2
43274327 } -cleanup {
43284328 deleteWindows
43294329 } -result 20
4330
4330
43314331
43324332 test panedwindow-21.1 {ArrangePanes, extra space is given to the last pane} -setup {
43334333 deleteWindows
45364536 } -result {50 150 1 1 211 50 150 1 89 300}
45374537
45384538
4539 test panedwindow-22.1 {PanedWindowReqProc, react to slave geometry changes} -setup {
4539 test panedwindow-22.1 {PanedWindowReqProc, react to pane geometry changes} -setup {
45404540 deleteWindows
45414541 } -body {
45424542 # Basically just want to make sure that the PanedWindowReqProc is called
45494549 } -cleanup {
45504550 deleteWindows
45514551 } -result {40 80}
4552 test panedwindow-22.2 {PanedWindowReqProc, react to slave geometry changes} -setup {
4552 test panedwindow-22.2 {PanedWindowReqProc, react to pane geometry changes} -setup {
45534553 deleteWindows
45544554 } -body {
45554555 panedwindow .p -orient horizontal -sashpad 0 -sashwidth 2
48234823 } -cleanup {
48244824 deleteWindows
48254825 } -result {.d .b .a .c}
4826 test panedwindow-23.22 {ConfigurePanes, slave specified multiple times} -setup {
4826 test panedwindow-23.22 {ConfigurePanes, pane specified multiple times} -setup {
48274827 deleteWindows
48284828 } -body {
48294829 # This test should not cause a core dump
48384838 } -cleanup {
48394839 deleteWindows
48404840 } -result {.a .b .c}
4841 test panedwindow-23.23 {ConfigurePanes, slave specified multiple times} -setup {
4841 test panedwindow-23.23 {ConfigurePanes, pane specified multiple times} -setup {
48424842 deleteWindows
48434843 } -body {
48444844 # This test should not cause a core dump
51455145 }
51465146 set result {}
51475147 } -result {}
5148 test panedwindow-25.2 {UnmapNotify and MapNotify events are propagated to slaves} -setup {
5148 test panedwindow-25.2 {UnmapNotify and MapNotify events are propagated to panes} -setup {
51495149 deleteWindows
51505150 } -body {
51515151 panedwindow .pw
1111
1212 # Used for constraining memory leak tests
1313 testConstraint memory [llength [info commands memory]]
14
15 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
16 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1417
1518 # XXX - This test file is woefully incomplete. At present, only a
1619 # few of the features are tested.
5255 } -result {-in {.t.a b} -x 1 -relx 0.2 -y 2 -rely 0.2 -width {} -relwidth 0.3 -height 4 -relheight {} -anchor w -bordermode ignore}
5356
5457
55 test place-2.1 {ConfigureSlave procedure, -height option} -body {
58 test place-2.1 {ConfigureContent procedure, -height option} -body {
5659 place .t.f2 -height abcd
5760 } -returnCodes error -result {bad screen distance "abcd"}
58 test place-2.2 {ConfigureSlave procedure, -height option} -setup {
61 test place-2.2 {ConfigureContent procedure, -height option} -setup {
5962 place forget .t.f2
6063 } -body {
6164 place .t.f2 -in .t.f -height 40
6265 update
6366 winfo height .t.f2
6467 } -result {40}
65 test place-2.3 {ConfigureSlave procedure, -height option} -setup {
68 test place-2.3 {ConfigureContent procedure, -height option} -setup {
6669 place forget .t.f2
6770 } -body {
6871 place .t.f2 -in .t.f -height 120
7376 } -result {60}
7477
7578
76 test place-3.1 {ConfigureSlave procedure, -relheight option} -body {
79 test place-3.1 {ConfigureContent procedure, -relheight option} -body {
7780 place .t.f2 -relheight abcd
7881 } -returnCodes error -result {expected floating-point number but got "abcd"}
79 test place-3.2 {ConfigureSlave procedure, -relheight option} -setup {
82 test place-3.2 {ConfigureContent procedure, -relheight option} -setup {
8083 place forget .t.f2
8184 } -body {
8285 place .t.f2 -in .t.f -relheight .5
8386 update
8487 winfo height .t.f2
8588 } -result {40}
86 test place-3.3 {ConfigureSlave procedure, -relheight option} -setup {
89 test place-3.3 {ConfigureContent procedure, -relheight option} -setup {
8790 place forget .t.f2
8891 } -body {
8992 place .t.f2 -in .t.f -relheight .8
9497 } -result {60}
9598
9699
97 test place-4.1 {ConfigureSlave procedure, bad -in options} -setup {
100 test place-4.1 {ConfigureContent procedure, bad -in options} -setup {
98101 place forget .t.f2
99102 } -body {
100103 place .t.f2 -in .t.f2
101104 } -returnCodes error -result {can't place .t.f2 relative to itself}
102 test place-4.2 {ConfigureSlave procedure, bad -in option} -setup {
105 test place-4.2 {ConfigureContent procedure, bad -in option} -setup {
103106 place forget .t.f2
104107 } -body {
105108 set result [list [winfo manager .t.f2]]
106109 catch {place .t.f2 -in .t.f2}
107110 lappend result [winfo manager .t.f2]
108111 } -result {{} {}}
109 test place-4.3 {ConfigureSlave procedure, bad -in option} -setup {
112 test place-4.3 {ConfigureContent procedure, bad -in option} -setup {
110113 place forget .t.f2
111114 } -body {
112115 winfo manager .t.f2
113116 place .t.f2 -in .t.f2
114117 } -returnCodes error -result {can't place .t.f2 relative to itself}
115 test place-4.4 {ConfigureSlave procedure, bad -in option} -setup {
118 test place-4.4 {ConfigureContent procedure, bad -in option} -setup {
116119 place forget .t.f2
117120 } -body {
118121 place .t.f2 -in .
119122 } -returnCodes error -result {can't place .t.f2 relative to .}
120 test place-4.5 {ConfigureSlave procedure, bad -in option} -setup {
123 test place-4.5 {ConfigureContent procedure, bad -in option} -setup {
121124 } -body {
122125 frame .t.f1
123126 place .t.f1 -in .t.f1
138141 place .t.f3 -in .t.f1
139142 } -returnCodes error -result {can't put .t.f3 inside .t.f1, would cause management loop}
140143
141 test place-5.1 {ConfigureSlave procedure, -relwidth option} -body {
144 test place-5.1 {ConfigureContent procedure, -relwidth option} -body {
142145 place .t.f2 -relwidth abcd
143146 } -returnCodes error -result {expected floating-point number but got "abcd"}
144 test place-5.2 {ConfigureSlave procedure, -relwidth option} -setup {
147 test place-5.2 {ConfigureContent procedure, -relwidth option} -setup {
145148 place forget .t.f2
146149 } -body {
147150 place .t.f2 -in .t.f -relwidth .5
148151 update
149152 winfo width .t.f2
150153 } -result {75}
151 test place-5.3 {ConfigureSlave procedure, -relwidth option} -setup {
154 test place-5.3 {ConfigureContent procedure, -relwidth option} -setup {
152155 place forget .t.f2
153156 } -body {
154157 place .t.f2 -in .t.f -relwidth .8
158161 winfo width .t.f2
159162 } -result {30}
160163
161 test place-6.1 {ConfigureSlave procedure, -width option} -body {
164 test place-6.1 {ConfigureContent procedure, -width option} -body {
162165 place .t.f2 -width abcd
163166 } -returnCodes error -result {bad screen distance "abcd"}
164 test place-6.2 {ConfigureSlave procedure, -width option} -setup {
167 test place-6.2 {ConfigureContent procedure, -width option} -setup {
165168 place forget .t.f2
166169 } -body {
167170 place .t.f2 -in .t.f -width 100
168171 update
169172 winfo width .t.f2
170173 } -result {100}
171 test place-6.3 {ConfigureSlave procedure, -width option} -setup {
174 test place-6.3 {ConfigureContent procedure, -width option} -setup {
172175 place forget .t.f2
173176 } -body {
174177 place .t.f2 -in .t.f -width 120
257260 list [winfo width .t.f2] [winfo height .t.f2]
258261 } -result {30 60}
259262
260
261 test place-8.1 {MasterStructureProc, mapping and unmapping slaves} -setup {
263 if {[tk windowingsystem] ne "aqua"} {
264 proc placeUpdate {} {
265 update
266 }
267 } else {
268 proc placeUpdate {} {
269 }
270 }
271
272 test place-8.1 {PlaceStructureProc, mapping and unmapping content} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
262273 place forget .t.f2
263274 place forget .t.f
264275 } -body {
265276 place .t.f2 -relx 1.0 -rely 1.0 -anchor sw
266 update
277 update idletasks
267278 set result [winfo ismapped .t.f2]
268279 wm iconify .t
269 update
270280 lappend result [winfo ismapped .t.f2]
271281 place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw
272 update
282 update idletasks
273283 lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2]
274284 wm deiconify .t
275 update
285 placeUpdate
276286 lappend result [winfo ismapped .t.f2]
277287 } -result {1 0 40 30 0 1}
278 test place-8.2 {MasterStructureProc, mapping and unmapping slaves} -setup {
288 test place-8.2 {PlaceStructureProc, mapping and unmapping content} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
279289 place forget .t.f2
280290 place forget .t.f
291 update idletasks
281292 } -body {
282293 place .t.f -x 0 -y 0 -width 200 -height 100
283294 place .t.f2 -in .t.f -relx 1.0 -rely 1.0 -anchor sw -width 50 -height 20
284 update
295 update idletasks
285296 set result [winfo ismapped .t.f2]
286297 wm iconify .t
287 update
288298 lappend result [winfo ismapped .t.f2]
289299 place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw
290 update
300 update idletasks
291301 lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2]
292302 wm deiconify .t
293 update
303 placeUpdate
294304 lappend result [winfo ismapped .t.f2]
295305 } -result {1 0 42 32 0 1}
296306 destroy .t
321331 place badopt .foo
322332 } -cleanup {
323333 destroy .foo
324 } -returnCodes error -result {bad option "badopt": must be configure, forget, info, or slaves}
334 } -returnCodes error -result {bad option "badopt": must be configure, content, forget, info, or slaves}
325335 test place-9.6 {PlaceObjCmd, configure errors} -setup {
326336 destroy .foo
327337 } -body {
372382 } -cleanup {
373383 destroy .foo
374384 } -returnCodes error -result {wrong # args: should be "place info pathName"}
375 test place-9.12 {PlaceObjCmd, slaves errors} -setup {
376 destroy .foo
377 } -body {
378 frame .foo
379 place slaves .foo bar
380 } -cleanup {
381 destroy .foo
382 } -returnCodes error -result {wrong # args: should be "place slaves pathName"}
383
384
385 test place-10.1 {ConfigureSlave} -setup {
385 test place-9.12 {PlaceObjCmd, content errors} -setup {
386 destroy .foo
387 } -body {
388 frame .foo
389 place content .foo bar
390 } -cleanup {
391 destroy .foo
392 } -returnCodes error -result {wrong # args: should be "place content pathName"}
393
394
395 test place-10.1 {ConfigureContent} -setup {
386396 destroy .foo
387397 } -body {
388398 frame .foo
390400 } -cleanup {
391401 destroy .foo
392402 } -returnCodes error -result {unknown option "-badopt"}
393 test place-10.2 {ConfigureSlave} -setup {
403 test place-10.2 {ConfigureContent} -setup {
394404 destroy .foo
395405 } -body {
396406 frame .foo
398408 } -cleanup {
399409 destroy .foo
400410 } -returnCodes error -result {value for "-anchor" missing}
401 test place-10.3 {ConfigureSlave} -setup {
411 test place-10.3 {ConfigureContent} -setup {
402412 destroy .foo
403413 } -body {
404414 frame .foo
406416 } -cleanup {
407417 destroy .foo
408418 } -returnCodes error -result {bad bordermode "j": must be inside, outside, or ignore}
409 test place-10.4 {ConfigureSlave} -setup {
419 test place-10.4 {ConfigureContent} -setup {
410420 destroy .foo
411421 } -body {
412422 frame .foo
414424 } -cleanup {
415425 destroy .foo
416426 } -returnCodes error -result {value for "-y" missing}
417
418
419 test place-11.1 {PlaceObjCmd, slaves command} -setup {
420 destroy .foo
421 } -body {
422 frame .foo
423 place slaves .foo
427
428
429 test place-11.1 {PlaceObjCmd, content command} -setup {
430 destroy .foo
431 } -body {
432 frame .foo
433 place content .foo
424434 } -cleanup {
425435 destroy .foo
426436 } -result {}
427 test place-11.2 {PlaceObjCmd, slaves command} -setup {
437 test place-11.2 {PlaceObjCmd, content command} -setup {
428438 destroy .foo .bar
429439 } -body {
430440 frame .foo
431441 frame .bar
432442 place .bar -in .foo
433 place slaves .foo
443 place content .foo
434444 } -cleanup {
435445 destroy .foo .bar
436446 } -result [list .bar]
492502 return $res
493503 }
494504 } -body {
495 # Test all manners of forgetting a slave
505 # Test all manners of forgetting content
496506 frame .f
497507 frame .f.f
498508 stress {
2727 # This probably means that tk wasn't installed properly.
2828
2929 ## it indicates that something went wrong sourcing tk.tcl.
30 ## Ensure that any changes that occured to tk.tcl will work or are properly
30 ## Ensure that any changes that occurred to tk.tcl will work or are properly
3131 ## prevented in a safe interpreter. -- hobbs
3232
3333 # The set of hidden commands is platform dependent:
3434
35 set hidden_cmds {bell cd clipboard encoding exec exit fconfigure glob grab load menu open pwd selection socket source tcl:encoding:dirs toplevel unload wm}
36 lappend hidden_cmds {*}[apply {{} {
35 set hidden_cmds [list bell cd clipboard encoding exec exit \
36 fconfigure glob grab load menu open pwd selection \
37 socket source toplevel unload wm]
38 if {[package vsatisfies [package provide Tcl] 8.6.7-]} {
39 lappend hidden_cmds tcl:encoding:dirs
40 }
41 if {[package vsatisfies [package provide Tcl] 8.7-]} {
42 lappend hidden_cmds file tcl:encoding:system tcl:file:tempdir
3743 foreach cmd {
38 atime attributes copy delete dirname executable exists extension
39 isdirectory isfile link lstat mkdir mtime nativename normalize owned
40 readable readlink rename rootname size stat tail tempfile type
41 volumes writable
42 } {lappend result tcl:file:$cmd}; return $result
43 }}]
44 cmdtype nameofexecutable
45 } {lappend hidden_cmds tcl:info:$cmd}
46 foreach cmd {
47 autopurge list purge status
48 } {lappend hidden_cmds tcl:process:$cmd}
49 foreach cmd {
50 lmkimg lmkzip mkimg mkkey mkzip mount mount_data unmount
51 } {lappend hidden_cmds tcl:zipfs:$cmd}
52 }
53 foreach cmd {
54 atime attributes copy delete dirname executable exists extension
55 isdirectory isfile link lstat mkdir mtime nativename normalize
56 owned readable readlink rename rootname size stat tail tempfile
57 type volumes writable
58 } {lappend hidden_cmds tcl:file:$cmd}
4459 if {[tk windowingsystem] ne "x11"} {
45 lappend hidden_cmds tk_chooseColor tk_chooseDirectory tk_getOpenFile \
46 tk_getSaveFile tk_messageBox
60 lappend hidden_cmds tk_chooseColor tk_chooseDirectory \
61 tk_getOpenFile tk_getSaveFile tk_messageBox
4762 }
4863 if {[llength [info commands send]]} {
4964 lappend hidden_cmds send
181196 destroy $w
182197 } -result {}
183198
184 test safe-5.1 {loading Tk in safe interps without master's clearance} -body {
199 test safe-5.1 {loading Tk in safe interps without parent's clearance} -body {
185200 set i [safe::interpCreate]
186201 interp eval $i {load {} Tk}
187202 } -cleanup {
188203 safe::interpDelete $i
189 } -returnCodes error -result {not allowed}
204 } -returnCodes error -match glob -result {*not allowed}
190205 test safe-5.2 {multi-level Tk loading with clearance} -setup {
191206 set safeParent [safe::interpCreate]
192207 } -body {
1515 # ------------------------------------------------------------------------------
1616 # - Tests 3.*, 6.* test that the fix for ticket de156e9efe implemented in branch
1717 # bug-de156e9efe has been applied and still works. They test that a Safe Base
18 # slave interpreter cannot write to the PRIMARY selection.
19 # - The other tests verify that the master interpreter and an unsafe slave CAN
20 # write to the PRIMARY selection, and therefore that the test scripts
18 # child interpreter cannot write to the PRIMARY selection.
19 # - The other tests verify that the parent interpreter and an child interpreter
20 # CAN write to the PRIMARY selection, and therefore that the test scripts
2121 # themselves are valid.
2222 # - A text, entry, ttk::entry, listbox, spinbox or ttk::spinbox widget can have
2323 # option -exportselection 1, meaning (in an unsafe interpreter) that a
3232 # ------------------------------------------------------------------------------
3333 # Proc ::_test_tmp::unsafeInterp
3434 # ------------------------------------------------------------------------------
35 # Command that creates an unsafe child interpreter and tries to load Tk.
35 # Command that creates an child interpreter and tries to load Tk.
3636 # - This is necessary for loading Tk if the tests are done in the build
3737 # directory without installing Tk. In that case the usual auto_path loading
3838 # mechanism cannot work because the tk binary is not where pkgIndex.tcl says
3939 # it is.
40 # - This command is not needed for Safe Base slaves because safe::loadTk does
40 # - This command is not needed for Safe Base children because safe::loadTk does
4141 # something similar and works correctly.
4242 # - Based on scripts in winSend.test.
4343 # ------------------------------------------------------------------------------
207207 }
208208 }
209209
210 # Do this once for the master interpreter.
210 # Do this once for the parent interpreter.
211211 eval $::_test_tmp::script
212212
213 test safePrimarySelection-1.1 {master interpreter, text, no existing selection} -setup {
214 catch {interp delete slave2}
213 test safePrimarySelection-1.1 {parent interpreter, text, no existing selection} -setup {
214 catch {interp delete child2}
215215 destroy {*}[winfo children .]
216216 ::_test_tmp::clearPrimarySelection
217217 } -body {
222222 ::_test_tmp::clearPrimarySelection
223223 } -result {PAYLOAD}
224224
225 test safePrimarySelection-1.2 {master interpreter, entry, no existing selection} -setup {
226 catch {interp delete slave2}
225 test safePrimarySelection-1.2 {parent interpreter, entry, no existing selection} -setup {
226 catch {interp delete child2}
227227 destroy {*}[winfo children .]
228228 ::_test_tmp::clearPrimarySelection
229229 } -body {
234234 ::_test_tmp::clearPrimarySelection
235235 } -result {PAYLOAD}
236236
237 test safePrimarySelection-1.3 {master interpreter, ttk::entry, no existing selection} -setup {
238 catch {interp delete slave2}
237 test safePrimarySelection-1.3 {parent interpreter, ttk::entry, no existing selection} -setup {
238 catch {interp delete child2}
239239 destroy {*}[winfo children .]
240240 ::_test_tmp::clearPrimarySelection
241241 } -body {
246246 ::_test_tmp::clearPrimarySelection
247247 } -result {PAYLOAD}
248248
249 test safePrimarySelection-1.4 {master interpreter, listbox, no existing selection} -setup {
250 catch {interp delete slave2}
249 test safePrimarySelection-1.4 {parent interpreter, listbox, no existing selection} -setup {
250 catch {interp delete child2}
251251 destroy {*}[winfo children .]
252252 ::_test_tmp::clearPrimarySelection
253253 } -body {
258258 ::_test_tmp::clearPrimarySelection
259259 } -result {PAYLOAD}
260260
261 test safePrimarySelection-1.5 {master interpreter, spinbox as entry, no existing selection} -setup {
262 catch {interp delete slave2}
261 test safePrimarySelection-1.5 {parent interpreter, spinbox as entry, no existing selection} -setup {
262 catch {interp delete child2}
263263 destroy {*}[winfo children .]
264264 ::_test_tmp::clearPrimarySelection
265265 } -body {
270270 ::_test_tmp::clearPrimarySelection
271271 } -result {PAYLOAD}
272272
273 test safePrimarySelection-1.6 {master interpreter, spinbox spun, no existing selection} -setup {
274 catch {interp delete slave2}
273 test safePrimarySelection-1.6 {parent interpreter, spinbox spun, no existing selection} -setup {
274 catch {interp delete child2}
275275 destroy {*}[winfo children .]
276276 ::_test_tmp::clearPrimarySelection
277277 } -body {
282282 ::_test_tmp::clearPrimarySelection
283283 } -result {2}
284284
285 test safePrimarySelection-1.7 {master interpreter, spinbox spun/selected/spun, no existing selection} -setup {
286 catch {interp delete slave2}
285 test safePrimarySelection-1.7 {parent interpreter, spinbox spun/selected/spun, no existing selection} -setup {
286 catch {interp delete child2}
287287 destroy {*}[winfo children .]
288288 ::_test_tmp::clearPrimarySelection
289289 } -body {
294294 ::_test_tmp::clearPrimarySelection
295295 } -result {3}
296296
297 test safePrimarySelection-1.8 {master interpreter, ttk::spinbox as entry, no existing selection} -setup {
298 catch {interp delete slave2}
297 test safePrimarySelection-1.8 {parent interpreter, ttk::spinbox as entry, no existing selection} -setup {
298 catch {interp delete child2}
299299 destroy {*}[winfo children .]
300300 ::_test_tmp::clearPrimarySelection
301301 } -body {
306306 ::_test_tmp::clearPrimarySelection
307307 } -result {PAYLOAD}
308308
309 test safePrimarySelection-1.9 {master interpreter, ttk::spinbox spun, no existing selection} -setup {
310 catch {interp delete slave2}
309 test safePrimarySelection-1.9 {parent interpreter, ttk::spinbox spun, no existing selection} -setup {
310 catch {interp delete child2}
311311 destroy {*}[winfo children .]
312312 ::_test_tmp::clearPrimarySelection
313313 } -body {
318318 ::_test_tmp::clearPrimarySelection
319319 } -result {2}
320320
321 test safePrimarySelection-1.10 {master interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
322 catch {interp delete slave2}
321 test safePrimarySelection-1.10 {parent interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
322 catch {interp delete child2}
323323 destroy {*}[winfo children .]
324324 ::_test_tmp::clearPrimarySelection
325325 } -body {
330330 ::_test_tmp::clearPrimarySelection
331331 } -result {3}
332332
333 test safePrimarySelection-2.1 {unsafe slave interpreter, text, no existing selection} -setup {
334 catch {interp delete slave2}
335 destroy {*}[winfo children .]
336 ::_test_tmp::clearPrimarySelection
337 } -body {
338 set int2 slave2
333 test safePrimarySelection-2.1 {child interpreter, text, no existing selection} -setup {
334 catch {interp delete child2}
335 destroy {*}[winfo children .]
336 ::_test_tmp::clearPrimarySelection
337 } -body {
338 set int2 child2
339339 ::_test_tmp::unsafeInterp $int2
340340 $int2 eval $::_test_tmp::script
341341 $int2 eval ::_test_tmp::tryText
347347 ::_test_tmp::clearPrimarySelection
348348 } -result {PAYLOAD}
349349
350 test safePrimarySelection-2.2 {unsafe slave interpreter, entry, no existing selection} -setup {
351 catch {interp delete slave2}
352 destroy {*}[winfo children .]
353 ::_test_tmp::clearPrimarySelection
354 } -body {
355 set int2 slave2
350 test safePrimarySelection-2.2 {child interpreter, entry, no existing selection} -setup {
351 catch {interp delete child2}
352 destroy {*}[winfo children .]
353 ::_test_tmp::clearPrimarySelection
354 } -body {
355 set int2 child2
356356 ::_test_tmp::unsafeInterp $int2
357357 $int2 eval $::_test_tmp::script
358358 $int2 eval ::_test_tmp::tryEntry
364364 ::_test_tmp::clearPrimarySelection
365365 } -result {PAYLOAD}
366366
367 test safePrimarySelection-2.3 {unsafe slave interpreter, ttk::entry, no existing selection} -setup {
368 catch {interp delete slave2}
369 destroy {*}[winfo children .]
370 ::_test_tmp::clearPrimarySelection
371 } -body {
372 set int2 slave2
367 test safePrimarySelection-2.3 {child interpreter, ttk::entry, no existing selection} -setup {
368 catch {interp delete child2}
369 destroy {*}[winfo children .]
370 ::_test_tmp::clearPrimarySelection
371 } -body {
372 set int2 child2
373373 ::_test_tmp::unsafeInterp $int2
374374 $int2 eval $::_test_tmp::script
375375 $int2 eval ::_test_tmp::tryTtkEntry
381381 ::_test_tmp::clearPrimarySelection
382382 } -result {PAYLOAD}
383383
384 test safePrimarySelection-2.4 {unsafe slave interpreter, listbox, no existing selection} -setup {
385 catch {interp delete slave2}
386 destroy {*}[winfo children .]
387 ::_test_tmp::clearPrimarySelection
388 } -body {
389 set int2 slave2
384 test safePrimarySelection-2.4 {child interpreter, listbox, no existing selection} -setup {
385 catch {interp delete child2}
386 destroy {*}[winfo children .]
387 ::_test_tmp::clearPrimarySelection
388 } -body {
389 set int2 child2
390390 ::_test_tmp::unsafeInterp $int2
391391 $int2 eval $::_test_tmp::script
392392 $int2 eval ::_test_tmp::tryListbox
398398 ::_test_tmp::clearPrimarySelection
399399 } -result {PAYLOAD}
400400
401 test safePrimarySelection-2.5 {unsafe slave interpreter, spinbox as entry, no existing selection} -setup {
402 catch {interp delete slave2}
403 destroy {*}[winfo children .]
404 ::_test_tmp::clearPrimarySelection
405 } -body {
406 set int2 slave2
401 test safePrimarySelection-2.5 {child interpreter, spinbox as entry, no existing selection} -setup {
402 catch {interp delete child2}
403 destroy {*}[winfo children .]
404 ::_test_tmp::clearPrimarySelection
405 } -body {
406 set int2 child2
407407 ::_test_tmp::unsafeInterp $int2
408408 $int2 eval $::_test_tmp::script
409409 $int2 eval ::_test_tmp::trySpinbox 1
415415 ::_test_tmp::clearPrimarySelection
416416 } -result {PAYLOAD}
417417
418 test safePrimarySelection-2.6 {unsafe slave interpreter, spinbox spun, no existing selection} -setup {
419 catch {interp delete slave2}
420 destroy {*}[winfo children .]
421 ::_test_tmp::clearPrimarySelection
422 } -body {
423 set int2 slave2
418 test safePrimarySelection-2.6 {child interpreter, spinbox spun, no existing selection} -setup {
419 catch {interp delete child2}
420 destroy {*}[winfo children .]
421 ::_test_tmp::clearPrimarySelection
422 } -body {
423 set int2 child2
424424 ::_test_tmp::unsafeInterp $int2
425425 $int2 eval $::_test_tmp::script
426426 $int2 eval ::_test_tmp::trySpinbox 2
432432 ::_test_tmp::clearPrimarySelection
433433 } -result {2}
434434
435 test safePrimarySelection-2.7 {unsafe slave interpreter, spinbox spun/selected/spun, no existing selection} -setup {
436 catch {interp delete slave2}
437 destroy {*}[winfo children .]
438 ::_test_tmp::clearPrimarySelection
439 } -body {
440 set int2 slave2
435 test safePrimarySelection-2.7 {child interpreter, spinbox spun/selected/spun, no existing selection} -setup {
436 catch {interp delete child2}
437 destroy {*}[winfo children .]
438 ::_test_tmp::clearPrimarySelection
439 } -body {
440 set int2 child2
441441 ::_test_tmp::unsafeInterp $int2
442442 $int2 eval $::_test_tmp::script
443443 $int2 eval ::_test_tmp::trySpinbox 3
449449 ::_test_tmp::clearPrimarySelection
450450 } -result {3}
451451
452 test safePrimarySelection-2.8 {unsafe slave interpreter, ttk::spinbox as entry, no existing selection} -setup {
453 catch {interp delete slave2}
454 destroy {*}[winfo children .]
455 ::_test_tmp::clearPrimarySelection
456 } -body {
457 set int2 slave2
452 test safePrimarySelection-2.8 {child interpreter, ttk::spinbox as entry, no existing selection} -setup {
453 catch {interp delete child2}
454 destroy {*}[winfo children .]
455 ::_test_tmp::clearPrimarySelection
456 } -body {
457 set int2 child2
458458 ::_test_tmp::unsafeInterp $int2
459459 $int2 eval $::_test_tmp::script
460460 $int2 eval ::_test_tmp::tryTtkSpinbox 1
466466 ::_test_tmp::clearPrimarySelection
467467 } -result {PAYLOAD}
468468
469 test safePrimarySelection-2.9 {unsafe slave interpreter, ttk::spinbox spun, no existing selection} -setup {
470 catch {interp delete slave2}
471 destroy {*}[winfo children .]
472 ::_test_tmp::clearPrimarySelection
473 } -body {
474 set int2 slave2
469 test safePrimarySelection-2.9 {child interpreter, ttk::spinbox spun, no existing selection} -setup {
470 catch {interp delete child2}
471 destroy {*}[winfo children .]
472 ::_test_tmp::clearPrimarySelection
473 } -body {
474 set int2 child2
475475 ::_test_tmp::unsafeInterp $int2
476476 $int2 eval $::_test_tmp::script
477477 $int2 eval ::_test_tmp::tryTtkSpinbox 2
483483 ::_test_tmp::clearPrimarySelection
484484 } -result {2}
485485
486 test safePrimarySelection-2.10 {unsafe slave interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
487 catch {interp delete slave2}
488 destroy {*}[winfo children .]
489 ::_test_tmp::clearPrimarySelection
490 } -body {
491 set int2 slave2
486 test safePrimarySelection-2.10 {child interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
487 catch {interp delete child2}
488 destroy {*}[winfo children .]
489 ::_test_tmp::clearPrimarySelection
490 } -body {
491 set int2 child2
492492 ::_test_tmp::unsafeInterp $int2
493493 $int2 eval $::_test_tmp::script
494494 $int2 eval ::_test_tmp::tryTtkSpinbox 3
500500 ::_test_tmp::clearPrimarySelection
501501 } -result {3}
502502
503 test safePrimarySelection-3.1 {IMPORTANT, safe slave interpreter, text, no existing selection} -setup {
504 catch {interp delete slave2}
505 destroy {*}[winfo children .]
506 ::_test_tmp::clearPrimarySelection
507 } -body {
508 set res0 [::_test_tmp::getPrimarySelection]
509 set int2 slave2
503 test safePrimarySelection-3.1 {IMPORTANT, safe interpreter, text, no existing selection} -setup {
504 catch {interp delete child2}
505 destroy {*}[winfo children .]
506 ::_test_tmp::clearPrimarySelection
507 } -body {
508 set res0 [::_test_tmp::getPrimarySelection]
509 set int2 child2
510510 ::safe::interpCreate $int2
511511 ::safe::loadTk $int2
512512 $int2 eval $::_test_tmp::script
521521 ::_test_tmp::clearPrimarySelection
522522 } -result {----}
523523
524 test safePrimarySelection-3.2 {IMPORTANT, safe slave interpreter, entry, no existing selection} -setup {
525 catch {interp delete slave2}
526 destroy {*}[winfo children .]
527 ::_test_tmp::clearPrimarySelection
528 } -body {
529 set res0 [::_test_tmp::getPrimarySelection]
530 set int2 slave2
524 test safePrimarySelection-3.2 {IMPORTANT, safe interpreter, entry, no existing selection} -setup {
525 catch {interp delete child2}
526 destroy {*}[winfo children .]
527 ::_test_tmp::clearPrimarySelection
528 } -body {
529 set res0 [::_test_tmp::getPrimarySelection]
530 set int2 child2
531531 ::safe::interpCreate $int2
532532 ::safe::loadTk $int2
533533 $int2 eval $::_test_tmp::script
542542 ::_test_tmp::clearPrimarySelection
543543 } -result {----}
544544
545 test safePrimarySelection-3.3 {IMPORTANT, safe slave interpreter, ttk::entry, no existing selection} -setup {
546 catch {interp delete slave2}
547 destroy {*}[winfo children .]
548 ::_test_tmp::clearPrimarySelection
549 } -body {
550 set res0 [::_test_tmp::getPrimarySelection]
551 set int2 slave2
545 test safePrimarySelection-3.3 {IMPORTANT, safe interpreter, ttk::entry, no existing selection} -setup {
546 catch {interp delete child2}
547 destroy {*}[winfo children .]
548 ::_test_tmp::clearPrimarySelection
549 } -body {
550 set res0 [::_test_tmp::getPrimarySelection]
551 set int2 child2
552552 ::safe::interpCreate $int2
553553 ::safe::loadTk $int2
554554 $int2 eval $::_test_tmp::script
563563 ::_test_tmp::clearPrimarySelection
564564 } -result {----}
565565
566 test safePrimarySelection-3.4 {IMPORTANT, safe slave interpreter, listbox, no existing selection} -setup {
567 catch {interp delete slave2}
568 destroy {*}[winfo children .]
569 ::_test_tmp::clearPrimarySelection
570 } -body {
571 set res0 [::_test_tmp::getPrimarySelection]
572 set int2 slave2
566 test safePrimarySelection-3.4 {IMPORTANT, safe interpreter, listbox, no existing selection} -setup {
567 catch {interp delete child2}
568 destroy {*}[winfo children .]
569 ::_test_tmp::clearPrimarySelection
570 } -body {
571 set res0 [::_test_tmp::getPrimarySelection]
572 set int2 child2
573573 ::safe::interpCreate $int2
574574 ::safe::loadTk $int2
575575 $int2 eval $::_test_tmp::script
584584 ::_test_tmp::clearPrimarySelection
585585 } -result {----}
586586
587 test safePrimarySelection-3.5 {IMPORTANT, safe slave interpreter, spinbox as entry, no existing selection} -setup {
588 catch {interp delete slave2}
589 destroy {*}[winfo children .]
590 ::_test_tmp::clearPrimarySelection
591 } -body {
592 set res0 [::_test_tmp::getPrimarySelection]
593 set int2 slave2
587 test safePrimarySelection-3.5 {IMPORTANT, safe interpreter, spinbox as entry, no existing selection} -setup {
588 catch {interp delete child2}
589 destroy {*}[winfo children .]
590 ::_test_tmp::clearPrimarySelection
591 } -body {
592 set res0 [::_test_tmp::getPrimarySelection]
593 set int2 child2
594594 ::safe::interpCreate $int2
595595 ::safe::loadTk $int2
596596 $int2 eval $::_test_tmp::script
605605 ::_test_tmp::clearPrimarySelection
606606 } -result {----}
607607
608 test safePrimarySelection-3.6 {IMPORTANT, safe slave interpreter, spinbox spun, no existing selection} -setup {
609 catch {interp delete slave2}
610 destroy {*}[winfo children .]
611 ::_test_tmp::clearPrimarySelection
612 } -body {
613 set res0 [::_test_tmp::getPrimarySelection]
614 set int2 slave2
608 test safePrimarySelection-3.6 {IMPORTANT, safe interpreter, spinbox spun, no existing selection} -setup {
609 catch {interp delete child2}
610 destroy {*}[winfo children .]
611 ::_test_tmp::clearPrimarySelection
612 } -body {
613 set res0 [::_test_tmp::getPrimarySelection]
614 set int2 child2
615615 ::safe::interpCreate $int2
616616 ::safe::loadTk $int2
617617 $int2 eval $::_test_tmp::script
626626 ::_test_tmp::clearPrimarySelection
627627 } -result {----}
628628
629 test safePrimarySelection-3.7 {IMPORTANT, safe slave interpreter, spinbox spun/selected/spun, no existing selection} -setup {
630 catch {interp delete slave2}
631 destroy {*}[winfo children .]
632 ::_test_tmp::clearPrimarySelection
633 } -body {
634 set res0 [::_test_tmp::getPrimarySelection]
635 set int2 slave2
629 test safePrimarySelection-3.7 {IMPORTANT, safe interpreter, spinbox spun/selected/spun, no existing selection} -setup {
630 catch {interp delete child2}
631 destroy {*}[winfo children .]
632 ::_test_tmp::clearPrimarySelection
633 } -body {
634 set res0 [::_test_tmp::getPrimarySelection]
635 set int2 child2
636636 ::safe::interpCreate $int2
637637 ::safe::loadTk $int2
638638 $int2 eval $::_test_tmp::script
647647 ::_test_tmp::clearPrimarySelection
648648 } -result {----}
649649
650 test safePrimarySelection-3.8 {IMPORTANT, safe slave interpreter, ttk::spinbox as entry, no existing selection} -setup {
651 catch {interp delete slave2}
652 destroy {*}[winfo children .]
653 ::_test_tmp::clearPrimarySelection
654 } -body {
655 set res0 [::_test_tmp::getPrimarySelection]
656 set int2 slave2
650 test safePrimarySelection-3.8 {IMPORTANT, safe interpreter, ttk::spinbox as entry, no existing selection} -setup {
651 catch {interp delete child2}
652 destroy {*}[winfo children .]
653 ::_test_tmp::clearPrimarySelection
654 } -body {
655 set res0 [::_test_tmp::getPrimarySelection]
656 set int2 child2
657657 ::safe::interpCreate $int2
658658 ::safe::loadTk $int2
659659 $int2 eval $::_test_tmp::script
668668 ::_test_tmp::clearPrimarySelection
669669 } -result {----}
670670
671 test safePrimarySelection-3.9 {IMPORTANT, safe slave interpreter, ttk::spinbox spun, no existing selection} -setup {
672 catch {interp delete slave2}
673 destroy {*}[winfo children .]
674 ::_test_tmp::clearPrimarySelection
675 } -body {
676 set res0 [::_test_tmp::getPrimarySelection]
677 set int2 slave2
671 test safePrimarySelection-3.9 {IMPORTANT, safe interpreter, ttk::spinbox spun, no existing selection} -setup {
672 catch {interp delete child2}
673 destroy {*}[winfo children .]
674 ::_test_tmp::clearPrimarySelection
675 } -body {
676 set res0 [::_test_tmp::getPrimarySelection]
677 set int2 child2
678678 ::safe::interpCreate $int2
679679 ::safe::loadTk $int2
680680 $int2 eval $::_test_tmp::script
689689 ::_test_tmp::clearPrimarySelection
690690 } -result {----}
691691
692 test safePrimarySelection-3.10 {IMPORTANT, safe slave interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
693 catch {interp delete slave2}
694 destroy {*}[winfo children .]
695 ::_test_tmp::clearPrimarySelection
696 } -body {
697 set res0 [::_test_tmp::getPrimarySelection]
698 set int2 slave2
692 test safePrimarySelection-3.10 {IMPORTANT, safe interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup {
693 catch {interp delete child2}
694 destroy {*}[winfo children .]
695 ::_test_tmp::clearPrimarySelection
696 } -body {
697 set res0 [::_test_tmp::getPrimarySelection]
698 set int2 child2
699699 ::safe::interpCreate $int2
700700 ::safe::loadTk $int2
701701 $int2 eval $::_test_tmp::script
710710 ::_test_tmp::clearPrimarySelection
711711 } -result {----}
712712
713 test safePrimarySelection-4.1 {master interpreter, text, existing selection} -setup {
714 catch {interp delete slave2}
713 test safePrimarySelection-4.1 {parent interpreter, text, existing selection} -setup {
714 catch {interp delete child2}
715715 destroy {*}[winfo children .]
716716 ::_test_tmp::setPrimarySelection
717717 } -body {
722722 ::_test_tmp::clearPrimarySelection
723723 } -result {PAYLOAD}
724724
725 test safePrimarySelection-4.2 {master interpreter, entry, existing selection} -setup {
726 catch {interp delete slave2}
725 test safePrimarySelection-4.2 {parent interpreter, entry, existing selection} -setup {
726 catch {interp delete child2}
727727 destroy {*}[winfo children .]
728728 ::_test_tmp::setPrimarySelection
729729 } -body {
734734 ::_test_tmp::clearPrimarySelection
735735 } -result {PAYLOAD}
736736
737 test safePrimarySelection-4.3 {master interpreter, ttk::entry, existing selection} -setup {
738 catch {interp delete slave2}
737 test safePrimarySelection-4.3 {parent interpreter, ttk::entry, existing selection} -setup {
738 catch {interp delete child2}
739739 destroy {*}[winfo children .]
740740 ::_test_tmp::setPrimarySelection
741741 } -body {
746746 ::_test_tmp::clearPrimarySelection
747747 } -result {PAYLOAD}
748748
749 test safePrimarySelection-4.4 {master interpreter, listbox, existing selection} -setup {
750 catch {interp delete slave2}
749 test safePrimarySelection-4.4 {parent interpreter, listbox, existing selection} -setup {
750 catch {interp delete child2}
751751 destroy {*}[winfo children .]
752752 ::_test_tmp::setPrimarySelection
753753 } -body {
758758 ::_test_tmp::clearPrimarySelection
759759 } -result {PAYLOAD}
760760
761 test safePrimarySelection-4.5 {master interpreter, spinbox as entry, existing selection} -setup {
762 catch {interp delete slave2}
761 test safePrimarySelection-4.5 {parent interpreter, spinbox as entry, existing selection} -setup {
762 catch {interp delete child2}
763763 destroy {*}[winfo children .]
764764 ::_test_tmp::setPrimarySelection
765765 } -body {
770770 ::_test_tmp::clearPrimarySelection
771771 } -result {PAYLOAD}
772772
773 test safePrimarySelection-4.6 {master interpreter, spinbox spun, existing selection} -setup {
774 catch {interp delete slave2}
773 test safePrimarySelection-4.6 {parent interpreter, spinbox spun, existing selection} -setup {
774 catch {interp delete child2}
775775 destroy {*}[winfo children .]
776776 ::_test_tmp::setPrimarySelection
777777 } -body {
782782 ::_test_tmp::clearPrimarySelection
783783 } -result {2}
784784
785 test safePrimarySelection-4.7 {master interpreter, spinbox spun/selected/spun, existing selection} -setup {
786 catch {interp delete slave2}
785 test safePrimarySelection-4.7 {parent interpreter, spinbox spun/selected/spun, existing selection} -setup {
786 catch {interp delete child2}
787787 destroy {*}[winfo children .]
788788 ::_test_tmp::setPrimarySelection
789789 } -body {
794794 ::_test_tmp::clearPrimarySelection
795795 } -result {3}
796796
797 test safePrimarySelection-4.8 {master interpreter, ttk::spinbox as entry, existing selection} -setup {
798 catch {interp delete slave2}
797 test safePrimarySelection-4.8 {parent interpreter, ttk::spinbox as entry, existing selection} -setup {
798 catch {interp delete child2}
799799 destroy {*}[winfo children .]
800800 ::_test_tmp::setPrimarySelection
801801 } -body {
806806 ::_test_tmp::clearPrimarySelection
807807 } -result {PAYLOAD}
808808
809 test safePrimarySelection-4.9 {master interpreter, ttk::spinbox spun, existing selection} -setup {
810 catch {interp delete slave2}
809 test safePrimarySelection-4.9 {parent interpreter, ttk::spinbox spun, existing selection} -setup {
810 catch {interp delete child2}
811811 destroy {*}[winfo children .]
812812 ::_test_tmp::setPrimarySelection
813813 } -body {
818818 ::_test_tmp::clearPrimarySelection
819819 } -result {2}
820820
821 test safePrimarySelection-4.10 {master interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
822 catch {interp delete slave2}
821 test safePrimarySelection-4.10 {parent interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
822 catch {interp delete child2}
823823 destroy {*}[winfo children .]
824824 ::_test_tmp::setPrimarySelection
825825 } -body {
830830 ::_test_tmp::clearPrimarySelection
831831 } -result {3}
832832
833 test safePrimarySelection-5.1 {unsafe slave interpreter, text, existing selection} -setup {
834 catch {interp delete slave2}
835 destroy {*}[winfo children .]
836 ::_test_tmp::setPrimarySelection
837 } -body {
838 set int2 slave2
833 test safePrimarySelection-5.1 {child interpreter, text, existing selection} -setup {
834 catch {interp delete child2}
835 destroy {*}[winfo children .]
836 ::_test_tmp::setPrimarySelection
837 } -body {
838 set int2 child2
839839 ::_test_tmp::unsafeInterp $int2
840840 $int2 eval $::_test_tmp::script
841841 $int2 eval ::_test_tmp::tryText
847847 ::_test_tmp::clearPrimarySelection
848848 } -result {PAYLOAD}
849849
850 test safePrimarySelection-5.2 {unsafe slave interpreter, entry, existing selection} -setup {
851 catch {interp delete slave2}
852 destroy {*}[winfo children .]
853 ::_test_tmp::setPrimarySelection
854 } -body {
855 set int2 slave2
850 test safePrimarySelection-5.2 {child interpreter, entry, existing selection} -setup {
851 catch {interp delete child2}
852 destroy {*}[winfo children .]
853 ::_test_tmp::setPrimarySelection
854 } -body {
855 set int2 child2
856856 ::_test_tmp::unsafeInterp $int2
857857 $int2 eval $::_test_tmp::script
858858 $int2 eval ::_test_tmp::tryEntry
864864 ::_test_tmp::clearPrimarySelection
865865 } -result {PAYLOAD}
866866
867 test safePrimarySelection-5.3 {unsafe slave interpreter, ttk::entry, existing selection} -setup {
868 catch {interp delete slave2}
869 destroy {*}[winfo children .]
870 ::_test_tmp::setPrimarySelection
871 } -body {
872 set int2 slave2
867 test safePrimarySelection-5.3 {child interpreter, ttk::entry, existing selection} -setup {
868 catch {interp delete child2}
869 destroy {*}[winfo children .]
870 ::_test_tmp::setPrimarySelection
871 } -body {
872 set int2 child2
873873 ::_test_tmp::unsafeInterp $int2
874874 $int2 eval $::_test_tmp::script
875875 $int2 eval ::_test_tmp::tryTtkEntry
881881 ::_test_tmp::clearPrimarySelection
882882 } -result {PAYLOAD}
883883
884 test safePrimarySelection-5.4 {unsafe slave interpreter, listbox, existing selection} -setup {
885 catch {interp delete slave2}
886 destroy {*}[winfo children .]
887 ::_test_tmp::setPrimarySelection
888 } -body {
889 set int2 slave2
884 test safePrimarySelection-5.4 {child interpreter, listbox, existing selection} -setup {
885 catch {interp delete child2}
886 destroy {*}[winfo children .]
887 ::_test_tmp::setPrimarySelection
888 } -body {
889 set int2 child2
890890 ::_test_tmp::unsafeInterp $int2
891891 $int2 eval $::_test_tmp::script
892892 $int2 eval ::_test_tmp::tryListbox
898898 ::_test_tmp::clearPrimarySelection
899899 } -result {PAYLOAD}
900900
901 test safePrimarySelection-5.5 {unsafe slave interpreter, spinbox as entry, existing selection} -setup {
902 catch {interp delete slave2}
903 destroy {*}[winfo children .]
904 ::_test_tmp::setPrimarySelection
905 } -body {
906 set int2 slave2
901 test safePrimarySelection-5.5 {child interpreter, spinbox as entry, existing selection} -setup {
902 catch {interp delete child2}
903 destroy {*}[winfo children .]
904 ::_test_tmp::setPrimarySelection
905 } -body {
906 set int2 child2
907907 ::_test_tmp::unsafeInterp $int2
908908 $int2 eval $::_test_tmp::script
909909 $int2 eval ::_test_tmp::trySpinbox 1
915915 ::_test_tmp::clearPrimarySelection
916916 } -result {PAYLOAD}
917917
918 test safePrimarySelection-5.6 {unsafe slave interpreter, spinbox spun, existing selection} -setup {
919 catch {interp delete slave2}
920 destroy {*}[winfo children .]
921 ::_test_tmp::setPrimarySelection
922 } -body {
923 set int2 slave2
918 test safePrimarySelection-5.6 {child interpreter, spinbox spun, existing selection} -setup {
919 catch {interp delete child2}
920 destroy {*}[winfo children .]
921 ::_test_tmp::setPrimarySelection
922 } -body {
923 set int2 child2
924924 ::_test_tmp::unsafeInterp $int2
925925 $int2 eval $::_test_tmp::script
926926 $int2 eval ::_test_tmp::trySpinbox 2
932932 ::_test_tmp::clearPrimarySelection
933933 } -result {2}
934934
935 test safePrimarySelection-5.7 {unsafe slave interpreter, spinbox spun/selected/spun, existing selection} -setup {
936 catch {interp delete slave2}
937 destroy {*}[winfo children .]
938 ::_test_tmp::setPrimarySelection
939 } -body {
940 set int2 slave2
935 test safePrimarySelection-5.7 {child interpreter, spinbox spun/selected/spun, existing selection} -setup {
936 catch {interp delete child2}
937 destroy {*}[winfo children .]
938 ::_test_tmp::setPrimarySelection
939 } -body {
940 set int2 child2
941941 ::_test_tmp::unsafeInterp $int2
942942 $int2 eval $::_test_tmp::script
943943 $int2 eval ::_test_tmp::trySpinbox 3
949949 ::_test_tmp::clearPrimarySelection
950950 } -result {3}
951951
952 test safePrimarySelection-5.8 {unsafe slave interpreter, ttk::spinbox as entry, existing selection} -setup {
953 catch {interp delete slave2}
954 destroy {*}[winfo children .]
955 ::_test_tmp::setPrimarySelection
956 } -body {
957 set int2 slave2
952 test safePrimarySelection-5.8 {child interpreter, ttk::spinbox as entry, existing selection} -setup {
953 catch {interp delete child2}
954 destroy {*}[winfo children .]
955 ::_test_tmp::setPrimarySelection
956 } -body {
957 set int2 child2
958958 ::_test_tmp::unsafeInterp $int2
959959 $int2 eval $::_test_tmp::script
960960 $int2 eval ::_test_tmp::tryTtkSpinbox 1
966966 ::_test_tmp::clearPrimarySelection
967967 } -result {PAYLOAD}
968968
969 test safePrimarySelection-5.9 {unsafe slave interpreter, ttk::spinbox spun, existing selection} -setup {
970 catch {interp delete slave2}
971 destroy {*}[winfo children .]
972 ::_test_tmp::setPrimarySelection
973 } -body {
974 set int2 slave2
969 test safePrimarySelection-5.9 {child interpreter, ttk::spinbox spun, existing selection} -setup {
970 catch {interp delete child2}
971 destroy {*}[winfo children .]
972 ::_test_tmp::setPrimarySelection
973 } -body {
974 set int2 child2
975975 ::_test_tmp::unsafeInterp $int2
976976 $int2 eval $::_test_tmp::script
977977 $int2 eval ::_test_tmp::tryTtkSpinbox 2
983983 ::_test_tmp::clearPrimarySelection
984984 } -result {2}
985985
986 test safePrimarySelection-5.10 {unsafe slave interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
987 catch {interp delete slave2}
988 destroy {*}[winfo children .]
989 ::_test_tmp::setPrimarySelection
990 } -body {
991 set int2 slave2
986 test safePrimarySelection-5.10 {child interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
987 catch {interp delete child2}
988 destroy {*}[winfo children .]
989 ::_test_tmp::setPrimarySelection
990 } -body {
991 set int2 child2
992992 ::_test_tmp::unsafeInterp $int2
993993 $int2 eval $::_test_tmp::script
994994 $int2 eval ::_test_tmp::tryTtkSpinbox 3
10001000 ::_test_tmp::clearPrimarySelection
10011001 } -result {3}
10021002
1003 test safePrimarySelection-6.1 {IMPORTANT, safe slave interpreter, text, existing selection} -setup {
1004 catch {interp delete slave2}
1005 destroy {*}[winfo children .]
1006 ::_test_tmp::setPrimarySelection
1007 } -body {
1008 set res0 [::_test_tmp::getPrimarySelection]
1009 set int2 slave2
1003 test safePrimarySelection-6.1 {IMPORTANT, safe interpreter, text, existing selection} -setup {
1004 catch {interp delete child2}
1005 destroy {*}[winfo children .]
1006 ::_test_tmp::setPrimarySelection
1007 } -body {
1008 set res0 [::_test_tmp::getPrimarySelection]
1009 set int2 child2
10101010 ::safe::interpCreate $int2
10111011 ::safe::loadTk $int2
10121012 $int2 eval $::_test_tmp::script
10211021 ::_test_tmp::clearPrimarySelection
10221022 } -result {OLD_VALUE----OLD_VALUE}
10231023
1024 test safePrimarySelection-6.2 {IMPORTANT, safe slave interpreter, entry, existing selection} -setup {
1025 catch {interp delete slave2}
1026 destroy {*}[winfo children .]
1027 ::_test_tmp::setPrimarySelection
1028 } -body {
1029 set res0 [::_test_tmp::getPrimarySelection]
1030 set int2 slave2
1024 test safePrimarySelection-6.2 {IMPORTANT, safe interpreter, entry, existing selection} -setup {
1025 catch {interp delete child2}
1026 destroy {*}[winfo children .]
1027 ::_test_tmp::setPrimarySelection
1028 } -body {
1029 set res0 [::_test_tmp::getPrimarySelection]
1030 set int2 child2
10311031 ::safe::interpCreate $int2
10321032 ::safe::loadTk $int2
10331033 $int2 eval $::_test_tmp::script
10421042 ::_test_tmp::clearPrimarySelection
10431043 } -result {OLD_VALUE----OLD_VALUE}
10441044
1045 test safePrimarySelection-6.3 {IMPORTANT, safe slave interpreter, ttk::entry, existing selection} -setup {
1046 catch {interp delete slave2}
1047 destroy {*}[winfo children .]
1048 ::_test_tmp::setPrimarySelection
1049 } -body {
1050 set res0 [::_test_tmp::getPrimarySelection]
1051 set int2 slave2
1045 test safePrimarySelection-6.3 {IMPORTANT, safe interpreter, ttk::entry, existing selection} -setup {
1046 catch {interp delete child2}
1047 destroy {*}[winfo children .]
1048 ::_test_tmp::setPrimarySelection
1049 } -body {
1050 set res0 [::_test_tmp::getPrimarySelection]
1051 set int2 child2
10521052 ::safe::interpCreate $int2
10531053 ::safe::loadTk $int2
10541054 $int2 eval $::_test_tmp::script
10631063 ::_test_tmp::clearPrimarySelection
10641064 } -result {OLD_VALUE----OLD_VALUE}
10651065
1066 test safePrimarySelection-6.4 {IMPORTANT, safe slave interpreter, listbox, existing selection} -setup {
1067 catch {interp delete slave2}
1068 destroy {*}[winfo children .]
1069 ::_test_tmp::setPrimarySelection
1070 } -body {
1071 set res0 [::_test_tmp::getPrimarySelection]
1072 set int2 slave2
1066 test safePrimarySelection-6.4 {IMPORTANT, safe interpreter, listbox, existing selection} -setup {
1067 catch {interp delete child2}
1068 destroy {*}[winfo children .]
1069 ::_test_tmp::setPrimarySelection
1070 } -body {
1071 set res0 [::_test_tmp::getPrimarySelection]
1072 set int2 child2
10731073 ::safe::interpCreate $int2
10741074 ::safe::loadTk $int2
10751075 $int2 eval $::_test_tmp::script
10841084 ::_test_tmp::clearPrimarySelection
10851085 } -result {OLD_VALUE----OLD_VALUE}
10861086
1087 test safePrimarySelection-6.5 {IMPORTANT, safe slave interpreter, spinbox as entry, existing selection} -setup {
1088 catch {interp delete slave2}
1089 destroy {*}[winfo children .]
1090 ::_test_tmp::setPrimarySelection
1091 } -body {
1092 set res0 [::_test_tmp::getPrimarySelection]
1093 set int2 slave2
1087 test safePrimarySelection-6.5 {IMPORTANT, safe interpreter, spinbox as entry, existing selection} -setup {
1088 catch {interp delete child2}
1089 destroy {*}[winfo children .]
1090 ::_test_tmp::setPrimarySelection
1091 } -body {
1092 set res0 [::_test_tmp::getPrimarySelection]
1093 set int2 child2
10941094 ::safe::interpCreate $int2
10951095 ::safe::loadTk $int2
10961096 $int2 eval $::_test_tmp::script
11051105 ::_test_tmp::clearPrimarySelection
11061106 } -result {OLD_VALUE----OLD_VALUE}
11071107
1108 test safePrimarySelection-6.6 {IMPORTANT, safe slave interpreter, spinbox spun, existing selection} -setup {
1109 catch {interp delete slave2}
1110 destroy {*}[winfo children .]
1111 ::_test_tmp::setPrimarySelection
1112 } -body {
1113 set res0 [::_test_tmp::getPrimarySelection]
1114 set int2 slave2
1108 test safePrimarySelection-6.6 {IMPORTANT, safe interpreter, spinbox spun, existing selection} -setup {
1109 catch {interp delete child2}
1110 destroy {*}[winfo children .]
1111 ::_test_tmp::setPrimarySelection
1112 } -body {
1113 set res0 [::_test_tmp::getPrimarySelection]
1114 set int2 child2
11151115 ::safe::interpCreate $int2
11161116 ::safe::loadTk $int2
11171117 $int2 eval $::_test_tmp::script
11261126 ::_test_tmp::clearPrimarySelection
11271127 } -result {OLD_VALUE----OLD_VALUE}
11281128
1129 test safePrimarySelection-6.7 {IMPORTANT, safe slave interpreter, spinbox spun/selected/spun, existing selection} -setup {
1130 catch {interp delete slave2}
1131 destroy {*}[winfo children .]
1132 ::_test_tmp::setPrimarySelection
1133 } -body {
1134 set res0 [::_test_tmp::getPrimarySelection]
1135 set int2 slave2
1129 test safePrimarySelection-6.7 {IMPORTANT, safe interpreter, spinbox spun/selected/spun, existing selection} -setup {
1130 catch {interp delete child2}
1131 destroy {*}[winfo children .]
1132 ::_test_tmp::setPrimarySelection
1133 } -body {
1134 set res0 [::_test_tmp::getPrimarySelection]
1135 set int2 child2
11361136 ::safe::interpCreate $int2
11371137 ::safe::loadTk $int2
11381138 $int2 eval $::_test_tmp::script
11471147 ::_test_tmp::clearPrimarySelection
11481148 } -result {OLD_VALUE----OLD_VALUE}
11491149
1150 test safePrimarySelection-6.8 {IMPORTANT, safe slave interpreter, ttk::spinbox as entry, existing selection} -setup {
1151 catch {interp delete slave2}
1152 destroy {*}[winfo children .]
1153 ::_test_tmp::setPrimarySelection
1154 } -body {
1155 set res0 [::_test_tmp::getPrimarySelection]
1156 set int2 slave2
1150 test safePrimarySelection-6.8 {IMPORTANT, safe interpreter, ttk::spinbox as entry, existing selection} -setup {
1151 catch {interp delete child2}
1152 destroy {*}[winfo children .]
1153 ::_test_tmp::setPrimarySelection
1154 } -body {
1155 set res0 [::_test_tmp::getPrimarySelection]
1156 set int2 child2
11571157 ::safe::interpCreate $int2
11581158 ::safe::loadTk $int2
11591159 $int2 eval $::_test_tmp::script
11681168 ::_test_tmp::clearPrimarySelection
11691169 } -result {OLD_VALUE----OLD_VALUE}
11701170
1171 test safePrimarySelection-6.9 {IMPORTANT, safe slave interpreter, ttk::spinbox spun, existing selection} -setup {
1172 catch {interp delete slave2}
1173 destroy {*}[winfo children .]
1174 ::_test_tmp::setPrimarySelection
1175 } -body {
1176 set res0 [::_test_tmp::getPrimarySelection]
1177 set int2 slave2
1171 test safePrimarySelection-6.9 {IMPORTANT, safe interpreter, ttk::spinbox spun, existing selection} -setup {
1172 catch {interp delete child2}
1173 destroy {*}[winfo children .]
1174 ::_test_tmp::setPrimarySelection
1175 } -body {
1176 set res0 [::_test_tmp::getPrimarySelection]
1177 set int2 child2
11781178 ::safe::interpCreate $int2
11791179 ::safe::loadTk $int2
11801180 $int2 eval $::_test_tmp::script
11891189 ::_test_tmp::clearPrimarySelection
11901190 } -result {OLD_VALUE----OLD_VALUE}
11911191
1192 test safePrimarySelection-6.10 {IMPORTANT, safe slave interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
1193 catch {interp delete slave2}
1194 destroy {*}[winfo children .]
1195 ::_test_tmp::setPrimarySelection
1196 } -body {
1197 set res0 [::_test_tmp::getPrimarySelection]
1198 set int2 slave2
1192 test safePrimarySelection-6.10 {IMPORTANT, safe interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup {
1193 catch {interp delete child2}
1194 destroy {*}[winfo children .]
1195 ::_test_tmp::setPrimarySelection
1196 } -body {
1197 set res0 [::_test_tmp::getPrimarySelection]
1198 set int2 child2
11991199 ::safe::interpCreate $int2
12001200 ::safe::loadTk $int2
12011201 $int2 eval $::_test_tmp::script
323323 scale
324324 } -returnCodes error -result {wrong # args: should be "scale pathName ?-option value ...?"}
325325 test scale-2.2 {Tk_ScaleCmd procedure} -body {
326 scale foo
326 scale foo
327327 } -returnCodes error -result {bad window path name "foo"}
328328 test scale-2.3 {Tk_ScaleCmd procedure} -body {
329329 catch {scale foo}
66 # Copyright (c) 1998-1999 by Scriptics Corporation.
77 # All rights reserved.
88
9 package require tcltest 2.1
9 package require tcltest 2.2
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
12
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1215
1316 proc scroll args {
1417 global scrollInfo
2225 return [expr {[winfo height $w] - 2*[testmetrics cyvscroll $w]}]
2326 } else {
2427 return [expr {[winfo width $w] - 2*[testmetrics cxhscroll $w]}]
25 }
28 }
2629 } else {
2730 if {[tk windowingsystem] eq "x11"} {
2831 # Calculations here assume that the arrow area is a square.
5962 foreach {width height} [wm minsize .] {
6063 set height [expr {($height < 200) ? 200 : $height}]
6164 set width [expr {($width < 1) ? 1 : $width}]
62 }
65 }
6366
6467 frame .f -height $height -width $width
6568 pack .f -side left
269272 format {%.6g} [.s fraction 4 21]
270273 } [format %.6g [expr {(21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \
271274 /([getTroughSize .s] - 1)}]]
272 test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
275 test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} {x11 failsOnUbuntu failsOnXQuarz} {
273276 format {%.6g} [.s fraction 4 179]
274277 } {1}
275278 test scrollbar-3.37 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics} {
276279 format {%.6g} [.s fraction 4 [expr {200 - [testmetrics cyvscroll .s]}]]
277280 } {1}
278 test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
281 test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} {x11 failsOnUbuntu failsOnXQuarz} {
279282 format {%.6g} [.s fraction 4 178]
280283 } {0.993711}
281284 test scrollbar-3.39 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics win} {
340343 test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua {
341344 .s identify 5 5
342345 } {arrow1}
343 test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} aqua {
346 test scrollbar-3.50.2 {ScrollbarWidgetCmd procedure, "identify" option} aqua {
344347 # macOS scrollbars have no arrows nowadays
345348 .s identify 5 5
346349 } {trough1}
379382 set result
380383 } {0.0 0.3}
381384 test scrollbar-3.60 {ScrollbarWidgetCmd procedure, "set" option} {
382 .s set 1.1 .4
385 .s set 1.1 .4
383386 .s get
384387 } {1.0 1.0}
385388 test scrollbar-3.61 {ScrollbarWidgetCmd procedure, "set" option} {
386 .s set .5 -.3
389 .s set .5 -.3
387390 .s get
388391 } {0.5 0.5}
389392 test scrollbar-3.62 {ScrollbarWidgetCmd procedure, "set" option} {
390 .s set .5 87
393 .s set .5 87
391394 .s get
392395 } {0.5 1.0}
393396 test scrollbar-3.63 {ScrollbarWidgetCmd procedure, "set" option} {
411414 list [catch {.s set 1 2 3 jkl} msg] $msg
412415 } {1 {expected integer but got "jkl"}}
413416 test scrollbar-3.68 {ScrollbarWidgetCmd procedure, "set" option} {
414 .s set -10 50 20 30
417 .s set -10 50 20 30
415418 .s get
416419 } {0 50 0 0}
417420 test scrollbar-3.69 {ScrollbarWidgetCmd procedure, "set" option} {
418 .s set 100 -10 20 30
421 .s set 100 -10 20 30
419422 .s get
420423 } {100 0 20 30}
421424 test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} {
422 .s set 100 50 30 20
425 .s set 100 50 30 20
423426 .s get
424427 } {100 50 30 30}
425428 test scrollbar-3.71 {ScrollbarWidgetCmd procedure, "set" option} {
490493 # macOS scrollbars have no arrows nowadays
491494 .s identify 8 4
492495 } {trough1}
493 test scrollbar-6.12.1 {ScrollbarPosition procedure} x11 {
496 test scrollbar-6.12.1 {ScrollbarPosition procedure} {x11 failsOnUbuntu failsOnXQuarz} {
494497 .s identify 8 19
495498 } {arrow1}
496499 test scrollbar-6.12.2 {ScrollbarPosition procedure} aqua {
498501 .s identify 8 19
499502 } {trough1}
500503 test scrollbar-6.14 {ScrollbarPosition procedure} win {
501 .s identify [expr {[winfo width .s] / 2}] 0
504 .s identify [expr {[winfo width .s] / 2}] 0
502505 } {arrow1}
503506 test scrollbar-6.15 {ScrollbarPosition procedure} {testmetrics win} {
504507 .s identify [expr {[winfo width .s] / 2}] [expr {[testmetrics cyvscroll .s] - 1}]
548551 .s identify [expr {[winfo width .s] / 2}] [expr {[winfo height .s]
549552 - [testmetrics cyvscroll .s] - 1}]
550553 } {trough2}
551 test scrollbar-6.29.1 {ScrollbarPosition procedure} x11 {
554 test scrollbar-6.29.1 {ScrollbarPosition procedure} {x11 failsOnUbuntu failsOnXQuarz} {
552555 .s identify 8 180
553556 } {arrow2}
554557 test scrollbar-6.29.2 {ScrollbarPosition procedure} aqua {
572575 test scrollbar-6.34 {ScrollbarPosition procedure} unix {
573576 .s identify 4 100
574577 } {trough2}
575 test scrollbar-6.35 {ScrollbarPosition procedure} unix {
578 test scrollbar-6.35 {ScrollbarPosition procedure} {unix failsOnUbuntu failsOnXQuarz} {
576579 .s identify 18 100
577580 } {trough2}
578581 test scrollbar-6.37 {ScrollbarPosition procedure} win {
609612 } {trough2}
610613 test scrollbar-6.43 {ScrollbarPosition procedure} {testmetrics win} {
611614 .t.s identify [expr {int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll .t.s]
612 - 1}] [expr {[winfo height .t.s] / 2}]
615 - 1}] [expr {[winfo height .t.s] / 2}]
613616 } {slider}
614 test scrollbar-6.44 {ScrollbarPosition procedure} unix {
617 test scrollbar-6.44 {ScrollbarPosition procedure} {unix failsOnUbuntu failsOnXQuarz} {
615618 .t.s identify 100 18
616619 } {trough2}
617620 test scrollbar-6.46 {ScrollbarPosition procedure} win {
758761 update ; # shall not trigger error invalid command name ".top.s"
759762 } -cleanup {
760763 destroy .top.s .top
761 } -result {}
764 } -result {}
762765 test scrollbar-11.2 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body {
763766 proc destroy_scrollbar {{y 0}} {
764767 if {[winfo exists .top.s]} {
777780 update ; # shall not trigger error invalid command name ".top.s"
778781 } -cleanup {
779782 destroy .top.s .top
780 } -result {}
783 } -result {}
781784
782785 catch {destroy .s}
783786 catch {destroy .t}
2222 testConstraint cliboardManagerPresent 1
2323 }
2424 }
25 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
2526
2627 global longValue selValue selInfo
2728
894895 test select-9.2 {SelCvtToX and SelCvtFromX procedures} -setup {
895896 setup
896897 setupbg
897 } -constraints x11 -body {
898 } -constraints {x11 failsOnUbuntu} -body {
898899 set selValue "1024 0xffff 2048 -2 "
899900 set selInfo ""
900901 selection handle -selection PRIMARY -format INTEGER -type TEST \
907908 test select-9.3 {SelCvtToX and SelCvtFromX procedures} -setup {
908909 setup
909910 setupbg
910 } -constraints x11 -body {
911 } -constraints {x11 failsOnUbuntu} -body {
911912 set selValue " "
912913 set selInfo ""
913914 selection handle -selection PRIMARY -format INTEGER -type TEST \
920921 test select-9.4 {SelCvtToX and SelCvtFromX procedures} -setup {
921922 setup
922923 setupbg
923 } -constraints x11 -body {
924 } -constraints {x11 failsOnUbuntu} -body {
924925 set selValue "16 foobar 32"
925926 set selInfo ""
926927 selection handle -selection PRIMARY -format INTEGER -type TEST \
951952
952953 # most control paths have been exercised above
953954 test select-10.1 {ConvertSelection procedure, race with selection clear} -constraints {
954 x11
955 x11
955956 } -setup {
956957 setup
957958 } -body {
10051006 # testing timers
10061007 # This one hangs in Exceed
10071008 test select-10.4 {ConvertSelection procedure} -constraints {
1008 x11 noExceed
1009 x11 noExceed failsOnUbuntu
10091010 } -setup {
10101011 setup
10111012 setupbg
10201021 lappend result $selInfo
10211022 } -result {{selection owner didn't respond} {STRING 0 4000 STRING 4000 4000 STRING 8000 4000 STRING 12000 4000 STRING 16000 4000 STRING 0 4000 STRING 4000 4000}}
10221023 test select-10.5 {ConvertSelection procedure, reentrancy issues} -constraints {
1023 x11
1024 x11 failsOnUbuntu
10241025 } -setup {
10251026 setup
10261027 setupbg
10351036 lappend result $selInfo
10361037 } -result {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000}}
10371038 test select-10.6 {ConvertSelection procedure, reentrancy issues} -constraints {
1038 x11
1039 x11 failsOnUbuntu
10391040 } -setup {
10401041 setup
10411042 setupbg
10581059 ##############################################################################
10591060
10601061 # testing reentrancy
1061 test select-11.1 {TkSelPropProc procedure} -constraints x11 -setup {
1062 test select-11.1 {TkSelPropProc procedure} -constraints {x11 failsOnUbuntu} -setup {
10621063 setup
10631064 setupbg
10641065 } -body {
11301131 } -result {{Targets value} {TARGETS.f1 0 4000} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}}
11311132
11321133 test select-13.1 {SelectionSize procedure, handler deleted} -constraints {
1133 x11
1134 x11 failsOnUbuntu
11341135 } -setup {
11351136 setup
11361137 setupbg
99 # See the file "license.terms" for information on usage and redistribution
1010 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1111
12 package require tcltest 2.1
12 package require tcltest 2.2
1313 eval tcltest::configure $argv
1414 tcltest::loadTestedCommands
1515
1616 testConstraint xhost [llength [auto_execok xhost]]
17 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
1718
1819 # Compute a script that will load Tk into a child interpreter.
1920
285286
286287 catch {interp delete t_s_2}
287288
288 test send-8.15 {Tk_SendCmd procedure, local interp, error info} {secureserver testsend} {
289 test send-8.15 {Tk_SendCmd procedure, local interp, error info} {secureserver testsend failsOnUbuntu} {
289290 catch {error foo}
290291 list [catch {send t_s_1 {if 1 {open bogus_file_name}}} msg] $msg $errorInfo $errorCode
291292 } {1 {couldn't open "bogus_file_name": no such file or directory} {couldn't open "bogus_file_name": no such file or directory
295296 "if 1 {open bogus_file_name}"
296297 invoked from within
297298 "send t_s_1 {if 1 {open bogus_file_name}}"} {POSIX ENOENT {no such file or directory}}}
298 test send-8.16 {Tk_SendCmd procedure, bogusCommWindow} {secureserver testsend} {
299 test send-8.16 {Tk_SendCmd procedure, bogusCommWindow} {secureserver testsend failsOnUbuntu} {
299300 testsend prop root InterpRegistry "10234 bogus\n"
300301 set result [list [catch {send bogus bogus command} msg] $msg]
301302 winfo interps
521522 set x
522523 } {1 {target application died}}
523524
524 test send-11.1 {AppendPropCarefully and AppendErrorProc procedures} {secureserver testsend} {
525 test send-11.1 {AppendPropCarefully and AppendErrorProc procedures} -constraints {secureserver testsend} -body {
525526 testsend prop root InterpRegistry "0x21447 dummy\n"
526 list [catch {send dummy foo} msg] $msg
527 } {1 {no application named "dummy"}}
527 send dummy foo
528 } -returnCodes 1 -match regexp -result {^(target application died|no application named "dummy")$}
528529 test send-11.2 {AppendPropCarefully and AppendErrorProc procedures} {secureserver testsend} {
529530 testsend prop comm Comm "c\n-r0x123 44\n-n tktest\n-s concat a b c\n"
530531 update
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
15
1316 # For xscrollcommand
17 set scrollInfo {}
1418 proc scroll args {
1519 global scrollInfo
1620 set scrollInfo $args
1721 }
18 # For trace variable
22 # For trace variable
1923 proc override args {
2024 global x
2125 set x 12345
9296 .e cget -bd
9397 } -cleanup {
9498 destroy .e
95 } -result {4}
99 } -result 4
96100 test spinbox-1.6 {configuration option: "bd" for spinbox} -setup {
97101 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
98102 -relief sunken
136140 .e cget -borderwidth
137141 } -cleanup {
138142 destroy .e
139 } -result {1}
143 } -result 1
140144 test spinbox-1.10 {configuration option: "borderwidth" for spinbox} -setup {
141145 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
142146 -relief sunken
280284 .e cget -exportselection
281285 } -cleanup {
282286 destroy .e
283 } -result {1}
287 } -result 1
284288 test spinbox-1.23 {configuration option: "exportselection" for spinbox} -setup {
285289 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
286290 -relief sunken
456460 .e cget -highlightthickness
457461 } -cleanup {
458462 destroy .e
459 } -result {6}
463 } -result 6
460464 test spinbox-1.39 {configuration option: "highlightthickness" for spinbox} -setup {
461465 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
462466 -relief sunken
478482 .e cget -highlightthickness
479483 } -cleanup {
480484 destroy .e
481 } -result {0}
485 } -result 0
482486
483487 test spinbox-1.41 {configuration option: "increment"} -setup {
484488 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
534538 .e cget -insertborderwidth
535539 } -cleanup {
536540 destroy .e
537 } -result {1}
541 } -result 1
538542 test spinbox-1.46 {configuration option: "insertborderwidth" for spinbox} -setup {
539543 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
540544 -relief sunken
556560 .e cget -insertofftime
557561 } -cleanup {
558562 destroy .e
559 } -result {100}
563 } -result 100
560564 test spinbox-1.48 {configuration option: "insertofftime" for spinbox} -setup {
561565 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
562566 -relief sunken
578582 .e cget -insertontime
579583 } -cleanup {
580584 destroy .e
581 } -result {100}
585 } -result 100
582586 test spinbox-1.50 {configuration option: "insertontime" for spinbox} -setup {
583587 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
584588 -relief sunken
690694 .e cget -repeatdelay
691695 } -cleanup {
692696 destroy .e
693 } -result {500}
697 } -result 500
694698 test spinbox-1.60 {configuration option: "repeatdelay" for spinbox} -setup {
695699 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
696700 -relief sunken
756760 .e cget -selectborderwidth
757761 } -cleanup {
758762 destroy .e
759 } -result {1}
763 } -result 1
760764 test spinbox-1.66 {configuration option: "selectborderwidth" for spinbox} -setup {
761765 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
762766 -relief sunken
936940 .e cget -width
937941 } -cleanup {
938942 destroy .e
939 } -result {402}
943 } -result 402
940944 test spinbox-1.82 {configuration option: "width" for spinbox} -setup {
941945 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
942946 -relief sunken
958962 .e cget -wrap
959963 } -cleanup {
960964 destroy .e
961 } -result {1}
965 } -result 1
962966 test spinbox-1.84 {configuration option: "wrap" for spinbox} -setup {
963967 spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
964968 -relief sunken
10161020
10171021
10181022 test spinbox-3.1 {SpinboxWidgetCmd procedure} -setup {
1019 spinbox .e
1023 spinbox .e
10201024 pack .e
10211025 update
10221026 } -body {
10251029 destroy .e
10261030 } -returnCodes error -result {wrong # args: should be ".e option ?arg ...?"}
10271031 test spinbox-3.2 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup {
1028 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1032 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
10291033 pack .e
10301034 update
10311035 } -body {
10341038 destroy .e
10351039 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
10361040 test spinbox-3.3 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup {
1037 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1041 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
10381042 pack .e
10391043 update
10401044 } -body {
10431047 destroy .e
10441048 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
10451049 test spinbox-3.4 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup {
1046 spinbox .e
1050 spinbox .e
10471051 pack .e
10481052 update
10491053 } -body {
10521056 destroy .e
10531057 } -returnCodes error -result {bad spinbox index "bogus"}
10541058 test spinbox-3.5 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup {
1055 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1059 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
10561060 pack .e
10571061 update
10581062 } -body {
10611065 destroy .e
10621066 } -result [list 5 5 0 $cy]
10631067
1064 # Oryginaly the result was count using measurements
1068 # Oryginaly the result was count using measurements
10651069 # and metrics. It was changed to less verbose solution - the result is the one
10661070 # that passes fonts constraint (this concerns tests 3.6, 3.7, 3.8, 3.10)
10671071 test spinbox-3.6 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints {
10801084 test spinbox-3.7 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints {
10811085 fonts
10821086 } -setup {
1083 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1087 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
10841088 pack .e
10851089 update
10861090 } -body {
10931097 test spinbox-3.8 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints {
10941098 fonts
10951099 } -setup {
1096 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1100 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
10971101 pack .e
10981102 update
10991103 } -body {
11041108 destroy .e
11051109 } -result {31 5 7 13}
11061110 test spinbox-3.9 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup {
1107 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1111 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
11081112 pack .e
11091113 update
11101114 } -body {
11161120 test spinbox-3.10 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints {
11171121 fonts
11181122 } -setup {
1119 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1123 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
11201124 pack .e
11211125 update
11221126 } -body {
11261130 destroy .e
11271131 } -result {{5 5 7 13} {12 5 7 13} {75 5 12 13} {122 5 7 13}}
11281132 test spinbox-3.11 {SpinboxWidgetCmd procedure, "cget" widget command} -setup {
1129 spinbox .e
1133 spinbox .e
11301134 } -body {
11311135 .e cget
11321136 } -cleanup {
11331137 destroy .e
11341138 } -returnCodes error -result {wrong # args: should be ".e cget option"}
11351139 test spinbox-3.12 {SpinboxWidgetCmd procedure, "cget" widget command} -setup {
1136 spinbox .e
1140 spinbox .e
11371141 } -body {
11381142 .e cget a b
11391143 } -cleanup {
11401144 destroy .e
11411145 } -returnCodes error -result {wrong # args: should be ".e cget option"}
11421146 test spinbox-3.13 {SpinboxWidgetCmd procedure, "cget" widget command} -setup {
1143 spinbox .e
1147 spinbox .e
11441148 } -body {
11451149 .e cget -gorp
11461150 } -cleanup {
11471151 destroy .e
11481152 } -returnCodes error -result {unknown option "-gorp"}
11491153 test spinbox-3.14 {SpinboxWidgetCmd procedure, "cget" widget command} -setup {
1150 spinbox .e
1154 spinbox .e
11511155 } -body {
11521156 .e configure -bd 4
11531157 .e cget -bd
11541158 } -cleanup {
11551159 destroy .e
1156 } -result {4}
1160 } -result 4
11571161 test spinbox-3.15 {SpinboxWidgetCmd procedure, "configure" widget command} -setup {
1158 spinbox .e
1162 spinbox .e
11591163 pack .e
11601164 update
11611165 } -body {
11621166 llength [.e configure]
11631167 } -cleanup {
11641168 destroy .e
1165 } -result {49}
1169 } -result 49
11661170 test spinbox-3.16 {SpinboxWidgetCmd procedure, "configure" widget command} -setup {
1167 spinbox .e
1171 spinbox .e
11681172 } -body {
11691173 .e configure -foo
11701174 } -cleanup {
11711175 destroy .e
11721176 } -returnCodes error -result {unknown option "-foo"}
11731177 test spinbox-3.17 {SpinboxWidgetCmd procedure, "configure" widget command} -setup {
1174 spinbox .e
1178 spinbox .e
11751179 } -body {
11761180 .e configure -bd 4
11771181 .e configure -bg #ffffff
11781182 lindex [.e configure -bd] 4
11791183 } -cleanup {
11801184 destroy .e
1181 } -result {4}
1185 } -result 4
11821186 test spinbox-3.18 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
1183 spinbox .e
1187 spinbox .e
11841188 } -body {
11851189 .e delete
11861190 } -cleanup {
11871191 destroy .e
11881192 } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"}
11891193 test spinbox-3.19 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
1190 spinbox .e
1194 spinbox .e
11911195 } -body {
11921196 .e delete a b c
11931197 } -cleanup {
11941198 destroy .e
11951199 } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"}
11961200 test spinbox-3.20 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
1197 spinbox .e
1201 spinbox .e
11981202 } -body {
11991203 .e delete foo
12001204 } -cleanup {
12011205 destroy .e
12021206 } -returnCodes error -result {bad spinbox index "foo"}
12031207 test spinbox-3.21 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
1204 spinbox .e
1208 spinbox .e
12051209 } -body {
12061210 .e delete 0 bar
12071211 } -cleanup {
12101214 test spinbox-3.22 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
12111215 spinbox .e
12121216 pack .e
1213 update
1217 update
12141218 } -body {
12151219 .e insert end "01234567890"
12161220 .e delete 2 4
12171221 .e get
12181222 } -cleanup {
12191223 destroy .e
1220 } -result {014567890}
1224 } -result 014567890
12211225 test spinbox-3.23 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
1222 spinbox .e
1226 spinbox .e
12231227 } -body {
12241228 .e insert end "01234567890"
12251229 .e delete 6
12261230 .e get
12271231 } -cleanup {
12281232 destroy .e
1229 } -result {0123457890}
1233 } -result 0123457890
12301234 test spinbox-3.24 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
12311235 spinbox .e
12321236 pack .e
1233 update
1237 update
12341238 set x {}
12351239 } -body {
12361240 # UTF
12511255 test spinbox-3.25 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
12521256 spinbox .e
12531257 pack .e
1254 update
1258 update
12551259 } -body {
12561260 .e insert end "01234567890"
12571261 .e delete 6 5
12581262 .e get
12591263 } -cleanup {
12601264 destroy .e
1261 } -result {01234567890}
1265 } -result 01234567890
12621266 test spinbox-3.26 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
12631267 spinbox .e
12641268 pack .e
1265 update
1269 update
12661270 } -body {
12671271 .e insert end "01234567890"
12681272 .e configure -state disabled
12711275 .e get
12721276 } -cleanup {
12731277 destroy .e
1274 } -result {01234567890}
1278 } -result 01234567890
12751279 test spinbox-3.26.1 {SpinboxWidgetCmd procedure, "delete" widget command} -setup {
12761280 spinbox .e
12771281 pack .e
1278 update
1282 update
12791283 } -body {
12801284 .e insert end "01234567890"
12811285 .e configure -state readonly
12841288 .e get
12851289 } -cleanup {
12861290 destroy .e
1287 } -result {01234567890}
1291 } -result 01234567890
12881292 test spinbox-3.27 {SpinboxWidgetCmd procedure, "get" widget command} -setup {
1289 spinbox .e
1293 spinbox .e
12901294 } -body {
12911295 .e get foo
12921296 } -cleanup {
12931297 destroy .e
12941298 } -returnCodes error -result {wrong # args: should be ".e get"}
12951299 test spinbox-3.28 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup {
1296 spinbox .e
1300 spinbox .e
12971301 } -body {
12981302 .e icursor
12991303 } -cleanup {
13001304 destroy .e
13011305 } -returnCodes error -result {wrong # args: should be ".e icursor pos"}
13021306 test spinbox-3.29 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup {
1303 spinbox .e
1307 spinbox .e
13041308 } -body {
13051309 .e icursor foo
13061310 } -cleanup {
13071311 destroy .e
13081312 } -returnCodes error -result {bad spinbox index "foo"}
13091313 test spinbox-3.30 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup {
1310 spinbox .e
1314 spinbox .e
13111315 } -body {
13121316 .e insert end "01234567890"
13131317 .e icursor 4
13141318 .e index insert
13151319 } -cleanup {
13161320 destroy .e
1317 } -result {4}
1321 } -result 4
13181322 test spinbox-3.31 {SpinboxWidgetCmd procedure, "index" widget command} -setup {
1319 spinbox .e
1323 spinbox .e
13201324 } -body {
13211325 .e in
13221326 } -cleanup {
13231327 destroy .e
13241328 } -returnCodes error -result {ambiguous option "in": must be bbox, cget, configure, delete, get, icursor, identify, index, insert, invoke, scan, selection, set, validate, or xview}
13251329 test spinbox-3.32 {SpinboxWidgetCmd procedure, "index" widget command} -setup {
1326 spinbox .e
1330 spinbox .e
13271331 } -body {
13281332 .e index
13291333 } -cleanup {
13301334 destroy .e
13311335 } -returnCodes error -result {wrong # args: should be ".e index string"}
13321336 test spinbox-3.33 {SpinboxWidgetCmd procedure, "index" widget command} -setup {
1333 spinbox .e
1337 spinbox .e
13341338 } -body {
13351339 .e index foo
13361340 } -cleanup {
13391343 test spinbox-3.34 {SpinboxWidgetCmd procedure, "index" widget command} -setup {
13401344 spinbox .e
13411345 pack .e
1342 update
1346 update
13431347 } -body {
13441348 .e index 0
13451349 } -cleanup {
13481352 test spinbox-3.35 {SpinboxWidgetCmd procedure, "index" widget command} -setup {
13491353 spinbox .e
13501354 pack .e
1351 update
1355 update
13521356 } -body {
13531357 # UTF
13541358 .e insert 0 abc\u4e4e\u0153def
13571361 destroy .e
13581362 } -result {3 4 8}
13591363 test spinbox-3.36 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
1360 spinbox .e
1364 spinbox .e
13611365 } -body {
13621366 .e insert a
13631367 } -cleanup {
13641368 destroy .e
13651369 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
13661370 test spinbox-3.37 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
1367 spinbox .e
1371 spinbox .e
13681372 } -body {
13691373 .e insert a b c
13701374 } -cleanup {
13711375 destroy .e
13721376 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
13731377 test spinbox-3.38 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
1374 spinbox .e
1378 spinbox .e
13751379 } -body {
13761380 .e insert foo Text
13771381 } -cleanup {
13801384 test spinbox-3.39 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
13811385 spinbox .e
13821386 pack .e
1383 update
1387 update
13841388 } -body {
13851389 .e insert end "01234567890"
13861390 .e insert 3 xxx
13911395 test spinbox-3.40 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
13921396 spinbox .e
13931397 pack .e
1394 update
1398 update
13951399 } -body {
13961400 .e insert end "01234567890"
13971401 .e configure -state disabled
14001404 .e get
14011405 } -cleanup {
14021406 destroy .e
1403 } -result {01234567890}
1407 } -result 01234567890
14041408 test spinbox-3.40.1 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
14051409 spinbox .e
14061410 pack .e
1407 update
1411 update
14081412 } -body {
14091413 .e insert end "01234567890"
14101414 .e configure -state readonly
14131417 .e get
14141418 } -cleanup {
14151419 destroy .e
1416 } -result {01234567890}
1420 } -result 01234567890
14171421 test spinbox-3.41 {SpinboxWidgetCmd procedure, "insert" widget command} -setup {
1418 spinbox .e
1422 spinbox .e
14191423 } -body {
14201424 .e insert a b c
14211425 } -cleanup {
14221426 destroy .e
14231427 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
14241428 test spinbox-3.42 {SpinboxWidgetCmd procedure, "scan" widget command} -setup {
1425 spinbox .e
1429 spinbox .e
14261430 pack .e
14271431 update
14281432 } -body {
14331437 test spinbox-3.43 {SpinboxWidgetCmd procedure, "scan" widget command} -setup {
14341438 spinbox .e
14351439 pack .e
1436 update
1440 update
14371441 } -body {
14381442 .e scan a b c
14391443 } -cleanup {
14421446 test spinbox-3.44 {SpinboxWidgetCmd procedure, "scan" widget command} -setup {
14431447 spinbox .e
14441448 pack .e
1445 update
1449 update
14461450 } -body {
14471451 .e scan foobar 20
14481452 } -cleanup {
14511455 test spinbox-3.45 {SpinboxWidgetCmd procedure, "scan" widget command} -setup {
14521456 spinbox .e
14531457 pack .e
1454 update
1458 update
14551459 } -body {
14561460 .e scan mark 20.1
14571461 } -cleanup {
14621466 test spinbox-3.46 {SpinboxWidgetCmd procedure, "scan" widget command} -constraints {
14631467 fonts
14641468 } -setup {
1465 spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
1469 spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
14661470 pack .e
14671471 update
14681472 } -body {
14731477 .e index @0
14741478 } -cleanup {
14751479 destroy .e
1476 } -result {2}
1480 } -result 2
14771481 test spinbox-3.47 {SpinboxWidgetCmd procedure, "select" widget command} -setup {
1478 spinbox .e
1482 spinbox .e
14791483 } -body {
14801484 .e select
14811485 } -cleanup {
14821486 destroy .e
14831487 } -returnCodes error -result {wrong # args: should be ".e selection option ?index?"}
14841488 test spinbox-3.48 {SpinboxWidgetCmd procedure, "select" widget command} -setup {
1485 spinbox .e
1489 spinbox .e
14861490 } -body {
14871491 .e select foo
14881492 } -cleanup {
14901494 } -returnCodes error -result {bad selection option "foo": must be adjust, clear, element, from, present, range, or to}
14911495
14921496 test spinbox-3.49 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup {
1493 spinbox .e
1497 spinbox .e
14941498 } -body {
14951499 .e select clear gorp
14961500 } -cleanup {
14971501 destroy .e
14981502 } -returnCodes error -result {wrong # args: should be ".e selection clear"}
14991503 test spinbox-3.50 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup {
1500 spinbox .e
1504 spinbox .e
15011505 } -body {
15021506 .e insert end "0123456789"
15031507 .e select from 1
15041508 .e select to 4
15051509 update
15061510 .e select clear
1507 selection get
1511 selection get
15081512 } -cleanup {
15091513 destroy .e
15101514 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
15111515 test spinbox-3.50.1 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup {
15121516 spinbox .e
15131517 pack .e
1514 update
1518 update
15151519 } -body {
15161520 .e insert end "0123456789"
15171521 .e select from 1
15251529 } -result {.e}
15261530
15271531 test spinbox-3.51 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup {
1528 spinbox .e
1532 spinbox .e
15291533 } -body {
15301534 .e selection present foo
15311535 } -cleanup {
15341538 test spinbox-3.52 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup {
15351539 spinbox .e
15361540 pack .e
1537 update
1541 update
15381542 } -body {
15391543 .e insert end 0123456789
15401544 .e select from 3
15421546 .e selection present
15431547 } -cleanup {
15441548 destroy .e
1545 } -result {1}
1549 } -result 1
15461550 test spinbox-3.53 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup {
15471551 spinbox .e
15481552 pack .e
1549 update
1553 update
15501554 } -body {
15511555 .e insert end 0123456789
15521556 .e select from 3
15551559 .e selection present
15561560 } -cleanup {
15571561 destroy .e
1558 } -result {1}
1562 } -result 1
15591563 test spinbox-3.54 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup {
15601564 spinbox .e
15611565 pack .e
1562 update
1566 update
15631567 } -body {
15641568 .e insert end 0123456789
15651569 .e select from 3
15681572 .e selection present
15691573 } -cleanup {
15701574 destroy .e
1571 } -result {0}
1575 } -result 0
15721576 test spinbox-3.55 {SpinboxWidgetCmd procedure, "selection adjust" widget command} -setup {
15731577 spinbox .e
15741578 } -body {
15961600 selection get
15971601 } -cleanup {
15981602 destroy .e
1599 } -result {123}
1603 } -result 123
16001604 test spinbox-3.58 {SpinboxWidgetCmd procedure, "selection adjust" widget command} -setup {
16011605 spinbox .e
16021606 pack .e
16101614 selection get
16111615 } -cleanup {
16121616 destroy .e
1613 } -result {234}
1617 } -result 234
16141618 test spinbox-3.59 {SpinboxWidgetCmd procedure, "selection from" widget command} -setup {
16151619 spinbox .e
16161620 } -body {
16981702 } -result {2 4}
16991703
17001704 test spinbox-3.65 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1701 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1705 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17021706 pack .e
17031707 update
17041708 } -body {
17101714 destroy .e
17111715 } -result {0.053763 0.268817}
17121716 test spinbox-3.66 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1713 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1717 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17141718 pack .e
17151719 update
17161720 } -body {
17191723 destroy .e
17201724 } -returnCodes error -result {bad spinbox index "gorp"}
17211725 test spinbox-3.67 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1722 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1726 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17231727 pack .e
17241728 update
17251729 } -body {
17331737 destroy .e
17341738 } -result {0.107527 0.322581}
17351739 test spinbox-3.68 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1736 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1740 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17371741 pack .e
17381742 update
17391743 } -body {
17421746 destroy .e
17431747 } -returnCodes error -result {wrong # args: should be ".e xview moveto fraction"}
17441748 test spinbox-3.69 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1745 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1749 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17461750 pack .e
17471751 update
17481752 } -body {
17511755 destroy .e
17521756 } -returnCodes error -result {expected floating-point number but got "foo"}
17531757 test spinbox-3.70 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1754 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1758 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17551759 pack .e
17561760 update
17571761 } -body {
17631767 destroy .e
17641768 } -result {0.505376 0.720430}
17651769 test spinbox-3.71 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1766 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1770 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17671771 pack .e
17681772 update
17691773 } -body {
17741778 destroy .e
17751779 } -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"}
17761780 test spinbox-3.72 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1777 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1781 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17781782 pack .e
17791783 } -body {
17801784 .e insert end "This is quite a long text string, so long that it "
17851789 destroy .e
17861790 } -returnCodes error -result {expected integer but got "gorp"}
17871791 test spinbox-3.73 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1788 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1792 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
17891793 pack .e
17901794 } -body {
17911795 .e insert end "This is quite a long text string, so long that it "
17981802 destroy .e
17991803 } -result {0.193548 0.408602}
18001804 test spinbox-3.74 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1801 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1805 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18021806 pack .e
18031807 update
18041808 } -body {
18121816 destroy .e
18131817 } -result {0.397849 0.612903}
18141818 test spinbox-3.75 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1815 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1819 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18161820 pack .e
18171821 } -body {
18181822 .e insert end "This is quite a long text string, so long that it "
18201824 update
18211825 .e xview 30
18221826 update
1823 .e xview scroll 2 units
1827 .e xview scroll 2 units
18241828 .e index @0
18251829 } -cleanup {
18261830 destroy .e
1827 } -result {32}
1831 } -result 32
18281832 test spinbox-3.76 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1829 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1833 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18301834 pack .e
18311835 } -body {
18321836 .e insert end "This is quite a long text string, so long that it "
18341838 update
18351839 .e xview 30
18361840 update
1837 .e xview scroll -1 units
1841 .e xview scroll -1 units
18381842 .e index @0
18391843 } -cleanup {
18401844 destroy .e
1841 } -result {29}
1845 } -result 29
18421846 test spinbox-3.77 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1843 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1847 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18441848 pack .e
18451849 } -body {
18461850 .e insert end "This is quite a long text string, so long that it "
18511855 destroy .e
18521856 } -returnCodes error -result {bad argument "foobars": must be units or pages}
18531857 test spinbox-3.78 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1854 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1858 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18551859 pack .e
18561860 } -body {
18571861 .e insert end "This is quite a long text string, so long that it "
18621866 destroy .e
18631867 } -returnCodes error -result {unknown option "eat": must be moveto or scroll}
18641868 test spinbox-3.79 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1865 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1869 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18661870 pack .e
18671871 update
18681872 } -body {
18701874 .e insert end "runs off the end of the window quite a bit."
18711875 .e xview 0
18721876 update
1873 .e xview -4
1877 .e xview -1
18741878 .e index @0
18751879 } -cleanup {
18761880 destroy .e
1877 } -result {0}
1881 } -result 0
18781882 test spinbox-3.80 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1879 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1883 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18801884 pack .e
18811885 } -body {
18821886 .e insert end "This is quite a long text string, so long that it "
18861890 .e index @0
18871891 } -cleanup {
18881892 destroy .e
1889 } -result {73}
1893 } -result 73
18901894 test spinbox-3.81 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
1891 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1895 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
18921896 pack .e
18931897 } -body {
18941898 .e insert end "This is quite a long text string, so long that it "
19101914 } -result {0.095745 0.106383 0.117021}
19111915
19121916 test spinbox-3.82 {SpinboxWidgetCmd procedure} -setup {
1913 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
1917 spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
19141918 pack .e
19151919 update
19161920 } -body {
19251929 .e get
19261930 } -cleanup {
19271931 destroy .e
1928 } -result {12345}
1932 } -result 12345
19291933 test spinbox-5.2 {ConfigureSpinbox procedure, -textvariable} -body {
19301934 set x 12345
19311935 spinbox .e -textvariable x
19811985 destroy .e1 .e2
19821986 } -result {{This is so} {This is so} 1234}
19831987 test spinbox-5.6 {ConfigureSpinbox procedure} -setup {
1984 spinbox .e
1988 spinbox .e
19851989 pack .e
19861990 } -body {
19871991 .e insert end "0123456789"
19881992 .e select from 1
19891993 .e select to 5
19901994 .e configure -exportselection 0
1991 selection get
1995 selection get
19921996 } -cleanup {
19931997 destroy .e
19941998 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
20002004 .e select from 1
20012005 .e select to 5
20022006 .e configure -exportselection 0
2003 catch {selection get}
2007 catch {selection get}
20042008 list [.e index sel.first] [.e index sel.last]
20052009 } -cleanup {
20062010 destroy .e
20072011 } -result {1 5}
20082012
20092013 test spinbox-5.7 {ConfigureSpinbox procedure} -setup {
2010 spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
2014 spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
20112015 pack .e
20122016 } -body {
20132017 .e configure -font {Courier -12} -width 4 -xscrollcommand scroll
20142018 .e insert end "01234567890"
2015 set timeout [after 500 {set $scrollInfo "timeout"}]
2019 update idletasks
2020 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
2021 .e configure -width 5
20162022 vwait scrollInfo
2017 .e configure -width 5
20182023 format {%.6f %.6f} {*}$scrollInfo
20192024 } -cleanup {
20202025 destroy .e
20242029 test spinbox-5.8 {ConfigureSpinbox procedure} -constraints {
20252030 fonts
20262031 } -setup {
2027 spinbox .e -borderwidth 2 -highlightthickness 2
2032 spinbox .e -borderwidth 2 -highlightthickness 2
20282033 pack .e
20292034 } -body {
20302035 .e configure -width 0 -font {Helvetica -12}
20792084 test spinbox-6.1 {SpinboxComputeGeometry procedure} -constraints {
20802085 fonts
20812086 } -setup {
2082 spinbox .e
2087 spinbox .e
20832088 pack .e
20842089 } -body {
20852090 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -highlightthickness 3
20922097 test spinbox-6.2 {SpinboxComputeGeometry procedure} -constraints {
20932098 fonts
20942099 } -setup {
2095 spinbox .e
2100 spinbox .e
20962101 pack .e
20972102 } -body {
20982103 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -justify center \
21062111 test spinbox-6.3 {SpinboxComputeGeometry procedure} -constraints {
21072112 fonts
21082113 } -setup {
2109 spinbox .e
2114 spinbox .e
21102115 pack .e
21112116 } -body {
21122117 .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -justify right \
21182123 destroy .e
21192124 } -result {3 4}
21202125 test spinbox-6.4 {SpinboxComputeGeometry procedure} -setup {
2121 spinbox .e
2126 spinbox .e
21222127 pack .e
21232128 } -body {
21242129 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
21282133 .e index @0
21292134 } -cleanup {
21302135 destroy .e
2131 } -result {6}
2136 } -result 6
21322137 test spinbox-6.5 {SpinboxComputeGeometry procedure} -setup {
21332138 spinbox .e -highlightthickness 2
21342139 pack .e
21352140 } -body {
2136 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
2141 .e configure -font {Courier -12} -bd 2 -relief raised -width 5
21372142 .e insert end "01234567890"
21382143 update
21392144 .e xview 7
21402145 .e index @0
21412146 } -cleanup {
21422147 destroy .e
2143 } -result {6}
2148 } -result 6
21442149 test spinbox-6.6 {SpinboxComputeGeometry procedure} -constraints {
21452150 fonts
21462151 } -setup {
21472152 spinbox .e -highlightthickness 2
21482153 pack .e
21492154 } -body {
2150 .e configure -font {Courier -12} -bd 2 -relief raised -width 10
2155 .e configure -font {Courier -12} -bd 2 -relief raised -width 10
21512156 .e insert end "01234\t67890"
21522157 update
21532158 .e xview 3
21872192 spinbox .e -highlightthickness 2
21882193 pack .e
21892194 } -body {
2190 .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
2195 .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
21912196 update
21922197 list [winfo reqwidth .e] [winfo reqheight .e]
21932198 } -cleanup {
21962201
21972202
21982203 test spinbox-7.1 {InsertChars procedure} -setup {
2199 unset -nocomplain contents
2204 unset -nocomplain contents
22002205 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22012206 pack .e
22022207 focus .e
22032208 } -body {
22042209 .e configure -textvariable contents -xscrollcommand scroll
22052210 .e insert 0 abcde
2211 update idletasks
2212 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
22062213 .e insert 2 XXX
2207 set timeout [after 500 {set $scrollInfo "timeout"}]
22082214 vwait scrollInfo
22092215 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
22102216 } -cleanup {
22132219 } -result {abXXXcde abXXXcde {0.000000 1.000000}}
22142220
22152221 test spinbox-7.2 {InsertChars procedure} -setup {
2216 unset -nocomplain contents
2217 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2222 unset -nocomplain contents
2223 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22182224 pack .e
22192225 focus .e
22202226 } -body {
22212227 .e configure -textvariable contents -xscrollcommand scroll
22222228 .e insert 0 abcde
2229 update idletasks
2230 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
22232231 .e insert 500 XXX
2224 set timeout [after 500 {set $scrollInfo "timeout"}]
22252232 vwait scrollInfo
22262233 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
22272234 } -cleanup {
22852292 destroy .e
22862293 } -result {2 6 2 5}
22872294 test spinbox-7.7 {InsertChars procedure} -setup {
2288 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2295 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
22892296 pack .e
22902297 } -body {
22912298 .e configure -xscrollcommand scroll
22952302 .e index insert
22962303 } -cleanup {
22972304 destroy .e
2298 } -result {7}
2305 } -result 7
22992306 test spinbox-7.8 {InsertChars procedure} -setup {
2300 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2307 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23012308 pack .e
23022309 } -body {
23032310 .e insert 0 0123456789
23062313 .e index insert
23072314 } -cleanup {
23082315 destroy .e
2309 } -result {4}
2316 } -result 4
23102317 test spinbox-7.9 {InsertChars procedure} -setup {
2311 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2318 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23122319 pack .e
23132320 } -body {
23142321 .e insert 0 "This is a very long string"
23182325 .e index @0
23192326 } -cleanup {
23202327 destroy .e
2321 } -result {7}
2328 } -result 7
23222329 test spinbox-7.10 {InsertChars procedure} -setup {
2323 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2330 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23242331 pack .e
23252332 } -body {
23262333 .e insert 0 "This is a very long string"
23302337 .e index @0
23312338 } -cleanup {
23322339 destroy .e
2333 } -result {4}
2340 } -result 4
23342341
23352342 test spinbox-7.11 {InsertChars procedure} -constraints {
23362343 fonts
23372344 } -setup {
2338 spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
2345 spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
23392346 pack .e
23402347 } -body {
23412348 .e insert 0 "xyzzy"
23442351 winfo reqwidth .e
23452352 } -cleanup {
23462353 destroy .e
2347 } -result {70}
2354 } -result 70
23482355
23492356 test spinbox-8.1 {DeleteChars procedure} -setup {
2350 unset -nocomplain contents
2351 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2357 unset -nocomplain contents
2358 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23522359 pack .e
23532360 focus .e
23542361 } -body {
23552362 .e configure -textvariable contents -xscrollcommand scroll
23562363 .e insert 0 abcde
2364 update idletasks
2365 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
23572366 .e delete 2 4
2358 set timeout [after 500 {set $scrollInfo "timeout"}]
23592367 vwait scrollInfo
23602368 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
23612369 } -cleanup {
23632371 after cancel $timeout
23642372 } -result {abe abe {0.000000 1.000000}}
23652373 test spinbox-8.2 {DeleteChars procedure} -setup {
2366 unset -nocomplain contents
2367 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2374 unset -nocomplain contents
2375 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23682376 pack .e
23692377 focus .e
23702378 } -body {
23712379 .e configure -textvariable contents -xscrollcommand scroll
23722380 .e insert 0 abcde
2373 .e delete -2 2
2374 set timeout [after 500 {set $scrollInfo "timeout"}]
2381 update idletasks
2382 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
2383 .e delete -1 2
23752384 vwait scrollInfo
23762385 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
23772386 } -cleanup {
23792388 after cancel $timeout
23802389 } -result {cde cde {0.000000 1.000000}}
23812390 test spinbox-8.3 {DeleteChars procedure} -setup {
2382 unset -nocomplain contents
2383 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2391 unset -nocomplain contents
2392 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23842393 pack .e
23852394 focus .e
23862395 } -body {
23872396 .e configure -textvariable contents -xscrollcommand scroll
23882397 .e insert 0 abcde
2398 update idletasks
2399 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
23892400 .e delete 3 1000
2390 set timeout [after 500 {set $scrollInfo "timeout"}]
23912401 vwait scrollInfo
23922402 list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
23932403 } -cleanup {
23952405 after cancel $timeout
23962406 } -result {abc abc {0.000000 1.000000}}
23972407 test spinbox-8.4 {DeleteChars procedure} -setup {
2398 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2408 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
23992409 pack .e
24002410 focus .e
24012411 } -body {
24112421 destroy .e
24122422 } -result {1 6 1 5}
24132423 test spinbox-8.5 {DeleteChars procedure} -setup {
2414 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2424 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24152425 pack .e
24162426 focus .e
24172427 } -body {
24272437 destroy .e
24282438 } -result {1 5 1 4}
24292439 test spinbox-8.6 {DeleteChars procedure} -setup {
2430 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2440 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24312441 pack .e
24322442 focus .e
24332443 } -body {
24432453 destroy .e
24442454 } -result {1 2 1 5}
24452455 test spinbox-8.7 {DeleteChars procedure} -setup {
2446 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2456 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24472457 pack .e
24482458 focus .e
24492459 } -body {
24572467 destroy .e
24582468 } -returnCodes error -result {selection isn't in widget .e}
24592469 test spinbox-8.8 {DeleteChars procedure} -setup {
2460 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2470 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24612471 pack .e
24622472 focus .e
24632473 } -body {
24732483 destroy .e
24742484 } -result {3 4 3 8}
24752485 test spinbox-8.9 {DeleteChars procedure} -setup {
2476 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2486 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24772487 pack .e
24782488 } -body {
24792489 .e insert 0 0123456789abcde
24862496 destroy .e
24872497 } -returnCodes error -result {selection isn't in widget .e}
24882498 test spinbox-8.10 {DeleteChars procedure} -setup {
2489 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2499 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
24902500 pack .e
24912501 focus .e
24922502 } -body {
25022512 destroy .e
25032513 } -result {3 5 5 8}
25042514 test spinbox-8.11 {DeleteChars procedure} -setup {
2505 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2515 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25062516 pack .e
25072517 focus .e
25082518 } -body {
25182528 destroy .e
25192529 } -result {3 8 4 8}
25202530 test spinbox-8.12 {DeleteChars procedure} -setup {
2521 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2531 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25222532 pack .e
25232533 focus .e
25242534 } -body {
25292539 .e index insert
25302540 } -cleanup {
25312541 destroy .e
2532 } -result {1}
2542 } -result 1
25332543 test spinbox-8.13 {DeleteChars procedure} -setup {
2534 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2544 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25352545 pack .e
25362546 focus .e
25372547 } -body {
25422552 .e index insert
25432553 } -cleanup {
25442554 destroy .e
2545 } -result {1}
2555 } -result 1
25462556 test spinbox-8.14 {DeleteChars procedure} -setup {
2547 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2557 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25482558 pack .e
25492559 focus .e
25502560 } -body {
25552565 .e index insert
25562566 } -cleanup {
25572567 destroy .e
2558 } -result {4}
2568 } -result 4
25592569 test spinbox-8.15 {DeleteChars procedure} -setup {
2560 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2570 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25612571 pack .e
25622572 focus .e
25632573 } -body {
25682578 .e index @0
25692579 } -cleanup {
25702580 destroy .e
2571 } -result {1}
2581 } -result 1
25722582 test spinbox-8.16 {DeleteChars procedure} -setup {
2573 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2583 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25742584 pack .e
25752585 focus .e
25762586 } -body {
25812591 .e index @0
25822592 } -cleanup {
25832593 destroy .e
2584 } -result {1}
2594 } -result 1
25852595 test spinbox-8.17 {DeleteChars procedure} -setup {
2586 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
2596 spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
25872597 pack .e
25882598 focus .e
25892599 } -body {
25942604 .e index @0
25952605 } -cleanup {
25962606 destroy .e
2597 } -result {4}
2598 test spinbox-8.18 {DeleteChars procedure} -setup {
2599 spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
2607 } -result 4
2608 test spinbox-8.18 {DeleteChars procedure} -constraints failsOnUbuntuNoXft -setup {
2609 spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
26002610 pack .e
26012611 focus .e
26022612 } -body {
26062616 winfo reqwidth .e
26072617 } -cleanup {
26082618 destroy .e
2609 } -result {42}
2619 } -result 42
26102620
26112621 test spinbox-9.1 {SpinboxValueChanged procedure} -setup {
26122622 unset -nocomplain x
26262636 set y ab
26272637 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 -width 0
26282638 pack .e
2629 .e configure -textvariable x
2639 .e configure -textvariable x
26302640 .e configure -textvariable y
26312641 update
26322642 list [.e get] [winfo reqwidth .e]
26352645 } -result {ab 35}
26362646 test spinbox-10.2 {SpinboxSetValue procedure, updating selection} -setup {
26372647 unset -nocomplain x
2638 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2648 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
26392649 pack .e
26402650 } -body {
26412651 .e configure -textvariable x
26482658 } -returnCodes error -result {selection isn't in widget .e}
26492659 test spinbox-10.3 {SpinboxSetValue procedure, updating selection} -setup {
26502660 unset -nocomplain x
2651 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2661 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
26522662 pack .e
26532663 } -body {
26542664 .e configure -textvariable x
26612671 } -result {4 7}
26622672 test spinbox-10.4 {SpinboxSetValue procedure, updating selection} -setup {
26632673 unset -nocomplain x
2664 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
2674 spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2
26652675 pack .e
26662676 } -body {
26672677 .e configure -textvariable x
26742684 } -result {4 10}
26752685 test spinbox-10.5 {SpinboxSetValue procedure, updating display position} -setup {
26762686 unset -nocomplain x
2677 spinbox .e -highlightthickness 2 -bd 2
2687 spinbox .e -highlightthickness 2 -bd 2
26782688 pack .e
26792689 } -body {
26802690 .e configure -width 10 -font {Courier -12} -textvariable x
26862696 .e index @0
26872697 } -cleanup {
26882698 destroy .e
2689 } -result {0}
2699 } -result 0
26902700 test spinbox-10.6 {SpinboxSetValue procedure, updating display position} -setup {
26912701 unset -nocomplain x
2692 spinbox .e -highlightthickness 2 -bd 2
2702 spinbox .e -highlightthickness 2 -bd 2
26932703 pack .e
26942704 } -body {
26952705 .e configure -width 10 -font {Courier -12} -textvariable x
27022712 .e index @0
27032713 } -cleanup {
27042714 destroy .e
2705 } -result {10}
2715 } -result 10
27062716 test spinbox-10.7 {SpinboxSetValue procedure, updating insertion cursor} -setup {
27072717 unset -nocomplain x
2708 spinbox .e -highlightthickness 2 -bd 2
2718 spinbox .e -highlightthickness 2 -bd 2
27092719 pack .e
27102720 update
27112721 } -body {
27172727 .e index insert
27182728 } -cleanup {
27192729 destroy .e
2720 } -result {3}
2730 } -result 3
27212731 test spinbox-10.8 {SpinboxSetValue procedure, updating insertion cursor} -setup {
27222732 unset -nocomplain x
2723 spinbox .e -highlightthickness 2 -bd 2
2733 spinbox .e -highlightthickness 2 -bd 2
27242734 pack .e
27252735 } -body {
27262736 .e configure -width 10 -font {Courier -12} -textvariable x
27312741 .e index insert
27322742 } -cleanup {
27332743 destroy .e
2734 } -result {5}
2744 } -result 5
27352745
27362746 test spinbox-11.1 {SpinboxEventProc procedure} -setup {
27372747 spinbox .e -highlightthickness 2 -bd 2 -font {Helvetica -12}
27752785 .e index end
27762786 } -cleanup {
27772787 destroy .e
2778 } -result {21}
2788 } -result 21
27792789 test spinbox-13.2 {GetSpinboxIndex procedure} -body {
2780 spinbox .e
2790 spinbox .e
27812791 .e index abogus
27822792 } -cleanup {
27832793 destroy .e
27942804 .e index anchor
27952805 } -cleanup {
27962806 destroy .e
2797 } -result {1}
2807 } -result 1
27982808 test spinbox-13.4 {GetSpinboxIndex procedure} -setup {
27992809 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
28002810 pack .e
28072817 .e index anchor
28082818 } -cleanup {
28092819 destroy .e
2810 } -result {4}
2820 } -result 4
28112821 test spinbox-13.5 {GetSpinboxIndex procedure} -setup {
28122822 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
28132823 pack .e
28212831 .e index anchor
28222832 } -cleanup {
28232833 destroy .e
2824 } -result {15}
2834 } -result 15
28252835 test spinbox-13.6 {GetSpinboxIndex procedure} -setup {
28262836 spinbox .e
28272837 } -body {
28402850 .e index insert
28412851 } -cleanup {
28422852 destroy .e
2843 } -result {2}
2853 } -result 2
28442854 test spinbox-13.8 {GetSpinboxIndex procedure} -setup {
28452855 spinbox .e
28462856 } -body {
28632873 } -result {1 6}
28642874
28652875 test spinbox-13.10 {GetSpinboxIndex procedure} -constraints x11 -body {
2866 # On unix, when selection is cleared, spinbox widget's internal
2876 # On unix, when selection is cleared, spinbox widget's internal
28672877 # selection range is reset.
28682878 # Previous settings:
28692879 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
28832893
28842894 test spinbox-13.11 {GetSpinboxIndex procedure} -constraints aquaOrWin32 -body {
28852895 # On mac and pc, when selection is cleared, spinbox widget remembers
2886 # last selected range. When selection ownership is restored to
2896 # last selected range. When selection ownership is restored to
28872897 # spinbox, the old range will be rehighlighted.
28882898 # Previous settings:
28892899 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
29002910 .e index sel.first
29012911 } -cleanup {
29022912 destroy .e
2903 } -result {1}
2913 } -result 1
29042914
29052915 test spinbox-13.12 {GetSpinboxIndex procedure} -constraints x11 -body {
29062916 # Previous settings:
29552965
29562966 test spinbox-13.14 {GetSpinboxIndex procedure} -constraints win -body {
29572967 # On mac and pc, when selection is cleared, spinbox widget remembers
2958 # last selected range. When selection ownership is restored to
2968 # last selected range. When selection ownership is restored to
29592969 # spinbox, the old range will be rehighlighted.
29602970 # Previous settings:
29612971 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
29682978 list [.e index sel.first] [.e index sel.last]
29692979 # Testing:
29702980 selection clear .e
2971 selection get
2981 selection get
29722982 } -cleanup {
29732983 destroy .e
29742984 } -returnCodes error -match glob -result {*}
29752985
29762986 test spinbox-13.14.1 {GetSpinboxIndex procedure} -constraints win -body {
29772987 # On mac and pc, when selection is cleared, spinbox widget remembers
2978 # last selected range. When selection ownership is restored to
2988 # last selected range. When selection ownership is restored to
29792989 # spinbox, the old range will be rehighlighted.
29802990 # Previous settings:
29812991 spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken
29872997 .e select to 6
29882998 list [.e index sel.first] [.e index sel.last]
29892999 # Testing:
2990 selection clear .e
2991 catch {selection get}
2992 .e index sbogus
3000 selection clear .e
3001 catch {selection get}
3002 .e index sbogus
29933003 } -cleanup {
29943004 destroy .e
29953005 } -returnCodes error -match glob -result {*}
30043014
30053015 test spinbox-13.16 {GetSpinboxIndex procedure} -constraints fonts -body {
30063016 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3007 -font {Courier -12}
3017 -font {Courier -12}
30083018 pack .e
30093019 .e insert 0 012345678901234567890
30103020 .e xview 4
30123022 .e index @4
30133023 } -cleanup {
30143024 destroy .e
3015 } -result {4}
3025 } -result 4
30163026 test spinbox-13.17 {GetSpinboxIndex procedure} -constraints fonts -body {
30173027 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3018 -font {Courier -12}
3028 -font {Courier -12}
30193029 pack .e
30203030 .e insert 0 012345678901234567890
30213031 .e xview 4
30233033 .e index @11
30243034 } -cleanup {
30253035 destroy .e
3026 } -result {4}
3036 } -result 4
30273037 test spinbox-13.18 {GetSpinboxIndex procedure} -constraints fonts -body {
30283038 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3029 -font {Courier -12}
3039 -font {Courier -12}
30303040 pack .e
30313041 .e insert 0 012345678901234567890
30323042 .e xview 4
30343044 .e index @12
30353045 } -cleanup {
30363046 destroy .e
3037 } -result {5}
3047 } -result 5
30383048 test spinbox-13.19 {GetSpinboxIndex procedure} -constraints fonts -body {
30393049 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3040 -font {Courier -12}
3050 -font {Courier -12}
30413051 pack .e
30423052 .e insert 0 012345678901234567890
30433053 .e xview 4
30453055 .e index @[expr {[winfo width .e] - 6-11}]
30463056 } -cleanup {
30473057 destroy .e
3048 } -result {8}
3058 } -result 8
30493059 test spinbox-13.20 {GetSpinboxIndex procedure} -constraints fonts -body {
30503060 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3051 -font {Courier -12}
3061 -font {Courier -12}
30523062 pack .e
30533063 .e insert 0 012345678901234567890
30543064 .e xview 4
30563066 .e index @[expr {[winfo width .e] - 5}]
30573067 } -cleanup {
30583068 destroy .e
3059 } -result {9}
3069 } -result 9
30603070 test spinbox-13.21 {GetSpinboxIndex procedure} -body {
30613071 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3062 -font {Courier -12}
3072 -font {Courier -12}
30633073 pack .e
30643074 .e insert 0 012345678901234567890
30653075 .e xview 4
30673077 .e index @1000
30683078 } -cleanup {
30693079 destroy .e
3070 } -result {9}
3080 } -result 9
30713081 test spinbox-13.22 {GetSpinboxIndex procedure} -setup {
3072 spinbox .e
3082 spinbox .e
30733083 pack .e
30743084 update
30753085 } -body {
30793089 } -returnCodes error -result {bad spinbox index "1xyz"}
30803090 test spinbox-13.23 {GetSpinboxIndex procedure} -body {
30813091 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3082 -font {Courier -12}
3092 -font {Courier -12}
30833093 pack .e
30843094 .e insert 0 012345678901234567890
30853095 .e xview 4
30863096 update
3087 .e index -10
3088 } -cleanup {
3089 destroy .e
3090 } -result {0}
3097 .e index -1
3098 } -cleanup {
3099 destroy .e
3100 } -result 0
30913101 test spinbox-13.24 {GetSpinboxIndex procedure} -body {
30923102 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3093 -font {Courier -12}
3103 -font {Courier -12}
30943104 pack .e
30953105 .e insert 0 012345678901234567890
30963106 .e xview 4
30983108 .e index 12
30993109 } -cleanup {
31003110 destroy .e
3101 } -result {12}
3111 } -result 12
31023112 test spinbox-13.25 {GetSpinboxIndex procedure} -body {
31033113 spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \
3104 -font {Courier -12}
3114 -font {Courier -12}
31053115 pack .e
31063116 .e insert 0 012345678901234567890
31073117 .e xview 4
31093119 .e index 49
31103120 } -cleanup {
31113121 destroy .e
3112 } -result {21}
3122 } -result 21
31133123
31143124 # XXX Still need to write tests for SpinboxScanTo and SpinboxSelectTo.
31153125
31293139 }
31303140 } -body {
31313141 spinbox .e
3132 .e insert end $x
3142 .e insert end $x
31333143 .e select from 0
31343144 .e select to end
31353145 string compare [selection get] $x
31363146 } -cleanup {
31373147 destroy .e
3138 } -result {0}
3148 } -result 0
31393149
31403150 test spinbox-15.1 {SpinboxLostSelection} -body {
31413151 spinbox .e
31563166 spinbox .e -width 10 -font {Helvetica -12}
31573167 pack .e
31583168 update
3159 .e insert 0 "............................."
3169 .e insert 0 "............................."
31603170 format {%.6f %.6f} {*}[.e xview]
31613171 } -cleanup {
31623172 destroy .e
31723182 test spinbox-17.1 {SpinboxUpdateScrollbar procedure} -body {
31733183 spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12}
31743184 pack .e
3185 update idletasks
3186 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
31753187 .e delete 0 end
31763188 .e insert 0 123
3177 set timeout [after 500 {set $scrollInfo "timeout"}]
31783189 vwait scrollInfo
31793190 format {%.6f %.6f} {*}$scrollInfo
31803191 } -cleanup {
31853196 spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12}
31863197 pack .e
31873198 .e insert 0 0123456789abcdef
3199 update idletasks
3200 set timeout [after 500 {set $scrollInfo {-1000000 -1000000}}]
31883201 .e xview 3
3189 set timeout [after 500 {set $scrollInfo "timeout"}]
31903202 vwait scrollInfo
31913203 format {%.6f %.6f} {*}$scrollInfo
31923204 } -cleanup {
31963208 test spinbox-17.3 {SpinboxUpdateScrollbar procedure} -body {
31973209 spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12}
31983210 pack .e
3211 update idletasks
3212 set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
31993213 .e insert 0 abcdefghijklmnopqrs
3200 .e xview 6
3201 set timeout [after 500 {set $scrollInfo "timeout"}]
3214 .e xview
32023215 vwait scrollInfo
32033216 format {%.6f %.6f} {*}$scrollInfo
32043217 } -cleanup {
32053218 destroy .e
32063219 after cancel $timeout
3207 } -result {0.315789 0.842105}
3220 } -result {0.000000 0.526316}
32083221 test spinbox-17.4 {SpinboxUpdateScrollbar procedure} -setup {
32093222 proc bgerror msg {
32103223 global x
32113224 set x $msg
32123225 }
32133226 } -body {
3214 spinbox .e -width 5 -xscrollcommand thisisnotacommand
3215 pack .e
3227 spinbox .e -width 5
3228 pack .e
3229 update idletasks
3230 .e configure -xscrollcommand thisisnotacommand
32163231 vwait x
32173232 list $x $errorInfo
32183233 } -cleanup {
32333248 set res1 [list [winfo children .] [interp hidden]]
32343249 set res2 [list {} $l]
32353250 expr {$res1 == $res2}
3236 } -result {1}
3251 } -result 1
32373252
32383253 ##
32393254 ## Spinbox widget VALIDATION tests
35873602 -background red -foreground white
35883603 pack .e
35893604 set ::e nextdata ;# previous settings
3590
3605
35913606 .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V]
35923607 .e validate
35933608 list [.e cget -validate] [.e get] $::vVals
35943609 } -cleanup {
35953610 destroy .e
3596 } -result {none mydata {.e -1 -1 nextdata nextdata {} all forced}}
3611 } -result {none nextdata {.e -1 -1 nextdata nextdata {} all forced}}
35973612
35983613 ## This leaves validate alone because we trigger validation through the
35993614 ## textvar (a write trace), and the write during validation triggers
36123627 set ::e nextdata ;# previous settings
36133628 .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V] ;# prev
36143629 .e validate ;# previous settings
3615
3630
36163631 .e configure -validate all
36173632 set ::e testdata
36183633 list [.e cget -validate] [.e get] $::e $::vVals
36193634 } -cleanup {
36203635 destroy .e
36213636 } -result {all testdata mydata {.e -1 -1 testdata mydata {} all forced}}
3637
3638 ## This leaves validate alone because we trigger validation through the
3639 ## textvar (a write trace), and the write during validation triggers
3640 ## nothing (by definition of avoiding loops on var traces). This is
3641 ## one of those "dangerous" conditions where the user will have a
3642 ## different value in the entry widget shown as is in the textvar.
3643 test spinbox-19.21 {spinbox widget validation - bug 40e4bf6198} -setup {
3644 unset -nocomplain ::e ::vVals
3645 } -body {
3646 spinbox .e -validate key \
3647 -validatecommand [list doval2 %W %d %i %P %s %S %v %V] \
3648 -textvariable ::e
3649 pack .e
3650 set ::e origdata
3651 .e insert 0 A
3652 list [.e cget -validate] [.e get] $::e $::vVals
3653 } -cleanup {
3654 destroy .e
3655 } -result {none origdata mydata {.e 1 0 Aorigdata origdata A key key}}
3656
36223657 ##
36233658 ## End validation tests
36243659 ##
37743809 set val
37753810 } -cleanup {
37763811 destroy .e
3777 } -result {5}
3812 } -result 5
37783813 test spinbox-22.2 {spinbox config, -from changes SF bug 559078} -body {
37793814 set val 5
37803815 spinbox .e -from 1 -to 10 -textvariable val
37823817 set val
37833818 } -cleanup {
37843819 destroy .e
3785 } -result {5}
3820 } -result 5
37863821 test spinbox-22.3 {spinbox config, -from changes SF bug 559078} -body {
37873822 set val 5
37883823 spinbox .e -from 3 -to 10 -textvariable val
37903825 set val
37913826 } -cleanup {
37923827 destroy .e
3793 } -result {6}
3828 } -result 6
37943829
37953830 test spinbox-23.1 {selection present while disabled, bug 637828} -body {
37963831 spinbox .e
909909 } -body {
910910 catch {destroy .t}
911911 text .t
912 .t tag cget sel -relief
912 .t tag cget sel -relief
913913 } -cleanup {
914914 destroy .t
915915 } -result {flat}
918918 } -body {
919919 catch {destroy .t}
920920 text .t
921 .t tag cget sel -relief
921 .t tag cget sel -relief
922922 } -cleanup {
923923 destroy .t
924924 } -result {flat}
927927 } -body {
928928 catch {destroy .t}
929929 text .t
930 .t tag cget sel -relief
930 .t tag cget sel -relief
931931 } -cleanup {
932932 destroy .t
933933 } -result {raised}
20342034 .t tag configure elide -elide 1
20352035 .t tag add elide 5.2 5.4
20362036 .t window create 5.4
2037 .t delete 5.4
2037 .t delete 5.4
20382038 .t tag add elide 5.5 5.6
20392039 .t get -displaychars 5.2 5.8
20402040 } -cleanup {
29162916 lappend res [.t index "1.0 +1 indices"]
29172917 lappend res [.t index "1.0 +1 display indices"]
29182918 lappend res [.t index "1.0 +1 display chars"]
2919 lappend res [.t index end]
2919 lappend res [.t index end]
29202920 lappend res [.t index "end -1 indices"]
29212921 lappend res [.t index "end -1 display indices"]
29222922 lappend res [.t index "end -1 display chars"]
30883088 for {set i 1} {$i < 300} {incr i} {
30893089 append content [string repeat "$i " 50] \n
30903090 }
3091 # Sync the widget and process all <<WidgetViewSync>> events before binding.
3091 # Sync the widget and process all <<WidgetViewSync>> events before binding.
30923092 .top.yt sync
30933093 update
30943094 bind .top.yt <<WidgetViewSync>> {lappend res Sync:%d}
31193119 pack [text .top.t]
31203120 update
31213121 for {set i 1} {$i < 10000} {incr i} {
3122 .top.t insert end "Hello world!\n"
3122 .top.t insert end "Hello world!\n"
31233123 }
31243124 bind .top.t <<WidgetViewSync>> {destroy .top.t}
31253125 .top.t tag add mytag 1.5 8000.8 ; # shall not crash
33223322 .t configure -tabs {30 foo}
33233323 } -cleanup {
33243324 destroy .t
3325 } -returnCodes {error} -result {bad tab alignment "foo": must be left, right, center, or numeric}
3325 } -returnCodes {error} -result {bad tab alignment "foo": must be left, right, center, or numeric}
33263326 test text-14.6 {ConfigureText procedure} -setup {
33273327 text .t
33283328 } -body {
3329 catch {.t configure -tabs {30 foo}}
3329 catch {.t configure -tabs {30 foo}}
33303330 .t configure -tabs {10 20 30}
33313331 return $errorInfo
33323332 } -cleanup {
33453345 destroy .t
33463346 } -result {}
33473347 test text-14.8 {ConfigureText procedure} -setup {
3348 text .t
3348 text .t
33493349 } -body {
33503350 .t configure -wrap bogus
33513351 } -cleanup {
33713371 destroy .t
33723372 } -result {}
33733373 test text-14.11 {ConfigureText procedure} -setup {
3374 text .t
3374 text .t
33753375 } -body {
33763376 .t configure -selectborderwidth foo
33773377 } -cleanup {
34613461 toplevel .top
34623462 text .top.t -font {Courier -12} -borderwidth 2 -highlightthickness 2
34633463 } -body {
3464 .top.t configure -width 20 -height 10
3464 .top.t configure -width 20 -height 10
34653465 pack .top.t
34663466 update
34673467 set geom [wm geometry .top]
34753475 # to the appropriate size.
34763476 # On macOS, however, there is no way to make the window overlap the menubar.
34773477 if {[tk windowingsystem] == "aqua"} {
3478 set minY 23
3478 set minY [expr [menubarheight] + 1]
34793479 } else {
34803480 set minY 0
34813481 }
35573557 test text-17.2 {TextCmdDeletedProc procedure, disabling -setgrid} -constraints {
35583558 fonts
35593559 } -body {
3560 toplevel .top
3560 toplevel .top
35613561 text .top.t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} \
35623562 -setgrid 1 -width 20 -height 10
35633563 pack .top.t
49494949 test text-22.119 {TextSearchCmd, multiline regexp matching} -body {
49504950 pack [text .t]
49514951 .t insert 1.0 { Tcl_Obj *objPtr));
4952 static Tcl_Obj* FSNormalizeAbsolutePath
4952 static Tcl_Obj* FSNormalizeAbsolutePath
49534953 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
49544954 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
49554955 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
49664966 pack [text .t]
49674967 .t insert 1.0 {static int SetFsPathFromAny _ANSI_ARGS_((Tcl_Interp *interp,
49684968 Tcl_Obj *objPtr));
4969 static Tcl_Obj* FSNormalizeAbsolutePath
4969 static Tcl_Obj* FSNormalizeAbsolutePath
49704970 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
49714971 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
49724972 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
49804980 .t insert 1.0 {
49814981 static int SetFsPathFromAny _ANSI_ARGS_((Tcl_Interp *interp,
49824982 Tcl_Obj *objPtr));
4983 static Tcl_Obj* FSNormalizeAbsolutePath
4983 static Tcl_Obj* FSNormalizeAbsolutePath
49844984 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
49854985 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
49864986 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
50655065
50665066 void
50675067 Tcl_SetObjLength(objPtr, length)
5068 register Tcl_Obj *objPtr; /* Pointer to object. This object must
5069 * not currently be shared. */
5070 register int length; /* Number of bytes desired for string
5068 Tcl_Obj *objPtr; /* Pointer to object. This object must
5069 * not currently be shared. */
5070 int length; /* Number of bytes desired for string
50715071 * representation of object, not including
5072 * terminating null byte. */
5072 * terminating null byte. */
50735073 \{
50745074 char *new;
50755075 }
61766176 test text-24.1 {TextDumpCmd procedure, bad args} -body {
61776177 pack [text .t]
61786178 .t insert 1.0 "One Line"
6179 .t mark set insert 1.0
6179 .t mark set insert 1.0
61806180 .t dump
61816181 } -cleanup {
61826182 destroy .t
61846184 test text-24.2 {TextDumpCmd procedure, bad args} -body {
61856185 pack [text .t]
61866186 .t insert 1.0 "One Line"
6187 .t mark set insert 1.0
6187 .t mark set insert 1.0
61886188 .t dump -all
61896189 } -cleanup {
61906190 destroy .t
61926192 test text-24.3 {TextDumpCmd procedure, bad args} -body {
61936193 pack [text .t]
61946194 .t insert 1.0 "One Line"
6195 .t mark set insert 1.0
6195 .t mark set insert 1.0
61966196 .t dump -command
61976197 } -cleanup {
61986198 destroy .t
62006200 test text-24.4 {TextDumpCmd procedure, bad args} -body {
62016201 pack [text .t]
62026202 .t insert 1.0 "One Line"
6203 .t mark set insert 1.0
6203 .t mark set insert 1.0
62046204 .t dump -bogus
62056205 } -cleanup {
62066206 destroy .t
62086208 test text-24.5 {TextDumpCmd procedure, bad args} -body {
62096209 pack [text .t]
62106210 .t insert 1.0 "One Line"
6211 .t mark set insert 1.0
6211 .t mark set insert 1.0
62126212 .t dump bogus
62136213 } -cleanup {
62146214 destroy .t
62456245 test text-24.10 {TextDumpCmd procedure, negative range} -body {
62466246 pack [text .t]
62476247 .t insert 1.0 "One Line"
6248 .t mark set insert 1.0
6248 .t mark set insert 1.0
62496249 .t dump 1.5 1.0
62506250 } -cleanup {
62516251 destroy .t
66916691 update
66926692 set ::retval no_<<Selection>>_event_fired
66936693 .t mark set insert 1.15
6694 focus .t
6694 update idletasks
6695 focus -force .t
66956696 event generate .t <Delete>
66966697 update
66976698 set ::retval
72357236 for {set i 1} {$i < 20} {incr i} {
72367237 .t insert end "Line $i\n"
72377238 }
7238 .t tag add sel 1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
7239 .t tag add sel 1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
72397240 lappend res [.t tag prevrange sel 1.0]
72407241 .t configure -start 6 -end 12
72417242 lappend res [.t tag ranges sel]
72567257 for {set i 1} {$i < 20} {incr i} {
72577258 .t insert end "Line $i\n"
72587259 }
7259 .t tag add sel 1.0 3.0 9.0 11.0 13.0 15.0 17.0 19.0
7260 .t tag add sel 1.0 3.0 9.0 11.0 13.0 15.0 17.0 19.0
72607261 .t configure -start 6 -end 12
72617262 lappend res [.t tag ranges sel]
72627263 lappend res "next" [.t tag nextrange sel 4.0] \
72767277 for {set i 1} {$i < 20} {incr i} {
72777278 .t insert end "Line $i\n"
72787279 }
7279 .t tag add sel 1.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
7280 .t tag add sel 1.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
72807281 .t configure -start 6 -end 12
72817282 lappend res [.t tag ranges sel]
72827283 lappend res "next" [.t tag nextrange sel 4.0] \
73217322 return $res
73227323 } -cleanup {
73237324 destroy .t
7324 } -result {1.0 11.0}
7325 } -result {1.0 11.0}
73257326 test text-31.19 {peer widgets} -body {
73267327 pack [text .t]
73277328 for {set i 1} {$i < 20} {incr i} {
73667367 update
73677368 set after [$w count -ypixels 1.0 2.0]
73687369 destroy .g
7369 expr {$before eq $after}
7370 expr {$before eq $after}
73707371 } -cleanup {
73717372 destroy .t
73727373 } -result {1}
55 # Copyright (c) 1998-1999 by Scriptics Corporation.
66 # All rights reserved.
77
8 package require tcltest 2.1
8 package require tcltest 2.2
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
15
1316 # Platform specific procedure for updating the text widget.
1417
1518 if {[tk windowingsystem] == "aqua"} {
1619 proc updateText {} {
1720 update idletasks
1821 }
22 proc delay {} {
23 update idletasks
24 after 100
25 update idletasks
26 }
1927 } else {
2028 proc updateText {} {
29 update
30 }
31 proc delay {} {
32 update
33 after 100
2134 update
2235 }
2336 }
266279 .t insert 1.0 "This isx some sample text for testing."
267280 list [.t bbox 1.13] [.t bbox 1.19] [.t bbox 1.20] [.t bbox 1.21]
268281 } [list [list 96 5 $fixedWidth $fixedHeight] [list 138 5 $fixedWidth $fixedHeight] [list 145 5 0 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] $fixedWidth $fixedHeight]]
269 test textDisp-2.6 {LayoutDLine, word wrap} {
282 test textDisp-2.6 {LayoutDLine, word wrap} failsOnUbuntu {
270283 .t configure -wrap word
271284 .t delete 1.0 end
272285 .t insert 1.0 "This isxxx some sample text for testing."
601614 test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
602615 # This test was failing on Windows because the title bar on .
603616 # was a certain minimum size and it was interfering with the size
604 # requested. The "overrideredirect" gets rid of the titlebar so
617 # requested. The "overrideredirect" gets rid of the titlebar so
605618 # the toplevel can shrink to the appropriate size. On Unix, setting
606619 # the overrideredirect on "." confuses the window manager and
607620 # causes subsequent tests to fail.
633646 test textDisp-4.7 {UpdateDisplayInfo, filling in extra vertical space} {
634647 # This test was failing on Windows because the title bar on .
635648 # was a certain minimum size and it was interfering with the size
636 # requested. The "overrideredirect" gets rid of the titlebar so
649 # requested. The "overrideredirect" gets rid of the titlebar so
637650 # the toplevel can shrink to the appropriate size. On Unix, setting
638651 # the overrideredirect on "." confuses the window manager and
639652 # causes subsequent tests to fail.
652665 updateText
653666 set x
654667 } {8.0 {16.0 17.0 15.0 14.0 13.0 12.0 11.0 10.0 9.0 8.0} {8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0}}
655 test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} {
668 test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} failsOnXQuarz {
656669 .t delete 1.0 end
657670 .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
658671 .t yview 16.0
715728 updateText
716729 list $tk_textRelayout $tk_textRedraw
717730 } {{11.0 12.0 13.0} {4.0 10.0 11.0 12.0 13.0}}
718 test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} {
731 test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} failsOnXQuarz {
719732 .t tag remove x 1.0 end
720733 .t yview 1.0
721734 updateText
848861 } [list 30 30]
849862
850863 .t configure -wrap char
851 test textDisp-6.1 {scrolling in DisplayText, scroll up} {
864 test textDisp-6.1 {scrolling in DisplayText, scroll up} failsOnXQuarz {
852865 .t delete 1.0 end
853866 .t insert 1.0 "Line 1"
854867 foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
11361149 updateText
11371150 list $tk_textRelayout $tk_textRedraw
11381151 } {{1.0 1.20 1.40} {1.0 1.20 1.40}}
1139 test textDisp-8.7 {TkTextChanged} {
1152 test textDisp-8.7 {TkTextChanged} failsOnXQuarz {
11401153 .t delete 1.0 end
11411154 .t insert 1.0 "Line 1 is so long that it wraps around, two times"
11421155 foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
11581171 updateText
11591172 list $tk_textRelayout $tk_textRedraw
11601173 } {2.0 2.0}
1161 test textDisp-8.9 {TkTextChanged} {
1174 test textDisp-8.9 {TkTextChanged} failsOnXQuarz {
11621175 .t delete 1.0 end
11631176 .t insert 1.0 "Line 1 is so long that it wraps around, two times"
11641177 foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
11691182 updateText
11701183 list $tk_textRelayout $tk_textRedraw
11711184 } {{2.0 8.0} {2.0 8.0}}
1172 test textDisp-8.10 {TkTextChanged} {
1185 test textDisp-8.10 {TkTextChanged} failsOnUbuntu {
11731186 .t configure -wrap char
11741187 .t delete 1.0 end
11751188 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
12291242 update idletasks
12301243 } {}
12311244
1232 test textDisp-9.1 {TkTextRedrawTag} {
1245 test textDisp-9.1 {TkTextRedrawTag} failsOnUbuntu {
12331246 .t configure -wrap char
12341247 .t delete 1.0 end
12351248 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
12471260 updateText
12481261 list $tk_textRelayout $tk_textRedraw
12491262 } {{1.0 2.0 2.17} {1.0 2.0 2.17}}
1250 test textDisp-9.3 {TkTextRedrawTag} {
1263 test textDisp-9.3 {TkTextRedrawTag} failsOnUbuntu {
12511264 .t configure -wrap char
12521265 .t delete 1.0 end
12531266 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
12581271 updateText
12591272 list $tk_textRelayout $tk_textRedraw
12601273 } {{2.0 2.20} {2.0 2.20 eof}}
1261 test textDisp-9.4 {TkTextRedrawTag} {
1274 test textDisp-9.4 {TkTextRedrawTag} failsOnUbuntu {
12621275 .t configure -wrap char
12631276 .t delete 1.0 end
12641277 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
12691282 updateText
12701283 list $tk_textRelayout $tk_textRedraw
12711284 } {{2.0 2.20} {2.0 2.20 eof}}
1272 test textDisp-9.5 {TkTextRedrawTag} {
1285 test textDisp-9.5 {TkTextRedrawTag} {failsOnUbuntu failsOnXQuarz} {
12731286 .t configure -wrap char
12741287 .t delete 1.0 end
12751288 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
12801293 updateText
12811294 list $tk_textRelayout $tk_textRedraw
12821295 } {{2.0 2.20} {2.0 2.20 eof}}
1283 test textDisp-9.6 {TkTextRedrawTag} {
1296 test textDisp-9.6 {TkTextRedrawTag} failsOnUbuntu {
12841297 .t configure -wrap char
12851298 .t delete 1.0 end
12861299 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap"
12911304 updateText
12921305 list $tk_textRelayout $tk_textRedraw
12931306 } {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 eof}}
1294 test textDisp-9.7 {TkTextRedrawTag} {
1307 test textDisp-9.7 {TkTextRedrawTag} failsOnUbuntu {
12951308 .t configure -wrap char
12961309 .t delete 1.0 end
12971310 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
14311444 updateText
14321445 .t index @0,0
14331446 } {30.0}
1434 test textDisp-11.2 {TkTextSetYView} {
1447 test textDisp-11.2 {TkTextSetYView} failsOnXQuarz {
14351448 .t yview 30.0
14361449 updateText
14371450 .t yview 32.0
14451458 updateText
14461459 list [.t index @0,0] $tk_textRedraw
14471460 } {28.0 {28.0 29.0}}
1448 test textDisp-11.4 {TkTextSetYView} {
1461 test textDisp-11.4 {TkTextSetYView} failsOnXQuarz {
14491462 .t yview 30.0
14501463 updateText
14511464 .t yview 31.4
14761489 updateText
14771490 list [.t index @0,0] $tk_textRedraw
14781491 } {21.0 {21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
1479 test textDisp-11.8 {TkTextSetYView} {
1492 test textDisp-11.8 {TkTextSetYView} failsOnXQuarz {
14801493 .t yview 30.0
14811494 updateText
14821495 set tk_textRedraw {}
14841497 updateText
14851498 list [.t index @0,0] $tk_textRedraw
14861499 } {32.0 {40.0 41.0}}
1487 test textDisp-11.9 {TkTextSetYView} {
1500 test textDisp-11.9 {TkTextSetYView} failsOnXQuarz {
14881501 .t yview 30.0
14891502 updateText
14901503 set tk_textRedraw {}
15081521 updateText
15091522 list [.t index @0,0] $tk_textRedraw
15101523 } {191.0 {191.0 192.0 193.0 194.0 195.0 196.0}}
1511 test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
1524 test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} failsOnXQuarz {
15121525 .t insert 10.0 "Long line with enough text to wrap\n"
15131526 .t yview 1.0
15141527 updateText
18491862 test textDisp-14.6 {TkTextXviewCmd procedure} {
18501863 list [catch {.t xview moveto a} msg] $msg
18511864 } {1 {expected floating-point number but got "a"}}
1852 test textDisp-14.7 {TkTextXviewCmd procedure} {
1865 test textDisp-14.7 {TkTextXviewCmd procedure} failsOnUbuntu {
18531866 .t delete 1.0 end
18541867 .t insert end xxxxxxxxx\n
18551868 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
19011914 .t insert end "a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9\n"
19021915 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
19031916 .t xview moveto 0
1904 .t xview scroll 21 u
1917 .t xview scroll 21 u
19051918 set x [.t index @0,22]
19061919 .t xview scroll -1 u
19071920 lappend x [.t index @0,22]
20492062 test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
20502063 list [catch {.t yview moveto gorp} msg] $msg
20512064 } {1 {expected floating-point number but got "gorp"}}
2052 test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
2065 test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
20532066 .t yview moveto 0.5
20542067 .t index @0,0
20552068 } {103.0}
20612074 .t yview moveto 1.1
20622075 .t index @0,0
20632076 } {191.0}
2064 test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
2077 test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
20652078 .t yview moveto .75
20662079 .t index @0,0
20672080 } {151.60}
2068 test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
2081 test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
20692082 .t yview moveto .752
20702083 .t index @0,0
20712084 } {151.60}
2072 test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {textfonts} {
2085 test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} textfonts {
20732086 set count [expr {5 * $bigHeight + 150 * $fixedHeight}]
20742087 set extra [expr {0.04 * double($fixedDiff * 150) / double($count)}]
20752088 .t yview moveto [expr {.753 - $extra}]
20762089 .t index @0,0
20772090 } {151.60}
2078 test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
2091 test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
20792092 .t yview moveto .755
20802093 .t index @0,0
20812094 } {151.80}
22392252 test textDisp-16.39 {TkTextYviewCmd procedure} {
22402253 list [catch {.t yview scroll 1.3i pixels} msg] $msg
22412254 } {0 {}}
2242 test textDisp-16.40 {text count -xpixels} {
2255 test textDisp-16.40 {text count -xpixels} failsOnUbuntu {
22432256 set res {}
22442257 lappend res [.t count -xpixels 1.0 1.5] \
22452258 [.t count -xpixels 1.5 1.0] \
23582371 .t xview moveto 0
23592372 .t scan mark 0 60
23602373 .t scan dragto 30 100
2361 .t scan dragto 25 95
2374 .t scan dragto 25 95
23622375 .t index @0,0
23632376 } {4.7}
23642377 test textDisp-17.9 {TkTextScanCmd procedure} {textfonts} {
25532566 updateText
25542567 set x $scrollInfo
25552568 } {0.125 0.75}
2556 test textDisp-19.8 {GetYView procedure} {
2569 test textDisp-19.8 {GetYView procedure} failsOnUbuntu {
25572570 .t configure -wrap char
25582571 .t delete 1.0 end
25592572 .t insert 1.0 "Line 1"
28502863 [.t count -ypixels 16.0 "16.0 displaylineend +1c"] \
28512864 [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"]
28522865 } [list [expr {260 + 20 * $fixedDiff}] [expr {260 + 20 * $fixedDiff}] $fixedHeight [expr {2*$fixedHeight}] $fixedHeight [expr {3*$fixedHeight}]]
2853 test textDisp-19.17 {count -ypixels with indices in elided lines} {
2866 test textDisp-19.17 {count -ypixels with indices in elided lines} {failsOnUbuntu failsOnXQuarz} {
28542867 .t configure -wrap none
28552868 .t delete 1.0 end
28562869 for {set i 1} {$i < 100} {incr i} {
28772890 .t yview 35.0
28782891 lappend res [.t count -ypixels 5.0 25.0]
28792892 } [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]]
2880 test textDisp-19.18 {count -ypixels with indices in elided lines} {
2893 test textDisp-19.18 {count -ypixels with indices in elided lines} {failsOnUbuntu failsOnXQuarz} {
28812894 .t configure -wrap none
28822895 .t delete 1.0 end
28832896 for {set i 1} {$i < 100} {incr i} {
29152928 .t configure -wrap word
29162929 .t delete 50.0 51.0
29172930 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2918 test textDisp-20.1 {FindDLine} {
2931 test textDisp-20.1 {FindDLine} failsOnUbuntu {
29192932 .t yview 48.0
29202933 list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
29212934 [.t dlineinfo 58.0]
29222935 } [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2923 test textDisp-20.2 {FindDLine} {
2936 test textDisp-20.2 {FindDLine} failsOnUbuntu {
29242937 .t yview 100.0
29252938 .t yview -pickplace 53.0
29262939 list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21]
29272940 } [list [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2928 test textDisp-20.3 {FindDLine} {
2941 test textDisp-20.3 {FindDLine} failsOnUbuntu {
29292942 .t yview 100.0
29302943 .t yview 49.0
29312944 list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 57.0]
29322945 } [list [list 3 [expr {$fixedDiff + 16}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2933 test textDisp-20.4 {FindDLine} {
2946 test textDisp-20.4 {FindDLine} failsOnUbuntu {
29342947 .t yview 100.0
29352948 .t yview 42.0
29362949 list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 50.40]
29372950 } [list [list 3 [expr {8*$fixedDiff + 107}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
29382951 .t config -wrap none
2939 test textDisp-20.5 {FindDLine} {
2952 test textDisp-20.5 {FindDLine} failsOnUbuntu {
29402953 .t yview 100.0
29412954 .t yview 48.0
29422955 list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
29692982 Use the Up (cursor) key to scroll up one line at a time. At the second press, the cursor either gets locked or jumps several lines.
29702983
29712984 Connect with Tkcon. The command
2972 .u count -displaylines \
2985 .u count -displaylines \
29732986 3.10 2.173
29742987 should give answer -1; it gives me 5.
29752988
33943407 .t tag add x 1.0 end
33953408 list [.t bbox 1.0] [.t bbox 1.10]
33963409 } [list [list 45 3 7 $fixedHeight] [list 94 3 7 $fixedHeight]]
3397 test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints {textfonts} -setup {
3410 test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints {textfonts failsOnXQuarz} -setup {
33983411 text .tt -tabs {40 right} -wrap none -font $fixedFont
33993412 pack .tt
34003413 } -body {
38733886 set iWidth [lindex [.t2.t bbox end-2c] 2]
38743887 .t2.t xview scroll 2 units
38753888 set iWidth2 [lindex [.t2.t bbox end-2c] 2]
3876
3889
38773890 if {($iWidth == $iWidth2) && $iWidth >= 2} {
38783891 set result "correct"
38793892 } else {
39163929 .t configure -height 1
39173930 updateText
39183931
3919 test textDisp-31.1 {line embedded window height update} {
3932 test textDisp-31.1 {line embedded window height update} failsOnUbuntu {
39203933 set res {}
39213934 .t delete 1.0 end
39223935 .t insert end "abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyx"
39293942 set res
39303943 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
39313944
3932 test textDisp-31.2 {line update index shifting} {
3945 test textDisp-31.2 {line update index shifting} failsOnUbuntu {
39333946 set res {}
39343947 .t.f configure -height 100
39353948 updateText
39463959 set res
39473960 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
39483961
3949 test textDisp-31.3 {line update index shifting} {
3962 test textDisp-31.3 {line update index shifting} failsOnUbuntu {
39503963 # Should do exactly the same as the above, as long
39513964 # as we are correctly tagging the correct lines for
39523965 # recalculation. The 'update' and 'delay' must be
39603973 .t insert 1.0 "abc\n"
39613974 .t insert 1.0 "abc\n"
39623975 lappend res [.t count -ypixels 1.0 end]
3963 update ; after 1000 ; update
3976 delay
39643977 lappend res [.t count -ypixels 1.0 end]
39653978 .t.f configure -height 100
39663979 .t delete 1.0 3.0
39673980 lappend res [.t count -ypixels 1.0 end]
3968 update ; after 1000 ; update
3981 delay
39693982 lappend res [.t count -ypixels 1.0 end]
39703983 set res
39713984 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
39833996 set res
39843997 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
39853998
3986 test textDisp-31.5 {line update index shifting} {
3999 test textDisp-31.5 {line update index shifting} failsOnUbuntu {
39874000 set res {}
39884001 textest configure -height 100
39894002 updateText
40004013 set res
40014014 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
40024015
4003 test textDisp-31.6 {line update index shifting} {
4016 test textDisp-31.6 {line update index shifting} failsOnUbuntu {
40044017 # Should do exactly the same as the above, as long
40054018 # as we are correctly tagging the correct lines for
40064019 # recalculation. The 'update' and 'delay' must be
40134026 .t insert 1.0 "abc\n"
40144027 .t insert 1.0 "abc\n"
40154028 lappend res [.t count -ypixels 1.0 end]
4016 update ; after 1000 ; update
4029 delay
40174030 lappend res [.t count -ypixels 1.0 end]
40184031 textest configure -height 100
40194032 .t delete 1.0 3.0
40204033 lappend res [.t count -ypixels 1.0 end]
4021 update ; after 1000 ; update
4034 delay
40224035 lappend res [.t count -ypixels 1.0 end]
40234036 set res
40244037 } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
40354048 .t tag configure elide -elide 1
40364049 .t tag add elide 1.3 2.1
40374050 lappend res [.t count -ypixels 1.0 end]
4038 update ; after 1000 ; update
4051 delay
40394052 lappend res [.t count -ypixels 1.0 end]
40404053 .t delete 1.0 3.0
40414054 lappend res [.t count -ypixels 1.0 end]
4042 update ; after 1000 ; update
4055 delay
40434056 lappend res [.t count -ypixels 1.0 end]
40444057 set res
40454058 } [list [expr {$fixedHeight * 1}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 2}] [expr {$fixedHeight * 1}] [expr {$fixedHeight * 1}]]
41744187
41754188 test textDisp-33.0 {one line longer than fits in the widget} {
41764189 pack [text .tt -wrap char]
4190 updateText
41774191 .tt insert 1.0 [string repeat "more wrap + " 300]
41784192 updateText
41794193 .tt see 1.0
41824196 test textDisp-33.1 {one line longer than fits in the widget} {
41834197 destroy .tt
41844198 pack [text .tt -wrap char]
4199 updateText
41854200 .tt insert 1.0 [string repeat "more wrap + " 300]
41864201 updateText
41874202 .tt yview "1.0 +1 displaylines"
41954210 destroy .tt
41964211 pack [text .tt -wrap char]
41974212 .tt debug 1
4213 updateText
41984214 set tk_textHeightCalc ""
4215 set timer [after 200 lappend tk_textHeightCalc "Timed out"]
41994216 .tt insert 1.0 [string repeat "more wrap + " 1]
4200 after 100 ; update idletasks
4201 # Nothing should have been recalculated.
4217 vwait tk_textHeightCalc
4218 after cancel $timer
42024219 set tk_textHeightCalc
4203 } {}
4220 } {1.0}
42044221 test textDisp-33.3 {one line longer than fits in the widget} {
42054222 destroy .tt
42064223 pack [text .tt -wrap char]
7373 } -body {
7474 text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
7575 pack .t
76 .t image configure
76 .t image configure
7777 } -cleanup {
7878 destroy .t
7979 } -returnCodes error -result {wrong # args: should be ".t image configure index ?-option value ...?"}
8383 } -body {
8484 text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
8585 pack .t
86 .t image configure blurf
86 .t image configure blurf
8787 } -cleanup {
8888 destroy .t
8989 } -returnCodes error -result {bad text index "blurf"}
9393 } -body {
9494 text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
9595 pack .t
96 .t image configure 1.1
96 .t image configure 1.1
9797 } -cleanup {
9898 destroy .t
9999 } -returnCodes error -result {no embedded image at index "1.1"}
113113 } -body {
114114 text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
115115 pack .t
116 .t image create blurf
116 .t image create blurf
117117 } -cleanup {
118118 destroy .t
119119 } -returnCodes error -result {bad text index "blurf"}
220220 .t image create end -image small
221221 foreach i {align padx pady image name} {
222222 lappend result $i:[.t image cget small -$i]
223 }
223 }
224224 return $result
225225 } -cleanup {
226226 destroy .t
242242 .t image create end -image small
243243 foreach {option value} {align top padx 5 pady 7 image large name none} {
244244 .t image configure small -$option $value
245 }
245 }
246246 update
247247 .t image configure small
248248 } -cleanup {
308308 vary configure -width $i -height $i
309309 update
310310 lappend result $i:[.t bbox vary]
311 }
311 }
312312 return $result
313313 } -cleanup {
314314 destroy .t
55 # Copyright (c) 1998-1999 by Scriptics Corporation.
66 # All rights reserved.
77
8 package require tcltest 2.1
8 package require tcltest 2.2
99 eval tcltest::configure $argv
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
1616 update
1717 .t debug on
1818 wm geometry . {}
19
19
2020 # The statements below reset the main window; it's needed if the window
2121 # manager is mwm to make mwm forget about a previous minimum size setting.
2222
7373 testtext .t byteindex 3 80
7474 } {3.5 5}
7575 test textIndex-1.10 {TkTextMakeByteIndex: verify index is in range} {testtext} {
76 # for (segPtr = indexPtr->linePtr->segPtr; ; segPtr = segPtr->nextPtr)
76 # for (segPtr = indexPtr->linePtr->segPtr; ; segPtr = segPtr->nextPtr)
7777 # one segment
7878
7979 testtext .t byteindex 3 5
8383 # index += segPtr->size
8484 # Multiple segments, make sure add segment size to index.
8585
86 .t mark set foo 3.2
86 .t mark set foo 3.2
8787 set x [testtext .t byteindex 3 7]
8888 .t mark unset foo
8989 set x
116116 } {5.18 20}
117117 test textIndex-1.17 {TkTextMakeByteIndex: prevent splitting UTF-8 character} \
118118 {testtext} {
119 # ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType))
119 # ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType))
120120 # Wrong answer would be \xb9 (the 2nd byte of UTF rep of 0x4e4f).
121121
122122 set x [testtext .t byteindex 5 2]
124124 } {{5.2 4} y}
125125 test textIndex-1.18 {TkTextMakeByteIndex: prevent splitting UTF-8 character} \
126126 {testtext} {
127 # ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType))
127 # ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType))
128128 testtext .t byteindex 5 1
129129 .t get insert
130130 } "\u4e4f"
167167 # for (segPtr = indexPtr->linePtr->segPtr; ; segPtr = segPtr->nextPtr)
168168 # Multiple segments, make sure add segment size to index.
169169
170 .t mark set foo 3.2
170 .t mark set foo 3.2
171171 set x [.t index 3.7]
172172 .t mark unset foo
173173 set x
438438 test textIndex-12.6 {TkTextIndexForwChars: find index} {
439439 # for ( ; segPtr != NULL; segPtr = segPtr->nextPtr)
440440 # border condition: segPtr == NULL -> beginning of next line
441
441
442442 .t index {2.3 + 11 chars}
443443 } 3.0
444444 test textIndex-12.7 {TkTextIndexForwChars: find index} {
457457 .t image create 2.4 -image textimage
458458 set x [.t get {2.3 + 3 chars}]
459459 .t delete 2.4
460 set x
460 set x
461461 } "f"
462462 test textIndex-12.10 {TkTextIndexForwChars: find index} {
463463 # dstPtr->byteIndex += segPtr->size - byteOffset
587587 set x
588588 } 2.9
589589 test textIndex-14.12 {TkTextIndexBackChars: move to previous line} {
590 # (lineIndex == 0)
590 # (lineIndex == 0)
591591 .t index {1.5 - 10 chars}
592592 } 1.0
593593 test textIndex-14.13 {TkTextIndexBackChars: move to previous line} {
594 # not (lineIndex == 0)
594 # not (lineIndex == 0)
595595 .t index {2.5 - 10 chars}
596596 } 1.2
597597 test textIndex-14.14 {TkTextIndexBackChars: move to previous line} {
811811 } {1}
812812
813813 test textIndex-19.13 {Display lines} {
814 destroy {*}[pack slaves .]
814 destroy {*}[pack content .]
815815 text .txt -height 1 -wrap word -yscroll ".sbar set" -width 400
816816 scrollbar .sbar -command ".txt yview"
817817 grid .txt .sbar -sticky news
2626 bOy GIrl .#@? x_yz
2727 !@#$%
2828 Line 7"
29
29
3030 # The statements below reset the main window; it's needed if the window
3131 # manager is mwm to make mwm forget about a previous minimum size setting.
3232
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
15
1316 destroy .t
1417 text .t -width 20 -height 10
1518 testConstraint haveCourier12 [expr {[catch {
2225
2326 wm geometry . {}
2427 set bigFont {Helvetica 24}
25
28
2629 # The statements below reset the main window; it's needed if the window
2730 # manager is mwm, to make mwm forget about a previous minimum size setting.
2831
371374
372375
373376 test textTag-2.1 {TkTextTagCmd - "add" option} -constraints {
374 haveCourier12
377 haveCourier12
375378 } -body {
376379 .t tag
377380 } -returnCodes error -result {wrong # args: should be ".t tag option ?arg ...?"}
378381 test textTag-2.2 {TkTextTagCmd - "add" option} -constraints {
379 haveCourier12
382 haveCourier12
380383 } -body {
381384 .t tag gorp
382385 } -returnCodes error -result {bad tag option "gorp": must be add, bind, cget, configure, delete, lower, names, nextrange, prevrange, raise, ranges, or remove}
383386 test textTag-2.3 {TkTextTagCmd - "add" option} -constraints {
384 haveCourier12
387 haveCourier12
385388 } -body {
386389 .t tag add foo
387390 } -returnCodes error -result {wrong # args: should be ".t tag add tagName index1 ?index2 index1 index2 ...?"}
388391 test textTag-2.4 {TkTextTagCmd - "add" option} -constraints {
389 haveCourier12
392 haveCourier12
390393 } -body {
391394 .t tag add x gorp
392395 } -returnCodes error -result {bad text index "gorp"}
393396 test textTag-2.5 {TkTextTagCmd - "add" option} -constraints {
394 haveCourier12
397 haveCourier12
395398 } -body {
396399 .t tag add x 1.2 gorp
397400 } -returnCodes error -result {bad text index "gorp"}
398401 test textTag-2.6 {TkTextTagCmd - "add" option} -constraints {
399 haveCourier12
402 haveCourier12
400403 } -setup {
401404 .t tag delete sel
402405 } -body {
405408 .t tag ranges sel
406409 } -result {3.2 3.4}
407410 test textTag-2.7 {TkTextTagCmd - "add" option} -constraints {
408 haveCourier12
411 haveCourier12
409412 } -setup {
410413 .t tag delete x
411414 } -body {
415418 .t tag delete x
416419 } -result {1.0 1.6}
417420 test textTag-2.8 {TkTextTagCmd - "add" option} -constraints {
418 haveCourier12
421 haveCourier12
419422 } -setup {
420423 .t tag remove x 1.0 end
421424 } -body {
425428 .t tag delete x
426429 } -result {1.2 1.3}
427430 test textTag-2.9 {TkTextTagCmd - "add" option} -constraints {
428 haveCourier12
431 haveCourier12
429432 } -setup {
430433 destroy .t.e
431434 } -body {
439442 destroy .t.e
440443 } -result 34
441444 test textTag-2.10 {TkTextTagCmd - "add" option} -constraints {
442 haveCourier12
445 haveCourier12
443446 } -setup {
444447 destroy .t.e
445448 } -body {
454457 destroy .t.e
455458 } -result {Text}
456459 test textTag-2.11 {TkTextTagCmd - "add" option} -constraints {
457 haveCourier12
460 haveCourier12
458461 } -body {
459462 .t tag remove sel 1.0 end
460463 .t tag add sel 1.1 1.5 2.4 3.1 4.2 4.4
461464 .t tag ranges sel
462465 } -result {1.1 1.5 2.4 3.1 4.2 4.4}
463466 test textTag-2.12 {TkTextTagCmd - "add" option} -constraints {
464 haveCourier12
467 haveCourier12
465468 } -body {
466469 .t tag remove sel 1.0 end
467470 .t tag add sel 1.1 1.5 2.4
485488
486489
487490 test textTag-3.1 {TkTextTagCmd - "bind" option} -constraints {
488 haveCourier12
491 haveCourier12
489492 } -body {
490493 .t tag bind
491494 } -returnCodes error -result {wrong # args: should be ".t tag bind tagName ?sequence? ?command?"}
492495 test textTag-3.2 {TkTextTagCmd - "bind" option} -constraints {
493 haveCourier12
496 haveCourier12
494497 } -body {
495498 .t tag bind 1 2 3 4
496499 } -returnCodes error -result {wrong # args: should be ".t tag bind tagName ?sequence? ?command?"}
497500 test textTag-3.3 {TkTextTagCmd - "bind" option} -constraints {
498 haveCourier12
501 haveCourier12
499502 } -body {
500503 .t tag bind x <Enter> script1
501504 .t tag bind x <Enter>
503506 .t tag delete x
504507 } -result {script1}
505508 test textTag-3.4 {TkTextTagCmd - "bind" option} -constraints {
506 haveCourier12
509 haveCourier12
507510 } -body {
508511 .t tag bind x <Gorp> script2
509512 } -returnCodes error -result {bad event type or keysym "Gorp"}
510513 test textTag-3.5 {TkTextTagCmd - "bind" option} -constraints {
511 haveCourier12
514 haveCourier12
512515 } -body {
513516 .t tag delete x
514517 .t tag bind x <Enter> script1
517520 .t tag delete x
518521 } -returnCodes error -result {requested illegal events; only key, button, motion, enter, leave, and virtual events may be used}
519522 test textTag-3.6 {TkTextTagCmd - "bind" option} -constraints {
520 haveCourier12
523 haveCourier12
521524 } -body {
522525 .t tag delete x
523526 .t tag bind x <Enter> script1
524 catch {.t tag bind x <FocusIn> script2}
527 catch {.t tag bind x <FocusIn> script2}
525528 .t tag bind x
526529 } -cleanup {
527530 .t tag delete x
528531 } -result {<Enter>}
529532 test textTag-3.7 {TkTextTagCmd - "bind" option} -constraints {
530 haveCourier12
533 haveCourier12
531534 } -body {
532535 .t tag delete x
533536 .t tag bind x <Enter> script1
538541 .t tag delete x
539542 } -result {{<Enter> <Leave> a} script1 xyzzy}
540543 test textTag-3.8 {TkTextTagCmd - "bind" option} -constraints {
541 haveCourier12
544 haveCourier12
542545 } -body {
543546 .t tag delete x
544547 .t tag bind x <Enter> script1
549552 } -result {script1
550553 script2}
551554 test textTag-3.9 {TkTextTagCmd - "bind" option} -constraints {
552 haveCourier12
555 haveCourier12
553556 } -body {
554557 .t tag delete x
555558 .t tag bind x <Enter>
557560 .t tag delete x
558561 } -returnCodes ok -result {}
559562 test textTag-3.10 {TkTextTagCmd - "bind" option} -constraints {
560 haveCourier12
563 haveCourier12
561564 } -body {
562565 .t tag delete x
563566 .t tag bind x <
567570
568571
569572 test textTag-4.1 {TkTextTagCmd - "cget" option} -constraints {
570 haveCourier12
573 haveCourier12
571574 } -body {
572575 .t tag cget a
573576 } -returnCodes error -result {wrong # args: should be ".t tag cget tagName option"}
574577 test textTag-4.2 {TkTextTagCmd - "cget" option} -constraints {
575 haveCourier12
578 haveCourier12
576579 } -body {
577580 .t tag cget a b c
578581 } -returnCodes error -result {wrong # args: should be ".t tag cget tagName option"}
579582 test textTag-4.3 {TkTextTagCmd - "cget" option} -constraints {
580 haveCourier12
583 haveCourier12
581584 } -body {
582585 .t tag delete foo
583586 .t tag cget foo bar
584587 } -returnCodes error -result {tag "foo" isn't defined in text widget}
585588 test textTag-4.4 {TkTextTagCmd - "cget" option} -constraints {
586 haveCourier12
589 haveCourier12
587590 } -body {
588591 .t tag cget sel bogus
589592 } -returnCodes error -result {unknown option "bogus"}
590593 test textTag-4.5 {TkTextTagCmd - "cget" option} -constraints {
591 haveCourier12
594 haveCourier12
592595 } -body {
593596 .t tag delete x
594597 .t tag configure x -background red
599602
600603
601604 test textTag-5.1 {TkTextTagCmd - "configure" option} -constraints {
602 haveCourier12
605 haveCourier12
603606 } -body {
604607 .t tag configure
605608 } -returnCodes error -result {wrong # args: should be ".t tag configure tagName ?-option? ?value? ?-option value ...?"}
606609 test textTag-5.2 {TkTextTagCmd - "configure" option} -constraints {
607 haveCourier12
610 haveCourier12
608611 } -body {
609612 .t tag configure x -foo
610613 } -returnCodes error -result {unknown option "-foo"}
611614 test textTag-5.3 {TkTextTagCmd - "configure" option} -constraints {
612 haveCourier12
615 haveCourier12
613616 } -body {
614617 .t tag configure x -background red -underline
615618 } -cleanup {
616619 .t tag delete x
617620 } -returnCodes error -result {value for "-underline" missing}
618621 test textTag-5.4 {TkTextTagCmd - "configure" option} -constraints {
619 haveCourier12
622 haveCourier12
620623 } -body {
621624 .t tag delete x
622625 .t tag configure x -underline yes
632635 .t tag delete x
633636 } -result {-underlinefg {} {} {} lightgreen}
634637 test textTag-5.5 {TkTextTagCmd - "configure" option} -constraints {
635 haveCourier12
638 haveCourier12
636639 } -body {
637640 .t tag delete x
638641 .t tag configure x -overstrike on
648651 .t tag delete x
649652 } -result {-overstrikefg {} {} {} lightgreen}
650653 test textTag-5.6 {TkTextTagCmd - "configure" option} -constraints {
651 haveCourier12
654 haveCourier12
652655 } -body {
653656 .t tag configure x -overstrike foo
654657 } -cleanup {
655658 .t tag delete x
656659 } -returnCodes error -result {expected boolean value but got "foo"}
657660 test textTag-5.7 {TkTextTagCmd - "configure" option} -constraints {
658 haveCourier12
661 haveCourier12
659662 } -body {
660663 .t tag delete x
661664 .t tag configure x -underline stupid
663666 .t tag delete x
664667 } -returnCodes error -result {expected boolean value but got "stupid"}
665668 test textTag-5.8 {TkTextTagCmd - "configure" option} -constraints {
666 haveCourier12
669 haveCourier12
667670 } -body {
668671 .t tag delete x
669672 .t tag configure x -justify left
672675 .t tag delete x
673676 } -result {-justify {} {} {} left}
674677 test textTag-5.9 {TkTextTagCmd - "configure" option} -constraints {
675 haveCourier12
678 haveCourier12
676679 } -body {
677680 .t tag delete x
678681 .t tag configure x -justify bogus
680683 .t tag delete x
681684 } -returnCodes error -result {bad justification "bogus": must be left, right, or center}
682685 test textTag-5.10 {TkTextTagCmd - "configure" option} -constraints {
683 haveCourier12
686 haveCourier12
684687 } -body {
685688 .t tag delete x
686689 .t tag configure x -justify fill
688691 .t tag delete x
689692 } -returnCodes error -result {bad justification "fill": must be left, right, or center}
690693 test textTag-5.11 {TkTextTagCmd - "configure" option} -constraints {
691 haveCourier12
694 haveCourier12
692695 } -body {
693696 .t tag delete x
694697 .t tag configure x -offset 2
697700 .t tag delete x
698701 } -result {-offset {} {} {} 2}
699702 test textTag-5.12 {TkTextTagCmd - "configure" option} -constraints {
700 haveCourier12
703 haveCourier12
701704 } -body {
702705 .t tag delete x
703706 .t tag configure x -offset 1.0q
718721 {-lmargincolor {} {} {} darkblue} {-rmargincolor {} {} {} lightgreen} \
719722 ]
720723 test textTag-5.14 {TkTextTagCmd - "configure" option} -constraints {
721 haveCourier12
724 haveCourier12
722725 } -body {
723726 .t tag delete x
724727 .t tag configure x -lmargin1 2.0x
726729 .t tag delete x
727730 } -returnCodes error -result {bad screen distance "2.0x"}
728731 test textTag-5.15 {TkTextTagCmd - "configure" option} -constraints {
729 haveCourier12
732 haveCourier12
730733 } -body {
731734 .t tag delete x
732735 .t tag configure x -lmargin2 gorp
740743 .t tag delete x
741744 } -returnCodes error -result {unknown color name "rainbow"}
742745 test textTag-5.16 {TkTextTagCmd - "configure" option} -constraints {
743 haveCourier12
746 haveCourier12
744747 } -body {
745748 .t tag delete x
746749 .t tag configure x -rmargin 140.1.1
755758 } -returnCodes error -result {unknown color name "rainbow"}
756759 .t tag delete x
757760 test textTag-5.17 {TkTextTagCmd - "configure" option} -constraints {
758 haveCourier12
761 haveCourier12
759762 } -body {
760763 .t tag delete x
761764 .t tag configure x -spacing1 2 -spacing2 4 -spacing3 6
765768 .t tag delete x
766769 } -result {{-spacing1 {} {} {} 2} {-spacing2 {} {} {} 4} {-spacing3 {} {} {} 6}}
767770 test textTag-5.18 {TkTextTagCmd - "configure" option} -constraints {
768 haveCourier12
771 haveCourier12
769772 } -body {
770773 .t tag delete x
771774 .t tag configure x -spacing1 2.0x
773776 .t tag delete x
774777 } -returnCodes error -result {bad screen distance "2.0x"}
775778 test textTag-5.19 {TkTextTagCmd - "configure" option} -constraints {
776 haveCourier12
779 haveCourier12
777780 } -body {
778781 .t tag delete x
779782 .t tag configure x -spacing1 lousy
781784 .t tag delete x
782785 } -returnCodes error -result {bad screen distance "lousy"}
783786 test textTag-5.20 {TkTextTagCmd - "configure" option} -constraints {
784 haveCourier12
787 haveCourier12
785788 } -body {
786789 .t tag delete x
787790 .t tag configure x -spacing1 4.2.3
789792 .t tag delete x
790793 } -returnCodes error -result {bad screen distance "4.2.3"}
791794 test textTag-5.21 {TkTextTagCmd - "configure" option} -constraints {
792 haveCourier12
795 haveCourier12
793796 } -body {
794797 .t configure -selectborderwidth 2 -selectforeground blue \
795798 -selectbackground black
801804 return $x
802805 } -result {4 green yellow}
803806 test textTag-5.22 {TkTextTagCmd - "configure" option} -constraints {
804 haveCourier12
807 haveCourier12
805808 } -body {
806809 .t configure -selectborderwidth 20
807810 .t tag configure sel -borderwidth {}
855858 } -result {yellow blue red white}
856859
857860 test textTag-6.1 {TkTextTagCmd - "delete" option} -constraints {
858 haveCourier12
861 haveCourier12
859862 } -body {
860863 .t tag delete
861864 } -returnCodes error -result {wrong # args: should be ".t tag delete tagName ?tagName ...?"}
862865 test textTag-6.2 {TkTextTagCmd - "delete" option} -constraints {
863 haveCourier12
866 haveCourier12
864867 } -body {
865868 .t tag delete zork
866869 } -returnCodes ok -result {}
867870 test textTag-6.3 {TkTextTagCmd - "delete" option} -constraints {
868 haveCourier12
871 haveCourier12
869872 } -setup {
870873 .t tag delete {*}[.t tag names]
871874 } -body {
878881 .t tag delete x
879882 } -result {sel x}
880883 test textTag-6.4 {TkTextTagCmd - "delete" option} -constraints {
881 haveCourier12
884 haveCourier12
882885 } -setup {
883886 .t tag delete {*}[.t tag names]
884887 } -body {
889892 .t tag names
890893 } -result {sel}
891894 test textTag-6.5 {TkTextTagCmd - "delete" option} -constraints {
892 haveCourier12
895 haveCourier12
893896 } -body {
894897 .t tag bind x <Enter> foo
895898 .t tag delete x
901904
902905
903906 test textTag-7.1 {TkTextTagCmd - "lower" option} -constraints {
904 haveCourier12
907 haveCourier12
905908 } -body {
906909 .t tag lower
907910 } -returnCodes error -result {wrong # args: should be ".t tag lower tagName ?belowThis?"}
908911 test textTag-7.2 {TkTextTagCmd - "lower" option} -constraints {
909 haveCourier12
912 haveCourier12
910913 } -body {
911914 .t tag lower foo
912915 } -returnCodes error -result {tag "foo" isn't defined in text widget}
913916 test textTag-7.3 {TkTextTagCmd - "lower" option} -constraints {
914 haveCourier12
917 haveCourier12
915918 } -body {
916919 .t tag lower sel bar
917920 } -returnCodes error -result {tag "bar" isn't defined in text widget}
918921 test textTag-7.4 {TkTextTagCmd - "lower" option} -constraints {
919 haveCourier12
922 haveCourier12
920923 } -setup {
921924 .t tag delete {*}[.t tag names]
922925 .t tag remove sel 1.0 end
930933 .t tag delete {*}[.t tag names]
931934 } -result {c sel a b d}
932935 test textTag-7.5 {TkTextTagCmd - "lower" option} -constraints {
933 haveCourier12
936 haveCourier12
934937 } -setup {
935938 .t tag delete {*}[.t tag names]
936939 .t tag remove sel 1.0 end
944947 .t tag delete {*}[.t tag names]
945948 } -result {sel a d b c}
946949 test textTag-7.6 {TkTextTagCmd - "lower" option} -constraints {
947 haveCourier12
950 haveCourier12
948951 } -setup {
949952 .t tag delete {*}[.t tag names]
950953 .t tag remove sel 1.0 end
960963
961964
962965 test textTag-8.1 {TkTextTagCmd - "names" option} -constraints {
963 haveCourier12
966 haveCourier12
964967 } -body {
965968 .t tag names a b
966969 } -cleanup {
967970 .t tag delete {*}[.t tag names]
968971 } -returnCodes error -result {wrong # args: should be ".t tag names ?index?"}
969972 test textTag-8.2 {TkTextTagCmd - "names" option} -constraints {
970 haveCourier12
973 haveCourier12
971974 } -setup {
972975 .t tag delete {*}[.t tag names]
973976 .t tag remove sel 1.0 end
980983 .t tag delete {*}[.t tag names]
981984 } -result {sel a b c d}
982985 test textTag-8.3 {TkTextTagCmd - "names" option} -constraints {
983 haveCourier12
986 haveCourier12
984987 } -setup {
985988 .t tag delete {*}[.t tag names]
986989 .t tag remove sel 1.0 end
9971000
9981001
9991002 test textTag-9.1 {TkTextTagCmd - "nextrange" option} -constraints {
1000 haveCourier12
1003 haveCourier12
10011004 } -body {
10021005 .t tag nextrange x
10031006 } -returnCodes error -result {wrong # args: should be ".t tag nextrange tagName index1 ?index2?"}
10041007 test textTag-9.2 {TkTextTagCmd - "nextrange" option} -constraints {
1005 haveCourier12
1008 haveCourier12
10061009 } -body {
10071010 .t tag nextrange x 1 2 3
10081011 } -returnCodes error -result {wrong # args: should be ".t tag nextrange tagName index1 ?index2?"}
10091012 test textTag-9.3 {TkTextTagCmd - "nextrange" option} -constraints {
1010 haveCourier12
1013 haveCourier12
10111014 } -body {
10121015 .t tag nextrange foo 1.0
10131016 } -returnCodes ok -result {}
10141017 test textTag-9.4 {TkTextTagCmd - "nextrange" option} -constraints {
1015 haveCourier12
1018 haveCourier12
10161019 } -setup {
10171020 .t tag delete x
10181021 } -body {
10221025 .t tag delete x
10231026 } -returnCodes error -result {bad text index "foo"}
10241027 test textTag-9.5 {TkTextTagCmd - "nextrange" option} -constraints {
1025 haveCourier12
1028 haveCourier12
10261029 } -setup {
10271030 .t tag delete x
10281031 } -body {
10341037 .t tag delete x
10351038 } -returnCodes error -result {bad text index "bar"}
10361039 test textTag-9.6 {TkTextTagCmd - "nextrange" option} -constraints {
1037 haveCourier12
1040 haveCourier12
10381041 } -setup {
10391042 .t tag delete x
10401043 } -body {
10461049 .t tag delete x
10471050 } -result {2.3 2.5}
10481051 test textTag-9.7 {TkTextTagCmd - "nextrange" option} -constraints {
1049 haveCourier12
1052 haveCourier12
10501053 } -setup {
10511054 .t tag delete x
10521055 } -body {
10581061 .t tag delete x
10591062 } -result {2.3 2.5}
10601063 test textTag-9.8 {TkTextTagCmd - "nextrange" option} -constraints {
1061 haveCourier12
1064 haveCourier12
10621065 } -setup {
10631066 .t tag delete x
10641067 } -body {
10701073 .t tag delete x
10711074 } -result {2.3 2.5}
10721075 test textTag-9.9 {TkTextTagCmd - "nextrange" option} -constraints {
1073 haveCourier12
1076 haveCourier12
10741077 } -setup {
10751078 .t tag delete x
10761079 } -body {
10821085 .t tag delete x
10831086 } -result {2.9 3.1}
10841087 test textTag-9.10 {TkTextTagCmd - "nextrange" option} -constraints {
1085 haveCourier12
1088 haveCourier12
10861089 } -setup {
10871090 .t tag delete x
10881091 } -body {
10941097 .t tag delete x
10951098 } -result {}
10961099 test textTag-9.11 {TkTextTagCmd - "nextrange" option} -constraints {
1097 haveCourier12
1100 haveCourier12
10981101 } -setup {
10991102 .t tag delete x
11001103 } -body {
11061109 .t tag delete x
11071110 } -result {2.9 3.1}
11081111 test textTag-9.12 {TkTextTagCmd - "nextrange" option} -constraints {
1109 haveCourier12
1112 haveCourier12
11101113 } -setup {
11111114 .t tag delete x
11121115 } -body {
11181121 .t tag delete x
11191122 } -result {2.9 3.1}
11201123 test textTag-9.13 {TkTextTagCmd - "nextrange" option} -constraints {
1121 haveCourier12
1124 haveCourier12
11221125 } -setup {
11231126 .t tag delete x
11241127 } -body {
11301133 .t tag delete x
11311134 } -result {7.2 7.3}
11321135 test textTag-9.14 {TkTextTagCmd - "nextrange" option} -constraints {
1133 haveCourier12
1136 haveCourier12
11341137 } -setup {
11351138 .t tag delete x
11361139 } -body {
11441147
11451148
11461149 test textTag-10.1 {TkTextTagCmd - "prevrange" option} -constraints {
1147 haveCourier12
1150 haveCourier12
11481151 } -body {
11491152 .t tag prevrange x
11501153 } -returnCodes error -result {wrong # args: should be ".t tag prevrange tagName index1 ?index2?"}
11511154 test textTag-10.2 {TkTextTagCmd - "prevrange" option} -constraints {
1152 haveCourier12
1155 haveCourier12
11531156 } -body {
11541157 .t tag prevrange x 1 2 3
11551158 } -returnCodes error -result {wrong # args: should be ".t tag prevrange tagName index1 ?index2?"}
11561159 test textTag-10.3 {TkTextTagCmd - "prevrange" option} -constraints {
1157 haveCourier12
1160 haveCourier12
11581161 } -setup {
11591162 .t tag delete x
11601163 } -body {
11631166 .t tag delete x
11641167 } -returnCodes ok -result {}
11651168 test textTag-10.4 {TkTextTagCmd - "prevrange" option} -constraints {
1166 haveCourier12
1169 haveCourier12
11671170 } -setup {
11681171 .t tag delete x
11691172 } -body {
11751178 .t tag delete x
11761179 } -returnCodes error -result {bad text index "foo"}
11771180 test textTag-10.5 {TkTextTagCmd - "prevrange" option} -constraints {
1178 haveCourier12
1181 haveCourier12
11791182 } -setup {
11801183 .t tag delete x
11811184 } -body {
11871190 .t tag delete x
11881191 } -returnCodes error -result {bad text index "bar"}
11891192 test textTag-10.6 {TkTextTagCmd - "prevrange" option} -constraints {
1190 haveCourier12
1193 haveCourier12
11911194 } -setup {
11921195 .t tag delete x
11931196 } -body {
11991202 .t tag delete x
12001203 } -result {7.2 7.3}
12011204 test textTag-10.7 {TkTextTagCmd - "prevrange" option} -constraints {
1202 haveCourier12
1205 haveCourier12
12031206 } -setup {
12041207 .t tag delete x
12051208 } -body {
12111214 .t tag delete x
12121215 } -result {2.3 2.5}
12131216 test textTag-10.8 {TkTextTagCmd - "prevrange" option} -constraints {
1214 haveCourier12
1217 haveCourier12
12151218 } -setup {
12161219 .t tag delete x
12171220 } -body {
12231226 .t tag delete x
12241227 } -result {2.3 2.5}
12251228 test textTag-10.9 {TkTextTagCmd - "prevrange" option} -constraints {
1226 haveCourier12
1229 haveCourier12
12271230 } -setup {
12281231 .t tag delete x
12291232 } -body {
12351238 .t tag delete x
12361239 } -result {2.3 2.5}
12371240 test textTag-10.10 {TkTextTagCmd - "prevrange" option} -constraints {
1238 haveCourier12
1241 haveCourier12
12391242 } -setup {
12401243 .t tag delete x
12411244 } -body {
12471250 .t tag delete x
12481251 } -result {}
12491252 test textTag-10.11 {TkTextTagCmd - "prevrange" option} -constraints {
1250 haveCourier12
1253 haveCourier12
12511254 } -setup {
12521255 .t tag delete x
12531256 } -body {
12591262 .t tag delete x
12601263 } -result {}
12611264 test textTag-10.12 {TkTextTagCmd - "prevrange" option} -constraints {
1262 haveCourier12
1265 haveCourier12
12631266 } -setup {
12641267 .t tag delete x
12651268 } -body {
12711274 .t tag delete x
12721275 } -result {2.3 2.5}
12731276 test textTag-10.13 {TkTextTagCmd - "prevrange" option} -constraints {
1274 haveCourier12
1277 haveCourier12
12751278 } -setup {
12761279 .t tag delete x
12771280 } -body {
12831286 .t tag delete x
12841287 } -result {2.9 3.1}
12851288 test textTag-10.14 {TkTextTagCmd - "prevrange" option} -constraints {
1286 haveCourier12
1289 haveCourier12
12871290 } -setup {
12881291 .t tag delete x
12891292 } -body {
12971300
12981301
12991302 test textTag-11.1 {TkTextTagCmd - "raise" option} -constraints {
1300 haveCourier12
1303 haveCourier12
13011304 } -body {
13021305 .t tag raise
13031306 } -returnCodes error -result {wrong # args: should be ".t tag raise tagName ?aboveThis?"}
13041307 test textTag-11.2 {TkTextTagCmd - "raise" option} -constraints {
1305 haveCourier12
1308 haveCourier12
13061309 } -body {
13071310 .t tag raise foo
13081311 } -returnCodes error -result {tag "foo" isn't defined in text widget}
13091312 test textTag-11.3 {TkTextTagCmd - "raise" option} -constraints {
1310 haveCourier12
1313 haveCourier12
13111314 } -body {
13121315 .t tag raise sel bar
13131316 } -returnCodes error -result {tag "bar" isn't defined in text widget}
13141317 test textTag-11.4 {TkTextTagCmd - "raise" option} -constraints {
1315 haveCourier12
1318 haveCourier12
13161319 } -setup {
13171320 .t tag delete {*}[.t tag names]
13181321 .t tag remove sel 1.0 end
13261329 .t tag delete {*}[.t tag names]
13271330 } -result {sel a b d c}
13281331 test textTag-11.5 {TkTextTagCmd - "raise" option} -constraints {
1329 haveCourier12
1332 haveCourier12
13301333 } -setup {
13311334 .t tag delete {*}[.t tag names]
13321335 .t tag remove sel 1.0 end
13401343 .t tag delete {*}[.t tag names]
13411344 } -result {sel a b d c}
13421345 test textTag-11.6 {TkTextTagCmd - "raise" option} -constraints {
1343 haveCourier12
1346 haveCourier12
13441347 } -setup {
13451348 .t tag delete {*}[.t tag names]
13461349 .t tag remove sel 1.0 end
13561359
13571360
13581361 test textTag-12.1 {TkTextTagCmd - "ranges" option} -constraints {
1359 haveCourier12
1362 haveCourier12
13601363 } -body {
13611364 .t tag ranges
13621365 } -returnCodes error -result {wrong # args: should be ".t tag ranges tagName"}
13631366 test textTag-12.2 {TkTextTagCmd - "ranges" option} -constraints {
1364 haveCourier12
1367 haveCourier12
13651368 } -body {
13661369 .t tag delete x
13671370 .t tag ranges x
13681371 } -result {}
13691372 test textTag-12.3 {TkTextTagCmd - "ranges" option} -constraints {
1370 haveCourier12
1373 haveCourier12
13711374 } -setup {
13721375 .t tag delete x
13731376 } -body {
13791382 .t tag delete x
13801383 } -result {2.2 2.3 2.7 4.6 5.2 5.5}
13811384 test textTag-12.4 {TkTextTagCmd - "ranges" option} -constraints {
1382 haveCourier12
1385 haveCourier12
13831386 } -setup {
13841387 .t tag delete x
13851388 } -body {
13921395
13931396
13941397 test textTag-13.1 {TkTextTagCmd - "remove" option} -constraints {
1395 haveCourier12
1398 haveCourier12
13961399 } -body {
13971400 .t tag remove
13981401 } -returnCodes error -result {wrong # args: should be ".t tag remove tagName index1 ?index2 index1 index2 ...?"}
13991402 test textTag-13.2 {TkTextTagCmd - "remove" option} -constraints {
1400 haveCourier12
1403 haveCourier12
14011404 } -setup {
14021405 .t tag delete x
14031406 } -body {
14081411 .t tag delete x
14091412 } -result {2.2 2.3 2.7 2.11}
14101413 test textTag-13.3 {TkTextTagCmd - "remove" option} -constraints {
1411 haveCourier12
1414 haveCourier12
14121415 } -setup {
14131416 destroy .t.e
14141417 } -body {
14871490
14881491 test textTag-15.1 {TkTextBindProc} -constraints haveCourier12 -setup {
14891492 .t tag delete x y
1490 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1493 wm geometry . +200+200 ; update
1494 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
14911495 } -body {
14921496 bind .t <ButtonRelease> {lappend x up}
14931497 .t tag bind x <ButtonRelease> {lappend x x-up}
15121516
15131517 test textTag-15.2 {TkTextBindProc} -constraints haveCourier12 -setup {
15141518 .t tag delete x y
1515 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1519 wm geometry . +200+200 ; update
1520 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
15161521 } -body {
15171522 .t tag bind x <Enter> {lappend x x-enter}
15181523 .t tag bind x <ButtonPress> {lappend x x-down}
15401545
15411546 test textTag-15.3 {TkTextBindProc} -constraints haveCourier12 -setup {
15421547 .t tag delete x y
1543 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1548 wm geometry . +200+200 ; update
1549 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
15441550 } -body {
15451551 .t tag bind x <Enter> {lappend x x-enter}
15461552 .t tag bind x <Any-ButtonPress-1> {lappend x x-down}
15721578
15731579
15741580 test textTag-16.1 {TkTextPickCurrent procedure} -constraints {
1575 haveCourier12
1576 } -setup {
1577 .t tag delete {*}[.t tag names]
1578 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1581 haveCourier12
1582 } -setup {
1583 .t tag delete {*}[.t tag names]
1584 wm geometry . +200+200 ; update
1585 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
15791586 } -body {
15801587 event gen .t <ButtonRelease-1> -state 0x100 -x $x1 -y $y1
15811588 set x [.t index current]
15941601 } -result {2.1 3.2 3.2 3.2 3.2 3.2 4.3}
15951602
15961603 test textTag-16.2 {TkTextPickCurrent procedure} -constraints {
1597 haveCourier12
1598 } -setup {
1599 .t tag delete {*}[.t tag names]
1600 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1604 haveCourier12 failsOnUbuntuNoXft
1605 } -setup {
1606 .t tag delete {*}[.t tag names]
1607 wm geometry . +200+200 ; update
1608 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
16011609 } -body {
16021610 .t tag configure big -font $bigFont
16031611 event gen .t <ButtonRelease-1> -state 0x100 -x $x1 -y $y1
16111619 } -result {3.2 3.1}
16121620
16131621 test textTag-16.3 {TkTextPickCurrent procedure} -constraints {
1614 haveCourier12
1622 haveCourier12
16151623 } -setup {
16161624 foreach i {a b c d} {
16171625 .t tag remove $i 1.0 end
16181626 }
1619 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1627 wm geometry . +200+200 ; update
1628 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
16201629 } -body {
16211630 foreach i {a b c d} {
16221631 .t tag bind $i <Enter> "lappend x enter-$i"
16401649 } -result {enter-a enter-b | leave-b enter-c | leave-a leave-c}
16411650
16421651 test textTag-16.4 {TkTextPickCurrent procedure} -constraints {
1643 haveCourier12
1652 haveCourier12
16441653 } -setup {
16451654 foreach i {a b c d} {
16461655 .t tag remove $i 1.0 end
16471656 }
1648 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1657 wm geometry . +200+200 ; update
1658 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
16491659 } -body {
16501660 foreach i {a b c d} {
16511661 .t tag bind $i <Enter> "lappend x enter-$i"
16681678 } -result {enter-a enter-b enter-c | leave-c leave-b}
16691679
16701680 test textTag-16.5 {TkTextPickCurrent procedure} -constraints {
1671 haveCourier12
1681 haveCourier12
16721682 } -setup {
16731683 foreach i {big a b c d} {
16741684 .t tag remove $i 1.0 end
16751685 }
1676 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1686 wm geometry . +200+200 ; update
1687 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
16771688 } -body {
16781689 .t tag configure big -font $bigFont
16791690 event gen .t <Motion> -x $x1 -y $y1
16861697 } -result {3.2}
16871698
16881699 test textTag-16.6 {TkTextPickCurrent procedure} -constraints {
1689 haveCourier12
1700 haveCourier12 failsOnUbuntuNoXft
16901701 } -setup {
16911702 foreach i {big a b c d} {
16921703 .t tag remove $i 1.0 end
16931704 }
1694 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1705 wm geometry . +200+200 ; update
1706 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
16951707 } -body {
16961708 .t tag configure big -font $bigFont
16971709 event gen .t <Motion> -x $x1 -y $y1
17051717 } -result {3.1}
17061718
17071719 test textTag-16.7 {TkTextPickCurrent procedure} -constraints {
1708 haveCourier12
1720 haveCourier12 failsOnUbuntuNoXft
17091721 } -setup {
17101722 foreach i {big a b c d} {
17111723 .t tag remove $i 1.0 end
17121724 }
1713 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1725 wm geometry . +200+200 ; update
1726 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
17141727 } -body {
17151728 .t tag configure big -font $bigFont
17161729 .t tag bind a <Enter> {.t tag add big 3.0 3.2}
17401753
17411754 test textTag-18.1 {TkTextPickCurrent tag bindings} -setup {
17421755 destroy .t
1743 event generate {} <Motion> -warp 1 -x -1 -y -1; update
1756 wm geometry . +200+200 ; update
1757 event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
17441758 } -body {
17451759 text .t -width 30 -height 4 -relief sunken -borderwidth 10 \
17461760 -highlightthickness 10 -pady 2
17471761 pack .t
17481762 update ; # map the window, otherwise -warp can't be done
1749
1763
17501764 .t insert end " Tag here " TAG " no tag here"
17511765 .t tag configure TAG -borderwidth 4 -relief raised
17521766 .t tag bind TAG <Enter> {lappend res "%x %y tag-Enter"}
1010 tcltest::configure {*}$argv
1111 tcltest::loadTestedCommands
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14
1315 deleteWindows
1416
15 set fixedFont {"Courier New" -12}
17 set fixedFont {"Courier" -12}
1618 set fixedHeight [font metrics $fixedFont -linespace]
1719 set fixedWidth [font measure $fixedFont m]
1820 set fixedAscent [font metrics $fixedFont -ascent]
4143 # This update is needed on MacOS to make sure that the window is mapped
4244 # when the tests begin.
4345
44 update
46 update
4547
4648 set bw [.t cget -borderwidth]
4749 set px [.t cget -padx]
581583 [list [expr {$padx+2*$fixedWidth+25}] [expr {$pady+((30-$fixedHeight)/2)}] $fixedWidth $fixedHeight]]
582584
583585
584 test textWind-7.1 {EmbWinLostSlaveProc procedure} -setup {
586 test textWind-7.1 {EmbWinLostContentProc procedure} -setup {
585587 .t delete 1.0 end
586588 destroy .f
587589 } -body {
598600 10x20+[expr {$padx+100}]+[expr {$pady+50}] \
599601 [list [expr {$padx+2*$fixedWidth}] [expr {$pady+($fixedHeight/2)}] 0 0]]
600602
601 test textWind-7.2 {EmbWinLostSlaveProc procedure} -setup {
603 test textWind-7.2 {EmbWinLostContentProc procedure} -setup {
602604 .t delete 1.0 end
603605 destroy .t.f
604606 } -body {
750752 destroy .t.f
751753 proc bgerror args {
752754 global msg
753 lappend msg $args
754 }
755 } -body {
756 .t insert 1.0 "Some sample text"
755 if {$msg == ""} {
756 lappend msg $args
757 }
758 }
759 } -body {
760 .t insert 1.0 "Some sample text"
761 set msg {}
757762 .t window create 1.5 -create {
758763 frame .t.f
759764 frame .t.f.f -width 10 -height 20 -bg $color
760765 }
761 set msg {}
762766 update idletasks
763767 lappend msg [winfo exists .t.f.f]
764768 } -cleanup {
770774 .t delete 1.0 end
771775 proc bgerror args {
772776 global msg
773 if {[lsearch -exact $msg $args] == -1} {
777 if {[lsearch -exact $msg $args] < 0} {
774778 lappend msg $args
775779 }
776780 }
789793 {{can't embed .t relative to .t}} \
790794 [list [expr {$padx+5*$fixedWidth}] [expr {$pady+($fixedHeight/2)}] 0 0]]
791795
792 test textWind-10.7 {EmbWinLayoutProc procedure, error in creating window} -setup {
796 test textWind-10.7 {EmbWinLayoutProc procedure, error in creating window} -constraints failsOnUbuntu -setup {
793797 .t delete 1.0 end
794798 destroy .t2
795799 proc bgerror args {
857861 } -body {
858862 .t configure -wrap char
859863 .t insert 1.0 "Some sample text"
860 frame .f -width 125 -height 20 -bg $color -bd 2 -relief raised
864 frame .f -width [expr {($tWidth-12)*$fixedWidth-1}] -height 20 -bg $color -bd 2 -relief raised
861865 .t window create 1.12 -window .f
862866 list [.t bbox .f] [.t bbox 1.13]
863867 } -cleanup {
872876 } -body {
873877 .t configure -wrap char
874878 .t insert 1.0 "Some sample text"
875 frame .f -width 126 -height 20 -bg $color -bd 2 -relief raised
879 frame .f -width [expr {($tWidth-12)*$fixedWidth}] -height 20 -bg $color -bd 2 -relief raised
876880 .t window create 1.12 -window .f
877881 update
878882 list [.t bbox .f] [.t bbox 1.13]
888892 } -body {
889893 .t configure -wrap char
890894 .t insert 1.0 "Some sample text"
891 frame .f -width 127 -height 20 -bg $color -bd 2 -relief raised
895 frame .f -width [expr {($tWidth-12)*$fixedWidth+1}] -height 20 -bg $color -bd 2 -relief raised
892896 .t window create 1.12 -window .f
893897 update
894898 list [.t bbox .f] [.t bbox 1.13]
895899 } -cleanup {
896900 destroy .f
897901 } -result [list \
898 [list $padx [expr {$pady+$fixedHeight}] 127 20] \
899 [list [expr {$padx+127}] [expr {$pady+$fixedHeight+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]]
902 [list $padx [expr {$pady+$fixedHeight}] [expr {($tWidth-12)*$fixedWidth+1}] 20] \
903 [list [expr {$padx+($tWidth-12)*$fixedWidth+1}] [expr {$pady+$fixedHeight+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]]
900904
901905 test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} -setup {
902906 .t delete 1.0 end
904908 } -body {
905909 .t configure -wrap none
906910 .t insert 1.0 "Some sample text"
907 frame .f -width 130 -height 20 -bg $color -bd 2 -relief raised
911 frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 20 -bg $color -bd 2 -relief raised
908912 .t window create 1.12 -window .f
909913 update
910914 list [.t bbox .f] [.t bbox 1.13]
920924 } -body {
921925 .t configure -wrap none
922926 .t insert 1.0 "Some sample text"
923 frame .f -width 130 -height 220 -bg $color -bd 2 -relief raised
927 frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 220 -bg $color -bd 2 -relief raised
924928 .t window create 1.12 -window .f
925929 update
926930 list [.t bbox .f] [.t bbox 1.13]
156156 update
157157 after 100
158158 set i [tk inactive]
159 expr {$i == -1 || ( $i > 90 && $i < 200 )}
159 expr {$i < 0 || ( $i > 90 && $i < 200 )}
160160 } -result 1
161161
162162 test tk-7.1 {tk inactive in a safe interpreter} -body {
33 # tests. Execute it by invoking "source all.tcl" when running tktest
44 # in this directory.
55 #
6 # Copyright (c) 2007 by the Tk developers.
6 # Copyright © 2007 by the Tk developers.
77 #
88 # See the file "license.terms" for information on usage and redistribution
99 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1515 tcltest::configure -loadfile \
1616 [file join [file dirname [tcltest::testsDirectory]] constraints.tcl]
1717 tcltest::configure -singleproc 1
18 tcltest::runAllTests
19
18 set ErrorOnFailures [info exists env(ERROR_ON_FAILURES)]
19 encoding system utf-8
20 if {[tcltest::runAllTests] && $ErrorOnFailures} {exit 1}
22 #
33
44 package require Tk
5 package require tcltest ; namespace import -force tcltest::*
5 package require tcltest 2.2
6 namespace import -force tcltest::*
67 loadTestedCommands
78
89 test checkbutton-1.1 "Checkbutton check" -body {
11 # ttk::combobox widget tests
22 #
33
4 package require Tk 8.5
5 package require tcltest ; namespace import -force tcltest::*
4 package require Tk
5 package require tcltest 2.2
6 namespace import -force tcltest::*
67 loadTestedCommands
78
89 test combobox-1.0 "Combobox tests -- setup" -body {
1112
1213 test combobox-1.1 "Bad -values list" -body {
1314 .cb configure -values "bad \{list"
14 } -result "unmatched open brace in list" -returnCodes 1
15 } -result "unmatched open brace in list" -returnCodes error
1516
1617 test combobox-1.end "Combobox tests -- cleanup" -body {
1718 destroy .cb
3738 .cb current
3839 } -result 1
3940
40 test combobox-2.4 "current -- value not in list" -body {
41 test combobox-2.4 "current -- value not in list" -body {
4142 .cb set "z"
4243 .cb current
4344 } -result -1
4445
45 test combobox-2.5 "current -- set to end index" -body {
46 test combobox-2.5 "current -- set to end index" -body {
4647 .cb configure -values [list a b c d e thelastone]
4748 .cb current end
4849 .cb get
4950 } -result thelastone
5051
51 test combobox-2.6 "current -- set to unknown index" -body {
52 test combobox-2.6 "current -- set to unknown index" -body {
5253 .cb configure -values [list a b c d e]
5354 .cb current notanindex
5455 } -returnCodes error -result {Incorrect index notanindex}
5758
5859 test combobox-3 "Read postoffset value dynamically from current style" -body {
5960 ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox"
60 pack .cb -expand true -fill both
61 pack .cb -expand true -fill both
6162 ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0]
6263 ttk::combobox::Post .cb
6364 expr {[winfo rootx .cb.popdown] - [winfo rootx .cb]}
11 # Tile package: entry widget tests
22 #
33
4 package require Tk 8.5
5 package require tcltest ; namespace import -force tcltest::*
4 package require Tk
5 package require tcltest 2.2
6 namespace import -force tcltest::*
67 loadTestedCommands
8
9 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
710
811 variable scrollInfo
912 proc scroll args {
7376 -expand false -fill x
7477 } -cleanup {destroy .te .tsb}
7578
79 test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -constraints failsOnUbuntu -body {
80 pack [ttk::entry .te -xscrollcommand [list .tsb set]] \
81 -expand true -fill both
82 .te insert end [string repeat "abc" 50]
83 catch {update} ; # error triggers because the -xscrollcommand callback
84 # errors out: invalid command name ".tsb"
85 pack [ttk::scrollbar .tsb -orient horizontal -command [list .te xview]] \
86 -expand false -fill x
87 update ; # no error
88 lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update
89 } -result 1 -cleanup {destroy .te .tsb}
90
7691 test entry-2.2 "Initial scroll position" -body {
7792 ttk::entry .e -font fixed -width 5 -xscrollcommand scroll
7893 .e insert end "0123456789"
115130 .e insert end abcdefghijklmnopqrstuvwxyz
116131 .e xview end
117132 set result [.e index @0]
118 } -result {7}
133 } -result 7
119134
120135 test entry-3.4 "xview" -body {
121136 .e delete 0 end;
122137 .e insert end abcdefghijklmnopqrstuvwxyz
123138 .e xview moveto 1.0
124139 set result [.e index @0]
125 } -result {7}
140 } -result 7
126141
127142 test entry-3.5 "xview" -body {
128143 .e delete 0 end;
129144 .e insert end abcdefghijklmnopqrstuvwxyz
130145 .e xview scroll 5 units
131146 set result [.e index @0]
132 } -result {5}
147 } -result 5
133148
134149 test entry-3.6 "xview" -body {
135150 .e delete 0 end;
136151 .e insert end [string repeat abcdefghijklmnopqrstuvwxyz 5]
137152 .e xview scroll 2 pages
138153 set result [.e index @0]
139 } -result {40}
154 } -result 40
140155
141156 test entry-3.last "Series 3 cleanup" -body {
142157 destroy .e
311326 destroy .e
312327 }
313328
329 test entry-10.1 {Bug [2830360fff] - Don't loose invalid at focus events} -setup {
330 pack [ttk::entry .e]
331 update
332 } -body {
333 .e state invalid
334 set res [.e state]
335 event generate .e <FocusOut>
336 lappend res [.e state]
337 } -result {invalid invalid} -cleanup {
338 destroy .e
339 }
340
314341 tcltest::cleanupTests
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 test image-1.1 "Bad image element" -body {
1011 ttk::style element create testElement image test.element
1112 } -body {
1213 ttk::style element create testElement image test.element
13 } -returnCodes 1 -result "Duplicate element testElement"
14 } -returnCodes error -result "Duplicate element testElement"
1415
1516 test image-2.0 "Deletion of displayed image (label)" -setup {
1617 image create photo test.image -width 10 -height 10
2223 } -cleanup {
2324 destroy .ttk_image20
2425 } -result {}
25
26
2627 test image-2.1 "Deletion of displayed image (checkbutton)" -setup {
2728 image create photo test.image -width 10 -height 10
2829 } -body {
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 test labelframe-1.0 "Setup" -body {
910 ttk::frame .lf.t
1011 ttk::checkbutton .lf.t.cb
1112 .lf configure -labelwidget .lf.t.cb
12 } -returnCodes 1 -result "can't *" -match glob \
13 } -returnCodes error -result "can't *" -match glob \
1314 -cleanup { destroy .lf.t } ;
1415
1516 test labelframe-2.2 "Can't use toplevel as labelwidget" -body {
1617 toplevel .lf.t
1718 .lf configure -labelwidget .lf.t
18 } -returnCodes 1 -result "can't *" -match glob \
19 } -returnCodes error -result "can't *" -match glob \
1920 -cleanup { destroy .lf.t } ;
2021
2122 test labelframe-2.3 "Can't use non-windows as -labelwidget" -body {
2223 .lf configure -labelwidget BogusWindowName
23 } -returnCodes 1 -result {bad window path name "BogusWindowName"}
24 } -returnCodes error -result {bad window path name "BogusWindowName"}
2425
2526 test labelframe-2.4 "Can't use nonexistent-windows as -labelwidget" -body {
2627 .lf configure -labelwidget .nosuchwindow
27 } -returnCodes 1 -result {bad window path name ".nosuchwindow"}
28 } -returnCodes error -result {bad window path name ".nosuchwindow"}
2829
2930
3031 ###
3132 # See also series labelframe-4.x
3233 #
33 test labelframe-3.1 "Add child slave" -body {
34 test labelframe-3.1 "Add child content" -body {
3435 checkbutton .lf.cb -text "abcde"
3536 .lf configure -labelwidget .lf.cb
3637 list [update; winfo viewable .lf.cb] [winfo manager .lf.cb]
3738 } -result [list 1 labelframe]
3839
39 test labelframe-3.2 "Remove child slave" -body {
40 test labelframe-3.2 "Remove child content" -body {
4041 .lf configure -labelwidget {}
4142 list [update; winfo viewable .lf.cb] [winfo manager .lf.cb]
4243 } -result [list 0 {}]
4344
44 test labelframe-3.3 "Re-add child slave" -body {
45 test labelframe-3.3 "Re-add child content" -body {
4546 .lf configure -labelwidget .lf.cb
4647 list [update; winfo viewable .lf.cb] [winfo manager .lf.cb]
4748 } -result [list 1 labelframe]
4849
49 test labelframe-3.4 "Re-manage child slave" -body {
50 test labelframe-3.4 "Re-manage child content" -body {
5051 pack .lf.cb -side right
5152 list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] [.lf cget -labelwidget]
5253 } -result [list 1 pack {}]
5354
54 test labelframe-3.5 "Re-add child slave" -body {
55 test labelframe-3.5 "Re-add child content" -body {
5556 .lf configure -labelwidget .lf.cb
5657 list [update; winfo viewable .lf.cb] [winfo manager .lf.cb]
5758 } -result [list 1 labelframe]
5859
59 test labelframe-3.6 "Destroy child slave" -body {
60 test labelframe-3.6 "Destroy child content" -body {
6061 destroy .lf.cb
6162 .lf cget -labelwidget
6263 } -result {}
6364
6465 ###
65 # Re-run series labelframe-3.x with nonchild slaves.
66 # Re-run series labelframe-3.x with nonchild content.
6667 #
6768 # @@@ ODDITY, 14 Nov 2005:
6869 # @@@ labelframe-4.1 fails if .cb is a [checkbutton],
6970 # @@@ but seems to succeed if it's some other widget class.
7071 # @@@ I suspect a race condition; unable to track it down ATM.
7172 #
72 # @@@ FOLLOWUP: This *may* have been caused by a bug in ManagerIdleProc
73 # @@@ FOLLOWUP: This *may* have been caused by a bug in ManagerIdleProc
7374 # @@@ (see manager.c r1.11). There's still probably a race condition in here.
7475 #
75 test labelframe-4.1 "Add nonchild slave" -body {
76 test labelframe-4.1 "Add nonchild content" -body {
7677 checkbutton .cb -text "abcde"
7778 .lf configure -labelwidget .cb
7879 update
8081
8182 } -result [list 1 1 labelframe]
8283
83 test labelframe-4.2 "Remove nonchild slave" -body {
84 test labelframe-4.2 "Remove nonchild content" -body {
8485 .lf configure -labelwidget {}
8586 update;
8687 list [winfo ismapped .cb] [winfo viewable .cb] [winfo manager .cb]
8788 } -result [list 0 0 {}]
8889
89 test labelframe-4.3 "Re-add nonchild slave" -body {
90 test labelframe-4.3 "Re-add nonchild content" -body {
9091 .lf configure -labelwidget .cb
9192 list [update; winfo viewable .cb] [winfo manager .cb]
9293 } -result [list 1 labelframe]
9394
94 test labelframe-4.4 "Re-manage nonchild slave" -body {
95 test labelframe-4.4 "Re-manage nonchild content" -body {
9596 pack .cb -side right
9697 list [update; winfo viewable .cb] \
9798 [winfo manager .cb] \
9899 [.lf cget -labelwidget]
99100 } -result [list 1 pack {}]
100101
101 test labelframe-4.5 "Re-add nonchild slave" -body {
102 test labelframe-4.5 "Re-add nonchild content" -body {
102103 .lf configure -labelwidget .cb
103104 list [update; winfo viewable .cb] \
104105 [winfo manager .cb] \
105106 [.lf cget -labelwidget]
106107 } -result [list 1 labelframe .cb]
107108
108 test labelframe-4.6 "Destroy nonchild slave" -body {
109 test labelframe-4.6 "Destroy nonchild content" -body {
109110 destroy .cb
110111 .lf cget -labelwidget
111112 } -result {}
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 test layout-1.1 "Size computations for mixed-orientation layouts" -body {
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 test notebook-1.0 "Setup" -body {
2324 .nb add [toplevel .nb.t]
2425 } -cleanup {
2526 destroy .t.nb
26 } -returnCodes 1 -match glob -result "can't add .nb.t*"
27 } -returnCodes error -match glob -result "can't add .nb.t*"
2728
2829 test notebook-1.4 "Try to select bad tab" -body {
2930 .nb select @6000,6000
30 } -returnCodes 1 -match glob -result "* not found"
31 } -returnCodes error -match glob -result "* not found"
3132
3233 #
3334 # Now add stuff:
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 proc propagate-geometry {} { update idletasks }
4546
4647 test panedwindow-1.8 "Re-forget pane" -body {
4748 .pw forget .pw.f1
48 } -returnCodes 1 -result ".pw.f1 is not managed by .pw"
49 } -returnCodes error -result ".pw.f1 is not managed by .pw"
4950
5051 test panedwindow-1.end "Cleanup" -body {
5152 destroy .pw
109110 #
110111 test panedwindow-3.0 "configure pane" -body {
111112 ttk::panedwindow .pw
112 .pw add [listbox .pw.lb1]
113 .pw add [listbox .pw.lb2]
113 .pw add [listbox .pw.lb1]
114 .pw add [listbox .pw.lb2]
114115 .pw pane 1 -weight 2
115116 .pw pane 1 -weight
116117 } -result 2
117118
118119 test panedwindow-3.1 "configure pane -- errors" -body {
119120 .pw pane 1 -weight -4
120 } -returnCodes 1 -match glob -result "-weight must be nonnegative"
121 } -returnCodes error -match glob -result "-weight must be nonnegative"
121122
122123 test panedwindow-3.2 "add pane -- errors" -body {
123124 .pw add [ttk::label .pw.l] -weight -1
124 } -returnCodes 1 -match glob -result "-weight must be nonnegative"
125 } -returnCodes error -match glob -result "-weight must be nonnegative"
125126
126127
127128 test panedwindow-3.end "cleanup" -body { destroy .pw }
145146
146147 test panedwindow-4.2 "forget forgotten" -body {
147148 .pw forget .pw.l1
148 } -returnCodes 1 -result ".pw.l1 is not managed by .pw"
149 } -returnCodes error -result ".pw.l1 is not managed by .pw"
149150
150151 # checkorder $winlist --
151152 # Ensure that Y coordinates windows in $winlist are strictly increasing.
252253 frame .pw.f2 -width 100 -height 50
253254
254255 list [winfo reqwidth .pw.f1] [winfo reqheight .pw.f1]
255 } -result [list 100 50]
256 } -result [list 100 50]
256257
257258 test paned-propagation-1 "Initial request size" -body {
258259 .pw add .pw.f1
261262 list [winfo reqwidth .pw] [winfo reqheight .pw]
262263 } -result [list 100 105]
263264
264 test paned-propagation-2 "Slave change before map" -body {
265 test paned-propagation-2 "Pane change before map" -body {
265266 .pw.f1 configure -width 200 -height 100
266267 propagate-geometry
267268 list [winfo reqwidth .pw] [winfo reqheight .pw]
273274 list [winfo width .pw] [winfo height .pw] [.pw sashpos 0]
274275 } -result [list 200 155 100]
275276
276 test paned-propagation-4 "Slave change after map, off-axis" -body {
277 test paned-propagation-4 "Pane change after map, off-axis" -body {
277278 .pw.f1 configure -width 100 ;# should be granted
278279 propagate-geometry
279280 list [winfo reqwidth .pw] [winfo reqheight .pw] [.pw sashpos 0]
280281 } -result [list 100 155 100]
281282
282 test paned-propagation-5 "Slave change after map, on-axis" -body {
283 test paned-propagation-5 "Pane change after map, on-axis" -body {
283284 .pw.f1 configure -height 50 ;# should be denied
284285 propagate-geometry
285286 list [winfo reqwidth .pw] [winfo reqheight .pw] [.pw sashpos 0]
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45
7576 trace variable PB w { error "YIPES!" ;# }
7677 .pb step
7778 set PB ;# NOTREACHED
78 } -cleanup { unset PB } -returnCodes 1 -match glob -result "*YIPES!"
79 } -cleanup { unset PB } -returnCodes error -match glob -result "*YIPES!"
7980
8081 test progressbar-end "Cleanup" -body {
8182 destroy .pb
22 #
33
44 package require Tk
5 package require tcltest ; namespace import -force tcltest::*
5 package require tcltest 2.2
6 namespace import -force tcltest::*
67 loadTestedCommands
78
89 test radiobutton-1.1 "Radiobutton check" -body {
0 package require Tk 8.5
1 package require tcltest ; namespace import -force tcltest::*
0 package require Tk
1 package require tcltest 2.2
2 namespace import -force tcltest::*
23 loadTestedCommands
34
45 testConstraint coreScrollbar [expr {[tk windowingsystem] eq "aqua"}]
1718 } -body {
1819 ttk::scrollbar .sb -command "yadda"
1920 list [winfo class .sb] [.sb cget -command]
20 } -result [list TScrollbar yadda] -cleanup {
21 destroy .sb
21 } -result [list TScrollbar yadda] -cleanup {
22 destroy .sb
2223 }
2324
2425 test scrollbar-swapout-2 "... regardless of whether -style ..." \
2728 } -body {
2829 ttk::style layout Vertical.Custom.TScrollbar \
2930 [ttk::style layout Vertical.TScrollbar] ; # See #1833339
30 ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar
31 ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar
3132 list [winfo class .sb] [.sb cget -command] [.sb cget -style]
3233 } -result [list TScrollbar yadda Custom.TScrollbar] -cleanup {
3334 destroy .sb
3637 test scrollbar-swapout-3 "... or -class is specified." -constraints {
3738 coreScrollbar
3839 } -body {
39 ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar
40 ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar
4041 list [winfo class .sb] [.sb cget -command]
4142 } -result [list Custom.TScrollbar yadda] -cleanup {
4243 destroy .sb
7879 ttk::scale .s -variable v
7980 pack .s ; update
8081 .s set 1 ; update
81 } -returnCodes 1 -match glob -result "*"
82 } -returnCodes error -match glob -result "*"
8283
8384 test scale-2.1 "-state option" -setup {
8485 ttk::scale .s
22 #
33
44 package require Tk
5 package require tcltest ; namespace import -force tcltest::*
5 package require tcltest 2.2
6 namespace import -force tcltest::*
67 loadTestedCommands
78
89 test spinbox-1.0 "Spinbox tests -- setup" -body {
147148 set ::spinbox_test
148149 } -cleanup {
149150 destroy .sb
150 } -result {50}
151 } -result 50
151152
152153
153154 test spinbox-2.0 "current command -- unset should be 0" -constraints nyi -setup {
203204 set ::spinbox_test {}
204205 ttk::spinbox .sb -from 0 -to 10 -textvariable SBV
205206 } -body {
206 grid .sb -sticky ew
207207 grid columnconfigure . 0 -weight 1
208 update idletasks
209 set timer [after 500 {set ::spinbox_test timedout}]
208210 bind . <Map> {
209211 after idle {
210212 wm geometry . "210x80"
211 after 100 {set ::spinbox_test [.sb identify element 5 5]}
213 update idletasks
214 set ::spinbox_test [.sb identify element 25 5]
212215 }
213216 bind . <Map> {}
214217 }
215 after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait
218 grid .sb -sticky ew
219 vwait ::spinbox_test
216220 set ::spinbox_test
217221 } -cleanup {
218222 destroy .sb
219223 unset -nocomplain ::spinbox_test SBV
220224 } -result {textarea}
225
226 test spinbox-4.0 "Increment with duplicates in -values, wrap" -setup {
227 ttk::spinbox .sb -values {one two three 4 5 two six} -wrap true
228 set max [expr {[llength [.sb cget -values]] + 2}]
229 } -body {
230 set ::spinbox_test [.sb get]
231 for {set i 0} {$i < $max} {incr i} {
232 event generate .sb <<Increment>>
233 lappend ::spinbox_test [.sb get]
234 }
235 for {set i 0} {$i < $max} {incr i} {
236 event generate .sb <<Decrement>>
237 lappend ::spinbox_test [.sb get]
238 }
239 set ::spinbox_test
240 } -cleanup {
241 destroy .sb
242 unset -nocomplain ::spinbox_test max
243 } -result {one two three 4 5 two six one two one six two 5 4 three two one six}
244
245 test spinbox-4.1 "Increment with duplicates in -values, wrap, initial value set" -setup {
246 ttk::spinbox .sb -values {one two three 4 5 two six} -wrap true
247 set max [expr {[llength [.sb cget -values]] + 2}]
248 } -body {
249 .sb set three
250 set ::spinbox_test [.sb get]
251 for {set i 0} {$i < $max} {incr i} {
252 event generate .sb <<Increment>>
253 lappend ::spinbox_test [.sb get]
254 }
255 .sb set two ; # the first "two" in the -values list becomes the current value
256 for {set i 0} {$i < $max} {incr i} {
257 event generate .sb <<Decrement>>
258 lappend ::spinbox_test [.sb get]
259 }
260 set ::spinbox_test
261 } -cleanup {
262 destroy .sb
263 unset -nocomplain ::spinbox_test max
264 } -result {three 4 5 two six one two three 4 5 one six two 5 4 three two one six}
265
266 test spinbox-4.2 "Increment with duplicates in -values, no wrap" -setup {
267 ttk::spinbox .sb -values {one two three 4 5 two six} -wrap false
268 set max [expr {[llength [.sb cget -values]] + 2}]
269 } -body {
270 set ::spinbox_test [.sb get]
271 for {set i 0} {$i < $max} {incr i} {
272 event generate .sb <<Increment>>
273 lappend ::spinbox_test [.sb get]
274 }
275 for {set i 0} {$i < $max} {incr i} {
276 event generate .sb <<Decrement>>
277 lappend ::spinbox_test [.sb get]
278 }
279 set ::spinbox_test
280 } -cleanup {
281 destroy .sb
282 unset -nocomplain ::spinbox_test max
283 } -result {one two three 4 5 two six six six two 5 4 three two one one one one}
284
221285
222286 # nostomp: NB intentional difference between ttk::spinbox and tk::spinbox;
223287 # see also #1439266
252316
253317 test spinbox-nostomp-4 "don't stomp on -variable (configure; -values)" -body {
254318 set SBV Apr
255 ttk::spinbox .sb
319 ttk::spinbox .sb
256320 .sb configure -textvariable SBV -values {Jan Feb Mar Apr May Jun Jul Aug}
257321 list $SBV [.sb get]
258322 } -cleanup {
277341 event generate .sb <<Decrement>>; lappend result $secs
278342
279343 set result
280 } -result [list 07 08 09 10 11 10 09 08 07] -cleanup {
344 } -result [list 07 08 09 10 11 10 09 08 07] -cleanup {
281345 destroy .sb
282346 unset secs
283347 }
00
11 package require Tk
2 package require tcltest ; namespace import -force tcltest::*
2 package require tcltest 2.2
3 namespace import -force tcltest::*
34 loadTestedCommands
45
56 ### treeview tag invariants:
104105 } -result [list tag1 tag2 tag3]
105106
106107 test treetags-1.9 "tag names - tag added to item" -body {
107 $tv item item1 -tags tag4
108 $tv item item1 -tags tag4
108109 lsort [$tv tag names]
109110 } -result [list tag1 tag2 tag3 tag4]
110111
164165
165166 test treetags-2.4 "Bad events" -body {
166167 $tv tag bind bad <Enter> { puts "Entered!" }
167 } -returnCodes 1 -result "unsupported event <Enter>*" -match glob
168 } -returnCodes error -result "unsupported event <Enter>*" -match glob
168169
169170 test treetags-3.0 "tag configure - set" -body {
170171 $tv tag configure tag1 -foreground blue -background red
200201 set result [list]
201202 $tv tag bind rm1 <<Remove>> { lappend ::result rm1 [%W focus] <<Remove>> }
202203 $tv tag bind rm2 <<Remove>> {
203 lappend ::result rm2 [%W focus] <<Remove>>
204 lappend ::result rm2 [%W focus] <<Remove>>
204205 %W item [%W focus] -tags {tag1}
205206 }
206207 $tv tag bind rm3 <<Remove>> { lappend ::result rm3 [%W focus] <<Remove>> }
207208
208 $tv item item1 -tags {rm1 rm2 rm3}
209 $tv item item1 -tags {rm1 rm2 rm3}
209210 $tv focus item1
210211 event generate $tv <<Remove>>
211212 set result
22 # what it currently does)
33 #
44
5 package require Tk 8.5
6 package require tcltest ; namespace import -force tcltest::*
5 package require Tk
6 package require tcltest 2.2
7 namespace import -force tcltest::*
78 loadTestedCommands
89
910 # consistencyCheck --
4445 test treeview-1.2 "Bad columns" -body {
4546 #.tv configure -columns {illegal "list"value}
4647 ttk::treeview .badtv -columns {illegal "list"value}
47 } -returnCodes 1 -result "list element in quotes followed by*" -match glob
48 } -returnCodes error -result "list element in quotes followed by*" -match glob
4849
4950 test treeview-1.3 "bad displaycolumns" -body {
5051 .tv configure -displaycolumns {a b d}
51 } -returnCodes 1 -result "Invalid column index d"
52 } -returnCodes error -result "Invalid column index d"
5253
5354 test treeview-1.4 "more bad displaycolumns" -body {
5455 .tv configure -displaycolumns {1 2 3}
55 } -returnCodes 1 -result "Column index 3 out of bounds"
56 } -returnCodes error -result "Column index 3 out of bounds"
5657
5758 test treeview-1.5 "Don't forget to check negative numbers" -body {
5859 .tv configure -displaycolumns {1 -2 3}
59 } -returnCodes 1 -result "Column index -2 out of bounds"
60 } -returnCodes error -result "Column index -2 out of bounds"
6061
6162 # Item creation.
6263 #
6364 test treeview-2.1 "insert -- not enough args" -body {
6465 .tv insert
65 } -returnCodes 1 -result "wrong # args: *" -match glob
66 } -returnCodes error -result "wrong # args: *" -match glob
6667
6768 test treeview-2.3 "insert -- bad integer index" -body {
6869 .tv insert {} badindex
69 } -returnCodes 1 -result "expected integer *" -match glob
70 } -returnCodes error -result "expected integer *" -match glob
7071
7172 test treeview-2.4 "insert -- bad parent node" -body {
7273 .tv insert badparent end
73 } -returnCodes 1 -result "Item badparent not found" -match glob
74 } -returnCodes error -result "Item badparent not found" -match glob
7475
7576 test treeview-2.5 "insert -- finaly insert a node" -body {
7677 .tv insert {} end -id newnode -text "New node"
8283
8384 test treeview-2.7 "insert -- prevent duplicate node names" -body {
8485 .tv insert {} end -id newnode
85 } -returnCodes 1 -result "Item newnode already exists"
86 } -returnCodes error -result "Item newnode already exists"
8687
8788 test treeview-2.8 "insert -- new node at end" -body {
8889 .tv insert {} end -id lastnode
124125
125126 test treeview-2.14 "insert -- bad options" -body {
126127 .tv insert {} end -badoption foo
127 } -returnCodes 1 -result {unknown option "-badoption"}
128 } -returnCodes error -result {unknown option "-badoption"}
128129
129130 test treeview-2.15 "insert -- at position 0 w/no children" -body {
130131 .tv insert newnode 0 -id newnode.n2 -text "Foo"
200201 .tv detach [list {}]
201202 update
202203 consistencyCheck .tv
203 } -returnCodes 1 -result "Cannot detach root item"
204 } -returnCodes error -result "Cannot detach root item"
204205 consistencyCheck .tv
205206
206207 test treeview-3.12 "Reattach" -body {
273274
274275 test treeview-5.1 "item -- error checks" -body {
275276 .tv item newnode -text "Bad values" -values "{bad}list"
276 } -returnCodes 1 -result "list element in braces followed by*" -match glob
277 } -returnCodes error -result "list element in braces followed by*" -match glob
277278
278279 test treeview-5.2 "item -- error leaves options unchanged " -body {
279280 .tv item newnode -text
296297
297298 test treeview-5.6 "set illegal cell" -body {
298299 .tv set newnode #0 YYY
299 } -returnCodes 1 -result "Display column #0 cannot be set"
300 } -returnCodes error -result "Display column #0 cannot be set"
300301
301302 test treeview-5.7 "set illegal cell" -body {
302303 .tv set newnode 3 YY ;# 3 == current #columns
303 } -returnCodes 1 -result "Column index 3 out of bounds"
304 } -returnCodes error -result "Column index 3 out of bounds"
304305
305306 test treeview-5.8 "set display columns" -body {
306307 .tv configure -displaycolumns [list 2 1 0]
316317
317318 test treeview-5.10 "cannot set column -id" -body {
318319 .tv column #1 -id X
319 } -returnCodes 1 -result "Attempt to change read-only option"
320 } -returnCodes error -result "Attempt to change read-only option"
320321
321322 test treeview-5.11 "get" -body {
322323 .tv set newnode #1
404405
405406 test treeview-7.2 "illegal move" -body {
406407 .tv move d d2 end
407 } -returnCodes 1 -result "Cannot insert d as descendant of d2"
408 } -returnCodes error -result "Cannot insert d as descendant of d2"
408409
409410 test treeview-7.3 "illegal move has no effect" -body {
410411 consistencyCheck .tv
425426
426427 test treeview-7.6 "Replace children - illegal move" -body {
427428 .tv children newnode.n1 [list newnode.n1 newnode.n2 newnode.n3]
428 } -returnCodes 1 -result "Cannot insert newnode.n1 as descendant of newnode.n1"
429 } -returnCodes error -result "Cannot insert newnode.n1 as descendant of newnode.n1"
429430
430431 consistencyCheck .tv
431432
456457
457458 test treeview-8.5 "Selection - bad operation" -body {
458459 .tv selection badop foo
459 } -returnCodes 1 -match glob -result {bad selection operation "badop": must be *}
460 } -returnCodes error -match glob -result {bad selection operation "badop": must be *}
460461
461462 test treeview-8.6 "Selection - <<TreeviewSelect>> on selection add" -body {
462463 .tv selection set {}
506507 } -cleanup {
507508 destroy .tree
508509 } -result {I006}
510
511 test treeview-9.2 {scrolling on see command - bug [14188104c3]} -setup {
512 toplevel .top
513 ttk::treeview .top.tree -show {} -height 10 -columns {label} \
514 -yscrollcommand [list .top.vs set]
515 ttk::scrollbar .top.vs -command {.top.tree yview}
516 grid .top.tree -row 0 -column 0 -sticky ns
517 grid .top.vs -row 0 -column 1 -sticky ns
518 update
519 proc setrows {n} {
520 .top.tree delete [.top.tree children {}]
521 for {set i 1} {$i <= $n} {incr i} {
522 .top.tree insert {} end -id row$i \
523 -values [list [format "Row %2.2d" $i]]
524 }
525 .top.tree see row1
526 update idletasks
527 }
528 } -body {
529 setrows 10
530 set res [.top.vs get]
531 setrows 20
532 lappend res [expr [lindex [.top.vs get] 1] < 1]
533 } -cleanup {
534 destroy .top
535 } -result {0.0 1.0 1}
536
537 test treeview-9.3 {scrolling on see command, requested item is closed} -setup {
538 toplevel .top
539 ttk::treeview .top.tree -show tree -height 10 -columns {label} \
540 -yscrollcommand [list .top.vs set]
541 ttk::scrollbar .top.vs -command {.top.tree yview}
542 grid .top.tree -row 0 -column 0 -sticky ns
543 grid .top.vs -row 0 -column 1 -sticky ns
544
545 .top.tree insert {} end -id a -text a
546 .top.tree insert a end -id b -text b
547 .top.tree insert b end -id c -text c
548 .top.tree insert c end -id d -text d
549 .top.tree insert d end -id e -text e
550 for {set i 6} {$i <= 15} {incr i} {
551 .top.tree insert {} end -id row$i \
552 -values [list [format "Row %2.2d" $i]]
553 }
554 update
555 } -body {
556 set before [lindex [.top.vs get] 1]
557 .top.tree see e
558 update idletasks
559 set after [lindex [.top.vs get] 1]
560 expr $after < $before
561 } -cleanup {
562 destroy .top
563 } -result {1}
509564
510565 ### identify tests:
511566 #
674729
675730 test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup {
676731 pack [ttk::treeview .tv]
677 .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left"
732 .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left"
678733 update
679734 } -body {
680735 foreach {x y w h} [.tv bbox foo #0] {}
693748
694749 test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup {
695750 pack [ttk::treeview .tv]
696 .tv heading #0 -text "Drag my right edge -->"
751 .tv heading #0 -text "Drag my right edge -->"
697752 update
698753 } -body {
699754 set res [.tv column #0 -width]
763818 update idletasks ; # redisplay treeview
764819 } -body {
765820 # only some columns are displayed (and in a different order than declared
766 # in -columns), a non-displayed column becomes stretchable --> nothing
821 # in -columns), a non-displayed column becomes stretchable --> nothing
767822 # happens
768823 set origTreeWidth [winfo width .tv]
769824 set res [list [.tv column bar -width] [.tv column colA -width]]
00
1 package require Tk 8.5
2 package require tcltest ; namespace import -force tcltest::*
1 package require Tk
2 package require tcltest 2.2
3 namespace import -force tcltest::*
34 loadTestedCommands
45
56 proc skip args {}
3031 trace variable sd w [list selfdestruct .sd]
3132 update
3233 .sd invoke
33 } -returnCodes 1
34 } -returnCodes error
3435 test ttk-6.2 "Checkbutton self-destructed" -body {
3536 winfo exists .sd
3637 } -result 0
144145
145146 test ttk-1.3 "Set bad style" -body {
146147 .t configure -style "nosuchstyle"
147 } -returnCodes 1 -result {Layout nosuchstyle not found}
148 } -returnCodes error -result {Layout nosuchstyle not found}
148149
149150 test ttk-1.4 "Original style preserved" -body {
150151 .t cget -style
206207 set ttk28 {}
207208 pack [ttk::button .b -command {set ::ttk28 failed}]
208209 update
209 } -body {
210 } -body {
210211 bind .b <ButtonPress-1> {after 0 {.b configure -state disabled}}
211212 after 1 {event generate .b <ButtonPress-1>}
212213 after 20 {event generate .b <ButtonRelease-1>}
233234 # misc. error detection
234235 test ttk-3.0 "Bad option" -body {
235236 ttk::button .bad -badoption foo
236 } -returnCodes 1 -result {unknown option "-badoption"} -match glob
237 } -returnCodes error -result {unknown option "-badoption"} -match glob
237238
238239 test ttk-3.1 "Make sure widget command not created" -body {
239240 .bad state disabled
240 } -returnCodes 1 -result {invalid command name ".bad"} -match glob
241 } -returnCodes error -result {invalid command name ".bad"} -match glob
241242
242243 test ttk-3.2 "Propagate errors from variable traces" -body {
243244 set A 0
250251
251252 test ttk-3.3 "Constructor failure with cursor" -body {
252253 ttk::button .b -cursor bottom_right_corner -style BadStyle
253 } -returnCodes 1 -result "Layout BadStyle not found"
254 } -returnCodes error -result "Layout BadStyle not found"
254255
255256 test ttk-3.4 "SF#2009213" -body {
256257 ttk::style configure TScale -sliderrelief {}
386387
387388 test ttk-9.1 "Traces on nonexistant namespaces" -body {
388389 ttk::checkbutton .tcb -variable foo::bar
389 } -returnCodes 1 -result "*parent namespace doesn't exist*" -match glob
390 } -returnCodes error -result "*parent namespace doesn't exist*" -match glob
390391
391392 test ttk-9.2 "Traces on nonexistant namespaces II" -body {
392393 ttk::checkbutton .tcb -variable X
393394 .tcb configure -variable foo::bar
394 } -returnCodes 1 -result "*parent namespace doesn't exist*" -match glob
395 } -returnCodes error -result "*parent namespace doesn't exist*" -match glob
395396
396397 test ttk-9.3 "Restore saved options on configure error" -body {
397398 .tcb cget -variable
456457
457458 test ttk-10.4 "Try to modify class resource" -body {
458459 .f configure -class Bar
459 } -returnCodes 1 -match glob -result "*read-only option*"
460 } -returnCodes error -match glob -result "*read-only option*"
460461
461462 test ttk-10.5 "Check class resource again" -body {
462463 .f cget -class
505506 .b configure -cursor arrow
506507 .b cget -cursor
507508 } -result arrow
509
510 test ttk-12.2.1 "-cursor option, widget doesn't overwrite it" -setup {
511 ttk::treeview .tr
512 pack .tr
513 update
514 } -body {
515 .tr configure -cursor X_cursor
516 event generate .tr <Motion>
517 update
518 .tr cget -cursor
519 } -cleanup {
520 destroy .tr
521 } -result {X_cursor}
508522
509523 test ttk-12.3 "-borderwidth frame option" -body {
510524 destroy .t
533547
534548 test ttk-13.1 "Custom styles -- bad -style option" -body {
535549 ttk::button .tb1 -style badstyle
536 } -returnCodes 1 -result "*badstyle not found*" -match glob
550 } -returnCodes error -result "*badstyle not found*" -match glob
537551
538552 test ttk-13.4 "Custom styles -- bad -style option" -body {
539553 ttk::button .tb1
540554 .tb1 configure -style badstyle
541555 } -cleanup {
542556 destroy .tb1
543 } -returnCodes 1 -result "*badstyle not found*" -match glob
557 } -returnCodes error -result "*badstyle not found*" -match glob
544558
545559 test ttk-13.5 "Custom layouts -- missing element definition" -body {
546560 ttk::style layout badstyle {
558572
559573 test ttk-14.1 "-variable in nonexistant namespace" -body {
560574 ttk::checkbutton .tw -variable ::nsn::foo
561 } -returnCodes 1 -result {can't trace *: parent namespace doesn't exist} \
575 } -returnCodes error -result {can't trace *: parent namespace doesn't exist} \
562576 -match glob -cleanup { destroy .tw }
563577
564578 test ttk-14.2 "-textvariable in nonexistant namespace" -body {
565579 ttk::label .tw -textvariable ::nsn::foo
566 } -returnCodes 1 -result {can't trace *: parent namespace doesn't exist} \
580 } -returnCodes error -result {can't trace *: parent namespace doesn't exist} \
567581 -match glob -cleanup { destroy .tw }
568582
569583 test ttk-14.3 "-textvariable in nonexistant namespace" -body {
570584 ttk::entry .tw -textvariable ::nsn::foo
571 } -returnCodes 1 -result {can't trace *: parent namespace doesn't exist} \
585 } -returnCodes error -result {can't trace *: parent namespace doesn't exist} \
572586 -match glob -cleanup { destroy .tw }
573587
574588 test ttk-15.1 {Bug 3062331} -setup {
614628
615629 test ttk-ensemble-0 "style element create: insufficient args" -body {
616630 ttk::style
617 } -returnCodes 1 -result \
631 } -returnCodes error -result \
618632 [wrong#varargs arg ttk::style option]
619633
620634 test ttk-ensemble-1 "style element create: insufficient args" -body {
621635 ttk::style element
622 } -returnCodes 1 -result \
636 } -returnCodes error -result \
623637 [wrong#varargs arg ttk::style element option]
624638
625639 test ttk-ensemble-2 "style element create: insufficient args" -body {
626640 ttk::style element create
627 } -returnCodes 1 -result \
641 } -returnCodes error -result \
628642 [wrong#varargs {-option value} ttk::style element create name type]
629643
630644 test ttk-ensemble-3 "style element create: insufficient args" -body {
631645 ttk::style element create plain.background
632 } -returnCodes 1 -result \
646 } -returnCodes error -result \
633647 [wrong#varargs {-option value} ttk::style element create name type]
634648
635649 test ttk-ensemble-4 "style element create: insufficient args" -body {
636650 ttk::style element create plain.background from
637 } -returnCodes 1 -result [wrong#args theme ?element?]
651 } -returnCodes error -result [wrong#args theme ?element?]
638652
639653 test ttk-ensemble-5 "style element create: valid" -body {
640654 ttk::style element create plain.background from default
22 ## Derived from core test suite entry-19.1 through entry-19.20
33 ##
44
5 package require Tk 8.5
6 package require tcltest 2.1
5 package require Tk
6 package require tcltest 2.2
77 namespace import -force tcltest::*
88
99 loadTestedCommands
160160 list [.e cget -validate] $::vVals
161161 } -result {none {.e -1 -1 nextdata newdata {} all forced}}
162162 # DIFFERENCE: ttk::entry doesn't validate when setting linked -variable
163 # DIFFERENCE: ttk::entry doesn't disable validation
163 # DIFFERENCE: ttk::entry doesn't disable validation
164164
165165 proc doval {W d i P s S v V} {
166166 set ::vVals [list $W $d $i $P $s $S $v $V]
00 # -*- tcl -*-
11 #
22
3 package require Tk 8.5
4 package require tcltest ; namespace import -force tcltest::*
3 package require Tk
4 package require tcltest 2.2
5 namespace import -force tcltest::*
56 loadTestedCommands
67
78 testConstraint xpnative \
8 [expr {[lsearch -exact [ttk::style theme names] xpnative] != -1}]
9 [expr {"xpnative" in [ttk::style theme names]}]
910
1011 test vsapi-1.1 "WINDOW WP_SMALLCLOSEBUTTON" -constraints {xpnative} -body {
1112 ttk::style element create smallclose vsapi \
1515
1616 # Create entries in the option database to be sure that geometry options
1717 # like border width have predictable values.
18
18
1919 option add *Label.borderWidth 2
2020 option add *Label.highlightThickness 0
2121 option add *Label.font {Helvetica -12 bold}
6969 [expr {72 + $bigIndicator}] 52 \
7070 [expr {72 + $bigIndicator}] 52]
7171 test unixbutton-1.2 {TkpComputeButtonGeometry procedure} -constraints {
72 unix
72 unix
7373 } -setup {
7474 deleteWindows
7575 } -body {
9090 [expr {27 + $smallIndicator}] 37 \
9191 [expr {27 + $smallIndicator}] 37]
9292 test unixbutton-1.3 {TkpComputeButtonGeometry procedure} -constraints {
93 unix
93 unix
9494 } -setup {
9595 deleteWindows
9696 } -body {
191191 deleteWindows
192192 } -result {62 30 56 24 58 22 62 22}
193193 test unixbutton-1.9 {TkpComputeButtonGeometry procedure} -constraints {
194 unix
194 unix
195195 } -setup {
196196 deleteWindows
197197 } -body {
199199 list [winfo reqwidth .b2] [winfo reqheight .b2]
200200 } -cleanup {
201201 deleteWindows
202 } -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
202 } -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
203203 test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints {
204 unix
204 unix
205205 } -setup {
206206 deleteWindows
207207 } -body {
211211 deleteWindows
212212 } -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
213213 test unixbutton-1.11 {TkpComputeButtonGeometry procedure} -constraints {
214 unix
214 unix
215215 } -setup {
216216 deleteWindows
217217 } -body {
223223
224224
225225 test unixbutton-2.1 {disabled coloring check, bug 669595} -constraints {
226 unix
226 unix
227227 } -setup {
228228 deleteWindows
229229 catch {unset value}
1010 tcltest::loadTestedCommands
1111 namespace import -force tcltest::test
1212
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
15
1316 namespace eval ::_test_tmp {}
1417
1518 # ------------------------------------------------------------------------------
1619 # Proc ::_test_tmp::testInterp
1720 # ------------------------------------------------------------------------------
18 # Command that creates an unsafe child interpreter and tries to load Tk.
21 # Command that creates an child interpreter and tries to load Tk.
1922 # This code is borrowed from safePrimarySelection.test
2023 # This is necessary for loading Tktest if the tests are done in the build
2124 # directory without installing Tk. In that case the usual auto_path loading
149152 unix testembed
150153 } -setup {
151154 deleteWindows
152 catch {interp delete slave}
153 ::_test_tmp::testInterp slave
154 load {} Tktest slave
155 catch {interp delete child}
156 ::_test_tmp::testInterp child
157 load {} Tktest child
155158 } -body {
156159 frame .f1 -container 1 -width 200 -height 50
157160 frame .f2 -container 1 -width 200 -height 50
158161 pack .f1 .f2
159 slave alias w winfo id .f1
160 slave eval {
162 child alias w winfo id .f1
163 child eval {
161164 destroy [winfo child .]
162165 toplevel .t -use [w]
163166 list [testembed] [expr {[lindex [lindex [testembed all] 0] 0] - [w]}]
164167 }
165168 } -cleanup {
166 interp delete slave
169 interp delete child
167170 deleteWindows
168171 } -result {{{XXX {} {} .t}} 0}
169172 test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constraints {
189192 unix testembed
190193 } -setup {
191194 deleteWindows
192 catch {interp delete slave}
193 ::_test_tmp::testInterp slave
194 load {} Tktest slave
195 catch {interp delete child}
196 ::_test_tmp::testInterp child
197 load {} Tktest child
195198 } -body {
196199 frame .f1 -container 1 -width 200 -height 50
197200 frame .f2 -container 1 -width 200 -height 50
198201 pack .f1 .f2
199 slave alias w1 winfo id .f1
200 slave alias w2 winfo id .f2
201 slave eval {
202 child alias w1 winfo id .f1
203 child alias w2 winfo id .f2
204 child eval {
202205 destroy [winfo child .]
203206 toplevel .t1 -use [w1]
204207 toplevel .t2 -use [w2]
205208 testembed
206209 }
207210 } -cleanup {
208 interp delete slave
211 interp delete child
209212 deleteWindows
210213 } -result {{XXX {} {} .t2} {XXX {} {} .t1}}
211214 test unixEmbed-1.7 {TkpUseWindow procedure, container and embedded in same app} -constraints {
252255 unix testembed
253256 } -setup {
254257 deleteWindows
255 catch {interp delete slave}
256 ::_test_tmp::testInterp slave
257 load {} Tktest slave
258 } -body {
259 frame .f1 -container 1 -width 200 -height 50
260 pack .f1
261 slave alias w1 winfo id .f1
262 slave eval {
258 catch {interp delete child}
259 ::_test_tmp::testInterp child
260 load {} Tktest child
261 } -body {
262 frame .f1 -container 1 -width 200 -height 50
263 pack .f1
264 child alias w1 winfo id .f1
265 child eval {
263266 destroy [winfo child .]
264267 toplevel .t1 -use [w1]
265268 testembed
266269 }
267270 destroy .f1
268271 update
269 slave eval {
272 child eval {
270273 testembed
271274 }
272275 } -cleanup {
294297 unix testembed
295298 } -setup {
296299 deleteWindows
297 catch {interp delete slave}
298 ::_test_tmp::testInterp slave
299 load {} Tktest slave
300 } -body {
301 frame .f1 -container 1 -width 200 -height 50
302 pack .f1
303 slave alias w1 winfo id .f1
304 slave eval {
300 catch {interp delete child}
301 ::_test_tmp::testInterp child
302 load {} Tktest child
303 } -body {
304 frame .f1 -container 1 -width 200 -height 50
305 pack .f1
306 child alias w1 winfo id .f1
307 child eval {
305308 destroy [winfo child .]
306309 toplevel .t1 -use [w1]
307310 testembed
309312 testembed
310313 }
311314 } -cleanup {
312 interp delete slave
315 interp delete child
313316 deleteWindows
314317 } -result {}
315318 test unixEmbed-2.3 {EmbeddedEventProc procedure} -constraints {
360363 test unixEmbed-3.1a {ContainerEventProc procedure, detect creation} -constraints {
361364 unix testembed
362365 } -setup {
363 catch {interp delete slave}
364 ::_test_tmp::testInterp slave
365 load {} Tktest slave
366 } -body {
367 frame .f1 -container 1 -width 200 -height 50
368 pack .f1
369 slave alias w1 winfo id .f1
366 catch {interp delete child}
367 ::_test_tmp::testInterp child
368 load {} Tktest child
369 } -body {
370 frame .f1 -container 1 -width 200 -height 50
371 pack .f1
372 child alias w1 winfo id .f1
370373 set x [testembed]
371 slave eval {
374 child eval {
372375 destroy [winfo child .]
373376 toplevel .t1 -use [w1]
374377 wm withdraw .t1
375378 }
376379 list $x [testembed]
377380 } -cleanup {
378 interp delete slave
381 interp delete child
379382 deleteWindows
380383 } -result {{{XXX .f1 {} {}}} {{XXX .f1 {} {}}}}
381384 test unixEmbed-3.2 {ContainerEventProc procedure, set size on creation} -constraints {
417420 unix
418421 } -setup {
419422 deleteWindows
420 catch {interp delete slave}
421 ::_test_tmp::testInterp slave
422 load {} Tktest slave
423 } -body {
424 frame .f1 -container 1 -width 200 -height 50
425 pack .f1
426 slave alias w1 winfo id .f1
427 slave eval {
423 catch {interp delete child}
424 ::_test_tmp::testInterp child
425 load {} Tktest child
426 } -body {
427 frame .f1 -container 1 -width 200 -height 50
428 pack .f1
429 child alias w1 winfo id .f1
430 child eval {
428431 destroy [winfo child .]
429432 toplevel .t1 -use [w1] -bd 2 -relief raised
430433 update
433436 wm geometry .t1
434437 }
435438 } -cleanup {
436 interp delete slave
439 interp delete child
437440 deleteWindows
438441 } -result {200x200+0+0}
439442 test unixEmbed-3.4 {ContainerEventProc procedure, disallow position changes} -constraints {
461464 unix
462465 } -setup {
463466 deleteWindows
464 catch {interp delete slave}
465 ::_test_tmp::testInterp slave
466 load {} Tktest slave
467 } -body {
468 frame .f1 -container 1 -width 200 -height 50
469 pack .f1
470 slave alias w1 winfo id .f1
471 slave eval {
467 catch {interp delete child}
468 ::_test_tmp::testInterp child
469 load {} Tktest child
470 } -body {
471 frame .f1 -container 1 -width 200 -height 50
472 pack .f1
473 child alias w1 winfo id .f1
474 child eval {
472475 destroy [winfo child .]
473476 toplevel .t1 -use [w1]
474477 update
477480 wm geometry .t1
478481 }
479482 } -cleanup {
480 interp delete slave
483 interp delete child
481484 deleteWindows
482485 } -result {300x100+0+0}
483486 test unixEmbed-3.5 {ContainerEventProc procedure, geometry requests} -constraints {
505508 unix
506509 } -setup {
507510 deleteWindows
508 catch {interp delete slave}
509 ::_test_tmp::testInterp slave
510 load {} Tktest slave
511 } -body {
512 frame .f1 -container 1 -width 200 -height 50
513 pack .f1
514 slave alias w1 winfo id .f1
515 slave eval {
511 catch {interp delete child}
512 ::_test_tmp::testInterp child
513 load {} Tktest child
514 } -body {
515 frame .f1 -container 1 -width 200 -height 50
516 pack .f1
517 child alias w1 winfo id .f1
518 child eval {
516519 destroy [winfo child .]
517520 toplevel .t1 -use [w1]
518521 .t1 configure -width 300 -height 80
519522 update
520523 }
521 list [winfo width .f1] [winfo height .f1] [slave eval {wm geometry .t1}]
522 } -cleanup {
523 interp delete slave
524 list [winfo width .f1] [winfo height .f1] [child eval {wm geometry .t1}]
525 } -cleanup {
526 interp delete child
524527 deleteWindows
525528 } -result {300 80 300x80+0+0}
526529 test unixEmbed-3.6 {ContainerEventProc procedure, map requests} -constraints {
550553 unix
551554 } -setup {
552555 deleteWindows
553 catch {interp delete slave}
554 ::_test_tmp::testInterp slave
555 load {} Tktest slave
556 } -body {
557 frame .f1 -container 1 -width 200 -height 50
558 pack .f1
559 slave alias w1 winfo id .f1
560 slave eval {
556 catch {interp delete child}
557 ::_test_tmp::testInterp child
558 load {} Tktest child
559 } -body {
560 frame .f1 -container 1 -width 200 -height 50
561 pack .f1
562 child alias w1 winfo id .f1
563 child eval {
561564 destroy [winfo child .]
562565 toplevel .t1 -use [w1]
563566 set x unmapped
568571 set x
569572 }
570573 } -cleanup {
571 interp delete slave
574 interp delete child
572575 deleteWindows
573576 } -result {mapped}
574577 test unixEmbed-3.7 {ContainerEventProc procedure, destroy events} -constraints {
598601 unix
599602 } -setup {
600603 deleteWindows
601 catch {interp delete slave}
602 ::_test_tmp::testInterp slave
603 load {} Tktest slave
604 } -body {
605 frame .f1 -container 1 -width 200 -height 50
606 pack .f1
607 slave alias w1 winfo id .f1
604 catch {interp delete child}
605 ::_test_tmp::testInterp child
606 load {} Tktest child
607 } -body {
608 frame .f1 -container 1 -width 200 -height 50
609 pack .f1
610 child alias w1 winfo id .f1
608611 bind .f1 <Destroy> {set x dead}
609612 set x alive
610 slave eval {
613 child eval {
611614 destroy [winfo child .]
612615 toplevel .t1 -use [w1]
613616 update
616619 update
617620 list $x [winfo exists .f1]
618621 } -cleanup {
619 interp delete slave
622 interp delete child
620623 deleteWindows
621624 } -result {dead 0}
622625
647650 unix
648651 } -setup {
649652 deleteWindows
650 catch {interp delete slave}
651 ::_test_tmp::testInterp slave
652 load {} Tktest slave
653 } -body {
654 frame .f1 -container 1 -width 200 -height 50
655 pack .f1
656 slave alias w1 winfo id .f1
657 slave eval {
653 catch {interp delete child}
654 ::_test_tmp::testInterp child
655 load {} Tktest child
656 } -body {
657 frame .f1 -container 1 -width 200 -height 50
658 pack .f1
659 child alias w1 winfo id .f1
660 child eval {
658661 destroy [winfo child .]
659662 toplevel .t1 -use [w1]
660663 update
663666 winfo geometry .t1
664667 }
665668 } -cleanup {
666 interp delete slave
669 interp delete child
667670 deleteWindows
668671 } -result {180x100+0+0}
669672 test unixEmbed-4.2 {EmbedStructureProc procedure, destroy events} -constraints {
690693 unix testembed
691694 } -setup {
692695 deleteWindows
693 catch {interp delete slave}
694 ::_test_tmp::testInterp slave
695 load {} Tktest slave
696 } -body {
697 frame .f1 -container 1 -width 200 -height 50
698 pack .f1
699 update
700 slave alias w1 winfo id .f1
701 slave eval {
696 catch {interp delete child}
697 ::_test_tmp::testInterp child
698 load {} Tktest child
699 } -body {
700 frame .f1 -container 1 -width 200 -height 50
701 pack .f1
702 update
703 child alias w1 winfo id .f1
704 child eval {
702705 destroy [winfo child .]
703706 toplevel .t1 -use [w1]
704707 }
706709 destroy .f1
707710 list $x [testembed]
708711 } -cleanup {
709 interp delete slave
712 interp delete child
710713 deleteWindows
711714 } -result "{{XXX .f1 {} {}}} {}"
712715
736739 unix
737740 } -setup {
738741 deleteWindows
739 catch {interp delete slave}
740 ::_test_tmp::testInterp slave
741 load {} Tktest slave
742 } -body {
743 frame .f1 -container 1 -width 200 -height 50
744 pack .f1
745 slave alias w1 winfo id .f1
746 slave eval {
742 catch {interp delete child}
743 ::_test_tmp::testInterp child
744 load {} Tktest child
745 } -body {
746 frame .f1 -container 1 -width 200 -height 50
747 pack .f1
748 child alias w1 winfo id .f1
749 child eval {
747750 destroy [winfo child .]
748751 toplevel .t1 -use [w1]
749752 bind .t1 <FocusIn> {lappend x "focus in %W"}
753756 }
754757 focus -force .f1
755758 update
756 slave eval {set x}
757 } -cleanup {
758 interp delete slave
759 child eval {set x}
760 } -cleanup {
761 interp delete child
759762 deleteWindows
760763 } -result {{focus in .t1}}
761764 test unixEmbed-5.2 {EmbedFocusProc procedure, focusing on dead window} -constraints {
784787 unix
785788 } -setup {
786789 deleteWindows
787 catch {interp delete slave}
788 ::_test_tmp::testInterp slave
789 load {} Tktest slave
790 } -body {
791 frame .f1 -container 1 -width 200 -height 50
792 pack .f1
793 slave alias w1 winfo id .f1
794 slave eval {
790 catch {interp delete child}
791 ::_test_tmp::testInterp child
792 load {} Tktest child
793 } -body {
794 frame .f1 -container 1 -width 200 -height 50
795 pack .f1
796 child alias w1 winfo id .f1
797 child eval {
795798 destroy [winfo child .]
796799 toplevel .t1 -use [w1]
797800 update
801804 focus -force .f1
802805 update
803806 } -cleanup {
804 interp delete slave
807 interp delete child
805808 deleteWindows
806809 } -result {}
807810 test unixEmbed-5.3 {EmbedFocusProc procedure, FocusOut events} -constraints {
832835 unix
833836 } -setup {
834837 deleteWindows
835 catch {interp delete slave}
836 ::_test_tmp::testInterp slave
837 load {} Tktest slave
838 } -body {
839 frame .f1 -container 1 -width 200 -height 50
840 pack .f1
841 slave alias w1 winfo id .f1
842 slave eval {
838 catch {interp delete child}
839 ::_test_tmp::testInterp child
840 load {} Tktest child
841 } -body {
842 frame .f1 -container 1 -width 200 -height 50
843 pack .f1
844 child alias w1 winfo id .f1
845 child eval {
843846 destroy [winfo child .]
844847 toplevel .t1 -use [w1]
845848 set x {}
849852 }
850853 focus -force .f1
851854 update
852 set x [slave eval {update; set x }]
855 set x [child eval {update; set x }]
853856 focus .
854857 update
855 list $x [slave eval {update; set x}]
856 } -cleanup {
857 interp delete slave
858 list $x [child eval {update; set x}]
859 } -cleanup {
860 interp delete child
858861 deleteWindows
859862 } -result {{{focus in .t1}} {{focus in .t1} {focus out .t1}}}
860863
884887 unix
885888 } -setup {
886889 deleteWindows
887 catch {interp delete slave}
888 ::_test_tmp::testInterp slave
889 load {} Tktest slave
890 } -body {
891 frame .f1 -container 1 -width 200 -height 50
892 pack .f1
893 slave alias w1 winfo id .f1
894 slave eval {
890 catch {interp delete child}
891 ::_test_tmp::testInterp child
892 load {} Tktest child
893 } -body {
894 frame .f1 -container 1 -width 200 -height 50
895 pack .f1
896 child alias w1 winfo id .f1
897 child eval {
895898 destroy [winfo child .]
896899 toplevel .t1 -use [w1]
897900 update
902905 list $x [winfo geom .t1]
903906 }
904907 } -cleanup {
905 interp delete slave
908 interp delete child
906909 deleteWindows
907910 } -result {{configure .t1 300 120} 300x120+0+0}
908911 test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constraints {
930933 unix
931934 } -setup {
932935 deleteWindows
933 catch {interp delete slave}
934 ::_test_tmp::testInterp slave
935 load {} Tktest slave
936 catch {interp delete child}
937 ::_test_tmp::testInterp child
938 load {} Tktest child
936939 } -body {
937940 frame .f1 -container 1 -width 200 -height 50
938941 place .f1 -width 200 -height 200
939942 update
940 slave alias w1 winfo id .f1
941 slave eval {
943 child alias w1 winfo id .f1
944 child eval {
942945 destroy [winfo child .]
943946 toplevel .t1 -use [w1]
944947 update
949952 list $x [winfo geom .t1]
950953 }
951954 } -cleanup {
952 interp delete slave
955 interp delete child
953956 deleteWindows
954957 } -result {{configure .t1 200 200} 200x200+0+0}
955958
987990 # TkpRedirectKeyEvent is not implemented in win or aqua. If someone
988991 # implements it they should change the constraints for this test.
989992 test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constraints {
990 unix notAqua
991 } -setup {
992 deleteWindows
993 catch {interp delete slave}
994 ::_test_tmp::testInterp slave
995 load {} Tktest slave
996 } -body {
997 deleteWindows
998 frame .f1 -container 1 -width 200 -height 50
999 pack .f1
1000 slave alias w1 winfo id .f1
1001 slave eval {
993 unix notAqua failsOnXQuarz
994 } -setup {
995 deleteWindows
996 catch {interp delete child}
997 ::_test_tmp::testInterp child
998 load {} Tktest child
999 } -body {
1000 deleteWindows
1001 frame .f1 -container 1 -width 200 -height 50
1002 pack .f1
1003 child alias w1 winfo id .f1
1004 child eval {
10021005 destroy [winfo child .]
10031006 toplevel .t1 -use [w1]
10041007 }
10051008 focus -force .
10061009 bind . <KeyPress> {lappend x {key %A %E}}
10071010 set x {}
1008 set y [slave eval {
1011 set y [child eval {
10091012 update
10101013 bind .t1 <KeyPress> {lappend y {key %A}}
10111014 set y {}
10151018 update
10161019 list $x $y
10171020 } -cleanup {
1018 interp delete slave
1021 interp delete child
10191022 deleteWindows
10201023 bind . <KeyPress> {}
10211024 } -result {{{key a 1}} {}}
10531056 unix
10541057 } -setup {
10551058 deleteWindows
1056 catch {interp delete slave}
1057 ::_test_tmp::testInterp slave
1058 load {} Tktest slave
1059 } -body {
1060 frame .f1 -container 1 -width 200 -height 50
1061 pack .f1
1062 slave alias w1 winfo id .f1
1063 slave eval {
1059 catch {interp delete child}
1060 ::_test_tmp::testInterp child
1061 load {} Tktest child
1062 } -body {
1063 frame .f1 -container 1 -width 200 -height 50
1064 pack .f1
1065 child alias w1 winfo id .f1
1066 child eval {
10641067 destroy [winfo child .]
10651068 toplevel .t1 -use [w1]
10661069 }
10691072 update
10701073 bind . <KeyPress> {lappend x {key %A}}
10711074 set x {}
1072 set y [slave eval {
1075 set y [child eval {
10731076 update
10741077 bind .t1 <KeyPress> {lappend y {key %A}}
10751078 set y {}
10791082 update
10801083 list $x $y
10811084 } -cleanup {
1082 interp delete slave
1085 interp delete child
10831086 deleteWindows
10841087 bind . <KeyPress> {}
10851088 } -result {{} {{key b}}}
10861089
10871090 test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints {
1088 unix notAqua
1091 unix notAqua failsOnUbuntu failsOnXQuarz
10891092 } -setup {
10901093 deleteWindows
10911094 } -body {
11121115 } -result {{{} .t1} .f1}
11131116 test unixEmbed-8.1a {TkpClaimFocus procedure} -constraints unix -setup {
11141117 deleteWindows
1115 catch {interp delete slave}
1116 ::_test_tmp::testInterp slave
1117 load {} Tktest slave
1118 catch {interp delete child}
1119 ::_test_tmp::testInterp child
1120 load {} Tktest child
11181121 } -body {
11191122 frame .f1 -container 1 -width 200 -height 50
11201123 frame .f2 -width 200 -height 50
11211124 pack .f1 .f2
11221125 update
1123 slave alias w1 winfo id .f1
1124 slave eval {
1126 child alias w1 winfo id .f1
1127 child eval {
11251128 destroy [winfo child .]
11261129 toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken
11271130 }
11281131 # This should clear focus from the application embedded in .f1
11291132 focus -force .f2
11301133 update
1131 list [slave eval {
1134 list [child eval {
11321135 set x [list [focus]]
11331136 focus .t1
11341137 update
11351138 lappend x [focus]
11361139 }] [focus]
11371140 } -cleanup {
1138 interp delete slave
1141 interp delete child
11391142 deleteWindows
11401143 } -result {{{} .t1} .f1}
11411144 test unixEmbed-8.2 {TkpClaimFocus procedure} -constraints unix -setup {
11871190 deleteWindows
11881191 } -result {{{XXX .f4 {} {}} {XXX .f3 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f4 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}}} {}}
11891192 test unixEmbed-9.2 {EmbedWindowDeleted procedure, check embeddedPtr} -constraints {
1190 unix testembed notAqua
1191 } -setup {
1192 deleteWindows
1193 unix testembed notAqua
1194 } -setup {
1195 deleteWindows
11931196 } -body {
11941197 frame .f1 -container 1 -width 200 -height 50
11951198 pack .f1
12101213 unix testembed
12111214 } -setup {
12121215 deleteWindows
1213 catch {interp delete slave}
1214 ::_test_tmp::testInterp slave
1215 load {} Tktest slave
1216 } -body {
1217 frame .f1 -container 1 -width 200 -height 50
1218 pack .f1
1219 slave alias w1 winfo id .f1
1220 slave eval {
1216 catch {interp delete child}
1217 ::_test_tmp::testInterp child
1218 load {} Tktest child
1219 } -body {
1220 frame .f1 -container 1 -width 200 -height 50
1221 pack .f1
1222 child alias w1 winfo id .f1
1223 child eval {
12211224 destroy [winfo child .]
12221225 toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken
12231226 set x {}
12261229 lappend x [testembed]
12271230 }
12281231 } -cleanup {
1229 interp delete slave
1232 interp delete child
12301233 deleteWindows
12311234 } -result {{{XXX {} {} .t1}} {}}
12321235
12331236
12341237 test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -constraints {
1235 unix
1236 } -setup {
1237 deleteWindows
1238 } -body {
1239 frame .f1 -container 1 -width 200 -height 50
1240 update
1241 pack .f1
1242 update
1238 unix failsOnUbuntu failsOnXQuarz
1239 } -setup {
1240 deleteWindows
1241 } -body {
1242 frame .f1 -container 1 -width 200 -height 50
1243 pack .f1
1244 update idletasks
12431245 toplevel .t1 -use [winfo id .f1] -width 150 -height 80
1244 update
1246 update idletasks
12451247 wm geometry .t1 +40+50
1246 update
1248 update idletasks
12471249 wm geometry .t1
12481250 } -cleanup {
12491251 deleteWindows
12501252 } -result {150x80+0+0}
12511253 test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -constraints {
1252 unix
1253 } -setup {
1254 deleteWindows
1255 } -body {
1256 frame .f1 -container 1 -width 200 -height 50
1257 pack .f1
1254 unix failsOnUbuntu failsOnXQuarz
1255 } -setup {
1256 deleteWindows
1257 } -body {
1258 frame .f1 -container 1 -width 200 -height 50
1259 pack .f1
1260 update idletasks
12581261 toplevel .t1 -use [winfo id .f1] -width 150 -height 80
1259 update
1262 update idletasks
12601263 wm geometry .t1 70x300+10+20
1261 update
1264 update idletasks
12621265 wm geometry .t1
12631266 } -cleanup {
12641267 deleteWindows
12651268 } -result {70x300+0+0}
12661269
12671270 test unixEmbed-11.1 {focus -force works for embedded toplevels} -constraints {
1268 unix
1269 } -setup {
1270 deleteWindows
1271 unix
1272 } -setup {
1273 deleteWindows
12711274 } -body {
12721275 toplevel .t
12731276 pack [frame .t.f -container 1 -width 200 -height 200] -fill both
12811284 deleteWindows
12821285 } -result .embed
12831286 test unixEmbed-11.2 {mouse coordinates in embedded toplevels} -constraints {
1284 unix pressbutton
1285 } -setup {
1286 deleteWindows
1287 unix pressbutton
1288 } -setup {
1289 deleteWindows
12871290 } -body {
12881291 toplevel .main
12891292 set result {}
1111 # Copyright (c) 1998-1999 by Scriptics Corporation.
1212 # All rights reserved.
1313
14 package require tcltest 2.1
14 package require tcltest 2.2
1515 eval tcltest::configure $argv
1616 tcltest::loadTestedCommands
17
18 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
19 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
20 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1721
1822 if {[tk windowingsystem] eq "x11"} {
1923 set xlsf [auto_execok xlsfonts]
6872 test unixfont-1.1 {TkpGetNativeFont procedure: not native} {x11 noExceed} {
6973 list [catch {font measure {} xyz} msg] $msg
7074 } {1 {font "" doesn't exist}}
71 test unixfont-1.2 {TkpGetNativeFont procedure: native} x11 {
75 test unixfont-1.2 {TkpGetNativeFont procedure: native} {x11 failsOnUbuntu} {
7276 font measure fixed 0
7377 } {6}
7478
7781 set x {}
7882 } {}
7983 test unixfont-2.2 {TkpGetFontFromAttributes procedure: Times relatives} \
80 {x11 noExceed hasTimesNew} {
84 {x11 noExceed hasTimesNew failsOnUbuntu} {
8185 set x {}
8286 lappend x [lindex [font actual {-family "Times New Roman"}] 1]
8387 lappend x [lindex [font actual {-family "New York"}] 1]
8488 lappend x [lindex [font actual {-family "Times"}] 1]
8589 } {times times times}
8690 test unixfont-2.3 {TkpGetFontFromAttributes procedure: Courier relatives} \
87 {x11 noExceed hasCourierNew} {
91 {x11 noExceed hasCourierNew failsOnUbuntu} {
8892 set x {}
8993 lappend x [lindex [font actual {-family "Courier New"}] 1]
9094 lappend x [lindex [font actual {-family "Monaco"}] 1]
9195 lappend x [lindex [font actual {-family "Courier"}] 1]
9296 } {courier courier courier}
9397 test unixfont-2.4 {TkpGetFontFromAttributes procedure: Helvetica relatives} \
94 {x11 noExceed hasArial} {
98 {x11 noExceed hasArial failsOnUbuntu} {
9599 set x {}
96100 lappend x [lindex [font actual {-family "Arial"}] 1]
97101 lappend x [lindex [font actual {-family "Geneva"}] 1]
101105 font actual {-xyz-xyz-*-*-*-*-*-*-*-*-*-*-*-*}
102106 set x {}
103107 } {}
104 test unixfont-2.6 {TkpGetFontFromAttributes: fallback to fixed family} x11 {
108 test unixfont-2.6 {TkpGetFontFromAttributes: fallback to fixed family} {x11 failsOnUbuntu} {
105109 lindex [font actual {-family fixed -size 10}] 1
106110 } {fixed}
107111 test unixfont-2.7 {TkpGetFontFromAttributes: fixed family not available!} x11 {
108112 # no test available
109113 } {}
110 test unixfont-2.8 {TkpGetFontFromAttributes: loop over returned font names} x11 {
114 test unixfont-2.8 {TkpGetFontFromAttributes: loop over returned font names} {x11 failsOnUbuntu} {
111115 lindex [font actual {-family fixed -size 31}] 1
112116 } {fixed}
113 test unixfont-2.9 {TkpGetFontFromAttributes: reject adobe courier if possible} {x11 noExceed} {
117 test unixfont-2.9 {TkpGetFontFromAttributes: reject adobe courier if possible} {x11 noExceed failsOnUbuntu} {
114118 lindex [font actual {-family courier}] 1
115119 } {courier}
116 test unixfont-2.10 {TkpGetFontFromAttributes: scalable font found} x11 {
120 test unixfont-2.10 {TkpGetFontFromAttributes: scalable font found} {x11 failsOnUbuntuNoXft} {
117121 lindex [font actual {-family courier -size 37}] 3
118122 } {37}
119123 test unixfont-2.11 {TkpGetFontFromAttributes: font cannot be loaded} x11 {
165169 .b.l config -text "000000 00000"
166170 getsize
167171 } "[expr $ax*6] [expr $ay*2]"
168 test unixfont-5.8 {Tk_MeasureChars procedure: internal spaces significant} x11 {
172 test unixfont-5.8 {Tk_MeasureChars procedure: internal spaces significant} {x11 failsOnUbuntu} {
169173 .b.l config -text "00 000 00000"
170174 getsize
171175 } "[expr $ax*7] [expr $ay*2]"
172 test unixfont-5.9 {Tk_MeasureChars procedure: TK_PARTIAL_OK} x11 {
176 test unixfont-5.9 {Tk_MeasureChars procedure: TK_PARTIAL_OK} {x11 failsOnUbuntu} {
173177 .b.c dchars $t 0 end
174178 .b.c insert $t 0 "0000"
175179 .b.c index $t @[expr int($ax*2.5)],1
185189 .b.l config -wrap $a
186190 set x
187191 } "$ax [expr $ay*6]"
188 test unixfont-5.12 {Tk_MeasureChars procedure: include eol spaces} x11 {
192 test unixfont-5.12 {Tk_MeasureChars procedure: include eol spaces} {x11 failsOnUbuntu} {
189193 .b.l config -text "000 \n000"
190194 getsize
191195 } "[expr $ax*6] [expr $ay*2]"
252256 catch {unset fontArray}
253257 set result
254258 } {-family -overstrike -size -slant -underline -weight}
255 test unixfont-8.4 {AllocFont procedure: classify characters} x11 {
259 test unixfont-8.4 {AllocFont procedure: classify characters} {x11 failsOnUbuntu failsOnXQuarz} {
256260 set x 0
257261 incr x [font measure $courier "\u4000"] ;# 6
258262 incr x [font measure $courier "\002"] ;# 4
263267 test unixfont-8.5 {AllocFont procedure: setup widths of normal chars} x11 {
264268 font metrics $courier -fixed
265269 } {1}
266 test unixfont-8.6 {AllocFont procedure: setup widths of special chars} x11 {
270 test unixfont-8.6 {AllocFont procedure: setup widths of special chars} {x11 failsOnUbuntu failsOnXQuarz} {
267271 set x 0
268272 incr x [font measure $courier "\001"] ;# 4
269273 incr x [font measure $courier "\002"] ;# 4
291295 set x {}
292296 } {}
293297
294 test unixfont-9.1 {GetControlCharSubst procedure: 2 chars subst} x11 {
298 test unixfont-9.1 {GetControlCharSubst procedure: 2 chars subst} {x11 failsOnUbuntu failsOnXQuarz} {
295299 .b.c dchars $t 0 end
296300 .b.c insert $t 0 "0\a0"
297301 set x {}
300304 lappend x [.b.c index $t @[expr $ax*2],0]
301305 lappend x [.b.c index $t @[expr $ax*3],0]
302306 } {0 1 1 2}
303 test unixfont-9.2 {GetControlCharSubst procedure: 4 chars subst} x11 {
307 test unixfont-9.2 {GetControlCharSubst procedure: 4 chars subst} {x11 failsOnUbuntu failsOnXQuarz} {
304308 .b.c dchars $t 0 end
305309 .b.c insert $t 0 "0\0010"
306310 set x {}
3434
3535
3636 test unixMenu-4.1 {TkpConfigureMenuEntry - non-cascade entry} -constraints {
37 unix
37 unix
3838 } -setup {
3939 destroy .m1
4040 } -body {
4343 list [.m1 entryconfigure test -label foo] [destroy .m1]
4444 } -returnCodes ok -result {{} {}}
4545 test unixMenu-4.2 {TkpConfigureMenuEntry - cascade entry} -constraints {
46 unix
46 unix
4747 } -setup {
4848 destroy .m1
4949 } -body {
7878
7979
8080 test unixMenu-8.1 {GetMenuIndicatorGeometry - indicator off} -constraints {
81 unix
81 unix
8282 } -setup {
8383 destroy .m1
8484 } -body {
8888 destroy .m1
8989 } -returnCodes ok
9090 test unixMenu-8.2 {GetMenuIndicatorGeometry - not checkbutton or radio} -constraints {
91 unix
91 unix
9292 } -setup {
9393 destroy .m1
9494 } -body {
111111 destroy .m1
112112 } -cleanup {
113113 image delete image1
114 } -returnCodes ok
114 } -returnCodes ok
115115 test unixMenu-8.4 {GetMenuIndicatorGeometry - checkbutton bitmap} -constraints {
116 unix
116 unix
117117 } -setup {
118118 destroy .m1
119119 } -body {
124124 destroy .m1
125125 } -returnCodes ok
126126 test unixMenu-8.5 {GetMenuIndicatorGeometry - checkbutton} -constraints {
127 unix
127 unix
128128 } -setup {
129129 destroy .m1
130130 } -body {
149149 image delete image1
150150 } -returnCodes ok
151151 test unixMenu-8.7 {GetMenuIndicatorGeometry - radiobutton bitmap} -constraints {
152 unix
152 unix
153153 } -setup {
154154 destroy .m1
155155 } -body {
158158 .m1 invoke foo
159159 tk::TearOffMenu .m1 40 40
160160 destroy .m1
161 } -returnCodes ok
161 } -returnCodes ok
162162 test unixMenu-8.8 {GetMenuIndicatorGeometry - radiobutton} -constraints {
163 unix
163 unix
164164 } -setup {
165165 destroy .m1
166166 } -body {
171171 destroy .m1
172172 } -returnCodes ok
173173 test unixMenu-8.9 {GetMenuIndicatorGeometry - hideMargin} -constraints {
174 unix
174 unix
175175 } -setup {
176176 destroy .m1
177177 } -body {
180180 .m1 invoke foo
181181 tk::TearOffMenu .m1 40 40
182182 destroy .m1
183 } -returnCodes ok
183 } -returnCodes ok
184184
185185
186186 test unixMenu-9.1 {GetMenuAccelGeometry - cascade entry} -constraints {
187 unix
187 unix
188188 } -setup {
189189 destroy .m1
190190 } -body {
194194 destroy .m1
195195 } -returnCodes ok
196196 test unixMenu-9.2 {GetMenuAccelGeometry - non-null label} -constraints {
197 unix
197 unix
198198 } -setup {
199199 destroy .m1
200200 } -body {
214214
215215
216216 test unixMenu-10.1 {DrawMenuEntryBackground - active menubar} -constraints {
217 unix
217 unix
218218 } -setup {
219219 destroy .m1
220220 } -body {
234234 list [update] [destroy .m1]
235235 } -returnCodes ok -result {{} {}}
236236 test unixMenu-10.3 {DrawMenuEntryBackground - non-active} -constraints {
237 unix
237 unix
238238 } -setup {
239239 destroy .m1
240240 } -body {
246246
247247
248248 test unixMenu-11.1 {DrawMenuEntryAccelerator - menubar} -constraints {
249 unix
249 unix
250250 } -setup {
251251 destroy .m1
252252 } -body {
257257 } -result {{} {} {}}
258258 # drawArrow parameter is never false under Unix
259259 test unixMenu-11.2 {DrawMenuEntryAccelerator - cascade entry} -constraints {
260 unix
260 unix
261261 } -setup {
262262 destroy .m1
263263 } -body {
267267 list [update] [destroy .m1]
268268 } -result {{} {}}
269269 test unixMenu-11.3 {DrawMenuEntryAccelerator - normal entry} -constraints {
270 unix
270 unix
271271 } -setup {
272272 destroy .m1
273273 } -body {
277277 list [update] [destroy .m1]
278278 } -result {{} {}}
279279 test unixMenu-11.4 {DrawMenuEntryAccelerator - null entry} -constraints {
280 unix
280 unix
281281 } -setup {
282282 destroy .m1
283283 } -body {
289289
290290
291291 test unixMenu-12.1 {DrawMenuEntryIndicator - non-check or radio} -constraints {
292 unix
292 unix
293293 } -setup {
294294 destroy .m1
295295 } -body {
299299 list [update] [destroy .m1]
300300 } -result {{} {}}
301301 test unixMenu-12.2 {DrawMenuEntryIndicator - checkbutton - indicator off} -constraints {
302 unix
302 unix
303303 } -setup {
304304 destroy .m1
305305 } -body {
309309 list [update] [destroy .m1]
310310 } -result {{} {}}
311311 test unixMenu-12.3 {DrawMenuEntryIndicator - checkbutton - not selected} -constraints {
312 unix
312 unix
313313 } -setup {
314314 destroy .m1
315315 } -body {
319319 list [update] [destroy .m1]
320320 } -result {{} {}}
321321 test unixMenu-12.4 {DrawMenuEntryIndicator - checkbutton - selected} -constraints {
322 unix
322 unix
323323 } -setup {
324324 destroy .m1
325325 } -body {
330330 list [update] [destroy .m1]
331331 } -result {{} {}}
332332 test unixMenu-12.5 {DrawMenuEntryIndicator - radiobutton - indicator off} -constraints {
333 unix
333 unix
334334 } -setup {
335335 destroy .m1
336336 } -body {
340340 list [update] [destroy .m1]
341341 } -result {{} {}}
342342 test unixMenu-12.6 {DrawMenuEntryIndicator - radiobutton - not selected} -constraints {
343 unix
343 unix
344344 } -setup {
345345 destroy .m1
346346 } -body {
350350 list [update] [destroy .m1]
351351 } -result {{} {}}
352352 test unixMenu-12.7 {DrawMenuEntryIndicator - radiobutton - selected} -constraints {
353 unix
353 unix
354354 } -setup {
355355 destroy .m1
356356 } -body {
445445 # Don't know how to reproduce the case where the tkwin has been deleted.
446446
447447 test unixMenu-19.1 {TkpComputeMenubarGeometry - zero entries} -constraints {
448 unix
448 unix
449449 } -setup {
450450 destroy .m1
451451 } -body {
455455 } -result {{} {} {}}
456456 # Don't know how to generate one width windows
457457 test unixMenu-19.2 {TkpComputeMenubarGeometry - one entry} -constraints {
458 unix
458 unix
459459 } -setup {
460460 destroy .m1
461461 } -body {
465465 list [update] [. configure -menu ""] [destroy .m1]
466466 } -result {{} {} {}}
467467 test unixMenu-19.3 {TkpComputeMenubarGeometry - entry with different font} -constraints {
468 unix
468 unix
469469 } -setup {
470470 destroy .m1
471471 } -body {
475475 list [update] [. configure -menu ""] [destroy .m1]
476476 } -result {{} {} {}}
477477 test unixMenu-19.4 {TkpComputeMenubarGeometry - separator} -constraints {
478 unix
478 unix
479479 } -setup {
480480 destroy .m1
481481 } -body {
485485 list [update] [. configure -menu ""] [destroy .m1]
486486 } -result {{} {} {}}
487487 test unixMenu-19.5 {TkpComputeMenubarGeometry - First entry} -constraints {
488 unix
488 unix
489489 } -setup {
490490 destroy .m1
491491 } -body {
495495 list [update] [. configure -menu ""] [destroy .m1]
496496 } -result {{} {} {}}
497497 test unixMenu-19.6 {TkpComputeMenubarGeometry - First entry too wide} -constraints {
498 unix
498 unix
499499 } -setup {
500500 destroy .m1
501501 } -body {
506506 list [update] [. configure -menu ""] [destroy .m1]
507507 } -result {{} {} {}}
508508 test unixMenu-19.7 {TkpComputeMenubarGeometry - two entries fit} -constraints {
509 unix
509 unix
510510 } -setup {
511511 destroy .m1
512512 } -body {
518518 list [update] [. configure -menu ""] [destroy .m1]
519519 } -result {{} {} {}}
520520 test unixMenu-19.8 {TkpComputeMenubarGeometry - two entries; 2nd don't fit} -constraints {
521 unix
521 unix
522522 } -setup {
523523 destroy .m1
524524 } -body {
530530 list [update] [. configure -menu ""] [destroy .m1]
531531 } -result {{} {} {}}
532532 test unixMenu-19.9 {TkpComputeMenubarGeometry - two entries; 1st dont fit} -constraints {
533 unix
533 unix
534534 } -setup {
535535 destroy .m1
536536 } -body {
542542 list [update] [. configure -menu ""] [destroy .m1]
543543 } -result {{} {} {}}
544544 test unixMenu-19.10 {TkpComputeMenubarGeometry - two entries; neither fit} -constraints {
545 unix
545 unix
546546 } -setup {
547547 destroy .m1
548548 } -body {
644644 list [update] [. configure -menu ""] [destroy .m1]
645645 } -result {{} {} {}}
646646 test unixMenu-19.19 {TkpComputeMenubarGeometry - help menu in first position} -constraints {
647 unix
647 unix
648648 } -setup {
649649 destroy .m1
650650 } -body {
660660 list [update] [. configure -menu ""] [destroy .m1]
661661 } -result {{} {} {}}
662662 test unixMenu-19.20 {TkpComputeMenubarGeometry - help menu in middle} -constraints {
663 unix
663 unix
664664 } -setup {
665665 destroy .m1
666666 } -body {
676676 list [update] [. configure -menu ""] [destroy .m1]
677677 } -result {{} {} {}}
678678 test unixMenu-19.21 {TkpComputeMenubarGeometry - help menu in first position} -constraints {
679 unix
679 unix
680680 } -setup {
681681 destroy .m1
682682 } -body {
692692 list [update] [. configure -menu ""] [destroy .m1]
693693 } -result {{} {} {}}
694694 test unixMenu-19.22 {TkpComputeMenubarGeometry - help item fits} -constraints {
695 unix
695 unix
696696 } -setup {
697697 destroy .m1
698698 } -body {
706706 list [update] [. configure -menu ""] [destroy .m1]
707707 } -result {{} {} {}}
708708 test unixMenu-19.23 {TkpComputeMenubarGeometry - help item does not fit} -constraints {
709 unix
709 unix
710710 } -setup {
711711 destroy .m1
712712 } -body {
720720 list [update] [. configure -menu ""] [destroy .m1]
721721 } -result {{} {} {}}
722722 test unixMenu-19.24 {TkpComputeMenubarGeometry - help item only one} -constraints {
723 unix
723 unix
724724 } -setup {
725725 destroy .m1
726726 } -body {
765765 } -result {.m1.test {}}
766766 # Don't know how to automate missing tkwins
767767 test unixMenu-22.2 {SetHelpMenu - menubar but no help menu} -constraints {
768 unix
768 unix
769769 } -setup {
770770 destroy .m1
771771 } -body {
775775 list [menu .m1.file] [. configure -menu ""] [destroy .m1]
776776 } -result {.m1.file {} {}}
777777 test unixMenu-22.3 {SetHelpMenu - menubar with help menu} -constraints {
778 unix
778 unix
779779 } -setup {
780780 destroy .m1
781781 } -body {
785785 list [menu .m1.help] [. configure -menu ""] [destroy .m1]
786786 } -result {.m1.help {} {}}
787787 test unixMenu-22.4 {SetHelpMenu - multiple menubars with same help menu} -constraints {
788 unix
788 unix
789789 } -setup {
790790 destroy .m1 .t2
791791 } -body {
800800
801801
802802 test unixMenu-23.1 {TkpDrawMenuEntry - gc for active and not strict motif} -constraints {
803 unix
803 unix
804804 } -setup {
805805 destroy .m1
806806 } -body {
811811 list [update] [destroy .m1]
812812 } -result {{} {}}
813813 test unixMenu-23.2 {TkpDrawMenuEntry - gc for active menu item with its own gc} -constraints {
814 unix
814 unix
815815 } -setup {
816816 destroy .m1
817817 } -body {
822822 list [update] [destroy .m1]
823823 } -result {{} {}}
824824 test unixMenu-23.3 {TkpDrawMenuEntry - gc for active and strict motif} -constraints {
825 unix
825 unix
826826 } -setup {
827827 destroy .m1
828828 } -body {
834834 list [update] [destroy .m1] [set tk_strictMotif 0]
835835 } -result {{} {} 0}
836836 test unixMenu-23.4 {TkpDrawMenuEntry - gc for disabled with disabledfg and custom entry} -constraints {
837 unix
837 unix
838838 } -setup {
839839 destroy .m1
840840 } -body {
844844 list [update] [destroy .m1]
845845 } -result {{} {}}
846846 test unixMenu-23.5 {TkpDrawMenuEntry - gc for disabled with disabledFg} -constraints {
847 unix
847 unix
848848 } -setup {
849849 destroy .m1
850850 } -body {
854854 list [update] [destroy .m1]
855855 } -result {{} {}}
856856 test unixMenu-23.6 {TkpDrawMenuEntry - gc for disabled - no disabledFg} -constraints {
857 unix
857 unix
858858 } -setup {
859859 destroy .m1
860860 } -body {
864864 list [update] [destroy .m1]
865865 } -result {{} {}}
866866 test unixMenu-23.7 {TkpDrawMenuEntry - gc for normal - custom entry} -constraints {
867 unix
867 unix
868868 } -setup {
869869 destroy .m1
870870 } -body {
882882 list [update] [destroy .m1]
883883 } -result {{} {}}
884884 test unixMenu-23.9 {TkpDrawMenuEntry - gc for indicator - custom entry} -constraints {
885 unix
885 unix
886886 } -setup {
887887 destroy .m1
888888 } -body {
893893 list [update] [destroy .m1]
894894 } -result {{} {}}
895895 test unixMenu-23.10 {TkpDrawMenuEntry - gc for indicator} -constraints {
896 unix
896 unix
897897 } -setup {
898898 destroy .m1
899899 } -body {
904904 list [update] [destroy .m1]
905905 } -result {{} {}}
906906 test unixMenu-23.11 {TkpDrawMenuEntry - border - custom entry} -constraints {
907 unix
907 unix
908908 } -setup {
909909 destroy .m1
910910 } -body {
924924 list [update] [destroy .m1]
925925 } -result {{} {}}
926926 test unixMenu-23.13 {TkpDrawMenuEntry - active border - strict motif} -constraints {
927 unix
927 unix
928928 } -setup {
929929 destroy .m1
930930 } -body {
936936 list [update] [destroy .m1] [set tk_strictMotif 0]
937937 } -result {{} {} 0}
938938 test unixMenu-23.14 {TkpDrawMenuEntry - active border - custom entry} -constraints {
939 unix
939 unix
940940 } -setup {
941941 destroy .m1
942942 } -body {
956956 list [update] [destroy .m1]
957957 } -result {{} {}}
958958 test unixMenu-23.16 {TkpDrawMenuEntry - font - custom entry} -constraints {
959 unix
959 unix
960960 } -setup {
961961 destroy .m1
962962 } -body {
990990 list [update] [destroy .m1]
991991 } -result {{} {}}
992992 test unixMenu-23.20 {TkpDrawMenuEntry - disabled cascade item} -constraints {
993 unix
993 unix
994994 } -setup {
995995 destroy .m1
996996 } -body {
10571057
10581058
10591059 test unixMenu-25.1 {TkpComputeStandardMenuGeometry - no entries} -constraints {
1060 unix
1060 unix
10611061 } -setup {
10621062 destroy .m1
10631063 } -body {
10651065 list [update idletasks] [destroy .m1]
10661066 } -result {{} {}}
10671067 test unixMenu-25.2 {TkpComputeStandardMenuGeometry - one entry} -constraints {
1068 unix
1068 unix
10691069 } -setup {
10701070 destroy .m1
10711071 } -body {
10741074 list [update idletasks] [destroy .m1]
10751075 } -result {{} {}}
10761076 test unixMenu-25.3 {TkpComputeStandardMenuGeometry - more than one entry} -constraints {
1077 unix
1077 unix
10781078 } -setup {
10791079 destroy .m1
10801080 } -body {
10841084 list [update idletasks] [destroy .m1]
10851085 } -result {{} {}}
10861086 test unixMenu-25.4 {TkpComputeStandardMenuGeometry - separator} -constraints {
1087 unix
1087 unix
10881088 } -setup {
10891089 destroy .m1
10901090 } -body {
11051105 list [update] [tk::MenuUnpost .mb.m] [destroy .mb]
11061106 } -result {{} {} {}}
11071107 test unixMenu-25.6 {TkpComputeStandardMenuGeometry - standard label geometry} -constraints {
1108 unix
1108 unix
11091109 } -setup {
11101110 destroy .m1
11111111 } -body {
11141114 list [update idletasks] [destroy .m1]
11151115 } -result {{} {}}
11161116 test unixMenu-25.7 {TkpComputeStandardMenuGeometry - different font for entry} -constraints {
1117 unix
1117 unix
11181118 } -setup {
11191119 destroy .m1
11201120 } -body {
11231123 list [update idletasks] [destroy .m1]
11241124 } -result {{} {}}
11251125 test unixMenu-25.8 {TkpComputeStandardMenuGeometry - second entry larger} -constraints {
1126 unix
1126 unix
11271127 } -setup {
11281128 destroy .m1
11291129 } -body {
11331133 list [update idletasks] [destroy .m1]
11341134 } -result {{} {}}
11351135 test unixMenu-25.9 {TkpComputeStandardMenuGeometry - first entry larger} -constraints {
1136 unix
1136 unix
11371137 } -setup {
11381138 destroy .m1
11391139 } -body {
11431143 list [update idletasks] [destroy .m1]
11441144 } -result {{} {}}
11451145 test unixMenu-25.10 {TkpComputeStandardMenuGeometry - accelerator} -constraints {
1146 unix
1146 unix
11471147 } -setup {
11481148 destroy .m1
11491149 } -body {
11521152 list [update idletasks] [destroy .m1]
11531153 } -result {{} {}}
11541154 test unixMenu-25.11 {TkpComputeStandardMenuGeometry - second accel larger} -constraints {
1155 unix
1155 unix
11561156 } -setup {
11571157 destroy .m1
11581158 } -body {
11621162 list [update idletasks] [destroy .m1]
11631163 } -result {{} {}}
11641164 test unixMenu-25.12 {TkpComputeStandardMenuGeometry - second accel smaller} -constraints {
1165 unix
1165 unix
11661166 } -setup {
11671167 destroy .m1
11681168 } -body {
11721172 list [update idletasks] [destroy .m1]
11731173 } -result {{} {}}
11741174 test unixMenu-25.13 {TkpComputeStandardMenuGeometry - indicator} -constraints {
1175 unix
1175 unix
11761176 } -setup {
11771177 destroy .m1
11781178 } -body {
12101210 list [update idletasks] [destroy .m1] [image delete image1]
12111211 } -result {{} {} {}}
12121212 test unixMenu-25.16 {TkpComputeStandardMenuGeometry - zero sized menus} -constraints {
1213 unix
1213 unix
12141214 } -setup {
12151215 destroy .m1
12161216 } -body {
12181218 list [update idletasks] [destroy .m1]
12191219 } -result {{} {}}
12201220 test unixMenu-25.17 {TkpComputeStandardMenuGeometry - first column bigger} -constraints {
1221 unix
1221 unix
12221222 } -setup {
12231223 destroy .m1
12241224 } -body {
12291229 list [update idletasks] [destroy .m1]
12301230 } -result {{} {}}
12311231 test unixMenu-25.18 {TkpComputeStandardMenuGeometry - second column bigger} -constraints {
1232 unix
1232 unix
12331233 } -setup {
12341234 destroy .m1
12351235 } -body {
12401240 list [update idletasks] [destroy .m1]
12411241 } -result {{} {}}
12421242 test unixMenu-25.19 {TkpComputeStandardMenuGeometry - three columns} -constraints {
1243 unix
1243 unix
12441244 } -setup {
12451245 destroy .m1
12461246 } -body {
12511251 .m1 add command -label four
12521252 .m1 add command -label five -columnbreak 1
12531253 .m1 add command -label six
1254 list [update idletasks] [destroy .m1]
1254 list [update idletasks] [destroy .m1]
12551255 } -result {{} {}}
12561256 test unixMenu-25.20 {TkpComputeStandardMenuGeometry - hide margin} -constraints {
1257 unix
1257 unix
12581258 } -setup {
12591259 destroy .m1
12601260 } -body {
1212
1313 namespace import -force ::tk::test:loadTkCommand
1414
15 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
16 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
17
1518 proc sleep ms {
1619 global x
1720 after $ms {set x 1}
1821 vwait x
1922 }
20
21 # The macOS window manager shows an animation when a window is deiconified.
22 # Tests which check the geometry of a window after deiconifying it should
23 # wait for the animation to finish.
24
25 proc animationDelay {} {
26 if {[tk windowingsystem] == "aqua"} {
27 sleep 250
28 }
29 }
3023
3124 # Procedure to set up a collection of top-level windows
3225
4538 # larger than the height of the menubar (normally 23 pixels).
4639
4740 if {[tk windowingsystem] eq "aqua"} {
48 set Y0 23
49 set Y2 25
50 set Y5 28
41 set mb [expr [menubarheight] + 1]
42 set Y0 $mb
43 set Y2 [expr $mb + 2]
44 set Y5 [expr $mb + 5]
5145 } else {
5246 set Y0 0
5347 set Y2 2
5549 }
5650
5751 set i 1
58 foreach geom "+23+80 +80+23 +0+$Y0" {
52 foreach geom "+$Y0+80 +80+$Y0 +0+$Y0" {
5953 destroy .t
6054 test unixWm-1.$i {initial window position} unix {
6155 toplevel .t -width 200 -height 150
8175 scan [wm geom .t] %dx%d+%d+%d width height x y
8276 set xerr [expr 150-$x]
8377 set yerr [expr 150-$y]
84 foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" {
78 foreach geom "+20+80 +80+$Y0 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" {
8579 test unixWm-2.$i {moving window while mapped} unix {
8680 wm geom .t $geom
8781 update
9387 }
9488
9589 set i 1
96 foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" {
90 foreach geom "+20+80 +80+$Y0 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" {
9791 test unixWm-3.$i {moving window while iconified} unix {
9892 wm iconify .t
99 sleep 200
93 update idletasks
10094 wm geom .t $geom
101 update
95 update idletasks
10296 wm deiconify .t
103 animationDelay
97 update idletasks
10498 scan [wm geom .t] %dx%d%1s%d%1s%d width height xsign x ysign y
10599 format "%s%d%s%d" $xsign [eval expr $x$xsign$xerr] $ysign \
106100 [eval expr $y$ysign$yerr]
112106 foreach geom "+20+80 +100+40 +0+$Y0" {
113107 test unixWm-4.$i {moving window while withdrawn} unix {
114108 wm withdraw .t
115 sleep 200
109 update idletasks
116110 wm geom .t $geom
117 update
111 update idletasks
118112 wm deiconify .t
119 animationDelay
113 update idletasks
120114 wm geom .t
121115 } 100x150$geom
122116 incr i
193187
194188 destroy .t
195189 toplevel .t -width 200 -height 100
196 wm geom .t +10+23
190 wm geom .t +10+$Y0
197191 wm minsize .t 1 1
198192 update
199193 test unixWm-6.1 {size changes} unix {
200194 .t config -width 180 -height 150
201195 update
202196 wm geom .t
203 } 180x150+10+23
197 } 180x150+10+$Y0
204198 test unixWm-6.2 {size changes} unix {
205199 wm geom .t 250x60
206200 .t config -width 170 -height 140
207201 update
208202 wm geom .t
209 } 250x60+10+23
203 } 250x60+10+$Y0
210204 test unixWm-6.3 {size changes} unix {
211205 wm geom .t 250x60
212206 .t config -width 170 -height 140
213207 wm geom .t {}
214208 update
215209 wm geom .t
216 } 170x140+10+23
210 } 170x140+10+$Y0
217211 test unixWm-6.4 {size changes} {unix nonPortable userInteraction} {
218212 wm minsize .t 1 1
219213 update
295289 toplevel .t -width 100 -height 30
296290 list [catch {wm iconwindow .t b c} msg] $msg
297291 } {1 {wrong # args: should be "wm iconwindow window ?pathName?"}}
298 test unixWm-8.4 {icon windows} unix {
292 test unixWm-8.4 {icon windows} {unix failsOnUbuntu} {
299293 destroy .t
300294 destroy .icon
301295 toplevel .t -width 100 -height 30
302296 wm geom .t +0+0
297 update idletasks
303298 set result [wm iconwindow .t]
304299 toplevel .icon -width 50 -height 50 -bg red
305300 wm iconwindow .t .icon
309304 update
310305 lappend result [winfo ismapped .t] [winfo ismapped .icon]
311306 wm iconify .t
312 update
307 update idletasks
313308 lappend result [winfo ismapped .t] [winfo ismapped .icon]
314309 } {.icon icon {} withdrawn 1 0 0 0}
315310 test unixWm-8.5 {icon windows} unix {
347342 wm geom .t +0+0
348343 tkwait visibility .t ;# Needed to keep tvtwm happy.
349344 wm iconwindow .t .icon
350 sleep 500
351345 lappend result [winfo ismapped .t] [winfo ismapped .icon]
352346 } {1 1 0}
353347 test unixWm-8.9 {icon windows} {unix nonPortable} {
419413 toplevel .t -width 100 -height 300 -bg blue
420414 wm geom .t +0+0
421415 wm iconify .t
422 sleep 500
423416 winfo ismapped .t
424417 } {0}
425418 test unixWm-9.4 {TkWmMapWindow procedure, icon windows} unix {
426419 destroy .t
427 sleep 500
428420 toplevel .t -width 100 -height 50 -bg blue
429421 tkwait visibility .t
430422 wm iconwindow . .t
642634 destroy .icon
643635 set result
644636 } {1 {can't deiconify .icon: it is an icon for .t}}
645 test unixWm-16.3 {Tk_WmCmd procedure, "deiconify" option} unix {
637 test unixWm-16.3 {Tk_WmCmd procedure, "deiconify" option} {unix failsOnUbuntu} {
646638 wm iconify .t
647639 set result {}
648640 lappend result [winfo ismapped .t] [wm state .t]
861853 destroy .t2
862854 set result
863855 } {1 {can't iconify .t2: it is an icon for .t}}
864 test unixWm-23.5 {Tk_WmCmd procedure, "iconify" option} unix {
856 test unixWm-23.5 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu} {
865857 destroy .t2
866858 toplevel .t2
867859 wm geom .t2 +0+0
868 update
860 update idletasks
869861 wm iconify .t2
870 update
862 update idletasks
871863 set result [winfo ismapped .t2]
872864 destroy .t2
873865 set result
874866 } {0}
875 test unixWm-23.6 {Tk_WmCmd procedure, "iconify" option} unix {
867 test unixWm-23.6 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu} {
876868 destroy .t2
877869 toplevel .t2
878870 wm geom .t2 -0+0
879 update
871 update idletasks
880872 set result [winfo ismapped .t2]
881873 wm iconify .t2
882 update
874 update idletasks
883875 lappend result [winfo ismapped .t2]
884876 destroy .t2
885877 set result
13081300 destroy .t2
13091301 set result
13101302 } {{} {} .t 0 {} {}}
1311 test unixWm-37.4 {TkWmDeadWindow, destroy on master should clear transient} {unix testwrapper} {
1303 test unixWm-37.4 {TkWmDeadWindow, destroy on toplevel should clear transient} {unix testwrapper} {
13121304 destroy .t2
13131305 toplevel .t2
13141306 destroy .t3
13191311 update
13201312 list [wm transient .t2] [testprop [testwrapper .t2] WM_TRANSIENT_FOR]
13211313 } {{} {}}
1322 test unixWm-37.5 {Tk_WmCmd procedure, "transient" option, create master wrapper} {unix testwrapper} {
1314 test unixWm-37.5 {Tk_WmCmd procedure, "transient" option, create toplevel wrapper} {unix testwrapper} {
13231315 destroy .t2
13241316 destroy .t3
13251317 toplevel .t2 -width 120 -height 300
13831375 test unixWm-41.1 {ConfigureEvent procedure, internally generated size changes} unix {
13841376 destroy .t
13851377 toplevel .t -width 400 -height 150
1378 tkwait visibility .t
13861379 wm geometry .t +0+0
1387 tkwait visibility .t
1380 update idletasks
13881381 set result {}
13891382 lappend result [winfo width .t] [winfo height .t]
13901383 .t configure -width 200 -height 300
1391 sleep 500
1384 update idletasks
13921385 lappend result [winfo width .t] [winfo height .t]
13931386 } {400 150 200 300}
13941387 test unixWm-41.2 {ConfigureEvent procedure, menubars} {nonPortable testmenubar} {
14421435 # No tests for ReparentEvent or ComputeReparentGeometry; I can't figure
14431436 # out how to exercise these procedures reliably.
14441437
1445 test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} unix {
1438 test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} {unix failsOnUbuntu} {
14461439 destroy .t
14471440 toplevel .t -width 400 -height 150
14481441 wm geometry .t +0+0
14521445 bind .t <Unmap> {set x "unmapped"}
14531446 set x {no event}
14541447 wm iconify .t
1455 animationDelay
1448 update idletasks
14561449 lappend result $x [winfo ismapped .t]
14571450 set x {no event}
14581451 wm deiconify .t
1459 animationDelay
1452 update idletasks
14601453 lappend result $x [winfo ismapped .t]
14611454 } {unmapped 0 mapped 1}
14621455
15591552 } {100 1}
15601553 destroy .t
15611554 toplevel .t -width 80 -height 60
1562 test unixWm-44.7 {UpdateGeometryInfo procedure, computing position} unix {
1555 test unixWm-44.7 {UpdateGeometryInfo procedure, computing position} {unix failsOnXQuarz} {
15631556 tkwait visibility .t
15641557 wm overrideredirect .t 1
15651558 update
15691562 } [list 5 [expr [winfo screenheight .t] - 70]]
15701563 destroy .t
15711564 toplevel .t -width 80 -height 60
1572 test unixWm-44.8 {UpdateGeometryInfo procedure, computing position} unix {
1565 test unixWm-44.8 {UpdateGeometryInfo procedure, computing position} {unix failsOnXQuarz} {
15731566 tkwait visibility .t
15741567 wm overrideredirect .t 1
15751568 update
16191612 [expr [lindex $property 7]] [expr [lindex $property 8]] \
16201613 [expr [lindex $property 9]] [expr [lindex $property 10]]
16211614 } {40 30 320 210 10 5}
1622 test unixWm-45.2 {UpdateSizeHints procedure} {unix testwrapper} {
1615 test unixWm-45.2 {UpdateSizeHints procedure} {unix testwrapper failsOnUbuntu failsOnXQuarz} {
16231616 destroy .t
16241617 toplevel .t -width 80 -height 60
16251618 wm minsize .t 30 40
16471640 [expr [lindex $property 7]] [expr [lindex $property 8]] \
16481641 [expr [lindex $property 9]] [expr [lindex $property 10]]
16491642 } {60 40 53 320 233 10 5}
1650 test unixWm-45.4 {UpdateSizeHints procedure, not resizable with menu} {testmenubar testwrapper} {
1643 test unixWm-45.4 {UpdateSizeHints procedure, not resizable with menu} {testmenubar testwrapper failsOnUbuntu failsOnXQuarz} {
16511644 destroy .t
16521645 toplevel .t -width 80 -height 60
16531646 frame .t.menu -height 23 -width 50
18011794 # Windows are assumed to have a border (invisible in Gnome 3).
18021795 set result_50_1 {{} {} .t {} .t2 {} .t2 {} .t}
18031796 }
1804 test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords, title bar} unix {
1797 test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords, title bar} {unix failsOnUbuntu failsOnXQuarz} {
18051798 update
18061799 toplevel .t -width 300 -height 400 -bg green
18071800 wm geom .t +100+100
18491842 Tk_CoordsToWindow procedure, finding a toplevel with embedding
18501843 } tempNotWin {
18511844 deleteWindows
1852 catch {interp delete slave}
1845 catch {interp delete child}
18531846
18541847 toplevel .t -width 300 -height 400 -bg blue
18551848 wm geom .t +100+100
18571850 place .t.f -x 150 -y 50
18581851 tkwait visibility .t.f
18591852 update
1860 interp create slave
1861 load {} Tk slave
1862 slave alias frameid winfo id .t.f
1863 slave eval {
1853 interp create child
1854 load {} Tk child
1855 child alias frameid winfo id .t.f
1856 child eval {
18641857 wm withdraw .
18651858 toplevel .x -width 100 -height 80 -use [frameid] -bg yellow
18661859 tkwait visibility .x
18681861 set x [winfo rootx .x]
18691862 set y [winfo rooty .x]
18701863 }
1871 set result [list [slave eval {winfo containing [expr $x - 1] [expr $y + 50]}] \
1872 [slave eval {winfo containing $x [expr $y + 50]}]]
1873 interp delete slave
1864 set result [list [child eval {winfo containing [expr $x - 1] [expr $y + 50]}] \
1865 [child eval {winfo containing $x [expr $y + 50]}]]
1866 interp delete child
18741867 set x [winfo rootx .t]
18751868 set y [winfo rooty .t]
18761869 lappend result [winfo containing [expr $x + 200] [expr $y + 49]] \
18801873 test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix {
18811874 destroy .t
18821875
1883 catch {interp delete slave}
1876 catch {interp delete child}
18841877 toplevel .t -width 200 -height 200 -bg green
18851878 wm geometry .t +100+100
18861879 tkwait visibility .t
18871880 update
1888 interp create slave
1889 load {} Tk slave
1890 slave eval {wm geometry . 200x200+100+100; tkwait visibility . ; update}
1881 interp create child
1882 load {} Tk child
1883 child eval {wm geometry . 200x200+100+100; tkwait visibility . ; update}
18911884 set result [list [winfo containing 200 200] \
1892 [slave eval {winfo containing 200 200}]]
1893 interp delete slave
1885 [child eval {winfo containing 200 200}]]
1886 interp delete child
18941887 set result
18951888 } {{} .}
18961889 test unixWm-50.5 {Tk_CoordsToWindow procedure, handling menubars} {unix testmenubar} {
19521945 test unixWm-50.8 {Tk_CoordsToWindow procedure, more basics} unix {
19531946 destroy .t
19541947 toplevel .t -width 400 -height 300 -bg green
1955 wm geom .t +0+0
1948 wm geom .t +0+30
19561949 frame .t.f -width 200 -height 100 -bd 2 -relief raised
19571950 place .t.f -x 100 -y 100
19581951 frame .t.f.f -width 200 -height 100 -bd 2 -relief raised
19591952 place .t.f.f -x 100 -y 0
19601953 update
1961 set x [winfo rooty .t]
1954 set x [winfo rootx .t]
19621955 set y [expr [winfo rooty .t] + 150]
19631956 list [winfo containing [expr $x + 50] $y] \
19641957 [winfo containing [expr $x + 150] $y] \
19661959 [winfo containing [expr $x + 350] $y] \
19671960 [winfo containing [expr $x + 450] $y]
19681961 } {.t .t.f .t.f.f .t {}}
1969 test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix {
1970 destroy .t
1971 destroy .t2
1972 sleep 500 ;# Give window manager time to catch up.
1962 test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} {unix failsOnUbuntu} {
1963 destroy .t
1964 destroy .t2
19731965 toplevel .t -width 200 -height 200 -bg green
19741966 wm geometry .t +0+0
19751967 tkwait visibility .t
19781970 tkwait visibility .t2
19791971 set result [list [winfo containing 100 100]]
19801972 wm iconify .t2
1981 animationDelay
1973 update idletasks
19821974 lappend result [winfo containing 100 100]
19831975 } {.t2 .t}
19841976 test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix {
19881980 frame .t.f -width 150 -height 150 -bd 2 -relief raised
19891981 place .t.f -x 25 -y 25
19901982 tkwait visibility .t.f
1983 update idletasks
19911984 set result [list [winfo containing 100 100]]
19921985 place forget .t.f
1993 update
1986 update idletasks
19941987 lappend result [winfo containing 100 100]
19951988 } {.t.f .t}
19961989 deleteWindows
20202013 set result [winfo containing [winfo rootx .raise1] \
20212014 [winfo rooty .raise1]]
20222015 destroy .raise2
2023 sleep 500
20242016 list $result [winfo containing [winfo rootx .raise1] \
20252017 [winfo rooty .raise1]]
20262018 } {.raise2 .raise1}
20312023 lower .raise3 .raise1
20322024 set result [winfo containing 100 100]
20332025 destroy .raise1
2034 sleep 500
20352026 lappend result [winfo containing 100 100]
20362027 } {.raise1 .raise3}
20372028 test unixWm-51.5 {TkWmRestackToplevel procedure, basic tests} {unix nonPortable} {
20462037 set result [winfo containing [winfo rootx .raise1] \
20472038 [winfo rooty .raise1]]
20482039 destroy .raise1
2049 sleep 500
20502040 list $result [winfo containing [winfo rootx .raise2] \
20512041 [winfo rooty .raise2]]
20522042 } {.raise1 .raise3}
20612051 wm geometry .t2 +0+0
20622052 winfo containing 100 100
20632053 } {.t}
2064 test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} unix {
2054 test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} {unix failsOnXQuarz} {
20652055 foreach w {.t .t2 .t3} {
20662056 destroy $w
20672057 update
20692059 wm geometry $w +0+0
20702060 }
20712061 raise .t .t2
2072 sleep 2000
20732062 update
20742063 set result [list [winfo containing 100 100]]
20752064 lower .t3
2076 sleep 2000
20772065 lappend result [winfo containing 100 100]
20782066 } {.t3 .t}
20792067 test unixWm-51.8 {TkWmRestackToplevel procedure, overrideredirect windows} unix {
5151 frame .menu -relief raised -borderwidth 1
5252 message .msg -font {Times 18} -relief raised -width 4i \
5353 -borderwidth 1 -text "This application provides a collection of visual tests for the Tk toolkit. Each menu entry invokes a test, which displays information on the screen. You can then verify visually that the information is being displayed in the correct way. The tests under the \"Postscript\" menu exercise the Postscript-generation capabilities of canvas widgets."
54
54
5555 pack .menu -side top -fill x
5656 pack .msg -side bottom -expand yes -fill both
5757
6363 menubutton .menu.file -text "File" -menu .menu.file.m
6464 menu .menu.file.m
6565 .menu.file.m add command -label "Quit" -command end
66
66
6767 menubutton .menu.group1 -text "Group 1" -menu .menu.group1.m
6868 menu .menu.group1.m
6969 .menu.group1.m add command -label "Canvas arcs" -command {runTest arc.tcl}
7575 -command {runTest butGeom.tcl}
7676 .menu.group1.m add command -label "Label/button colors" \
7777 -command {runTest butGeom2.tcl}
78
78
7979 menubutton .menu.ps -text "Canvas Postscript" -menu .menu.ps.m
8080 menu .menu.ps.m
8181 .menu.ps.m add command -label "Rectangles and other graphics" \
8888 -command {runTest canvPsImg.tcl}
8989 .menu.ps.m add command -label "Arcs" \
9090 -command {runTest canvPsArc.tcl}
91
91
9292 pack .menu.file .menu.group1 .menu.ps -side left -padx 1m
93
93
9494 # Set up for keyboard-based menu traversal
95
95
9696 bind . <Any-FocusIn> {
9797 if {("%d" == "NotifyVirtual") && ("%m" == "NotifyNormal")} {
9898 focus .menu
254254 set y [then {
255255 Click cancel
256256 }]
257 # Note this also tests fix for
257 # Note this also tests fix for
258258 # https://core.tcl-lang.org/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
259259 # $x is expected to be empty
260260 append x $y
440440 nt testwinevent
441441 } -body {
442442 # case FILE_TYPES:
443
443
444444 start {tk_getSaveFile -filetypes {{"foo files" .foo FOOF}} -title Foo}
445445 # XXX - currently disabled for vista style dialogs because the file
446446 # types control has no control ID and we don't have a mechanism to
503503 test winDialog-5.12.2 {tk_getSaveFile: initial directory: ~user} -constraints {
504504 nt testwinevent
505505 } -body {
506
506
507507 # Note: this test will fail on Tcl versions 8.6.4 and earlier due
508508 # to a bug in file normalize for names of the form ~xxx that
509509 # returns the wrong dir on Windows. In particular (in Win8 at
590590 string equal $x [file join $dir testfile]
591591 } -result 1
592592
593 test winDialog-5.12.7 {tk_getOpenFile: initial directory: ~} -constraints {
593 test winDialog-5.12.7 {tk_getOpenFile: initial directory: ~} -setup {
594 # Ensure there's at least one file in the home directory in CI environments
595 set makeEmpty [expr {![llength [glob -nocomplain -type f -directory ~ *]]}]
596 if {$makeEmpty} {
597 for {set i 1} {$i < 1000} {incr i} {
598 # Technically a race condition...
599 set actualFilename [format "~/tkWinDialog5_12_7_%03d" $i]
600 if {![file exists $actualFilename]} break
601 }
602 close [open $actualFilename w]
603 }
604 } -constraints {
594605 nt testwinevent
595606 } -body {
596607 set fn [file tail [lindex [glob -types f ~/*] 0]]
602613 Click ok
603614 }
604615 string equal $x [file normalize [file join ~ $fn]]
616 } -cleanup {
617 if {$makeEmpty} {
618 file delete $actualFilename
619 }
605620 } -result 1
606621
607622 test winDialog-5.12.8 {tk_getOpenFile: initial directory: .} -constraints {
730745 nt testwinevent
731746 } -body {
732747 # case FILE_TITLE:
733
748
734749 start {tk_getOpenFile -title Narf}
735750 then {
736751 Click cancel
793808 nt testwinevent english
794809 } -body {
795810 # winCode = GetOpenFileName(&ofn);
796
811
797812 start {tk_getOpenFile -title Open}
798813 then {
799814 set x [GetText ok]
926941 } -body {
927942 # if (Tcl_TranslateFileName(interp, string,
928943 # &utfDirString) == NULL)
929
944
930945 tk_chooseDirectory -initialdir ~12x/455
931946 } -returnCodes error -result {user "12x" doesn't exist}
932947
33 # Many of these tests are visually oriented and cannot be checked
44 # programmatically (such as "does an underlined font appear to be
55 # underlined?"); these tests attempt to exercise the code in question,
6 # but there are no results that can be checked.
6 # but there are no results that can be checked.
77 #
88 # Copyright (c) 1996-1997 Sun Microsystems, Inc.
99 # Copyright (c) 1998-1999 by Scriptics Corporation.
140140 update
141141 set ax [winfo reqwidth .t.l]
142142 set ay [winfo reqheight .t.l]
143
143
144144 .t.l config -wrap 0 -text "000000"
145145 list [expr {[winfo reqwidth .t.l] eq 6*$ax}] \
146146 [expr {[winfo reqheight .t.l] eq $ay}]
159159 update
160160 set ax [winfo reqwidth .t.l]
161161 set ay [winfo reqheight .t.l]
162
162
163163 .t.l config -wrap 100000 -text "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
164164 list [expr {[winfo reqwidth .t.l] eq 256*$ax}] \
165165 [expr {[winfo reqheight .t.l] eq $ay}]
178178 update
179179 set ax [winfo reqwidth .t.l]
180180 set ay [winfo reqheight .t.l]
181
181
182182 .t.l config -wrap [expr {$ax*10}] -text "00000000"
183183 list [expr {[winfo reqwidth .t.l] eq 8*$ax}] \
184184 [expr {[winfo reqheight .t.l] eq $ay}]
197197 update
198198 set ax [winfo reqwidth .t.l]
199199 set ay [winfo reqheight .t.l]
200
200
201201 .t.l config -wrap [expr {$ax*6}] -text "00000000"
202202 list [expr {[winfo reqwidth .t.l] eq 6*$ax}] \
203203 [expr {[winfo reqheight .t.l] eq 2*$ay}]
233233 update
234234 set ax [winfo reqwidth .t.l]
235235 set ay [winfo reqheight .t.l]
236
236
237237 .t.l config -text "000000" -wrap 1
238238 list [expr {[winfo reqwidth .t.l] eq $ax}] \
239239 [expr {[winfo reqheight .t.l] eq 6*$ay}]
252252 update
253253 set ax [winfo reqwidth .t.l]
254254 set ay [winfo reqheight .t.l]
255
255
256256 .t.l config -wrap [expr {$ax*8}] -text "000000 0000"
257257 list [expr {[winfo reqwidth .t.l] eq 6*$ax}] \
258258 [expr {[winfo reqheight .t.l] eq 2*$ay}]
271271 update
272272 set ax [winfo reqwidth .t.l]
273273 set ay [winfo reqheight .t.l]
274
274
275275 .t.l config -wrap [expr {$ax*12}] -text "000000 0000000"
276276 list [expr {[winfo reqwidth .t.l] eq 7*$ax}] \
277277 [expr {[winfo reqheight .t.l] eq 2*$ay}]
290290 update
291291 set ax [winfo reqwidth .t.l]
292292 set ay [winfo reqheight .t.l]
293
293
294294 .t.l config -wrap [expr {$ax*12}] -text "000 00 00000"
295295 list [expr {[winfo reqwidth .t.l] eq 7*$ax}] \
296296 [expr {[winfo reqheight .t.l] eq 2*$ay}]
309309 update
310310 set ax [winfo reqwidth .t.l]
311311 set ay [winfo reqheight .t.l]
312
312
313313 .t.l config -wrap [expr {$ax*12}] -text "0000000000000000"
314314 list [expr {[winfo reqwidth .t.l] eq 12*$ax}] \
315315 [expr {[winfo reqheight .t.l] eq 2*$ay}]
326326 -text "0" -font systemfixed
327327 pack .t.l
328328 update
329
329
330330 set font [.t.l cget -font]
331331 .t.l config -font {{MS Sans Serif} 8} -text "W"
332332 set width [winfo reqwidth .t.l]
480480 "error 1"
481481 (menu invoke)}} {} {}}
482482
483
483
484484 # Can't test WM_MENUCHAR
485485
486486 test winMenu-11.4 {TkWinHandleMenuEvent - WM_MEASUREITEM} -constraints {
787787 .m1 add command -label foo -underline 0
788788 set tearoff [tk::TearOffMenu .m1 40 40]
789789 list [update] [destroy .m1]
790 } -result {{} {}}
790 } -result {{} {}}
791791
792792
793793 test winMenu-23.1 {Don't know how to test MenuKeyBindProc} -constraints {
13421342 .m1 add command -label four
13431343 .m1 add command -label five -columnbreak 1
13441344 .m1 add command -label six
1345 list [update idletasks] [destroy .m1]
1345 list [update idletasks] [destroy .m1]
13461346 } -result {{} {}}
13471347
13481348
66 # Copyright (c) 1998-1999 by Scriptics Corporation.
77 # All rights reserved.
88
9 package require tcltest 2.1
9 package require tcltest 2.2
1010 eval tcltest::configure $argv
1111 tcltest::loadTestedCommands
1212
473473 global winwm90done
474474 set winwm90done wait
475475 toplevel .t
476 } -body {
476 } -body {
477477 pack [button .t.b -text "Show" -command {winwm90proc1 .tx}]
478478 bind .t.b <Map> {bind %W <Map> {}; after idle {winwm90click %W}}
479479 after 5000 {set winwm90done timeout}
484484 rename winwm90$cmd {}
485485 }
486486 destroy .tx .t .sd
487 } -result {ok}
487 } -result ok
488488
489489 test winWm-9.1 "delayed activation of grabbed destroyed window" -constraints win -setup {
490490 proc winwm91click {w} {
518518 global winwm91done
519519 set winwm91done wait
520520 toplevel .t
521 } -body {
521 } -body {
522522 pack [button .t.b -text "Show" -command {winwm91proc1 .tx}]
523523 bind .t.b <Map> {bind %W <Map> {}; after idle {winwm91click %W}}
524524 after 5000 {set winwm91done timeout}
529529 rename winwm91$cmd {}
530530 }
531531 destroy .tx .t .sd
532 } -result {ok}
533
534 test winWm-9.2 "check wm forget for unmapped parent (#3205464,#2967911)" -setup {
532 } -result ok
533
534 test winWm-9.2 "check wm forget for unmapped parent (#3205464,#2967911)" -constraints failsOnUbuntu -setup {
535535 destroy .t
536536 toplevel .t
537537 set winwm92 {}
540540 } -body {
541541 pack .t.f.x
542542 pack .t.f
543 lappend aid [after 2000 {set ::winwm92 timeout}] [after 100 {
543 lappend aid [after 5000 {set ::winwm92 timeout}] [after 500 {
544544 wm manage .t.f
545545 wm iconify .t
546 lappend aid [after 100 {
546 lappend aid [after 500 {
547547 wm forget .t.f
548548 wm deiconify .t
549 lappend aid [after 100 {
549 lappend aid [after 500 {
550550 pack .t.f
551 lappend aid [after 100 {
551 lappend aid [after 500 {
552552 set ::winwm92 [expr {
553553 [winfo rooty .t.f.x] == 0 ? "failed" : "ok"}]}]
554554 }]
99 namespace import ::tcltest::*
1010 tcltest::configure {*}$argv
1111 tcltest::loadTestedCommands
12
13 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
14 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
1215
1316 # eatColors --
1417 # Creates a toplevel window and allocates enough colors in it to
290293 test winfo-9.3 {"winfo viewable" command} -body {
291294 winfo viewable .
292295 } -result {1}
293 test winfo-9.4 {"winfo viewable" command} -body {
296 test winfo-9.4 {"winfo viewable" command} -constraints failsOnUbuntu -body {
294297 wm iconify .
295298 winfo viewable .
296299 } -cleanup {
319322 } -cleanup {
320323 deleteWindows
321324 } -result {0 0}
322 test winfo-9.7 {"winfo viewable" command} -setup {
325 test winfo-9.7 {"winfo viewable" command} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
323326 deleteWindows
324327 } -body {
325328 frame .f1 -width 100 -height 100 -relief raised -bd 2
1010 # Window manager tests that only work on a specific platform should be placed
1111 # in unixWm.test or winWm.test.
1212
13 package require tcltest 2.1
13 package require tcltest 2.2
1414 eval tcltest::configure $argv
1515 tcltest::loadTestedCommands
1616
2626 update
2727 }
2828
29 testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
30 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
31
2932 # [raise] and [lower] may return before the window manager has completed the
3033 # operation. The raiseDelay procedure idles for a while to give the operation
3134 # a chance to complete.
3235 #
3336
3437 proc raiseDelay {} {
35 after 100; update
38 after 100;
39 update
40 update idletasks
3641 }
3742
3843 # How to carry out a small delay while processing events
804809 destroy .t2 .r.f
805810 } -result {can't iconify .t2: it is an embedded window}
806811
807 test wm-iconify-3.1 {iconify behavior} -body {
812 test wm-iconify-3.1 {iconify behavior} -constraints failsOnUbuntu -body {
808813 toplevel .t2
809814 wm geom .t2 -0+0
810 update
815 update idletasks
811816 set result [winfo ismapped .t2]
812817 wm iconify .t2
813 update
818 update idletasks
814819 lappend result [winfo ismapped .t2]
815820 } -cleanup {
816821 destroy .t2
14121417
14131418 deleteWindows
14141419
1415 test wm-stackorder-3.1 {unmapped toplevel} -body {
1420 test wm-stackorder-3.1 {unmapped toplevel} -constraints failsOnUbuntu -body {
14161421 toplevel .t1 ; update
14171422 toplevel .t2 ; update
14181423 wm iconify .t1
15221527 destroy .t
15231528 } -result {.t .}
15241529 test wm-stackorder-5.2 {A normal toplevel can't be raised above an \
1525 overrideredirect toplevel on unix} -constraints x11 -body {
1526 toplevel .t
1527 tkwait visibility .t
1530 overrideredirect toplevel on unix} -constraints {x11 failsOnUbuntu failsOnXQuarz} -body {
1531 toplevel .t
1532 tkwait visibility .t
15281533 wm overrideredirect .t 1
15291534 raise .
15301535 update
15361541 test wm-stackorder-5.2.1 {A normal toplevel can be raised above an \
15371542 overrideredirect toplevel on macOS or win} -constraints aquaOrWin32 -body {
15381543 toplevel .t
1539 tkwait visibility .t
1544 tkwait visibility .t
15401545 wm overrideredirect .t 1
15411546 raise .
15421547 update
15461551 destroy .t
15471552 } -result 1
15481553 test wm-stackorder-5.3 {An overrideredirect window\
1549 can be explicitly lowered} -body {
1550 toplevel .t
1551 tkwait visibility .t
1554 can be explicitly lowered} -constraints failsOnXQuarz -body {
1555 toplevel .t
1556 tkwait visibility .t
15521557 wm overrideredirect .t 1
15531558 lower .t
15541559 update
16051610 } -result {bad window path name "foo"}
16061611 deleteWindows
16071612 test wm-transient-1.4 {usage} -returnCodes error -body {
1608 toplevel .master
1613 toplevel .top
16091614 toplevel .subject
1610 wm transient .subject .master
1615 wm transient .subject .top
16111616 wm iconify .subject
16121617 } -cleanup {
16131618 deleteWindows
16311636 deleteWindows
16321637 } -result {can't make ".icon" a master: it is an icon for .top}
16331638 test wm-transient-1.7 {usage} -returnCodes error -body {
1634 toplevel .master
1635 wm transient .master .master
1636 } -cleanup {
1637 deleteWindows
1638 } -result {setting ".master" as master creates a transient/master cycle}
1639 toplevel .top
1640 wm transient .top .top
1641 } -cleanup {
1642 deleteWindows
1643 } -result {setting ".top" as master creates a transient/master cycle}
16391644 test wm-transient-1.8 {usage} -returnCodes error -body {
16401645 toplevel .t1
16411646 toplevel .t2
16471652 deleteWindows
16481653 } -result {setting ".t3" as master creates a transient/master cycle}
16491654 test wm-transient-1.9 {usage} -returnCodes error -body {
1650 toplevel .master
1651 frame .master.f
1652 wm transient .master .master.f
1653 } -cleanup {
1654 deleteWindows
1655 } -result {setting ".master" as master creates a transient/master cycle}
1656
1657 test wm-transient-2.1 {basic get/set of master} -setup {
1655 toplevel .top
1656 frame .top.f
1657 wm transient .top .top.f
1658 } -cleanup {
1659 deleteWindows
1660 } -result {setting ".top" as master creates a transient/master cycle}
1661
1662 test wm-transient-2.1 {basic get/set of toplevel} -setup {
16581663 set results [list]
16591664 } -body {
1660 toplevel .master
1665 toplevel .top
16611666 toplevel .subject
16621667 lappend results [wm transient .subject]
1663 wm transient .subject .master
1668 wm transient .subject .top
16641669 lappend results [wm transient .subject]
16651670 wm transient .subject {}
16661671 lappend results [wm transient .subject]
16671672 } -cleanup {
16681673 deleteWindows
1669 } -result {{} .master {}}
1670 test wm-transient-2.2 {first toplevel parent of non-toplevel master is used} -body {
1671 toplevel .master
1672 frame .master.f
1674 } -result {{} .top {}}
1675 test wm-transient-2.2 {first toplevel parent of non-toplevel container window is used} -body {
1676 toplevel .top
1677 frame .top.f
16731678 toplevel .subject
1674 wm transient .subject .master.f
1679 wm transient .subject .top.f
16751680 wm transient .subject
16761681 } -cleanup {
16771682 deleteWindows
1678 } -result {.master}
1683 } -result {.top}
16791684
16801685 test wm-transient-3.1 {transient toplevel is withdrawn
1681 when mapped if master is withdrawn} -body {
1682 toplevel .master
1683 wm withdraw .master
1686 when mapped if toplevel is withdrawn} -body {
1687 toplevel .top
1688 wm withdraw .top
16841689 update
16851690 toplevel .subject
1686 wm transient .subject .master
1691 wm transient .subject .top
16871692 update
16881693 list [wm state .subject] [winfo ismapped .subject]
16891694 } -cleanup {
16901695 deleteWindows
16911696 } -result {withdrawn 0}
16921697 test wm-transient-3.2 {already mapped transient toplevel
1693 takes on withdrawn state of master} -body {
1694 toplevel .master
1695 wm withdraw .master
1698 takes on withdrawn state of toplevel} -body {
1699 toplevel .top
1700 wm withdraw .top
16961701 update
16971702 toplevel .subject
16981703 update
1699 wm transient .subject .master
1704 wm transient .subject .top
17001705 update
17011706 list [wm state .subject] [winfo ismapped .subject]
17021707 } -cleanup {
17031708 deleteWindows
17041709 } -result {withdrawn 0}
1705 test wm-transient-3.3 {withdraw/deiconify on the master
1710 test wm-transient-3.3 {withdraw/deiconify on the toplevel
17061711 also does a withdraw/deiconify on the transient} -setup {
17071712 set results [list]
17081713 } -body {
1709 toplevel .master
1714 toplevel .top
17101715 toplevel .subject
17111716 update
1712 wm transient .subject .master
1713 wm withdraw .master
1717 wm transient .subject .top
1718 wm withdraw .top
17141719 update
17151720 lappend results [wm state .subject] [winfo ismapped .subject]
1716 wm deiconify .master
1721 wm deiconify .top
17171722 update
17181723 lappend results [wm state .subject] [winfo ismapped .subject]
17191724 } -cleanup {
17211726 } -result {withdrawn 0 normal 1}
17221727
17231728 test wm-transient-4.1 {transient toplevel is withdrawn
1724 when mapped if master is iconic} -body {
1725 toplevel .master
1726 wm iconify .master
1729 when mapped if toplevel is iconic} -constraints {failsOnUbuntu failsOnXQuarz} -body {
1730 toplevel .top
1731 wm iconify .top
17271732 update
17281733 toplevel .subject
1729 wm transient .subject .master
1734 wm transient .subject .top
17301735 update
17311736 list [wm state .subject] [winfo ismapped .subject]
17321737 } -cleanup {
17331738 deleteWindows
17341739 } -result {withdrawn 0}
17351740 test wm-transient-4.2 {already mapped transient toplevel
1736 is withdrawn if master is iconic} -body {
1737 toplevel .master
1741 is withdrawn if toplevel is iconic} -constraints failsOnUbuntu -body {
1742 toplevel .top
17381743 raiseDelay
1739 wm iconify .master
1740 update
1744 wm iconify .top
1745 update idletasks
17411746 toplevel .subject
1742 update
1743 wm transient .subject .master
1744 update
1747 update idletasks
1748 wm transient .subject .top
1749 update idletasks
17451750 list [wm state .subject] [winfo ismapped .subject]
17461751 } -cleanup {
17471752 deleteWindows
17481753 } -result {withdrawn 0}
1749 test wm-transient-4.3 {iconify/deiconify on the master
1750 does a withdraw/deiconify on the transient} -setup {
1754 test wm-transient-4.3 {iconify/deiconify on the toplevel
1755 does a withdraw/deiconify on the transient} -constraints failsOnUbuntu -setup {
17511756 set results [list]
17521757 } -body {
1753 toplevel .master
1758 toplevel .top
17541759 toplevel .subject
1755 update
1756 wm transient .subject .master
1757 wm iconify .master
1758 update
1760 update idletasks
1761 wm transient .subject .top
1762 wm iconify .top
1763 update idletasks
17591764 lappend results [wm state .subject] [winfo ismapped .subject]
1760 wm deiconify .master
1761 update
1765 wm deiconify .top
1766 update idletasks
17621767 lappend results [wm state .subject] [winfo ismapped .subject]
17631768 } -cleanup {
17641769 deleteWindows
17681773 cause the map/unmap binding to be deleted} -setup {
17691774 set results [list]
17701775 } -body {
1771 toplevel .master
1776 toplevel .top
17721777 toplevel .subject
17731778 update
1774 wm transient .subject .master
1779 wm transient .subject .top
17751780 # Expect a bad window path error here
17761781 lappend results [catch {wm transient .subject .bad}]
1777 wm withdraw .master
1782 wm withdraw .top
17781783 update
17791784 lappend results [wm state .subject]
1780 wm deiconify .master
1785 wm deiconify .top
17811786 update
17821787 lappend results [wm state .subject]
17831788 } -cleanup {
17841789 deleteWindows
17851790 } -result {1 withdrawn normal}
1786 test wm-transient-5.2 {remove transient property when master
1791 test wm-transient-5.2 {remove transient property when toplevel
17871792 is destroyed} -body {
1788 toplevel .master
1793 toplevel .top
17891794 toplevel .subject
1790 wm transient .subject .master
1791 update
1792 destroy .master
1795 wm transient .subject .top
1796 update
1797 destroy .top
17931798 update
17941799 wm transient .subject
17951800 } -cleanup {
17961801 deleteWindows
17971802 } -result {}
17981803 test wm-transient-5.3 {remove transient property from window
1799 that had never been mapped when master is destroyed} -body {
1800 toplevel .master
1804 that had never been mapped when toplevel is destroyed} -body {
1805 toplevel .top
18011806 toplevel .subject
1802 wm transient .subject .master
1803 destroy .master
1807 wm transient .subject .top
1808 destroy .top
18041809 wm transient .subject
18051810 } -cleanup {
18061811 deleteWindows
18071812 } -result {}
18081813
18091814 test wm-transient-6.1 {a withdrawn transient does not track
1810 state changes in the master} -body {
1811 toplevel .master
1815 state changes in the toplevel} -body {
1816 toplevel .top
18121817 toplevel .subject
18131818 update
1814 wm transient .subject .master
1819 wm transient .subject .top
18151820 wm withdraw .subject
1816 wm withdraw .master
1817 wm deiconify .master
1821 wm withdraw .top
1822 wm deiconify .top
18181823 # idle handler should not map the transient
18191824 update
18201825 wm state .subject
18221827 deleteWindows
18231828 } -result {withdrawn}
18241829 test wm-transient-6.2 {a withdrawn transient does not track
1825 state changes in the master} -setup {
1830 state changes in the toplevel} -setup {
18261831 set results [list]
18271832 } -body {
1828 toplevel .master
1833 toplevel .top
18291834 toplevel .subject
18301835 update
1831 wm transient .subject .master
1836 wm transient .subject .top
18321837 wm withdraw .subject
1833 wm withdraw .master
1834 wm deiconify .master
1838 wm withdraw .top
1839 wm deiconify .top
18351840 # idle handler should not map the transient
18361841 update
18371842 lappend results [wm state .subject]
18381843 wm deiconify .subject
18391844 lappend results [wm state .subject]
1840 wm withdraw .master
1845 wm withdraw .top
18411846 lappend results [wm state .subject]
1842 wm deiconify .master
1847 wm deiconify .top
18431848 # idle handler should map transient
18441849 update
18451850 lappend results [wm state .subject]
18471852 deleteWindows
18481853 } -result {withdrawn normal withdrawn normal}
18491854 test wm-transient-6.3 {a withdrawn transient does not track
1850 state changes in the master} -body {
1851 toplevel .master
1855 state changes in the toplevel} -body {
1856 toplevel .top
18521857 toplevel .subject
18531858 update
18541859 # withdraw before making window a transient
18551860 wm withdraw .subject
1856 wm transient .subject .master
1857 wm withdraw .master
1858 wm deiconify .master
1861 wm transient .subject .top
1862 wm withdraw .top
1863 wm deiconify .top
18591864 # idle handler should not map the transient
18601865 update
18611866 wm state .subject
18631868 deleteWindows
18641869 } -result {withdrawn}
18651870
1866 # wm-transient-7.*: See SF Tk Bug #592201 "wm transient fails with two masters"
1871 # wm-transient-7.*: See SF Tk Bug #592201 "wm transient fails with two toplevels"
18671872 # wm-transient-7.3 through 7.5 all caused panics on Unix in Tk 8.4b1.
18681873 # 7.1 and 7.2 added to catch (potential) future errors.
18691874 #
18771882 } -cleanup {
18781883 deleteWindows
18791884 }
1880 test wm-transient-7.2 {Destroying master} -body {
1881 toplevel .t
1885 test wm-transient-7.2 {Destroying toplevel} -body {
1886 toplevel .top
18821887 toplevel .transient
1883 wm transient .transient .t
1884 destroy .t
1888 wm transient .transient .top
1889 destroy .top
18851890 wm transient .transient
18861891 } -cleanup {
18871892 deleteWindows
18881893 } -result {}
1889 test wm-transient-7.3 {Reassign transient, destroy old master} -body {
1894 test wm-transient-7.3 {Reassign transient, destroy old toplevel} -body {
18901895 toplevel .t1
18911896 toplevel .t2
18921897 toplevel .transient
18981903 } -cleanup {
18991904 deleteWindows
19001905 }
1901 test wm-transient-7.4 {Reassign transient, destroy new master} -body {
1906 test wm-transient-7.4 {Reassign transient, destroy new toplevel} -body {
19021907 toplevel .t1
19031908 toplevel .t2
19041909 toplevel .transient
19231928 deleteWindows
19241929 }
19251930
1926 test wm-transient-8.1 {transient to withdrawn window, Bug 1163496} -setup {
1931 test wm-transient-8.1 {transient to withdrawn window, Bug 1163496} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
19271932 deleteWindows
19281933 set result {}
19291934 } -body {
1930 # Verifies that transients stay on top of their masters, even if they were
1931 # made transients when those masters were withdrawn.
1935 # Verifies that transients stay on top of their toplevels, even if they were
1936 # made transients when those toplevels were withdrawn.
19321937 toplevel .t1; wm withdraw .t1; update
19331938 toplevel .t2; wm transient .t2 .t1; update
19341939 lappend result [winfo ismapped .t1] [winfo ismapped .t2]
20002005 } -cleanup {
20012006 deleteWindows
20022007 } -result {iconic}
2003 test wm-state-2.8 {state change after map} -body {
2008 test wm-state-2.8 {state change after map} -constraints failsOnUbuntu -body {
20042009 toplevel .t
20052010 update
20062011 wm state .t iconic
20082013 } -cleanup {
20092014 deleteWindows
20102015 } -result {iconic}
2011 test wm-state-2.9 {state change after map} -body {
2016 test wm-state-2.9 {state change after map} -constraints failsOnUbuntu -body {
20122017 toplevel .t
20132018 update
20142019 wm iconify .t
23092314 test wm-forget-2 {bug [e9112ef96e] - [wm forget] doesn't completely} -setup {
23102315 catch {destroy .l .f.b .f}
23112316 set res {}
2317 if {[tk windowingsystem] == "aqua"} {
2318 proc doUpdate {} {update idletasks}
2319 } else {
2320 proc doUpdate {} {update}
2321 }
23122322 } -body {
23132323 label .l -text "Top Dot"
23142324 frame .f
23162326 pack .l -side top
23172327 pack .f.b
23182328 pack .f -side bottom
2319 update
23202329 set res [winfo manager .f]
23212330 pack forget .f
2322 update
2331 doUpdate
23232332 lappend res [winfo manager .f]
23242333 wm manage .f
2325 update
2334 doUpdate
23262335 lappend res [winfo manager .f]
23272336 wm forget .f
2328 update
2337 doUpdate
23292338 lappend res [winfo manager .f]
23302339 } -cleanup {
23312340 destroy .l .f.b .f
100100 # The directory containing the Tcl sources and headers appropriate
101101 # for this version of Tk ("srcdir" will be replaced or has already
102102 # been replaced by the configure script):
103 TCL_GENERIC_DIR = @TCL_SRC_DIR@/generic
103 TCLDIR = @TCL_SRC_DIR@
104 TCL_GENERIC_DIR = $(TCLDIR)/generic
104105
105106 # The directory containing the platform specific Tcl sources and headers
106107 # appropriate for this version of Tk:
107 TCL_PLATFORM_DIR = @TCL_SRC_DIR@/unix
108 TCL_PLATFORM_DIR = $(TCLDIR)/unix
108109
109110 # The directory containing the Tcl library archive file appropriate
110111 # for this version of Tk:
310311 TTK_DIR = $(GENERIC_DIR)/ttk
311312 UNIX_DIR = $(TOP_DIR)/unix
312313 BMAP_DIR = $(TOP_DIR)/bitmaps
313 TOOL_DIR = @TCL_SRC_DIR@/tools
314 TOOL_DIR = $(TCLDIR)/tools
314315 TEST_DIR = $(TOP_DIR)/tests
315316 MAC_OSX_DIR = $(TOP_DIR)/macosx
316317 XLIB_DIR = $(TOP_DIR)/xlib
327328
328329 CC = @CC@
329330
330 CC_SWITCHES_NO_STUBS = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
331 -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} -I${TCL_GENERIC_DIR} \
332 -I${TCL_PLATFORM_DIR} ${@TK_WINDOWINGSYSTEM@_INCLUDES} ${AC_FLAGS} \
331 CC_SWITCHES_NO_STUBS = -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
332 ${@TK_WINDOWINGSYSTEM@_INCLUDES} ${CFLAGS} ${CFLAGS_WARNING} \
333 ${SHLIB_CFLAGS} -I${TCL_GENERIC_DIR} -I${TCL_PLATFORM_DIR} ${AC_FLAGS} \
333334 ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
334335 ${NO_DEPRECATED_FLAGS} @EXTRA_CC_SWITCHES@
335336
337338
338339 APP_CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @EXTRA_APP_CC_SWITCHES@
339340
340 DEPEND_SWITCHES = ${CFLAGS} -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
341 -I${TCL_GENERIC_DIR} -I${TCL_PLATFORM_DIR} ${@TK_WINDOWINGSYSTEM@_INCLUDES} \
342 ${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} \
343 ${KEYSYM_FLAGS} @EXTRA_CC_SWITCHES@
341 DEPEND_SWITCHES = -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
342 ${@TK_WINDOWINGSYSTEM@_INCLUDES} ${CFLAGS} -I${TCL_GENERIC_DIR} \
343 -I${TCL_PLATFORM_DIR} ${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} \
344 ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} @EXTRA_CC_SWITCHES@
344345
345346 WISH_OBJS = tkAppInit.o
346347
569570 SHELL_ENV = \
570571 @LD_LIBRARY_PATH_VAR@="`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}"; \
571572 export @LD_LIBRARY_PATH_VAR@; \
572 TCL_LIBRARY=@TCL_SRC_DIR@/library; export TCL_LIBRARY; \
573 TCL_LIBRARY=$(TCLDIR)/library; export TCL_LIBRARY; \
573574 TK_LIBRARY=@TK_SRC_DIR@/library; export TK_LIBRARY;
574575
575576 all: binaries libraries doc
579580 libraries:
580581
581582 $(TOP_DIR)/doc/man.macros:
582 $(INSTALL_DATA) @TCL_SRC_DIR@/doc/man.macros $(TOP_DIR)/doc/man.macros
583 $(INSTALL_DATA) $(TCLDIR)/doc/man.macros $(TOP_DIR)/doc/man.macros
583584
584585 doc: $(TOP_DIR)/doc/man.macros
585586
632633 $(MAKE) tktest-real LIB_RUNTIME_DIR="`pwd`:$(TCL_BIN_DIR)"
633634
634635 tktest-real: ${TK_STUB_LIB_FILE}
635 ${CC} ${CFLAGS} ${LDFLAGS} $(TKTEST_OBJS) ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} @TK_BUILD_LIB_SPEC@ \
636 $(WISH_LIBS) $(CC_SEARCH_FLAGS) -o $(TKTEST_EXE)
636 ${CC} ${CFLAGS} ${LDFLAGS} $(TKTEST_OBJS) @TK_BUILD_LIB_SPEC@ $(WISH_LIBS) \
637 ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} $(CC_SEARCH_FLAGS) -o $(TKTEST_EXE)
637638
638639 # # FIXME: This xttest rule seems to be broken in a number of ways. It should
639640 # # use CC_SEARCH_FLAGS, it does not include the shared lib location logic from
685686 # This target can be used to run wish inside either gdb or insight
686687 gdb: ${WISH_EXE}
687688 @echo "set env @LD_LIBRARY_PATH_VAR@=\"`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}\"" > gdb.run
688 @echo "set env TCL_LIBRARY=@TCL_SRC_DIR@/library" >> gdb.run
689 @echo "set env TCL_LIBRARY=$(TCLDIR)/library" >> gdb.run
689690 @echo "set env TK_LIBRARY=@TK_SRC_DIR@/library" >> gdb.run
690691 gdb ./${WISH_EXE} --command=gdb.run
691692 rm gdb.run
747748 @if test -f "tk${MAJOR_VERSION}${MINOR_VERSION}.dll"; then \
748749 $(INSTALL_LIBRARY) "tk${MAJOR_VERSION}${MINOR_VERSION}.dll" "$(DLL_INSTALL_DIR)";\
749750 chmod 555 "$(DLL_INSTALL_DIR)/tk${MAJOR_VERSION}${MINOR_VERSION}.dll";\
750 $(INSTALL_LIBRARY) "../win/libtk${MAJOR_VERSION}${MINOR_VERSION}.a" "$(LIB_INSTALL_DIR)";\
751 chmod 555 "$(LIB_INSTALL_DIR)/libtk${MAJOR_VERSION}${MINOR_VERSION}.a";\
751 $(INSTALL_LIBRARY) "../win/libtk${MAJOR_VERSION}${MINOR_VERSION}.dll.a" "$(LIB_INSTALL_DIR)";\
752 chmod 555 "$(LIB_INSTALL_DIR)/libtk${MAJOR_VERSION}${MINOR_VERSION}.dll.a";\
752753 fi
753754 @echo "Installing ${WISH_EXE} as $(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}"
754755 @$(INSTALL_PROGRAM) ${WISH_EXE} "$(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}"
760761 fi
761762 @EXTRA_INSTALL_BINARIES@
762763 @echo "Installing pkg-config file to $(LIB_INSTALL_DIR)/pkgconfig/"
763 @$(INSTALL_DATA_DIR) $(LIB_INSTALL_DIR)/pkgconfig
764 @$(INSTALL_DATA) tk.pc $(LIB_INSTALL_DIR)/pkgconfig/tk.pc
764 @$(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/pkgconfig"
765 @$(INSTALL_DATA) tk.pc "$(LIB_INSTALL_DIR)/pkgconfig/tk.pc"
765766
766767 install-libraries: libraries
767768 @for i in "$(SCRIPT_INSTALL_DIR)" "$(SCRIPT_INSTALL_DIR)/images" \
12041205 $(CC) -c $(CC_SWITCHES) $(XFT_CFLAGS) $(UNIX_DIR)/tkUnixRFont.c
12051206
12061207 tkUnixInit.o: $(UNIX_DIR)/tkUnixInit.c tkConfig.sh
1207 $(CC) -c $(CC_SWITCHES) -DTK_LIBRARY=\"${TK_LIBRARY}\" \
1208 $(CC) -c $(CC_SWITCHES) \
12081209 $(UNIX_DIR)/tkUnixInit.c
12091210
12101211 tkUnixKey.o: $(UNIX_DIR)/tkUnixKey.c
12801281 $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXImage.c
12811282
12821283 tkMacOSXInit.o: $(MAC_OSX_DIR)/tkMacOSXInit.c tkConfig.sh
1283 $(CC) -c $(CC_SWITCHES) -DTK_LIBRARY=\"${TK_LIBRARY}\" \
1284 $(CC) -c $(CC_SWITCHES) \
12841285 $(MAC_OSX_DIR)/tkMacOSXInit.c
12851286
12861287 tkMacOSXKeyboard.o: $(MAC_OSX_DIR)/tkMacOSXKeyboard.c
15291530
15301531 #
15311532 # Target to create a proper Tk distribution from information in the
1532 # master source directory. DISTDIR must be defined to indicate where
1533 # source directory. DISTDIR must be defined to indicate where
15331534 # to put the distribution. DISTDIR must be an absolute path name.
15341535 #
15351536
15371538 DISTNAME = tk${VERSION}${PATCH_LEVEL}
15381539 ZIPNAME = tk${MAJOR_VERSION}${MINOR_VERSION}${PATCH_LEVEL}-src.zip
15391540 DISTDIR = $(DISTROOT)/$(DISTNAME)
1540 TCLDIR = @TCL_SRC_DIR@
15411541 $(UNIX_DIR)/configure: $(UNIX_DIR)/configure.in $(UNIX_DIR)/tcl.m4 \
15421542 $(UNIX_DIR)/aclocal.m4
15431543 cd $(UNIX_DIR); autoconf
15461546 $(UNIX_DIR)/tkConfig.h.in: $(MAC_OSX_DIR)/configure
15471547 cd $(MAC_OSX_DIR); autoheader; touch $@
15481548
1549 dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure genstubs
1549 $(TOP_DIR)/manifest.uuid:
1550 printf "git." >$(TOP_DIR)/manifest.uuid
1551 git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid
1552
1553 dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure $(TOP_DIR)/doc/man.macros $(TOP_DIR)/manifest.uuid
15501554 rm -rf $(DISTDIR)
15511555 mkdir -p $(DISTDIR)/unix
1556 cp -p $(TOP_DIR)/manifest.uuid $(DISTDIR)
15521557 cp -p $(UNIX_DIR)/*.c $(UNIX_DIR)/*.h $(DISTDIR)/unix
15531558 cp $(TOP_DIR)/license.terms $(UNIX_DIR)/Makefile.in $(DISTDIR)/unix
15541559 chmod 664 $(DISTDIR)/unix/Makefile.in
15551560 cp $(UNIX_DIR)/configure $(UNIX_DIR)/configure.in $(UNIX_DIR)/tk.spec \
15561561 $(UNIX_DIR)/aclocal.m4 $(UNIX_DIR)/tcl.m4 \
1557 $(UNIX_DIR)/tkConfig.sh.in $(TCLDIR)/unix/install-sh \
1562 $(UNIX_DIR)/tkConfig.sh.in $(UNIX_DIR)/install-sh \
15581563 $(UNIX_DIR)/README $(UNIX_DIR)/installManPage \
15591564 $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(DISTDIR)/unix
1560 chmod 775 $(DISTDIR)/unix/configure $(DISTDIR)/unix/configure.in
1565 chmod 775 $(DISTDIR)/unix/configure
15611566 mkdir $(DISTDIR)/bitmaps
15621567 @(cd $(TOP_DIR); for i in bitmaps/* ; do \
15631568 if [ -f $$i ] ; then \
16071612 $(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \
16081613 $(DISTDIR)/macosx/Tk.xcodeproj
16091614 mkdir $(DISTDIR)/compat
1610 cp -p $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \
1611 $(TCLDIR)/compat/stdlib.h \
1615 cp -p $(TOP_DIR)/license.terms $(TOP_DIR)/compat/unistd.h \
1616 $(TOP_DIR)/compat/stdlib.h \
16121617 $(DISTDIR)/compat
16131618 mkdir $(DISTDIR)/xlib
16141619 cp -p $(XLIB_DIR)/*.[ch] $(DISTDIR)/xlib
16551660 done;)
16561661 mkdir $(DISTDIR)/doc
16571662 cp -p $(TOP_DIR)/license.terms $(TOP_DIR)/doc/*.[13n] \
1658 $(TCLDIR)/doc/man.macros $(DISTDIR)/doc
1663 $(TOP_DIR)/doc/man.macros $(DISTDIR)/doc
16591664 mkdir $(DISTDIR)/tests
16601665 cp -p $(TOP_DIR)/license.terms $(TEST_DIR)/*.{test,tcl} \
16611666 $(TEST_DIR)/README $(TEST_DIR)/*.{gif,png,ppm,xbm} \
16621667 $(TEST_DIR)/option.file* $(DISTDIR)/tests
16631668 mkdir $(DISTDIR)/tests/ttk
16641669 cp -p $(TEST_DIR)/ttk/*.{test,tcl} $(DISTDIR)/tests/ttk
1670 cp -p $(TOP_DIR)/.travis.yml $(DISTDIR)
1671 mkdir -p $(DISTDIR)/.github/workflows
1672 cp -p $(TOP_DIR)/.github/workflows/*.yml $(DISTDIR)/.github/workflows
16651673
16661674 alldist: dist
16671675 rm -f $(DISTROOT)/$(DISTNAME)-src.tar.gz $(DISTROOT)/$(ZIPNAME)
13371337 TK_VERSION=8.6
13381338 TK_MAJOR_VERSION=8
13391339 TK_MINOR_VERSION=6
1340 TK_PATCH_LEVEL=".10"
1340 TK_PATCH_LEVEL=".11"
13411341 VERSION=${TK_VERSION}
13421342 LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
13431343
14851485 echo "$as_me:$LINENO: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
14861486 echo "${ECHO_T}could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6
14871487 fi
1488
1489 # eval is required to do the TCL_DBGX substitution
1490 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
1491 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
14921488
14931489 # If the TCL_BIN_DIR is the build directory (not the install directory),
14941490 # then set the common variable name to the value of the build variables.
15231519 esac
15241520 fi
15251521
1526 # eval is required to do the TCL_DBGX substitution
1527 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
1528 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
1529 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
1530 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
1531
15321522
15331523
15341524
30583048 cat >>conftest.$ac_ext <<_ACEOF
30593049 /* end confdefs.h. */
30603050 #include <ctype.h>
3051 #include <stdlib.h>
30613052 #if ((' ' & 0x0FF) == 0x020)
30623053 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
30633054 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
40284019 else
40294020 tcl_ok=yes
40304021 fi;
4031
4032 if test "${enable_shared+set}" = set; then
4033 enableval="$enable_shared"
4034 tcl_ok=$enableval
4035 else
4036 tcl_ok=yes
4037 fi
4038
40394022 if test "$tcl_ok" = "yes" ; then
40404023 echo "$as_me:$LINENO: result: shared" >&5
40414024 echo "${ECHO_T}shared" >&6
44014384 if test "$GCC" = yes; then
44024385
44034386 CFLAGS_OPTIMIZE=-O2
4404 CFLAGS_WARNING="-Wall"
4387 CFLAGS_WARNING="-Wall -Wpointer-arith"
44054388
44064389 else
44074390
46924675 CC_SEARCH_FLAGS=""
46934676 LD_SEARCH_FLAGS=""
46944677 ;;
4695 CYGWIN_*|MINGW32*)
4678 CYGWIN_*|MINGW32_*|MSYS_*)
46964679 SHLIB_CFLAGS=""
46974680 SHLIB_LD='${CC} -shared'
46984681 SHLIB_SUFFIX=".dll"
47034686 CC_SEARCH_FLAGS=""
47044687 LD_SEARCH_FLAGS=""
47054688 TCL_NEEDS_EXP_FILE=1
4706 TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
4689 TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
47074690 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a"
47084691 echo "$as_me:$LINENO: checking for Cygwin version of gcc" >&5
47094692 echo $ECHO_N "checking for Cygwin version of gcc... $ECHO_C" >&6
50044987 SHLIB_LD='${CC} -shared'
50054988 if test $doRpath = yes; then
50064989
5007 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
4990 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
50084991 fi
50094992
50104993 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
51285111
51295112 if test $doRpath = yes; then
51305113
5131 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5114 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
51325115 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
51335116 fi
51345117
51495132
51505133 if test $doRpath = yes; then
51515134
5152 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5135 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
51535136 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
51545137 fi
51555138
51905173
51915174 if test $doRpath = yes; then
51925175
5193 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5176 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
51945177 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
51955178 fi
51965179
52335216 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
52345217 if test $doRpath = yes; then
52355218
5236 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5219 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
52375220 fi
52385221
52395222 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
53335316 LD_FLAGS="-Wl,--export-dynamic"
53345317 if test $doRpath = yes; then
53355318
5336 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5337 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5319 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
5320 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
53385321 fi
53395322
53405323 ;;
53755358 DL_LIBS=""
53765359 if test $doRpath = yes; then
53775360
5378 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5361 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
53795362 fi
53805363
53815364 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
54055388 LDFLAGS="$LDFLAGS -export-dynamic"
54065389 if test $doRpath = yes; then
54075390
5408 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5391 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
54095392 fi
54105393
54115394 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
54275410 SHLIB_SUFFIX=".so"
54285411 DL_OBJS="tclLoadDl.o"
54295412 DL_LIBS=""
5430 LDFLAGS=""
54315413 if test $doRpath = yes; then
54325414
5433 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5434 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
5415 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
5416 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
54355417 fi
54365418
54375419 if test "${TCL_THREADS}" = "1"; then
57565738 #define MODULE_SCOPE __private_extern__
57575739 _ACEOF
57585740
5741 tcl_cv_cc_visibility_hidden=yes
57595742
57605743 fi
57615744
60196002 DL_LIBS=""
60206003 if test $doRpath = yes; then
60216004
6022 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
6005 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
60236006 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
60246007 fi
60256008
66186601 case $system in
66196602 AIX-*) ;;
66206603 BSD/OS*) ;;
6621 CYGWIN_*|MINGW32_*) ;;
6604 CYGWIN_*|MINGW32_*|MSYS_*) ;;
66226605 IRIX*) ;;
66236606 NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
66246607 Darwin-*) ;;
66546637 if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""; then
66556638
66566639 LIB_SUFFIX=${SHARED_LIB_SUFFIX}
6657 MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
6640 MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
66586641 if test "${SHLIB_SUFFIX}" = ".dll"; then
66596642
66606643 INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
68306813 tcl_ok=no
68316814 fi;
68326815 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
6833 DBGX=""
68346816 if test "$tcl_ok" = "no"; then
68356817 CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
68366818 LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
88158797 int
88168798 main ()
88178799 {
8818 struct passwd pwd; pwd.pw_gecos;
8800 struct passwd pwd; (void)pwd.pw_gecos;
88198801 ;
88208802 return 0;
88218803 }
1099010972 echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000'
1099110973 TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist'
1099210974 EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist'
10975 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html'
10976 if test "${SHARED_BUILD}" = "0"; then
10977 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -ObjC'
10978 fi
1099310979 EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic'
10994 ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in"
10980 ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in"
1099510981
1099610982 for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done
1099710983 TK_YEAR="`date +%Y`"
1102711013 EXTRA_INSTALL="install-private-headers html-tk"
1102811014 EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
1102911015 EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
11016 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"'
1103011017 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
1103111018 if test $tk_aqua = yes; then
1103211019 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
1103611023 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
1103711024 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
1103811025 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
11026 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"'
1103911027 fi
1104011028 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
1104111029 # Don't use AC_DEFINE for the following as the framework version define
1170811696 # Handling of arguments.
1170911697 "Tk-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../macosx/Tk-Info.plist.in" ;;
1171011698 "Wish-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../macosx/Wish-Info.plist.in" ;;
11699 "Credits.html" ) CONFIG_FILES="$CONFIG_FILES Credits.html:../macosx/Credits.html.in" ;;
1171111700 "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile:../unix/Makefile.in" ;;
1171211701 "tkConfig.sh" ) CONFIG_FILES="$CONFIG_FILES tkConfig.sh:../unix/tkConfig.sh.in" ;;
1171311702 "tk.pc" ) CONFIG_FILES="$CONFIG_FILES tk.pc:../unix/tk.pc.in" ;;
2424 TK_VERSION=8.6
2525 TK_MAJOR_VERSION=8
2626 TK_MINOR_VERSION=6
27 TK_PATCH_LEVEL=".10"
27 TK_PATCH_LEVEL=".11"
2828 VERSION=${TK_VERSION}
2929 LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
3030
243243
244244 AC_CACHE_CHECK([pw_gecos in struct pwd], tcl_cv_pwd_pw_gecos, [
245245 AC_TRY_COMPILE([#include <pwd.h>],
246 [struct passwd pwd; pwd.pw_gecos;],
246 [struct passwd pwd; (void)pwd.pw_gecos;],
247247 tcl_cv_pwd_pw_gecos=yes, tcl_cv_pwd_pw_gecos=no)])
248248 if test $tcl_cv_pwd_pw_gecos = yes; then
249249 AC_DEFINE(HAVE_PW_GECOS, 1, [Does struct password have a pw_gecos field?])
681681 echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000'
682682 TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist'
683683 EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist'
684 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html'
685 if test "${SHARED_BUILD}" = "0"; then
686 EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -ObjC'
687 fi
684688 EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic'
685 AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in])
689 AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in])
686690 for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done
687691 TK_YEAR="`date +%Y`"
688692 fi
719723 EXTRA_INSTALL="install-private-headers html-tk"
720724 EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
721725 EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
726 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"'
722727 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
723728 if test $tk_aqua = yes; then
724729 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
728733 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
729734 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
730735 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
736 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"'
731737 fi
732738 EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
733739 # Don't use AC_DEFINE for the following as the framework version define
00 #!/bin/sh
11 # install - install a program, script, or datafile
22
3 scriptversion=2011-04-20.01; # UTC
3 scriptversion=2020-07-26.22; # UTC
44
55 # This originates from X11R5 (mit/util/scripts/install.sh), which was
66 # later released in X11R6 (xc/config/util/install.sh) with the
3434 # FSF changes to this file are in the public domain.
3535 #
3636 # Calling this script install-sh is preferred over install.sh, to prevent
37 # `make' implicit rules from creating a file called install from it
37 # 'make' implicit rules from creating a file called install from it
3838 # when there is no Makefile.
3939 #
4040 # This script is compatible with the BSD install script, but was written
4141 # from scratch.
4242
43 tab=' '
4344 nl='
4445 '
45 IFS=" "" $nl"
46
47 # set DOITPROG to echo to test this script
48
49 # Don't use :- since 4.3BSD and earlier shells don't like it.
46 IFS=" $tab$nl"
47
48 # Set DOITPROG to "echo" to test this script.
49
5050 doit=${DOITPROG-}
51 if test -z "$doit"; then
52 doit_exec=exec
53 else
54 doit_exec=$doit
55 fi
51 doit_exec=${doit:-exec}
5652
5753 # Put in absolute file names if you don't have them in your path;
5854 # or use environment vars.
6763 rmprog=${RMPROG-rm}
6864 stripprog=${STRIPPROG-strip}
6965
70 posix_glob='?'
71 initialize_posix_glob='
72 test "$posix_glob" != "?" || {
73 if (set -f) 2>/dev/null; then
74 posix_glob=
75 else
76 posix_glob=:
77 fi
78 }
79 '
80
8166 posix_mkdir=
8267
8368 # Desired mode of installed file.
8469 mode=0755
70
71 # Create dirs (including intermediate dirs) using mode 755.
72 # This is like GNU 'install' as of coreutils 8.32 (2020).
73 mkdir_umask=22
8574
8675 chgrpcmd=
8776 chmodcmd=$chmodprog
9685 dst_arg=
9786
9887 copy_on_change=false
99 no_target_directory=
88 is_target_a_directory=possibly
10089
10190 usage="\
10291 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
119108 -m MODE $chmodprog installed files to MODE.
120109 -o USER $chownprog installed files to USER.
121110 -s $stripprog installed files.
122 -S $stripprog installed files.
111 -S OPTION $stripprog installed files using OPTION.
123112 -t DIRECTORY install into DIRECTORY.
124113 -T report an error if DSTFILE is a directory.
125114
137126 -d) dir_arg=true;;
138127
139128 -g) chgrpcmd="$chgrpprog $2"
140 shift;;
129 shift;;
141130
142131 --help) echo "$usage"; exit $?;;
143132
144133 -m) mode=$2
145 case $mode in
146 *' '* | *' '* | *'
147 '* | *'*'* | *'?'* | *'['*)
148 echo "$0: invalid mode: $mode" >&2
149 exit 1;;
150 esac
151 shift;;
134 case $mode in
135 *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
136 echo "$0: invalid mode: $mode" >&2
137 exit 1;;
138 esac
139 shift;;
152140
153141 -o) chowncmd="$chownprog $2"
154 shift;;
142 shift;;
155143
156144 -s) stripcmd=$stripprog;;
157145
158146 -S) stripcmd="$stripprog $2"
159 shift;;
160
161 -t) dst_arg=$2
162 shift;;
163
164 -T) no_target_directory=true;;
147 shift;;
148
149 -t)
150 is_target_a_directory=always
151 dst_arg=$2
152 # Protect names problematic for 'test' and other utilities.
153 case $dst_arg in
154 -* | [=\(\)!]) dst_arg=./$dst_arg;;
155 esac
156 shift;;
157
158 -T) is_target_a_directory=never;;
165159
166160 --version) echo "$0 $scriptversion"; exit $?;;
167161
168 --) shift
169 break;;
170
171 -*) echo "$0: invalid option: $1" >&2
172 exit 1;;
162 --) shift
163 break;;
164
165 -*) echo "$0: invalid option: $1" >&2
166 exit 1;;
173167
174168 *) break;;
175169 esac
176170 shift
177171 done
172
173 # We allow the use of options -d and -T together, by making -d
174 # take the precedence; this is for compatibility with GNU install.
175
176 if test -n "$dir_arg"; then
177 if test -n "$dst_arg"; then
178 echo "$0: target directory not allowed when installing a directory." >&2
179 exit 1
180 fi
181 fi
178182
179183 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
180184 # When -d is used, all remaining arguments are directories to create.
189193 fi
190194 shift # arg
191195 dst_arg=$arg
196 # Protect names problematic for 'test' and other utilities.
197 case $dst_arg in
198 -* | [=\(\)!]) dst_arg=./$dst_arg;;
199 esac
192200 done
193201 fi
194202
197205 echo "$0: no input file specified." >&2
198206 exit 1
199207 fi
200 # It's OK to call `install-sh -d' without argument.
208 # It's OK to call 'install-sh -d' without argument.
201209 # This can happen when creating conditional directories.
202210 exit 0
211 fi
212
213 if test -z "$dir_arg"; then
214 if test $# -gt 1 || test "$is_target_a_directory" = always; then
215 if test ! -d "$dst_arg"; then
216 echo "$0: $dst_arg: Is not a directory." >&2
217 exit 1
218 fi
219 fi
203220 fi
204221
205222 if test -z "$dir_arg"; then
218235
219236 *[0-7])
220237 if test -z "$stripcmd"; then
221 u_plus_rw=
238 u_plus_rw=
222239 else
223 u_plus_rw='% 200'
240 u_plus_rw='% 200'
224241 fi
225242 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
226243 *)
227244 if test -z "$stripcmd"; then
228 u_plus_rw=
245 u_plus_rw=
229246 else
230 u_plus_rw=,u+rw
247 u_plus_rw=,u+rw
231248 fi
232249 cp_umask=$mode$u_plus_rw;;
233250 esac
235252
236253 for src
237254 do
238 # Protect names starting with `-'.
255 # Protect names problematic for 'test' and other utilities.
239256 case $src in
240 -*) src=./$src;;
257 -* | [=\(\)!]) src=./$src;;
241258 esac
242259
243260 if test -n "$dir_arg"; then
259276 echo "$0: no destination specified." >&2
260277 exit 1
261278 fi
262
263279 dst=$dst_arg
264 # Protect names starting with `-'.
265 case $dst in
266 -*) dst=./$dst;;
267 esac
268
269 # If destination is a directory, append the input filename; won't work
270 # if double slashes aren't ignored.
280
281 # If destination is a directory, append the input filename.
271282 if test -d "$dst"; then
272 if test -n "$no_target_directory"; then
273 echo "$0: $dst_arg: Is a directory" >&2
274 exit 1
283 if test "$is_target_a_directory" = never; then
284 echo "$0: $dst_arg: Is a directory" >&2
285 exit 1
275286 fi
276287 dstdir=$dst
277 dst=$dstdir/`basename "$src"`
288 dstbase=`basename "$src"`
289 case $dst in
290 */) dst=$dst$dstbase;;
291 *) dst=$dst/$dstbase;;
292 esac
278293 dstdir_status=0
279294 else
280 # Prefer dirname, but fall back on a substitute if dirname fails.
281 dstdir=`
282 (dirname "$dst") 2>/dev/null ||
283 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
284 X"$dst" : 'X\(//\)[^/]' \| \
285 X"$dst" : 'X\(//\)$' \| \
286 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
287 echo X"$dst" |
288 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
289 s//\1/
290 q
291 }
292 /^X\(\/\/\)[^/].*/{
293 s//\1/
294 q
295 }
296 /^X\(\/\/\)$/{
297 s//\1/
298 q
299 }
300 /^X\(\/\).*/{
301 s//\1/
302 q
303 }
304 s/.*/./; q'
305 `
306
295 dstdir=`dirname "$dst"`
307296 test -d "$dstdir"
308297 dstdir_status=$?
309298 fi
310299 fi
311300
301 case $dstdir in
302 */) dstdirslash=$dstdir;;
303 *) dstdirslash=$dstdir/;;
304 esac
305
312306 obsolete_mkdir_used=false
313307
314308 if test $dstdir_status != 0; then
315309 case $posix_mkdir in
316310 '')
317 # Create intermediate dirs using mode 755 as modified by the umask.
318 # This is like FreeBSD 'install' as of 1997-10-28.
319 umask=`umask`
320 case $stripcmd.$umask in
321 # Optimize common cases.
322 *[2367][2367]) mkdir_umask=$umask;;
323 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
324
325 *[0-7])
326 mkdir_umask=`expr $umask + 22 \
327 - $umask % 100 % 40 + $umask % 20 \
328 - $umask % 10 % 4 + $umask % 2
329 `;;
330 *) mkdir_umask=$umask,go-w;;
331 esac
332
333 # With -d, create the new directory with the user-specified mode.
334 # Otherwise, rely on $mkdir_umask.
335 if test -n "$dir_arg"; then
336 mkdir_mode=-m$mode
311 # With -d, create the new directory with the user-specified mode.
312 # Otherwise, rely on $mkdir_umask.
313 if test -n "$dir_arg"; then
314 mkdir_mode=-m$mode
315 else
316 mkdir_mode=
317 fi
318
319 posix_mkdir=false
320 # The $RANDOM variable is not portable (e.g., dash). Use it
321 # here however when possible just to lower collision chance.
322 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
323
324 trap '
325 ret=$?
326 rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
327 exit $ret
328 ' 0
329
330 # Because "mkdir -p" follows existing symlinks and we likely work
331 # directly in world-writeable /tmp, make sure that the '$tmpdir'
332 # directory is successfully created first before we actually test
333 # 'mkdir -p'.
334 if (umask $mkdir_umask &&
335 $mkdirprog $mkdir_mode "$tmpdir" &&
336 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
337 then
338 if test -z "$dir_arg" || {
339 # Check for POSIX incompatibilities with -m.
340 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
341 # other-writable bit of parent directory when it shouldn't.
342 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
343 test_tmpdir="$tmpdir/a"
344 ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
345 case $ls_ld_tmpdir in
346 d????-?r-*) different_mode=700;;
347 d????-?--*) different_mode=755;;
348 *) false;;
349 esac &&
350 $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
351 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
352 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
353 }
354 }
355 then posix_mkdir=:
356 fi
357 rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
337358 else
338 mkdir_mode=
359 # Remove any dirs left behind by ancient mkdir implementations.
360 rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
339361 fi
340
341 posix_mkdir=false
342 case $umask in
343 *[123567][0-7][0-7])
344 # POSIX mkdir -p sets u+wx bits regardless of umask, which
345 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
346 ;;
347 *)
348 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
349 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
350
351 if (umask $mkdir_umask &&
352 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
353 then
354 if test -z "$dir_arg" || {
355 # Check for POSIX incompatibilities with -m.
356 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
357 # other-writeable bit of parent directory when it shouldn't.
358 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
359 ls_ld_tmpdir=`ls -ld "$tmpdir"`
360 case $ls_ld_tmpdir in
361 d????-?r-*) different_mode=700;;
362 d????-?--*) different_mode=755;;
363 *) false;;
364 esac &&
365 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
366 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
367 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
368 }
369 }
370 then posix_mkdir=:
371 fi
372 rmdir "$tmpdir/d" "$tmpdir"
373 else
374 # Remove any dirs left behind by ancient mkdir implementations.
375 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
376 fi
377 trap '' 0;;
378 esac;;
362 trap '' 0;;
379363 esac
380364
381365 if
382366 $posix_mkdir && (
383 umask $mkdir_umask &&
384 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
367 umask $mkdir_umask &&
368 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
385369 )
386370 then :
387371 else
388372
389 # The umask is ridiculous, or mkdir does not conform to POSIX,
373 # mkdir does not conform to POSIX,
390374 # or it failed possibly due to a race condition. Create the
391375 # directory the slow way, step by step, checking for races as we go.
392376
393377 case $dstdir in
394 /*) prefix='/';;
395 -*) prefix='./';;
396 *) prefix='';;
378 /*) prefix='/';;
379 [-=\(\)!]*) prefix='./';;
380 *) prefix='';;
397381 esac
398
399 eval "$initialize_posix_glob"
400382
401383 oIFS=$IFS
402384 IFS=/
403 $posix_glob set -f
385 set -f
404386 set fnord $dstdir
405387 shift
406 $posix_glob set +f
388 set +f
407389 IFS=$oIFS
408390
409391 prefixes=
410392
411393 for d
412394 do
413 test -z "$d" && continue
414
415 prefix=$prefix$d
416 if test -d "$prefix"; then
417 prefixes=
418 else
419 if $posix_mkdir; then
420 (umask=$mkdir_umask &&
421 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
422 # Don't fail if two instances are running concurrently.
423 test -d "$prefix" || exit 1
424 else
425 case $prefix in
426 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
427 *) qprefix=$prefix;;
428 esac
429 prefixes="$prefixes '$qprefix'"
430 fi
431 fi
432 prefix=$prefix/
395 test X"$d" = X && continue
396
397 prefix=$prefix$d
398 if test -d "$prefix"; then
399 prefixes=
400 else
401 if $posix_mkdir; then
402 (umask $mkdir_umask &&
403 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
404 # Don't fail if two instances are running concurrently.
405 test -d "$prefix" || exit 1
406 else
407 case $prefix in
408 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
409 *) qprefix=$prefix;;
410 esac
411 prefixes="$prefixes '$qprefix'"
412 fi
413 fi
414 prefix=$prefix/
433415 done
434416
435417 if test -n "$prefixes"; then
436 # Don't fail if two instances are running concurrently.
437 (umask $mkdir_umask &&
438 eval "\$doit_exec \$mkdirprog $prefixes") ||
439 test -d "$dstdir" || exit 1
440 obsolete_mkdir_used=true
418 # Don't fail if two instances are running concurrently.
419 (umask $mkdir_umask &&
420 eval "\$doit_exec \$mkdirprog $prefixes") ||
421 test -d "$dstdir" || exit 1
422 obsolete_mkdir_used=true
441423 fi
442424 fi
443425 fi
450432 else
451433
452434 # Make a couple of temp file names in the proper directory.
453 dsttmp=$dstdir/_inst.$$_
454 rmtmp=$dstdir/_rm.$$_
435 dsttmp=${dstdirslash}_inst.$$_
436 rmtmp=${dstdirslash}_rm.$$_
455437
456438 # Trap to clean up those temp files at exit.
457439 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
458440
459441 # Copy the file name to the temp name.
460 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
442 (umask $cp_umask &&
443 { test -z "$stripcmd" || {
444 # Create $dsttmp read-write so that cp doesn't create it read-only,
445 # which would cause strip to fail.
446 if test -z "$doit"; then
447 : >"$dsttmp" # No need to fork-exec 'touch'.
448 else
449 $doit touch "$dsttmp"
450 fi
451 }
452 } &&
453 $doit_exec $cpprog "$src" "$dsttmp") &&
461454
462455 # and set any options; do chmod last to preserve setuid bits.
463456 #
472465
473466 # If -C, don't bother to copy if it wouldn't change the file.
474467 if $copy_on_change &&
475 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
476 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
477
478 eval "$initialize_posix_glob" &&
479 $posix_glob set -f &&
468 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
469 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
470 set -f &&
480471 set X $old && old=:$2:$4:$5:$6 &&
481472 set X $new && new=:$2:$4:$5:$6 &&
482 $posix_glob set +f &&
483
473 set +f &&
484474 test "$old" = "$new" &&
485475 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
486476 then
493483 # to itself, or perhaps because mv is so ancient that it does not
494484 # support -f.
495485 {
496 # Now remove or move aside any old file at destination location.
497 # We try this two ways since rm can't unlink itself on some
498 # systems and the destination file might be busy for other
499 # reasons. In this case, the final cleanup might fail but the new
500 # file should still install successfully.
501 {
502 test ! -f "$dst" ||
503 $doit $rmcmd -f "$dst" 2>/dev/null ||
504 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
505 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
506 } ||
507 { echo "$0: cannot unlink or rename $dst" >&2
508 (exit 1); exit 1
509 }
510 } &&
511
512 # Now rename the file to the real destination.
513 $doit $mvcmd "$dsttmp" "$dst"
486 # Now remove or move aside any old file at destination location.
487 # We try this two ways since rm can't unlink itself on some
488 # systems and the destination file might be busy for other
489 # reasons. In this case, the final cleanup might fail but the new
490 # file should still install successfully.
491 {
492 test ! -f "$dst" ||
493 $doit $rmcmd -f "$dst" 2>/dev/null ||
494 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
495 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
496 } ||
497 { echo "$0: cannot unlink or rename $dst" >&2
498 (exit 1); exit 1
499 }
500 } &&
501
502 # Now rename the file to the real destination.
503 $doit $mvcmd "$dsttmp" "$dst"
514504 }
515505 fi || exit 1
516506
519509 done
520510
521511 # Local variables:
522 # eval: (add-hook 'write-file-hooks 'time-stamp)
512 # eval: (add-hook 'before-save-hook 'time-stamp)
523513 # time-stamp-start: "scriptversion="
524514 # time-stamp-format: "%:y-%02m-%02d.%02H"
525 # time-stamp-time-zone: "UTC"
515 # time-stamp-time-zone: "UTC0"
526516 # time-stamp-end: "; # UTC"
527 # End:
517 # End:
4242 echo "source manual page file must exist"
4343 exit 1
4444 fi
45 if test -d $Dir ; then : ; else
45 if test -d "$Dir" ; then : ; else
4646 echo "target directory must exist"
4747 exit 1
4848 fi
9898 ### Process Page to Create Target Pages
9999 ###
100100
101 Specials="FindPhoto FontId MeasureChar"
101 Specials="DString Thread Notifier RegExp library packagens pkgMkIndex safesock FindPhoto FontId MeasureChar"
102102 for n in $Specials; do
103103 if [ "$Name" = "$n" ] ; then
104104 Names="$n $Names"
108108 First=""
109109 for Target in $Names; do
110110 Target=$Target.$Section$Suffix
111 rm -f $Dir/$Target $Dir/$Target.*
111 rm -f "$Dir/$Target" "$Dir/$Target.*"
112112 if test -z "$First" ; then
113113 First=$Target
114114 sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \
115 $ManPage > $Dir/$First
116 chmod 644 $Dir/$First
117 $Gzip $Dir/$First
115 $ManPage > "$Dir/$First"
116 chmod 644 "$Dir/$First"
117 $Gzip "$Dir/$First"
118118 else
119 ln $SymOrLoc$First$Gz $Dir/$Target$Gz
119 ln $SymOrLoc"$First$Gz" "$Dir/$Target$Gz"
120120 fi
121121 done
122122
291291 else
292292 AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
293293 fi
294
295 # eval is required to do the TCL_DBGX substitution
296 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
297 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
298294
299295 # If the TCL_BIN_DIR is the build directory (not the install directory),
300296 # then set the common variable name to the value of the build variables.
329325 esac
330326 fi
331327
332 # eval is required to do the TCL_DBGX substitution
333 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
334 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
335 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
336 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
337
338328 AC_SUBST(TCL_VERSION)
339329 AC_SUBST(TCL_PATCH_LEVEL)
340330 AC_SUBST(TCL_BIN_DIR)
374364 else
375365 AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
376366 fi
377
378 # eval is required to do the TK_DBGX substitution
379 eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
380 eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
381367
382368 # If the TK_BIN_DIR is the build directory (not the install directory),
383369 # then set the common variable name to the value of the build variables.
412398 esac
413399 fi
414400
415 # eval is required to do the TK_DBGX substitution
416 eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
417 eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
418 eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
419 eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
420
421401 AC_SUBST(TK_VERSION)
422402 AC_SUBST(TK_BIN_DIR)
423403 AC_SUBST(TK_SRC_DIR)
530510 AC_HELP_STRING([--enable-shared],
531511 [build and link with shared libraries (default: on)]),
532512 [tcl_ok=$enableval], [tcl_ok=yes])
533
534 if test "${enable_shared+set}" = set; then
535 enableval="$enable_shared"
536 tcl_ok=$enableval
537 else
538 tcl_ok=yes
539 fi
540
541513 if test "$tcl_ok" = "yes" ; then
542514 AC_MSG_RESULT([shared])
543515 SHARED_BUILD=1
729701 # Sets to $(CFLAGS_OPTIMIZE) if false
730702 # LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
731703 # Sets to $(LDFLAGS_OPTIMIZE) if false
732 # DBGX Formerly used as debug library extension;
733 # always blank now.
734704 #------------------------------------------------------------------------
735705
736706 AC_DEFUN([SC_ENABLE_SYMBOLS], [
740710 [build with debugging symbols (default: off)]),
741711 [tcl_ok=$enableval], [tcl_ok=no])
742712 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
743 DBGX=""
744713 if test "$tcl_ok" = "no"; then
745714 CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
746715 LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
11021071 CFLAGS_DEBUG=-g
11031072 AS_IF([test "$GCC" = yes], [
11041073 CFLAGS_OPTIMIZE=-O2
1105 CFLAGS_WARNING="-Wall"
1074 CFLAGS_WARNING="-Wall -Wpointer-arith"
11061075 ], [
11071076 CFLAGS_OPTIMIZE=-O
11081077 CFLAGS_WARNING=""
12111180 CC_SEARCH_FLAGS=""
12121181 LD_SEARCH_FLAGS=""
12131182 ;;
1214 CYGWIN_*|MINGW32*)
1183 CYGWIN_*|MINGW32_*|MSYS_*)
12151184 SHLIB_CFLAGS=""
12161185 SHLIB_LD='${CC} -shared'
12171186 SHLIB_SUFFIX=".dll"
12221191 CC_SEARCH_FLAGS=""
12231192 LD_SEARCH_FLAGS=""
12241193 TCL_NEEDS_EXP_FILE=1
1225 TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
1194 TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
12261195 SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
12271196 AC_CACHE_CHECK(for Cygwin version of gcc,
12281197 ac_cv_cygwin,
13111280 do64bit_ok=yes
13121281 SHLIB_LD='${CC} -shared'
13131282 AS_IF([test $doRpath = yes], [
1314 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1283 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
13151284 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
13161285 ;;
13171286 *)
13461315 DL_LIBS=""
13471316 AC_LIBOBJ(mkstemp)
13481317 AS_IF([test $doRpath = yes], [
1349 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1318 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
13501319 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
13511320 ;;
13521321 IRIX-6.*)
13571326 DL_LIBS=""
13581327 AC_LIBOBJ(mkstemp)
13591328 AS_IF([test $doRpath = yes], [
1360 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1329 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
13611330 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
13621331 AS_IF([test "$GCC" = yes], [
13631332 CFLAGS="$CFLAGS -mabi=n32"
13831352 DL_LIBS=""
13841353 AC_LIBOBJ(mkstemp)
13851354 AS_IF([test $doRpath = yes], [
1386 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1355 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
13871356 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
13881357
13891358 # Check to enable 64-bit flags for compiler/linker
14141383 DL_LIBS="-ldl"
14151384 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
14161385 AS_IF([test $doRpath = yes], [
1417 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1386 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
14181387 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
14191388 AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
14201389 AS_IF([test $do64bit = yes], [
14461415 DL_LIBS="-mshared -ldl"
14471416 LD_FLAGS="-Wl,--export-dynamic"
14481417 AS_IF([test $doRpath = yes], [
1449 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1450 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1418 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1419 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
14511420 ;;
14521421 MP-RAS-02*)
14531422 SHLIB_CFLAGS="-K PIC"
14851454 DL_OBJS="tclLoadDl.o"
14861455 DL_LIBS=""
14871456 AS_IF([test $doRpath = yes], [
1488 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1457 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
14891458 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
14901459 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
14911460 LDFLAGS="-Wl,-export-dynamic"
15091478 DL_LIBS=""
15101479 LDFLAGS="$LDFLAGS -export-dynamic"
15111480 AS_IF([test $doRpath = yes], [
1512 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1481 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
15131482 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
15141483 AS_IF([test "${TCL_THREADS}" = "1"], [
15151484 # The -pthread needs to go in the CFLAGS, not LIBS
15261495 SHLIB_SUFFIX=".so"
15271496 DL_OBJS="tclLoadDl.o"
15281497 DL_LIBS=""
1529 LDFLAGS=""
15301498 AS_IF([test $doRpath = yes], [
1531 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1532 LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
1499 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
1500 LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
15331501 AS_IF([test "${TCL_THREADS}" = "1"], [
15341502 # The -pthread needs to go in the LDFLAGS, not LIBS
15351503 LIBS=`echo $LIBS | sed s/-pthread//`
16181586 AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
16191587 AC_DEFINE(MODULE_SCOPE, [__private_extern__],
16201588 [Compiler support for module scope symbols])
1589 tcl_cv_cc_visibility_hidden=yes
16211590 ])
16221591 CC_SEARCH_FLAGS=""
16231592 LD_SEARCH_FLAGS=""
17321701 DL_OBJS="tclLoadDl.o"
17331702 DL_LIBS=""
17341703 AS_IF([test $doRpath = yes], [
1735 CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
1704 CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
17361705 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
17371706 AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [
17381707 CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"])
20081977 case $system in
20091978 AIX-*) ;;
20101979 BSD/OS*) ;;
2011 CYGWIN_*|MINGW32_*) ;;
1980 CYGWIN_*|MINGW32_*|MSYS_*) ;;
20121981 IRIX*) ;;
20131982 NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
20141983 Darwin-*) ;;
20291998
20301999 AS_IF([test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""], [
20312000 LIB_SUFFIX=${SHARED_LIB_SUFFIX}
2032 MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
2001 MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
20332002 AS_IF([test "${SHLIB_SUFFIX}" = ".dll"], [
20342003 INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
20352004 DLL_INSTALL_DIR="\$(BIN_INSTALL_DIR)"
21362105 #
21372106 # Defines some of the following vars:
21382107 # NO_DIRENT_H
2108 # NO_FLOAT_H
21392109 # NO_VALUES_H
21402110 # NO_STDLIB_H
21412111 # NO_STRING_H
21422112 # NO_SYS_WAIT_H
21432113 # NO_DLFCN_H
21442114 # HAVE_SYS_PARAM_H
2145 #
21462115 # HAVE_STRING_H ?
21472116 #
21482117 #--------------------------------------------------------------------
23612330 fi
23622331
23632332 AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
2364 AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
2333 AC_TRY_COMPILE([#include <time.h>], [struct tm tm; (void)tm.tm_gmtoff;],
23652334 tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
23662335 if test $tcl_cv_member_tm_gmtoff = yes ; then
23672336 AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
26502619 AC_CHECK_FUNC($1, tcl_ok=1, tcl_ok=0)
26512620 if test ["$tcl_ok"] = 1; then
26522621 AC_CACHE_CHECK([proper ]$1[ implementation], [tcl_cv_]$1[_unbroken],
2653 AC_TRY_RUN([[int main() {]$2[}]],[tcl_cv_]$1[_unbroken]=ok,
2622 AC_TRY_RUN([[
2623 #include <stdlib.h>
2624 #include <string.h>
2625 int main() {]$2[}]],[tcl_cv_]$1[_unbroken]=ok,
26542626 [tcl_cv_]$1[_unbroken]=broken,[tcl_cv_]$1[_unbroken]=unknown))
26552627 if test ["$tcl_cv_]$1[_unbroken"] = "ok"; then
26562628 tcl_ok=1
33
44 Name: tk
55 Summary: Tk graphical toolkit for the Tcl scripting language.
6 Version: 8.6.10
6 Version: 8.6.11
77 Release: 2
88 License: BSD
99 Group: Development/Languages
1414 #undef BUILD_tk
1515 #undef STATIC_BUILD
1616 #include "tk.h"
17 #include "tkPort.h"
1718
1819 #ifdef TK_TEST
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
1923 extern Tcl_PackageInitProc Tktest_Init;
24 #ifdef __cplusplus
25 }
26 #endif
2027 #endif /* TK_TEST */
2128
2229 /*
2936 #define TK_LOCAL_APPINIT Tcl_AppInit
3037 #endif
3138 #ifndef MODULE_SCOPE
32 # define MODULE_SCOPE extern
39 # ifdef __cplusplus
40 # define MODULE_SCOPE extern "C"
41 # else
42 # define MODULE_SCOPE extern
43 # endif
3344 #endif
3445 MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *);
3546 MODULE_SCOPE int main(int, char **);
110121 }
111122 Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
112123
124 #if defined(USE_CUSTOM_EXIT_PROC)
125 if (TkpWantsExitProc()) {
126 /* The cast below avoids warnings from old gcc compilers. */
127 Tcl_SetExitProc((void *)TkpExitProc);
128 }
129 #endif
130
113131 #ifdef TK_TEST
114132 if (Tktest_Init(interp) == TCL_ERROR) {
115133 return TCL_ERROR;
1515 # include <X11/extensions/scrnsaver.h>
1616 # ifdef __APPLE__
1717 /* Support for weak-linked libXss. */
18 # define HaveXSSLibrary() (XScreenSaverQueryInfo != NULL)
18 # define HaveXSSLibrary() (&XScreenSaverQueryInfo != NULL)
1919 # else
2020 /* Other platforms always link libXss. */
2121 # define HaveXSSLibrary() (1)
172172 * Sanity check.
173173 */
174174
175 if (tkwin == NULL || display == None || d == None || bgBorder == NULL
175 if (tkwin == NULL || display == NULL || d == None || bgBorder == NULL
176176 || indicatorColor == NULL) {
177177 return;
178178 }
325325
326326 TkButton *
327327 TkpCreateButton(
328 Tk_Window tkwin)
328 TCL_UNUSED(Tk_Window))
329329 {
330 UnixButton *butPtr = ckalloc(sizeof(UnixButton));
331
332 return (TkButton *) butPtr;
330 return (TkButton *)ckalloc(sizeof(UnixButton));
333331 }
334332
335333 /*
395393 TkpDisplayButton(
396394 ClientData clientData) /* Information about widget. */
397395 {
398 register TkButton *butPtr = (TkButton *) clientData;
396 TkButton *butPtr = (TkButton *)clientData;
399397 GC gc;
400398 Tk_3DBorder border;
401399 Pixmap pixmap;
806804 butPtr->borderWidth, relief);
807805 }
808806 if (butPtr->highlightWidth > 0) {
809 GC gc;
810
811807 if (butPtr->flags & GOT_FOCUS) {
812808 gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap);
813809 } else {
859855
860856 void
861857 TkpComputeButtonGeometry(
862 register TkButton *butPtr) /* Button whose geometry may have changed. */
858 TkButton *butPtr) /* Button whose geometry may have changed. */
863859 {
864860 int width, height, avgWidth, txtWidth, txtHeight;
865861 int haveImage = 0, haveText = 0;
135135 if (*name != '#') {
136136 XColor screen;
137137
138 if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
139 if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
140 && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
138 if (((*name - 'A') & 0xDF) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
139 if (!((name[0] - 'G') & 0xDF) && !((name[1] - 'R') & 0xDF)
140 && !((name[2] - 'A') & 0xDB) && !((name[3] - 'Y') & 0xDF)
141141 && !name[4]) {
142142 name = "#808080808080";
143143 goto gotWebColor;
144144 } else {
145 const char *p = tkWebColors[((*name - 'A') & 0x1f)];
145 const char *p = tkWebColors[((*name - 'A') & 0x1F)];
146146 if (p) {
147147 const char *q = name;
148 while (!((*p - *(++q)) & 0xdf)) {
148 while (!((*p - *(++q)) & 0xDF)) {
149149 if (!*p++) {
150150 name = p;
151151 goto gotWebColor;
244244 if ((argv[0][0] != '@') && !inTkTable) {
245245 XColor fg, bg;
246246 unsigned int maskIndex;
247 register const struct CursorName *namePtr;
247 const struct CursorName *namePtr;
248248 TkDisplay *dispPtr;
249249
250250 /*
359359 int type;
360360 XEvent x;
361361 TkKeyEvent k;
362 #ifdef GenericEvent
363 xGenericEvent xge;
364 #endif
365362 } event;
366363 Window w;
367364 TkDisplay *dispPtr = NULL;
379376
380377 while (QLength(display) > 0) {
381378 XNextEvent(display, &event.x);
382 #ifdef GenericEvent
383 if (event.type == GenericEvent) {
384 Tcl_Panic("Wild GenericEvent; panic! (extension=%d,evtype=%d)",
385 event.xge.extension, event.xge.evtype);
386 }
387 #endif
379 if (event.type > MappingNotify) {
380 continue;
381 }
388382 w = None;
389383 if (event.type == KeyPress || event.type == KeyRelease) {
390384 for (dispPtr = TkGetDisplayList(); ; dispPtr = dispPtr->nextPtr) {
513507 * nice (?!) message.
514508 */
515509
516 void (*oldHandler)();
517
518 oldHandler = (void (*)()) signal(SIGPIPE, SIG_IGN);
510 void (*oldHandler)(int);
511
512 oldHandler = (void (*)(int)) signal(SIGPIPE, SIG_IGN);
519513 XNoOp(display);
520514 XFlush(display);
521515 (void) signal(SIGPIPE, oldHandler);
1111
1212 #include "tkUnixInt.h"
1313 #include "tkFont.h"
14 #include <netinet/in.h> /* for htons() prototype */
15 #include <arpa/inet.h> /* inet_ntoa() */
1614
1715 /*
1816 * The preferred font encodings.
1917 */
2018
21 static const char *const encodingList[] = {
22 "iso8859-1", "jis0208", "jis0212", NULL
19 static const char encodingList[][10] = {
20 "iso8859-1", "jis0208", "jis0212"
2321 };
2422
2523 /*
3735 #define FONTMAP_SHIFT 10
3836
3937 #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
40 #define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
38 #define FONTMAP_NUMCHARS 0x40000
39 #define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
4140
4241 typedef struct FontFamily {
4342 struct FontFamily *nextPtr; /* Next in list of all known font families. */
44 int refCount; /* How many SubFonts are referring to this
43 size_t refCount; /* How many SubFonts are referring to this
4544 * FontFamily. When the refCount drops to
4645 * zero, this FontFamily may be freed. */
4746 /*
6261 /* Two-level sparse table used to determine
6362 * quickly if the specified character exists.
6463 * As characters are encountered, more pages
65 * in this table are dynamically alloced. The
64 * in this table are dynamically allocated. The
6665 * contents of each page is a bitmask
6766 * consisting of FONTMAP_BITSPERPAGE bits,
6867 * representing whether this font can be used
193192 * Functions used only in this file.
194193 */
195194
196 static void FontPkgCleanup(ClientData clientData);
195 static void FontPkgCleanup(void *clientData);
197196 static FontFamily * AllocFontFamily(Display *display,
198197 XFontStruct *fontStructPtr, int base);
199198 static SubFont * CanUseFallback(UnixFont *fontPtr,
203202 const char *fallbackName, int ch,
204203 Tcl_DString *nameTriedPtr,
205204 SubFont **fixSubFontPtrPtr);
206 static int ControlUtfProc(ClientData clientData, const char *src,
205 static int ControlUtfProc(void *clientData, const char *src,
207206 int srcLen, int flags, Tcl_EncodingState*statePtr,
208207 char *dst, int dstLen, int *srcReadPtr,
209208 int *dstWrotePtr, int *dstCharsPtr);
238237 static void ReleaseFont(UnixFont *fontPtr);
239238 static void ReleaseSubFont(Display *display, SubFont *subFontPtr);
240239 static int SeenName(const char *name, Tcl_DString *dsPtr);
241 static int Ucs2beToUtfProc(ClientData clientData, const char*src,
240 static int Ucs2beToUtfProc(void *clientData, const char*src,
242241 int srcLen, int flags, Tcl_EncodingState*statePtr,
243242 char *dst, int dstLen, int *srcReadPtr,
244243 int *dstWrotePtr, int *dstCharsPtr);
245 static int UtfToUcs2beProc(ClientData clientData, const char*src,
244 static int UtfToUcs2beProc(void *clientData, const char*src,
246245 int srcLen, int flags, Tcl_EncodingState*statePtr,
247246 char *dst, int dstLen, int *srcReadPtr,
248247 int *dstWrotePtr, int *dstCharsPtr);
267266
268267 static void
269268 FontPkgCleanup(
270 ClientData clientData)
271 {
272 ThreadSpecificData *tsdPtr =
269 TCL_UNUSED(void *))
270 {
271 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
273272 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
274273
275274 if (tsdPtr->controlFamily.encoding != NULL) {
306305
307306 void
308307 TkpFontPkgInit(
309 TkMainInfo *mainPtr) /* The application being created. */
310 {
311 ThreadSpecificData *tsdPtr =
308 TCL_UNUSED(TkMainInfo *)) /* The application being created. */
309 {
310 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
312311 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
313312 SubFont dummy;
314313 int i;
362361
363362 static int
364363 ControlUtfProc(
365 ClientData clientData, /* Not used. */
364 TCL_UNUSED(void *), /* Not used. */
366365 const char *src, /* Source string in UTF-8. */
367366 int srcLen, /* Source string length in bytes. */
368 int flags, /* Conversion control flags. */
369 Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
367 TCL_UNUSED(int), /* Conversion control flags. */
368 TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
370369 * information used during a piecewise
371370 * conversion. Contents of statePtr are
372371 * initialized and/or reset by conversion
390389 const char *srcStart, *srcEnd;
391390 char *dstStart, *dstEnd;
392391 int ch, result;
393 static char hexChars[] = "0123456789abcdef";
394 static char mapChars[] = {
392 static const char hexChars[] = "0123456789abcdef";
393 static const char mapChars[] = {
395394 0, 0, 0, 0, 0, 0, 0,
396395 'a', 'b', 't', 'n', 'v', 'f', 'r'
397396 };
416415 dst += 2;
417416 } else if ((size_t)ch < 256) {
418417 dst[1] = 'x';
419 dst[2] = hexChars[(ch >> 4) & 0xf];
420 dst[3] = hexChars[ch & 0xf];
418 dst[2] = hexChars[(ch >> 4) & 0xF];
419 dst[3] = hexChars[ch & 0xF];
421420 dst += 4;
422421 } else if ((size_t)ch < 0x10000) {
423422 dst[1] = 'u';
424 dst[2] = hexChars[(ch >> 12) & 0xf];
425 dst[3] = hexChars[(ch >> 8) & 0xf];
426 dst[4] = hexChars[(ch >> 4) & 0xf];
427 dst[5] = hexChars[ch & 0xf];
423 dst[2] = hexChars[(ch >> 12) & 0xF];
424 dst[3] = hexChars[(ch >> 8) & 0xF];
425 dst[4] = hexChars[(ch >> 4) & 0xF];
426 dst[5] = hexChars[ch & 0xF];
428427 dst += 6;
429428 } else {
430429 /* TODO we can do better here */
460459
461460 static int
462461 Ucs2beToUtfProc(
463 ClientData clientData, /* Not used. */
462 TCL_UNUSED(void *), /* Not used. */
464463 const char *src, /* Source string in Unicode. */
465464 int srcLen, /* Source string length in bytes. */
466465 int flags, /* Conversion control flags. */
467 Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
466 TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
468467 * information used during a piecewise
469468 * conversion. Contents of statePtr are
470469 * initialized and/or reset by conversion
486485 * output buffer. */
487486 {
488487 const char *srcStart, *srcEnd;
489 char *dstEnd, *dstStart;
490 int result, numChars;
491
488 const char *dstEnd, *dstStart;
489 int result, numChars, charLimit = INT_MAX;
490 unsigned short ch;
491
492 if (flags & TCL_ENCODING_CHAR_LIMIT) {
493 charLimit = *dstCharsPtr;
494 }
492495 result = TCL_OK;
493496
494497 /* check alignment with ucs-2 (2 == sizeof(UCS-2)) */
506509 srcEnd = src + srcLen;
507510
508511 dstStart = dst;
509 dstEnd = dst + dstLen - TCL_UTF_MAX;
510
511 for (numChars = 0; src < srcEnd; numChars++) {
512 dstEnd = dst + dstLen - 4;
513
514 for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
512515 if (dst > dstEnd) {
513516 result = TCL_CONVERT_NOSPACE;
514517 break;
515518 }
516519
520 ch = (src[0] & 0xFF) << 8 | (src[1] & 0xFF);
521 src += 2 /* sizeof(UTF-16) */;
522
517523 /*
518 * Need to swap byte-order on little-endian machines (x86) for
519 * UCS-2BE. We know this is an LE->BE swap.
524 * Special case for 1-byte utf chars for speed. Make sure we work with
525 * unsigned short-size data.
520526 */
521
522 dst += TkUniCharToUtf(htons(*((short *)src)), dst);
523 src += 2 /* sizeof(UCS-2) */;
527 if (ch && ch < 0x80) {
528 *dst++ = (ch & 0xFF);
529 } else {
530 dst += Tcl_UniCharToUtf(ch, dst);
531 }
524532 }
525533
526534 *srcReadPtr = src - srcStart;
547555
548556 static int
549557 UtfToUcs2beProc(
550 ClientData clientData, /* TableEncodingData that specifies
558 TCL_UNUSED(void *), /* TableEncodingData that specifies
551559 * encoding. */
552560 const char *src, /* Source string in UTF-8. */
553561 int srcLen, /* Source string length in bytes. */
554562 int flags, /* Conversion control flags. */
555 Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
563 TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
556564 * information used during a piecewise
557565 * conversion. Contents of statePtr are
558566 * initialized and/or reset by conversion
575583 {
576584 const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
577585 int result, numChars;
578 Tcl_UniChar *chPtr = (Tcl_UniChar *)statePtr;
579
580 if (flags & TCL_ENCODING_START) {
581 *statePtr = 0;
582 }
586 int ch;
583587
584588 srcStart = src;
585589 srcEnd = src + srcLen;
586590 srcClose = srcEnd;
587591 if (!(flags & TCL_ENCODING_END)) {
588 srcClose -= TCL_UTF_MAX;
592 srcClose -= 6;
589593 }
590594
591595 dstStart = dst;
605609 result = TCL_CONVERT_NOSPACE;
606610 break;
607611 }
608 src += Tcl_UtfToUniChar(src, chPtr);
612 src += TkUtfToUniChar(src, &ch);
613 if (ch > 0xFFFF) {
614 ch = 0xFFFD;
615 }
609616
610617 /*
611618 * Ensure big-endianness (store big bits first).
612 * XXX: This hard-codes the assumed size of Tcl_UniChar as 2. Make
613 * sure to work in char* for Tcl_UtfToUniChar alignment. [Bug 1122671]
614619 */
615620
616
617 *dst++ = (char)(*chPtr >> 8);
618 *dst++ = (char)*chPtr;
621 *dst++ = (char)((ch >> 8) & 0xFF);
622 *dst++ = (char)(ch & 0xFF);
619623 }
620624 *srcReadPtr = src - srcStart;
621625 *dstWrotePtr = dst - dstStart;
700704
701705 if (name[0] == '-') {
702706 if (name[1] != '*') {
703 char *dash;
707 const char *dash;
704708
705709 dash = strchr(name + 1, '-');
706710 if ((dash == NULL) || (isspace(UCHAR(dash[-1])))) {
715719 }
716720 fontStructPtr = CreateClosestFont(tkwin, &fa.fa, &fa.xa);
717721 }
718 fontPtr = ckalloc(sizeof(UnixFont));
722 fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
719723 InitFont(tkwin, fontStructPtr, fontPtr);
720724
721725 return (TkFont *) fontPtr;
771775
772776 fontPtr = (UnixFont *) tkFontPtr;
773777 if (fontPtr == NULL) {
774 fontPtr = ckalloc(sizeof(UnixFont));
778 fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
775779 } else {
776780 ReleaseFont(fontPtr);
777781 }
834838 Tcl_Interp *interp, /* Interp to hold result. */
835839 Tk_Window tkwin) /* For display to query. */
836840 {
837 int i, new, numNames;
841 int i, isNew, numNames;
838842 char *family, **nameList;
839843 Tcl_HashTable familyTable;
840844 Tcl_HashEntry *hPtr;
863867 continue; /* See comment above. */
864868 }
865869 *familyEnd = '\0';
866 Tcl_CreateHashEntry(&familyTable, family, &new);
870 Tcl_CreateHashEntry(&familyTable, family, &isNew);
867871 }
868872 XFreeFontNames(nameList);
869873
870874 hPtr = Tcl_FirstHashEntry(&familyTable, &search);
871875 resultPtr = Tcl_NewObj();
872876 while (hPtr != NULL) {
873 strPtr = Tcl_NewStringObj(Tcl_GetHashKey(&familyTable, hPtr), -1);
877 strPtr = Tcl_NewStringObj((const char *)Tcl_GetHashKey(&familyTable, hPtr), -1);
874878 Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
875879 hPtr = Tcl_NextHashEntry(&search);
876880 }
11981202 Tk_Font tkfont, /* Font in which characters will be drawn. */
11991203 const char *source, /* UTF-8 string to be displayed. Need not be
12001204 * '\0' terminated. */
1201 int numBytes, /* Maximum number of bytes to consider from
1205 TCL_UNUSED(int), /* Maximum number of bytes to consider from
12021206 * source string in all. */
12031207 int rangeStart, /* Index of first byte to measure. */
12041208 int rangeLength, /* Length of range to measure in bytes. */
12201224 int *lengthPtr) /* Filled with x-location just after the
12211225 * terminating character. */
12221226 {
1223 (void) numBytes; /*unused*/
12241227 return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
12251228 maxLength, flags, lengthPtr);
12261229 }
13691372 * with access to all the characters on the line for context. On X11 this
13701373 * context isn't consulted, so we just call Tk_DrawChars().
13711374 *
1375 * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this
1376 * function is unused (and possibly unfinished). See [7655f65ae7].
1377 *
13721378 * Results:
13731379 * None.
13741380 *
13921398 * is passed to this function. If they are not
13931399 * stripped out, they will be displayed as
13941400 * regular printing characters. */
1395 int numBytes, /* Number of bytes in string. */
1401 TCL_UNUSED(int), /* Number of bytes in string. */
13961402 int rangeStart, /* Index of first byte to draw. */
13971403 int rangeLength, /* Length of range to draw in bytes. */
13981404 int x, int y) /* Coordinates at which to place origin of the
14011407 {
14021408 int widthUntilStart;
14031409
1404 (void) numBytes; /*unused*/
1405
14061410 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
14071411 Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
14081412 rangeLength, x+widthUntilStart, y);
1413 }
1414
1415 void
1416 TkpDrawAngledCharsInContext(
1417 Display *display, /* Display on which to draw. */
1418 Drawable drawable, /* Window or pixmap in which to draw. */
1419 GC gc, /* Graphics context for drawing characters. */
1420 Tk_Font tkfont, /* Font in which characters will be drawn; must
1421 * be the same as font used in GC. */
1422 const char * source, /* UTF-8 string to be displayed. Need not be
1423 * '\0' terminated. All Tk meta-characters
1424 * (tabs, control characters, and newlines)
1425 * should be stripped out of the string that is
1426 * passed to this function. If they are not
1427 * stripped out, they will be displayed as
1428 * regular printing characters. */
1429 int numBytes, /* Number of bytes in string. */
1430 int rangeStart, /* Index of first byte to draw. */
1431 int rangeLength, /* Length of range to draw in bytes. */
1432 double x, double y, /* Coordinates at which to place origin of the
1433 * whole (not just the range) string when
1434 * drawing. */
1435 double angle) /* What angle to put text at, in degrees. */
1436 {
1437 int widthUntilStart;
1438 double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
1439
1440 (void) numBytes; /*unused*/
1441
1442 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
1443 TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart,
1444 rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle);
14091445 }
14101446
14111447 /*
15701606 UnixFont *fontPtr) /* Filled with information constructed from
15711607 * the above arguments. */
15721608 {
1573 ThreadSpecificData *tsdPtr =
1609 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
15741610 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
15751611 unsigned long value;
15761612 int minHi, maxHi, minLo, maxLo, fixed, width, limit, i, n;
16761712 * 1/3 the width of a capital I.
16771713 */
16781714
1679 fontPtr->barHeight = fontPtr->widths['I'] / 3;
1715 fontPtr->barHeight = fontPtr->widths[(unsigned char)'I'] / 3;
16801716 if (fontPtr->barHeight == 0) {
16811717 fontPtr->barHeight = 1;
16821718 }
18171853 Display *display, /* Display in which font will be used. */
18181854 XFontStruct *fontStructPtr, /* Screen font whose FontFamily is to be
18191855 * returned. */
1820 int base) /* Non-zero if this font family is to be used
1856 TCL_UNUSED(int)) /* Non-zero if this font family is to be used
18211857 * in the base font of a font object. */
18221858 {
18231859 FontFamily *familyPtr;
18241860 FontAttributes fa;
18251861 Tcl_Encoding encoding;
1826 ThreadSpecificData *tsdPtr =
1862 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
18271863 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
18281864
18291865 GetFontAttributes(display, fontStructPtr, &fa);
18421878 }
18431879 }
18441880
1845 familyPtr = ckalloc(sizeof(FontFamily));
1881 familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
18461882 memset(familyPtr, 0, sizeof(FontFamily));
18471883 familyPtr->nextPtr = tsdPtr->fontFamilyList;
18481884 tsdPtr->fontFamilyList = familyPtr;
18991935 FontFamily *familyPtr) /* The FontFamily to delete. */
19001936 {
19011937 FontFamily **familyPtrPtr;
1902 ThreadSpecificData *tsdPtr =
1938 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
19031939 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
19041940 int i;
19051941
19061942 if (familyPtr == NULL) {
19071943 return;
19081944 }
1909 familyPtr->refCount--;
1910 if (familyPtr->refCount > 0) {
1945 if (familyPtr->refCount-- > 1) {
19111946 return;
19121947 }
19131948 if (familyPtr->encoding) {
19752010 SubFont *subFontPtr;
19762011 Tcl_DString ds;
19772012
1978 if (ch < 0 || ch > 0x30000) {
1979 ch = 0xfffd;
2013 if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
2014 ch = 0xFFFD;
19802015 }
19812016
19822017 for (i = 0; i < fontPtr->numSubFonts; i++) {
21292164 {
21302165 int row, bitOffset;
21312166
2132 if (ch < 0 || ch >= 0x30000) {
2167 if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
21332168 return 0;
21342169 }
21352170 row = ch >> FONTMAP_SHIFT;
21722207 {
21732208 int row, bitOffset;
21742209
2175 if (ch >= 0 && ch < 0x30000) {
2210 if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
21762211 row = ch >> FONTMAP_SHIFT;
21772212 if (subFontPtr->fontMap[row] == NULL) {
21782213 FontMapLoadPage(subFontPtr, row);
22132248 Tcl_Encoding encoding;
22142249 XFontStruct *fontStructPtr;
22152250 XCharStruct *widths;
2216 ThreadSpecificData *tsdPtr =
2251 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
22172252 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
22182253
2219 subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
2254 subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
22202255 memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
22212256
22222257 if (subFontPtr->familyPtr == &tsdPtr->controlFamily) {
24542489 numEncodings = 0;
24552490 Tcl_DStringInit(&dsEncodings);
24562491
2457 charset = NULL; /* lint, since numNames must be > 0 to get here. */
2492 charset = NULL; /* numNames must be > 0 to get here. */
24582493
24592494 retry:
24602495 bestIdx[0] = -1;
25482583 * make a copy.
25492584 */
25502585
2551 nameList = ckalloc(numNames * sizeof(char *));
2586 nameList = (char **)ckalloc(numNames * sizeof(char *));
25522587 memcpy(nameList, nameListOrig, numNames * sizeof(char *));
25532588 }
25542589 nameList[nameIdx] = NULL;
25932628 if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
25942629 SubFont *newPtr;
25952630
2596 newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
2631 newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
25972632 memcpy(newPtr, fontPtr->subFontArray,
25982633 fontPtr->numSubFonts * sizeof(SubFont));
25992634 if (fixSubFontPtrPtr != NULL) {
2600 register SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
2635 SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
26012636
26022637 if (fixSubFontPtr != &fontPtr->controlSubFont) {
26032638 *fixSubFontPtrPtr =
26832718 penalty += diff;
26842719 }
26852720 if (gotPtr->xa.charset != wantPtr->xa.charset) {
2686 int i;
2721 size_t i;
26872722 const char *gotAlias, *wantAlias;
26882723
26892724 penalty += 65000;
26912726 wantAlias = GetEncodingAlias(wantPtr->xa.charset);
26922727 if (strcmp(gotAlias, wantAlias) != 0) {
26932728 penalty += 30000;
2694 for (i = 0; encodingList[i] != NULL; i++) {
2729 for (i = 0; i < sizeof(encodingList)/sizeof(encodingList[0]); i++) {
26952730 if (strcmp(gotAlias, encodingList[i]) == 0) {
26962731 penalty -= 30000;
26972732 break;
30623097 Pixmap bitmap;
30633098 GC bitmapGC;
30643099 XGCValues values;
3065 XImage *image;
3100 XImage *image = NULL;
30663101
30673102 (void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
30683103 height = fontPtr->fm.ascent + fontPtr->fm.descent;
30693104
3070 bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
3071 values.graphics_exposures = False;
3072 values.foreground = BlackPixel(display, DefaultScreen(display));
3073 bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
3074 &values);
3075 XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
3076
3077 values.font = Tk_FontId(tkfont);
3078 values.foreground = WhitePixel(display, DefaultScreen(display));
3079 values.background = BlackPixel(display, DefaultScreen(display));
3080 XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
3081 Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
3082 fontPtr->fm.ascent);
3083 XFreeGC(display, bitmapGC);
3084
3085 image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
3086 ZPixmap);
3087 Tk_FreePixmap(display, bitmap);
3105 if ((width > 0) && (height > 0)) {
3106 bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
3107 values.graphics_exposures = False;
3108 values.foreground = BlackPixel(display, DefaultScreen(display));
3109 bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
3110 &values);
3111 XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
3112
3113 values.font = Tk_FontId(tkfont);
3114 values.foreground = WhitePixel(display, DefaultScreen(display));
3115 values.background = BlackPixel(display, DefaultScreen(display));
3116 XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
3117 Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
3118 fontPtr->fm.ascent);
3119 XFreeGC(display, bitmapGC);
3120
3121 image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
3122 ZPixmap);
3123 Tk_FreePixmap(display, bitmap);
3124 }
30883125
30893126 *realWidthPtr = width;
30903127 *realHeightPtr = height;
30993136 int height,
31003137 Pixmap *bitmapPtr)
31013138 {
3102 Pixmap bitmap;
3103 XImage *image;
3139 Pixmap bitmap = None;
3140 XImage *image = NULL;
31043141 GC bitmapGC;
31053142 XGCValues values;
31063143
3107 bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
3108 values.graphics_exposures = False;
3109 values.foreground = BlackPixel(display, DefaultScreen(display));
3110 bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
3111 &values);
3112 XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
3113 XFreeGC(display, bitmapGC);
3114
3115 image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
3116 ZPixmap);
3144 if ((width > 0) && (height > 0)) {
3145 bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
3146 values.graphics_exposures = False;
3147 values.foreground = BlackPixel(display, DefaultScreen(display));
3148 bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
3149 &values);
3150 XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
3151 XFreeGC(display, bitmapGC);
3152
3153 image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
3154 ZPixmap);
3155 }
31173156 *bitmapPtr = bitmap;
31183157 return image;
31193158 }
1010 */
1111
1212 #include "tkInt.h"
13
14 #ifdef __GNUC__
15 /*
16 * We know that XKeycodeToKeysym is deprecated, nothing we can do about it.
17 */
18 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
19 #endif
1320
1421 /*
1522 ** Bug [3607830]: Before using Xkb, it must be initialized. TkpOpenDisplay
1623 ** does this and sets the USE_XKB flag if xkb is supported.
1724 ** (should this be function ptr?)
1825 */
26
1927 #ifdef HAVE_XKBKEYCODETOKEYSYM
2028 # include <X11/XKBlib.h>
2129 #else
137145
138146 #ifdef TK_USE_INPUT_METHODS
139147 if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
140 && (winPtr->inputContext != NULL)
141 && (eventPtr->type == KeyPress)) {
148 && (winPtr->inputContext != NULL)) {
142149 Status status;
143150
144151 #if X_HAVE_UTF8_STRING
193200 {
194201 /*
195202 * Fall back to convert a keyboard event to a UTF-8 string using
196 * XLookupString. This is used when input methods are turned off and
197 * for KeyRelease events.
203 * XLookupString. This is used when input methods are turned off.
198204 *
199205 * Note: XLookupString() normally returns a single ISO Latin 1 or
200206 * ASCII control character.
278284 mincode = 0;
279285 maxcode = -1;
280286 XDisplayKeycodes(dispPtr->display, &mincode, &maxcode);
281 if (keycode < mincode) {
287 if (keycode < (KeyCode)mincode) {
282288 keycode = mincode;
283 } else if (keycode > maxcode) {
289 } else if (keycode > (KeyCode)maxcode) {
284290 keycode = maxcode;
285291 }
286292
305311 *
306312 *----------------------------------------------------------------------
307313 */
314
315 #ifdef __GNUC__
316 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
317 #endif
308318
309319 KeySym
310320 TkpGetKeySym(
316326 TkKeyEvent* kePtr = (TkKeyEvent*) eventPtr;
317327
318328 /*
329 * X11 keycodes always lie in the inclusive range [8,255].
330 */
331
332 if (eventPtr->xkey.keycode > 0xff) {
333 return NoSymbol;
334 }
335
336 /*
319337 * Refresh the mapping information if it's stale. This must happen before
320338 * we do any input method processing. [Bug 3599312]
321339 */
362380 && (eventPtr->xkey.state & LockMask))) {
363381 index += 1;
364382 }
383
365384 sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0,
366385 index);
367386
371390 * alphabetic, then switch back to the unshifted keysym.
372391 */
373392
393 #ifndef XK_Oslash
394 /* XK_Oslash is the official name, but might not be present in older X11 headers */
395 # define XK_Oslash XK_Ooblique
396 #endif
374397 if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
375398 && (dispPtr->lockUsage == LU_CAPS)) {
376399 if (!(((sym >= XK_A) && (sym <= XK_Z))
377400 || ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
378 || ((sym >= XK_Ooblique) && (sym <= XK_Thorn)))) {
401 || ((sym >= XK_Oslash) && (sym <= XK_Thorn)))) {
379402 index &= ~1;
380403 sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode,
381404 0, index);
465488 continue;
466489 }
467490 keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0);
491
468492 if (keysym == XK_Mode_switch) {
469493 dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
470494 }
144144
145145 void
146146 TkpDestroyMenu(
147 TkMenu *menuPtr)
147 TCL_UNUSED(TkMenu *))
148148 {
149149 /*
150150 * Nothing to do.
170170
171171 void
172172 TkpDestroyMenuEntry(
173 TkMenuEntry *mEntryPtr)
173 TCL_UNUSED(TkMenuEntry *))
174174 {
175175 /*
176176 * Nothing to do.
198198
199199 int
200200 TkpConfigureMenuEntry(
201 register TkMenuEntry *mePtr)/* Information about menu entry; may or may
201 TkMenuEntry *mePtr)/* Information about menu entry; may or may
202202 * not already have values for some fields. */
203203 {
204204 /*
238238
239239 int
240240 TkpMenuNewEntry(
241 TkMenuEntry *mePtr)
241 TCL_UNUSED(TkMenuEntry *))
242242 {
243243 return TCL_OK;
244244 }
291291
292292 void
293293 TkpSetMainMenubar(
294 Tcl_Interp *interp,
295 Tk_Window tkwin,
296 const char *menuName)
294 TCL_UNUSED(Tcl_Interp *),
295 TCL_UNUSED(Tk_Window),
296 TCL_UNUSED(const char *))
297297 {
298298 /*
299299 * Nothing to do.
322322 GetMenuIndicatorGeometry(
323323 TkMenu *menuPtr, /* The menu we are drawing. */
324324 TkMenuEntry *mePtr, /* The entry we are interested in. */
325 Tk_Font tkfont, /* The precalculated font */
326 const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
325 TCL_UNUSED(Tk_Font), /* The precalculated font */
326 TCL_UNUSED(const Tk_FontMetrics *),/* The precalculated metrics */
327327 int *widthPtr, /* The resulting width */
328328 int *heightPtr) /* The resulting height */
329329 {
444444 } else {
445445 relief = TK_RELIEF_RAISED;
446446 }
447
448447 Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
449448 menuPtr->activeBorderWidthPtr, &activeBorderWidth);
450449 Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height,
523522 if (menuPtr->menuType == MENUBAR) {
524523 left += 5;
525524 }
526 Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
525 Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
527526 mePtr->accelLength, left,
528527 (y + (height + fmPtr->ascent - fmPtr->descent) / 2));
529528 }
553552 Tk_3DBorder border, /* The background color */
554553 XColor *indicatorColor, /* The color to draw indicators with */
555554 XColor *disableColor, /* The color use use when disabled */
556 Tk_Font tkfont, /* The font to draw with */
557 const Tk_FontMetrics *fmPtr,/* The font metrics of the font */
555 TCL_UNUSED(Tk_Font), /* The font to draw with */
556 TCL_UNUSED(const Tk_FontMetrics *),/* The font metrics of the font */
558557 int x, /* The left of the entry rect */
559558 int y, /* The top of the entry rect */
560 int width, /* Width of menu entry */
559 TCL_UNUSED(int), /* Width of menu entry */
561560 int height) /* Height of menu entry */
562561 {
563562 /*
622621 static void
623622 DrawMenuSeparator(
624623 TkMenu *menuPtr, /* The menu we are drawing */
625 TkMenuEntry *mePtr, /* The entry we are drawing */
624 TCL_UNUSED(TkMenuEntry *), /* The entry we are drawing */
626625 Drawable d, /* The drawable we are using */
627 GC gc, /* The gc to draw into */
628 Tk_Font tkfont, /* The font to draw with */
629 const Tk_FontMetrics *fmPtr,/* The font metrics from the font */
626 TCL_UNUSED(GC), /* The gc to draw into */
627 TCL_UNUSED(Tk_Font), /* The font to draw with */
628 TCL_UNUSED(const Tk_FontMetrics *),/* The font metrics from the font */
630629 int x, int y,
631630 int width, int height)
632631 {
789788 imageHeight, d, leftEdge + imageXOffset,
790789 (int) (y + (mePtr->height-imageHeight)/2 + imageYOffset));
791790 }
792 } else if (mePtr->bitmapPtr != None) {
791 } else if (mePtr->bitmapPtr != NULL) {
793792 Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
794793
795794 XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
817816 XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
818817 (unsigned) width, (unsigned) height);
819818 } else if ((mePtr->image != NULL)
820 && (menuPtr->disabledImageGC != None)) {
819 && (menuPtr->disabledImageGC != NULL)) {
821820 XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
822821 leftEdge + imageXOffset,
823822 (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset),
851850 Tk_Font tkfont, /* The precalculated font */
852851 const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
853852 int x, int y,
854 int width, int height)
853 TCL_UNUSED(int), int height)
855854 {
856855 if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
857856 int len;
858857
859858 len = Tcl_GetCharLength(mePtr->labelPtr);
860859 if (mePtr->underline < len) {
861 int activeBorderWidth, leftEdge;
860 int activeBorderWidth, leftEdge, ch;
862861 const char *label, *start, *end;
863862
864863 label = Tcl_GetString(mePtr->labelPtr);
865 start = Tcl_UtfAtIndex(label, mePtr->underline);
866 end = Tcl_UtfNext(start);
864 start = TkUtfAtIndex(label, mePtr->underline);
865 end = start + TkUtfToUniChar(start, &ch);
867866
868867 Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
869868 menuPtr->activeBorderWidthPtr, &activeBorderWidth);
930929
931930 int
932931 TkpPostTearoffMenu(
933 Tcl_Interp *interp, /* The interpreter of the menu */
932 TCL_UNUSED(Tcl_Interp *), /* The interpreter of the menu */
934933 TkMenu *menuPtr, /* The menu we are posting */
935934 int x, int y, int index) /* The root X,Y coordinates where the
936935 * specified entry will be posted */
10201019
10211020 static void
10221021 GetMenuSeparatorGeometry(
1023 TkMenu *menuPtr, /* The menu we are measuring */
1024 TkMenuEntry *mePtr, /* The entry we are measuring */
1025 Tk_Font tkfont, /* The precalculated font */
1022 TCL_UNUSED(TkMenu *), /* The menu we are measuring */
1023 TCL_UNUSED(TkMenuEntry *), /* The entry we are measuring */
1024 TCL_UNUSED(Tk_Font), /* The precalculated font */
10261025 const Tk_FontMetrics *fmPtr,/* The precalcualted font metrics */
10271026 int *widthPtr, /* The resulting width */
10281027 int *heightPtr) /* The resulting height */
10501049 static void
10511050 GetTearoffEntryGeometry(
10521051 TkMenu *menuPtr, /* The menu we are drawing */
1053 TkMenuEntry *mePtr, /* The entry we are measuring */
1052 TCL_UNUSED(TkMenuEntry *), /* The entry we are measuring */
10541053 Tk_Font tkfont, /* The precalculated font */
10551054 const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
10561055 int *widthPtr, /* The resulting width */
10571056 int *heightPtr) /* The resulting height */
10581057 {
1059 if (menuPtr->menuType != MASTER_MENU) {
1058 if (menuPtr->menuType != MAIN_MENU) {
10601059 *heightPtr = 0;
10611060 *widthPtr = 0;
10621061 } else {
10911090 Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
10921091 int width, height, i, j, x, y, currentRowHeight, maxWidth;
10931092 int maxWindowWidth, lastRowBreak, lastEntry;
1094 int borderWidth, activeBorderWidth, helpMenuIndex = -1;
1093 int activeBorderWidth, helpMenuIndex = -1;
10951094 TkMenuEntry *mePtr;
10961095
10971096 if (menuPtr->tkwin == NULL) {
10981097 return;
10991098 }
11001099
1101 Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
1102 &borderWidth);
11031100 Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
11041101 &activeBorderWidth);
11051102 maxWidth = 0;
11101107
11111108 maxWindowWidth = Tk_Width(menuPtr->tkwin);
11121109 if (maxWindowWidth == 1) {
1113 maxWindowWidth = 0x7ffffff;
1110 maxWindowWidth = 0x7FFFFFF;
11141111 }
11151112 currentRowHeight = 0;
11161113 Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
11211118 /*
11221119 * On the Mac especially, getting font metrics can be quite slow, so
11231120 * we want to do it intelligently. We are going to precalculate them
1124 * and pass them down to all of the measureing and drawing routines.
1121 * and pass them down to all of the measuring and drawing routines.
11251122 * We will measure the font metrics of the menu once, and if an entry
11261123 * has a font set, we will measure it as we come to it, and then we
11271124 * decide which set to give the geometry routines.
12681265 static void
12691266 DrawTearoffEntry(
12701267 TkMenu *menuPtr, /* The menu we are drawing */
1271 TkMenuEntry *mePtr, /* The entry we are drawing */
1268 TCL_UNUSED(TkMenuEntry *), /* The entry we are drawing */
12721269 Drawable d, /* The drawable we are drawing into */
1273 GC gc, /* The gc we are drawing with */
1274 Tk_Font tkfont, /* The font we are drawing with */
1275 const Tk_FontMetrics *fmPtr,/* The metrics we are drawing with */
1270 TCL_UNUSED(GC), /* The gc we are drawing with */
1271 TCL_UNUSED(Tk_Font), /* The font we are drawing with */
1272 TCL_UNUSED(const Tk_FontMetrics *),/* The metrics we are drawing with */
12761273 int x, int y,
12771274 int width, int height)
12781275 {
12801277 int segmentWidth, maxX;
12811278 Tk_3DBorder border;
12821279
1283 if (menuPtr->menuType != MASTER_MENU) {
1280 if (menuPtr->menuType != MAIN_MENU) {
12841281 return;
12851282 }
12861283
13231320
13241321 void
13251322 TkpInitializeMenuBindings(
1326 Tcl_Interp *interp, /* The interpreter to set. */
1327 Tk_BindingTable bindingTable)
1323 TCL_UNUSED(Tcl_Interp *), /* The interpreter to set. */
1324 TCL_UNUSED(Tk_BindingTable))
13281325 /* The table to add to. */
13291326 {
13301327 /*
13751372 && (cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin != NULL)
13761373 && (menuPtr->masterMenuPtr->tkwin != NULL)) {
13771374 TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr;
1378 char *helpMenuName = ckalloc(strlen(Tk_PathName(
1375 char *helpMenuName = (char *)ckalloc(strlen(Tk_PathName(
13791376 masterMenuPtr->tkwin)) + strlen(".help") + 1);
13801377
13811378 strcpy(helpMenuName, Tk_PathName(masterMenuPtr->tkwin));
18511848
18521849 void
18531850 TkpMenuNotifyToplevelCreate(
1854 Tcl_Interp *interp, /* The interp the menu lives in. */
1855 const char *menuName) /* The name of the menu to reconfigure. */
1851 TCL_UNUSED(Tcl_Interp *), /* The interp the menu lives in. */
1852 TCL_UNUSED(const char *)) /* The name of the menu to reconfigure. */
18561853 {
18571854 /*
18581855 * Nothing to do.
2424 * Returns a newly allocated TkMenuButton structure.
2525 *
2626 * Side effects:
27 * Registers an event handler for the widget.
27 * None
2828 *
2929 *----------------------------------------------------------------------
3030 */
3131
3232 TkMenuButton *
3333 TkpCreateMenuButton(
34 Tk_Window tkwin)
34 TCL_UNUSED(Tk_Window))
3535 {
36 return ckalloc(sizeof(TkMenuButton));
36 return (TkMenuButton *)ckalloc(sizeof(TkMenuButton));
3737 }
3838
3939 /*
5757 TkpDisplayMenuButton(
5858 ClientData clientData) /* Information about widget. */
5959 {
60 register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
60 TkMenuButton *mbPtr = (TkMenuButton *)clientData;
6161 GC gc;
6262 Tk_3DBorder border;
6363 Pixmap pixmap;
6464 int x = 0; /* Initialization needed only to stop compiler
6565 * warning. */
6666 int y = 0;
67 register Tk_Window tkwin = mbPtr->tkwin;
67 Tk_Window tkwin = mbPtr->tkwin;
6868 int fullWidth, fullHeight;
6969 int textXOffset, textYOffset;
7070 int imageWidth, imageHeight;
279279 mbPtr->borderWidth, mbPtr->relief);
280280 }
281281 if (mbPtr->highlightWidth != 0) {
282 GC gc;
283
284282 if (mbPtr->flags & GOT_FOCUS) {
285283 gc = Tk_GCForColor(mbPtr->highlightColorPtr, pixmap);
286284 } else {
1717 #define __UNIX__ 1
1818
1919 #include <stdio.h>
20 #include <pwd.h>
21 #include <assert.h>
22 #include <errno.h>
23 #include <fcntl.h>
2024 #include <ctype.h>
21 #include <fcntl.h>
25 #include <math.h>
26 #include <string.h>
2227 #include <limits.h>
23 #include <math.h>
24 #include <pwd.h>
2528 #ifdef NO_STDLIB_H
2629 # include "../compat/stdlib.h"
2730 #else
2831 # include <stdlib.h>
2932 #endif
30 #include <assert.h>
31 #include <string.h>
3233 #include <sys/types.h>
3334 #include <sys/file.h>
3435 #ifdef HAVE_SYS_SELECT_H
4344 # include <time.h>
4445 #else
4546 # if HAVE_SYS_TIME_H
46 # include <sys/time.h>
47 # include <sys/time.h>
4748 # else
48 # include <time.h>
49 # include <time.h>
4950 # endif
5051 #endif
5152 #if HAVE_INTTYPES_H
189190 sprintf((buf), "%#08lx", (unsigned long) (w))
190191 #endif
191192
193 /*
194 * Used by tkWindow.c
195 */
196
197 #define TkpHandleMapOrUnmap(tkwin, event) Tk_HandleEvent(event)
198
192199 #endif /* _UNIXPORT */
1111 #include "tkUnixInt.h"
1212 #include "tkFont.h"
1313 #include <X11/Xft/Xft.h>
14 #include <ctype.h>
1514
1615 #define MAX_CACHED_COLORS 16
1716
6059 * the TIP 59 configuration database.
6160 */
6261
63 #ifndef TCL_CFGVAL_ENCODING
64 #define TCL_CFGVAL_ENCODING "ascii"
65 #endif
62 static int utf8ToUcs4(const char *source, FcChar32 *c, int numBytes)
63 {
64 if (numBytes >= 6) {
65 return TkUtfToUniChar(source, (int *)c);
66 }
67 return FcUtf8ToUcs4((const FcChar8 *)source, c, numBytes);
68 }
6669
6770 void
6871 TkpFontPkgInit(
7376 { 0,0 }
7477 };
7578
76 Tcl_RegisterConfig(mainPtr->interp, "tk", cfg, TCL_CFGVAL_ENCODING);
79 Tcl_RegisterConfig(mainPtr->interp, "tk", cfg, "utf-8");
7780 }
7881
7982 static XftFont *
246249 *---------------------------------------------------------------------------
247250 */
248251
252 static void
253 FinishedWithFont(
254 UnixFtFont *fontPtr);
255
256 static int
257 InitFontErrorProc(
258 ClientData clientData,
259 TCL_UNUSED(XErrorEvent *))
260 {
261 int *errorFlagPtr = (int *)clientData;
262
263 if (errorFlagPtr != NULL) {
264 *errorFlagPtr = 1;
265 }
266 return 0;
267 }
268
249269 static UnixFtFont *
250270 InitFont(
251271 Tk_Window tkwin,
256276 FcCharSet *charset;
257277 FcResult result;
258278 XftFont *ftFont;
259 int i, iWidth;
279 int i, iWidth, errorFlag;
280 Tk_ErrorHandler handler;
260281
261282 if (!fontPtr) {
262 fontPtr = ckalloc(sizeof(UnixFtFont));
283 fontPtr = (UnixFtFont *)ckalloc(sizeof(UnixFtFont));
263284 }
264285
265286 FcConfigSubstitute(0, pattern, FcMatchPattern);
270291 */
271292
272293 set = FcFontSort(0, pattern, FcTrue, NULL, &result);
273 if (!set) {
294 if (!set || set->nfont == 0) {
274295 ckfree(fontPtr);
275296 return NULL;
276297 }
277298
278299 fontPtr->fontset = set;
279300 fontPtr->pattern = pattern;
280 fontPtr->faces = ckalloc(set->nfont * sizeof(UnixFtFace));
301 fontPtr->faces = (UnixFtFace *)ckalloc(set->nfont * sizeof(UnixFtFace));
281302 fontPtr->nfaces = set->nfont;
282303
283304 /*
307328 * Fill in platform-specific fields of TkFont.
308329 */
309330
331 errorFlag = 0;
332 handler = Tk_CreateErrorHandler(Tk_Display(tkwin),
333 -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag);
310334 ftFont = GetFont(fontPtr, 0, 0.0);
335 if ((ftFont == NULL) || errorFlag) {
336 Tk_DeleteErrorHandler(handler);
337 FinishedWithFont(fontPtr);
338 ckfree(fontPtr);
339 return NULL;
340 }
311341 fontPtr->font.fid = XLoadFont(Tk_Display(tkwin), "fixed");
312342 GetTkFontAttributes(ftFont, &fontPtr->font.fa);
313343 GetTkFontMetrics(ftFont, &fontPtr->font.fm);
344 Tk_DeleteErrorHandler(handler);
345 if (errorFlag) {
346 FinishedWithFont(fontPtr);
347 ckfree(fontPtr);
348 return NULL;
349 }
314350
315351 /*
316352 * Fontconfig can't report any information about the position or thickness
335371 TkFont *fPtr = &fontPtr->font;
336372
337373 fPtr->underlinePos = fPtr->fm.descent / 2;
374 handler = Tk_CreateErrorHandler(Tk_Display(tkwin),
375 -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag);
376 errorFlag = 0;
338377 Tk_MeasureChars((Tk_Font) fPtr, "I", 1, -1, 0, &iWidth);
378 Tk_DeleteErrorHandler(handler);
379 if (errorFlag) {
380 FinishedWithFont(fontPtr);
381 ckfree(fontPtr);
382 return NULL;
383 }
339384 fPtr->underlineHeight = iWidth / 3;
340385 if (fPtr->underlineHeight == 0) {
341386 fPtr->underlineHeight = 1;
615660
616661 void
617662 TkpGetFontAttrsForChar(
618 Tk_Window tkwin, /* Window on the font's display */
663 TCL_UNUSED(Tk_Window), /* Window on the font's display */
619664 Tk_Font tkfont, /* Font to query */
620665 int c, /* Character of interest */
621666 TkFontAttributes *faPtr) /* Output: Font attributes */
660705 FcChar32 c;
661706 XGlyphInfo extents;
662707 int clen, curX, newX, curByte, newByte, sawNonSpace;
663 int termByte = 0, termX = 0;
708 int termByte = 0, termX = 0, errorFlag = 0;
709 Tk_ErrorHandler handler;
664710 #if DEBUG_FONTSEL
665711 char string[256];
666712 int len = 0;
667713 #endif /* DEBUG_FONTSEL */
668714
715 handler = Tk_CreateErrorHandler(fontPtr->display,
716 -1, -1, -1, InitFontErrorProc, &errorFlag);
669717 curX = 0;
670718 curByte = 0;
671719 sawNonSpace = 0;
701749 #endif /* DEBUG_FONTSEL */
702750 ftFont = GetFont(fontPtr, c, 0.0);
703751
704 XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
752 if (!errorFlag) {
753 XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
754 } else {
755 extents.xOff = 0;
756 errorFlag = 0;
757 }
705758
706759 newX = curX + extents.xOff;
707760 newByte = curByte + clen;
730783 curX = newX;
731784 curByte = newByte;
732785 }
786 Tk_DeleteErrorHandler(handler);
733787 #if DEBUG_FONTSEL
734788 string[len] = '\0';
735789 printf("MeasureChars %s length %d bytes %d\n", string, curX, curByte);
823877 fontPtr->colors[last].color.color.red = xcolor.red;
824878 fontPtr->colors[last].color.color.green = xcolor.green;
825879 fontPtr->colors[last].color.color.blue = xcolor.blue;
826 fontPtr->colors[last].color.color.alpha = 0xffff;
880 fontPtr->colors[last].color.color.alpha = 0xFFFF;
827881 fontPtr->colors[last].color.pixel = pixel;
828882
829883 /*
885939 }
886940 XGetGCValues(display, gc, GCForeground, &values);
887941 xftcolor = LookUpColor(display, fontPtr, values.foreground);
888 if (tsdPtr->clipRegion != None) {
942 if (tsdPtr->clipRegion != NULL) {
889943 XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
890944 }
891945 nspec = 0;
893947 XftFont *ftFont;
894948 FcChar32 c;
895949
896 clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
950 clen = utf8ToUcs4(source, &c, numBytes);
897951 if (clen <= 0) {
898952 /*
899953 * This should not happen, but it can.
935989 }
936990
937991 doUnderlineStrikeout:
938 if (tsdPtr->clipRegion != None) {
992 if (tsdPtr->clipRegion != NULL) {
939993 XftDrawSetClip(fontPtr->ftDraw, NULL);
940994 }
941995 if (fontPtr->font.fa.underline != 0) {
10271081
10281082 nglyph = 0;
10291083 currentFtFont = NULL;
1030 originX = originY = 0; /* lint */
1084 originX = originY = 0;
10311085
10321086 while (numBytes > 0) {
10331087 XftFont *ftFont;
10341088 FcChar32 c;
10351089
1036 clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
1090 clen = utf8ToUcs4(source, &c, numBytes);
10371091 if (clen <= 0) {
10381092 /*
10391093 * This should not happen, but it can.
11291183 }
11301184 XGetGCValues(display, gc, GCForeground, &values);
11311185 xftcolor = LookUpColor(display, fontPtr, values.foreground);
1132 if (tsdPtr->clipRegion != None) {
1186 if (tsdPtr->clipRegion != NULL) {
11331187 XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
11341188 }
11351189 nspec = 0;
11371191 XftFont *ftFont, *ft0Font;
11381192 FcChar32 c;
11391193
1140 clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
1194 clen = utf8ToUcs4(source, &c, numBytes);
11411195 if (clen <= 0) {
11421196 /*
11431197 * This should not happen, but it can.
11811235 #endif /* XFT_HAS_FIXED_ROTATED_PLACEMENT */
11821236
11831237 doUnderlineStrikeout:
1184 if (tsdPtr->clipRegion != None) {
1238 if (tsdPtr->clipRegion != NULL) {
11851239 XftDrawSetClip(fontPtr->ftDraw, NULL);
11861240 }
11871241 if (fontPtr->font.fa.underline || fontPtr->font.fa.overstrike) {
12401294 }
12411295 }
12421296
1297 /*
1298 *---------------------------------------------------------------------------
1299 *
1300 * TkpDrawCharsInContext --
1301 *
1302 * Draw a string of characters on the screen like Tk_DrawChars(), but
1303 * with access to all the characters on the line for context. On X11 this
1304 * context isn't consulted, so we just call Tk_DrawChars().
1305 *
1306 * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this
1307 * function is unused (and possibly unfinished). See [7655f65ae7].
1308 *
1309 * Results:
1310 * None.
1311 *
1312 * Side effects:
1313 * Information gets drawn on the screen.
1314 *
1315 *---------------------------------------------------------------------------
1316 */
1317
1318 void
1319 TkpDrawCharsInContext(
1320 Display *display, /* Display on which to draw. */
1321 Drawable drawable, /* Window or pixmap in which to draw. */
1322 GC gc, /* Graphics context for drawing characters. */
1323 Tk_Font tkfont, /* Font in which characters will be drawn;
1324 * must be the same as font used in GC. */
1325 const char *source, /* UTF-8 string to be displayed. Need not be
1326 * '\0' terminated. All Tk meta-characters
1327 * (tabs, control characters, and newlines)
1328 * should be stripped out of the string that
1329 * is passed to this function. If they are not
1330 * stripped out, they will be displayed as
1331 * regular printing characters. */
1332 int numBytes, /* Number of bytes in string. */
1333 int rangeStart, /* Index of first byte to draw. */
1334 int rangeLength, /* Length of range to draw in bytes. */
1335 int x, int y) /* Coordinates at which to place origin of the
1336 * whole (not just the range) string when
1337 * drawing. */
1338 {
1339 int widthUntilStart;
1340
1341 (void) numBytes; /*unused*/
1342
1343 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
1344 Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
1345 rangeLength, x+widthUntilStart, y);
1346 }
1347
1348 void
1349 TkpDrawAngledCharsInContext(
1350 Display *display, /* Display on which to draw. */
1351 Drawable drawable, /* Window or pixmap in which to draw. */
1352 GC gc, /* Graphics context for drawing characters. */
1353 Tk_Font tkfont, /* Font in which characters will be drawn; must
1354 * be the same as font used in GC. */
1355 const char * source, /* UTF-8 string to be displayed. Need not be
1356 * '\0' terminated. All Tk meta-characters
1357 * (tabs, control characters, and newlines)
1358 * should be stripped out of the string that is
1359 * passed to this function. If they are not
1360 * stripped out, they will be displayed as
1361 * regular printing characters. */
1362 int numBytes, /* Number of bytes in string. */
1363 int rangeStart, /* Index of first byte to draw. */
1364 int rangeLength, /* Length of range to draw in bytes. */
1365 double x, double y, /* Coordinates at which to place origin of the
1366 * whole (not just the range) string when
1367 * drawing. */
1368 double angle) /* What angle to put text at, in degrees. */
1369 {
1370 int widthUntilStart;
1371 double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
1372
1373 (void) numBytes; /*unused*/
1374
1375 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
1376 TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart,
1377 rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle);
1378 }
1379
12431380 void
12441381 TkUnixSetXftClipRegion(
12451382 TkRegion clipRegion) /* The clipping region to install. */
4949
5050 TkScale *
5151 TkpCreateScale(
52 Tk_Window tkwin)
52 TCL_UNUSED(Tk_Window))
5353 {
54 return ckalloc(sizeof(TkScale));
54 return (TkScale *)ckalloc(sizeof(TkScale));
5555 }
5656
5757 /*
255255
256256 static void
257257 DisplayVerticalValue(
258 register TkScale *scalePtr, /* Information about widget in which to
258 TkScale *scalePtr, /* Information about widget in which to
259259 * display value. */
260260 Drawable drawable, /* Pixmap or window in which to draw the
261261 * value. */
266266 * specified in pixels. */
267267 const char *format) /* Format string to use for the value */
268268 {
269 register Tk_Window tkwin = scalePtr->tkwin;
269 Tk_Window tkwin = scalePtr->tkwin;
270270 int y, width, length;
271271 char valueString[TCL_DOUBLE_SPACE];
272272 Tk_FontMetrics fm;
324324 * to reflect the part of the window that was
325325 * redrawn. */
326326 {
327 register Tk_Window tkwin = scalePtr->tkwin;
327 Tk_Window tkwin = scalePtr->tkwin;
328328 int x, y, width, height, shadowWidth;
329329 double tickInterval = scalePtr->tickInterval;
330330 Tk_3DBorder sliderBorder;
478478
479479 static void
480480 DisplayHorizontalValue(
481 register TkScale *scalePtr, /* Information about widget in which to
481 TkScale *scalePtr, /* Information about widget in which to
482482 * display value. */
483483 Drawable drawable, /* Pixmap or window in which to draw the
484484 * value. */
489489 * in pixels. */
490490 const char *format) /* Format string to use for the value */
491491 {
492 register Tk_Window tkwin = scalePtr->tkwin;
492 Tk_Window tkwin = scalePtr->tkwin;
493493 int x, y, length, width;
494494 char valueString[TCL_DOUBLE_SPACE];
495495 Tk_FontMetrics fm;
545545 TkpDisplayScale(
546546 ClientData clientData) /* Widget record for scale. */
547547 {
548 TkScale *scalePtr = (TkScale *) clientData;
548 TkScale *scalePtr = (TkScale *)clientData;
549549 Tk_Window tkwin = scalePtr->tkwin;
550550 Tcl_Interp *interp = scalePtr->interp;
551551 Pixmap pixmap;
574574 Tcl_DStringAppend(&buf, scalePtr->command, -1);
575575 Tcl_DStringAppend(&buf, " ", -1);
576576 Tcl_DStringAppend(&buf, string, -1);
577 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
577 result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
578578 Tcl_DStringFree(&buf);
579579 if (result != TCL_OK) {
580580 Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
6262 TkpCreateScrollbar(
6363 Tk_Window tkwin)
6464 {
65 UnixScrollbar *scrollPtr = ckalloc(sizeof(UnixScrollbar));
65 UnixScrollbar *scrollPtr = (UnixScrollbar *)ckalloc(sizeof(UnixScrollbar));
6666
6767 scrollPtr->troughGC = NULL;
6868 scrollPtr->copyGC = NULL;
9696 TkpDisplayScrollbar(
9797 ClientData clientData) /* Information about window. */
9898 {
99 register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
100 register Tk_Window tkwin = scrollPtr->tkwin;
99 TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
100 Tk_Window tkwin = scrollPtr->tkwin;
101101 XPoint points[7];
102102 Tk_3DBorder border;
103103 int relief, width, elementBorderWidth;
276276
277277 extern void
278278 TkpComputeScrollbarGeometry(
279 register TkScrollbar *scrollPtr)
279 TkScrollbar *scrollPtr)
280280 /* Scrollbar whose geometry may have
281281 * changed. */
282282 {
393393
394394 void
395395 TkpConfigureScrollbar(
396 register TkScrollbar *scrollPtr)
396 TkScrollbar *scrollPtr)
397397 /* Information about widget; may or may not
398398 * already have values for some fields. */
399399 {
400400 XGCValues gcValues;
401 GC new;
401 GC newGC;
402402 UnixScrollbar *unixScrollPtr = (UnixScrollbar *) scrollPtr;
403403
404404 Tk_SetBackgroundFromBorder(scrollPtr->tkwin, scrollPtr->bgBorder);
405405
406406 gcValues.foreground = scrollPtr->troughColorPtr->pixel;
407 new = Tk_GetGC(scrollPtr->tkwin, GCForeground, &gcValues);
407 newGC = Tk_GetGC(scrollPtr->tkwin, GCForeground, &gcValues);
408408 if (unixScrollPtr->troughGC != NULL) {
409409 Tk_FreeGC(scrollPtr->display, unixScrollPtr->troughGC);
410410 }
411 unixScrollPtr->troughGC = new;
411 unixScrollPtr->troughGC = newGC;
412412 if (unixScrollPtr->copyGC == NULL) {
413413 gcValues.graphics_exposures = False;
414414 unixScrollPtr->copyGC = Tk_GetGC(scrollPtr->tkwin,
436436
437437 int
438438 TkpScrollbarPosition(
439 register TkScrollbar *scrollPtr,
439 TkScrollbar *scrollPtr,
440440 /* Scrollbar widget record. */
441441 int x, int y) /* Coordinates within scrollPtr's window. */
442442 {
443443 int length, width, tmp;
444 register const int inset = scrollPtr->inset;
444 const int inset = scrollPtr->inset;
445445
446446 if (scrollPtr->vertical) {
447447 length = Tk_Height(scrollPtr->tkwin);
239239
240240 void
241241 TkSelPropProc(
242 register XEvent *eventPtr) /* X PropertyChange event. */
242 XEvent *eventPtr) /* X PropertyChange event. */
243243 {
244 register IncrInfo *incrPtr;
245 register TkSelHandler *selPtr;
244 IncrInfo *incrPtr;
245 TkSelHandler *selPtr;
246246 int length, numItems;
247247 unsigned long i;
248248 Atom target, formatType;
249249 long buffer[TK_SEL_WORDS_AT_ONCE];
250250 TkDisplay *dispPtr = TkGetDisplay(eventPtr->xany.display);
251251 Tk_ErrorHandler errorHandler;
252 ThreadSpecificData *tsdPtr =
252 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
253253 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
254254
255255 /*
355355 ((char *) buffer)[numItems] = 0;
356356
357357 errorHandler = Tk_CreateErrorHandler(eventPtr->xproperty.display,
358 -1, -1, -1, (int (*)()) NULL, NULL);
358 -1, -1, -1, NULL, NULL);
359359
360360 /*
361361 * Encode the data using the proper format for each type.
448448 if (srcLen > 3) {
449449 Tcl_Panic("selection conversion left too many bytes unconverted");
450450 }
451 memcpy(incrPtr->converts[i].buffer, src, (size_t) srcLen+1);
451 memcpy(incrPtr->converts[i].buffer, src, srcLen + 1);
452452 Tcl_DStringFree(&ds);
453453 } else {
454454 /*
518518 void
519519 TkSelEventProc(
520520 Tk_Window tkwin, /* Window for which event was targeted. */
521 register XEvent *eventPtr) /* X event: either SelectionClear,
521 XEvent *eventPtr) /* X event: either SelectionClear,
522522 * SelectionRequest, or SelectionNotify. */
523523 {
524 register TkWindow *winPtr = (TkWindow *) tkwin;
524 TkWindow *winPtr = (TkWindow *) tkwin;
525525 TkDisplay *dispPtr = winPtr->dispPtr;
526526 Tcl_Interp *interp;
527527
539539 */
540540
541541 if (eventPtr->type == SelectionNotify) {
542 register TkSelRetrievalInfo *retrPtr;
542 TkSelRetrievalInfo *retrPtr;
543543 char *propInfo, **propInfoPtr = &propInfo;
544544 Atom type;
545545 int format, result;
546546 unsigned long numItems, bytesAfter;
547 Tcl_DString ds;
548547
549548 for (retrPtr = pendingRetrievals; ; retrPtr = retrPtr->nextPtr) {
550549 if (retrPtr == NULL) {
590589 if ((type == XA_STRING) || (type == dispPtr->textAtom)
591590 || (type == dispPtr->compoundTextAtom)) {
592591 Tcl_Encoding encoding;
592 Tcl_DString ds;
593593
594594 if (format != 8) {
595595 Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
648648 }
649649
650650 if (propInfo[numItems] != '\0') {
651 propData = ckalloc(numItems + 1);
651 propData = (char *)ckalloc(numItems + 1);
652652 strcpy(propData, propInfo);
653653 propData[numItems] = '\0';
654654 }
741741 SelTimeoutProc(
742742 ClientData clientData) /* Information about retrieval in progress. */
743743 {
744 register TkSelRetrievalInfo *retrPtr = clientData;
744 TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
745745
746746 /*
747747 * Make sure that the retrieval is still in progress. Then see how long
765765 retrPtr->result = TCL_ERROR;
766766 } else {
767767 retrPtr->timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
768 (ClientData) retrPtr);
768 retrPtr);
769769 }
770770 }
771771
795795 * request; may not be selection's current
796796 * owner, be we set it to the current
797797 * owner. */
798 register XSelectionRequestEvent *eventPtr)
798 XSelectionRequestEvent *eventPtr)
799799 /* Event describing request. */
800800 {
801801 union {
812812 Tk_ErrorHandler errorHandler;
813813 TkSelectionInfo *infoPtr;
814814 TkSelInProgress ip;
815 ThreadSpecificData *tsdPtr =
815 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
816816 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
817817
818 errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,-1,
819 (int (*)()) NULL, NULL);
818 errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,
819 -1, NULL, NULL);
820820
821821 /*
822822 * Initialize the reply event.
892892 * below).
893893 */
894894
895 incr.converts = ckalloc(incr.numConversions * sizeof(ConvertInfo));
895 incr.converts = (ConvertInfo *)ckalloc(incr.numConversions * sizeof(ConvertInfo));
896896 incr.numIncrs = 0;
897897 for (i = 0; i < incr.numConversions; i++) {
898898 Atom target, property, type;
899899 long buffer[TK_SEL_WORDS_AT_ONCE];
900 register TkSelHandler *selPtr;
900 TkSelHandler *selPtr;
901901 int numItems, format;
902902 char *propPtr;
903903
918918 /*
919919 * Nobody seems to know about this kind of request. If it's of a
920920 * sort that we can handle without any help, do it. Otherwise mark
921 * the request as an errror.
921 * the request as an error.
922922 */
923923
924924 numItems = TkSelDefaultSelection(infoPtr, target, (char *) buffer,
10631063 }
10641064 Tcl_DeleteTimerHandler(incr.timeout);
10651065 errorHandler = Tk_CreateErrorHandler(winPtr->display,
1066 -1, -1, -1, (int (*)()) NULL, NULL);
1066 -1, -1, -1, NULL, NULL);
10671067 XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L);
10681068 Tk_DeleteErrorHandler(errorHandler);
10691069 if (tsdPtr->pendingIncrs == &incr) {
11231123 static void
11241124 SelRcvIncrProc(
11251125 ClientData clientData, /* Information about retrieval. */
1126 register XEvent *eventPtr) /* X PropertyChange event. */
1126 XEvent *eventPtr) /* X PropertyChange event. */
11271127 {
1128 register TkSelRetrievalInfo *retrPtr = clientData;
1128 TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
11291129 char *propInfo, **propInfoPtr = &propInfo;
11301130 Atom type;
11311131 int format, result;
13731373 * retrieval for which we are selection
13741374 * owner. */
13751375 {
1376 register IncrInfo *incrPtr = clientData;
1376 IncrInfo *incrPtr = (IncrInfo *)clientData;
13771377
13781378 incrPtr->idleTime++;
13791379 if (incrPtr->idleTime >= 5) {
14341434 if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) {
14351435 return NULL;
14361436 }
1437 propPtr = ckalloc(numFields * sizeof(long));
1437 propPtr = (long *)ckalloc(numFields * sizeof(long));
14381438
14391439 /*
14401440 * Convert the fields one-by-one.
14861486
14871487 static void
14881488 SelCvtFromX32(
1489 register long *propPtr, /* Property value from X. */
1489 long *propPtr, /* Property value from X. */
14901490 int numValues, /* Number of 32-bit values in property. */
14911491 Atom type, /* Type of property Should not be XA_STRING
14921492 * (if so, don't bother calling this function
15191519
15201520 static void
15211521 SelCvtFromX8(
1522 register char *propPtr, /* Property value from X. */
1522 char *propPtr, /* Property value from X. */
15231523 int numValues, /* Number of 8-bit values in property. */
1524 Atom type, /* Type of property Should not be XA_STRING
1524 TCL_UNUSED(Atom), /* Type of property Should not be XA_STRING
15251525 * (if so, don't bother calling this function
15261526 * at all). */
1527 Tk_Window tkwin, /* Window to use for atom conversion. */
1527 TCL_UNUSED(Tk_Window), /* Window to use for atom conversion. */
15281528 Tcl_DString *dsPtr) /* Where to store the converted string. */
15291529 {
15301530 /*
268268
269269 handler = Tk_CreateErrorHandler(dispPtr->display, -1, -1, -1, NULL, NULL);
270270
271 regPtr = ckalloc(sizeof(NameRegistry));
271 regPtr = (NameRegistry *)ckalloc(sizeof(NameRegistry));
272272 regPtr->dispPtr = dispPtr;
273273 regPtr->locked = 0;
274274 regPtr->modified = 0;
478478 sprintf(id, "%x ", (unsigned) commWindow);
479479 idLength = strlen(id);
480480 newBytes = idLength + strlen(name) + 1;
481 newProp = ckalloc(regPtr->propLength + newBytes);
481 newProp = (char *)ckalloc(regPtr->propLength + newBytes);
482482 strcpy(newProp, id);
483483 strcpy(newProp+idLength, name);
484484 if (regPtr->property != NULL) {
807807 const char *actualName;
808808 Tcl_DString dString;
809809 int offset, i;
810 ThreadSpecificData *tsdPtr =
810 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
811811 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
812812
813813 interp = winPtr->mainPtr->interp;
829829 * the "send" command to the interpreter.
830830 */
831831
832 riPtr = ckalloc(sizeof(RegisteredInterp));
832 riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
833833 riPtr->interp = interp;
834834 riPtr->dispPtr = winPtr->dispPtr;
835835 riPtr->nextPtr = tsdPtr->interpListPtr;
913913
914914 RegAddName(regPtr, actualName, Tk_WindowId(dispPtr->commTkwin));
915915 RegClose(regPtr);
916 riPtr->name = ckalloc(strlen(actualName) + 1);
916 riPtr->name = (char *)ckalloc(strlen(actualName) + 1);
917917 strcpy(riPtr->name, actualName);
918918 if (actualName != name) {
919919 Tcl_DStringFree(&dString);
942942
943943 int
944944 Tk_SendObjCmd(
945 ClientData clientData, /* Information about sender (only dispPtr
945 TCL_UNUSED(void *), /* Information about sender (only dispPtr
946946 * field is used). */
947947 Tcl_Interp *interp, /* Current interpreter. */
948948 int objc, /* Number of arguments. */
957957 TkWindow *winPtr;
958958 Window commWindow;
959959 PendingCommand pending;
960 register RegisteredInterp *riPtr;
960 RegisteredInterp *riPtr;
961961 const char *destName;
962962 int result, index, async, i, firstArg;
963963 Tk_RestrictProc *prevProc;
966966 Tcl_Time timeout;
967967 NameRegistry *regPtr;
968968 Tcl_DString request;
969 ThreadSpecificData *tsdPtr =
969 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
970970 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
971971 Tcl_Interp *localInterp; /* Used when the interpreter to send the
972972 * command to is within the same process. */
11741174 msg = "target application died";
11751175 }
11761176 pending.code = TCL_ERROR;
1177 pending.result = ckalloc(strlen(msg) + 1);
1177 pending.result = (char *)ckalloc(strlen(msg) + 1);
11781178 strcpy(pending.result, msg);
11791179 pending.gotResponse = 1;
11801180 } else {
13551355
13561356 static int
13571357 SendInit(
1358 Tcl_Interp *interp, /* Interpreter to use for error reporting (no
1358 TCL_UNUSED(Tcl_Interp *), /* Interpreter to use for error reporting (no
13591359 * errors are ever returned, but the
13601360 * interpreter is needed anyway). */
13611361 TkDisplay *dispPtr) /* Display to initialize. */
14181418 ClientData clientData, /* Display information. */
14191419 XEvent *eventPtr) /* Information about event. */
14201420 {
1421 TkDisplay *dispPtr = clientData;
1421 TkDisplay *dispPtr = (TkDisplay *)clientData;
14221422 char *propInfo, **propInfoPtr = &propInfo;
14231423 const char *p;
14241424 int result, actualFormat;
14251425 unsigned long numItems, bytesAfter;
14261426 Atom actualType;
14271427 Tcl_Interp *remoteInterp; /* Interp in which to execute the command. */
1428 ThreadSpecificData *tsdPtr =
1428 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
14291429 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
14301430
14311431 if ((eventPtr->xproperty.atom != dispPtr->commProperty)
16971697 }
16981698 pcPtr->code = code;
16991699 if (resultString != NULL) {
1700 pcPtr->result = ckalloc(strlen(resultString) + 1);
1700 pcPtr->result = (char *)ckalloc(strlen(resultString) + 1);
17011701 strcpy(pcPtr->result, resultString);
17021702 }
17031703 if (code == TCL_ERROR) {
17041704 if (errorInfo != NULL) {
1705 pcPtr->errorInfo = ckalloc(strlen(errorInfo) + 1);
1705 pcPtr->errorInfo = (char *)ckalloc(strlen(errorInfo) + 1);
17061706 strcpy(pcPtr->errorInfo, errorInfo);
17071707 }
17081708 if (errorCode != NULL) {
1709 pcPtr->errorCode = ckalloc(strlen(errorCode) + 1);
1709 pcPtr->errorCode = (char *)ckalloc(strlen(errorCode) + 1);
17101710 strcpy(pcPtr->errorCode, errorCode);
17111711 }
17121712 }
17731773 * operation above.
17741774 */
17751775
1776 /* ARGSUSED */
17771776 static int
17781777 AppendErrorProc(
17791778 ClientData clientData, /* Command to mark complete, or NULL. */
1780 XErrorEvent *errorPtr) /* Information about error. */
1779 TCL_UNUSED(XErrorEvent *)) /* Information about error. */
17811780 {
1782 PendingCommand *pendingPtr = clientData;
1783 register PendingCommand *pcPtr;
1784 ThreadSpecificData *tsdPtr =
1781 PendingCommand *pendingPtr = (PendingCommand *)clientData;
1782 PendingCommand *pcPtr;
1783 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
17851784 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
17861785
17871786 if (pendingPtr == NULL) {
17951794 for (pcPtr = tsdPtr->pendingCommands; pcPtr != NULL;
17961795 pcPtr = pcPtr->nextPtr) {
17971796 if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) {
1798 pcPtr->result = ckalloc(strlen(pcPtr->target) + 50);
1797 pcPtr->result = (char *)ckalloc(strlen(pcPtr->target) + 50);
17991798 sprintf(pcPtr->result, "no application named \"%s\"",
18001799 pcPtr->target);
18011800 pcPtr->code = TCL_ERROR;
18281827 ClientData clientData) /* Info about registration, passed as
18291828 * ClientData. */
18301829 {
1831 RegisteredInterp *riPtr = clientData;
1832 register RegisteredInterp *riPtr2;
1830 RegisteredInterp *riPtr = (RegisteredInterp *)clientData;
1831 RegisteredInterp *riPtr2;
18331832 NameRegistry *regPtr;
1834 ThreadSpecificData *tsdPtr =
1833 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
18351834 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
18361835
18371836 regPtr = RegOpen(riPtr->interp, riPtr->dispPtr, 1);
18731872 *----------------------------------------------------------------------
18741873 */
18751874
1876 /* ARGSUSED */
18771875 static Tk_RestrictAction
18781876 SendRestrictProc(
1879 ClientData clientData, /* Not used. */
1880 register XEvent *eventPtr) /* Event that just arrived. */
1877 TCL_UNUSED(void *), /* Not used. */
1878 XEvent *eventPtr) /* Event that just arrived. */
18811879 {
18821880 TkDisplay *dispPtr;
18831881
19201918 {
19211919 Tcl_DString names;
19221920 RegisteredInterp *riPtr;
1923 ThreadSpecificData *tsdPtr =
1921 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
19241922 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
19251923
19261924 Tcl_DStringInit(&names);
19531951 *----------------------------------------------------------------------
19541952 */
19551953
1956 /* ARGSUSED */
19571954 int
19581955 TkpTestsendCmd(
19591956 ClientData clientData, /* Main window for application. */
19671964 static const char *const testsendOptions[] = {
19681965 "bogus", "prop", "serial", NULL
19691966 };
1970 TkWindow *winPtr = clientData;
1967 TkWindow *winPtr = (TkWindow *)clientData;
19711968 Tk_ErrorHandler handler;
19721969 int index;
19731970
2626 /* Next in list of protocol handlers for the
2727 * same top-level window, or NULL for end of
2828 * list. */
29 Tcl_Interp *interp; /* Interpreter in which to invoke command. */
30 char command[1]; /* Tcl command to invoke when a client message
29 Tcl_Interp *interp; /* Interpreter in which to invoke command. */
30 char command[TKFLEXARRAY]; /* Tcl command to invoke when a client message
3131 * for this protocol arrives. The actual size
3232 * of the structure varies to accommodate the
3333 * needs of the actual command. THIS MUST BE
3535 } ProtocolHandler;
3636
3737 #define HANDLER_SIZE(cmdLength) \
38 ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
38 ((unsigned)((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
3939
4040 /*
4141 * Data for [wm attributes] command:
8181 * (corresponds to hints.window_group).
8282 * Malloc-ed. Note: this field doesn't get
8383 * updated if leader is destroyed. */
84 TkWindow *masterPtr; /* Master window for TRANSIENT_FOR property,
84 TkWindow *containerPtr; /* Container window for TRANSIENT_FOR property,
8585 * or NULL. */
8686 Tk_Window icon; /* Window to use as icon for this window, or
8787 * NULL. */
258258 * window (controlled by "wm resizable" command).
259259 * WM_WITHDRAWN - non-zero means that this window has explicitly
260260 * been withdrawn. If it's a transient, it should
261 * not mirror state changes in the master.
261 * not mirror state changes in the container.
262262 */
263263
264264 #define WM_NEVER_MAPPED 1
563563 TkWmNewWindow(
564564 TkWindow *winPtr) /* Newly-created top-level window. */
565565 {
566 register WmInfo *wmPtr;
566 WmInfo *wmPtr;
567567 TkDisplay *dispPtr = winPtr->dispPtr;
568568
569 wmPtr = ckalloc(sizeof(WmInfo));
569 wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
570570 memset(wmPtr, 0, sizeof(WmInfo));
571571 wmPtr->winPtr = winPtr;
572572 wmPtr->reparent = None;
573 wmPtr->masterPtr = NULL;
573 wmPtr->containerPtr = NULL;
574574 wmPtr->numTransients = 0;
575575 wmPtr->hints.flags = InputHint | StateHint;
576576 wmPtr->hints.input = True;
658658 TkWindow *winPtr) /* Top-level window that's about to be
659659 * mapped. */
660660 {
661 register WmInfo *wmPtr = winPtr->wmInfoPtr;
661 WmInfo *wmPtr = winPtr->wmInfoPtr;
662662 XTextProperty textProp;
663663
664664 if (wmPtr->flags & WM_NEVER_MAPPED) {
683683 UpdateTitle(winPtr);
684684 UpdatePhotoIcon(winPtr);
685685
686 if (wmPtr->masterPtr != NULL) {
686 if (wmPtr->containerPtr != NULL) {
687687 /*
688 * Don't map a transient if the master is not mapped.
688 * Don't map a transient if the container is not mapped.
689689 */
690690
691 if (!Tk_IsMapped(wmPtr->masterPtr)) {
691 if (!Tk_IsMapped(wmPtr->containerPtr)) {
692692 wmPtr->withdrawn = 1;
693693 wmPtr->hints.initial_state = WithdrawnState;
694694 }
699699 */
700700
701701 XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window,
702 wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window);
702 wmPtr->containerPtr->wmInfoPtr->wrapperPtr->window);
703703 }
704704
705705 wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
826826 TkWmDeadWindow(
827827 TkWindow *winPtr) /* Top-level window that's being deleted. */
828828 {
829 register WmInfo *wmPtr = winPtr->wmInfoPtr;
829 WmInfo *wmPtr = winPtr->wmInfoPtr;
830830 WmInfo *wmPtr2;
831831
832832 if (wmPtr == NULL) {
835835 if ((WmInfo *) winPtr->dispPtr->firstWmPtr == wmPtr) {
836836 winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr;
837837 } else {
838 register WmInfo *prevPtr;
838 WmInfo *prevPtr;
839839
840840 for (prevPtr = (WmInfo *) winPtr->dispPtr->firstWmPtr; ;
841841 prevPtr = prevPtr->nextPtr) {
908908 }
909909
910910 /*
911 * Reset all transient windows whose master is the dead window.
911 * Reset all transient windows whose container is the dead window.
912912 */
913913
914914 for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
915915 wmPtr2 = wmPtr2->nextPtr) {
916 if (wmPtr2->masterPtr == winPtr) {
916 if (wmPtr2->containerPtr == winPtr) {
917917 wmPtr->numTransients--;
918 Tk_DeleteEventHandler((Tk_Window) wmPtr2->masterPtr,
918 Tk_DeleteEventHandler((Tk_Window) wmPtr2->containerPtr,
919919 StructureNotifyMask, WmWaitMapProc, wmPtr2->winPtr);
920 wmPtr2->masterPtr = NULL;
920 wmPtr2->containerPtr = NULL;
921921 if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
922922 XDeleteProperty(winPtr->display, wmPtr2->wrapperPtr->window,
923923 Tk_InternAtom((Tk_Window) winPtr, "WM_TRANSIENT_FOR"));
932932 }
933933 /* ASSERT: numTransients == 0 [Bug 1789819] */
934934
935 if (wmPtr->masterPtr != NULL) {
936 wmPtr2 = wmPtr->masterPtr->wmInfoPtr;
935 if (wmPtr->containerPtr != NULL) {
936 wmPtr2 = wmPtr->containerPtr->wmInfoPtr;
937937
938938 /*
939 * If we had a master, tell them that we aren't tied to them anymore
939 * If we had a container, tell them that we aren't tied to them anymore
940940 */
941941
942942 if (wmPtr2 != NULL) {
943943 wmPtr2->numTransients--;
944944 }
945 Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
945 Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr,
946946 StructureNotifyMask, WmWaitMapProc, winPtr);
947 wmPtr->masterPtr = NULL;
947 wmPtr->containerPtr = NULL;
948948 }
949949 ckfree(wmPtr);
950950 winPtr->wmInfoPtr = NULL;
10041004 *----------------------------------------------------------------------
10051005 */
10061006
1007 /* ARGSUSED */
10081007 int
10091008 Tk_WmObjCmd(
10101009 ClientData clientData, /* Main window associated with interpreter. */
10121011 int objc, /* Number of arguments. */
10131012 Tcl_Obj *const objv[]) /* Argument objects. */
10141013 {
1015 Tk_Window tkwin = clientData;
1014 Tk_Window tkwin = (Tk_Window)clientData;
10161015 static const char *const optionStrings[] = {
10171016 "aspect", "attributes", "client", "colormapwindows",
10181017 "command", "deiconify", "focusmodel", "forget",
11811180
11821181 static int
11831182 WmAspectCmd(
1184 Tk_Window tkwin, /* Main window of the application. */
1183 TCL_UNUSED(Tk_Window), /* Main window of the application. */
11851184 TkWindow *winPtr, /* Toplevel to work with */
11861185 Tcl_Interp *interp, /* Current interpreter. */
11871186 int objc, /* Number of arguments. */
11881187 Tcl_Obj *const objv[]) /* Argument objects. */
11891188 {
1190 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1189 WmInfo *wmPtr = winPtr->wmInfoPtr;
11911190 int numer1, denom1, numer2, denom2;
11921191
11931192 if ((objc != 3) && (objc != 7)) {
13141313 SetNetWmState(winPtr, "_NET_WM_STATE_FULLSCREEN",
13151314 wmPtr->reqState.fullscreen);
13161315 break;
1317 case _WMATT_LAST_ATTRIBUTE: /* NOTREACHED */
1316 case _WMATT_LAST_ATTRIBUTE:
13181317 return TCL_ERROR;
13191318 }
13201319 return TCL_OK;
13511350 return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
13521351 case WMATT_TYPE:
13531352 return GetNetWmType(winPtr);
1354 case _WMATT_LAST_ATTRIBUTE: /*NOTREACHED*/
1353 case _WMATT_LAST_ATTRIBUTE:
13551354 break;
13561355 }
1357 /*NOTREACHED*/
13581356 return NULL;
13591357 }
13601358
13841382
13851383 static int
13861384 WmAttributesCmd(
1387 Tk_Window tkwin, /* Main window of the application. */
1385 TCL_UNUSED(Tk_Window), /* Main window of the application. */
13881386 TkWindow *winPtr, /* Toplevel to work with */
13891387 Tcl_Interp *interp, /* Current interpreter. */
13901388 int objc, /* Number of arguments. */
14481446
14491447 static int
14501448 WmClientCmd(
1451 Tk_Window tkwin, /* Main window of the application. */
1449 TCL_UNUSED(Tk_Window), /* Main window of the application. */
14521450 TkWindow *winPtr, /* Toplevel to work with */
14531451 Tcl_Interp *interp, /* Current interpreter. */
14541452 int objc, /* Number of arguments. */
14551453 Tcl_Obj *const objv[]) /* Argument objects. */
14561454 {
1457 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1455 WmInfo *wmPtr = winPtr->wmInfoPtr;
14581456 const char *argv3;
14591457 int length;
14601458
14851483 if (wmPtr->clientMachine != NULL) {
14861484 ckfree(wmPtr->clientMachine);
14871485 }
1488 wmPtr->clientMachine = ckalloc(length + 1);
1486 wmPtr->clientMachine = (char *)ckalloc(length + 1);
14891487 strcpy(wmPtr->clientMachine, argv3);
14901488 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
14911489 XTextProperty textProp;
15401538 int objc, /* Number of arguments. */
15411539 Tcl_Obj *const objv[]) /* Argument objects. */
15421540 {
1543 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1541 WmInfo *wmPtr = winPtr->wmInfoPtr;
15441542 Window *cmapList;
15451543 TkWindow *winPtr2;
15461544 int count, i, windowObjc, gotToplevel;
15831581 != TCL_OK) {
15841582 return TCL_ERROR;
15851583 }
1586 cmapList = ckalloc((windowObjc+1) * sizeof(Window));
1584 cmapList = (Window *)ckalloc((windowObjc+1) * sizeof(Window));
15871585 gotToplevel = 0;
15881586 for (i = 0; i < windowObjc; i++) {
15891587 Tk_Window mapWin;
16351633
16361634 static int
16371635 WmCommandCmd(
1638 Tk_Window tkwin, /* Main window of the application. */
1636 TCL_UNUSED(Tk_Window), /* Main window of the application. */
16391637 TkWindow *winPtr, /* Toplevel to work with */
16401638 Tcl_Interp *interp, /* Current interpreter. */
16411639 int objc, /* Number of arguments. */
16421640 Tcl_Obj *const objv[]) /* Argument objects. */
16431641 {
1644 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1642 WmInfo *wmPtr = winPtr->wmInfoPtr;
16451643 const char *argv3;
16461644 int cmdArgc;
16471645 const char **cmdArgv;
17041702
17051703 static int
17061704 WmDeiconifyCmd(
1707 Tk_Window tkwin, /* Main window of the application. */
1705 TCL_UNUSED(Tk_Window), /* Main window of the application. */
17081706 TkWindow *winPtr, /* Toplevel to work with */
17091707 Tcl_Interp *interp, /* Current interpreter. */
17101708 int objc, /* Number of arguments. */
17111709 Tcl_Obj *const objv[]) /* Argument objects. */
17121710 {
1713 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1711 WmInfo *wmPtr = winPtr->wmInfoPtr;
17141712
17151713 if (objc != 3) {
17161714 Tcl_WrongNumArgs(interp, 2, objv, "window");
17541752
17551753 static int
17561754 WmFocusmodelCmd(
1757 Tk_Window tkwin, /* Main window of the application. */
1755 TCL_UNUSED(Tk_Window), /* Main window of the application. */
17581756 TkWindow *winPtr, /* Toplevel to work with */
17591757 Tcl_Interp *interp, /* Current interpreter. */
17601758 int objc, /* Number of arguments. */
17611759 Tcl_Obj *const objv[]) /* Argument objects. */
17621760 {
1763 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1761 WmInfo *wmPtr = winPtr->wmInfoPtr;
17641762 static const char *const optionStrings[] = {
17651763 "active", "passive", NULL };
17661764 enum options {
18091807
18101808 static int
18111809 WmForgetCmd(
1812 Tk_Window tkwin, /* Main window of the application. */
1810 TCL_UNUSED(Tk_Window), /* Main window of the application. */
18131811 TkWindow *winPtr, /* Toplevel or Frame to work with */
1814 Tcl_Interp *interp, /* Current interpreter. */
1815 int objc, /* Number of arguments. */
1816 Tcl_Obj *const objv[]) /* Argument objects. */
1817 {
1818 register Tk_Window frameWin = (Tk_Window) winPtr;
1812 TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */
1813 TCL_UNUSED(int), /* Number of arguments. */
1814 TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
1815 {
1816 Tk_Window frameWin = (Tk_Window) winPtr;
18191817
18201818 if (Tk_IsTopLevel(frameWin)) {
18211819 TkFocusJoin(winPtr);
18621860
18631861 static int
18641862 WmFrameCmd(
1865 Tk_Window tkwin, /* Main window of the application. */
1863 TCL_UNUSED(Tk_Window), /* Main window of the application. */
18661864 TkWindow *winPtr, /* Toplevel to work with */
18671865 Tcl_Interp *interp, /* Current interpreter. */
18681866 int objc, /* Number of arguments. */
18691867 Tcl_Obj *const objv[]) /* Argument objects. */
18701868 {
1871 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1869 WmInfo *wmPtr = winPtr->wmInfoPtr;
18721870 Window window;
18731871 char buf[TCL_INTEGER_SPACE];
18741872
19041902
19051903 static int
19061904 WmGeometryCmd(
1907 Tk_Window tkwin, /* Main window of the application. */
1905 TCL_UNUSED(Tk_Window), /* Main window of the application. */
19081906 TkWindow *winPtr, /* Toplevel to work with */
19091907 Tcl_Interp *interp, /* Current interpreter. */
19101908 int objc, /* Number of arguments. */
19111909 Tcl_Obj *const objv[]) /* Argument objects. */
19121910 {
1913 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1911 WmInfo *wmPtr = winPtr->wmInfoPtr;
19141912 char xSign, ySign;
19151913 int width, height;
19161914 const char *argv3;
19641962
19651963 static int
19661964 WmGridCmd(
1967 Tk_Window tkwin, /* Main window of the application. */
1965 TCL_UNUSED(Tk_Window), /* Main window of the application. */
19681966 TkWindow *winPtr, /* Toplevel to work with */
19691967 Tcl_Interp *interp, /* Current interpreter. */
19701968 int objc, /* Number of arguments. */
19711969 Tcl_Obj *const objv[]) /* Argument objects. */
19721970 {
1973 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1971 WmInfo *wmPtr = winPtr->wmInfoPtr;
19741972 int reqWidth, reqHeight, widthInc, heightInc;
19751973
19761974 if ((objc != 3) && (objc != 7)) {
20692067 int objc, /* Number of arguments. */
20702068 Tcl_Obj *const objv[]) /* Argument objects. */
20712069 {
2072 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2070 WmInfo *wmPtr = winPtr->wmInfoPtr;
20732071 Tk_Window tkwin2;
20742072 WmInfo *wmPtr2;
20752073 const char *argv3;
21132111 }
21142112 wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr);
21152113 wmPtr->hints.flags |= WindowGroupHint;
2116 wmPtr->leaderName = ckalloc(length + 1);
2114 wmPtr->leaderName = (char *)ckalloc(length + 1);
21172115 strcpy(wmPtr->leaderName, argv3);
21182116 }
21192117 UpdateHints(winPtr);
21392137
21402138 static int
21412139 WmIconbitmapCmd(
2142 Tk_Window tkwin, /* Main window of the application. */
2140 TCL_UNUSED(Tk_Window), /* Main window of the application. */
21432141 TkWindow *winPtr, /* Toplevel to work with */
21442142 Tcl_Interp *interp, /* Current interpreter. */
21452143 int objc, /* Number of arguments. */
21462144 Tcl_Obj *const objv[]) /* Argument objects. */
21472145 {
2148 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2146 WmInfo *wmPtr = winPtr->wmInfoPtr;
21492147 Pixmap pixmap;
21502148 const char *argv3;
21512149
21992197
22002198 static int
22012199 WmIconifyCmd(
2202 Tk_Window tkwin, /* Main window of the application. */
2200 TCL_UNUSED(Tk_Window), /* Main window of the application. */
22032201 TkWindow *winPtr, /* Toplevel to work with */
22042202 Tcl_Interp *interp, /* Current interpreter. */
22052203 int objc, /* Number of arguments. */
22062204 Tcl_Obj *const objv[]) /* Argument objects. */
22072205 {
2208 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2206 WmInfo *wmPtr = winPtr->wmInfoPtr;
22092207
22102208 if (objc != 3) {
22112209 Tcl_WrongNumArgs(interp, 2, objv, "window");
22192217 NULL);
22202218 return TCL_ERROR;
22212219 }
2222 if (wmPtr->masterPtr != NULL) {
2220 if (wmPtr->containerPtr != NULL) {
22232221 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
22242222 "can't iconify \"%s\": it is a transient",
22252223 winPtr->pathName));
22742272 int objc, /* Number of arguments. */
22752273 Tcl_Obj *const objv[]) /* Argument objects. */
22762274 {
2277 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2275 WmInfo *wmPtr = winPtr->wmInfoPtr;
22782276 Pixmap pixmap;
22792277 const char *argv3;
22802278
23272325
23282326 static int
23292327 WmIconnameCmd(
2330 Tk_Window tkwin, /* Main window of the application. */
2328 TCL_UNUSED(Tk_Window), /* Main window of the application. */
23312329 TkWindow *winPtr, /* Toplevel to work with */
23322330 Tcl_Interp *interp, /* Current interpreter. */
23332331 int objc, /* Number of arguments. */
23342332 Tcl_Obj *const objv[]) /* Argument objects. */
23352333 {
2336 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2334 WmInfo *wmPtr = winPtr->wmInfoPtr;
23372335 const char *argv3;
23382336 int length;
23392337
23792377
23802378 static int
23812379 WmIconphotoCmd(
2382 Tk_Window tkwin, /* Main window of the application. */
2380 TCL_UNUSED(Tk_Window), /* Main window of the application. */
23832381 TkWindow *winPtr, /* Toplevel to work with */
23842382 Tcl_Interp *interp, /* Current interpreter. */
23852383 int objc, /* Number of arguments. */
23862384 Tcl_Obj *const objv[]) /* Argument objects. */
23872385 {
2388 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2386 WmInfo *wmPtr = winPtr->wmInfoPtr;
23892387 Tk_PhotoHandle photo;
23902388 Tk_PhotoImageBlock block;
23912389 int i, size = 0, width, height, index = 0, x, y, isDefault = 0;
24362434 * defines CARD32 arrays to use. [Bug 2902814]
24372435 */
24382436
2439 iconPropertyData = attemptckalloc(sizeof(unsigned long) * size);
2437 iconPropertyData = (unsigned long *)attemptckalloc(sizeof(unsigned long) * size);
24402438 if (iconPropertyData == NULL) {
24412439 return TCL_ERROR;
24422440 }
24782476 iconPropertyData[index++] = (unsigned long) height;
24792477 for (y = 0; y < height; y++) {
24802478 for (x = 0; x < width; x++) {
2481 register unsigned char *pixelPtr =
2479 unsigned char *pixelPtr =
24822480 block.pixelPtr + x*block.pixelSize + y*block.pitch;
2483 register unsigned long R, G, B, A;
2481 unsigned long R, G, B, A;
24842482
24852483 R = pixelPtr[block.offset[0]];
24862484 G = pixelPtr[block.offset[1]];
25292527
25302528 static int
25312529 WmIconpositionCmd(
2532 Tk_Window tkwin, /* Main window of the application. */
2530 TCL_UNUSED(Tk_Window), /* Main window of the application. */
25332531 TkWindow *winPtr, /* Toplevel to work with */
25342532 Tcl_Interp *interp, /* Current interpreter. */
25352533 int objc, /* Number of arguments. */
25362534 Tcl_Obj *const objv[]) /* Argument objects. */
25372535 {
2538 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2536 WmInfo *wmPtr = winPtr->wmInfoPtr;
25392537 int x, y;
25402538
25412539 if ((objc != 3) && (objc != 5)) {
25922590 int objc, /* Number of arguments. */
25932591 Tcl_Obj *const objv[]) /* Argument objects. */
25942592 {
2595 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2593 WmInfo *wmPtr = winPtr->wmInfoPtr;
25962594 Tk_Window tkwin2;
25972595 WmInfo *wmPtr2;
25982596 XSetWindowAttributes atts;
27062704
27072705 static int
27082706 WmManageCmd(
2709 Tk_Window tkwin, /* Main window of the application. */
2707 TCL_UNUSED(Tk_Window), /* Main window of the application. */
27102708 TkWindow *winPtr, /* Toplevel or Frame to work with */
27112709 Tcl_Interp *interp, /* Current interpreter. */
2712 int objc, /* Number of arguments. */
2713 Tcl_Obj *const objv[]) /* Argument objects. */
2714 {
2715 register Tk_Window frameWin = (Tk_Window) winPtr;
2716 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2710 TCL_UNUSED(int), /* Number of arguments. */
2711 TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
2712 {
2713 Tk_Window frameWin = (Tk_Window) winPtr;
2714 WmInfo *wmPtr = winPtr->wmInfoPtr;
27172715
27182716 if (!Tk_IsTopLevel(frameWin)) {
27192717 if (!Tk_IsManageable(frameWin)) {
27682766
27692767 static int
27702768 WmMaxsizeCmd(
2771 Tk_Window tkwin, /* Main window of the application. */
2769 TCL_UNUSED(Tk_Window), /* Main window of the application. */
27722770 TkWindow *winPtr, /* Toplevel to work with */
27732771 Tcl_Interp *interp, /* Current interpreter. */
27742772 int objc, /* Number of arguments. */
27752773 Tcl_Obj *const objv[]) /* Argument objects. */
27762774 {
2777 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2775 WmInfo *wmPtr = winPtr->wmInfoPtr;
27782776 int width, height;
27792777
27802778 if ((objc != 3) && (objc != 5)) {
28272825
28282826 static int
28292827 WmMinsizeCmd(
2830 Tk_Window tkwin, /* Main window of the application. */
2828 TCL_UNUSED(Tk_Window), /* Main window of the application. */
28312829 TkWindow *winPtr, /* Toplevel to work with */
28322830 Tcl_Interp *interp, /* Current interpreter. */
28332831 int objc, /* Number of arguments. */
28342832 Tcl_Obj *const objv[]) /* Argument objects. */
28352833 {
2836 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2834 WmInfo *wmPtr = winPtr->wmInfoPtr;
28372835 int width, height;
28382836
28392837 if ((objc != 3) && (objc != 5)) {
28782876
28792877 static int
28802878 WmOverrideredirectCmd(
2881 Tk_Window tkwin, /* Main window of the application. */
2879 TCL_UNUSED(Tk_Window), /* Main window of the application. */
28822880 TkWindow *winPtr, /* Toplevel to work with */
28832881 Tcl_Interp *interp, /* Current interpreter. */
28842882 int objc, /* Number of arguments. */
29362934
29372935 static int
29382936 WmPositionfromCmd(
2939 Tk_Window tkwin, /* Main window of the application. */
2937 TCL_UNUSED(Tk_Window), /* Main window of the application. */
29402938 TkWindow *winPtr, /* Toplevel to work with */
29412939 Tcl_Interp *interp, /* Current interpreter. */
29422940 int objc, /* Number of arguments. */
29432941 Tcl_Obj *const objv[]) /* Argument objects. */
29442942 {
2945 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2943 WmInfo *wmPtr = winPtr->wmInfoPtr;
29462944 static const char *const optionStrings[] = {
29472945 "program", "user", NULL };
29482946 enum options {
30033001
30043002 static int
30053003 WmProtocolCmd(
3006 Tk_Window tkwin, /* Main window of the application. */
3004 TCL_UNUSED(Tk_Window), /* Main window of the application. */
30073005 TkWindow *winPtr, /* Toplevel to work with */
30083006 Tcl_Interp *interp, /* Current interpreter. */
30093007 int objc, /* Number of arguments. */
30103008 Tcl_Obj *const objv[]) /* Argument objects. */
30113009 {
3012 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3013 register ProtocolHandler *protPtr, *prevPtr;
3010 WmInfo *wmPtr = winPtr->wmInfoPtr;
3011 ProtocolHandler *protPtr, *prevPtr;
30143012 Atom protocol;
30153013 const char *cmd;
30163014 int cmdLength;
30813079 }
30823080 cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
30833081 if (cmdLength > 0) {
3084 protPtr = ckalloc(HANDLER_SIZE(cmdLength));
3082 protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
30853083 protPtr->protocol = protocol;
30863084 protPtr->nextPtr = wmPtr->protPtr;
30873085 wmPtr->protPtr = protPtr;
31133111
31143112 static int
31153113 WmResizableCmd(
3116 Tk_Window tkwin, /* Main window of the application. */
3114 TCL_UNUSED(Tk_Window), /* Main window of the application. */
31173115 TkWindow *winPtr, /* Toplevel to work with */
31183116 Tcl_Interp *interp, /* Current interpreter. */
31193117 int objc, /* Number of arguments. */
31203118 Tcl_Obj *const objv[]) /* Argument objects. */
31213119 {
3122 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3120 WmInfo *wmPtr = winPtr->wmInfoPtr;
31233121 int width, height;
31243122
31253123 if ((objc != 3) && (objc != 5)) {
31723170
31733171 static int
31743172 WmSizefromCmd(
3175 Tk_Window tkwin, /* Main window of the application. */
3173 TCL_UNUSED(Tk_Window), /* Main window of the application. */
31763174 TkWindow *winPtr, /* Toplevel to work with */
31773175 Tcl_Interp *interp, /* Current interpreter. */
31783176 int objc, /* Number of arguments. */
31793177 Tcl_Obj *const objv[]) /* Argument objects. */
31803178 {
3181 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3179 WmInfo *wmPtr = winPtr->wmInfoPtr;
31823180 static const char *const optionStrings[] = {
31833181 "program", "user", NULL };
31843182 enum options {
33643362
33653363 static int
33663364 WmStateCmd(
3367 Tk_Window tkwin, /* Main window of the application. */
3365 TCL_UNUSED(Tk_Window), /* Main window of the application. */
33683366 TkWindow *winPtr, /* Toplevel to work with */
33693367 Tcl_Interp *interp, /* Current interpreter. */
33703368 int objc, /* Number of arguments. */
33713369 Tcl_Obj *const objv[]) /* Argument objects. */
33723370 {
3373 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3371 WmInfo *wmPtr = winPtr->wmInfoPtr;
33743372 static const char *const optionStrings[] = {
33753373 "normal", "iconic", "withdrawn", NULL };
33763374 enum options {
34073405 "OVERRIDE_REDIRECT", NULL);
34083406 return TCL_ERROR;
34093407 }
3410 if (wmPtr->masterPtr != NULL) {
3408 if (wmPtr->containerPtr != NULL) {
34113409 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
34123410 "can't iconify \"%s\": it is a transient",
34133411 winPtr->pathName));
34703468
34713469 static int
34723470 WmTitleCmd(
3473 Tk_Window tkwin, /* Main window of the application. */
3471 TCL_UNUSED(Tk_Window), /* Main window of the application. */
34743472 TkWindow *winPtr, /* Toplevel to work with */
34753473 Tcl_Interp *interp, /* Current interpreter. */
34763474 int objc, /* Number of arguments. */
34773475 Tcl_Obj *const objv[]) /* Argument objects. */
34783476 {
3479 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3477 WmInfo *wmPtr = winPtr->wmInfoPtr;
34803478 const char *argv3;
34813479 int length;
34823480
34953493 ckfree(wmPtr->title);
34963494 }
34973495 argv3 = Tcl_GetStringFromObj(objv[3], &length);
3498 wmPtr->title = ckalloc(length + 1);
3496 wmPtr->title = (char *)ckalloc(length + 1);
34993497 strcpy(wmPtr->title, argv3);
35003498
35013499 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
35303528 int objc, /* Number of arguments. */
35313529 Tcl_Obj *const objv[]) /* Argument objects. */
35323530 {
3533 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3534 TkWindow *masterPtr = wmPtr->masterPtr, *w;
3531 WmInfo *wmPtr = winPtr->wmInfoPtr;
3532 TkWindow *containerPtr = wmPtr->containerPtr, *w;
35353533 WmInfo *wmPtr2;
35363534
35373535 if ((objc != 3) && (objc != 4)) {
35393537 return TCL_ERROR;
35403538 }
35413539 if (objc == 3) {
3542 if (masterPtr != NULL) {
3543 Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) masterPtr));
3540 if (containerPtr != NULL) {
3541 Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) containerPtr));
35443542 }
35453543 return TCL_OK;
35463544 }
35473545 if (Tcl_GetString(objv[3])[0] == '\0') {
3548 if (masterPtr != NULL) {
3546 if (containerPtr != NULL) {
35493547 /*
3550 * If we had a master, tell them that we aren't tied to them
3548 * If we had a container, tell them that we aren't tied to them
35513549 * anymore
35523550 */
35533551
3554 masterPtr->wmInfoPtr->numTransients--;
3555 Tk_DeleteEventHandler((Tk_Window) masterPtr, StructureNotifyMask,
3552 containerPtr->wmInfoPtr->numTransients--;
3553 Tk_DeleteEventHandler((Tk_Window) containerPtr, StructureNotifyMask,
35563554 WmWaitMapProc, winPtr);
35573555
35583556 /*
35623560 */
35633561 }
35643562
3565 wmPtr->masterPtr = NULL;
3563 wmPtr->containerPtr = NULL;
35663564 } else {
3567 Tk_Window masterWin;
3568
3569 if (TkGetWindowFromObj(interp, tkwin, objv[3], &masterWin)!=TCL_OK) {
3565 Tk_Window container;
3566
3567 if (TkGetWindowFromObj(interp, tkwin, objv[3], &container)!=TCL_OK) {
35703568 return TCL_ERROR;
35713569 }
3572 masterPtr = (TkWindow *) masterWin;
3573 while (!Tk_TopWinHierarchy(masterPtr)) {
3570 containerPtr = (TkWindow *) container;
3571 while (!Tk_TopWinHierarchy(containerPtr)) {
35743572 /*
3575 * Ensure that the master window is actually a Tk toplevel.
3573 * Ensure that the container window is actually a Tk toplevel.
35763574 */
35773575
3578 masterPtr = masterPtr->parentPtr;
3579 }
3580 Tk_MakeWindowExist((Tk_Window) masterPtr);
3576 containerPtr = containerPtr->parentPtr;
3577 }
3578 Tk_MakeWindowExist((Tk_Window) containerPtr);
35813579
35823580 if (wmPtr->iconFor != NULL) {
35833581 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
35873585 return TCL_ERROR;
35883586 }
35893587
3590 wmPtr2 = masterPtr->wmInfoPtr;
3588 wmPtr2 = containerPtr->wmInfoPtr;
35913589 if (wmPtr2->wrapperPtr == NULL) {
35923590 CreateWrapper(wmPtr2);
35933591 }
36003598 return TCL_ERROR;
36013599 }
36023600
3603 for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL;
3604 w = (TkWindow *)w->wmInfoPtr->masterPtr) {
3601 for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
3602 w = (TkWindow *)w->wmInfoPtr->containerPtr) {
36053603 if (w == winPtr) {
36063604 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
36073605 "setting \"%s\" as master creates a transient/master cycle",
3608 Tk_PathName(masterPtr)));
3606 Tk_PathName(containerPtr)));
36093607 Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
36103608 return TCL_ERROR;
36113609 }
36123610 }
36133611
3614 if (masterPtr != wmPtr->masterPtr) {
3612 if (containerPtr != wmPtr->containerPtr) {
36153613 /*
3616 * Remove old master map/unmap binding before setting the new
3617 * master. The event handler will ensure that transient states
3618 * reflect the state of the master.
3614 * Remove old container map/unmap binding before setting the new
3615 * container. The event handler will ensure that transient states
3616 * reflect the state of the container.
36193617 */
36203618
3621 if (wmPtr->masterPtr != NULL) {
3622 wmPtr->masterPtr->wmInfoPtr->numTransients--;
3623 Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
3619 if (wmPtr->containerPtr != NULL) {
3620 wmPtr->containerPtr->wmInfoPtr->numTransients--;
3621 Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr,
36243622 StructureNotifyMask, WmWaitMapProc, winPtr);
36253623 }
36263624
3627 masterPtr->wmInfoPtr->numTransients++;
3628 Tk_CreateEventHandler((Tk_Window) masterPtr,
3625 containerPtr->wmInfoPtr->numTransients++;
3626 Tk_CreateEventHandler((Tk_Window) containerPtr,
36293627 StructureNotifyMask, WmWaitMapProc, winPtr);
36303628
3631 wmPtr->masterPtr = masterPtr;
3629 wmPtr->containerPtr = containerPtr;
36323630 }
36333631 }
36343632 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
3635 if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) {
3633 if (wmPtr->containerPtr != NULL && !Tk_IsMapped(wmPtr->containerPtr)) {
36363634 if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
36373635 Tcl_SetObjResult(interp, Tcl_NewStringObj(
36383636 "couldn't send withdraw message to window manager",
36413639 return TCL_ERROR;
36423640 }
36433641 } else {
3644 if (wmPtr->masterPtr != NULL) {
3642 if (wmPtr->containerPtr != NULL) {
36453643 XSetTransientForHint(winPtr->display,
36463644 wmPtr->wrapperPtr->window,
3647 wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window);
3645 wmPtr->containerPtr->wmInfoPtr->wrapperPtr->window);
36483646 } else {
36493647 XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window,
36503648 Tk_InternAtom((Tk_Window) winPtr,"WM_TRANSIENT_FOR"));
36733671
36743672 static int
36753673 WmWithdrawCmd(
3676 Tk_Window tkwin, /* Main window of the application. */
3674 TCL_UNUSED(Tk_Window), /* Main window of the application. */
36773675 TkWindow *winPtr, /* Toplevel to work with */
36783676 Tcl_Interp *interp, /* Current interpreter. */
36793677 int objc, /* Number of arguments. */
36803678 Tcl_Obj *const objv[]) /* Argument objects. */
36813679 {
3682 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3680 WmInfo *wmPtr = winPtr->wmInfoPtr;
36833681
36843682 if (objc != 3) {
36853683 Tcl_WrongNumArgs(interp, 2, objv, "window");
37203718
37213719 /*
37223720 * Invoked when a MapNotify or UnmapNotify event is delivered for a toplevel
3723 * that is the master of a transient toplevel.
3721 * that is the container of a transient toplevel.
37243722 */
37253723
37263724 static void
37283726 ClientData clientData, /* Pointer to window. */
37293727 XEvent *eventPtr) /* Information about event. */
37303728 {
3731 TkWindow *winPtr = clientData;
3732 TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
3733
3734 if (masterPtr == NULL) {
3729 TkWindow *winPtr = (TkWindow *)clientData;
3730 TkWindow *containerPtr = winPtr->wmInfoPtr->containerPtr;
3731
3732 if (containerPtr == NULL) {
37353733 return;
37363734 }
37373735
37793777 * of one grid unit. */
37803778 {
37813779 TkWindow *winPtr = (TkWindow *) tkwin;
3782 register WmInfo *wmPtr;
3780 WmInfo *wmPtr;
37833781
37843782 /*
37853783 * Ensure widthInc and heightInc are greater than 0
38843882 * controlling gridding. */
38853883 {
38863884 TkWindow *winPtr = (TkWindow *) tkwin;
3887 register WmInfo *wmPtr;
3885 WmInfo *wmPtr;
38883886
38893887 /*
38903888 * Find the top-level window for tkwin, plus the window manager
44174415 ClientData clientData, /* Information about toplevel window. */
44184416 XEvent *eventPtr) /* Event that just happened. */
44194417 {
4420 WmInfo *wmPtr = clientData;
4418 WmInfo *wmPtr = (WmInfo *)clientData;
44214419 XEvent mapEvent;
44224420 TkDisplay *dispPtr = wmPtr->winPtr->dispPtr;
44234421
44974495 *----------------------------------------------------------------------
44984496 */
44994497
4500 /* ARGSUSED */
45014498 static void
45024499 TopLevelReqProc(
4503 ClientData dummy, /* Not used. */
4500 TCL_UNUSED(void *), /* Not used. */
45044501 Tk_Window tkwin) /* Information about window. */
45054502 {
45064503 TkWindow *winPtr = (TkWindow *) tkwin;
45674564 UpdateGeometryInfo(
45684565 ClientData clientData) /* Pointer to the window's record. */
45694566 {
4570 register TkWindow *winPtr = clientData;
4571 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4567 TkWindow *winPtr = (TkWindow *)clientData;
4568 WmInfo *wmPtr = winPtr->wmInfoPtr;
45724569 int x, y, width, height, min, max;
45734570 unsigned long serial;
45744571
48294826 int newWidth,
48304827 int newHeight)
48314828 {
4832 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4829 WmInfo *wmPtr = winPtr->wmInfoPtr;
48334830 XSizeHints *hintsPtr;
48344831 int maxWidth, maxHeight;
48354832
53065303 ClientData clientData, /* Pointer to WaitRestrictInfo structure. */
53075304 XEvent *eventPtr) /* Event that is about to be handled. */
53085305 {
5309 WaitRestrictInfo *infoPtr = clientData;
5306 WaitRestrictInfo *infoPtr = (WaitRestrictInfo *)clientData;
53105307
53115308 if (eventPtr->type == ReparentNotify) {
53125309 return TK_PROCESS_EVENT;
54625459 }
54635460
54645461 if (objc > 0) {
5465 atoms = ckalloc(sizeof(Atom) * objc);
5462 atoms = (Atom *)ckalloc(sizeof(Atom) * objc);
54665463 }
54675464
54685465 for (n = 0; n < objc; ++n) {
55755572 TkWindow *winPtr) /* Pointer to top-level window whose geometry
55765573 * is to be changed. */
55775574 {
5578 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5575 WmInfo *wmPtr = winPtr->wmInfoPtr;
55795576 int x, y, width, height, flags;
55805577 char *end;
5581 register const char *p = string;
5578 const char *p = string;
55825579
55835580 /*
55845581 * The leading "=" is optional.
57115708 int *yPtr) /* Where to store y-displacement of (0,0). */
57125709 {
57135710 int x, y;
5714 register TkWindow *winPtr = (TkWindow *) tkwin;
5711 TkWindow *winPtr = (TkWindow *) tkwin;
57155712
57165713 /*
57175714 * Search back through this window's parents all the way to a top-level
61786175 int x, int y) /* New location for window (within parent). */
61796176 {
61806177 TkWindow *winPtr = (TkWindow *) tkwin;
6181 register WmInfo *wmPtr = winPtr->wmInfoPtr;
6178 WmInfo *wmPtr = winPtr->wmInfoPtr;
61826179
61836180 if (!(winPtr->flags & TK_TOP_LEVEL)) {
61846181 Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window");
62266223
62276224 static void
62286225 UpdateWmProtocols(
6229 register WmInfo *wmPtr) /* Information about top-level window. */
6230 {
6231 register ProtocolHandler *protPtr;
6226 WmInfo *wmPtr) /* Information about top-level window. */
6227 {
6228 ProtocolHandler *protPtr;
62326229 Atom deleteWindowAtom, pingAtom;
62336230 int count;
62346231 Atom *arrayPtr, *atomPtr;
62456242 protPtr = protPtr->nextPtr, count++) {
62466243 /* Empty loop body; we're just counting the handlers. */
62476244 }
6248 arrayPtr = ckalloc(count * sizeof(Atom));
6245 arrayPtr = (Atom *)ckalloc(count * sizeof(Atom));
62496246 deleteWindowAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr,
62506247 "WM_DELETE_WINDOW");
62516248 pingAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, "_NET_WM_PING");
62876284 XEvent *eventPtr) /* X event. */
62886285 {
62896286 WmInfo *wmPtr;
6290 register ProtocolHandler *protPtr;
6287 ProtocolHandler *protPtr;
62916288 Atom protocol;
62926289 int result;
62936290 const char *protocolName;
64366433 Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
64376434 TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
64386435
6439 window_ptr = windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
6436 window_ptr = windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *));
64406437 if (windows == NULL) {
64416438 return NULL;
64426439 }
64526449 goto done;
64536450 case 1:
64546451 hPtr = Tcl_FirstHashEntry(&table, &search);
6455 windows[0] = Tcl_GetHashValue(hPtr);
6452 windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr);
64566453 windows[1] = NULL;
64576454 goto done;
64586455 }
64686465 windows = NULL;
64696466 } else {
64706467 for (i = 0; i < numChildren; i++) {
6471 hPtr = Tcl_FindHashEntry(&table, (char *) children[i]);
6468 hPtr = Tcl_FindHashEntry(&table, (char *)children[i]);
64726469 if (hPtr != NULL) {
6473 childWinPtr = Tcl_GetHashValue(hPtr);
6470 childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
64746471 *window_ptr++ = childWinPtr;
64756472 }
64766473 }
66436640 * add the toplevel itself as the last element of the list.
66446641 */
66456642
6646 newPtr = ckalloc((count+2) * sizeof(Window));
6643 newPtr = (Window *)ckalloc((count+2) * sizeof(Window));
66476644 for (i = 0; i < count; i++) {
66486645 newPtr[i] = oldPtr[i];
66496646 }
68786875 static void
68796876 TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
68806877 {
6881 if (parent == None) {
6878 if (parent == NULL) {
68826879 parent = Tk_Parent(tkwin);
68836880 while (!Tk_IsTopLevel(parent))
68846881 parent = Tk_Parent(parent);
69966993 TkWindow *winPtr, *wrapperPtr;
69976994 Window parent;
69986995 Tcl_HashEntry *hPtr;
6999 int new;
6996 int isNew;
70006997
70016998 winPtr = wmPtr->winPtr;
70026999 if (winPtr->window == None) {
70407037 InputOutput, wrapperPtr->visual,
70417038 wrapperPtr->dirtyAtts|CWOverrideRedirect, &wrapperPtr->atts);
70427039 hPtr = Tcl_CreateHashEntry(&wrapperPtr->dispPtr->winTable,
7043 (char *) wrapperPtr->window, &new);
7040 (char *) wrapperPtr->window, &isNew);
70447041 Tcl_SetHashValue(hPtr, wrapperPtr);
70457042 wrapperPtr->mainPtr = winPtr->mainPtr;
70467043 wrapperPtr->mainPtr->refCount++;
72597256 * for tkwin's toplevel. */
72607257 Tk_Window tkwin) /* Handle for menubar window. */
72617258 {
7262 WmInfo *wmPtr = clientData;
7259 WmInfo *wmPtr = (WmInfo *)clientData;
72637260
72647261 wmPtr->menuHeight = Tk_ReqHeight(tkwin);
72657262 if (wmPtr->menuHeight <= 0) {
72947291 TkpGetWrapperWindow(
72957292 TkWindow *winPtr) /* A toplevel window pointer. */
72967293 {
7297 register WmInfo *wmPtr = winPtr->wmInfoPtr;
7294 WmInfo *wmPtr = winPtr->wmInfoPtr;
72987295
72997296 if ((winPtr == NULL) || (wmPtr == NULL)) {
73007297 return NULL;
73247321 UpdateCommand(
73257322 TkWindow *winPtr)
73267323 {
7327 register WmInfo *wmPtr = winPtr->wmInfoPtr;
7324 WmInfo *wmPtr = winPtr->wmInfoPtr;
73287325 Tcl_DString cmds, ds;
73297326 int i, *offsets;
73307327 char **cmdArgv;
73417338 * entire DString is done.
73427339 */
73437340
7344 cmdArgv = ckalloc(sizeof(char *) * wmPtr->cmdArgc);
7345 offsets = ckalloc(sizeof(int) * wmPtr->cmdArgc);
7341 cmdArgv = (char **)ckalloc(sizeof(char *) * wmPtr->cmdArgc);
7342 offsets = (int *)ckalloc(sizeof(int) * wmPtr->cmdArgc);
73467343 Tcl_DStringInit(&cmds);
73477344 for (i = 0; i < wmPtr->cmdArgc; i++) {
73487345 Tcl_UtfToExternalDString(NULL, wmPtr->cmdArgv[i], -1, &ds);
128128 DLLSUFFIX = @DLLSUFFIX@
129129 LIBSUFFIX = @LIBSUFFIX@
130130 EXESUFFIX = @EXESUFFIX@
131 VER = @TK_MAJOR_VERSION@@TK_MINOR_VERSION@
132 DOTVER = @TK_MAJOR_VERSION@.@TK_MINOR_VERSION@
131133
132134 TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@
133135 TK_LIB_FILE = @TK_LIB_FILE@
134136 TK_DLL_FILE = @TK_DLL_FILE@
135137 TEST_DLL_FILE = tktest$(VER)${DLLSUFFIX}
136 TEST_LIB_FILE = @LIBPREFIX@tktest$(VER)${LIBSUFFIX}
138 TEST_LIB_FILE = @LIBPREFIX@tktest$(VER)${DLLSUFFIX}.a
137139
138140 SHARED_LIBRARIES = $(TK_DLL_FILE) $(TK_STUB_LIB_FILE)
139141 STATIC_LIBRARIES = $(TK_LIB_FILE)
140142
141143 WISH = wish$(VER)${EXESUFFIX}
142 TKTEST = tktest${EXEEXT}
143 CAT32 = cat32$(EXEEXT)
144 MAN2TCL = man2tcl$(EXEEXT)
144 TKTEST = tktest${EXESUFFIX}
145 CAT32 = cat32${EXESUFFIX}
146 MAN2TCL = man2tcl${EXESUFFIX}
145147
146148 @SET_MAKE@
147149
149151 # makefile to look into these paths when resolving .c to .obj
150152 # dependencies.
151153
152 VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(UNIX_DIR):$(XLIB_DIR):$(RC_DIR)
154 VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(XLIB_DIR):$(RC_DIR)
153155
154156 # warning flags
155157 CFLAGS_WARNING = @CFLAGS_WARNING@
167169 #CFLAGS = $(CFLAGS_DEBUG)
168170 #CFLAGS = $(CFLAGS_OPTIMIZE)
169171 #CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
170 CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
172 CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING=1 -D__USE_MINGW_ANSI_STDIO=0
171173
172174 # Special compiler flags to use when building man2tcl on Windows.
173175 MAN2TCLFLAGS = @MAN2TCLFLAGS@
183185 LDFLAGS = @LDFLAGS@ @LDFLAGS_DEFAULT@
184186 LDFLAGS_CONSOLE = @LDFLAGS_CONSOLE@
185187 LDFLAGS_WINDOW = @LDFLAGS_WINDOW@
186 EXEEXT = @EXEEXT@
187188 OBJEXT = @OBJEXT@
188189 STLIB_LD = @STLIB_LD@
189190 SHLIB_LD = @SHLIB_LD@
190191 SHLIB_LD_LIBS = @SHLIB_LD_LIBS@
191192 SHLIB_CFLAGS = @SHLIB_CFLAGS@
192193 SHLIB_SUFFIX = @SHLIB_SUFFIX@
193 VER = @TK_MAJOR_VERSION@@TK_MINOR_VERSION@
194 DOTVER = @TK_MAJOR_VERSION@.@TK_MINOR_VERSION@
195194 LIBS = $(TCL_STUB_LIB_FILE) @LIBS@ @LIBS_GUI@
196195 RMDIR = rm -rf
197196 MKDIR = mkdir -p
629628 $(TCL_SRC_DIR)/win/cat.c:
630629
631630 cat32.${OBJEXT}: $(TCL_SRC_DIR)/win/cat.c
632 $(CC) -c $(CC_SWITCHES) "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
631 $(CC) -c $(CC_SWITCHES) -DUNICODE -D_UNICODE "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
633632
634633 $(CAT32): cat32.${OBJEXT}
635634 $(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
655654 # Special case object file targets
656655
657656 winMain.$(OBJEXT): winMain.c
658 $(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
657 $(CC) -c $(CC_SWITCHES) -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
659658
660659 testMain.$(OBJEXT): winMain.c
661 $(CC) -c $(CC_SWITCHES) @DEPARG@ -DTK_TEST $(CC_OBJNAME)
660 $(CC) -c $(CC_SWITCHES) -DTK_TEST -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
662661
663662 tkTest.$(OBJEXT): tkTest.c
664663 $(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
673672 $(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
674673
675674 tkMain2.$(OBJEXT): tkMain.c
676 $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DTK_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
675 $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
676
677 tkUnixMenubu.$(OBJEXT): ${UNIX_DIR}/tkUnixMenubu.c
678 $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
679
680 tkUnixScale.$(OBJEXT): ${UNIX_DIR}/tkUnixScale.c
681 $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
677682
678683 # Extra dependency info
679684 tkConsole.$(OBJEXT): configure Makefile
680685 tkMain.$(OBJEXT): configure Makefile
686 tkMain2.$(OBJEXT): configure Makefile
681687 tkWindow.$(OBJEXT): configure Makefile
682688
683689 # Add the object extension to the implicit rules. By default .obj is not
698704 depend:
699705
700706 cleanhelp:
701 $(RM) *.hlp *.cnt *.hpj *.GID *.rtf man2tcl${EXEEXT}
707 $(RM) *.hlp *.cnt *.hpj *.GID *.rtf man2tcl.exe
702708
703709 clean: cleanhelp
704710 $(RM) *.lib *.a *.exp *.dll *.res *.${OBJEXT} *~ \#* TAGS a.out
13111311 TK_VERSION=8.6
13121312 TK_MAJOR_VERSION=8
13131313 TK_MINOR_VERSION=6
1314 TK_PATCH_LEVEL=".10"
1314 TK_PATCH_LEVEL=".11"
13151315 VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
13161316
13171317 #------------------------------------------------------------------------
30893089 else
30903090 tcl_ok=yes
30913091 fi;
3092
3093 if test "${enable_shared+set}" = set; then
3094 enableval="$enable_shared"
3095 tcl_ok=$enableval
3096 else
3097 tcl_ok=yes
3098 fi
3099
31003092 if test "$tcl_ok" = "yes" ; then
31013093 echo "$as_me:$LINENO: result: shared" >&5
31023094 echo "${ECHO_T}shared" >&6
33103302 # after SC_ENABLE_SHARED checks the configure switches.
33113303 #--------------------------------------------------------------------
33123304
3313 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
3324 inttypes.h stdint.h unistd.h
3325 do
3326 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
3327 echo "$as_me:$LINENO: checking for $ac_header" >&5
3328 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
3329 if eval "test \"\${$as_ac_Header+set}\" = set"; then
3330 echo $ECHO_N "(cached) $ECHO_C" >&6
3331 else
3332 cat >conftest.$ac_ext <<_ACEOF
3333 /* confdefs.h. */
3334 _ACEOF
3335 cat confdefs.h >>conftest.$ac_ext
3336 cat >>conftest.$ac_ext <<_ACEOF
3337 /* end confdefs.h. */
3338 $ac_includes_default
3339
3340 #include <$ac_header>
3341 _ACEOF
3342 rm -f conftest.$ac_objext
3343 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
3344 (eval $ac_compile) 2>conftest.er1
3345 ac_status=$?
3346 grep -v '^ *+' conftest.er1 >conftest.err
3347 rm -f conftest.er1
3348 cat conftest.err >&5
3349 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3350 (exit $ac_status); } &&
3351 { ac_try='test -z "$ac_c_werror_flag"
3352 || test ! -s conftest.err'
3353 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3354 (eval $ac_try) 2>&5
3355 ac_status=$?
3356 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3357 (exit $ac_status); }; } &&
3358 { ac_try='test -s conftest.$ac_objext'
3359 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3360 (eval $ac_try) 2>&5
3361 ac_status=$?
3362 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3363 (exit $ac_status); }; }; then
3364 eval "$as_ac_Header=yes"
3365 else
3366 echo "$as_me: failed program was:" >&5
3367 sed 's/^/| /' conftest.$ac_ext >&5
3368
3369 eval "$as_ac_Header=no"
3370 fi
3371 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
3372 fi
3373 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
3374 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
3375 if test `eval echo '${'$as_ac_Header'}'` = yes; then
3376 cat >>confdefs.h <<_ACEOF
3377 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
3378 _ACEOF
3379
3380 fi
3381
3382 done
3383
3384
33853305
33863306
33873307 # Step 0: Enable 64 bit support?
35403460 if test "$ac_cv_cross" = "yes"; then
35413461 case "$do64bit" in
35423462 amd64|x64|yes)
3543 CC="x86_64-w64-mingw32-gcc"
3463 CC="x86_64-w64-mingw32-${CC}"
35443464 LD="x86_64-w64-mingw32-ld"
35453465 AR="x86_64-w64-mingw32-ar"
35463466 RANLIB="x86_64-w64-mingw32-ranlib"
35473467 RC="x86_64-w64-mingw32-windres"
35483468 ;;
35493469 *)
3550 CC="i686-w64-mingw32-gcc"
3470 CC="i686-w64-mingw32-${CC}"
35513471 LD="i686-w64-mingw32-ld"
35523472 AR="i686-w64-mingw32-ar"
35533473 RANLIB="i686-w64-mingw32-ranlib"
37843704 SHLIB_LD='${CC} -shared'
37853705 SHLIB_LD_LIBS='${LIBS}'
37863706 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \$@ ${extra_ldflags} \
3787 -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\$@)"
3707 -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\$@)"
37883708 # DLLSUFFIX is separate because it is the building block for
37893709 # users of tclConfig.sh that may build shared or static.
37903710 DLLSUFFIX="\${DBGX}.dll"
37963716
37973717 CFLAGS_DEBUG=-g
37983718 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
3799 CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
3719 CFLAGS_WARNING="-Wall -Wpointer-arith"
38003720 LDFLAGS_DEBUG=
38013721 LDFLAGS_OPTIMIZE=
3722
3723 case "${CC}" in
3724 *++)
3725 CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
3726 ;;
3727 *)
3728 CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
3729 ;;
3730 esac
38023731
38033732 # Specify the CC output file names based on the target name
38043733 CC_OBJNAME="-o \$@"
39223851 LIBSUFFIX="\${DBGX}.lib"
39233852 LIBFLAGSUFFIX="\${DBGX}"
39243853
3925 # This is a 2-stage check to make sure we have the 64-bit SDK
3926 # We have to know where the SDK is installed.
3927 # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
39283854 if test "$do64bit" != "no" ; then
3929 if test "x${MSSDK}x" = "xx" ; then
3930 MSSDK="C:/Progra~1/Microsoft Platform SDK"
3931 fi
3932 MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
3933 PATH64=""
39343855 case "$do64bit" in
39353856 amd64|x64|yes)
39363857 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
3937 PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
39383858 ;;
39393859 ia64)
39403860 MACHINE="IA64"
3941 PATH64="${MSSDK}/Bin/Win64"
39423861 ;;
39433862 esac
3944 if test ! -d "${PATH64}" ; then
3945 { echo "$as_me:$LINENO: WARNING: Could not find 64-bit $MACHINE SDK" >&5
3946 echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK" >&2;}
3947 fi
39483863 echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
39493864 echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
39503865 fi
39603875 esac
39613876
39623877 if test "$do64bit" != "no" ; then
3963 # The space-based-path will work for the Makefile, but will
3964 # not work if AC_TRY_COMPILE is called. TEA has the
3965 # TEA_PATH_NOSPACE to avoid this issue.
3966 # Check if _WIN64 is already recognized, and if so we don't
3967 # need to modify CC.
3968 echo "$as_me:$LINENO: checking whether _WIN64 is declared" >&5
3969 echo $ECHO_N "checking whether _WIN64 is declared... $ECHO_C" >&6
3970 if test "${ac_cv_have_decl__WIN64+set}" = set; then
3971 echo $ECHO_N "(cached) $ECHO_C" >&6
3972 else
3973 cat >conftest.$ac_ext <<_ACEOF
3974 /* confdefs.h. */
3975 _ACEOF
3976 cat confdefs.h >>conftest.$ac_ext
3977 cat >>conftest.$ac_ext <<_ACEOF
3978 /* end confdefs.h. */
3979 $ac_includes_default
3980 int
3981 main ()
3982 {
3983 #ifndef _WIN64
3984 char *p = (char *) _WIN64;
3985 #endif
3986
3987 ;
3988 return 0;
3989 }
3990 _ACEOF
3991 rm -f conftest.$ac_objext
3992 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
3993 (eval $ac_compile) 2>conftest.er1
3994 ac_status=$?
3995 grep -v '^ *+' conftest.er1 >conftest.err
3996 rm -f conftest.er1
3997 cat conftest.err >&5
3998 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3999 (exit $ac_status); } &&
4000 { ac_try='test -z "$ac_c_werror_flag"
4001 || test ! -s conftest.err'
4002 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4003 (eval $ac_try) 2>&5
4004 ac_status=$?
4005 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4006 (exit $ac_status); }; } &&
4007 { ac_try='test -s conftest.$ac_objext'
4008 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4009 (eval $ac_try) 2>&5
4010 ac_status=$?
4011 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4012 (exit $ac_status); }; }; then
4013 ac_cv_have_decl__WIN64=yes
4014 else
4015 echo "$as_me: failed program was:" >&5
4016 sed 's/^/| /' conftest.$ac_ext >&5
4017
4018 ac_cv_have_decl__WIN64=no
4019 fi
4020 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4021 fi
4022 echo "$as_me:$LINENO: result: $ac_cv_have_decl__WIN64" >&5
4023 echo "${ECHO_T}$ac_cv_have_decl__WIN64" >&6
4024 if test $ac_cv_have_decl__WIN64 = yes; then
4025 :
4026 else
4027 CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
4028 -I\"${MSSDK}/Include/crt\" \
4029 -I\"${MSSDK}/Include/crt/sys\""
4030 fi
4031
4032 RC="\"${MSSDK}/bin/rc.exe\""
3878 RC="rc"
40333879 CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
40343880 # Do not use -O2 for Win64 - this has proved buggy in code gen.
40353881 CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
4036 lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
4037 LINKBIN="\"${PATH64}/link.exe\""
3882 lflags="${lflags} -nologo -MACHINE:${MACHINE}"
3883 LINKBIN="link"
40383884 # Avoid 'unresolved external symbol __security_cookie' errors.
40393885 # c.f. http://support.microsoft.com/?id=894573
40403886 LIBS="$LIBS bufferoverflowU.lib"
44964342 # man2tcl needs this so that it can use errno.h
44974343 #--------------------------------------------------------------------
44984344
4345 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
4356 inttypes.h stdint.h unistd.h
4357 do
4358 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
4359 echo "$as_me:$LINENO: checking for $ac_header" >&5
4360 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
4361 if eval "test \"\${$as_ac_Header+set}\" = set"; then
4362 echo $ECHO_N "(cached) $ECHO_C" >&6
4363 else
4364 cat >conftest.$ac_ext <<_ACEOF
4365 /* confdefs.h. */
4366 _ACEOF
4367 cat confdefs.h >>conftest.$ac_ext
4368 cat >>conftest.$ac_ext <<_ACEOF
4369 /* end confdefs.h. */
4370 $ac_includes_default
4371
4372 #include <$ac_header>
4373 _ACEOF
4374 rm -f conftest.$ac_objext
4375 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4376 (eval $ac_compile) 2>conftest.er1
4377 ac_status=$?
4378 grep -v '^ *+' conftest.er1 >conftest.err
4379 rm -f conftest.er1
4380 cat conftest.err >&5
4381 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4382 (exit $ac_status); } &&
4383 { ac_try='test -z "$ac_c_werror_flag"
4384 || test ! -s conftest.err'
4385 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4386 (eval $ac_try) 2>&5
4387 ac_status=$?
4388 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4389 (exit $ac_status); }; } &&
4390 { ac_try='test -s conftest.$ac_objext'
4391 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4392 (eval $ac_try) 2>&5
4393 ac_status=$?
4394 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4395 (exit $ac_status); }; }; then
4396 eval "$as_ac_Header=yes"
4397 else
4398 echo "$as_me: failed program was:" >&5
4399 sed 's/^/| /' conftest.$ac_ext >&5
4400
4401 eval "$as_ac_Header=no"
4402 fi
4403 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4404 fi
4405 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
4406 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
4407 if test `eval echo '${'$as_ac_Header'}'` = yes; then
4408 cat >>confdefs.h <<_ACEOF
4409 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
4410 _ACEOF
4411
4412 fi
4413
4414 done
4415
4416
44994417 if test "${ac_cv_header_errno_h+set}" = set; then
45004418 echo "$as_me:$LINENO: checking for errno.h" >&5
45014419 echo $ECHO_N "checking for errno.h... $ECHO_C" >&6
50304948 eval "TK_SRC_DIR=\"`cd $srcdir/..; pwd`\""
50314949
50324950 eval "TK_DLL_FILE=tk$VER${DLLSUFFIX}"
5033 eval "TK_LIB_FILE=${LIBPREFIX}tk$VER${LIBSUFFIX}"
4951 if test ${SHARED_BUILD} = 0 ; then
4952 eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${LIBSUFFIX}"
4953 else
4954 eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${DLLSUFFIX}.a"
4955 fi
50344956
50354957 eval "TK_STUB_LIB_FILE=${LIBPREFIX}tkstub${VER}${LIBSUFFIX}"
50364958 # FIXME: All of this var junk needs to be done in tcl.m4 !!!!
1313 TK_VERSION=8.6
1414 TK_MAJOR_VERSION=8
1515 TK_MINOR_VERSION=6
16 TK_PATCH_LEVEL=".10"
16 TK_PATCH_LEVEL=".11"
1717 VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
1818
1919 #------------------------------------------------------------------------
165165 eval "TK_SRC_DIR=\"`cd $srcdir/..; pwd`\""
166166
167167 eval "TK_DLL_FILE=tk$VER${DLLSUFFIX}"
168 eval "TK_LIB_FILE=${LIBPREFIX}tk$VER${LIBSUFFIX}"
168 if test ${SHARED_BUILD} = 0 ; then
169 eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${LIBSUFFIX}"
170 else
171 eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${DLLSUFFIX}.a"
172 fi
169173
170174 eval "TK_STUB_LIB_FILE=${LIBPREFIX}tkstub${VER}${LIBSUFFIX}"
171175 # FIXME: All of this var junk needs to be done in tcl.m4 !!!!
5757 # 64-bit compiler, if your SDK has it.
5858 #
5959 # Examples:
60 # Assumign Tcl sources lie in ../../tcl
60 # Assuming Tcl sources lie in ../../tcl
6161 # c:\tcl_src\win\>nmake -f makefile.vc release
6262 # If Tcl sources are not in ../../tcl, use the TCLDIR macro to specify dir
6363 # c:\tcl_src\win\>nmake -f makefile.vc release TCLDIR=c:\src\tcl
6565 # c:\tcl_src\win\>nmake -f makefile.vc test
6666 # Install Tk in location specified by INSTALLDIR macro
6767 # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
68 # Build release with PDF files
68 # Build release with PDB files
6969 # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=pdbs
7070 # Build debug version
7171 # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=symbols
305305
306306 CONFIG_DEFS =/DSTDC_HEADERS=1 /DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
307307 /DHAVE_STDLIB_H=1 /DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \
308 /DHAVE_STRINGS_H=1 /DHAVE_INTTYPES_H=1 \
309 /DSUPPORT_CONFIG_EMBEDDED /DUNICODE /D_UNICODE \
308 /DHAVE_STRINGS_H=1 \
310309 !if $(HAVE_UXTHEME_H)
311310 /DHAVE_UXTHEME_H=1 \
312311 !endif
454453
455454
456455 $(CAT32): $(_TCLDIR)\win\cat.c
457 $(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE -Fo$(TMP_DIR)\ $?
456 $(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE /DUNICODE /D_UNICODE -Fo$(TMP_DIR)\ $?
458457 $(CONEXECMD) /DCONSOLE -stack:16384 $(TMP_DIR)\cat.obj
459458 $(_VC_MANIFEST_EMBED_EXE)
460459
530529 #---------------------------------------------------------------------
531530
532531 $(TMP_DIR)\testMain.obj: $(WIN_DIR)\winMain.c
533 $(cc32) $(appcflags_nostubs) /DTK_TEST \
532 $(cc32) $(appcflags_nostubs) /DTK_TEST /DUNICODE /D_UNICODE \
534533 /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
535534 -Fo$@ $?
536535
547546 $(cc32) $(appcflags_nostubs) -Fo$@ $?
548547
549548 $(TMP_DIR)\winMain.obj: $(WIN_DIR)\winMain.c
550 $(cc32) $(appcflags_nostubs) \
549 $(cc32) $(appcflags_nostubs) /DUNICODE /D_UNICODE \
551550 /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
552551 -Fo$@ $?
553552
554553 $(TMP_DIR)\tkMain2.obj: $(GENERICDIR)\tkMain.c
555 $(cc32) $(pkgcflags) /DTK_ASCII_MAIN -Fo$@ $?
554 $(cc32) $(pkgcflags) /DUNICODE /D_UNICODE -Fo$@ $?
556555
557556 # The following objects are part of the stub library and should not
558557 # be built as DLL objects but none of the symbols should be exported
3030 # We extract version numbers using the nmakehlp program. For now use
3131 # the local copy of nmakehlp. Once we locate Tcl, we will use that
3232 # one if it is newer.
33 !if [$(CC) -nologo "nmakehlp.c" -link -subsystem:console > nul]
33 !if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul]
3434 !endif
3535
3636 # First locate the Tcl directory that we are working with.
37 !ifdef TCLDIR
37 !if "$(TCLDIR)" != ""
3838
3939 _RULESDIR = $(TCLDIR:/=\)
4040
55 # compiler switches, defining common targets and macros. The Tcl makefile
66 # directly includes this. Extensions include it via "rules-ext.vc".
77 #
8 # See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for
8 # See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for
99 # detailed documentation.
1010 #
1111 # See the file "license.terms" for information on usage and redistribution
2323 # For modifications that are not backward-compatible, you *must* change
2424 # the major version.
2525 RULES_VERSION_MAJOR = 1
26 RULES_VERSION_MINOR = 4
26 RULES_VERSION_MINOR = 8
2727
2828 # The PROJECT macro must be defined by parent makefile.
2929 !if "$(PROJECT)" == ""
301301 _TCLDIR = $(_INSTALLDIR)\..
302302 _TCL_H = $(_TCLDIR)\include\tcl.h
303303
304 !else # exist(...) && ! $(NEED_TCL_SOURCE)
304 !else # exist(...) && !$(NEED_TCL_SOURCE)
305305
306306 !if [echo _TCLDIR = \> nmakehlp.out] \
307307 || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
312312 TCLDIR = $(_TCLDIR)
313313 _TCL_H = $(_TCLDIR)\generic\tcl.h
314314
315 !endif # exist(...) && ! $(NEED_TCL_SOURCE)
315 !endif # exist(...) && !$(NEED_TCL_SOURCE)
316316
317317 !endif # TCLDIR
318318
414414 # NATIVE_ARCH - set to IX86 or AMD64 for the host machine
415415 # MACHINE - same as $(ARCH) - legacy
416416 # _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed
417 # CFG_ENCODING - set to an character encoding.
418 # TBD - this is passed to compiler as TCL_CFGVAL_ENCODING but can't
419 # see where it is used
420417
421418 cc32 = $(CC) # built-in default.
422419 link32 = link
502499 _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
503500 !endif
504501
505 !ifndef CFG_ENCODING
506 CFG_ENCODING = \"cp1252\"
507 !endif
508
509502 ################################################################
510503 # 4. Build the nmakehlp program
511504 # This is a helper app we need to overcome nmake's limiting
513506 # information about supported compiler options etc.
514507 #
515508 # Tcl itself will always use the nmakehlp.c program which is
516 # in its own source. This is the "master" copy and kept updated.
509 # in its own source. It will be kept updated there.
517510 #
518511 # Extensions built against an installed Tcl will use the installed
519512 # copy of Tcl's nmakehlp.c if there is one and their own version
536529 !if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
537530 NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
538531 !endif
539 !else # ! $(TCLINSTALL)
532 !else # !$(TCLINSTALL)
540533 !if exist("$(_TCLDIR)\win\nmakehlp.c")
541534 NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
542535 !endif
658651 !endif
659652 !endif
660653
654
655 ################################################################
656 # 6. Extract various version numbers from headers
657 # For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
658 # respectively. For extensions, versions are extracted from the
659 # configure.in or configure.ac from the TEA configuration if it
660 # exists, and unset otherwise.
661 # Sets the following macros:
662 # TCL_MAJOR_VERSION
663 # TCL_MINOR_VERSION
664 # TCL_RELEASE_SERIAL
665 # TCL_PATCH_LEVEL
666 # TCL_PATCH_LETTER
667 # TCL_VERSION
668 # TK_MAJOR_VERSION
669 # TK_MINOR_VERSION
670 # TK_RELEASE_SERIAL
671 # TK_PATCH_LEVEL
672 # TK_PATCH_LETTER
673 # TK_VERSION
674 # DOTVERSION - set as (for example) 2.5
675 # VERSION - set as (for example 25)
676 #--------------------------------------------------------------
677
678 !if [echo REM = This file is generated from rules.vc > versions.vc]
679 !endif
680 !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
681 && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
682 !endif
683 !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
684 && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
685 !endif
686 !if [echo TCL_RELEASE_SERIAL = \>> versions.vc] \
687 && [nmakehlp -V "$(_TCL_H)" TCL_RELEASE_SERIAL >> versions.vc]
688 !endif
689 !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
690 && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
691 !endif
692
693 !if defined(_TK_H)
694 !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
695 && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
696 !endif
697 !if [echo TK_MINOR_VERSION = \>> versions.vc] \
698 && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
699 !endif
700 !if [echo TK_RELEASE_SERIAL = \>> versions.vc] \
701 && [nmakehlp -V "$(_TK_H)" TK_RELEASE_SERIAL >> versions.vc]
702 !endif
703 !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
704 && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
705 !endif
706 !endif # _TK_H
707
708 !include versions.vc
709
710 TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
711 TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
712 !if [nmakehlp -f $(TCL_PATCH_LEVEL) "a"]
713 TCL_PATCH_LETTER = a
714 !elseif [nmakehlp -f $(TCL_PATCH_LEVEL) "b"]
715 TCL_PATCH_LETTER = b
716 !else
717 TCL_PATCH_LETTER = .
718 !endif
719
720 !if defined(_TK_H)
721
722 TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
723 TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
724 !if [nmakehlp -f $(TK_PATCH_LEVEL) "a"]
725 TK_PATCH_LETTER = a
726 !elseif [nmakehlp -f $(TK_PATCH_LEVEL) "b"]
727 TK_PATCH_LETTER = b
728 !else
729 TK_PATCH_LETTER = .
730 !endif
731
732 !endif
733
734 # Set DOTVERSION and VERSION
735 !if $(DOING_TCL)
736
737 DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
738 VERSION = $(TCL_VERSION)
739
740 !elseif $(DOING_TK)
741
742 DOTVERSION = $(TK_DOTVERSION)
743 VERSION = $(TK_VERSION)
744
745 !else # Doing a non-Tk extension
746
747 # If parent makefile has not defined DOTVERSION, try to get it from TEA
748 # first from a configure.in file, and then from configure.ac
749 !ifndef DOTVERSION
750 !if [echo DOTVERSION = \> versions.vc] \
751 || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
752 !if [echo DOTVERSION = \> versions.vc] \
753 || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
754 !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
755 !endif
756 !endif
757 !include versions.vc
758 !endif # DOTVERSION
759 VERSION = $(DOTVERSION:.=)
760
761 !endif # $(DOING_TCL) ... etc.
762
763 # Windows RC files have 3 version components. Ensure this irrespective
764 # of how many components the package has specified. Basically, ensure
765 # minimum 4 components by appending 4 0's and then pick out the first 4.
766 # Also take care of the fact that DOTVERSION may have "a" or "b" instead
767 # of "." separating the version components.
768 DOTSEPARATED=$(DOTVERSION:a=.)
769 DOTSEPARATED=$(DOTSEPARATED:b=.)
770 !if [echo RCCOMMAVERSION = \> versions.vc] \
771 || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
772 !error *** Could not generate RCCOMMAVERSION ***
773 !endif
774 !include versions.vc
775
661776 ########################################################################
662 # 6. Parse the OPTS macro to work out the requested build configuration.
777 # 7. Parse the OPTS macro to work out the requested build configuration.
663778 # Based on this, we will construct the actual switches to be passed to the
664779 # compiler and linker using the macros defined in the previous section.
665780 # The following macros are defined by this section based on OPTS
673788 # MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build
674789 # 0 -> link to static C runtime for static Tcl build.
675790 # Does not impact shared Tcl builds (STATIC_BUILD == 0)
791 # Default: 1 for Tcl 8.7 and up, 0 otherwise.
676792 # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
677 # in the Tcl shell. 0 -> keep them as shared libraries
678 # Does not impact shared Tcl builds.
793 # in the Tcl and Wish shell. 0 -> keep them as shared libraries. Does
794 # not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 8.7.
679795 # USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
680796 # 0 -> Use the non-thread allocator.
681797 # UNCHECKED - 1 -> when doing a debug build with symbols, use the release
684800 # CONFIG_CHECK - 1 -> check current build configuration against Tcl
685801 # configuration (ignored for Tcl itself)
686802 # _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build
687 # (CRT library should support this)
803 # (CRT library should support this, not needed for Tcl 9.x)
804 # TCL_UTF_MAX=4 - forces a build allowing 4-byte UTF-8 sequences internally.
805 # (Not needed for Tcl 9.x)
688806 # Further, LINKERFLAGS are modified based on above.
689807
690808 # Default values for all the above
727845 !else
728846 !if [nmakehlp -f $(OPTS) "msvcrt"]
729847 !message *** Doing msvcrt
730 MSVCRT = 1
731 !else
732 !if !$(STATIC_BUILD)
733 MSVCRT = 1
734 !else
848 !else
849 !if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7 && $(STATIC_BUILD)
735850 MSVCRT = 0
736851 !endif
737852 !endif
740855 !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
741856 !message *** Doing staticpkg
742857 TCL_USE_STATIC_PACKAGES = 1
743 !else
744 TCL_USE_STATIC_PACKAGES = 0
745858 !endif
746859
747860 !if [nmakehlp -f $(OPTS) "nothreads"]
748861 !message *** Compile explicitly for non-threaded tcl
749862 TCL_THREADS = 0
750863 USE_THREAD_ALLOC= 0
751 !else
752 TCL_THREADS = 1
753 USE_THREAD_ALLOC= 1
754 !endif
755
864 !endif
865
866 !if $(TCL_MAJOR_VERSION) == 8
756867 !if [nmakehlp -f $(OPTS) "time64bit"]
757868 !message *** Force 64-bit time_t
758869 _USE_64BIT_TIME_T = 1
870 !endif
871
872 !if [nmakehlp -f $(OPTS) "utfmax"]
873 !message *** Force allowing 4-byte UTF-8 sequences internally
874 TCL_UTF_MAX = 4
875 !endif
759876 !endif
760877
761878 # Yes, it's weird that the "symbols" option controls DEBUG and
841958 !endif
842959
843960 ################################################################
844 # 7. Parse the STATS macro to configure code instrumentation
961 # 8. Parse the STATS macro to configure code instrumentation
845962 # The following macros are set by this section:
846963 # TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
847964 # 0 -> disables
871988 !endif
872989
873990 ####################################################################
874 # 8. Parse the CHECKS macro to configure additional compiler checks
991 # 9. Parse the CHECKS macro to configure additional compiler checks
875992 # The following macros are set by this section:
876993 # WARNINGS - compiler switches that control the warnings level
877994 # TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
9031020
9041021 !endif
9051022
906 ################################################################
907 # 9. Extract various version numbers
908 # For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
909 # respectively. For extensions, versions are extracted from the
910 # configure.in or configure.ac from the TEA configuration if it
911 # exists, and unset otherwise.
912 # Sets the following macros:
913 # TCL_MAJOR_VERSION
914 # TCL_MINOR_VERSION
915 # TCL_PATCH_LEVEL
916 # TCL_VERSION
917 # TK_MAJOR_VERSION
918 # TK_MINOR_VERSION
919 # TK_PATCH_LEVEL
920 # TK_VERSION
921 # DOTVERSION - set as (for example) 2.5
922 # VERSION - set as (for example 25)
923 #--------------------------------------------------------------
924
925 !if [echo REM = This file is generated from rules.vc > versions.vc]
926 !endif
927 !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
928 && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
929 !endif
930 !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
931 && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
932 !endif
933 !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
934 && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
935 !endif
936
937 !if defined(_TK_H)
938 !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
939 && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
940 !endif
941 !if [echo TK_MINOR_VERSION = \>> versions.vc] \
942 && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
943 !endif
944 !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
945 && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
946 !endif
947 !endif # _TK_H
948
949 !include versions.vc
950
951 TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
952 TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
953 !if defined(_TK_H)
954 TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
955 TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
956 !endif
957
958 # Set DOTVERSION and VERSION
959 !if $(DOING_TCL)
960
961 DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
962 VERSION = $(TCL_VERSION)
963
964 !elseif $(DOING_TK)
965
966 DOTVERSION = $(TK_DOTVERSION)
967 VERSION = $(TK_VERSION)
968
969 !else # Doing a non-Tk extension
970
971 # If parent makefile has not defined DOTVERSION, try to get it from TEA
972 # first from a configure.in file, and then from configure.ac
973 !ifndef DOTVERSION
974 !if [echo DOTVERSION = \> versions.vc] \
975 || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
976 !if [echo DOTVERSION = \> versions.vc] \
977 || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
978 !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
979 !endif
980 !endif
981 !include versions.vc
982 !endif # DOTVERSION
983 VERSION = $(DOTVERSION:.=)
984
985 !endif # $(DOING_TCL) ... etc.
9861023
9871024 ################################################################
9881025 # 10. Construct output directory and file paths
10281065 BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
10291066 !endif
10301067
1031 !if !$(DEBUG) || $(DEBUG) && $(UNCHECKED)
1068 !if !$(DEBUG) || $(TCL_VERSION) > 86 || $(DEBUG) && $(UNCHECKED)
10321069 SUFX = $(SUFX:g=)
10331070 !endif
10341071
10791116 # The name of the stubs library for the project being built
10801117 STUBPREFIX = $(PROJECT)stub
10811118
1119 #
10821120 # Set up paths to various Tcl executables and libraries needed by extensions
1121 #
1122
1123 # TIP 430. Unused for 8.6 but no harm defining it to allow a common rules.vc
1124 !if "$(TCL_PATCH_LETTER)" == "."
1125 TCLSCRIPTZIPNAME = libtcl_$(TCL_MAJOR_VERSION)_$(TCL_MINOR_VERSION)_$(TCL_RELEASE_SERIAL).zip
1126 !else
1127 TCLSCRIPTZIPNAME = libtcl_$(TCL_MAJOR_VERSION)_$(TCL_MINOR_VERSION)_$(TCL_PATCH_LETTER)$(TCL_RELEASE_SERIAL).zip
1128 !endif
1129 !if "$(TK_PATCH_LETTER)" == "."
1130 TKSCRIPTZIPNAME = libtk_$(TK_MAJOR_VERSION)_$(TK_MINOR_VERSION)_$(TK_RELEASE_SERIAL).zip
1131 !else
1132 TKSCRIPTZIPNAME = libtk_$(TK_MAJOR_VERSION)_$(TK_MINOR_VERSION)_$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip
1133 !endif
1134
10831135 !if $(DOING_TCL)
1084
10851136 TCLSHNAME = $(PROJECT)sh$(VERSION)$(SUFX).exe
10861137 TCLSH = $(OUT_DIR)\$(TCLSHNAME)
10871138 TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
10881139 TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
10891140 TCLLIB = $(OUT_DIR)\$(TCLLIBNAME)
1141 TCLSCRIPTZIP = $(OUT_DIR)\$(TCLSCRIPTZIPNAME)
10901142
10911143 TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
10921144 TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME)
10931145 TCL_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
10941146
1095 !else # ! $(DOING_TCL)
1147 !else # !$(DOING_TCL)
10961148
10971149 !if $(TCLINSTALL) # Building against an installed Tcl
10981150
11141166 TCL_LIBRARY = $(_TCLDIR)\lib
11151167 TCLREGLIB = $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
11161168 TCLDDELIB = $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
1169 TCLSCRIPTZIP = $(_TCLDIR)\lib\$(TCLSCRIPTZIPNAME)
11171170 TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
11181171 TCL_INCLUDES = -I"$(_TCLDIR)\include"
11191172
11331186 TCL_LIBRARY = $(_TCLDIR)\library
11341187 TCLREGLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
11351188 TCLDDELIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
1189 TCLSCRIPTZIP = $(_TCLDIR)\win\$(BUILDDIRTOP)\$(TCLSCRIPTZIPNAME)
11361190 TCLTOOLSDIR = $(_TCLDIR)\tools
11371191 TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
11381192
11651219 TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME)
11661220 TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME)
11671221 TKLIB = $(OUT_DIR)\$(TKLIBNAME)
1168 TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
1222 TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
1223 TKSCRIPTZIP = $(OUT_DIR)\$(TKSCRIPTZIPNAME)
11691224
11701225 !else # effectively NEED_TK
11711226
11801235 TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
11811236 !endif
11821237 TK_INCLUDES = -I"$(_TKDIR)\include"
1238 TKSCRIPTZIP = $(_TKDIR)\lib\$(TKSCRIPTZIPNAME)
1239
11831240 !else # Building against Tk sources
1241
11841242 WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
11851243 TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
11861244 TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
11911249 TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
11921250 !endif
11931251 TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
1252 TKSCRIPTZIP = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSCRIPTZIPNAME)
1253
11941254 !endif # TKINSTALL
1255
11951256 tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
11961257
11971258 !endif # $(DOING_TK)
12321293 DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
12331294 !if $(DOING_TCL)
12341295 SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
1296 MODULE_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION)
12351297 !else # DOING_TK
12361298 SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
12371299 !endif
12761338 # baselibs - minimum Windows libraries required. Parent makefile can
12771339 # define PRJ_LIBS before including rules.rc if additional libs are needed
12781340
1279 OPTDEFINES = /DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) /DSTDC_HEADERS
1341 OPTDEFINES = /DSTDC_HEADERS
1342 !if $(VCVERSION) > 1600
1343 OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1
1344 !else
1345 OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1
1346 !endif
1347 !if $(VCVERSION) >= 1800
1348 OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1
1349 !endif
12801350
12811351 !if $(TCL_MEM_DEBUG)
12821352 OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG
12921362 !endif
12931363 !if $(STATIC_BUILD)
12941364 OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
1365 !elseif $(TCL_VERSION) > 86
1366 OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
1367 !if "$(MACHINE)" == "AMD64"
1368 OPTDEFINES = $(OPTDEFINES) /DMP_64BIT
1369 !endif
12951370 !endif
12961371 !if $(TCL_NO_DEPRECATED)
12971372 OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED
13001375 !if $(USE_STUBS)
13011376 # Note we do not define USE_TCL_STUBS even when building tk since some
13021377 # test targets in tk do not use stubs
1303 !if ! $(DOING_TCL)
1378 !if !$(DOING_TCL)
13041379 USE_STUBS_DEFS = /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS
13051380 !if $(NEED_TK)
13061381 USE_STUBS_DEFS = $(USE_STUBS_DEFS) /DUSE_TK_STUBS
13211396 OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
13221397 !endif
13231398 !if $(VCVERSION) < 1300
1324 OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64
1325 !endif
1326
1399 OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64=1
1400 !endif
1401
1402 !if "$(TCL_MAJOR_VERSION)" == "8"
13271403 !if "$(_USE_64BIT_TIME_T)" == "1"
1328 OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T
1404 OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T=1
1405 !endif
1406 !if "$(TCL_UTF_MAX)" == "4"
1407 OPTDEFINES = $(OPTDEFINES) /DTCL_UTF_MAX=4
13291408 !endif
13301409
13311410 # _ATL_XP_TARGETING - Newer SDK's need this to build for XP
13321411 COMPILERFLAGS = /D_ATL_XP_TARGETING
1412 !endif
13331413
13341414 # Like the TEA system only set this non empty for non-Tk extensions
13351415 # Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
14541534 lflags = $(lflags) -nodefaultlib:libucrt.lib
14551535 !endif
14561536
1457 # Old linkers (Visual C++ 6 in particular) will link for fast loading
1458 # on Win98. Since we do not support Win98 any more, we specify nowin98
1459 # as recommended for NT and later. However, this is only required by
1460 # IX86 on older compilers and only needed if we are not doing a static build.
1461
1462 !if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD)
1463 !if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
1464 # Align sections for PE size savings.
1465 lflags = $(lflags) -opt:nowin98
1466 !endif
1467 !endif
1468
14691537 dlllflags = $(lflags) -dll
14701538 conlflags = $(lflags) -subsystem:console
14711539 guilflags = $(lflags) -subsystem:windows
15071575 RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
15081576 $(TCL_INCLUDES) \
15091577 /DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
1510 /DCOMMAVERSION=$(DOTVERSION:.=,),0 \
1578 /DCOMMAVERSION=$(RCCOMMAVERSION) \
15111579 /DDOTVERSION=\"$(DOTVERSION)\" \
15121580 /DVERSION=\"$(VERSION)\" \
15131581 /DSUFX=\"$(SUFX)\" \
15231591 !if $(MULTIPLATFORM_INSTALL)
15241592 default-pkgindex:
15251593 @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1526 [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
1594 [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)] [string totitle $(PRJ_PACKAGE_TCLNAME)]] > $(OUT_DIR)\pkgIndex.tcl
15271595 !else
15281596 default-pkgindex:
15291597 @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1530 [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
1598 [list load [file join $$dir $(PRJLIBNAME)] [string totitle $(PRJ_PACKAGE_TCLNAME)]] > $(OUT_DIR)\pkgIndex.tcl
15311599 !endif
15321600
15331601 default-pkgindex-tea:
15721640 @echo Installing PDBs to '$(LIB_INSTALL_DIR)'
15731641 @if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
15741642 @$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\"
1643
1644 # "emacs font-lock highlighting fix
15751645
15761646 default-install-docs-html:
15771647 @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
16351705 !ifdef RCFILE
16361706
16371707 # Note: don't use $** in below rule because there may be other dependencies
1638 # and only the "master" rc must be passed to the resource compiler
1708 # and only the "main" rc must be passed to the resource compiler
16391709 $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc
16401710 $(RESCMD) $(RCDIR)\$(PROJECT).rc
16411711
16891759
16901760 !if !$(DISABLE_IMPLICIT_RULES)
16911761 # Implicit rule definitions - only for building library objects. For stubs and
1692 # main application, the master makefile should define explicit rules.
1762 # main application, the makefile should define explicit rules.
16931763
16941764 {$(ROOT)}.c{$(TMP_DIR)}.obj::
16951765 $(CCPKGCMD) @<<
17301800 # When building an extension, certain configuration options should
17311801 # match the ones used when Tcl was built. Here we check and
17321802 # warn on a mismatch.
1733 !if ! $(DOING_TCL)
1803 !if !$(DOING_TCL)
17341804
17351805 !if $(TCLINSTALL) # Building against an installed Tcl
17361806 !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
17371807 TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
17381808 !endif
1739 !else # ! $(TCLINSTALL) - building against Tcl source
1740 !if exist("$(OUT_DIR)\tcl.nmake")
1741 TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
1809 !else # !$(TCLINSTALL) - building against Tcl source
1810 !if exist("$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake")
1811 TCLNMAKECONFIG = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake"
17421812 !endif
17431813 !endif # TCLINSTALL
17441814
17591829
17601830 !endif # TCLNMAKECONFIG
17611831
1762 !endif # ! $(DOING_TCL)
1832 !endif # !$(DOING_TCL)
17631833
17641834
17651835 #----------------------------------------------------------
0 #include "tk.h"
0 #include "tkInt.h"
11
22 /*
33 * Undocumented Xlib internal function
77 _XInitImageFuncPtrs(
88 XImage *image)
99 {
10 (void)image;
11
1012 return Success;
1113 }
1214
2022 Window w,
2123 XTextProperty *text_prop)
2224 {
25 (void)display;
26 (void)w;
27 (void)text_prop;
2328 }
2429
2530 Status
2833 int count,
2934 XTextProperty *text_prop_return)
3035 {
31 return (Status) 0;
36 (void)list;
37 (void)count;
38 (void)text_prop_return;
39
40 return Success;
3241 }
3342
3443 /*
4655 _Xconst unsigned char *data,
4756 int nelements)
4857 {
49 return Success;
50 }
51
52 Cursor
53 XCreateGlyphCursor(
54 Display *display,
55 Font source_font,
56 Font mask_font,
57 unsigned int source_char,
58 unsigned int mask_char,
59 XColor _Xconst *foreground_color,
60 XColor _Xconst *background_color)
61 {
62 return 1;
58 (void)display;
59 (void)w;
60 (void)property;
61 (void)type;
62 (void)format;
63 (void)mode;
64 (void)data;
65 (void)nelements;
66
67 return Success;
6368 }
6469
6570 XIC
6671 XCreateIC(XIM xim, ...)
6772 {
73 (void)xim;
6874 return NULL;
6975 }
7076
71 Cursor
72 XCreatePixmapCursor(
73 Display *display,
74 Pixmap source,
75 Pixmap mask,
76 XColor *foreground_color,
77 XColor *background_color,
78 unsigned int x,
79 unsigned int y)
80 {
81 return (Cursor) NULL;
82 }
83
8477 int
8578 XDeleteProperty(
8679 Display *display,
8780 Window w,
8881 Atom property)
8982 {
90 return Success;
91 }
92
93 void
94 XDestroyIC(
95 XIC ic)
96 {
83 (void)display;
84 (void)w;
85 (void)property;
86
87 return Success;
9788 }
9889
9990 Bool
10192 XEvent *event,
10293 Window window)
10394 {
95 (void)event;
96 (void)window;
97
10498 return 0;
10599 }
106100
109103 Display *display,
110104 int mode)
111105 {
106 (void)display;
107 (void)mode;
108
112109 return Success;
113110 }
114111
117114 Display *display,
118115 Cursor cursor)
119116 {
117 (void)display;
118 (void)cursor;
119
120120 return Success;
121121 }
122122
124124 XGContextFromGC(
125125 GC gc)
126126 {
127 (void)gc;
128
127129 return (GContext) NULL;
128130 }
129131
132134 Display *display,
133135 Atom atom)
134136 {
137 (void)display;
138 (void)atom;
139
135140 return NULL;
136141 }
137142
141146 Window w,
142147 XWindowAttributes *window_attributes_return)
143148 {
149 (void)display;
150 (void)w;
151 (void)window_attributes_return;
152
144153 return Success;
145154 }
146155
151160 Window **windows_return,
152161 int *count_return)
153162 {
154 return (Status) 0;
163 (void)display;
164 (void)w;
165 (void)windows_return;
166 (void)count_return;
167
168 return Success;
155169 }
156170
157171 int
160174 Window w,
161175 int screen_number)
162176 {
177 (void)display;
178 (void)w;
179 (void)screen_number;
180
163181 return Success;
164182 }
165183
169187 int *nhosts_return,
170188 Bool *state_return)
171189 {
190 (void)display;
191 (void)nhosts_return;
192 (void)state_return;
193
172194 return NULL;
173195 }
174196
180202 XColor *exact_def_return,
181203 XColor *screen_def_return)
182204 {
205 (void)display;
206 (void)colormap;
207 (void)color_name;
208 (void)exact_def_return;
209 (void)screen_def_return;
210
183211 return Success;
184212 }
185213
188216 Display *display,
189217 XEvent *event_return)
190218 {
219 (void)display;
220 (void)event_return;
221
191222 return Success;
192223 }
193224
196227 Display *display,
197228 XEvent *event)
198229 {
230 (void)display;
231 (void)event;
232
199233 return Success;
200234 }
201235
206240 XColor *defs_in_out,
207241 int ncolors)
208242 {
243 (void)display;
244 (void)colormap;
245 (void)defs_in_out;
246 (void)ncolors;
247
209248 return Success;
210249 }
211250
218257 Window **children_return,
219258 unsigned int *nchildren_return)
220259 {
260 (void)display;
261 (void)w;
262 (void)root_return;
263 (void)parent_return;
264 (void)children_return;
265 (void)nchildren_return;
266
221267 return Success;
222268 }
223269
225271 XRefreshKeyboardMapping(
226272 XMappingEvent *event_map)
227273 {
274 (void)event_map;
275
228276 return Success;
229277 }
230278
233281 Display *display,
234282 int screen_number)
235283 {
284 (void)display;
285 (void)screen_number;
286
236287 return (Window) NULL;
237288 }
238289
242293 Window w,
243294 long event_mask)
244295 {
296 (void)display;
297 (void)w;
298 (void)event_mask;
299
245300 return Success;
246301 }
247302
253308 long event_mask,
254309 XEvent *event_send)
255310 {
311 (void)display;
312 (void)w;
313 (void)propagate;
314 (void)event_mask;
315 (void)event_send;
316
256317 return Success;
257318 }
258319
263324 char **argv,
264325 int argc)
265326 {
327 (void)display;
328 (void)w;
329 (void)argv;
330 (void)argc;
331
266332 return Success;
267333 }
268334
270336 XSetErrorHandler(
271337 XErrorHandler handler)
272338 {
339 (void)handler;
340
273341 return NULL;
274342 }
275343
279347 Window w,
280348 _Xconst char *icon_name)
281349 {
350 (void)display;
351 (void)w;
352 (void)icon_name;
353
282354 return Success;
283355 }
284356
288360 Window w,
289361 unsigned long background_pixel)
290362 {
363 (void)display;
364 (void)w;
365 (void)background_pixel;
366
291367 return Success;
292368 }
293369
297373 Window w,
298374 Pixmap background_pixmap)
299375 {
376 (void)display;
377 (void)w;
378 (void)background_pixmap;
379
300380 return Success;
301381 }
302382
306386 Window w,
307387 unsigned long border_pixel)
308388 {
389 (void)display;
390 (void)w;
391 (void)border_pixel;
392
309393 return Success;
310394 }
311395
315399 Window w,
316400 Pixmap border_pixmap)
317401 {
402 (void)display;
403 (void)w;
404 (void)border_pixmap;
405
318406 return Success;
319407 }
320408
324412 Window w,
325413 unsigned int width)
326414 {
415 (void)display;
416 (void)w;
417 (void)width;
418
327419 return Success;
328420 }
329421
333425 Window w,
334426 Colormap colormap)
335427 {
428 (void)display;
429 (void)w;
430 (void)colormap;
431
336432 return Success;
337433 }
338434
347443 int *dest_y_return,
348444 Window *child_return)
349445 {
446 (void)display;
447 (void)src_w;
448 (void)dest_w;
449 (void)src_x;
450 (void)src_y;
451 (void)dest_x_return;
452 (void)dest_y_return;
453 (void)child_return;
454
350455 return 0;
351456 }
352457
357462 long event_mask,
358463 XEvent *event_return)
359464 {
465 (void)display;
466 (void)w;
467 (void)event_mask;
468 (void)event_return;
469
360470 return Success;
361471 }
362472
366476 Window w,
367477 int screen_number)
368478 {
479 (void)display;
480 (void)w;
481 (void)screen_number;
482
369483 return Success;
370484 }
371485
378492 KeySym *keysym_return,
379493 Status *status_return)
380494 {
495 (void)ic;
496 (void)event;
497 (void)buffer_return;
498 (void)bytes_buffer;
499 (void)keysym_return;
500 (void)status_return;
501
381502 return Success;
382503 }
383504
388509 Atom property,
389510 long long_offset,
390511 long long_length,
391 Bool delete,
512 Bool del,
392513 Atom req_type,
393514 Atom *actual_type_return,
394515 int *actual_format_return,
396517 unsigned long *bytes_after_return,
397518 unsigned char **prop_return)
398519 {
520 (void)display;
521 (void)w;
522 (void)property;
523 (void)long_offset;
524 (void)long_length;
525 (void)del;
526 (void)req_type;
527
399528 *actual_type_return = None;
400529 *actual_format_return = 0;
401530 *nitems_return = 0;
412541 XFlush(
413542 Display *display)
414543 {
544 (void)display;
545
415546 return 0;
416547 }
417548
419550 XGrabServer(
420551 Display *display)
421552 {
553 (void)display;
554
422555 return 0;
423556 }
424557
426559 XUngrabServer(
427560 Display *display)
428561 {
562 (void)display;
563
429564 return 0;
430565 }
431566
452587 Display *display,
453588 Bool onoff)
454589 {
590 (void)onoff;
591
455592 display->request++;
456593 return NULL;
457594 }
461598 Display *display,
462599 Bool discard)
463600 {
601 (void)discard;
602
464603 display->request++;
465604 return 0;
466605 }
471610 {
472611 return visual->visualid;
473612 }
613
614 int
615 XOffsetRegion(
616 Region rgn,
617 int dx,
618 int dy)
619 {
620 (void)rgn;
621 (void)dx;
622 (void)dy;
623
624 return 0;
625 }
363363 AC_ARG_ENABLE(shared,
364364 [ --enable-shared build and link with shared libraries (default: on)],
365365 [tcl_ok=$enableval], [tcl_ok=yes])
366
367 if test "${enable_shared+set}" = set; then
368 enableval="$enable_shared"
369 tcl_ok=$enableval
370 else
371 tcl_ok=yes
372 fi
373
374366 if test "$tcl_ok" = "yes" ; then
375367 AC_MSG_RESULT([shared])
376368 SHARED_BUILD=1
582574 if test "$ac_cv_cross" = "yes"; then
583575 case "$do64bit" in
584576 amd64|x64|yes)
585 CC="x86_64-w64-mingw32-gcc"
577 CC="x86_64-w64-mingw32-${CC}"
586578 LD="x86_64-w64-mingw32-ld"
587579 AR="x86_64-w64-mingw32-ar"
588580 RANLIB="x86_64-w64-mingw32-ranlib"
589581 RC="x86_64-w64-mingw32-windres"
590582 ;;
591583 *)
592 CC="i686-w64-mingw32-gcc"
584 CC="i686-w64-mingw32-${CC}"
593585 LD="i686-w64-mingw32-ld"
594586 AR="i686-w64-mingw32-ar"
595587 RANLIB="i686-w64-mingw32-ranlib"
714706 SHLIB_LD='${CC} -shared'
715707 SHLIB_LD_LIBS='${LIBS}'
716708 MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
717 -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)"
709 -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\[$]@)"
718710 # DLLSUFFIX is separate because it is the building block for
719711 # users of tclConfig.sh that may build shared or static.
720712 DLLSUFFIX="\${DBGX}.dll"
726718
727719 CFLAGS_DEBUG=-g
728720 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
729 CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
721 CFLAGS_WARNING="-Wall -Wpointer-arith"
730722 LDFLAGS_DEBUG=
731723 LDFLAGS_OPTIMIZE=
724
725 case "${CC}" in
726 *++)
727 CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
728 ;;
729 *)
730 CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
731 ;;
732 esac
732733
733734 # Specify the CC output file names based on the target name
734735 CC_OBJNAME="-o \[$]@"
805806 LIBSUFFIX="\${DBGX}.lib"
806807 LIBFLAGSUFFIX="\${DBGX}"
807808
808 # This is a 2-stage check to make sure we have the 64-bit SDK
809 # We have to know where the SDK is installed.
810 # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
811809 if test "$do64bit" != "no" ; then
812 if test "x${MSSDK}x" = "xx" ; then
813 MSSDK="C:/Progra~1/Microsoft Platform SDK"
814 fi
815 MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
816 PATH64=""
817810 case "$do64bit" in
818811 amd64|x64|yes)
819812 MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
820 PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
821813 ;;
822814 ia64)
823815 MACHINE="IA64"
824 PATH64="${MSSDK}/Bin/Win64"
825816 ;;
826817 esac
827 if test ! -d "${PATH64}" ; then
828 AC_MSG_WARN([Could not find 64-bit $MACHINE SDK])
829 fi
830818 AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
831819 fi
832820
841829 esac
842830
843831 if test "$do64bit" != "no" ; then
844 # The space-based-path will work for the Makefile, but will
845 # not work if AC_TRY_COMPILE is called. TEA has the
846 # TEA_PATH_NOSPACE to avoid this issue.
847 # Check if _WIN64 is already recognized, and if so we don't
848 # need to modify CC.
849 AC_CHECK_DECL([_WIN64], [],
850 [CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
851 -I\"${MSSDK}/Include/crt\" \
852 -I\"${MSSDK}/Include/crt/sys\""])
853 RC="\"${MSSDK}/bin/rc.exe\""
832 RC="rc"
854833 CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
855834 # Do not use -O2 for Win64 - this has proved buggy in code gen.
856835 CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
857 lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
858 LINKBIN="\"${PATH64}/link.exe\""
836 lflags="${lflags} -nologo -MACHINE:${MACHINE}"
837 LINKBIN="link"
859838 # Avoid 'unresolved external symbol __security_cookie' errors.
860839 # c.f. http://support.microsoft.com/?id=894573
861840 LIBS="$LIBS bufferoverflowU.lib"
133133 "leaq %[registration], %%rdx" "\n\t"
134134 "movq %%gs:0, %%rax" "\n\t"
135135 "movq %%rax, 0x0(%%rdx)" "\n\t" /* link */
136 "leaq 1f, %%rax" "\n\t"
136 "leaq 1f(%%rip), %%rax" "\n\t"
137137 "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
138138 "movq %%rbp, 0x10(%%rdx)" "\n\t" /* rbp */
139139 "movq %%rsp, 0x18(%%rdx)" "\n\t" /* rsp */
149149 * Call TkFinalize
150150 */
151151
152 "movq $0x0, 0x0(%%esp)" "\n\t"
152 "movq $0x0, 0x0(%%rsp)" "\n\t"
153153 "call TkFinalize" "\n\t"
154154
155155 /*
7777 CloseClipboard();
7878 goto error;
7979 }
80 data = GlobalLock(handle);
81 Tcl_WinTCharToUtf((LPCTSTR)data, -1, &ds);
80 data = (char *)GlobalLock(handle);
81 Tcl_DStringInit(&ds);
82 Tcl_WCharToUtfDString((WCHAR *)data, wcslen((WCHAR *)data), &ds);
8283 GlobalUnlock(handle);
8384 } else if (IsClipboardFormatAvailable(CF_TEXT)) {
8485 /*
99100
100101 Tcl_DStringInit(&ds);
101102 Tcl_DStringAppend(&ds, "cp######", -1);
102 data = GlobalLock(handle);
103 data = (char *)GlobalLock(handle);
103104
104105 /*
105106 * Even though the documentation claims that GetLocaleInfo expects
129130 CloseClipboard();
130131 goto error;
131132 }
132 data = GlobalLock(handle);
133 data = (char *)GlobalLock(handle);
133134 Tcl_ExternalToUtfDString(encoding, data, -1, &ds);
134135 GlobalUnlock(handle);
135136 if (encoding) {
156157 Tcl_DStringAppend(&ds, "\n", 1);
157158 }
158159 len = wcslen(fname);
159 Tcl_WinTCharToUtf((LPCTSTR)fname, len * sizeof(WCHAR), &dsTmp);
160 Tcl_DStringInit(&dsTmp);
161 Tcl_WCharToUtfDString(fname, len, &dsTmp);
160162 Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsTmp),
161163 Tcl_DStringLength(&dsTmp));
162164 Tcl_DStringFree(&dsTmp);
231233 {
232234 HWND hwnd = owner ? TkWinGetHWND(owner) : NULL;
233235 Tk_Window tkwin;
236 (void)display;
237 (void)time;
234238
235239 /*
236240 * This is a gross hack because the Tk_InternAtom interface is broken. It
280284 char *buffer, *p, *rawText, *endPtr;
281285 int length;
282286 Tcl_DString ds;
287 (void)format;
283288
284289 for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
285290 targetPtr = targetPtr->nextPtr) {
311316 * Copy the data and change EOL characters.
312317 */
313318
314 buffer = rawText = ckalloc(length + 1);
319 buffer = rawText = (char *)ckalloc(length + 1);
315320 if (targetPtr != NULL) {
316321 for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
317322 cbPtr = cbPtr->nextPtr) {
327332 *buffer = '\0';
328333
329334 Tcl_DStringInit(&ds);
330 Tcl_WinUtfToTChar(rawText, -1, &ds);
335 Tcl_UtfToWCharDString(rawText, -1, &ds);
331336 ckfree(rawText);
332337 handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
333338 Tcl_DStringLength(&ds) + 2);
335340 Tcl_DStringFree(&ds);
336341 return;
337342 }
338 buffer = GlobalLock(handle);
343 buffer = (char *)GlobalLock(handle);
339344 memcpy(buffer, Tcl_DStringValue(&ds),
340345 Tcl_DStringLength(&ds) + 2);
341346 GlobalUnlock(handle);
366371 TkClipboardTarget *targetPtr)
367372 {
368373 HWND hwnd = TkWinGetHWND(winPtr->window);
374 (void)targetPtr;
375
369376 UpdateClipboard(hwnd);
370377 }
371378
418425 void
419426 TkSelEventProc(
420427 Tk_Window tkwin, /* Window for which event was targeted. */
421 register XEvent *eventPtr) /* X event: either SelectionClear,
428 XEvent *eventPtr) /* X event: either SelectionClear,
422429 * SelectionRequest, or SelectionNotify. */
423430 {
424431 if (eventPtr->type == SelectionClear) {
445452
446453 void
447454 TkSelPropProc(
448 register XEvent *eventPtr) /* X PropertyChange event. */
449 {
455 XEvent *eventPtr) /* X PropertyChange event. */
456 {
457 (void)eventPtr;
450458 }
451459
452460 /*
102102
103103 /*
104104 * All cursor names are valid lists of one element (for
105 * Unix-compatability), even unadorned system cursor names.
105 * Unix-compatibility), even unadorned system cursor names.
106106 */
107107
108108 if (Tcl_SplitList(interp, string, &argc, &argv) != TCL_OK) {
422422 ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *);
423423 HRESULT ( STDMETHODCALLTYPE *Show )(
424424 IFileSaveDialog *, HWND);
425 HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this,
425 HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *,
426426 UINT, const TCLCOMDLG_FILTERSPEC *);
427427 HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(
428428 IFileSaveDialog *, UINT);
588588 LPARAM lParam);
589589 static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
590590 static void SetTkDialog(ClientData clientData);
591 static const char *ConvertExternalFilename(WCHAR *filename,
592 Tcl_DString *dsPtr);
591 static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *);
593592 static void LoadShellProcs(void);
594593
595594
629628 * ShellProcs is populated.
630629 *-------------------------------------------------------------------------
631630 */
632 static void LoadShellProcs()
631 static void LoadShellProcs(void)
633632 {
634633 static HMODULE shell32_handle = NULL;
635634
636 if (shell32_handle != NULL)
637 return; /* We have already been through here. */
635 if (shell32_handle != NULL) {
636 return; /* We have already been through here. */
637 }
638638
639639 shell32_handle = GetModuleHandleW(L"shell32.dll");
640 if (shell32_handle == NULL) /* Should never happen but check anyways. */
641 return;
642
643 ShellProcs.SHCreateItemFromParsingName =
644 (SHCreateItemFromParsingNameProc*) GetProcAddress(shell32_handle,
645 "SHCreateItemFromParsingName");
640 if (shell32_handle == NULL) { /* Should never happen but check anyways. */
641 return;
642 }
643
644 ShellProcs.SHCreateItemFromParsingName = (SHCreateItemFromParsingNameProc*)
645 (void *)GetProcAddress(shell32_handle, "SHCreateItemFromParsingName");
646646 }
647647
648648
718718 TkWinDialogDebug(
719719 int debug)
720720 {
721 ThreadSpecificData *tsdPtr =
721 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
722722 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
723723
724724 tsdPtr->debugFlag = debug;
750750 int objc, /* Number of arguments. */
751751 Tcl_Obj *const objv[]) /* Argument objects. */
752752 {
753 Tk_Window tkwin = clientData, parent;
753 Tk_Window tkwin = (Tk_Window)clientData, parent;
754754 HWND hWnd;
755755 int i, oldMode, winCode, result;
756756 CHOOSECOLORW chooseColor;
788788 chooseColor.lpCustColors = dwCustColors;
789789 chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK;
790790 chooseColor.lCustData = (LPARAM) NULL;
791 chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc;
791 chooseColor.lpfnHook = (LPOFNHOOKPROC)(void *)ColorDlgHookProc;
792792 chooseColor.lpTemplateName = (LPWSTR) interp;
793793
794794 for (i = 1; i < objc; i += 2) {
904904 WPARAM wParam, /* First message parameter. */
905905 LPARAM lParam) /* Second message parameter. */
906906 {
907 ThreadSpecificData *tsdPtr =
907 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
908908 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
909909 const char *title;
910910 CHOOSECOLOR *ccPtr;
911 (void)wParam;
911912
912913 if (WM_INITDIALOG == uMsg) {
913914
921922 if ((title != NULL) && (title[0] != '\0')) {
922923 Tcl_DString ds;
923924
924 SetWindowTextW(hDlg, (LPCWSTR)Tcl_WinUtfToTChar(title,-1,&ds));
925 Tcl_DStringInit(&ds);
926 SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds));
925927 Tcl_DStringFree(&ds);
926928 }
927929 if (tsdPtr->debugFlag) {
10831085 }
10841086
10851087 ZeroMemory(optsPtr, sizeof(*optsPtr));
1086 // optsPtr->forceXPStyle = 1;
1087 optsPtr->tkwin = clientData;
1088 /* optsPtr->forceXPStyle = 1; */
1089 optsPtr->tkwin = (Tk_Window)clientData;
10881090 optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */
10891091 Tcl_DStringInit(&optsPtr->utfDirString);
10901092 optsPtr->file[0] = 0;
11451147 Tcl_DStringFree(&ds);
11461148 break;
11471149 case FILE_PARENT:
1148 optsPtr->tkwin = Tk_NameToWindow(interp, string, clientData);
1150 optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData);
11491151 if (optsPtr->tkwin == NULL)
11501152 goto error_return;
11511153 break;
12001202 * If new dialogs are available, COM is also initialized.
12011203 *----------------------------------------------------------------------
12021204 */
1203 static int VistaFileDialogsAvailable()
1205 static int VistaFileDialogsAvailable(void)
12041206 {
12051207 HRESULT hr;
12061208 IFileDialog *fdlgPtr = NULL;
1207 ThreadSpecificData *tsdPtr =
1209 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
12081210 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
12091211
12101212 if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) {
12661268 IShellItem *dirIf = NULL;
12671269 LPWSTR wstr;
12681270 Tcl_Obj *resultObj = NULL;
1269 ThreadSpecificData *tsdPtr =
1271 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
12701272 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
12711273 int oldMode;
12721274
13701372 const char *src;
13711373
13721374 src = Tcl_GetString(optsPtr->extObj);
1373 wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds);
1374 if (wstr[0] == L'.')
1375 Tcl_DStringInit(&ds);
1376 wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds);
1377 if (wstr[0] == '.')
13751378 ++wstr;
13761379 hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr);
13771380 Tcl_DStringFree(&ds);
13841387 const char *src;
13851388
13861389 src = Tcl_GetString(optsPtr->titleObj);
1387 wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds);
1390 Tcl_DStringInit(&ds);
1391 wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds);
13881392 hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr);
13891393 Tcl_DStringFree(&ds);
13901394 if (FAILED(hr))
14061410 if (normPath) {
14071411 LPCWSTR nativePath;
14081412 Tcl_IncrRefCount(normPath);
1409 nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
1413 nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
14101414 if (nativePath) {
14111415 hr = ShellProcs.SHCreateItemFromParsingName(
14121416 nativePath, NULL,
15101514 Tcl_DString ftds;
15111515 Tcl_Obj *ftobj;
15121516
1513 Tcl_WinTCharToUtf((LPCTSTR)filterPtr[ftix-1].pszName, -1, &ftds);
1517 Tcl_DStringInit(&ftds);
1518 Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds);
15141519 ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds),
15151520 Tcl_DStringLength(&ftds));
15161521 Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL,
15721577 Tcl_DString utfFilterString, ds;
15731578 Tcl_DString extString, filterString, dirString, titleString;
15741579 const char *str;
1575 ThreadSpecificData *tsdPtr =
1580 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
15761581 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
15771582
15781583 ZeroMemory(&ofnData, sizeof(OFNData));
15971602 ofn.nMaxFile = TK_MULTI_MAX_PATH;
15981603 ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR
15991604 | OFN_EXPLORER| OFN_ENABLEHOOK| OFN_ENABLESIZING;
1600 ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
1605 ofn.lpfnHook = (LPOFNHOOKPROC)(void *)OFNHookProc;
16011606 ofn.lCustData = (LPARAM) &ofnData;
16021607
16031608 if (oper != OFN_FILE_SAVE) {
16171622 */
16181623
16191624 ofnData.dynFileBufferSize = 512;
1620 ofnData.dynFileBuffer = ckalloc(512 * sizeof(WCHAR));
1625 ofnData.dynFileBuffer = (WCHAR *)ckalloc(512 * sizeof(WCHAR));
16211626 }
16221627
16231628 if (optsPtr->extObj != NULL) {
1624 str = Tcl_GetString(optsPtr->extObj);
1625 if (str[0] == '.')
1626 ++str;
1627 Tcl_WinUtfToTChar(str, -1, &extString);
1628 ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString);
1629 }
1630
1631 Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString),
1629 str = Tcl_GetString(optsPtr->extObj);
1630 if (str[0] == '.') {
1631 ++str;
1632 }
1633 Tcl_DStringInit(&extString);
1634 ofn.lpstrDefExt = Tcl_UtfToWCharDString(str, -1, &extString);
1635 }
1636
1637 Tcl_DStringInit(&filterString);
1638 ofn.lpstrFilter = Tcl_UtfToWCharDString(Tcl_DStringValue(&utfFilterString),
16321639 Tcl_DStringLength(&utfFilterString), &filterString);
1633 ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString);
16341640 ofn.nFilterIndex = filterIndex;
16351641
16361642 if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') {
1637 Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString),
1643 Tcl_DStringInit(&dirString);
1644 Tcl_UtfToWCharDString(Tcl_DStringValue(&optsPtr->utfDirString),
16381645 Tcl_DStringLength(&optsPtr->utfDirString), &dirString);
16391646 } else {
16401647 /*
16501657 Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) {
16511658 Tcl_ResetResult(interp);
16521659 } else {
1653 Tcl_WinUtfToTChar(Tcl_DStringValue(&cwd),
1660 Tcl_DStringInit(&dirString);
1661 Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd),
16541662 Tcl_DStringLength(&cwd), &dirString);
16551663 }
16561664 Tcl_DStringFree(&cwd);
16581666 ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString);
16591667
16601668 if (optsPtr->titleObj != NULL) {
1661 Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
1662 ofn.lpstrTitle = (WCHAR *) Tcl_DStringValue(&titleString);
1669 Tcl_DStringInit(&titleString);
1670 ofn.lpstrTitle = Tcl_UtfToWCharDString(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
16631671 }
16641672
16651673 /*
19121920 WPARAM wParam, /* Message parameter */
19131921 LPARAM lParam) /* Message parameter */
19141922 {
1915 ThreadSpecificData *tsdPtr =
1923 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
19161924 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
19171925 OPENFILENAME *ofnPtr;
19181926 OFNData *ofnData;
1927 (void)wParam;
19191928
19201929 if (uMsg == WM_INITDIALOG) {
19211930 TkWinSetUserData(hdlg, lParam);
19601969
19611970 if ((selsize > 1) && (dirsize > 0)) {
19621971 if (ofnData->dynFileBufferSize < buffersize) {
1963 buffer = ckrealloc(buffer, buffersize * sizeof(WCHAR));
1972 buffer = (WCHAR *)ckrealloc(buffer, buffersize * sizeof(WCHAR));
19641973 ofnData->dynFileBufferSize = buffersize;
19651974 ofnData->dynFileBuffer = buffer;
19661975 }
20062015 if (TCL_PATH_ABSOLUTE ==
20072016 Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) {
20082017 /* re-get the full path to the start of the buffer */
2009 buffer = (WCHAR *) ofnData->dynFileBuffer;
2018 buffer = ofnData->dynFileBuffer;
20102019 SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
20112020 } else {
20122021 *(buffer-1) = '\\';
20922101 */
20932102 const char *defaultFilter = "All Files (*.*)";
20942103
2095 p = filterStr = ckalloc(30);
2104 p = filterStr = (char *)ckalloc(30);
20962105
20972106 strcpy(p, defaultFilter);
20982107 p+= strlen(defaultFilter);
21062115 *p = '\0';
21072116
21082117 } else {
2109 size_t len;
2118 int len;
21102119
21112120 if (valuePtr == NULL) {
21122121 len = 0;
21132122 } else {
2114 (void) Tcl_GetString(valuePtr);
2115 len = valuePtr->length;
2123 (void) Tcl_GetStringFromObj(valuePtr, &len);
21162124 }
21172125
21182126 /*
21292137 * twice the size of the string to format the filter
21302138 */
21312139
2132 filterStr = ckalloc(len * 3);
2140 filterStr = (char *)ckalloc(len * 3);
21332141
21342142 for (filterPtr = flist.filters, p = filterStr; filterPtr;
21352143 filterPtr = filterPtr->next) {
22822290
22832291 Tcl_DStringInit(&ds);
22842292 Tcl_DStringInit(&patterns);
2285 dlgFilterPtr = ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
2293 dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
22862294
22872295 for (i = 0, filterPtr = flist.filters;
22882296 filterPtr;
22962304 initialIndex = i+1; /* Windows filter indices are 1-based */
22972305
22982306 /* First stash away the text description of the pattern */
2299 Tcl_WinUtfToTChar(filterPtr->name, -1, &ds);
2307 Tcl_DStringInit(&ds);
2308 Tcl_UtfToWCharDString(filterPtr->name, -1, &ds);
23002309 nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
23012310 nbytes += sizeof(WCHAR); /* Terminating \0 */
2302 dlgFilterPtr[i].pszName = ckalloc(nbytes);
2311 dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes);
23032312 memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
23042313 Tcl_DStringFree(&ds);
23052314
23242333 }
23252334
23262335 /* Again we need a Unicode form of the string */
2327 Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds);
2336 Tcl_DStringInit(&ds);
2337 Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), -1, &ds);
23282338 nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
23292339 nbytes += sizeof(WCHAR); /* Terminating \0 */
2330 dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
2340 dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes);
23312341 memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
23322342 Tcl_DStringFree(&ds);
23332343 Tcl_DStringSetLength(&patterns, 0);
24232433 int objc, /* Number of arguments. */
24242434 Tcl_Obj *const objv[]) /* Argument objects. */
24252435 {
2426 WCHAR path[MAX_PATH];
2436 WCHAR path[MAX_PATH];
24272437 int oldMode, result;
24282438 LPCITEMIDLIST pidl; /* Returned by browser */
24292439 BROWSEINFOW bInfo; /* Used by browser */
24602470 if (utfDir[0] != '\0') {
24612471 LPCWSTR uniStr;
24622472
2463 Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
2473 Tcl_DStringInit(&tempString);
2474 Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
24642475 &tempString);
2465 uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
2466
2467 /* Convert possible relative path to full path to keep dialog happy. */
2468
2469 GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
2470 wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
2476 uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
2477
2478 /* Convert possible relative path to full path to keep dialog happy. */
2479
2480 GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
2481 wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
24712482 }
24722483
24732484 /* XXX - rest of this (original) code has no error checks at all. */
24922503 bInfo.lParam = (LPARAM) &cdCBData;
24932504
24942505 if (ofnOpts.titleObj != NULL) {
2495 bInfo.lpszTitle = (LPCWSTR)Tcl_WinUtfToTChar(
2496 Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
2506 Tcl_DStringInit(&titleString);
2507 bInfo.lpszTitle = Tcl_UtfToWCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
24972508 } else {
24982509 bInfo.lpszTitle = L"Please choose a directory, then select OK.";
24992510 }
26172628 Tcl_DString tempString;
26182629 Tcl_DString initDirString;
26192630 WCHAR string[MAX_PATH];
2620 ThreadSpecificData *tsdPtr =
2631 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
26212632 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
26222633
26232634 if (tsdPtr->debugFlag) {
26362647 * like ~ are converted correctly.
26372648 */
26382649
2639 Tcl_WinTCharToUtf((LPCTSTR) lParam, -1, &initDirString);
2650 Tcl_DStringInit(&initDirString);
2651 Tcl_WCharToUtfDString((WCHAR *) lParam, wcslen((WCHAR *) lParam), &initDirString);
26402652 if (Tcl_TranslateFileName(chooseDirSharedData->interp,
26412653 Tcl_DStringValue(&initDirString), &tempString) == NULL) {
26422654 /*
26472659 chooseDirSharedData->retDir[0] = '\0';
26482660 return 1;
26492661 }
2650 Tcl_DStringFree(&initDirString);
2651 Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString);
2652 Tcl_DStringFree(&tempString);
2653 wcsncpy(string, (WCHAR *) Tcl_DStringValue(&initDirString),
2662 Tcl_DStringSetLength(&initDirString, 0);
2663 wcsncpy(string, Tcl_UtfToWCharDString(Tcl_DStringValue(&tempString), -1, &initDirString),
26542664 MAX_PATH);
26552665 Tcl_DStringFree(&initDirString);
2666 Tcl_DStringFree(&tempString);
26562667
26572668 if (SetCurrentDirectoryW(string) == 0) {
26582669
26992710
27002711 if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
27012712 SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM) selDir);
2702 // enable the OK button
2713 /* enable the OK button */
27032714 SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
27042715 } else {
2705 // disable the OK button
2716 /* disable the OK button */
27062717 SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
27072718 }
27082719 UpdateWindow(hwnd);
27332744 ULONG ulCount, ulAttr;
27342745
27352746 if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName(
2736 psfFolder, hwnd, NULL, (WCHAR *)
2737 initDir, &ulCount,&pidlMain,&ulAttr))
2747 psfFolder, hwnd, NULL, initDir,
2748 &ulCount,&pidlMain,&ulAttr))
27382749 && (pidlMain != NULL)) {
27392750 SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE,
27402751 (LPARAM) pidlMain);
27802791 int objc, /* Number of arguments. */
27812792 Tcl_Obj *const objv[]) /* Argument objects. */
27822793 {
2783 Tk_Window tkwin = clientData, parent;
2794 Tk_Window tkwin = (Tk_Window)clientData, parent;
27842795 HWND hWnd;
27852796 Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj;
27862797 int defaultBtn, icon, type;
27942805 MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE,
27952806 MSG_PARENT, MSG_TITLE, MSG_TYPE
27962807 };
2797 ThreadSpecificData *tsdPtr =
2808 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
27982809 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
27992810 Tcl_DString titleBuf, tmpBuf;
28002811 LPCWSTR titlePtr, tmpPtr;
29282939 tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL,
29292940 GetCurrentThreadId());
29302941 src = Tcl_GetString(tmpObj);
2931 tmpPtr = (LPCWSTR)Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
2942 Tcl_DStringInit(&tmpBuf);
2943 tmpPtr = Tcl_UtfToWCharDString(src, tmpObj->length, &tmpBuf);
29322944 if (titleObj != NULL) {
29332945 src = Tcl_GetString(titleObj);
2934 titlePtr = (LPCWSTR)Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
2946 Tcl_DStringInit(&titleBuf);
2947 titlePtr = Tcl_UtfToWCharDString(src, titleObj->length, &titleBuf);
29352948 } else {
29362949 titlePtr = L"";
29372950 Tcl_DStringInit(&titleBuf);
29622975 WPARAM wParam,
29632976 LPARAM lParam)
29642977 {
2965 ThreadSpecificData *tsdPtr =
2978 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
29662979 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
29672980
29682981 if (nCode == HCBT_CREATEWND) {
30093022 SetTkDialog(
30103023 ClientData clientData)
30113024 {
3012 ThreadSpecificData *tsdPtr =
3025 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
30133026 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
30143027 char buf[32];
30153028
30233036
30243037 static const char *
30253038 ConvertExternalFilename(
3026 WCHAR *filename,
3039 LPCWSTR filename,
30273040 Tcl_DString *dsPtr)
30283041 {
30293042 char *p;
30303043
3031 Tcl_WinTCharToUtf((LPCTSTR)filename, -1, dsPtr);
3044 Tcl_DStringInit(dsPtr);
3045 Tcl_WCharToUtfDString(filename, wcslen(filename), dsPtr);
30323046 for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) {
30333047 /*
30343048 * Change the pathname to the Tcl "normalized" pathname, where back
30653079 int pt = 0;
30663080
30673081 resObj = Tcl_NewListObj(0, NULL);
3068 Tcl_WinTCharToUtf((LPCTSTR)plf->lfFaceName, -1, &ds);
3082 Tcl_DStringInit(&ds);
3083 Tcl_WCharToUtfDString(plf->lfFaceName, wcslen(plf->lfFaceName), &ds);
30693084 Tcl_ListObjAppendElement(NULL, resObj,
30703085 Tcl_NewStringObj(Tcl_DStringValue(&ds), -1));
30713086 Tcl_DStringFree(&ds);
31003115 Tcl_Obj **objv, **tmpv;
31013116
31023117 Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv);
3103 tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
3118 tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
31043119 memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
31053120 tmpv[objc] = GetFontObj(hdc, logfontPtr);
31063121 TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL);
31383153 CHOOSEFONT *pcf = (CHOOSEFONT *) lParam;
31393154 HWND hwndCtrl;
31403155 static HookData *phd = NULL;
3141 ThreadSpecificData *tsdPtr =
3156 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
31423157 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
31433158
31443159 if (WM_INITDIALOG == msg && lParam != 0) {
31513166 if (phd->titleObj != NULL) {
31523167 Tcl_DString title;
31533168
3154 Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title);
3169 Tcl_DStringInit(&title);
3170 Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title);
31553171 if (Tcl_DStringLength(&title) > 0) {
31563172 SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
31573173 }
32803296 int objc,
32813297 Tcl_Obj *const objv[])
32823298 {
3283 Tk_Window tkwin = clientData;
3299 Tk_Window tkwin = (Tk_Window)clientData;
32843300 HookData *hdPtr = NULL;
32853301 int i, r = TCL_OK;
32863302 static const char *const optionStrings[] = {
32873303 "-parent", "-title", "-font", "-command", "-visible", NULL
32883304 };
32893305
3290 hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
3306 hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
32913307
32923308 /*
32933309 * With no arguments we return all the options in a dict.
34243440 Tcl_Obj *const objv[])
34253441 {
34263442 Tcl_DString ds;
3427 Tk_Window tkwin = clientData, parent;
3443 Tk_Window tkwin = (Tk_Window)clientData, parent;
34283444 CHOOSEFONTW cf;
34293445 LOGFONTW lf;
34303446 HDC hdc;
34313447 HookData *hdPtr;
34323448 int r = TCL_OK, oldMode = 0;
3433
3434 hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
3449 (void)objc;
3450 (void)objv;
3451
3452 hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
34353453
34363454 parent = tkwin;
34373455 if (hdPtr->parentObj) {
34683486 }
34693487 fontPtr = (TkFont *) f;
34703488 cf.Flags |= CF_INITTOLOGFONTSTRUCT;
3471 Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
3472 wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds),
3489 Tcl_DStringInit(&ds);
3490 wcsncpy(lf.lfFaceName, Tcl_UtfToWCharDString(fontPtr->fa.family, -1, &ds),
34733491 LF_FACESIZE-1);
34743492 Tcl_DStringFree(&ds);
34753493 lf.lfFaceName[LF_FACESIZE-1] = 0;
35323550
35333551 static int
35343552 FontchooserHideCmd(
3535 ClientData clientData, /* Main window */
3553 ClientData dummy, /* Main window */
35363554 Tcl_Interp *interp,
35373555 int objc,
35383556 Tcl_Obj *const objv[])
35393557 {
3540 HookData *hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
3558 HookData *hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
3559 (void)dummy;
3560 (void)objc;
3561 (void)objv;
35413562
35423563 if (hdPtr->hwnd && IsWindow(hdPtr->hwnd)) {
35433564 EndDialog(hdPtr->hwnd, 0);
35573578 */
35583579
35593580 static void
3560 DeleteHookData(ClientData clientData, Tcl_Interp *interp)
3581 DeleteHookData(ClientData clientData, Tcl_Interp *dummy)
35613582 {
3562 HookData *hdPtr = clientData;
3583 HookData *hdPtr = (HookData *)clientData;
3584 (void)dummy;
35633585
35643586 if (hdPtr->parentObj) {
35653587 Tcl_DecrRefCount(hdPtr->parentObj);
35963618 };
35973619
35983620 int
3599 TkInitFontchooser(Tcl_Interp *interp, ClientData clientData)
3621 TkInitFontchooser(Tcl_Interp *interp, ClientData dummy)
36003622 {
3601 HookData *hdPtr = ckalloc(sizeof(HookData));
3623 HookData *hdPtr = (HookData *)ckalloc(sizeof(HookData));
3624 (void)dummy;
36023625
36033626 memset(hdPtr, 0, sizeof(HookData));
36043627 Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr);
2828 #define FONTMAP_SHIFT 10
2929
3030 #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
31 #define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
31 #define FONTMAP_NUMCHARS 0x40000
32 #define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
3233
3334 typedef struct FontFamily {
3435 struct FontFamily *nextPtr; /* Next in list of all known font families. */
213214 USHORT **startCount, USHORT **endCount,
214215 int *symbolPtr);
215216 static void MultiFontTextOut(HDC hdc, WinFont *fontPtr,
216 const char *source, int numBytes, int x, int y,
217 double angle);
217 const char *source, int numBytes,
218 double x, double y, double angle);
218219 static void ReleaseFont(WinFont *fontPtr);
219220 static inline void ReleaseSubFont(SubFont *subFontPtr);
220221 static int SeenName(const char *name, Tcl_DString *dsPtr);
298299 }
299300
300301 tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr;
301 fontPtr = ckalloc(sizeof(WinFont));
302 InitFont(tkwin, GetStockObject(object), 0, fontPtr);
302 fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
303 InitFont(tkwin, (HFONT)GetStockObject(object), 0, fontPtr);
303304
304305 return (TkFont *) fontPtr;
305306 }
556557 hFont = GetScreenFont(faPtr, faceName,
557558 (int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0);
558559 if (tkFontPtr == NULL) {
559 fontPtr = ckalloc(sizeof(WinFont));
560 fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
560561 } else {
561562 fontPtr = (WinFont *) tkFontPtr;
562563 ReleaseFont(fontPtr);
652653 static int CALLBACK
653654 WinFontFamilyEnumProc(
654655 ENUMLOGFONTW *lfPtr, /* Logical-font data. */
655 NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
656 int fontType, /* Type of font (not used). */
656 TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
657 TCL_UNUSED(int), /* Type of font (not used). */
657658 LPARAM lParam) /* Result object to hold result. */
658659 {
660 WCHAR *faceName = lfPtr->elfLogFont.lfFaceName;
659661 Tcl_Obj *resultObj = (Tcl_Obj *) lParam;
660662 Tcl_DString faceString;
661663
662 Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString);
664 Tcl_DStringInit(&faceString);
665 Tcl_WCharToUtfDString(faceName, wcslen(faceName), &faceString);
663666 Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
664667 Tcl_DStringValue(&faceString), Tcl_DStringLength(&faceString)));
665668 Tcl_DStringFree(&faceString);
748751 * Get the font attributes.
749752 */
750753
751 oldfont = SelectObject(hdc, thisSubFontPtr->hFont0);
754 oldfont = (HFONT)SelectObject(hdc, thisSubFontPtr->hFont0);
752755 GetTextMetricsW(hdc, &tm);
753756 SelectObject(hdc, oldfont);
754757 ReleaseDC(fontPtr->hwnd, hdc);
826829
827830 hdc = GetDC(fontPtr->hwnd);
828831 lastSubFontPtr = &fontPtr->subFontArray[0];
829 oldFont = SelectObject(hdc, lastSubFontPtr->hFont0);
832 oldFont = (HFONT)SelectObject(hdc, lastSubFontPtr->hFont0);
830833
831834 /*
832835 * A three step process:
10121015 Tk_Font tkfont, /* Font in which characters will be drawn. */
10131016 const char *source, /* UTF-8 string to be displayed. Need not be
10141017 * '\0' terminated. */
1015 int numBytes, /* Maximum number of bytes to consider from
1018 TCL_UNUSED(int), /* Maximum number of bytes to consider from
10161019 * source string in all. */
10171020 int rangeStart, /* Index of first byte to measure. */
10181021 int rangeLength, /* Length of range to measure in bytes. */
10341037 int *lengthPtr) /* Filled with x-location just after the
10351038 * terminating character. */
10361039 {
1037 (void) numBytes; /*unused*/
10381040 return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
10391041 maxLength, flags, lengthPtr);
10401042 }
10601062 Display *display, /* Display on which to draw. */
10611063 Drawable drawable, /* Window or pixmap in which to draw. */
10621064 GC gc, /* Graphics context for drawing characters. */
1063 Tk_Font tkfont, /* Font in which characters will be drawn;
1065 TCL_UNUSED(Tk_Font), /* Font in which characters will be drawn;
10641066 * must be the same as font used in GC. */
10651067 const char *source, /* UTF-8 string to be displayed. Need not be
10661068 * '\0' terminated. All Tk meta-characters
11151117
11161118 stipple = CreatePatternBrush(twdPtr->bitmap.handle);
11171119 SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
1118 oldBrush = SelectObject(dc, stipple);
1120 oldBrush = (HBRUSH)SelectObject(dc, stipple);
11191121
11201122 SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
11211123 SetTextColor(dcMem, gc->foreground);
11301132 GetTextMetricsW(dcMem, &tm);
11311133 size.cx -= tm.tmOverhang;
11321134 bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
1133 oldBitmap = SelectObject(dcMem, bitmap);
1135 oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
11341136
11351137 /*
11361138 * The following code is tricky because fonts are rendered in multiple
11841186 GetTextMetricsW(dcMem, &tm);
11851187 size.cx -= tm.tmOverhang;
11861188 bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
1187 oldBitmap = SelectObject(dcMem, bitmap);
1189 oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
11881190
11891191 MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
11901192 0.0);
12071209 Display *display, /* Display on which to draw. */
12081210 Drawable drawable, /* Window or pixmap in which to draw. */
12091211 GC gc, /* Graphics context for drawing characters. */
1210 Tk_Font tkfont, /* Font in which characters will be drawn;
1212 TCL_UNUSED(Tk_Font), /* Font in which characters will be drawn;
12111213 * must be the same as font used in GC. */
12121214 const char *source, /* UTF-8 string to be displayed. Need not be
12131215 * '\0' terminated. All Tk meta-characters
12631265
12641266 stipple = CreatePatternBrush(twdPtr->bitmap.handle);
12651267 SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
1266 oldBrush = SelectObject(dc, stipple);
1268 oldBrush = (HBRUSH)SelectObject(dc, stipple);
12671269
12681270 SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
12691271 SetTextColor(dcMem, gc->foreground);
12781280 GetTextMetricsW(dcMem, &tm);
12791281 size.cx -= tm.tmOverhang;
12801282 bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
1281 oldBitmap = SelectObject(dcMem, bitmap);
1283 oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
12821284
12831285 /*
12841286 * The following code is tricky because fonts are rendered in multiple
12891291 */
12901292
12911293 PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
1292 MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
1294 MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
12931295 BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
12941296 0, 0, 0xEA02E9);
12951297 PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
1296 MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
1298 MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
12971299 BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
12981300 0, 0, 0x8A0E06);
12991301
13101312 SetTextAlign(dc, TA_LEFT | TA_BASELINE);
13111313 SetTextColor(dc, gc->foreground);
13121314 SetBkMode(dc, TRANSPARENT);
1313 MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
1315 MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
13141316 } else {
13151317 HBITMAP oldBitmap, bitmap;
13161318 HDC dcMem;
13321334 GetTextMetricsW(dcMem, &tm);
13331335 size.cx -= tm.tmOverhang;
13341336 bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
1335 oldBitmap = SelectObject(dcMem, bitmap);
1337 oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
13361338
13371339 MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
13381340 angle);
13581360 * Draw a string of characters on the screen like Tk_DrawChars(), but
13591361 * with access to all the characters on the line for context. On Windows
13601362 * this context isn't consulted, so we just call Tk_DrawChars().
1361 *
1363 *
1364 * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this
1365 * function is unused (and possibly unfinished). See [7655f65ae7].
1366 *
13621367 * Results:
13631368 * None.
13641369 *
13821387 * is passed to this function. If they are not
13831388 * stripped out, they will be displayed as
13841389 * regular printing characters. */
1385 int numBytes, /* Number of bytes in string. */
1390 TCL_UNUSED(int), /* Number of bytes in string. */
13861391 int rangeStart, /* Index of first byte to draw. */
13871392 int rangeLength, /* Length of range to draw in bytes. */
13881393 int x, int y) /* Coordinates at which to place origin of the
13911396 {
13921397 int widthUntilStart;
13931398
1394 (void) numBytes; /*unused*/
1395
13961399 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
13971400 Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
13981401 rangeLength, x+widthUntilStart, y);
1402 }
1403
1404 void
1405 TkpDrawAngledCharsInContext(
1406 Display *display, /* Display on which to draw. */
1407 Drawable drawable, /* Window or pixmap in which to draw. */
1408 GC gc, /* Graphics context for drawing characters. */
1409 Tk_Font tkfont, /* Font in which characters will be drawn; must
1410 * be the same as font used in GC. */
1411 const char * source, /* UTF-8 string to be displayed. Need not be
1412 * '\0' terminated. All Tk meta-characters
1413 * (tabs, control characters, and newlines)
1414 * should be stripped out of the string that is
1415 * passed to this function. If they are not
1416 * stripped out, they will be displayed as
1417 * regular printing characters. */
1418 int numBytes, /* Number of bytes in string. */
1419 int rangeStart, /* Index of first byte to draw. */
1420 int rangeLength, /* Length of range to draw in bytes. */
1421 double x, double y, /* Coordinates at which to place origin of the
1422 * whole (not just the range) string when
1423 * drawing. */
1424 double angle) /* What angle to put text at, in degrees. */
1425 {
1426 int widthUntilStart;
1427 double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
1428 (void) numBytes; /*unused*/
1429
1430 Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
1431 TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart,
1432 rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle);
13991433 }
14001434
14011435 /*
14251459 * following string. */
14261460 const char *source, /* Potentially multilingual UTF-8 string. */
14271461 int numBytes, /* Length of string in bytes. */
1428 int x, int y, /* Coordinates at which to place origin of
1462 double x, double y, /* Coordinates at which to place origin of
14291463 * string when drawing. */
14301464 double angle)
14311465 {
14371471 const char *p, *end, *next;
14381472 SubFont *lastSubFontPtr, *thisSubFontPtr;
14391473 TEXTMETRICW tm;
1474 double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
14401475
14411476 lastSubFontPtr = &fontPtr->subFontArray[0];
14421477 oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
14591494 familyPtr = lastSubFontPtr->familyPtr;
14601495 Tcl_UtfToExternalDString(familyPtr->encoding, source,
14611496 (int) (p - source), &runString);
1462 familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
1497 familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
14631498 (WCHAR *)Tcl_DStringValue(&runString),
1464 Tcl_DStringLength(&runString)>>familyPtr->isWideFont);
1499 Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
14651500 familyPtr->getTextExtentPoint32Proc(hdc,
14661501 (WCHAR *)Tcl_DStringValue(&runString),
14671502 Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
14681503 &size);
1469 x += size.cx;
1504 x += cosA*size.cx;
1505 y -= sinA*size.cx;
14701506 Tcl_DStringFree(&runString);
14711507 }
14721508 lastSubFontPtr = thisSubFontPtr;
14801516 familyPtr = lastSubFontPtr->familyPtr;
14811517 Tcl_UtfToExternalDString(familyPtr->encoding, source,
14821518 (int) (p - source), &runString);
1483 familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
1519 familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
14841520 (WCHAR *)Tcl_DStringValue(&runString),
14851521 Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
14861522 Tcl_DStringFree(&runString);
14961532 double angle)
14971533 {
14981534 if (angle == 0.0) {
1499 return SelectObject(hdc, subFontPtr->hFont0);
1535 return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
15001536 } else if (angle == subFontPtr->angle) {
1501 return SelectObject(hdc, subFontPtr->hFontAngled);
1537 return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
15021538 } else {
15031539 if (subFontPtr->hFontAngled) {
15041540 DeleteObject(subFontPtr->hFontAngled);
15061542 subFontPtr->hFontAngled = GetScreenFont(&fontPtr->font.fa,
15071543 subFontPtr->familyPtr->faceName, fontPtr->pixelSize, angle);
15081544 if (subFontPtr->hFontAngled == NULL) {
1509 return SelectObject(hdc, subFontPtr->hFont0);
1545 return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
15101546 }
15111547 subFontPtr->angle = angle;
1512 return SelectObject(hdc, subFontPtr->hFontAngled);
1548 return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
15131549 }
15141550 }
15151551
15611597 window = Tk_WindowId(tkwin);
15621598 hwnd = (window == None) ? NULL : TkWinGetHWND(window);
15631599 hdc = GetDC(hwnd);
1564 oldFont = SelectObject(hdc, hFont);
1600 oldFont = (HFONT)SelectObject(hdc, hFont);
15651601
15661602 GetTextMetricsW(hdc, &tm);
15671603
15681604 GetTextFaceW(hdc, LF_FACESIZE, buf);
1569 Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString);
1605 Tcl_DStringInit(&faceString);
1606 Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
15701607
15711608 fontPtr->font.fid = (Font) fontPtr;
15721609 fontPtr->hwnd = hwnd;
17301767 HDC hdc, /* HDC in which font can be selected. */
17311768 HFONT hFont, /* Screen font whose FontFamily is to be
17321769 * returned. */
1733 int base) /* Non-zero if this font family is to be used
1770 TCL_UNUSED(int)) /* Non-zero if this font family is to be used
17341771 * in the base font of a font object. */
17351772 {
17361773 Tk_Uid faceName;
17381775 Tcl_DString faceString;
17391776 Tcl_Encoding encoding;
17401777 WCHAR buf[LF_FACESIZE];
1741 ThreadSpecificData *tsdPtr =
1778 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
17421779 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
17431780
1744 hFont = SelectObject(hdc, hFont);
1781 hFont = (HFONT)SelectObject(hdc, hFont);
17451782 GetTextFaceW(hdc, LF_FACESIZE, buf);
1746 Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString);
1783 Tcl_DStringInit(&faceString);
1784 Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
17471785 faceName = Tk_GetUid(Tcl_DStringValue(&faceString));
17481786 Tcl_DStringFree(&faceString);
1749 hFont = SelectObject(hdc, hFont);
1787 hFont = (HFONT)SelectObject(hdc, hFont);
17501788
17511789 familyPtr = tsdPtr->fontFamilyList;
17521790 for ( ; familyPtr != NULL; familyPtr = familyPtr->nextPtr) {
17561794 }
17571795 }
17581796
1759 familyPtr = ckalloc(sizeof(FontFamily));
1797 familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
17601798 memset(familyPtr, 0, sizeof(FontFamily));
17611799 familyPtr->nextPtr = tsdPtr->fontFamilyList;
17621800 tsdPtr->fontFamilyList = familyPtr;
18421880 {
18431881 int i;
18441882 FontFamily **familyPtrPtr;
1845 ThreadSpecificData *tsdPtr =
1883 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
18461884 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
18471885
18481886 if (familyPtr == NULL) {
19191957 SubFont *subFontPtr;
19201958 Tcl_DString ds;
19211959
1922 if ((ch < BASE_CHARS) || (ch >= 0x30000)) {
1960 if ((ch < BASE_CHARS) || (ch >= FONTMAP_NUMCHARS)) {
19231961 return &fontPtr->subFontArray[0];
19241962 }
19251963
20272065 static int CALLBACK
20282066 WinFontCanUseProc(
20292067 ENUMLOGFONTW *lfPtr, /* Logical-font data. */
2030 NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
2031 int fontType, /* Type of font (not used). */
2068 TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
2069 TCL_UNUSED(int), /* Type of font (not used). */
20322070 LPARAM lParam) /* Result object to hold result. */
20332071 {
20342072 int ch;
20462084 fontPtr = canUsePtr->fontPtr;
20472085 nameTriedPtr = canUsePtr->nameTriedPtr;
20482086
2049 fallbackName = Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString);
2087 fallbackName = (char *) lfPtr->elfLogFont.lfFaceName;
2088 Tcl_DStringInit(&faceString);
2089 Tcl_WCharToUtfDString((WCHAR *)fallbackName, wcslen((WCHAR *)fallbackName), &faceString);
2090 fallbackName = Tcl_DStringValue(&faceString);
20502091
20512092 if (SeenName(fallbackName, nameTriedPtr) == 0) {
20522093 subFontPtr = CanUseFallback(hdc, fontPtr, fallbackName, ch,
20892130 {
20902131 int row, bitOffset;
20912132
2092 if (ch < 0 || ch >= 0x30000) {
2133 if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
20932134 return 0;
20942135 }
20952136
21332174 {
21342175 int row, bitOffset;
21352176
2136 if (ch >= 0 && ch < 0x30000) {
2177 if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
21372178 row = ch >> FONTMAP_SHIFT;
21382179 if (subFontPtr->fontMap[row] == NULL) {
21392180 FontMapLoadPage(subFontPtr, row);
21712212 {
21722213 FontFamily *familyPtr;
21732214 Tcl_Encoding encoding;
2174 char src[XMaxTransChars], buf[16];
2215 int i, j, bitOffset, end, segCount;
21752216 USHORT *startCount, *endCount;
2176 int i, j, bitOffset, end, segCount;
2177
2178 subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
2217 char buf[16], src[6];
2218
2219 subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
21792220 memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
21802221
21812222 familyPtr = subFontPtr->familyPtr;
24062447 if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
24072448 SubFont *newPtr;
24082449
2409 newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
2450 newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
24102451 memcpy(newPtr, fontPtr->subFontArray,
24112452 fontPtr->numSubFonts * sizeof(SubFont));
24122453 if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
24542495 double angle) /* What is the desired orientation of the
24552496 * font. */
24562497 {
2457 Tcl_DString ds;
24582498 HFONT hFont;
24592499 LOGFONTW lf;
24602500
24732513 lf.lfQuality = DEFAULT_QUALITY;
24742514 lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
24752515
2476 Tcl_WinUtfToTChar(faceName, -1, &ds);
2477 wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1);
2478 Tcl_DStringFree(&ds);
2516 MultiByteToWideChar(CP_UTF8, 0, faceName, -1, lf.lfFaceName, LF_FACESIZE);
24792517 lf.lfFaceName[LF_FACESIZE-1] = 0;
24802518 hFont = CreateFontIndirectW(&lf);
24812519 return hFont;
25242562 return 0;
25252563 }
25262564
2527 Tcl_WinUtfToTChar(faceName, -1, &faceString);
2565 Tcl_DStringInit(&faceString);
2566 Tcl_UtfToWCharDString(faceName, -1, &faceString);
25282567
25292568 /*
25302569 * If the family exists, WinFontExistProc() will be called and
25332572 * non-zero value.
25342573 */
25352574
2536 result = EnumFontFamiliesW(hdc, (WCHAR*) Tcl_DStringValue(&faceString),
2575 result = EnumFontFamiliesW(hdc, (WCHAR *)Tcl_DStringValue(&faceString),
25372576 (FONTENUMPROCW) WinFontExistProc, 0);
25382577 Tcl_DStringFree(&faceString);
25392578 return (result == 0);
25632602
25642603 static int CALLBACK
25652604 WinFontExistProc(
2566 ENUMLOGFONTW *lfPtr, /* Logical-font data. */
2567 NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
2568 int fontType, /* Type of font (not used). */
2569 LPARAM lParam) /* EnumFontData to hold result. */
2605 TCL_UNUSED(ENUMLOGFONTW *), /* Logical-font data. */
2606 TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
2607 TCL_UNUSED(int), /* Type of font (not used). */
2608 TCL_UNUSED(LPARAM)) /* EnumFontData to hold result. */
25702609 {
25712610 return 0;
25722611 }
27212760 endCount = NULL;
27222761 *symbolPtr = 0;
27232762
2724 hFont = SelectObject(hdc, hFont);
2763 hFont = (HFONT)SelectObject(hdc, hFont);
27252764
27262765 i = 0;
27272766 s = (char *) &i;
27762815 segCount = subTable.segment.segCountX2 / 2;
27772816 cbData = segCount * sizeof(USHORT);
27782817
2779 startCount = ckalloc(cbData);
2780 endCount = ckalloc(cbData);
2818 startCount = (USHORT *)ckalloc(cbData);
2819 endCount = (USHORT *)ckalloc(cbData);
27812820
27822821 offset = encTable.offset + sizeof(subTable.segment);
27832822 GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
28202859
28212860 segCount = 1;
28222861 cbData = segCount * sizeof(USHORT);
2823 startCount = ckalloc(cbData);
2824 endCount = ckalloc(cbData);
2862 startCount = (USHORT *)ckalloc(cbData);
2863 endCount = (USHORT *)ckalloc(cbData);
28252864 startCount[0] = 0x0000;
28262865 endCount[0] = 0x00ff;
28272866 }
3434 TkpInit(
3535 Tcl_Interp *interp)
3636 {
37 (void)interp;
3738 /*
3839 * This is necessary for static initialization, and is ok otherwise
3940 * because TkWinXInit flips a static bit to do its work just once.
136137
137138 len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
138139 msgString = &titleString[len + 1];
139 titleString[TK_MAX_WARN_LEN - 1] = L'\0';
140 titleString[TK_MAX_WARN_LEN - 1] = '\0';
140141 MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len);
141142 /*
142143 * Truncate MessageBox string if it is too long to not overflow the screen
143144 * and cause possible oversized window error.
144145 */
145 if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') {
146 if (titleString[TK_MAX_WARN_LEN - 1] != '\0') {
146147 memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR));
147148 }
148149 if (IsDebuggerPresent()) {
149 titleString[len - 1] = L':';
150 titleString[len] = L' ';
150 titleString[len - 1] = ':';
151 titleString[len] = ' ';
151152 OutputDebugStringW(titleString);
152153 } else {
153 titleString[len - 1] = L'\0';
154 titleString[len - 1] = '\0';
154155 MessageBoxW(NULL, msgString, titleString,
155156 MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
156157 | MB_SETFOREGROUND | MB_TOPMOST);
195196 *p = '\0';
196197 }
197198
198 Tcl_WinTCharToUtf((LPCTSTR)lpBuffer, -1, &ds);
199 Tcl_DStringInit(&ds);
200 Tcl_WCharToUtfDString(lpBuffer, wcslen(lpBuffer), &ds);
199201 errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
200202 Tcl_DStringFree(&ds);
201203
205207
206208 return errPtr;
207209 }
208
209210
210211 /*
211212 * Local Variables:
184184
185185 #define TK_THEME_WIN_CLASSIC 1
186186 #define TK_THEME_WIN_XP 2
187 #define TK_THEME_WIN_VISTA 3
187188
188189 /*
189190 * The following is implemented in tkWinWm and used by tkWinEmbed.c
9696 * result. */
9797 {
9898 XKeyEvent *keyEv = &eventPtr->xkey;
99 int len;
99100 char buf[6];
100 int len;
101101
102102 Tcl_DStringInit(dsPtr);
103103 if (keyEv->send_event == -1) {
104 if (keyEv->nbytes > 0) {
104 TkKeyEvent *ev = (TkKeyEvent *)keyEv;
105 if (ev->nbytes > 0) {
105106 Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(),
106 keyEv->trans_chars, keyEv->nbytes, dsPtr);
107 ev->trans_chars, ev->nbytes, dsPtr);
107108 }
108109 } else if (keyEv->send_event == -3) {
109110
110111 /*
111 * Special case for WM_UNICHAR and win2000 multi-lingal IME input
112 * Special case for WM_UNICHAR and win2000 multilingual IME input
112113 */
113114
114115 len = TkUniCharToUtf(keyEv->keycode, buf);
232232 TkMenuEntry *mePtr, /* The menu we are working with. */
233233 WORD *menuIDPtr) /* The resulting id. */
234234 {
235 ThreadSpecificData *tsdPtr =
235 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
236236 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
237237 WORD curID = tsdPtr->lastCommandID;
238238
239239 while (1) {
240240 Tcl_HashEntry *commandEntryPtr;
241 int new;
241 int isNew;
242242
243243 /*
244244 * Try the next ID number, taking care to wrap rather than stray
254254 }
255255
256256 commandEntryPtr = Tcl_CreateHashEntry(&tsdPtr->commandTable,
257 INT2PTR(curID), &new);
258 if (new) {
257 INT2PTR(curID), &isNew);
258 if (isNew) {
259259 Tcl_SetHashValue(commandEntryPtr, mePtr);
260260 *menuIDPtr = curID;
261261 tsdPtr->lastCommandID = curID;
284284 FreeID(
285285 WORD commandID)
286286 {
287 ThreadSpecificData *tsdPtr =
287 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
288288 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
289289
290290 /*
327327 HMENU winMenuHdl;
328328 Tcl_HashEntry *hashEntryPtr;
329329 int newEntry;
330 ThreadSpecificData *tsdPtr =
330 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
331331 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
332332
333333 winMenuHdl = CreatePopupMenu();
373373 {
374374 HMENU winMenuHdl = (HMENU) menuPtr->platformData;
375375 const char *searchName;
376 ThreadSpecificData *tsdPtr =
376 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
377377 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
378378
379379 if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
387387 if (menuPtr->menuFlags & MENU_SYSTEM_MENU) {
388388 TkMenuEntry *searchEntryPtr;
389389 Tcl_HashTable *tablePtr = TkGetMenuHashTable(menuPtr->interp);
390 char *menuName = Tcl_GetHashKey(tablePtr,
390 char *menuName = (char *)Tcl_GetHashKey(tablePtr,
391391 menuPtr->menuRefPtr->hashEntryPtr);
392392
393393 /*
419419
420420 if (tsdPtr->menuHWND != NULL) {
421421 Tcl_HashEntry *hashEntryPtr =
422 Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl);
422 Tcl_FindHashEntry(&tsdPtr->winMenuTable, winMenuHdl);
423423
424424 if (hashEntryPtr != NULL) {
425425 Tcl_DeleteHashEntry(hashEntryPtr);
491491 char *itemText;
492492
493493 if (mePtr->type == TEAROFF_ENTRY) {
494 itemText = ckalloc(sizeof("(Tear-off)"));
494 itemText = (char *)ckalloc(sizeof("(Tear-off)"));
495495 strcpy(itemText, "(Tear-off)");
496496 } else if (mePtr->imagePtr != NULL) {
497 itemText = ckalloc(sizeof("(Image)"));
497 itemText = (char *)ckalloc(sizeof("(Image)"));
498498 strcpy(itemText, "(Image)");
499499 } else if (mePtr->bitmapPtr != NULL) {
500 itemText = ckalloc(sizeof("(Pixmap)"));
500 itemText = (char *)ckalloc(sizeof("(Pixmap)"));
501501 strcpy(itemText, "(Pixmap)");
502502 } else if (mePtr->labelPtr == NULL || mePtr->labelLength == 0) {
503 itemText = ckalloc(sizeof("( )"));
503 itemText = (char *)ckalloc(sizeof("( )"));
504504 strcpy(itemText, "( )");
505505 } else {
506506 int i;
510510 : Tcl_GetString(mePtr->accelPtr);
511511 const char *p, *next;
512512 Tcl_DString itemString;
513 int ch;
513514
514515 /*
515516 * We have to construct the string with an ampersand preceeding the
526527 if (*p == '&') {
527528 Tcl_DStringAppend(&itemString, "&", 1);
528529 }
529 next = Tcl_UtfNext(p);
530 next = p + TkUtfToUniChar(p, &ch);
530531 Tcl_DStringAppend(&itemString, p, (int) (next - p));
531532 }
532533 if (mePtr->accelLength > 0) {
535536 if (*p == '&') {
536537 Tcl_DStringAppend(&itemString, "&", 1);
537538 }
538 next = Tcl_UtfNext(p);
539 next = p + TkUtfToUniChar(p, &ch);
539540 Tcl_DStringAppend(&itemString, p, (int) (next - p));
540541 }
541542 }
542543
543 itemText = ckalloc(Tcl_DStringLength(&itemString) + 1);
544 itemText = (char *)ckalloc(Tcl_DStringLength(&itemString) + 1);
544545 strcpy(itemText, Tcl_DStringValue(&itemString));
545546 Tcl_DStringFree(&itemString);
546547 }
568569 ReconfigureWindowsMenu(
569570 ClientData clientData) /* The menu we are rebuilding */
570571 {
571 TkMenu *menuPtr = clientData;
572 TkMenu *menuPtr = (TkMenu *)clientData;
572573 TkMenuEntry *mePtr;
573574 HMENU winMenuHdl = (HMENU) menuPtr->platformData;
574575 char *itemText = NULL;
608609 itemText = GetEntryText(menuPtr, mePtr);
609610 if ((menuPtr->menuType == MENUBAR)
610611 || (menuPtr->menuFlags & MENU_SYSTEM_MENU)) {
611 Tcl_WinUtfToTChar(itemText, -1, &translatedText);
612 Tcl_DStringInit(&translatedText);
613 Tcl_UtfToWCharDString(itemText, -1, &translatedText);
612614 lpNewItem = (LPCWSTR) Tcl_DStringValue(&translatedText);
613615 flags |= MF_STRING;
614616 } else {
727729
728730 if ((menuPtr->menuType == MENUBAR)
729731 && (menuPtr->parentTopLevelPtr != NULL)) {
730 HANDLE bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
732 HWND bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
731733
732734 if (bar) {
733735 DrawMenuBar(bar);
758760
759761 int
760762 TkpPostMenu(
761 Tcl_Interp *interp,
763 Tcl_Interp *dummy,
762764 TkMenu *menuPtr,
763765 int x, int y, int index)
764766 {
768770 POINT point;
769771 Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin);
770772 int oldServiceMode = Tcl_GetServiceMode();
771 ThreadSpecificData *tsdPtr =
773 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
772774 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
775 (void)dummy;
773776
774777 tsdPtr->inPostMenu++;
775778 CallPendingReconfigureImmediately(menuPtr);
868871
869872 int
870873 TkpPostTearoffMenu(
871 Tcl_Interp *interp, /* The interpreter of the menu */
874 Tcl_Interp *dummy, /* The interpreter of the menu */
872875 TkMenu *menuPtr, /* The menu we are posting */
873876 int x, int y, int index) /* The root X,Y coordinates where we are
874877 * posting */
875878 {
876879 int vRootX, vRootY, vRootWidth, vRootHeight;
877880 int result;
881 (void)dummy;
878882
879883 if (index >= menuPtr->numEntries) {
880884 index = menuPtr->numEntries - 1;
10631067 {
10641068 static int nIdles = 0;
10651069 LRESULT lResult = 1;
1066 ThreadSpecificData *tsdPtr =
1070 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
10671071 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
10681072
10691073 switch(message) {
11391143 int returnResult = 0;
11401144 TkMenu *menuPtr;
11411145 TkMenuEntry *mePtr;
1142 ThreadSpecificData *tsdPtr =
1146 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
11431147 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
1148 (void)phwnd;
11441149
11451150 switch (*pMessage) {
11461151 case WM_UNINITMENUPOPUP:
11471152 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
1148 (char *) *pwParam);
1153 *pwParam);
11491154 if (hashEntryPtr != NULL) {
1150 menuPtr = Tcl_GetHashValue(hashEntryPtr);
1155 menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
11511156 if ((menuPtr->menuRefPtr != NULL)
11521157 && (menuPtr->menuRefPtr->parentEntryPtr != NULL)) {
11531158 TkPostSubmenu(menuPtr->interp,
11591164 case WM_INITMENU:
11601165 TkMenuInit();
11611166 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
1162 (char *) *pwParam);
1167 *pwParam);
11631168 if (hashEntryPtr != NULL) {
11641169 tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
1165 menuPtr = Tcl_GetHashValue(hashEntryPtr);
1170 menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
11661171 tsdPtr->modalMenuPtr = menuPtr;
11671172 CallPendingReconfigureImmediately(menuPtr);
11681173 RecursivelyClearActiveMenu(menuPtr);
11981203 if (hashEntryPtr == NULL) {
11991204 break;
12001205 }
1201 mePtr = Tcl_GetHashValue(hashEntryPtr);
1206 mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
12021207 if (mePtr != NULL) {
12031208 TkMenuReferences *menuRefPtr;
12041209 TkMenuEntry *parentEntryPtr;
12441249
12451250 case WM_MENUCHAR: {
12461251 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
1247 (char *) *plParam);
1252 *plParam);
12481253 if (hashEntryPtr != NULL) {
12491254 int i, len, underline;
12501255 Tcl_Obj *labelPtr;
1251 LPCWSTR wlabel;
1256 WCHAR *wlabel;
12521257 int menuChar;
12531258 Tcl_DString ds;
12541259
12551260 *plResult = 0;
1256 menuPtr = Tcl_GetHashValue(hashEntryPtr);
1261 menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
12571262 /*
12581263 * Assume we have something directly convertable to Tcl_UniChar.
12591264 * True at least for wide systems.
12711276 const char *src = Tcl_GetStringFromObj(labelPtr, &len);
12721277
12731278 Tcl_DStringFree(&ds);
1274 wlabel = (LPCWSTR) Tcl_WinUtfToTChar(src, len, &ds);
1275 if ((underline < len) && (menuChar ==
1279 Tcl_DStringInit(&ds);
1280 wlabel = Tcl_UtfToWCharDString(src, len, &ds);
1281 if ((underline + 1 < len + 1) && (menuChar ==
12761282 Tcl_UniCharToUpper(wlabel[underline]))) {
12771283 *plResult = (2 << 16) | i;
12781284 returnResult = 1;
13241330 }
13251331 mePtr = (TkMenuEntry *) itemPtr->itemData;
13261332 menuPtr = mePtr->menuPtr;
1327 twdPtr = ckalloc(sizeof(TkWinDrawable));
1333 twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
13281334 twdPtr->type = TWD_WINDC;
13291335 twdPtr->winDC.hdc = itemPtr->hDC;
13301336
13881394 menuPtr = NULL;
13891395 if (*plParam != 0) {
13901396 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
1391 (char *) *plParam);
1397 *plParam);
13921398 if (hashEntryPtr != NULL) {
1393 menuPtr = Tcl_GetHashValue(hashEntryPtr);
1399 menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
13941400 }
13951401 }
13961402
14151421 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
14161422 INT2PTR(entryIndex));
14171423 if (hashEntryPtr != NULL) {
1418 mePtr = Tcl_GetHashValue(hashEntryPtr);
1424 mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
14191425 }
14201426 }
14211427 }
15041510 TkMenu *menuPtr) /* The menu we are inserting */
15051511 {
15061512 HMENU winMenuHdl;
1507 ThreadSpecificData *tsdPtr =
1513 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
15081514 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
15091515
15101516 if (menuPtr != NULL) {
15131519
15141520 winMenuHdl = (HMENU) menuPtr->platformData;
15151521 hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
1516 (char *) winMenuHdl);
1522 winMenuHdl);
15171523 Tcl_DeleteHashEntry(hashEntryPtr);
15181524 DestroyMenu(winMenuHdl);
15191525 winMenuHdl = CreateMenu();
15521558 const char *menuName) /* The name of the menu to put in front. If
15531559 * NULL, use the default menu bar. */
15541560 {
1561 (void)interp;
1562 (void)tkwin;
1563 (void)menuName;
1564
15551565 /*
15561566 * Nothing to do.
15571567 */
15821592 int *widthPtr, /* The resulting width */
15831593 int *heightPtr) /* The resulting height */
15841594 {
1595 (void)menuPtr;
1596 (void)tkfont;
1597 (void)fmPtr;
1598
15851599 *heightPtr = indicatorDimensions[0];
15861600 if (mePtr->hideMargin) {
15871601 *widthPtr = 0;
16301644 {
16311645 *heightPtr = fmPtr->linespace;
16321646 if (mePtr->type == CASCADE_ENTRY) {
1633 *widthPtr = 0;
1647 /*
1648 * Cascade entries have no accelerator but do show an arrow. Set
1649 * this field width to the width of the OBM_MNARROW system bitmap
1650 * used to display the arrow. I couldn't find how to query the
1651 * system for this value, therefore I resort to hardcoding.
1652 */
1653 *widthPtr = CASCADE_ARROW_WIDTH;
16341654 } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) {
16351655 const char *accel = Tcl_GetString(mePtr->accelPtr);
16361656
16651685 int *widthPtr, /* The resulting width */
16661686 int *heightPtr) /* The resulting height */
16671687 {
1668 if (menuPtr->menuType != MASTER_MENU) {
1688 (void)mePtr;
1689 (void)tkfont;
1690
1691 if (menuPtr->menuType != MAIN_MENU) {
16691692 *heightPtr = 0;
16701693 } else {
16711694 *heightPtr = fmPtr->linespace;
16981721 int *widthPtr, /* The resulting width */
16991722 int *heightPtr) /* The resulting height */
17001723 {
1724 (void)menuPtr;
1725 (void)mePtr;
1726 (void)tkfont;
1727
17011728 *widthPtr = 0;
17021729 *heightPtr = fmPtr->linespace - (2 * fmPtr->descent);
17031730 }
18111838 int width,
18121839 int height)
18131840 {
1841 (void)tkfont;
1842 (void)fmPtr;
1843 (void)width;
1844 (void)height;
1845
18141846 if ((mePtr->type == CHECK_BUTTON_ENTRY)
18151847 || (mePtr->type == RADIO_BUTTON_ENTRY)) {
18161848 if (mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) {
18911923 int baseline;
18921924 int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth;
18931925 const char *accel;
1926 (void)activeBorder;
1927 (void)width;
1928 (void)height;
18941929
18951930 if (menuPtr->menuType == MENUBAR) {
18961931 return;
19081943 * Draw disabled 3D text highlight only with the Win95/98 look.
19091944 */
19101945
1911 if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
1946 if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
19121947 if ((mePtr->state == ENTRY_DISABLED)
19131948 && (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) {
19141949 COLORREF oldFgColor = gc->foreground;
19341969 * DrawMenuEntryArrow --
19351970 *
19361971 * This function draws the arrow bitmap on the right side of a menu
1937 * entry. This function is only used when drawing the arrow for a
1938 * disabled cascade menu.
1972 * entry. This function is only used when drawing the arrow for:
1973 * - a disabled cascade item
1974 * - a cascade item in any state in a torn-off menu
19391975 *
19401976 * Results:
19411977 * None.
19642000 COLORREF oldFgColor;
19652001 COLORREF oldBgColor;
19662002 RECT rect;
2003 (void)gc;
2004 (void)activeBorder;
19672005
19682006 if (!drawArrow || (mePtr->type != CASCADE_ENTRY)) {
19692007 return;
2008 }
2009
2010 /*
2011 * Don't draw the arrow if a submenu is not attached to this
2012 * cascade entry.
2013 */
2014
2015 if ((mePtr->childMenuRefPtr == NULL)
2016 || (mePtr->childMenuRefPtr->menuPtr == NULL)) {
2017 return;
19702018 }
19712019
19722020 oldFgColor = gc->foreground;
20342082 {
20352083 XPoint points[2];
20362084 Tk_3DBorder border;
2085 (void)mePtr;
2086 (void)gc;
2087 (void)tkfont;
2088 (void)fmPtr;
20372089
20382090 points[0].x = x;
20392091 points[0].y = y + height / 2;
20732125 int width, /* Width of entry */
20742126 int height) /* Height of entry */
20752127 {
2128 (void)fmPtr;
2129 (void)width;
2130
20762131 if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
20772132 int len;
20782133
20792134 len = Tcl_GetCharLength(mePtr->labelPtr);
20802135 if (mePtr->underline < len) {
20812136 const char *label, *start, *end;
2137 int ch;
20822138
20832139 label = Tcl_GetString(mePtr->labelPtr);
2084 start = Tcl_UtfAtIndex(label, mePtr->underline);
2085 end = Tcl_UtfNext(start);
2140 start = TkUtfAtIndex(label, mePtr->underline);
2141 end = start + TkUtfToUniChar(start, &ch);
20862142 Tk_UnderlineChars(menuPtr->display, d,
20872143 gc, tkfont, label, x + mePtr->indicatorSpace,
20882144 y + (height + fmPtr->ascent - fmPtr->descent) / 2,
21122168
21132169 static int
21142170 TkWinMenuKeyObjCmd(
2115 ClientData clientData, /* Unused. */
2171 ClientData dummy, /* Unused. */
21162172 Tcl_Interp *interp, /* Current interpreter. */
21172173 int objc, /* Number of arguments. */
21182174 Tcl_Obj *const objv[]) /* Argument objects. */
21242180 TkWindow *winPtr;
21252181 KeySym keySym;
21262182 int i;
2183 (void)dummy;
21272184
21282185 if (objc != 3) {
21292186 Tcl_WrongNumArgs(interp, 1, objv, "window keySym");
21732230 virtualKey = XKeysymToKeycode(winPtr->display, keySym);
21742231 scanCode = MapVirtualKeyW(virtualKey, 0);
21752232 if (0 != scanCode) {
2176 XKeyEvent xkey = eventPtr->xkey;
2233 TkKeyEvent xkey;
2234 memcpy(&xkey, eventPtr, sizeof(xkey));
21772235 CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
21782236 WM_SYSKEYDOWN, virtualKey,
21792237 (int) ((scanCode << 16) | (1 << 29)));
2180 if (xkey.nbytes > 0) {
2181 for (i = 0; i < xkey.nbytes; i++) {
2182 CallWindowProcW(DefWindowProcW,
2183 Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
2184 xkey.trans_chars[i],
2185 (int) ((scanCode << 16) | (1 << 29)));
2186 }
2238 for (i = 0; i < xkey.nbytes; i++) {
2239 CallWindowProcW(DefWindowProcW,
2240 Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
2241 xkey.trans_chars[i],
2242 (int) ((scanCode << 16) | (1 << 29)));
21872243 }
21882244 }
21892245 }
22562312 */
22572313
22582314 (void) Tcl_CreateObjCommand(interp, "tk::WinMenuKey",
2259 TkWinMenuKeyObjCmd,
2260 (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
2315 TkWinMenuKeyObjCmd, Tk_MainWindow(interp), NULL);
22612316
22622317 (void) Tk_CreateBinding(interp, bindingTable, (ClientData) uid,
22632318 "<Alt_L>", "tk::WinMenuKey %W %N", 0);
24402495 int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
24412496 const char *label = Tcl_GetString(mePtr->labelPtr);
24422497
2443 if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
2498 if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
24442499 /*
24452500 * Win 95/98 systems draw disabled menu text with a 3D
24462501 * highlight, unless the menu item is highlighted,
25362591 XPoint points[2];
25372592 int segmentWidth, maxX;
25382593 Tk_3DBorder border;
2539
2540 if (menuPtr->menuType != MASTER_MENU) {
2594 (void)mePtr;
2595 (void)gc;
2596 (void)tkfont;
2597 (void)fmPtr;
2598
2599 if (menuPtr->menuType != MAIN_MENU) {
25412600 return;
25422601 }
25432602
25792638
25802639 int
25812640 TkpConfigureMenuEntry(
2582 register TkMenuEntry *mePtr)/* Information about menu entry; may or may
2641 TkMenuEntry *mePtr)/* Information about menu entry; may or may
25832642 * not already have values for some fields. */
25842643 {
25852644 ScheduleMenuReconfigure(mePtr->menuPtr);
26432702 menuDc = TkWinGetDrawableDC(menuPtr->display, menuDrawable, &dcState);
26442703
26452704 memDc = CreateCompatibleDC(menuDc);
2646 oldBitmap = SelectObject(memDc,
2705 oldBitmap = (HBITMAP)SelectObject(memDc,
26472706 CreateCompatibleBitmap(menuDc, width, height) );
26482707
26492708 memWinDraw.type = TWD_WINDC;
31003159 MenuSelectEvent(
31013160 TkMenu *menuPtr) /* the menu we have selected. */
31023161 {
3103 XVirtualEvent event;
3162 union {XEvent general; XVirtualEvent virt;} event;
31043163 union {DWORD msgpos; POINTS point;} root;
31053164
3106 event.type = VirtualEvent;
3107 event.serial = menuPtr->display->request;
3108 event.send_event = 0;
3109 event.display = menuPtr->display;
3165 memset(&event, 0, sizeof(event));
3166 event.virt.type = VirtualEvent;
3167 event.virt.serial = menuPtr->display->request;
3168 event.virt.send_event = 0;
3169 event.virt.display = menuPtr->display;
31103170 Tk_MakeWindowExist(menuPtr->tkwin);
3111 event.event = Tk_WindowId(menuPtr->tkwin);
3112 event.root = XRootWindow(menuPtr->display, 0);
3113 event.subwindow = None;
3114 event.time = TkpGetMS();
3171 event.virt.event = Tk_WindowId(menuPtr->tkwin);
3172 event.virt.root = XRootWindow(menuPtr->display, 0);
3173 event.virt.subwindow = None;
3174 event.virt.time = TkpGetMS();
31153175
31163176 root.msgpos = GetMessagePos();
3117 event.x_root = root.point.x;
3118 event.y_root = root.point.y;
3119 event.state = TkWinGetModifierState();
3120 event.same_screen = 1;
3121 event.name = Tk_GetUid("MenuSelect");
3122 event.user_data = NULL;
3123 Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
3177 event.virt.x_root = root.point.x;
3178 event.virt.y_root = root.point.y;
3179 event.virt.state = TkWinGetModifierState();
3180 event.virt.same_screen = 1;
3181 event.virt.name = Tk_GetUid("MenuSelect");
3182 event.virt.user_data = NULL;
3183 Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
31243184 }
31253185
31263186 /*
31853245 Tk_GetMenuHWND(
31863246 Tk_Window tkwin)
31873247 {
3188 ThreadSpecificData *tsdPtr =
3248 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
31893249 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
3250 (void)tkwin;
31903251
31913252 TkMenuInit();
31923253 return tsdPtr->embeddedMenuHWND;
32103271
32113272 static void
32123273 MenuExitHandler(
3213 ClientData clientData) /* Not used */
3214 {
3274 ClientData dummy) /* Not used */
3275 {
3276 (void)dummy;
3277
32153278 UnregisterClassW(MENU_CLASS_NAME, Tk_GetHINSTANCE());
32163279 UnregisterClassW(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
32173280 }
32353298
32363299 static void
32373300 MenuThreadExitHandler(
3238 ClientData clientData) /* Not used */
3239 {
3240 ThreadSpecificData *tsdPtr =
3301 ClientData dummy) /* Not used */
3302 {
3303 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
32413304 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
3305 (void)dummy;
32423306
32433307 DestroyWindow(tsdPtr->menuHWND);
32443308 DestroyWindow(tsdPtr->embeddedMenuHWND);
32753339 const char *className) /* The name of the option class. */
32763340 {
32773341 Tcl_Obj *valuePtr = NULL;
3342 (void)tkwin;
3343 (void)className;
32783344
32793345 if ((strcmp(dbName, "activeBorderWidth") == 0) ||
32803346 (strcmp(dbName, "borderWidth") == 0)) {
33233389 int padding;
33243390 #endif
33253391 } nc;
3326 OSVERSIONINFOW os;
33273392
33283393 /*
33293394 * Set all of the default options. The loop will terminate when we run out
33433408
33443409 nc.metrics.cbSize = sizeof(nc);
33453410
3346 os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
3347 GetVersionExW(&os);
3348 if (os.dwMajorVersion < 6) {
3411 if (TkWinGetPlatformTheme() != TK_THEME_WIN_VISTA) {
33493412 nc.metrics.cbSize -= sizeof(int);
33503413 }
33513414
34783541 void
34793542 TkpMenuThreadInit(void)
34803543 {
3481 ThreadSpecificData *tsdPtr =
3544 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
34823545 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
34833546
34843547 tsdPtr->menuHWND = CreateWindowW(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP,
367367 input.type = INPUT_MOUSE;
368368 input.mi.dx = (x * 65535 + xscreen/2) / xscreen;
369369 input.mi.dy = (y * 65535 + yscreen/2) / yscreen;
370
371 /*
372 * Horrible workaround here. There is a bug on Win 10: when warping to
373 * pixel (x = 0, y = 0) the SendInput() below just does not move the
374 * mouse pointer. However, as soon as dx or dy is non zero it moves as
375 * expected. Given the scaling factor of 65535 (see above),
376 * (dx = 1 , dy = 0) still means pixel (x = 0, y = 0).
377 * See ticket [69b48f427e].
378 */
379 if (input.mi.dx == 0 && input.mi.dy == 0) {
380 input.mi.dx = 1;
381 }
382
370383 input.mi.mouseData = 0;
371384 input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
372385 input.mi.time = 0;
9090 * See ticket [916c1095438eae56]: GetVersionExW triggers warnings
9191 */
9292 #if defined(_MSC_VER)
93 # pragma warning(disable:4146)
9394 # pragma warning(disable:4267)
9495 # pragma warning(disable:4244)
9596 # pragma warning(disable:4311)
9697 # pragma warning(disable:4312)
9798 # pragma warning(disable:4996)
99 #if !defined(_WIN64)
100 # pragma warning(disable:4305)
101 #endif
98102 #endif
99103
100104 /*
116120 | ((p)->green & 0xff00) | (((p)->blue << 8) & 0xff0000)) | 0x20000000)
117121
118122 /*
123 * Used by tkWindow.c
124 */
125
126 #define TkpHandleMapOrUnmap(tkwin, event) Tk_HandleEvent(event)
127
128 /*
119129 * These calls implement native bitmaps which are not currently
120130 * supported under Windows. The macros eliminate the calls.
121131 */
120120 * be globally unique. */
121121 {
122122 #ifndef TK_SEND_ENABLED_ON_WINDOWS
123 (void)tkwin;
124
123125 /*
124126 * Temporarily disabled for bug #858822
125127 */
162164 if (riPtr == NULL) {
163165 LPUNKNOWN *objPtr;
164166
165 riPtr = ckalloc(sizeof(RegisteredInterp));
167 riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
166168 memset(riPtr, 0, sizeof(RegisteredInterp));
167169 riPtr->interp = interp;
168170
212214 * lookup. */
213215 {
214216 #ifndef TK_SEND_ENABLED_ON_WINDOWS
217 (void)interp;
218 (void)tkwin;
215219 /*
216220 * Temporarily disabled for bug #858822
217221 */
253257 if (*p) {
254258 Tcl_DString ds;
255259
256 Tcl_WinTCharToUtf((LPCTSTR)(p + 1), -1, &ds);
260 Tcl_DStringInit(&ds);
261 Tcl_WCharToUtfDString(p + 1, wcslen(p + 1), &ds);
257262 result = Tcl_ListObjAppendElement(interp,
258263 objList,
259264 Tcl_NewStringObj(Tcl_DStringValue(&ds),
618623 LPMONIKER pmkItem = NULL;
619624 Tcl_DString dString;
620625
621 Tcl_WinUtfToTChar(name, -1, &dString);
626 Tcl_DStringInit(&dString);
627 Tcl_UtfToWCharDString(name, -1, &dString);
622628 hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
623629 Tcl_DStringFree(&dString);
624630 if (SUCCEEDED(hr)) {
732738 * object. */
733739 Tcl_Interp *interp, /* The local interpreter. */
734740 int async, /* Flag for the calling style. */
735 ClientData clientData, /* The RegisteredInterp structure for this
741 ClientData dummy, /* The RegisteredInterp structure for this
736742 * interp. */
737743 int objc, /* Number of arguments to be sent. */
738744 Tcl_Obj *const objv[]) /* The arguments to be sent. */
746752 DISPID dispid;
747753 Tcl_DString ds;
748754 const char *src;
755 (void)dummy;
749756
750757 cmd = Tcl_ConcatObj(objc, objv);
751758
760767
761768 vCmd.vt = VT_BSTR;
762769 src = Tcl_GetString(cmd);
763 Tcl_WinUtfToTChar(src, cmd->length, &ds);
764 vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
770 Tcl_DStringInit(&ds);
771 vCmd.bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, cmd->length, &ds));
765772 Tcl_DStringFree(&ds);
766773
767774 dp.cArgs = 1;
783790
784791 ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR);
785792 if (SUCCEEDED(ehr)) {
786 Tcl_WinTCharToUtf((LPCTSTR)vResult.bstrVal, SysStringLen(vResult.bstrVal) *
787 sizeof (WCHAR), &ds);
793 Tcl_DStringInit(&ds);
794 Tcl_WCharToUtfDString(vResult.bstrVal, SysStringLen(vResult.bstrVal), &ds);
788795 Tcl_DStringResult(interp, &ds);
789796 }
790797
796803
797804 if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) {
798805 Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
799 Tcl_WinTCharToUtf((LPCTSTR)ei.bstrSource, SysStringLen(ei.bstrSource) *
800 sizeof (WCHAR), &ds);
806
807 Tcl_DStringInit(&ds);
808 Tcl_WCharToUtfDString(ei.bstrSource, SysStringLen(ei.bstrSource), &ds);
801809 opError = Tcl_NewStringObj(Tcl_DStringValue(&ds),
802810 Tcl_DStringLength(&ds));
803811 Tcl_DStringFree(&ds);
868876 /* TODO: Handle failure to append */
869877
870878 src = Tcl_GetString(opError);
871 Tcl_WinUtfToTChar(src, opError->length, &ds);
879 Tcl_DStringInit(&ds);
872880 pExcepInfo->bstrDescription =
873 SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
881 SysAllocString(Tcl_UtfToWCharDString(src, opError->length, &ds));
874882 Tcl_DStringFree(&ds);
875883 src = Tcl_GetString(opErrorCode);
876 Tcl_WinUtfToTChar(src, opErrorCode->length, &ds);
884 Tcl_DStringInit(&ds);
877885 pExcepInfo->bstrSource =
878 SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
886 SysAllocString(Tcl_UtfToWCharDString(src, opErrorCode->length, &ds));
879887 Tcl_DStringFree(&ds);
880888 Tcl_DecrRefCount(opErrorCode);
881889 pExcepInfo->scode = E_FAIL;
922930
923931 TRACE("SendQueueCommand()\n");
924932
925 evPtr = ckalloc(sizeof(SendEvent));
933 evPtr = (SendEvent *)ckalloc(sizeof(SendEvent));
926934 evPtr->header.proc = SendEventProc;
927935 evPtr->header.nextPtr = NULL;
928936 evPtr->interp = interp;
964972 int flags)
965973 {
966974 SendEvent *evPtr = (SendEvent *)eventPtr;
975 (void)flags;
967976
968977 TRACE("SendEventProc\n");
969978
165165 void **ppvObject)
166166 {
167167 HRESULT hr = E_NOINTERFACE;
168 TkWinSendCom *this = (TkWinSendCom *) This;
168 TkWinSendCom *sendCom = (TkWinSendCom *) This;
169169 *ppvObject = NULL;
170170
171171 if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0
172172 || memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) {
173 *ppvObject = (void **) this;
174 this->lpVtbl->AddRef(This);
173 *ppvObject = (void **) sendCom;
174 sendCom->lpVtbl->AddRef(This);
175175 hr = S_OK;
176176 } else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) {
177 *ppvObject = (void **) (this + 1);
178 this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1));
177 *ppvObject = (void **) (sendCom + 1);
178 sendCom->lpVtbl2->AddRef((ISupportErrorInfo *) (sendCom + 1));
179179 hr = S_OK;
180180 }
181181 return hr;
185185 WinSendCom_AddRef(
186186 IDispatch *This)
187187 {
188 TkWinSendCom *this = (TkWinSendCom*)This;
189
190 return InterlockedIncrement(&this->refcount);
188 TkWinSendCom *sendCom = (TkWinSendCom*)This;
189
190 return InterlockedIncrement(&sendCom->refcount);
191191 }
192192
193193 static STDMETHODIMP_(ULONG)
195195 IDispatch *This)
196196 {
197197 long r = 0;
198 TkWinSendCom *this = (TkWinSendCom*)This;
199
200 if ((r = InterlockedDecrement(&this->refcount)) == 0) {
198 TkWinSendCom *sendCom = (TkWinSendCom*)This;
199
200 if ((r = InterlockedDecrement(&sendCom->refcount)) == 0) {
201201 TkWinSendCom_Destroy(This);
202202 }
203203 return r;
209209 UINT *pctinfo)
210210 {
211211 HRESULT hr = E_POINTER;
212 (void)This;
212213
213214 if (pctinfo != NULL) {
214215 *pctinfo = 0;
225226 ITypeInfo **ppTI)
226227 {
227228 HRESULT hr = E_POINTER;
229 (void)This;
230 (void)iTInfo;
231 (void)lcid;
228232
229233 if (ppTI) {
230234 *ppTI = NULL;
243247 DISPID *rgDispId)
244248 {
245249 HRESULT hr = E_POINTER;
250 (void)This;
251 (void)riid;
252 (void)cNames;
253 (void)lcid;
246254
247255 if (rgDispId) {
248256 hr = DISP_E_UNKNOWNNAME;
268276 UINT *puArgErr)
269277 {
270278 HRESULT hr = DISP_E_MEMBERNOTFOUND;
271 TkWinSendCom *this = (TkWinSendCom*)This;
279 TkWinSendCom *sendCom = (TkWinSendCom*)This;
280 (void)riid;
281 (void)lcid;
272282
273283 switch (dispidMember) {
274284 case TKWINSENDCOM_DISPID_SEND:
276286 if (pDispParams->cArgs != 1) {
277287 hr = DISP_E_BADPARAMCOUNT;
278288 } else {
279 hr = Send(this, pDispParams->rgvarg[0], pvarResult,
289 hr = Send(sendCom, pDispParams->rgvarg[0], pvarResult,
280290 pExcepInfo, puArgErr);
281291 }
282292 }
287297 if (pDispParams->cArgs != 1) {
288298 hr = DISP_E_BADPARAMCOUNT;
289299 } else {
290 hr = Async(this, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
300 hr = Async(sendCom, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
291301 }
292302 }
293303 break;
312322 REFIID riid,
313323 void **ppvObject)
314324 {
315 TkWinSendCom *this = (TkWinSendCom *)(This - 1);
316
317 return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject);
325 TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
326
327 return sendCom->lpVtbl->QueryInterface((IDispatch *) sendCom, riid, ppvObject);
318328 }
319329
320330 static STDMETHODIMP_(ULONG)
321331 ISupportErrorInfo_AddRef(
322332 ISupportErrorInfo *This)
323333 {
324 TkWinSendCom *this = (TkWinSendCom *)(This - 1);
325
326 return InterlockedIncrement(&this->refcount);
334 TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
335
336 return InterlockedIncrement(&sendCom->refcount);
327337 }
328338
329339 static STDMETHODIMP_(ULONG)
330340 ISupportErrorInfo_Release(
331341 ISupportErrorInfo *This)
332342 {
333 TkWinSendCom *this = (TkWinSendCom *)(This - 1);
334
335 return this->lpVtbl->Release((IDispatch *) this);
343 TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
344
345 return sendCom->lpVtbl->Release((IDispatch *) sendCom);
336346 }
337347
338348 static STDMETHODIMP
340350 ISupportErrorInfo *This,
341351 REFIID riid)
342352 {
343 /*TkWinSendCom *this = (TkWinSendCom*)(This - 1);*/
353 (void)This;
354 (void)riid;
355
356 /*TkWinSendCom *sendCom = (TkWinSendCom*)(This - 1);*/
344357 return S_OK; /* or S_FALSE */
345358 }
346359
370383 HRESULT hr = S_OK;
371384 VARIANT vCmd;
372385 Tcl_DString ds;
386 (void)puArgErr;
373387
374388 VariantInit(&vCmd);
375389
384398 if (SUCCEEDED(hr) && obj->interp) {
385399 Tcl_Obj *scriptPtr;
386400
387 Tcl_WinTCharToUtf((LPCTSTR)vCmd.bstrVal, SysStringLen(vCmd.bstrVal) *
388 sizeof (WCHAR), &ds);
401 Tcl_DStringInit(&ds);
402 Tcl_WCharToUtfDString(vCmd.bstrVal, SysStringLen(vCmd.bstrVal), &ds);
389403 scriptPtr =
390404 Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
391405 Tcl_DStringFree(&ds);
426440 HRESULT hr = S_OK;
427441 int result = TCL_OK;
428442 VARIANT v;
429 register Tcl_Interp *interp = obj->interp;
443 Tcl_Interp *interp = obj->interp;
430444 Tcl_Obj *scriptPtr;
431445 Tcl_DString ds;
446 (void)puArgErr;
432447
433448 if (interp == NULL) {
434449 return S_OK;
439454 return hr;
440455 }
441456
442 Tcl_WinTCharToUtf((LPCTSTR)v.bstrVal, SysStringLen(v.bstrVal) *
443 sizeof(WCHAR), &ds);
457 Tcl_DStringInit(&ds);
458 Tcl_WCharToUtfDString(v.bstrVal, SysStringLen(v.bstrVal), &ds);
444459 scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
445460 Tcl_DStringFree(&ds);
446461 Tcl_Preserve(interp);
456471 pvResult->vt = VT_BSTR;
457472 obj = Tcl_GetObjResult(interp);
458473 src = Tcl_GetString(obj);
459 Tcl_WinUtfToTChar(src, obj->length, &ds);
460 pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
474 Tcl_DStringInit(&ds);
475 pvResult->bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, obj->length, &ds));
461476 Tcl_DStringFree(&ds);
462477 }
463478 if (result == TCL_ERROR) {
6666 */
6767
6868 Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
69 (ClientData) Tk_MainWindow(interp), NULL);
69 Tk_MainWindow(interp), NULL);
7070 Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd,
71 (ClientData) Tk_MainWindow(interp), NULL);
71 Tk_MainWindow(interp), NULL);
7272 Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd,
73 (ClientData) Tk_MainWindow(interp), NULL);
73 Tk_MainWindow(interp), NULL);
7474 Tcl_CreateObjCommand(interp, "testgetwindowinfo", TestgetwindowinfoObjCmd,
75 (ClientData) Tk_MainWindow(interp), NULL);
75 Tk_MainWindow(interp), NULL);
7676 Tcl_CreateObjCommand(interp, "testwinlocale", TestwinlocaleObjCmd,
77 (ClientData) Tk_MainWindow(interp), NULL);
77 Tk_MainWindow(interp), NULL);
7878 return TCL_OK;
7979 }
8080
176176 } else {
177177 char *msgPtr;
178178
179 Tcl_WinTCharToUtf((LPCTSTR)wMsgPtr, -1, &ds);
179 Tcl_DStringInit(&ds);
180 Tcl_WCharToUtfDString(wMsgPtr, wcslen(wMsgPtr), &ds);
180181 LocalFree(wMsgPtr);
181182
182183 msgPtr = Tcl_DStringValue(&ds);
229230 Tcl_Interp *interp,
230231 const char *selection)
231232 {
233 (void)dummy;
234
232235 Tcl_AppendResult(interp, selection, NULL);
233236 return TCL_OK;
234237 }
240243 int objc, /* Number of arguments. */
241244 Tcl_Obj *const objv[]) /* Argument values. */
242245 {
243 Tk_Window tkwin = (Tk_Window) clientData;
246 Tk_Window tkwin = (Tk_Window)clientData;
244247
245248 if (objc != 1) {
246249 Tcl_WrongNumArgs(interp, 1, objv, NULL);
269272
270273 static int
271274 TestwineventObjCmd(
272 ClientData clientData, /* Main window for application. */
275 ClientData dummy, /* Main window for application. */
273276 Tcl_Interp *interp, /* Current interpreter. */
274277 int objc, /* Number of arguments. */
275278 Tcl_Obj *const objv[]) /* Argument strings. */
292295 {WM_COMMAND, "WM_COMMAND"},
293296 {-1, NULL}
294297 };
298 (void)dummy;
295299
296300 if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) {
297301 int b;
374378 case WM_SETTEXT: {
375379 Tcl_DString ds;
376380
377 control = TestFindControl(hwnd, id);
378 if (control == NULL) {
379 Tcl_SetObjResult(interp,
380 Tcl_ObjPrintf("Could not find control with id %d", id));
381 return TCL_ERROR;
382 }
381 control = TestFindControl(hwnd, id);
382 if (control == NULL) {
383 Tcl_SetObjResult(interp,
384 Tcl_ObjPrintf("Could not find control with id %d", id));
385 return TCL_ERROR;
386 }
383387 Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds);
384 result = SendMessageA(control, WM_SETTEXT, 0,
385 (LPARAM) Tcl_DStringValue(&ds));
388 result = SendMessageA(control, WM_SETTEXT, 0,
389 (LPARAM) Tcl_DStringValue(&ds));
386390 Tcl_DStringFree(&ds);
387391 if (result == 0) {
388 Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
389 AppendSystemError(interp, GetLastError());
390 return TCL_ERROR;
392 Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
393 AppendSystemError(interp, GetLastError());
394 return TCL_ERROR;
391395 }
392396 break;
393397 }
426430
427431 static int
428432 TestfindwindowObjCmd(
429 ClientData clientData, /* Main window for application. */
433 ClientData dummy, /* Main window for application. */
430434 Tcl_Interp *interp, /* Current interpreter. */
431435 int objc, /* Number of arguments. */
432436 Tcl_Obj *const objv[]) /* Argument values. */
436440 HWND hwnd = NULL;
437441 int r = TCL_OK;
438442 DWORD myPid;
443 (void)dummy;
439444
440445 Tcl_DStringInit(&classString);
441446 Tcl_DStringInit(&titleString);
445450 return TCL_ERROR;
446451 }
447452
448 title = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[1]), -1, &titleString);
453 Tcl_DStringInit(&titleString);
454 title = Tcl_UtfToWCharDString(Tcl_GetString(objv[1]), -1, &titleString);
449455 if (objc == 3) {
450 windowClass = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[2]), -1, &classString);
456 Tcl_DStringInit(&classString);
457 windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), -1, &classString);
451458 }
452459 if (title[0] == 0)
453460 title = NULL;
496503
497504 static int
498505 TestgetwindowinfoObjCmd(
499 ClientData clientData,
506 ClientData dummy,
500507 Tcl_Interp *interp,
501508 int objc,
502509 Tcl_Obj *const objv[])
507514 WCHAR buf[512];
508515 int cch, cchBuf = 256;
509516 Tcl_DString ds;
517 (void)dummy;
510518
511519 if (objc != 2) {
512520 Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
522530 AppendSystemError(interp, GetLastError());
523531 return TCL_ERROR;
524532 } else {
525 Tcl_DString ds;
526 Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &ds);
533 Tcl_DStringInit(&ds);
534 Tcl_WCharToUtfDString(buf, wcslen(buf), &ds);
527535 classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
528536 Tcl_DStringFree(&ds);
529537 }
534542 Tcl_NewWideIntObj(GetWindowLongPtrW(INT2PTR(hwnd), GWL_ID)));
535543
536544 cch = GetWindowTextW(INT2PTR(hwnd), buf, cchBuf);
537 Tcl_WinTCharToUtf((LPCTSTR)buf, cch * sizeof (WCHAR), &ds);
545 Tcl_DStringInit(&ds);
546 Tcl_WCharToUtfDString(buf, cch, &ds);
538547 textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
539548 Tcl_DStringFree(&ds);
540549
552561
553562 static int
554563 TestwinlocaleObjCmd(
555 ClientData clientData, /* Main window for application. */
564 ClientData dummy, /* Main window for application. */
556565 Tcl_Interp *interp, /* Current interpreter. */
557566 int objc, /* Number of arguments. */
558567 Tcl_Obj *const objv[]) /* Argument values. */
559568 {
569 (void)dummy;
570
560571 if (objc != 1) {
561572 Tcl_WrongNumArgs(interp, 1, objv, NULL);
562573 return TCL_ERROR;
5656 /* Next in list of protocol handlers for the
5757 * same top-level window, or NULL for end of
5858 * list. */
59 Tcl_Interp *interp; /* Interpreter in which to invoke command. */
60 char command[1]; /* Tcl command to invoke when a client message
59 Tcl_Interp *interp; /* Interpreter in which to invoke command. */
60 char command[TKFLEXARRAY]; /* Tcl command to invoke when a client message
6161 * for this protocol arrives. The actual size
6262 * of the structure varies to accommodate the
6363 * needs of the actual command. THIS MUST BE
6565 } ProtocolHandler;
6666
6767 #define HANDLER_SIZE(cmdLength) \
68 ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
68 ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)
6969
7070 /*
7171 * Helper type passed via lParam to TkWmStackorderToplevelEnumProc
176176 * (corresponds to hints.window_group).
177177 * Malloc-ed. Note: this field doesn't get
178178 * updated if leader is destroyed. */
179 TkWindow *masterPtr; /* Master window for TRANSIENT_FOR property,
179 TkWindow *containerPtr; /* Container window for TRANSIENT_FOR property,
180180 * or NULL. */
181181 Tk_Window icon; /* Window to use as icon for this window, or
182182 * NULL. */
314314 * window (controlled by "wm resizable" command).
315315 * WM_WITHDRAWN - Non-zero means that this window has explicitly
316316 * been withdrawn. If it's a transient, it should
317 * not mirror state changes in the master.
317 * not mirror state changes in the container.
318318 * WM_FULLSCREEN - Non-zero means that this window has been placed
319319 * in the full screen mode. It should be mapped at
320320 * 0,0 and be the width and height of the screen.
855855 InitWindowClass(
856856 WinIconPtr titlebaricon)
857857 {
858 ThreadSpecificData *tsdPtr =
858 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
859859 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
860860
861861 if (!tsdPtr->initialized) {
11161116 {
11171117 WmInfo *wmPtr;
11181118 HICON icon;
1119 ThreadSpecificData *tsdPtr =
1119 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
11201120 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
11211121
11221122 if (tsdPtr->iconPtr != NULL) {
12401240 if (file == NULL) {
12411241 return NULL;
12421242 }
1243 Tcl_WinUtfToTChar(file, -1, &ds2);
1243 Tcl_DStringInit(&ds2);
1244 res = (DWORD *)SHGetFileInfoW(Tcl_UtfToWCharDString(file, -1, &ds2), 0, &sfiSM,
1245 sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
12441246 Tcl_DStringFree(&ds);
1245 res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM,
1246 sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
12471247
12481248 if (res != 0) {
12491249 SHFILEINFOW sfi;
12591259
12601260 size = sizeof(BlockOfIconImages)
12611261 + ((res != 0) ? sizeof(ICONIMAGE) : 0);
1262 lpIR = ckalloc(size);
1262 lpIR = (BlockOfIconImagesPtr)ckalloc(size);
12631263 if (lpIR == NULL) {
12641264 if (res != 0) {
12651265 DestroyIcon(sfi.hIcon);
12901290 Tcl_DStringFree(&ds2);
12911291 }
12921292 if (lpIR != NULL) {
1293 titlebaricon = ckalloc(sizeof(WinIconInstance));
1293 titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
12941294 titlebaricon->iconBlock = lpIR;
12951295 titlebaricon->refCount = 1;
12961296 }
13661366 return NULL;
13671367 }
13681368
1369 lpIR = ckalloc(sizeof(BlockOfIconImages));
1369 lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
13701370 if (lpIR == NULL) {
13711371 DestroyIcon(hIcon);
13721372 return NULL;
13871387 lpIR->IconImages[0].lpXOR = 0;
13881388 lpIR->IconImages[0].lpAND = 0;
13891389
1390 titlebaricon = ckalloc(sizeof(WinIconInstance));
1390 titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
13911391 titlebaricon->iconBlock = lpIR;
13921392 titlebaricon->refCount = 1;
13931393 return titlebaricon;
15921592 * Allocate memory for the resource structure
15931593 */
15941594
1595 lpIR = ckalloc(sizeof(BlockOfIconImages));
1595 lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
15961596
15971597 /*
15981598 * Read in the header
16101610 * Adjust the size of the struct to account for the images.
16111611 */
16121612
1613 lpIR = ckrealloc(lpIR, sizeof(BlockOfIconImages)
1613 lpIR = (BlockOfIconImagesPtr)ckrealloc(lpIR, sizeof(BlockOfIconImages)
16141614 + (lpIR->nNumImages - 1) * sizeof(ICONIMAGE));
16151615
16161616 /*
16171617 * Allocate enough memory for the icon directory entries.
16181618 */
16191619
1620 lpIDE = ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
1620 lpIDE = (LPICONDIRENTRY)ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
16211621
16221622 /*
16231623 * Read in the icon directory entries.
16521652 * Allocate memory for the resource.
16531653 */
16541654
1655 lpIR->IconImages[i].lpBits = ckalloc(lpIDE[i].dwBytesInRes);
1655 lpIR->IconImages[i].lpBits = (LPBYTE)ckalloc(lpIDE[i].dwBytesInRes);
16561656 lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes;
16571657
16581658 /*
17311731 GetTopLevel(
17321732 HWND hwnd)
17331733 {
1734 ThreadSpecificData *tsdPtr =
1734 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
17351735 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
17361736
17371737 /*
17681768 HWND hwnd,
17691769 MINMAXINFO *info)
17701770 {
1771 register WmInfo *wmPtr;
1771 WmInfo *wmPtr;
17721772 int maxWidth, maxHeight;
17731773 int minWidth, minHeight;
17741774 int base;
18731873 }
18741874 initialized = 0;
18751875
1876 tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
1876 tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
18771877
18781878 if (!tsdPtr->initialized) {
18791879 return;
19041904 TkWmNewWindow(
19051905 TkWindow *winPtr) /* Newly-created top-level window. */
19061906 {
1907 register WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
1907 WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
19081908
19091909 /*
19101910 * Initialize full structure, then set what isn't NULL
19891989 UpdateWrapper(
19901990 TkWindow *winPtr) /* Top-level window to redecorate. */
19911991 {
1992 register WmInfo *wmPtr = winPtr->wmInfoPtr;
1992 WmInfo *wmPtr = winPtr->wmInfoPtr;
19931993 HWND parentHWND, oldWrapper = wmPtr->wrapper;
19941994 HWND child, nextHWND, focusHWND;
19951995 int x, y, width, height, state;
19981998 HICON hBigIcon = NULL;
19991999 Tcl_DString titleString;
20002000 int *childStateInfo = NULL;
2001 ThreadSpecificData *tsdPtr =
2001 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
20022002 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
20032003
20042004 if (winPtr->window == None) {
20362036 * Pick the decorative frame style. Override redirect windows get
20372037 * created as undecorated popups if they have no transient parent,
20382038 * otherwise they are children. This allows splash screens to operate
2039 * as an independent window, while having dropdows (like for a
2039 * as an independent window, while having dropdowns (like for a
20402040 * combobox) not grab focus away from their parent. Transient windows
20412041 * get a modal dialog frame. Neither override, nor transient windows
20422042 * appear in the Windows taskbar. Note that a transient window does
20532053 */
20542054
20552055 parentHWND = GetDesktopWindow();
2056 if (wmPtr->masterPtr) {
2056 if (wmPtr->containerPtr) {
20572057 wmPtr->style |= WS_CHILD;
20582058 } else {
20592059 wmPtr->style |= WS_POPUP;
20612061 } else if (wmPtr->flags & WM_FULLSCREEN) {
20622062 wmPtr->style = WM_FULLSCREEN_STYLE;
20632063 wmPtr->exStyle = EX_FULLSCREEN_STYLE;
2064 } else if (wmPtr->masterPtr) {
2064 } else if (wmPtr->containerPtr) {
20652065 wmPtr->style = WM_TRANSIENT_STYLE;
20662066 wmPtr->exStyle = EX_TRANSIENT_STYLE;
2067 parentHWND = Tk_GetHWND(Tk_WindowId(wmPtr->masterPtr));
2067 parentHWND = Tk_GetHWND(Tk_WindowId(wmPtr->containerPtr));
20682068 if (! ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE)
20692069 && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE))) {
20702070 wmPtr->style |= WS_THICKFRAME;
21202120 */
21212121
21222122 tsdPtr->createWindow = winPtr;
2123 Tcl_WinUtfToTChar(((wmPtr->title != NULL) ?
2123 Tcl_DStringInit(&titleString);
2124 Tcl_UtfToWCharDString(((wmPtr->title != NULL) ?
21242125 wmPtr->title : winPtr->nameUid), -1, &titleString);
21252126
21262127 wmPtr->wrapper = CreateWindowExW(wmPtr->exStyle,
22022203 if (wmPtr->numTransients > 0) {
22032204 /*
22042205 * Unset the current wrapper as the parent for all transient
2205 * children for whom this is the master
2206 * children for whom this is the container
22062207 */
22072208
22082209 WmInfo *wmPtr2;
22092210
2210 childStateInfo = ckalloc(wmPtr->numTransients * sizeof(int));
2211 childStateInfo = (int *)ckalloc(wmPtr->numTransients * sizeof(int));
22112212 state = 0;
22122213 for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
22132214 wmPtr2 = wmPtr2->nextPtr) {
2214 if (wmPtr2->masterPtr == winPtr
2215 if (wmPtr2->containerPtr == winPtr
22152216 && !(wmPtr2->flags & WM_NEVER_MAPPED)) {
22162217 childStateInfo[state++] = wmPtr2->hints.initial_state;
22172218 SetParent(TkWinGetHWND(wmPtr2->winPtr->window), NULL);
22902291 if (childStateInfo) {
22912292 if (wmPtr->numTransients > 0) {
22922293 /*
2293 * Reset all transient children for whom this is the master.
2294 * Reset all transient children for whom this is the container.
22942295 */
22952296
22962297 WmInfo *wmPtr2;
22982299 state = 0;
22992300 for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
23002301 wmPtr2 = wmPtr2->nextPtr) {
2301 if (wmPtr2->masterPtr == winPtr
2302 if (wmPtr2->containerPtr == winPtr
23022303 && !(wmPtr2->flags & WM_NEVER_MAPPED)) {
23032304 UpdateWrapper(wmPtr2->winPtr);
23042305 TkpWmSetState(wmPtr2->winPtr, childStateInfo[state++]);
23532354 TkWindow *winPtr) /* Top-level window that's about to be
23542355 * mapped. */
23552356 {
2356 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2357 ThreadSpecificData *tsdPtr =
2357 WmInfo *wmPtr = winPtr->wmInfoPtr;
2358 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
23582359 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
23592360
23602361 if (!tsdPtr->initialized) {
23632364
23642365 if (wmPtr->flags & WM_NEVER_MAPPED) {
23652366 /*
2366 * Don't map a transient if the master is not mapped.
2367 * Don't map a transient if the container is not mapped.
23672368 */
23682369
2369 if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) {
2370 if (wmPtr->containerPtr != NULL && !Tk_IsMapped(wmPtr->containerPtr)) {
23702371 wmPtr->hints.initial_state = WithdrawnState;
23712372 return;
23722373 }
25792580 TkWmDeadWindow(
25802581 TkWindow *winPtr) /* Top-level window that's being deleted. */
25812582 {
2582 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2583 WmInfo *wmPtr = winPtr->wmInfoPtr;
25832584 WmInfo *wmPtr2;
25842585
25852586 if (wmPtr == NULL) {
25932594 if (winPtr->dispPtr->firstWmPtr == wmPtr) {
25942595 winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr;
25952596 } else {
2596 register WmInfo *prevPtr;
2597 WmInfo *prevPtr;
25972598
25982599 for (prevPtr = winPtr->dispPtr->firstWmPtr; ;
25992600 prevPtr = prevPtr->nextPtr) {
26082609 }
26092610
26102611 /*
2611 * Reset all transient windows whose master is the dead window.
2612 * Reset all transient windows whose container is the dead window.
26122613 */
26132614
26142615 for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
26152616 wmPtr2 = wmPtr2->nextPtr) {
2616 if (wmPtr2->masterPtr == winPtr) {
2617 if (wmPtr2->containerPtr == winPtr) {
26172618 wmPtr->numTransients--;
2618 Tk_DeleteEventHandler((Tk_Window) wmPtr2->masterPtr,
2619 Tk_DeleteEventHandler((Tk_Window) wmPtr2->containerPtr,
26192620 VisibilityChangeMask|StructureNotifyMask,
26202621 WmWaitVisibilityOrMapProc, wmPtr2->winPtr);
2621 wmPtr2->masterPtr = NULL;
2622 wmPtr2->containerPtr = NULL;
26222623 if ((wmPtr2->wrapper != NULL)
26232624 && !(wmPtr2->flags & (WM_NEVER_MAPPED))) {
26242625 UpdateWrapper(wmPtr2->winPtr);
26682669 if (wmPtr->flags & WM_UPDATE_PENDING) {
26692670 Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
26702671 }
2671 if (wmPtr->masterPtr != NULL) {
2672 wmPtr2 = wmPtr->masterPtr->wmInfoPtr;
2672 if (wmPtr->containerPtr != NULL) {
2673 wmPtr2 = wmPtr->containerPtr->wmInfoPtr;
26732674
26742675 /*
2675 * If we had a master, tell them that we aren't tied to them anymore.
2676 * If we had a container, tell them that we aren't tied to them anymore.
26762677 */
26772678
26782679 if (wmPtr2 != NULL) {
26792680 wmPtr2->numTransients--;
26802681 }
2681 Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
2682 Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr,
26822683 VisibilityChangeMask|StructureNotifyMask,
26832684 WmWaitVisibilityOrMapProc, winPtr);
2684 wmPtr->masterPtr = NULL;
2685 wmPtr->containerPtr = NULL;
26852686 }
26862687 if (wmPtr->crefObj != NULL) {
26872688 Tcl_DecrRefCount(wmPtr->crefObj);
27402741 TkWmSetClass(
27412742 TkWindow *winPtr) /* Newly-created top-level window. */
27422743 {
2744 (void)winPtr;
2745
27432746 /* Do nothing */
27442747 return;
27452748 }
27612764 *----------------------------------------------------------------------
27622765 */
27632766
2764 /* ARGSUSED */
27652767 int
27662768 Tk_WmObjCmd(
27672769 ClientData clientData, /* Main window associated with interpreter. */
27692771 int objc, /* Number of arguments. */
27702772 Tcl_Obj *const objv[]) /* Argument objects. */
27712773 {
2772 Tk_Window tkwin = clientData;
2774 Tk_Window tkwin = (Tk_Window)clientData;
27732775 static const char *const optionStrings[] = {
27742776 "aspect", "attributes", "client", "colormapwindows",
27752777 "command", "deiconify", "focusmodel", "forget", "frame",
27952797 WMOPT_WITHDRAW
27962798 };
27972799 int index;
2798 size_t length;
2800 int length;
27992801 const char *argv1;
28002802 TkWindow *winPtr, **winPtrPtr = &winPtr;
28012803 TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
28062808 return TCL_ERROR;
28072809 }
28082810
2809 argv1 = Tcl_GetString(objv[1]);
2810 length = objv[1]->length;
2811 argv1 = Tcl_GetStringFromObj(objv[1], &length);
28112812 if ((argv1[0] == 't') && !strncmp(argv1, "tracing", length)
28122813 && (length >= 3)) {
28132814 int wmTracing;
29502951 int objc, /* Number of arguments. */
29512952 Tcl_Obj *const objv[]) /* Argument objects. */
29522953 {
2953 register WmInfo *wmPtr = winPtr->wmInfoPtr;
2954 WmInfo *wmPtr = winPtr->wmInfoPtr;
29542955 int numer1, denom1, numer2, denom2;
2956 (void)tkwin;
29552957
29562958 if ((objc != 3) && (objc != 7)) {
29572959 Tcl_WrongNumArgs(interp, 2, objv,
30203022 int objc, /* Number of arguments. */
30213023 Tcl_Obj *const objv[]) /* Argument objects. */
30223024 {
3023 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3025 WmInfo *wmPtr = winPtr->wmInfoPtr;
30243026 LONG style, exStyle, styleBit, *stylePtr = NULL;
30253027 const char *string;
30263028 int i, boolean;
3027 size_t length;
3029 int length;
30283030 int config_fullscreen = 0, updatewrapper = 0;
30293031 int fullscreen_attr_changed = 0, fullscreen_attr = 0;
30303032
30713073 return TCL_OK;
30723074 }
30733075 for (i = 3; i < objc; i += 2) {
3074 string = Tcl_GetString(objv[i]);
3075 length = objv[i]->length;
3076 string = Tcl_GetStringFromObj(objv[i], &length);
30763077 if ((length < 2) || (string[0] != '-')) {
30773078 goto configArgs;
30783079 }
31403141 }
31413142 wmPtr->alpha = dval;
31423143 } else { /* -transparentcolor */
3143 const char *crefstr = Tcl_GetString(objv[i+1]);
3144
3145 length = objv[i+1]->length;
3144 const char *crefstr = Tcl_GetStringFromObj(objv[i+1], &length);
3145
31463146 if (length == 0) {
31473147 /* reset to no transparent color */
31483148 if (wmPtr->crefObj) {
33183318 int objc, /* Number of arguments. */
33193319 Tcl_Obj *const objv[]) /* Argument objects. */
33203320 {
3321 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3321 WmInfo *wmPtr = winPtr->wmInfoPtr;
33223322 const char *argv3;
3323 size_t length;
3323 int length;
3324 (void)tkwin;
33243325
33253326 if ((objc != 3) && (objc != 4)) {
33263327 Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
33333334 }
33343335 return TCL_OK;
33353336 }
3336 argv3 = Tcl_GetString(objv[3]);
3337 length = objv[3]->length;
3337 argv3 = Tcl_GetStringFromObj(objv[3], &length);
33383338 if (argv3[0] == 0) {
33393339 if (wmPtr->clientMachine != NULL) {
33403340 ckfree(wmPtr->clientMachine);
33493349 if (wmPtr->clientMachine != NULL) {
33503350 ckfree(wmPtr->clientMachine);
33513351 }
3352 wmPtr->clientMachine = ckalloc(length + 1);
3352 wmPtr->clientMachine = (char *)ckalloc(length + 1);
33533353 memcpy(wmPtr->clientMachine, argv3, length + 1);
33543354 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
33553355 XTextProperty textProp;
33893389 int objc, /* Number of arguments. */
33903390 Tcl_Obj *const objv[]) /* Argument objects. */
33913391 {
3392 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3392 WmInfo *wmPtr = winPtr->wmInfoPtr;
33933393 TkWindow **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2;
33943394 int i, windowObjc, gotToplevel;
33953395 Tcl_Obj **windowObjv, *resultObj;
34163416 != TCL_OK) {
34173417 return TCL_ERROR;
34183418 }
3419 cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*));
3419 cmapList = (TkWindow**)ckalloc((windowObjc + 1) * sizeof(TkWindow*));
34203420 gotToplevel = 0;
34213421 for (i = 0; i < windowObjc; i++) {
34223422 if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
34833483 int objc, /* Number of arguments. */
34843484 Tcl_Obj *const objv[]) /* Argument objects. */
34853485 {
3486 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3486 WmInfo *wmPtr = winPtr->wmInfoPtr;
34873487 const char *argv3;
34883488 int cmdArgc;
34893489 const char **cmdArgv;
3490 (void)tkwin;
34903491
34913492 if ((objc != 3) && (objc != 4)) {
34923493 Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
35523553 int objc, /* Number of arguments. */
35533554 Tcl_Obj *const objv[]) /* Argument objects. */
35543555 {
3555 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3556 WmInfo *wmPtr = winPtr->wmInfoPtr;
3557 (void)tkwin;
35563558
35573559 if (objc != 3) {
35583560 Tcl_WrongNumArgs(interp, 2, objv, "window");
36043606 int objc, /* Number of arguments. */
36053607 Tcl_Obj *const objv[]) /* Argument objects. */
36063608 {
3607 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3609 WmInfo *wmPtr = winPtr->wmInfoPtr;
36083610 static const char *const optionStrings[] = {
36093611 "active", "passive", NULL
36103612 };
36123614 OPT_ACTIVE, OPT_PASSIVE
36133615 };
36143616 int index;
3617 (void)tkwin;
36153618
36163619 if ((objc != 3) && (objc != 4)) {
36173620 Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
36563659 WmForgetCmd(
36573660 Tk_Window tkwin, /* Main window of the application. */
36583661 TkWindow *winPtr, /* Toplevel or Frame to work with */
3659 Tcl_Interp *interp, /* Current interpreter. */
3662 Tcl_Interp *dummy, /* Current interpreter. */
36603663 int objc, /* Number of arguments. */
36613664 Tcl_Obj *const objv[]) /* Argument objects. */
36623665 {
3663 register Tk_Window frameWin = (Tk_Window) winPtr;
3666 Tk_Window frameWin = (Tk_Window) winPtr;
3667 (void)tkwin;
3668 (void)dummy;
3669 (void)objc;
3670 (void)objv;
36643671
36653672 if (Tk_IsTopLevel(frameWin)) {
36663673 Tk_UnmapWindow(frameWin);
37083715 int objc, /* Number of arguments. */
37093716 Tcl_Obj *const objv[]) /* Argument objects. */
37103717 {
3711 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3718 WmInfo *wmPtr = winPtr->wmInfoPtr;
37123719 HWND hwnd;
37133720 char buf[TCL_INTEGER_SPACE];
3721 (void)tkwin;
37143722
37153723 if (objc != 3) {
37163724 Tcl_WrongNumArgs(interp, 2, objv, "window");
37533761 int objc, /* Number of arguments. */
37543762 Tcl_Obj *const objv[]) /* Argument objects. */
37553763 {
3756 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3764 WmInfo *wmPtr = winPtr->wmInfoPtr;
37573765 char xSign, ySign;
37583766 int width, height;
37593767 const char *argv3;
3768 (void)tkwin;
37603769
37613770 if ((objc != 3) && (objc != 4)) {
37623771 Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
38213830 int objc, /* Number of arguments. */
38223831 Tcl_Obj *const objv[]) /* Argument objects. */
38233832 {
3824 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3833 WmInfo *wmPtr = winPtr->wmInfoPtr;
38253834 int reqWidth, reqHeight, widthInc, heightInc;
3835 (void)tkwin;
38263836
38273837 if ((objc != 3) && (objc != 7)) {
38283838 Tcl_WrongNumArgs(interp, 2, objv,
39193929 int objc, /* Number of arguments. */
39203930 Tcl_Obj *const objv[]) /* Argument objects. */
39213931 {
3922 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3932 WmInfo *wmPtr = winPtr->wmInfoPtr;
39233933 Tk_Window tkwin2;
39243934 const char *argv3;
3925 size_t length;
3935 int length;
39263936
39273937 if ((objc != 3) && (objc != 4)) {
39283938 Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
39343944 }
39353945 return TCL_OK;
39363946 }
3937 argv3 = Tcl_GetString(objv[3]);
3938 length = objv[3]->length;
3947 argv3 = Tcl_GetStringFromObj(objv[3], &length);
39393948 if (*argv3 == '\0') {
39403949 wmPtr->hints.flags &= ~WindowGroupHint;
39413950 if (wmPtr->leaderName != NULL) {
39523961 }
39533962 wmPtr->hints.window_group = Tk_WindowId(tkwin2);
39543963 wmPtr->hints.flags |= WindowGroupHint;
3955 wmPtr->leaderName = ckalloc(length + 1);
3964 wmPtr->leaderName = (char *)ckalloc(length + 1);
39563965 memcpy(wmPtr->leaderName, argv3, length + 1);
39573966 }
39583967 return TCL_OK;
39833992 int objc, /* Number of arguments. */
39843993 Tcl_Obj *const objv[]) /* Argument objects. */
39853994 {
3986 register WmInfo *wmPtr = winPtr->wmInfoPtr;
3995 WmInfo *wmPtr = winPtr->wmInfoPtr;
39873996 TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
39883997 const char *string;
3998 (void)tkwin;
39893999
39904000 if ((objc < 3) || (objc > 5)) {
39914001 Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
41194129 int objc, /* Number of arguments. */
41204130 Tcl_Obj *const objv[]) /* Argument objects. */
41214131 {
4122 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4132 WmInfo *wmPtr = winPtr->wmInfoPtr;
4133 (void)tkwin;
4134
41234135 if (objc != 3) {
41244136 Tcl_WrongNumArgs(interp, 2, objv, "window");
41254137 return TCL_ERROR;
41414153 NULL);
41424154 return TCL_ERROR;
41434155 }
4144 if (wmPtr->masterPtr != NULL) {
4156 if (wmPtr->containerPtr != NULL) {
41454157 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
41464158 "can't iconify \"%s\": it is a transient",
41474159 winPtr->pathName));
41844196 int objc, /* Number of arguments. */
41854197 Tcl_Obj *const objv[]) /* Argument objects. */
41864198 {
4187 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4199 WmInfo *wmPtr = winPtr->wmInfoPtr;
41884200 Pixmap pixmap;
41894201 const char *argv3;
41904202
42424254 int objc, /* Number of arguments. */
42434255 Tcl_Obj *const objv[]) /* Argument objects. */
42444256 {
4245 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4257 WmInfo *wmPtr = winPtr->wmInfoPtr;
42464258 const char *argv3;
4247 size_t length;
4259 int length;
4260 (void)tkwin;
42484261
42494262 if (objc > 4) {
42504263 Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
42584271 if (wmPtr->iconName != NULL) {
42594272 ckfree(wmPtr->iconName);
42604273 }
4261 argv3 = Tcl_GetString(objv[3]);
4262 length = objv[3]->length;
4263 wmPtr->iconName = ckalloc(length + 1);
4274 argv3 = Tcl_GetStringFromObj(objv[3], &length);
4275 wmPtr->iconName = (char *)ckalloc(length + 1);
42644276 memcpy(wmPtr->iconName, argv3, length + 1);
42654277 if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
42664278 XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
43064318 unsigned size;
43074319 BITMAPINFO bmInfo;
43084320 ICONINFO iconInfo;
4321 (void)tkwin;
43094322
43104323 if (objc < 4) {
43114324 Tcl_WrongNumArgs(interp, 2, objv,
43434356 */
43444357
43454358 size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1));
4346 lpIR = attemptckalloc(size);
4359 lpIR = (BlockOfIconImagesPtr)attemptckalloc(size);
43474360 if (lpIR == NULL) {
43484361 return TCL_ERROR;
43494362 }
44484461 lpIR->IconImages[i-startObj].hIcon = hIcon;
44494462 }
44504463
4451 titlebaricon = ckalloc(sizeof(WinIconInstance));
4464 titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
44524465 titlebaricon->iconBlock = lpIR;
44534466 titlebaricon->refCount = 1;
44544467 if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) {
44874500 int objc, /* Number of arguments. */
44884501 Tcl_Obj *const objv[]) /* Argument objects. */
44894502 {
4490 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4503 WmInfo *wmPtr = winPtr->wmInfoPtr;
44914504 int x, y;
4505 (void)tkwin;
44924506
44934507 if ((objc != 3) && (objc != 5)) {
44944508 Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
45434557 int objc, /* Number of arguments. */
45444558 Tcl_Obj *const objv[]) /* Argument objects. */
45454559 {
4546 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4560 WmInfo *wmPtr = winPtr->wmInfoPtr;
45474561 Tk_Window tkwin2;
45484562 WmInfo *wmPtr2;
45494563 XSetWindowAttributes atts;
46534667 int objc, /* Number of arguments. */
46544668 Tcl_Obj *const objv[]) /* Argument objects. */
46554669 {
4656 register Tk_Window frameWin = (Tk_Window) winPtr;
4657 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4670 Tk_Window frameWin = (Tk_Window) winPtr;
4671 WmInfo *wmPtr = winPtr->wmInfoPtr;
4672 (void)tkwin;
4673 (void)objc;
4674 (void)objv;
46584675
46594676 if (!Tk_IsTopLevel(frameWin)) {
46604677 if (!Tk_IsManageable(frameWin)) {
47074724 int objc, /* Number of arguments. */
47084725 Tcl_Obj *const objv[]) /* Argument objects. */
47094726 {
4710 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4727 WmInfo *wmPtr = winPtr->wmInfoPtr;
47114728 int width, height;
4729 (void)tkwin;
47124730
47134731 if ((objc != 3) && (objc != 5)) {
47144732 Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
47584776 int objc, /* Number of arguments. */
47594777 Tcl_Obj *const objv[]) /* Argument objects. */
47604778 {
4761 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4779 WmInfo *wmPtr = winPtr->wmInfoPtr;
47624780 int width, height;
4781 (void)tkwin;
47634782
47644783 if ((objc != 3) && (objc != 5)) {
47654784 Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
48094828 int objc, /* Number of arguments. */
48104829 Tcl_Obj *const objv[]) /* Argument objects. */
48114830 {
4812 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4831 WmInfo *wmPtr = winPtr->wmInfoPtr;
48134832 int boolean, curValue;
48144833 XSetWindowAttributes atts;
4834 (void)tkwin;
48154835
48164836 if ((objc != 3) && (objc != 4)) {
48174837 Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
48814901 int objc, /* Number of arguments. */
48824902 Tcl_Obj *const objv[]) /* Argument objects. */
48834903 {
4884 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4904 WmInfo *wmPtr = winPtr->wmInfoPtr;
48854905 static const char *const optionStrings[] = {
48864906 "program", "user", NULL
48874907 };
48894909 OPT_PROGRAM, OPT_USER
48904910 };
48914911 int index;
4912 (void)tkwin;
48924913
48934914 if ((objc != 3) && (objc != 4)) {
48944915 Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
49494970 int objc, /* Number of arguments. */
49504971 Tcl_Obj *const objv[]) /* Argument objects. */
49514972 {
4952 register WmInfo *wmPtr = winPtr->wmInfoPtr;
4953 register ProtocolHandler *protPtr, *prevPtr;
4973 WmInfo *wmPtr = winPtr->wmInfoPtr;
4974 ProtocolHandler *protPtr, *prevPtr;
49544975 Atom protocol;
49554976 const char *cmd;
4956 size_t cmdLength;
4977 int cmdLength;
49574978 Tcl_Obj *resultObj;
4979 (void)tkwin;
49584980
49594981 if ((objc < 3) || (objc > 5)) {
49604982 Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
50085030 break;
50095031 }
50105032 }
5011 cmd = Tcl_GetString(objv[4]);
5012 cmdLength = objv[4]->length;
5033 cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
50135034 if (cmdLength > 0) {
5014 protPtr = ckalloc(HANDLER_SIZE(cmdLength));
5035 protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
50155036 protPtr->protocol = protocol;
50165037 protPtr->nextPtr = wmPtr->protPtr;
50175038 wmPtr->protPtr = protPtr;
50465067 int objc, /* Number of arguments. */
50475068 Tcl_Obj *const objv[]) /* Argument objects. */
50485069 {
5049 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5070 WmInfo *wmPtr = winPtr->wmInfoPtr;
50505071 int width, height;
5072 (void)tkwin;
50515073
50525074 if ((objc != 3) && (objc != 5)) {
50535075 Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
51085130 int objc, /* Number of arguments. */
51095131 Tcl_Obj *const objv[]) /* Argument objects. */
51105132 {
5111 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5133 WmInfo *wmPtr = winPtr->wmInfoPtr;
51125134 static const char *const optionStrings[] = {
51135135 "program", "user", NULL
51145136 };
51165138 OPT_PROGRAM, OPT_USER
51175139 };
51185140 int index;
5141 (void)tkwin;
51195142
51205143 if ((objc != 3) && (objc != 4)) {
51215144 Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
53055328 int objc, /* Number of arguments. */
53065329 Tcl_Obj *const objv[]) /* Argument objects. */
53075330 {
5308 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5331 WmInfo *wmPtr = winPtr->wmInfoPtr;
53095332 static const char *const optionStrings[] = {
53105333 "normal", "iconic", "withdrawn", "zoomed", NULL
53115334 };
53135336 OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED
53145337 };
53155338 int index;
5339 (void)tkwin;
53165340
53175341 if ((objc < 3) || (objc > 4)) {
53185342 Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
53785402 "OVERRIDE_REDIRECT", NULL);
53795403 return TCL_ERROR;
53805404 }
5381 if (wmPtr->masterPtr != NULL) {
5405 if (wmPtr->containerPtr != NULL) {
53825406 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
53835407 "can't iconify \"%s\": it is a transient",
53845408 winPtr->pathName));
54455469 int objc, /* Number of arguments. */
54465470 Tcl_Obj *const objv[]) /* Argument objects. */
54475471 {
5448 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5472 WmInfo *wmPtr = winPtr->wmInfoPtr;
54495473 const char *argv3;
5450 size_t length;
5474 int length;
54515475 HWND wrapper;
5476 (void)tkwin;
54525477
54535478 if (objc > 4) {
54545479 Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
54675492 int size = 256;
54685493
54695494 GetWindowTextW(wrapper, buf, size);
5470 Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &titleString);
5495 Tcl_DStringInit(&titleString);
5496 Tcl_WCharToUtfDString(buf, wcslen(buf), &titleString);
54715497 Tcl_SetObjResult(interp, Tcl_NewStringObj(
54725498 Tcl_DStringValue(&titleString),
54735499 Tcl_DStringLength(&titleString)));
54805506 if (wmPtr->title != NULL) {
54815507 ckfree(wmPtr->title);
54825508 }
5483 argv3 = Tcl_GetString(objv[3]);
5484 length = objv[3]->length;
5485 wmPtr->title = ckalloc(length + 1);
5509 argv3 = Tcl_GetStringFromObj(objv[3], &length);
5510 wmPtr->title = (char *)ckalloc(length + 1);
54865511 memcpy(wmPtr->title, argv3, length + 1);
54875512
54885513 if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) {
54895514 Tcl_DString titleString;
54905515
5491 Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString);
5516 Tcl_DStringInit(&titleString);
5517 Tcl_UtfToWCharDString(wmPtr->title, -1, &titleString);
54925518 SetWindowTextW(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString));
54935519 Tcl_DStringFree(&titleString);
54945520 }
55215547 int objc, /* Number of arguments. */
55225548 Tcl_Obj *const objv[]) /* Argument objects. */
55235549 {
5524 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5525 TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr, *w;
5550 WmInfo *wmPtr = winPtr->wmInfoPtr;
5551 TkWindow *containerPtr = wmPtr->containerPtr, **containerPtrPtr = &containerPtr, *w;
55265552 WmInfo *wmPtr2;
55275553
55285554 if ((objc != 3) && (objc != 4)) {
55305556 return TCL_ERROR;
55315557 }
55325558 if (objc == 3) {
5533 if (masterPtr != NULL) {
5534 Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) masterPtr));
5559 if (containerPtr != NULL) {
5560 Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) containerPtr));
55355561 }
55365562 return TCL_OK;
55375563 }
55385564 if (Tcl_GetString(objv[3])[0] == '\0') {
5539 if (masterPtr != NULL) {
5565 if (containerPtr != NULL) {
55405566 /*
5541 * If we had a master, tell them that we aren't tied to them
5567 * If we had a container, tell them that we aren't tied to them
55425568 * anymore.
55435569 */
55445570
5545 masterPtr->wmInfoPtr->numTransients--;
5546 Tk_DeleteEventHandler((Tk_Window) masterPtr,
5571 containerPtr->wmInfoPtr->numTransients--;
5572 Tk_DeleteEventHandler((Tk_Window) containerPtr,
55475573 VisibilityChangeMask|StructureNotifyMask,
55485574 WmWaitVisibilityOrMapProc, winPtr);
55495575 }
55505576
5551 wmPtr->masterPtr = NULL;
5577 wmPtr->containerPtr = NULL;
55525578 } else {
55535579 if (TkGetWindowFromObj(interp, tkwin, objv[3],
5554 (Tk_Window *) masterPtrPtr) != TCL_OK) {
5580 (Tk_Window *) containerPtrPtr) != TCL_OK) {
55555581 return TCL_ERROR;
55565582 }
5557 while (!Tk_TopWinHierarchy(masterPtr)) {
5583 while (!Tk_TopWinHierarchy(containerPtr)) {
55585584 /*
5559 * Ensure that the master window is actually a Tk toplevel.
5585 * Ensure that the container window is actually a Tk toplevel.
55605586 */
55615587
5562 masterPtr = masterPtr->parentPtr;
5563 }
5564 Tk_MakeWindowExist((Tk_Window) masterPtr);
5588 containerPtr = containerPtr->parentPtr;
5589 }
5590 Tk_MakeWindowExist((Tk_Window) containerPtr);
55655591
55665592 if (wmPtr->iconFor != NULL) {
55675593 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
55715597 return TCL_ERROR;
55725598 }
55735599
5574 wmPtr2 = masterPtr->wmInfoPtr;
5600 wmPtr2 = containerPtr->wmInfoPtr;
55755601
55765602 if (wmPtr2->iconFor != NULL) {
55775603 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
55805606 Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
55815607 return TCL_ERROR;
55825608 }
5583 for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL;
5584 w = (TkWindow *)w->wmInfoPtr->masterPtr) {
5609 for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
5610 w = (TkWindow *)w->wmInfoPtr->containerPtr) {
55855611 if (w == winPtr) {
55865612 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
55875613 "setting \"%s\" as master creates a transient/master cycle",
5588 Tk_PathName(masterPtr)));
5614 Tk_PathName(containerPtr)));
55895615 Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
55905616 return TCL_ERROR;
55915617 }
55925618 }
5593 if (masterPtr != wmPtr->masterPtr) {
5619 if (containerPtr != wmPtr->containerPtr) {
55945620 /*
5595 * Remove old master map/unmap binding before setting the new
5596 * master. The event handler will ensure that transient states
5597 * reflect the state of the master.
5621 * Remove old container map/unmap binding before setting the new
5622 * container. The event handler will ensure that transient states
5623 * reflect the state of the container.
55985624 */
55995625
5600 if (wmPtr->masterPtr != NULL) {
5601 wmPtr->masterPtr->wmInfoPtr->numTransients--;
5602 Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
5626 if (wmPtr->containerPtr != NULL) {
5627 wmPtr->containerPtr->wmInfoPtr->numTransients--;
5628 Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr,
56035629 VisibilityChangeMask|StructureNotifyMask,
56045630 WmWaitVisibilityOrMapProc, winPtr);
56055631 }
56065632
5607 masterPtr->wmInfoPtr->numTransients++;
5608 Tk_CreateEventHandler((Tk_Window) masterPtr,
5633 containerPtr->wmInfoPtr->numTransients++;
5634 Tk_CreateEventHandler((Tk_Window) containerPtr,
56095635 VisibilityChangeMask|StructureNotifyMask,
56105636 WmWaitVisibilityOrMapProc, winPtr);
56115637
5612 wmPtr->masterPtr = masterPtr;
5638 wmPtr->containerPtr = containerPtr;
56135639 }
56145640 }
56155641 if (!((wmPtr->flags & WM_NEVER_MAPPED)
56165642 && !(winPtr->flags & TK_EMBEDDED))) {
5617 if (wmPtr->masterPtr != NULL
5618 && !Tk_IsMapped(wmPtr->masterPtr)) {
5643 if (wmPtr->containerPtr != NULL
5644 && !Tk_IsMapped(wmPtr->containerPtr)) {
56195645 TkpWmSetState(winPtr, WithdrawnState);
56205646 } else {
56215647 UpdateWrapper(winPtr);
56495675 int objc, /* Number of arguments. */
56505676 Tcl_Obj *const objv[]) /* Argument objects. */
56515677 {
5652 register WmInfo *wmPtr = winPtr->wmInfoPtr;
5678 WmInfo *wmPtr = winPtr->wmInfoPtr;
5679 (void)tkwin;
56535680
56545681 if (objc != 3) {
56555682 Tcl_WrongNumArgs(interp, 2, objv, "window");
56945721 }
56955722 }
56965723
5697 /*ARGSUSED*/
56985724 static void
56995725 WmWaitVisibilityOrMapProc(
57005726 ClientData clientData, /* Pointer to window. */
57015727 XEvent *eventPtr) /* Information about event. */
57025728 {
5703 TkWindow *winPtr = clientData;
5704 TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
5705
5706 if (masterPtr == NULL)
5729 TkWindow *winPtr = (TkWindow *)clientData;
5730 TkWindow *containerPtr = winPtr->wmInfoPtr->containerPtr;
5731
5732 if (containerPtr == NULL)
57075733 return;
57085734
57095735 if (eventPtr->type == MapNotify) {
57155741 }
57165742
57175743 if (eventPtr->type == VisibilityNotify) {
5718 int state = masterPtr->wmInfoPtr->hints.initial_state;
5744 int state = containerPtr->wmInfoPtr->hints.initial_state;
57195745
57205746 if ((state == NormalState) || (state == ZoomState)) {
57215747 state = winPtr->wmInfoPtr->hints.initial_state;
57615787 * of one grid unit. */
57625788 {
57635789 TkWindow *winPtr = (TkWindow *) tkwin;
5764 register WmInfo *wmPtr;
5790 WmInfo *wmPtr;
57655791
57665792 /*
57675793 * Ensure widthInc and heightInc are greater than 0
58585884 * controlling gridding. */
58595885 {
58605886 TkWindow *winPtr = (TkWindow *) tkwin;
5861 register WmInfo *wmPtr;
5887 WmInfo *wmPtr;
58625888
58635889 /*
58645890 * Find the top-level window for tkwin, plus the window manager
59175943 ClientData clientData, /* Window for which event occurred. */
59185944 XEvent *eventPtr) /* Event that just happened. */
59195945 {
5920 register TkWindow *winPtr = clientData;
5946 TkWindow *winPtr = (TkWindow *)clientData;
59215947
59225948 if (eventPtr->type == DestroyNotify) {
59235949 Tk_ErrorHandler handler;
59575983 *----------------------------------------------------------------------
59585984 */
59595985
5960 /* ARGSUSED */
59615986 static void
59625987 TopLevelReqProc(
59635988 ClientData dummy, /* Not used. */
59655990 {
59665991 TkWindow *winPtr = (TkWindow *) tkwin;
59675992 WmInfo *wmPtr;
5993 (void)dummy;
59685994
59695995 wmPtr = winPtr->wmInfoPtr;
59705996 if (wmPtr) {
60086034 int width, height; /* Size of client area. */
60096035 int min, max;
60106036 RECT rect;
6011 register TkWindow *winPtr = clientData;
6012 register WmInfo *wmPtr = winPtr->wmInfoPtr;
6037 TkWindow *winPtr = (TkWindow *)clientData;
6038 WmInfo *wmPtr = winPtr->wmInfoPtr;
60136039
60146040 wmPtr->flags &= ~WM_UPDATE_PENDING;
60156041
62896315 TkWindow *winPtr) /* Pointer to top-level window whose geometry
62906316 * is to be changed. */
62916317 {
6292 register WmInfo *wmPtr = winPtr->wmInfoPtr;
6318 WmInfo *wmPtr = winPtr->wmInfoPtr;
62936319 int x, y, width, height, flags;
62946320 char *end;
6295 register const char *p = string;
6321 const char *p = string;
62966322
62976323 /*
62986324 * The leading "=" is optional.
64216447 int *xPtr, /* Where to store x-displacement of (0,0). */
64226448 int *yPtr) /* Where to store y-displacement of (0,0). */
64236449 {
6424 register TkWindow *winPtr = (TkWindow *) tkwin;
6450 TkWindow *winPtr = (TkWindow *) tkwin;
64256451
64266452 /*
64276453 * If the window is mapped, let Windows figure out the translation.
65186544 int *widthPtr, int *heightPtr)
65196545 /* Store dimensions of virtual root here. */
65206546 {
6547 (void)tkwin;
6548
65216549 *xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN);
65226550 *yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN);
65236551 *widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN);
65506578 int x, int y) /* New location for window (within parent). */
65516579 {
65526580 TkWindow *winPtr = (TkWindow *) tkwin;
6553 register WmInfo *wmPtr = winPtr->wmInfoPtr;
6581 WmInfo *wmPtr = winPtr->wmInfoPtr;
65546582
65556583 if (!(winPtr->flags & TK_TOP_LEVEL)) {
65566584 Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window");
66016629 XEvent *eventPtr) /* X event. */
66026630 {
66036631 WmInfo *wmPtr;
6604 register ProtocolHandler *protPtr;
6632 ProtocolHandler *protPtr;
66056633 Atom protocol;
66066634 int result;
66076635 Tcl_Interp *interp;
66796707
66806708 hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd);
66816709 if (hPtr != NULL) {
6682 childWinPtr = Tcl_GetHashValue(hPtr);
6710 childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
66836711
66846712 /*
66856713 * Double check that same HWND does not get passed twice.
67796807 Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
67806808 TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
67816809
6782 windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
6810 windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *));
67836811
67846812 /*
67856813 * Special cases: If zero or one toplevels were mapped there is no need to
67926820 goto done;
67936821 case 1:
67946822 hPtr = Tcl_FirstHashEntry(&table, &search);
6795 windows[0] = Tcl_GetHashValue(hPtr);
6823 windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr);
67966824 windows[1] = NULL;
67976825 goto done;
67986826 }
69556983 * Automatically add the toplevel itself as the last element of the list.
69566984 */
69576985
6958 newPtr = ckalloc((count+2) * sizeof(TkWindow *));
6986 newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *));
69596987 if (count > 0) {
69606988 memcpy(newPtr, oldPtr, count * sizeof(TkWindow*));
69616989 }
82518279 static void
82528280 GenerateActivateEvent(TkWindow * winPtr, const int *flagPtr)
82538281 {
8254 ActivateEvent *eventPtr = ckalloc(sizeof(ActivateEvent));
8282 ActivateEvent *eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
82558283
82568284 eventPtr->ev.proc = ActivateWindow;
82578285 eventPtr->winPtr = winPtr;
83548382 TkWinSetForegroundWindow(
83558383 TkWindow *winPtr)
83568384 {
8357 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8385 WmInfo *wmPtr = winPtr->wmInfoPtr;
83588386
83598387 if (wmPtr->wrapper != NULL) {
83608388 SetForegroundWindow(wmPtr->wrapper);
83848412 TkpWinToplevelWithDraw(
83858413 TkWindow *winPtr)
83868414 {
8387 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8415 WmInfo *wmPtr = winPtr->wmInfoPtr;
83888416
83898417 wmPtr->flags |= WM_WITHDRAWN;
83908418 TkpWmSetState(winPtr, WithdrawnState);
84358463 TkpWinToplevelDeiconify(
84368464 TkWindow *winPtr)
84378465 {
8438 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8466 WmInfo *wmPtr = winPtr->wmInfoPtr;
84398467
84408468 wmPtr->flags &= ~WM_WITHDRAWN;
84418469
85038531 TkpWinToplevelIsControlledByWm(
85048532 TkWindow *winPtr)
85058533 {
8506 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8534 WmInfo *wmPtr = winPtr->wmInfoPtr;
85078535
85088536 if (!wmPtr) {
85098537 return 0;
85338561 TkWindow *winPtr,
85348562 int x, int y)
85358563 {
8536 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8564 WmInfo *wmPtr = winPtr->wmInfoPtr;
85378565
85388566 if (wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) {
85398567 Tk_MoveToplevelWindow((Tk_Window) winPtr, x, y);
85658593 int reqValue)
85668594 {
85678595 int curValue;
8568 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8596 WmInfo *wmPtr = winPtr->wmInfoPtr;
85698597
85708598 curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
85718599 if (reqValue < 0) {
86128640 TkpWinToplevelDetachWindow(
86138641 TkWindow *winPtr)
86148642 {
8615 register WmInfo *wmPtr = winPtr->wmInfoPtr;
8643 WmInfo *wmPtr = winPtr->wmInfoPtr;
86168644
86178645 if (winPtr->flags & TK_EMBEDDED) {
86188646 int state = SendMessageW(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
6969 static HINSTANCE tkInstance = NULL; /* Application instance handle. */
7070 static int childClassInitialized; /* Registered child class? */
7171 static WNDCLASSW childClass; /* Window class for child windows. */
72 static int tkPlatformId = 0; /* version of Windows platform */
7372 static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */
7473 static Tcl_Encoding keyInputEncoding = NULL;
7574 /* The current character encoding for
104103 static void GenerateXEvent(HWND hwnd, UINT message,
105104 WPARAM wParam, LPARAM lParam);
106105 static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam);
107 static void GetTranslatedKey(XKeyEvent *xkey, UINT type);
106 static void GetTranslatedKey(TkKeyEvent *xkey, UINT type);
108107 static void UpdateInputLanguage(int charset);
109108 static int HandleIMEComposition(HWND hwnd, LPARAM lParam);
110109
138137
139138 if (!buffer[0]) {
140139 HANDLE handle = GetModuleHandleW(L"NTDLL");
141 int(__stdcall *getversion)(void *) =
142 (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion");
140 int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))
141 (void *)GetProcAddress(handle, "RtlGetVersion");
143142 os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
144143 if (!getversion || getversion(&os)) {
145144 GetVersionExW(&os);
327326 /*
328327 *----------------------------------------------------------------------
329328 *
330 * TkWinGetPlatformId --
331 *
332 * Determines whether running under NT, 95, or Win32s, to allow runtime
333 * conditional code. Win32s is no longer supported.
329 * TkWinGetPlatformTheme --
330 *
331 * Return the Windows drawing style we should be using.
334332 *
335333 * Results:
336334 * The return value is one of:
337 * VER_PLATFORM_WIN32s Win32s on Windows 3.1 (not supported)
338 * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME (not supported)
339 * VER_PLATFORM_WIN32_NT Win32 on Windows XP, Vista, Windows 7, Windows 8
340 * VER_PLATFORM_WIN32_CE Win32 on Windows CE
341 *
342 * Side effects:
343 * None.
335 * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
336 * TK_THEME_WIN_XP XP not in classic mode
337 * TK_THEME_WIN_VISTA Vista or higher
344338 *
345339 *----------------------------------------------------------------------
346340 */
347341
348342 int
349 TkWinGetPlatformId(void)
350 {
351 if (tkPlatformId == 0) {
343 TkWinGetPlatformTheme(void)
344 {
345 if (tkWinTheme == 0) {
352346 OSVERSIONINFOW os;
353347
354348 os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
355349 GetVersionExW(&os);
356 tkPlatformId = os.dwPlatformId;
350
351 if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) {
352 Tcl_Panic("Windows NT is the only supported platform");
353 }
357354
358355 /*
359 * Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC. The
356 * Set tkWinTheme to be TK_THEME_WIN_(CLASSIC|XP|VISTA). The
360357 * TK_THEME_WIN_CLASSIC could be set even when running under XP if the
361358 * windows classic theme was selected.
362359 */
363
364 if ((os.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
365 (os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) {
360 if (os.dwMajorVersion == 5 && os.dwMinorVersion >= 1) {
366361 HKEY hKey;
367362 LPCWSTR szSubKey = L"Control Panel\\Appearance";
368363 LPCWSTR szCurrent = L"Current";
369364 DWORD dwSize = 200;
370 char pBuffer[200];
365 WCHAR pBuffer[200];
371366
372367 memset(pBuffer, 0, dwSize);
373368 if (RegOpenKeyExW(HKEY_CURRENT_USER, szSubKey, 0L,
376371 } else {
377372 RegQueryValueExW(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
378373 RegCloseKey(hKey);
379 if (strcmp(pBuffer, "Windows Standard") == 0) {
374 if (wcscmp(pBuffer, L"Windows Standard") == 0) {
380375 tkWinTheme = TK_THEME_WIN_CLASSIC;
381376 } else {
382377 tkWinTheme = TK_THEME_WIN_XP;
383378 }
384379 }
380 } else if (os.dwMajorVersion > 5) {
381 tkWinTheme = TK_THEME_WIN_VISTA;
385382 } else {
386383 tkWinTheme = TK_THEME_WIN_CLASSIC;
387384 }
388385 }
389 return tkPlatformId;
390 }
391
392 /*
393 *----------------------------------------------------------------------
394 *
395 * TkWinGetPlatformTheme --
396 *
397 * Return the Windows drawing style we should be using.
398 *
399 * Results:
400 * The return value is one of:
401 * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
402 * TK_THEME_WIN_XP XP not in classic mode
403 *
404 * Side effects:
405 * Could invoke TkWinGetPlatformId.
386 return tkWinTheme;
387 }
388
389 /*
390 *----------------------------------------------------------------------
391 *
392 * TkWinGetPlatformId --
393 *
394 * Determines whether running under NT, 95, or Win32s, to allow runtime
395 * conditional code. Win32s is no longer supported.
396 *
397 * Results:
398 * The return value is always:
399 * VER_PLATFORM_WIN32_NT Win32 on Windows XP, Vista, Windows 7, Windows 8
400 *
401 * Side effects:
402 * None.
406403 *
407404 *----------------------------------------------------------------------
408405 */
409406
410407 int
411 TkWinGetPlatformTheme(void)
412 {
413 if (tkPlatformId == 0) {
414 TkWinGetPlatformId();
415 }
416 return tkWinTheme;
417 }
418
408 TkWinGetPlatformId(void)
409 {
410 return VER_PLATFORM_WIN32_NT;
411 }
412
419413 /*
420414 *----------------------------------------------------------------------
421415 *
999993 WPARAM wParam,
1000994 LPARAM lParam)
1001995 {
1002 XEvent event;
996 union {XEvent x; TkKeyEvent key;} event;
1003997 TkWindow *winPtr;
1004998 ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
1005999 Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
10251019 return;
10261020 }
10271021
1028 memset(&event, 0, sizeof(XEvent));
1029 event.xany.serial = winPtr->display->request++;
1030 event.xany.send_event = False;
1031 event.xany.display = winPtr->display;
1032 event.xany.window = winPtr->window;
1022 memset(&event.x, 0, sizeof(XEvent));
1023 event.x.xany.serial = winPtr->display->request++;
1024 event.x.xany.send_event = False;
1025 event.x.xany.display = winPtr->display;
1026 event.x.xany.window = winPtr->window;
10331027
10341028 switch (message) {
10351029 case WM_PAINT: {
10361030 PAINTSTRUCT ps;
10371031
1038 event.type = Expose;
1032 event.x.type = Expose;
10391033 BeginPaint(hwnd, &ps);
1040 event.xexpose.x = ps.rcPaint.left;
1041 event.xexpose.y = ps.rcPaint.top;
1042 event.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
1043 event.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
1034 event.x.xexpose.x = ps.rcPaint.left;
1035 event.x.xexpose.y = ps.rcPaint.top;
1036 event.x.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
1037 event.x.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
10441038 EndPaint(hwnd, &ps);
1045 event.xexpose.count = 0;
1039 event.x.xexpose.count = 0;
10461040 break;
10471041 }
10481042
10491043 case WM_CLOSE:
1050 event.type = ClientMessage;
1051 event.xclient.message_type =
1044 event.x.type = ClientMessage;
1045 event.x.xclient.message_type =
10521046 Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS");
1053 event.xclient.format = 32;
1054 event.xclient.data.l[0] =
1047 event.x.xclient.format = 32;
1048 event.x.xclient.data.l[0] =
10551049 Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW");
10561050 break;
10571051
10871081 return;
10881082 }
10891083
1090 event.xany.window = winPtr->window;
1091 event.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
1092 event.xfocus.mode = NotifyNormal;
1093 event.xfocus.detail = NotifyNonlinear;
1084 event.x.xany.window = winPtr->window;
1085 event.x.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
1086 event.x.xfocus.mode = NotifyNormal;
1087 event.x.xfocus.detail = NotifyNonlinear;
10941088
10951089 /*
10961090 * Destroy the caret if we own it. If we are moving to another Tk
11121106
11131107 return;
11141108 }
1115 event.type = SelectionClear;
1116 event.xselectionclear.selection =
1109 event.x.type = SelectionClear;
1110 event.x.xselectionclear.selection =
11171111 Tk_InternAtom((Tk_Window)winPtr, "CLIPBOARD");
1118 event.xselectionclear.time = TkpGetMS();
1112 event.x.xselectionclear.time = TkpGetMS();
11191113 break;
11201114
11211115 case WM_MOUSEWHEEL:
11441138 * Set up the common event fields.
11451139 */
11461140
1147 event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
1148 event.xbutton.subwindow = None;
1149 event.xbutton.x = clientPoint.x;
1150 event.xbutton.y = clientPoint.y;
1151 event.xbutton.x_root = root.point.x;
1152 event.xbutton.y_root = root.point.y;
1153 event.xbutton.state = state;
1154 event.xbutton.time = time;
1155 event.xbutton.same_screen = True;
1141 event.x.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
1142 event.x.xbutton.subwindow = None;
1143 event.x.xbutton.x = clientPoint.x;
1144 event.x.xbutton.y = clientPoint.y;
1145 event.x.xbutton.x_root = root.point.x;
1146 event.x.xbutton.y_root = root.point.y;
1147 event.x.xbutton.state = state;
1148 event.x.xbutton.time = time;
1149 event.x.xbutton.same_screen = True;
11561150
11571151 /*
11581152 * Now set up event specific fields.
11841178 * TkpGetString. [Bug 1118340].
11851179 */
11861180
1187 event.type = MouseWheelEvent;
1188 event.xany.send_event = -1;
1189 event.xkey.nbytes = 0;
1190 event.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
1181 event.x.type = MouseWheelEvent;
1182 event.x.xany.send_event = -1;
1183 event.key.nbytes = 0;
1184 event.x.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
11911185 tsdPtr->vWheelAcc = tsdPtr->vWheelAcc % WHEEL_DELTA;
11921186 break;
11931187 }
12161210 * TkpGetString. [Bug 1118340].
12171211 */
12181212
1219 event.type = MouseWheelEvent;
1220 event.xany.send_event = -1;
1221 event.xkey.nbytes = 0;
1222 event.xkey.state |= ShiftMask;
1223 event.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
1213 event.x.type = MouseWheelEvent;
1214 event.x.xany.send_event = -1;
1215 event.key.nbytes = 0;
1216 event.x.xkey.state |= ShiftMask;
1217 event.x.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
12241218 tsdPtr->hWheelAcc = tsdPtr->hWheelAcc % WHEEL_DELTA;
12251219 break;
12261220 }
12341228 * MBCS characters that came from the TranslateMessage call.
12351229 */
12361230
1237 event.type = KeyPress;
1238 event.xany.send_event = -1;
1239 event.xkey.keycode = wParam;
1240 GetTranslatedKey(&event.xkey, (message == WM_KEYDOWN) ? WM_CHAR :
1231 event.x.type = KeyPress;
1232 event.x.xany.send_event = -1;
1233 event.x.xkey.keycode = wParam;
1234 GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR :
12411235 WM_SYSCHAR);
12421236 break;
12431237
12491243 * WM_CHAR messages which will follow.
12501244 */
12511245
1252 event.type = KeyRelease;
1253 event.xkey.keycode = wParam;
1254 event.xkey.nbytes = 0;
1246 event.x.type = KeyRelease;
1247 event.x.xkey.keycode = wParam;
1248 event.key.nbytes = 0;
12551249 break;
12561250
12571251 case WM_CHAR:
12851279 * character.
12861280 */
12871281
1288 event.type = KeyPress;
1289 event.xany.send_event = -1;
1290 event.xkey.keycode = 0;
1282 event.x.type = KeyPress;
1283 event.x.xany.send_event = -1;
1284 event.x.xkey.keycode = 0;
12911285 if ((int)wParam & 0xff00) {
12921286 int ch1 = wParam & 0xffff;
12931287
13001294 (ch1 & 0x3ff) | 0x10000;
13011295 tsdPtr->surrogateBuffer = 0;
13021296 }
1303 event.xany.send_event = -3;
1304 event.xkey.nbytes = 0;
1305 event.xkey.keycode = ch1;
1297 event.x.xany.send_event = -3;
1298 event.key.nbytes = 0;
1299 event.x.xkey.keycode = ch1;
13061300 } else {
1307 event.xkey.nbytes = 1;
1308 event.xkey.trans_chars[0] = (char) wParam;
1301 event.key.nbytes = 1;
1302 event.key.trans_chars[0] = (char) wParam;
13091303
13101304 if (IsDBCSLeadByte((BYTE) wParam)) {
13111305 MSG msg;
13141308 PM_NOREMOVE) != 0)
13151309 && (msg.message == WM_CHAR)) {
13161310 GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR);
1317 event.xkey.nbytes = 2;
1318 event.xkey.trans_chars[1] = (char) msg.wParam;
1311 event.key.nbytes = 2;
1312 event.key.trans_chars[1] = (char) msg.wParam;
13191313 }
13201314 }
13211315 }
1322 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
1323 event.type = KeyRelease;
1316 Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
1317 event.x.type = KeyRelease;
13241318 break;
13251319
13261320 case WM_UNICHAR: {
1327 event.type = KeyPress;
1328 event.xany.send_event = -3;
1329 event.xkey.keycode = wParam;
1330 event.xkey.nbytes = 0;
1331 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
1332 event.type = KeyRelease;
1321 event.x.type = KeyPress;
1322 event.x.xany.send_event = -3;
1323 event.x.xkey.keycode = wParam;
1324 event.key.nbytes = 0;
1325 Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
1326 event.x.type = KeyRelease;
13331327 break;
13341328 }
13351329
13501344 * Post the translated event to the main Tk event queue.
13511345 */
13521346
1353 Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
1347 Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
13541348 }
13551349
13561350 /*
13591353 * GetState --
13601354 *
13611355 * This function constructs a state mask for the mouse buttons and
1362 * modifier keys as they were before the event occured.
1356 * modifier keys as they were before the event occurred.
13631357 *
13641358 * Results:
13651359 * Returns a composite value of all the modifier and button state flags
14521446
14531447 static void
14541448 GetTranslatedKey(
1455 XKeyEvent *xkey,
1449 TkKeyEvent *xkey,
14561450 UINT type)
14571451 {
14581452 MSG msg;
14751469 */
14761470
14771471 if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) {
1478 xkey->state = 0;
1479 }
1480 xkey->trans_chars[xkey->nbytes] = (char) msg.wParam;
1481 xkey->nbytes++;
1472 xkey->keyEvent.state = 0;
1473 }
1474 xkey->trans_chars[xkey->nbytes++] = (char) msg.wParam;
14821475
14831476 if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) {
14841477 /*
15351528 return;
15361529 }
15371530
1538 sprintf(codepage, "cp%d", charsetInfo.ciACP);
1531 if (charsetInfo.ciACP == CP_UTF8) {
1532 strcpy(codepage, "utf-8");
1533 } else {
1534 sprintf(codepage, "cp%d", charsetInfo.ciACP);
1535 }
15391536
15401537 if ((encoding = Tcl_GetEncoding(NULL, codepage)) == NULL) {
15411538 /*
66
77 #include <tkWinInt.h>
88
9 #ifndef DFCS_HOT /* Windows 98/Me, Windows 200/XP only */
9 #ifndef DFCS_HOT /* Windows 98/Me, Windows 2000/XP only */
1010 #define DFCS_HOT 0
1111 #endif
1212
685685 TTK_LAYOUT("TCombobox",
686686 TTK_GROUP("Combobox.field", TTK_FILL_BOTH,
687687 TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y)
688 TTK_GROUP("Combobox.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH,
689 TTK_GROUP("Combobox.focus", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH,
688 TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
689 TTK_GROUP("Combobox.focus", TTK_FILL_BOTH,
690690 TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))))
691691
692692 TTK_END_LAYOUT_TABLE
1414 * shellcc/platform/commctls/userex/refentry.asp >
1515 */
1616
17 #define WINVER 0x0501 /* Requires Windows XP APIs */
18
19 #include <tkWinInt.h>
1720 #ifndef HAVE_UXTHEME_H
1821 /* Stub for platforms that lack the XP theme API headers: */
19 #include <tkWinInt.h>
2022 int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; }
2123 #else
22
23 #define WINVER 0x0501 /* Requires Windows XP APIs */
2424
2525 #include <windows.h>
2626 #include <uxtheme.h>
2929 #else
3030 # include <tmschema.h>
3131 #endif
32
33 #include <tkWinInt.h>
3432
3533 #include "ttk/ttkTheme.h"
3634
105103 * We have successfully loaded the library. Proceed in storing the
106104 * addresses of the functions we want to use.
107105 */
108 XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs));
106 XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs));
109107 #define LOADPROC(name) \
110 (0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) ))
108 (0 != (procs->name = (name ## Proc *)(void *)GetProcAddress(handle, #name) ))
111109
112110 if ( LOADPROC(OpenThemeData)
113111 && LOADPROC(CloseThemeData)
137135 static void
138136 XPThemeDeleteProc(void *clientData)
139137 {
140 XPThemeData *themeData = clientData;
138 XPThemeData *themeData = (XPThemeData *)clientData;
141139 FreeLibrary(themeData->hlibrary);
142140 ckfree(clientData);
143141 }
145143 static int
146144 XPThemeEnabled(Ttk_Theme theme, void *clientData)
147145 {
148 XPThemeData *themeData = clientData;
146 XPThemeData *themeData = (XPThemeData *)clientData;
149147 int active = themeData->procs->IsThemeActive();
150148 int themed = themeData->procs->IsAppThemed();
149 (void)theme;
150
151151 return (active && themed);
152152 }
153153
381381 int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */
382382 Ttk_StateTable *statemap; /* Map Tk states to XP states */
383383 Ttk_Padding padding; /* See NOTE-GetThemeMargins */
384 int flags;
385 # define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */
386 # define PAD_MARGINS 0x40000000 /* See NOTE-GetThemeMargins */
387 # define HEAP_ELEMENT 0x20000000 /* ElementInfo is on heap */
388 # define HALF_HEIGHT 0x10000000 /* Used by GenericSizedElements */
389 # define HALF_WIDTH 0x08000000 /* Used by GenericSizedElements */
384 unsigned flags;
385 # define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */
386 # define PAD_MARGINS 0x40000000U /* See NOTE-GetThemeMargins */
387 # define HEAP_ELEMENT 0x20000000U /* ElementInfo is on heap */
388 # define HALF_HEIGHT 0x10000000U /* Used by GenericSizedElements */
389 # define HALF_WIDTH 0x08000000U /* Used by GenericSizedElements */
390390 } ElementInfo;
391391
392392 typedef struct
394394 /*
395395 * Static data, initialized when element is registered:
396396 */
397 ElementInfo *info;
397 const ElementInfo *info;
398398 XPThemeProcs *procs; /* Pointer to theme procedure table */
399399
400400 /*
410410 } ElementData;
411411
412412 static ElementData *
413 NewElementData(XPThemeProcs *procs, ElementInfo *info)
414 {
415 ElementData *elementData = ckalloc(sizeof(ElementData));
413 NewElementData(XPThemeProcs *procs, const ElementInfo *info)
414 {
415 ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData));
416416
417417 elementData->procs = procs;
418418 elementData->info = info;
428428 */
429429 static void DestroyElementData(void *clientData)
430430 {
431 ElementData *elementData = clientData;
431 ElementData *elementData = (ElementData *)clientData;
432432 if (elementData->info->flags & HEAP_ELEMENT) {
433 ckfree(elementData->info->statemap);
434 ckfree(elementData->info->className);
435 ckfree(elementData->info->elementName);
436 ckfree(elementData->info);
433 ckfree((char *)elementData->info->statemap);
434 ckfree((char *)elementData->info->className);
435 ckfree((char *)elementData->info->elementName);
436 ckfree((char *)elementData->info);
437437 }
438438 ckfree(clientData);
439439 }
496496 void *clientData, void *elementRecord, Tk_Window tkwin,
497497 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
498498 {
499 ElementData *elementData = clientData;
499 ElementData *elementData = (ElementData *)clientData;
500500 HRESULT result;
501501 SIZE size;
502 (void)elementRecord;
502503
503504 if (!InitElementData(elementData, tkwin, 0))
504505 return;
506507 if (!(elementData->info->flags & IGNORE_THEMESIZE)) {
507508 result = elementData->procs->GetThemePartSize(
508509 elementData->hTheme,
509 elementData->hDC,
510 NULL,
510511 elementData->info->partId,
511512 Ttk_StateTableLookup(elementData->info->statemap, 0),
512513 NULL /*RECT *prc*/,
532533 void *clientData, void *elementRecord, Tk_Window tkwin,
533534 Drawable d, Ttk_Box b, unsigned int state)
534535 {
535 ElementData *elementData = clientData;
536 ElementData *elementData = (ElementData *)clientData;
536537 RECT rc;
538 (void)elementRecord;
537539
538540 if (!InitElementData(elementData, tkwin, d)) {
539541 return;
577579 void *clientData, void *elementRecord, Tk_Window tkwin,
578580 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
579581 {
580 ElementData *elementData = clientData;
582 ElementData *elementData = (ElementData *)clientData;
581583
582584 if (!InitElementData(elementData, tkwin, 0))
583585 return;
613615 void *clientData, void *elementRecord, Tk_Window tkwin,
614616 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
615617 {
616 ElementData *elementData = clientData;
618 ElementData *elementData = (ElementData *)clientData;
617619
618620 if (!InitElementData(elementData, tkwin, 0))
619621 return;
642644 void *clientData, void *elementRecord, Tk_Window tkwin,
643645 Drawable d, Ttk_Box b, unsigned int state)
644646 {
645 ElementData *elementData = clientData;
647 ElementData *elementData = (ElementData *)clientData;
646648 unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
647649 RECT rc = BoxToRect(b);
650 (void)elementRecord;
648651
649652 /*
650653 * Don't draw the thumb if we are disabled.
681684 void *clientData, void *elementRecord, Tk_Window tkwin,
682685 int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
683686 {
684 ElementData *elementData = clientData;
687 ElementData *elementData = (ElementData *)clientData;
685688 int nBars = 3;
686689
687690 GenericElementSize(clientData, elementRecord, tkwin,
721724 void *clientData, void *elementRecord, Tk_Window tkwin,
722725 Drawable d, Ttk_Box b, unsigned int state)
723726 {
724 ElementData *elementData = clientData;
727 ElementData *elementData = (ElementData *)clientData;
725728 int partId = elementData->info->partId;
726729 RECT rc = BoxToRect(b);
730 (void)elementRecord;
727731
728732 if (!InitElementData(elementData, tkwin, d))
729733 return;
792796 TreeIndicatorElementDraw
793797 };
794798
795 #if BROKEN_TEXT_ELEMENT
799 #ifdef BROKEN_TEXT_ELEMENT
796800
797801 /*
798802 *----------------------------------------------------------------------
811815 Tcl_Obj *fontObj;
812816 } TextElement;
813817
814 static Ttk_ElementOptionSpec TextElementOptions[] =
818 static const Ttk_ElementOptionSpec TextElementOptions[] =
815819 {
816820 { "-text", TK_OPTION_STRING,
817821 Tk_Offset(TextElement,textObj), "" },
836840 return;
837841
838842 src = Tcl_GetStringFromObj(element->textObj, &len);
839 Tcl_WinUtfToTChar(src, len, &ds);
843 Tcl_DStringInit(&ds);
840844 hr = elementData->procs->GetThemeTextExtent(
841845 elementData->hTheme,
842846 elementData->hDC,
843847 elementData->info->partId,
844848 Ttk_StateTableLookup(elementData->info->statemap, 0),
845 (WCHAR *) Tcl_DStringValue(&ds),
849 Tcl_UtfToWCharDString(src, len, &ds),
846850 -1,
847 DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
851 DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
848852 NULL,
849853 &rc);
850854
875879 return;
876880
877881 src = Tcl_GetStringFromObj(element->textObj, &len);
878 Tcl_WinUtfToTChar(src, len, &ds);
882 Tcl_DStringInit(&ds);
879883 hr = elementData->procs->DrawThemeText(
880884 elementData->hTheme,
881885 elementData->hDC,
882886 elementData->info->partId,
883887 Ttk_StateTableLookup(elementData->info->statemap, state),
884 (WCHAR *) Tcl_DStringValue(&ds),
888 Tcl_UtfToWCharDString(src, len, &ds),
885889 -1,
886 DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
890 DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
887891 (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0,
888892 &rc);
889893
916920
917921 TTK_LAYOUT("TMenubutton",
918922 TTK_NODE("Menubutton.dropdown", TTK_PACK_RIGHT|TTK_FILL_Y)
919 TTK_GROUP("Menubutton.button", TTK_PACK_RIGHT|TTK_EXPAND|TTK_FILL_BOTH,
920 TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X,
923 TTK_GROUP("Menubutton.button", TTK_FILL_BOTH,
924 TTK_GROUP("Menubutton.padding", TTK_FILL_X,
921925 TTK_NODE("Menubutton.label", 0))))
922926
923927 TTK_LAYOUT("Horizontal.TScrollbar",
935939 TTK_NODE("Vertical.Scrollbar.grip", 0))))
936940
937941 TTK_LAYOUT("Horizontal.TScale",
938 TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH,
939 TTK_GROUP("Horizontal.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH,
942 TTK_GROUP("Scale.focus", TTK_FILL_BOTH,
943 TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH,
940944 TTK_NODE("Horizontal.Scale.track", TTK_FILL_X)
941945 TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) )))
942946
943947 TTK_LAYOUT("Vertical.TScale",
944 TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH,
945 TTK_GROUP("Vertical.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH,
948 TTK_GROUP("Scale.focus", TTK_FILL_BOTH,
949 TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH,
946950 TTK_NODE("Vertical.Scale.track", TTK_FILL_Y)
947951 TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) )))
948952
10281032 { "Menubutton.dropdown", &GenericElementSpec, L"TOOLBAR",
10291033 TP_SPLITBUTTONDROPDOWN,toolbutton_statemap, NOPAD,0 },
10301034 { "Treeview.field", &GenericElementSpec, L"TREEVIEW",
1031 TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), 0 },
1035 TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), IGNORE_THEMESIZE },
10321036 { "Treeitem.indicator", &TreeIndicatorElementSpec, L"TREEVIEW",
10331037 TVP_GLYPH, tvpglyph_statemap, PAD(1,1,6,0), PAD_MARGINS },
10341038 { "Treeheading.border", &GenericElementSpec, L"HEADER",
10431047 { "Spinbox.downarrow", &SpinboxArrowElementSpec, L"SPIN",
10441048 SPNP_DOWN, spinbutton_statemap, NOPAD,
10451049 PAD_MARGINS | ((SM_CXVSCROLL << 8) | SM_CYVSCROLL) },
1046
1047 #if BROKEN_TEXT_ELEMENT
1050 #ifdef BROKEN_TEXT_ELEMENT
10481051 { "Labelframe.text", &TextElementSpec, L"BUTTON",
10491052 BP_GROUPBOX, groupbox_statemap, NOPAD,0 },
10501053 #endif
1051
10521054 { 0,0,0,0,0,NOPAD,0 }
10531055 };
10541056 #undef PAD
10571059 static int
10581060 GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
10591061 {
1060 static const char *names[] = {
1062 static const char *const names[] = {
10611063 "SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL",
10621064 "SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK",
10631065 "SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE",
11111113 int objc,
11121114 Tcl_Obj *const objv[])
11131115 {
1114 XPThemeData *themeData = clientData;
1116 XPThemeData *themeData = (XPThemeData *)clientData;
11151117 ElementInfo *elementPtr = NULL;
11161118 ClientData elementData;
11171119 LPCWSTR className;
11251127 Ttk_ElementSpec *elementSpec = &GenericElementSpec;
11261128 Tcl_DString classBuf;
11271129
1128 static const char *optionStrings[] =
1130 static const char *const optionStrings[] =
11291131 { "-padding","-width","-height","-margins", "-syssize",
11301132 "-halfheight", "-halfwidth", NULL };
11311133 enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE,
11421144 return TCL_ERROR;
11431145 }
11441146 name = Tcl_GetStringFromObj(objv[0], &length);
1145 className = (LPCWSTR) Tcl_WinUtfToTChar(name, length, &classBuf);
1147 Tcl_DStringInit(&classBuf);
1148 className = Tcl_UtfToWCharDString(name, length, &classBuf);
11461149
11471150 /* flags or padding */
11481151 if (objc > 3) {
12171220 if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
12181221 goto retErr;
12191222 /* we over-allocate to ensure there is a terminating entry */
1220 stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1));
1223 stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1));
12211224 memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1));
12221225 for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) {
12231226 Ttk_StateSpec spec = {0,0};
12351238 return status;
12361239 }
12371240 } else {
1238 stateTable = ckalloc(sizeof(Ttk_StateTable));
1241 stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable));
12391242 memset(stateTable, 0, sizeof(Ttk_StateTable));
12401243 }
12411244
1242 elementPtr = ckalloc(sizeof(ElementInfo));
1245 elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo));
12431246 elementPtr->elementSpec = elementSpec;
12441247 elementPtr->partId = partId;
12451248 elementPtr->statemap = stateTable;
12471250 elementPtr->flags = HEAP_ELEMENT | flags;
12481251
12491252 /* set the element name to an allocated copy */
1250 name = ckalloc(strlen(elementName) + 1);
1253 name = (char *)ckalloc(strlen(elementName) + 1);
12511254 strcpy(name, elementName);
12521255 elementPtr->elementName = name;
12531256
12541257 /* set the class name to an allocated copy */
1255 wname = ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
1258 wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
12561259 wcscpy(wname, className);
12571260 elementPtr->className = wname;
12581261
12801283 XPThemeProcs *procs;
12811284 HINSTANCE hlibrary;
12821285 Ttk_Theme themePtr, parentPtr, vistaPtr;
1283 ElementInfo *infoPtr;
1284 OSVERSIONINFOW os;
1285
1286 os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
1287 GetVersionExW(&os);
1286 const ElementInfo *infoPtr;
12881287
12891288 procs = LoadXPThemeProcs(&hlibrary);
12901289 if (!procs)
13041303 * Set theme data and cleanup proc
13051304 */
13061305
1307 themeData = ckalloc(sizeof(XPThemeData));
1306 themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData));
13081307 themeData->procs = procs;
13091308 themeData->hlibrary = hlibrary;
13101309
13171316 * enable function. The theme itself is defined in script.
13181317 */
13191318
1320 if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && os.dwMajorVersion > 5) {
1319 if (TkWinGetPlatformTheme() == TK_THEME_WIN_VISTA) {
13211320 vistaPtr = Ttk_CreateTheme(interp, "vista", themePtr);
13221321 if (vistaPtr) {
13231322 Ttk_SetThemeEnabledProc(vistaPtr, XPThemeEnabled, themeData);
2424 #endif /* __GNUC__ */
2525
2626 #ifdef TK_TEST
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
2730 extern Tcl_PackageInitProc Tktest_Init;
2831 #endif /* TK_TEST */
32
33 #if !defined(TCL_USE_STATIC_PACKAGES)
34 # if TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6
35 # define TCL_USE_STATIC_PACKAGES 1
36 # else
37 # define TCL_USE_STATIC_PACKAGES 0
38 # endif
39 #endif
2940
3041 #if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
3142 extern Tcl_PackageInitProc Registry_Init;
3344 extern Tcl_PackageInitProc Dde_SafeInit;
3445 #endif
3546
47 #ifdef __cplusplus
48 }
49 #endif
3650 #ifdef TCL_BROKEN_MAINARGS
3751 static void setargv(int *argcPtr, TCHAR ***argvPtr);
3852 #endif
5367 #define TK_LOCAL_APPINIT Tcl_AppInit
5468 #endif
5569 #ifndef MODULE_SCOPE
56 # define MODULE_SCOPE extern
70 # ifdef __cplusplus
71 # define MODULE_SCOPE extern "C"
72 # else
73 # define MODULE_SCOPE extern
74 # endif
5775 #endif
5876 MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *interp);
5977
105123 TCHAR **argv;
106124 int argc;
107125 TCHAR *p;
126 (void)hInstance;
127 (void)hPrevInstance;
128 (void)lpszCmdLine;
129 (void)nCmdShow;
108130
109131 /*
110132 * Create the console channels and install them as the standard channels.
195217 if (Registry_Init(interp) == TCL_ERROR) {
196218 return TCL_ERROR;
197219 }
198 Tcl_StaticPackage(interp, "registry", Registry_Init, 0);
220 Tcl_StaticPackage(interp, "Registry", Registry_Init, 0);
199221
200222 if (Dde_Init(interp) == TCL_ERROR) {
201223 return TCL_ERROR;
202224 }
203 Tcl_StaticPackage(interp, "dde", Dde_Init, Dde_SafeInit);
225 Tcl_StaticPackage(interp, "Dde", Dde_Init, Dde_SafeInit);
204226 #endif
205227
206228 #ifdef TK_TEST
264286 char **dummy)
265287 {
266288 TCHAR **argv;
289 (void)dummy;
267290 #else
268291 int
269292 _tmain(
363386 #undef Tcl_Alloc
364387 #undef Tcl_DbCkalloc
365388
366 argSpace = ckalloc(size * sizeof(char *)
389 argSpace = (TCHAR *)ckalloc(size * sizeof(char *)
367390 + (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR));
368391 argv = (TCHAR **) argSpace;
369392 argSpace += size * (sizeof(char *)/sizeof(TCHAR));
330330 unsigned long blue_mask;
331331 XPointer obdata; /* hook for the object routines to hang on */
332332 #if defined(MAC_OSX_TK)
333 int pixelpower; /* n such that pixels are 2^n x 2^n blocks*/
333 int pixelpower; /* No longer used. */
334334 #endif
335335 struct funcs { /* image manipulation routines */
336336 struct _XImage *(*create_image)();
540540 Bool send_event; /* true if this came from a SendEvent request */
541541 Display *display; /* Display the event was read from */
542542 Window window; /* "event" window it is reported relative to */
543 Window root; /* root window that the event occured on */
543 Window root; /* root window that the event occurred on */
544544 Window subwindow; /* child window */
545545 Time time; /* milliseconds */
546546 int x, y; /* pointer x, y coordinates in event window */
548548 unsigned int state; /* key or button mask */
549549 unsigned int keycode; /* detail */
550550 Bool same_screen; /* same screen flag */
551 char trans_chars[XMaxTransChars];
552 /* translated characters */
553 unsigned char nbytes;
554551 } XKeyEvent;
555552 typedef XKeyEvent XKeyPressedEvent;
556553 typedef XKeyEvent XKeyReleasedEvent;
561558 Bool send_event; /* true if this came from a SendEvent request */
562559 Display *display; /* Display the event was read from */
563560 Window window; /* "event" window it is reported relative to */
564 Window root; /* root window that the event occured on */
561 Window root; /* root window that the event occurred on */
565562 Window subwindow; /* child window */
566563 Time time; /* milliseconds */
567564 int x, y; /* pointer x, y coordinates in event window */
579576 Bool send_event; /* true if this came from a SendEvent request */
580577 Display *display; /* Display the event was read from */
581578 Window window; /* "event" window reported relative to */
582 Window root; /* root window that the event occured on */
579 Window root; /* root window that the event occurred on */
583580 Window subwindow; /* child window */
584581 Time time; /* milliseconds */
585582 int x, y; /* pointer x, y coordinates in event window */
596593 Bool send_event; /* true if this came from a SendEvent request */
597594 Display *display; /* Display the event was read from */
598595 Window window; /* "event" window reported relative to */
599 Window root; /* root window that the event occured on */
596 Window root; /* root window that the event occurred on */
600597 Window subwindow; /* child window */
601598 Time time; /* milliseconds */
602599 int x, y; /* pointer x, y coordinates in event window */
958955 XMappingEvent xmapping;
959956 XErrorEvent xerror;
960957 XKeymapEvent xkeymap;
961 long pad[24];
958 XID pad[24];
962959 } XEvent;
963960 #endif
964961
2929 /*
3030 * TTY Functions, cleverly chosen to map to ascii, for convenience of
3131 * programming, but could have been arbitrary (at the cost of lookup
32 * tables in client code.
32 * tables in client code).
3333 */
3434
3535 #define XK_BackSpace 0xFF08 /* back space, back char */
346346
347347 /*
348348 * If *p does not point to the end of the string, there were invalid
349 * digits in the spec. Ergo, it is not a vailid color string.
349 * digits in the spec. Ergo, it is not a valid color string.
350350 * (Bug f0188aca9e)
351351 */
352352
1212 */
1313
1414 #include "tkInt.h"
15
16 #if !defined(MAC_OSX_TK)
17 # include <X11/Xlib.h>
18 # define gcCacheSize 0
19 # define TkpInitGCCache(gc)
20 # define TkpFreeGCCache(gc)
21 # define TkpGetGCCache(gc)
22 #else
23 # include <tkMacOSXInt.h>
24 # include <X11/Xlib.h>
25 # include <X11/X.h>
15 #include <X11/Xlib.h>
16 #if defined(MAC_OSX_TK)
2617 # define Cursor XCursor
2718 # define Region XRegion
28 # define gcCacheSize sizeof(TkpGCCache)
2919 #endif
3020
3121 #undef TkSetRegion
3222
23 #define MAX_DASH_LIST_SIZE 10
24 typedef struct {
25 XGCValues gc;
26 char dash[MAX_DASH_LIST_SIZE];
27 } XGCValuesWithDash;
28
3329 /*
3430 *----------------------------------------------------------------------
3531 *
5046 TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask;
5147
5248 if (clip_mask == NULL) {
53 clip_mask = ckalloc(sizeof(TkpClipMask));
49 clip_mask = (TkpClipMask *)ckalloc(sizeof(TkpClipMask));
5450 gc->clip_mask = (Pixmap) clip_mask;
55 #ifdef MAC_OSX_TK
56 } else if (clip_mask->type == TKP_CLIP_REGION) {
57 TkpReleaseRegion(clip_mask->value.region);
58 #endif
5951 }
6052 return clip_mask;
6153 }
7870
7971 static void FreeClipMask(GC gc) {
8072 if (gc->clip_mask != None) {
81 #ifdef MAC_OSX_TK
82 if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) {
83 TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region);
84 }
85 #endif
86 ckfree(gc->clip_mask);
73 ckfree((char *)gc->clip_mask);
8774 gc->clip_mask = None;
8875 }
8976 }
11299 XGCValues *values)
113100 {
114101 GC gp;
102 (void)d;
115103
116104 /*
117105 * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars
120108 * initialization.
121109 */
122110
123 #define MAX_DASH_LIST_SIZE 10
124
125 gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize);
111 gp = (GC)ckalloc(sizeof(XGCValuesWithDash));
126112 if (!gp) {
127113 return NULL;
128114 }
143129 InitField(fill_style, GCFillStyle, FillSolid);
144130 InitField(fill_rule, GCFillRule, WindingRule);
145131 InitField(arc_mode, GCArcMode, ArcPieSlice);
146 InitField(tile, GCTile, None);
147 InitField(stipple, GCStipple, None);
132 InitField(tile, GCTile, 0);
133 InitField(stipple, GCStipple, 0);
148134 InitField(ts_x_origin, GCTileStipXOrigin, 0);
149135 InitField(ts_y_origin, GCTileStipYOrigin, 0);
150 InitField(font, GCFont, None);
136 InitField(font, GCFont, 0);
151137 InitField(subwindow_mode, GCSubwindowMode, ClipByChildren);
152138 InitField(graphics_exposures, GCGraphicsExposures, True);
153139 InitField(clip_x_origin, GCClipXOrigin, 0);
163149 clip_mask->type = TKP_CLIP_PIXMAP;
164150 clip_mask->value.pixmap = values->clip_mask;
165151 }
166 TkpInitGCCache(gp);
167
168152 return gp;
169153 }
170
171 #ifdef MAC_OSX_TK
172 /*
173 *----------------------------------------------------------------------
174 *
175 * TkpGetGCCache --
176 *
177 * Results:
178 * Pointer to the TkpGCCache at the end of the GC.
179 *
180 * Side effects:
181 * None.
182 *
183 *----------------------------------------------------------------------
184 */
185
186 TkpGCCache*
187 TkpGetGCCache(GC gc) {
188 return (gc ? (TkpGCCache*)(((char*) gc) + sizeof(XGCValues) +
189 MAX_DASH_LIST_SIZE) : NULL);
190 }
191 #endif
192154
193155 /*
194156 *----------------------------------------------------------------------
267229 Display *d,
268230 GC gc)
269231 {
232 (void)d;
233
270234 if (gc != NULL) {
271235 FreeClipMask(gc);
272 TkpFreeGCCache(gc);
273236 ckfree(gc);
274237 }
275238 return Success;
298261 GC gc,
299262 unsigned long foreground)
300263 {
264 (void)display;
265
301266 gc->foreground = foreground;
302267 return Success;
303268 }
308273 GC gc,
309274 unsigned long background)
310275 {
276 (void)display;
277
311278 gc->background = background;
312279 return Success;
313280 }
321288 int n)
322289 {
323290 char *p = &(gc->dashes);
291 (void)display;
324292
325293 #ifdef TkWinDeleteBrush
326294 TkWinDeleteBrush(gc->fgBrush);
343311 GC gc,
344312 int function)
345313 {
314 (void)display;
315
346316 gc->function = function;
347317 return Success;
348318 }
353323 GC gc,
354324 int fill_rule)
355325 {
326 (void)display;
327
356328 gc->fill_rule = fill_rule;
357329 return Success;
358330 }
363335 GC gc,
364336 int fill_style)
365337 {
338 (void)display;
339
366340 gc->fill_style = fill_style;
367341 return Success;
368342 }
373347 GC gc,
374348 int x, int y)
375349 {
350 (void)display;
351
376352 gc->ts_x_origin = x;
377353 gc->ts_y_origin = y;
378354 return Success;
384360 GC gc,
385361 Font font)
386362 {
363 (void)display;
364
387365 gc->font = font;
388366 return Success;
389367 }
394372 GC gc,
395373 int arc_mode)
396374 {
375 (void)display;
376
397377 gc->arc_mode = arc_mode;
398378 return Success;
399379 }
404384 GC gc,
405385 Pixmap stipple)
406386 {
387 (void)display;
388
407389 gc->stipple = stipple;
408390 return Success;
409391 }
417399 int cap_style,
418400 int join_style)
419401 {
402 (void)display;
403
420404 gc->line_width = line_width;
421405 gc->line_style = line_style;
422406 gc->cap_style = cap_style;
431415 int clip_x_origin,
432416 int clip_y_origin)
433417 {
418 (void)display;
419
434420 gc->clip_x_origin = clip_x_origin;
435421 gc->clip_y_origin = clip_y_origin;
436422 return Success;
463449 GC gc,
464450 TkRegion r)
465451 {
452 (void)display;
453
466454 if (r == NULL) {
467455 Tcl_Panic("must not pass NULL to TkSetRegion for compatibility with X11; use XSetClipMask instead");
468456 } else {
470458
471459 clip_mask->type = TKP_CLIP_REGION;
472460 clip_mask->value.region = r;
473 #ifdef MAC_OSX_TK
474 TkpRetainRegion(r);
475 #endif
476461 }
477462 return Success;
478463 }
483468 GC gc,
484469 Pixmap pixmap)
485470 {
471 (void)display;
472
486473 if (pixmap == None) {
487474 FreeClipMask(gc);
488475 } else {
541528 int mode)
542529 {
543530 int res = Success;
531 (void)mode;
544532
545533 while (npoints-- > 0) {
546534 res = XDrawLine(display, d, gc,
560548 XSegment *segments,
561549 int nsegments)
562550 {
551 (void)display;
552 (void)d;
553 (void)gc;
554 (void)segments;
555 (void)nsegments;
556
563557 return BadDrawable;
564558 }
565559 #endif
571565 int *nbytes_return,
572566 int buffer)
573567 {
568 (void)display;
569 (void)nbytes_return;
570 (void)buffer;
571
574572 return (char *) 0;
575573 }
576574
580578 Window w,
581579 char **window_name_return)
582580 {
583 return (Status) 0;
581 (void)display;
582 (void)w;
583 (void)window_name_return;
584
585 return Success;
584586 }
585587
586588 Atom *
589591 Window w,
590592 int *num_prop_return)
591593 {
594 (void)display;
595 (void)w;
596 (void)num_prop_return;
597
592598 return (Atom *) 0;
593599 }
594600
595 void
601 int
596602 XMapRaised(
597603 Display *display,
598604 Window w)
599605 {
600 }
601
602 void
603 XPutImage(
604 Display *display,
605 Drawable d,
606 GC gc,
607 XImage *image,
608 int src_x,
609 int src_y,
610 int dest_x,
611 int dest_y,
612 unsigned int width,
613 unsigned int height)
614 {
615 }
616
617 void
606 (void)display;
607 (void)w;
608
609 return Success;
610 }
611
612 int
618613 XQueryTextExtents(
619614 Display *display,
620615 XID font_ID,
625620 int *font_descent_return,
626621 XCharStruct *overall_return)
627622 {
628 }
629
630 void
623 (void)display;
624 (void)font_ID;
625 (void)string;
626 (void)nchars;
627 (void)direction_return;
628 (void)font_ascent_return;
629 (void)font_descent_return;
630 (void)overall_return;
631
632 return Success;
633 }
634
635 int
631636 XReparentWindow(
632637 Display *display,
633638 Window w,
635640 int x,
636641 int y)
637642 {
643 (void)display;
644 (void)w;
645 (void)parent;
646 (void)x;
647 (void)y;
648
649 return BadWindow;
650 }
651
652 int
653 XUndefineCursor(
654 Display *display,
655 Window w)
656 {
657 (void)display;
658 (void)w;
659
660 return Success;
661 }
662
663 XVaNestedList
664 XVaCreateNestedList(
665 int unused, ...)
666 {
667 (void)unused;
668 return NULL;
669 }
670
671 char *
672 XSetICValues(
673 XIC xic, ...)
674 {
675 (void)xic;
676 return NULL;
677 }
678
679 char *
680 XGetICValues(
681 XIC xic, ...)
682 {
683 (void)xic;
684 return NULL;
638685 }
639686
640687 void
641 XRotateBuffers(
642 Display *display,
643 int rotate)
644 {
645 }
646
688 XSetICFocus(
689 XIC xic)
690 {
691 (void)xic;
692 }
693
694 Window
695 XCreateWindow(
696 Display *display,
697 Window parent,
698 int x,
699 int y,
700 unsigned int width,
701 unsigned int height,
702 unsigned int border_width,
703 int depth,
704 unsigned int clazz,
705 Visual *visual,
706 unsigned long value_mask,
707 XSetWindowAttributes *attributes)
708 {
709 (void)display;
710 (void)parent;
711 (void)x;
712 (void)y;
713 (void)width;
714 (void)height;
715 (void)border_width;
716 (void)depth;
717 (void)clazz;
718 (void)visual;
719 (void)value_mask;
720 (void)attributes;
721
722 return 0;
723 }
724
725 int
726 XPointInRegion(
727 Region rgn,
728 int x,
729 int y)
730 {
731 (void)rgn;
732 (void)x;
733 (void)y;
734
735 return 0;
736 }
737
738 int
739 XUnionRegion(
740 Region srca,
741 Region srcb,
742 Region dr_return)
743 {
744 (void)srca;
745 (void)srcb;
746 (void)dr_return;
747
748 return 0;
749 }
750
751 Region
752 XPolygonRegion(
753 XPoint *pts,
754 int n,
755 int rule)
756 {
757 (void)pts;
758 (void)n;
759 (void)rule;
760
761 return 0;
762 }
763 #endif
764
647765 void
648 XStoreBuffer(
649 Display *display,
650 _Xconst char *bytes,
651 int nbytes,
652 int buffer)
653 {
766 XDestroyIC(
767 XIC ic)
768 {
769 (void)ic;
770 }
771
772 Cursor
773 XCreatePixmapCursor(
774 Display *display,
775 Pixmap source,
776 Pixmap mask,
777 XColor *foreground_color,
778 XColor *background_color,
779 unsigned int x,
780 unsigned int y)
781 {
782 (void)display;
783 (void)source;
784 (void)mask;
785 (void)foreground_color;
786 (void)background_color;
787 (void)x;
788 (void)y;
789
790 return (Cursor) NULL;
791 }
792
793 Cursor
794 XCreateGlyphCursor(
795 Display *display,
796 Font source_font,
797 Font mask_font,
798 unsigned int source_char,
799 unsigned int mask_char,
800 XColor _Xconst *foreground_color,
801 XColor _Xconst *background_color)
802 {
803 (void)display;
804 (void)source_font;
805 (void)mask_font;
806 (void)source_char;
807 (void)mask_char;
808 (void)foreground_color;
809 (void)background_color;
810
811 return (Cursor) NULL;
812 }
813
814 #if 0
815 XFontSet
816 XCreateFontSet(
817 Display *display /* display */,
818 _Xconst char *base_font_name_list /* base_font_name_list */,
819 char ***missing_charset_list /* missing_charset_list */,
820 int *missing_charset_count /* missing_charset_count */,
821 char **def_string /* def_string */
822 ) {
823 (void)display;
824 (void)base_font_name_list;
825 (void)missing_charset_list;
826 (void)missing_charset_count;
827 (void)def_string;
828
829 return (XFontSet)0;
654830 }
655831
656832 void
657 XUndefineCursor(
658 Display *display,
659 Window w)
660 {
833 XFreeFontSet(
834 Display *display, /* display */
835 XFontSet fontset /* font_set */
836 ) {
837 (void)display;
838 (void)fontset;
839 }
840
841 void
842 XFreeStringList(
843 char **list /* list */
844 ) {
845 (void)list;
846 }
847
848 Status
849 XCloseIM(
850 XIM im /* im */
851 ) {
852 (void)im;
853
854 return Success;
855 }
856
857 Bool
858 XRegisterIMInstantiateCallback(
859 Display *dpy /* dpy */,
860 struct _XrmHashBucketRec *rdb /* rdb */,
861 char *res_name /* res_name */,
862 char *res_class /* res_class */,
863 XIDProc callback /* callback */,
864 XPointer client_data /* client_data */
865 ) {
866 (void)dpy;
867 (void)rdb;
868 (void)res_name;
869 (void)res_class;
870 (void)callback;
871 (void)client_data;
872
873 return False;
874 }
875
876 Bool
877 XUnregisterIMInstantiateCallback(
878 Display *dpy /* dpy */,
879 struct _XrmHashBucketRec *rdb /* rdb */,
880 char *res_name /* res_name */,
881 char *res_class /* res_class */,
882 XIDProc callback /* callback */,
883 XPointer client_data /* client_data */
884 ) {
885 (void)dpy;
886 (void)rdb;
887 (void)res_name;
888 (void)res_class;
889 (void)callback;
890 (void)client_data;
891
892 return False;
893 }
894
895 char *
896 XSetLocaleModifiers(
897 const char *modifier_list /* modifier_list */
898 ) {
899 (void)modifier_list;
900
901 return NULL;
902 }
903
904 XIM XOpenIM(
905 Display *dpy /* dpy */,
906 struct _XrmHashBucketRec *rdb /* rdb */,
907 char *res_name /* res_name */,
908 char *res_class /* res_class */
909 ) {
910 (void)dpy;
911 (void)rdb;
912 (void)res_name;
913 (void)res_class;
914
915 return NULL;
916 }
917
918 char *
919 XGetIMValues(
920 XIM im /* im */, ...
921 ) {
922 (void)im;
923
924 return NULL;
925 }
926
927 char *
928 XSetIMValues(
929 XIM im /* im */, ...
930 ) {
931 (void)im;
932
933 return NULL;
661934 }
662935 #endif
663936