Index: .fossil-settings/encoding-glob ================================================================== --- .fossil-settings/encoding-glob +++ .fossil-settings/encoding-glob @@ -1,3 +1,9 @@ win/buildall.vc.bat win/makefile.vc +win/rules-ext.vc win/rules.vc +win/targets.vc +win/rc/*.bmp +win/rc/*.cur +win/rc/*.ico +win/rc/*.rc Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -1,8 +1,9 @@ *.a *.dll *.dylib +*.dylib.E *.exe *.exp *.la *.lib *.lo @@ -19,12 +20,18 @@ */config.status */tkConfig.sh */wish* */tktest* */versions.vc +*/version.vc +*/libtk.vfs +*/libtk_*.zip +html +macosx/configure win/Debug* win/Release* win/*.manifest win/nmhlp-out.txt win/nmakehlp.out unix/tk.pc -html/* +unix/Tk-Info.plist +unix/Wish-Info.plist Index: .gitattributes ================================================================== --- .gitattributes +++ .gitattributes @@ -20,19 +20,23 @@ *.tcl text *.test text # Declare files that will always have CRLF line endings on checkout. *.bat eol=crlf +*.rc eol=crlf *.sln eol=crlf *.vc eol=crlf # Denote all files that are truly binary and should not be modified. *.a binary +*.bmp binary +*.cur binary *.dll binary *.exe binary *.gif binary *.gz binary +*.ico binary *.jpg binary *.lib binary *.pdf binary *.png binary *.xlsx binary ADDED .github/workflows/linux-build.yml Index: .github/workflows/linux-build.yml ================================================================== --- /dev/null +++ .github/workflows/linux-build.yml @@ -0,0 +1,154 @@ +name: Linux +on: [push] +defaults: + run: + shell: bash + working-directory: tk/unix +env: + ERROR_ON_FAILURES: 1 +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + matrix: + compiler: + - "gcc" + - "clang" + cfgopt: + - "" + - "CFLAGS=-DTK_NO_DEPRECATED=1" + - "--disable-shared" + - "--disable-xft" + - "--disable-xss" + - "--enable-symbols" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: tk + - name: Checkout Tcl + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-6-branch + path: tcl + - name: Setup Environment (compiler=${{ matrix.compiler }}) + run: | + sudo apt-get install tcl8.6-dev libxss-dev + mkdir "$HOME/install dir" + touch tk/doc/man.macros tk/generic/tkStubInit.c + echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6" >> $GITHUB_ENV + echo "CC=$COMPILER" >> $GITHUB_ENV + echo "TOOL_DIR=$(cd tcl/tools;pwd)" >> $GITHUB_ENV + echo "BUILD_CONFIG_ID=$OPTS" >> $GITHUB_ENV + working-directory: "." + env: + CFGOPT: ${{ matrix.cfgopt }} + COMPILER: ${{ matrix.compiler }} + OPTS: ${{ matrix.compiler }}${{ matrix.cfgopt }} + - name: Configure (opts=${{ matrix.cfgopt }}) + run: | + ./configure $CFGOPT "--prefix=$HOME/install dir" || { + cat config.log + echo "::error::Failure during Configure" + exit 1 + } + - name: Build + run: | + make binaries libraries || { + echo "::error::Failure during Build" + exit 1 + } + - name: Build Test Harness + run: | + make tktest || { + echo "::error::Failure during Build" + exit 1 + } + - name: Test-Drive Installation + run: | + make install || { + echo "::error::Failure during Install" + exit 1 + } + - name: Create Distribution Package + run: | + make dist || { + echo "::error::Failure during Distribute" + exit 1 + } + - name: Convert Documentation to HTML + run: | + make html-tk TOOL_DIR=$TOOL_DIR || { + echo "::error::Failure during Distribute" + exit 1 + } + - name: Discover Version ID + if: ${{ env.BUILD_CONFIG_ID == 'gcc' }} + run: | + cd /tmp/dist + echo "VERSION=`ls -d tk* | sed 's/tk//'`" >> $GITHUB_ENV + - name: Upload Source Distribution + if: ${{ env.BUILD_CONFIG_ID == 'gcc' }} + uses: actions/upload-artifact@v2 + with: + name: Tk ${{ env.VERSION }} Source distribution (unofficial) + path: | + /tmp/dist/tk* + !/tmp/dist/tk*/html/** + - name: Upload Documentation Distribution + if: ${{ env.BUILD_CONFIG_ID == 'gcc' }} + uses: actions/upload-artifact@v2 + with: + name: Tk ${{ env.VERSION }} HTML documentation (unofficial) + path: /tmp/dist/tk*/html + test: + runs-on: ubuntu-20.04 + strategy: + matrix: + compiler: + - "gcc" + cfgopt: + - "" + - "--enable-symbols" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: tk + - name: Setup Environment (compiler=${{ matrix.compiler }}) + run: | + sudo apt-get install tcl8.6-dev libxss-dev xvfb + mkdir "$HOME/install dir" + touch tk/doc/man.macros tk/generic/tkStubInit.c + echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6" >> $GITHUB_ENV + echo "CC=$COMPILER" >> $GITHUB_ENV + working-directory: "." + env: + CFGOPT: ${{ matrix.cfgopt }} + COMPILER: ${{ matrix.compiler }} + - name: Configure ${{ matrix.cfgopt }} + run: | + ./configure $CFGOPT "--prefix=$HOME/install dir" || { + cat config.log + echo "::error::Failure during Configure" + exit 1 + } + - name: Build + run: | + make binaries libraries tktest || { + echo "::error::Failure during Build" + exit 1 + } + - name: Run Tests + run: | + xvfb-run --auto-servernum make test-classic | tee out-classic.txt + xvfb-run --auto-servernum make test-ttk | tee out-ttk.txt + grep -q "Failed 0" out-classic.txt || { + echo "::error::Failure during Test" + exit 1 + } + grep -q "Failed 0" out-ttk.txt || { + echo "::error::Failure during Test" + exit 1 + } ADDED .github/workflows/mac-build.yml Index: .github/workflows/mac-build.yml ================================================================== --- /dev/null +++ .github/workflows/mac-build.yml @@ -0,0 +1,152 @@ +name: macOS +on: [push] +env: + ERROR_ON_FAILURES: 1 +jobs: + xcode: + runs-on: macos-11.0 + defaults: + run: + shell: bash + working-directory: tk/macosx + steps: + - name: Check out Tk + uses: actions/checkout@v2 + with: + path: tk + - name: Check out Tcl + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-6-branch + path: tcl + - name: Prepare checked out repositories + run: | + touch tk/generic/tkStubInit.c + mkdir build + echo "BUILD_DIR=`cd build && pwd`" >> $GITHUB_ENV + echo "DESTDIR=`cd build && pwd`" >> $GITHUB_ENV + working-directory: . + - name: Build Tcl + run: | + make all + working-directory: tcl/macosx + - name: Build + run: | + make all install || { + echo "::error::Failure during Build" + exit 1 + } + clang: + runs-on: macos-11.0 + strategy: + matrix: + symbols: + - 'no' + - 'mem' + options: + - '--enable-aqua' + - '--disable-aqua' + defaults: + run: + shell: bash + working-directory: tk/unix + steps: + - name: Check out Tk + uses: actions/checkout@v2 + with: + path: tk + - name: Check out Tcl + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-6-branch + path: tcl + - name: Prepare checked out repositories + run: | + touch tkStubInit.c + mkdir "$HOME/install dir" + echo "USE_XVFB=$SET_DISPLAY" >> $GITHUB_ENV + working-directory: tk/generic + env: + SET_DISPLAY: ${{ contains(matrix.options, '--disable-aqua') }} + - name: Add X11 (if required) + if: ${{ env.USE_XVFB }} + # This involves black magic + run: | + brew install --cask xquartz + sudo /opt/X11/lib/X11/xinit/privileged_startx.d/10-tmpdirs || true + working-directory: . + - name: Build Tcl + # Note that macOS is always a 64 bit platform + run: | + ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" || { + cat config.log + echo "::error::Failure during Tcl Configure" + exit 1 + } + make all || { + echo "::error::Failure during Tcl Build" + exit 1 + } + make install || { + echo "::error::Failure during Tcl Install" + exit 1 + } + working-directory: tcl/unix + env: + CFGOPT: --enable-symbols=${{ matrix.symbols }} + - name: Configure (symbols=${{ matrix.symbols }} ${{matrix.options }}) + # Note that macOS is always a 64 bit platform + run: | + ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" || { + cat config.log + echo "::error::Failure during Configure" + exit 1 + } + env: + CFGOPT: --enable-symbols=${{ matrix.symbols }} ${{matrix.options }} + - name: Build + run: | + make all tktest || { + echo "::error::Failure during Build" + exit 1 + } + - name: Run Tests + run: | + if [ $USE_XVFB == true ]; then + function runXvfb { + PATH=$PATH:/opt/X11/bin + Xvfb $1 & + XVFB_PID=$! + echo Launched Xvfb $1 as process $XVFB_PID >&2 + trap "echo killing process $XVFB_PID... >&2; kill $XVFB_PID" 0 + export DISPLAY=$1 + sleep 2 + } + else + function runXvfb { + : do nothing + } + fi + ( runXvfb :0; make test-classic; exit $? ) | tee out-classic.txt || { + echo "::error::Failure during Test" + exit 1 + } + ( runXvfb :0; make test-ttk; exit $? ) | tee out-ttk.txt || { + echo "::error::Failure during Test" + exit 1 + } + cat out-classic.txt out-ttk.txt | grep -q "Failed[[:space:]][[:space:]]*[1-9]" && { + echo "::error::Failure during Test" + exit 1 + } + env: + MAC_CI: 1 + - name: Carry out trial installation + run: | + make install || { + cat config.log + echo "::error::Failure during Install" + exit 1 + } ADDED .github/workflows/onefiledist.yml Index: .github/workflows/onefiledist.yml ================================================================== --- /dev/null +++ .github/workflows/onefiledist.yml @@ -0,0 +1,229 @@ +name: Build Binaries +on: [push] +jobs: + linux: + name: Linux + runs-on: ubuntu-16.04 + defaults: + run: + shell: bash + env: + CC: gcc + CFGOPT: --disable-symbols --disable-shared + steps: + - name: Checkout Tk + uses: actions/checkout@v2 + with: + path: tk + - name: Checkout Tcl 8.7 + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-branch + path: tcl + - name: Setup Environment + run: | + sudo apt-get install libxss-dev + mkdir -p install/1dist.vfs + touch tcl/generic/tclStubInit.c tcl/generic/tclOOStubInit.c + touch tk/generic/tkStubInit.c + echo "INST_DIR=$(cd install;pwd)" >> $GITHUB_ENV + echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV + working-directory: "." + - name: Configure Tcl + run: | + ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR + working-directory: tcl/unix + - name: Build & Install Tcl + run: | + make binaries libraries tclzipfile install + make shell SCRIPT="$VER_PATH $GITHUB_ENV" + working-directory: tcl/unix + - name: Configure Tk + run: | + ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR + working-directory: tk/unix + - name: Build & Install Tk + run: | + make binaries libraries install + working-directory: tk/unix + # TODO: need the Tk version separately for distro naming below + - name: Pack Tk Library Files into Library Zip + run: | + unzip ../lib/libtcl*.zip + cp -a ../lib/tk[0-9]* . + zip -r ../1dist.zip . + working-directory: ${{ env.INST_DIR }}/1dist.vfs + - name: Package + run: | + cat ../tk/unix/wish 1dist.zip >> ${BUILD_NAME} + chmod +x ${BUILD_NAME} + tar -cf ${BUILD_NAME}.tar ${BUILD_NAME} + working-directory: ${{ env.INST_DIR }} + env: + BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_unofficial + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Wish ${{ env.TCL_PATCHLEVEL }} Linux single-file build (unofficial) + path: ${{ env.INST_DIR }}/*.tar + - name: Describe Installation Zip Contents + if: ${{ always() }} + run: | + unzip -l 1dist.zip || true + working-directory: ${{ env.INST_DIR }} + macos: + name: macOS + runs-on: macos-11.0 + defaults: + run: + shell: bash + env: + CC: gcc + CFGOPT: --disable-symbols --disable-shared --enable-64bit + steps: + - name: Checkout Tk + uses: actions/checkout@v2 + with: + path: tk + - name: Checkout Tcl 8.7 + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-branch + path: tcl + - name: Checkout create-dmg + uses: actions/checkout@v2 + with: + repository: create-dmg/create-dmg + ref: v1.0.8 + path: create-dmg + - name: Setup Environment + run: | + mkdir -p install/1dist.vfs install/contents + touch tcl/generic/tclStubInit.c tcl/generic/tclOOStubInit.c + touch tk/generic/tkStubInit.c + echo "INST_DIR=$(cd install;pwd)" >> $GITHUB_ENV + echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV + echo "CREATE_DMG=$(cd create-dmg;pwd)/create-dmg" >> $GITHUB_ENV + working-directory: "." + - name: Configure Tcl + run: | + ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR + working-directory: tcl/unix + - name: Build & Install Tcl + run: | + make binaries libraries tclzipfile install + make shell SCRIPT="$VER_PATH $GITHUB_ENV" + working-directory: tcl/unix + - name: Configure Tk + run: | + ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR \ + --enable-aqua + working-directory: tk/unix + - name: Build & Install Tk + run: | + make binaries libraries install + working-directory: tk/unix + # TODO: need the Tk version separately for distro naming below + - name: Pack Tk Library Files into Library Zip + run: | + unzip ../lib/libtcl*.zip + cp -a ../lib/tk[0-9]* . + zip -r ../1dist.zip . + working-directory: ${{ env.INST_DIR }}/1dist.vfs + - name: Package + run: | + cat ../tk/unix/wish 1dist.zip >> contents/${BUILD_NAME} + chmod +x contents/${BUILD_NAME} + cat > contents/README.txt <> $GITHUB_ENV + echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV + working-directory: "." + - name: Configure Tcl + run: | + ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR + working-directory: tcl/win + - name: Build & Install Tcl + run: | + make binaries libraries tclzipfile install + echo "ZIP_BIN=`pwd`/minizip.exe" >> $GITHUB_ENV + echo "TCL_ZIP=`pwd`/`echo libtcl*.zip`" >> $GITHUB_ENV + $INST_DIR/bin/tclsh* $VER_PATH $GITHUB_ENV + working-directory: tcl/win + - name: Configure Tk + run: | + ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR + working-directory: tk/win + - name: Build & Install Tk + run: | + make all install + echo "TK_BIN=`pwd`/`echo wish*.exe`" >> $GITHUB_ENV + working-directory: tk/win + # TODO: need the Tk version separately for distro naming below + - name: Pack Tk Library Files into Library Zip + run: | + unzip $TCL_ZIP + cp -R ../lib/tk[0-9]* . + $ZIP_BIN -o -r ../1dist.zip * + working-directory: install/1dist + - name: Package + run: | + cat ${TK_BIN} 1dist.zip > combined/${BUILD_NAME}.exe + working-directory: install + env: + BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_unofficial + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Wish ${{ env.TCL_PATCHLEVEL }} Windows single-file build (unofficial) + path: install/combined/wish${{ env.TCL_PATCHLEVEL }}_unofficial.exe ADDED .github/workflows/win-build.yml Index: .github/workflows/win-build.yml ================================================================== --- /dev/null +++ .github/workflows/win-build.yml @@ -0,0 +1,158 @@ +name: Windows +on: [push] +env: + ERROR_ON_FAILURES: 1 +jobs: + msvc: + runs-on: windows-2019 + defaults: + run: + shell: powershell + working-directory: tk/win + # Using powershell means we need to explicitly stop on failure + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: tk + - name: Checkout + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-branch + path: tcl + - name: Init MSVC + uses: ilammy/msvc-dev-cmd@v1 + - name: Make Install Location + working-directory: tcl + run: | + echo "TCLDIR=`pwd`" >> $GITHUB_ENV + cd .. + mkdir install + cd install + echo "INSTALLDIR=`pwd`" >> $GITHUB_ENV + - name: Build Tcl + run: | + &nmake -f makefile.vc release install + if ($lastexitcode -ne 0) { + throw "nmake exit code: $lastexitcode" + } + working-directory: tcl/win + - name: Build + run: | + &nmake -f makefile.vc all + if ($lastexitcode -ne 0) { + throw "nmake exit code: $lastexitcode" + } + - name: Build Test Harness + run: | + &nmake -f makefile.vc tktest + if ($lastexitcode -ne 0) { + throw "nmake exit code: $lastexitcode" + } + - name: Run Tests + run: | + nmake -f makefile.vc test-classic | tee out-classic.txt || { + echo "::error::Failure during Test" + exit 1 + } + nmake -f makefile.vc test-ttk | tee out-ttk.txt || { + echo "::error::Failure during Test" + exit 1 + } + grep -q "Failed 0" out-classic.txt || { + echo "::error::Failure during Test" + exit 1 + } + grep -q "Failed 0" out-ttk.txt || { + echo "::error::Failure during Test" + exit 1 + } + env: + CI_BUILD_WITH_MSVC: 1 + shell: bash + - name: Build Help + run: | + &nmake -f makefile.vc htmlhelp + if ($lastexitcode -ne 0) { + throw "nmake exit code: $lastexitcode" + } + - name: Install + run: | + &nmake -f makefile.vc install + if ($lastexitcode -ne 0) { + throw "nmake exit code: $lastexitcode" + } + gcc: + runs-on: windows-2019 + defaults: + run: + shell: bash + working-directory: win + strategy: + matrix: + symbols: + - "no" + - "mem" + - "all" + # Using powershell means we need to explicitly stop on failure + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 + with: + repository: tcltk/tcl + ref: core-8-6-branch + path: tcl + - name: Install MSYS2, Make + run: choco install -y msys2 make + - name: Prepare + run: | + touch tkStubInit.c + touch "${HOME}/forWinDialog-5.12.7" + mkdir "${HOME}/install_dir" + echo "INSTALL_DIR=${HOME}/install_dir" >> $GITHUB_ENV + working-directory: generic + - name: Configure and Build Tcl + run: | + ./configure ${CFGOPT} "--prefix=$INSTALL_DIR" || { + cat config.log + echo "::warning::Failure during Tcl Configure" + exit 1 + } + make all install || { + echo "::warning::Failure during Tcl Build" + exit 1 + } + echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV + env: + CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }} + working-directory: tcl/win + - name: Configure (symbols=${{ matrix.symbols }}) + run: | + ./configure ${CFGOPT} "--prefix=$HOME/INSTALL_DIR" "--with-tcl=$TCL_CONFIG_PATH" || { + cat config.log + echo "::error::Failure during Configure" + exit 1 + } + env: + CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }} + - name: Build + run: | + make all tktest || { + echo "::error::Failure during Build" + exit 1 + } + - name: Run Tests + run: | + make test-classic | tee out-classic.txt + make test-ttk | tee out-ttk.txt + grep -q "Failed 0" out-classic.txt || { + echo "::error::Failure during Test" + exit 1 + } + grep -q "Failed 0" out-ttk.txt || { + echo "::error::Failure during Test" + exit 1 + } Index: .gitignore ================================================================== --- .gitignore +++ .gitignore @@ -1,9 +1,10 @@ *.a *.bundle *.dll *.dylib +*.dylib.E *.exe *.exp *.lib *.o *.obj @@ -12,10 +13,11 @@ *.sl *.so .fslckout Makefile Tk-Info.plist +Wish-Info.plist autom4te.cache config.cache config.log config.status config.status.lineno @@ -53,7 +55,7 @@ unix/tk.pc unix/tclIndex win/Debug* win/Release* win/*.manifest -win/nmhlp-out.txt win/nmakehlp.out +win/nmhlp-out.txt Index: .travis.yml ================================================================== --- .travis.yml +++ .travis.yml @@ -1,233 +1,250 @@ -sudo: required language: c addons: apt: + sources: + - ubuntu-toolchain-r-test packages: - binutils-mingw-w64-i686 - binutils-mingw-w64-x86-64 - gcc-mingw-w64 - gcc-mingw-w64-base - gcc-mingw-w64-i686 - gcc-mingw-w64-x86-64 - gcc-multilib - - tcl-dev + - tcl8.6-dev - libx11-dev + - libnotify-dev + - libglib2.0-dev + - libxss-dev + - xvfb homebrew: packages: - tcl-tk - casks: - - xquartz - update: true -matrix: + - libnotify + - glib +# casks: +# - xquartz +jobs: include: -# Testing on Linux with various compilers +# Testing on Linux GCC - name: "Linux/GCC/Shared" os: linux - dist: bionic + dist: focal + services: + - xvfb compiler: gcc env: - BUILD_DIR=unix + script: &x11gui + - make binaries libraries tktest + - make install + - make test-classic >out-classic.txt + - cat out-classic.txt + - grep -q "Failed 0" out-classic.txt + - make test-ttk >out-ttk.txt + - cat out-ttk.txt + - grep -q "Failed 0" out-ttk.txt - name: "Linux/GCC/Shared: NO_DEPRECATED" os: linux - dist: bionic + dist: focal + services: + - xvfb compiler: gcc env: - BUILD_DIR=unix - CFGOPT="CFLAGS=-DTK_NO_DEPRECATED=1" + script: *x11gui - name: "Linux/GCC/Shared/no-xft" os: linux - dist: bionic + dist: focal + services: + - xvfb compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--disable-xft" - - name: "Linux/GCC/Static" + script: *x11gui + - name: "Linux/GCC/Shared/no-libnotify" + os: linux + dist: focal + services: + - xvfb + compiler: gcc + env: + - BUILD_DIR=unix + - CFGOPT="--disable-libnotify" + script: *x11gui + - name: "Linux/GCC/Shared/bionic" os: linux dist: bionic + services: + - xvfb + compiler: gcc + env: + - BUILD_DIR=unix + script: *x11gui + - name: "Linux/GCC/Shared/xenial" + os: linux + dist: xenial + services: + - xvfb + compiler: gcc + env: + - BUILD_DIR=unix + script: *x11gui + - name: "Linux/GCC/Static" + os: linux + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--disable-shared" - name: "Linux/GCC/Debug" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" - name: "Linux/G++/Shared" os: linux - dist: bionic + dist: focal compiler: g++ env: - BUILD_DIR=unix - CFGOPT="CC=g++ CFLAGS=-Dregister=dont+use+register" - name: "Linux/G++/Shared UTF_MAX=4" os: linux - dist: bionic + dist: focal compiler: g++ env: - BUILD_DIR=unix - CFGOPT="CC=g++ CFLAGS=-DTCL_UTF_MAX=4" - name: "Linux/G++/Shared UTF_MAX=6" os: linux - dist: bionic + dist: focal compiler: g++ env: - BUILD_DIR=unix - CFGOPT="CC=g++ CFLAGS=-DTCL_UTF_MAX=6" -# Older versions of GCC... - - name: "Linux/GCC 7/Shared" - os: linux - dist: bionic - compiler: gcc-7 - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - env: - - BUILD_DIR=unix - - name: "Linux/GCC 6/Shared" - os: linux - dist: bionic - compiler: gcc-6 - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-6 +# Newer/Older versions of GCC + - name: "Linux/GCC 10/Shared" + os: linux + dist: focal + compiler: gcc-10 + addons: + apt: + packages: + - g++-10 env: - BUILD_DIR=unix - name: "Linux/GCC 5/Shared" os: linux dist: bionic compiler: gcc-5 addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - g++-5 env: - BUILD_DIR=unix -# Clang +# Testing on Linux Clang - name: "Linux/Clang/Shared" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - name: "Linux/Clang/Shared: NO_DEPRECATED" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - CFGOPT="CFLAGS=-DTK_NO_DEPRECATED=1" - name: "Linux/Clang/Shared/no-xft" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - CFGOPT="--disable-xft" - name: "Linux/Clang/Static" os: linux - dist: bionic + dist: focal compiler: clang env: - CFGOPT="--disable-shared" - BUILD_DIR=unix - name: "Linux/Clang/Debug" os: linux - dist: bionic + dist: focal compiler: clang env: - BUILD_DIR=unix - CFGOPT="--enable-symbols" # Testing on Mac, various styles - - name: "macOS/Clang/Xcode 11.5/Shared" + - name: "macOS/Xcode 12/Shared" os: osx - osx_image: xcode11.5 + osx_image: xcode12 env: - BUILD_DIR=unix - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include" - - name: "macOS/Clang++/Xcode 11.5/Shared" + - name: "macOS/Clang++/Xcode 12/Shared" os: osx - osx_image: xcode11.5 + osx_image: xcode12 env: - BUILD_DIR=unix - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib CC=clang++ --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-D__private_extern__=extern" - - name: "macOS/Clang/Xcode 11.5/Shared" - os: osx - osx_image: xcode11.5 - env: - - BUILD_DIR=unix - - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: &mactest - - make all tktest - - name: "macOS/Clang/Xcode 11.5/Static" - os: osx - osx_image: xcode11.5 + - name: "macOS/Xcode 12/Static" + os: osx + osx_image: xcode12 env: - BUILD_DIR=unix - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --disable-shared CFLAGS=-I/usr/local/opt/tcl-tk/include" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest - - name: "macOS/Clang/Xcode 11.5/Debug" + - name: "macOS/Xcode 12/Debug" os: osx - osx_image: xcode11.5 + osx_image: xcode12 env: - BUILD_DIR=unix - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --enable-symbols CFLAGS=-I/usr/local/opt/tcl-tk/include" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest - - name: "macOS/Clang/Xcode 11.5/Shared/XQuartz" - os: osx - osx_image: xcode11.5 - env: - - BUILD_DIR=unix - - 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" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest -# Older MacOS versions - - name: "macOS/Clang/Xcode 11/Shared" - os: osx - osx_image: xcode11 - env: - - BUILD_DIR=unix - - 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" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest - - name: "macOS/Clang/Xcode 10/Shared" - os: osx - osx_image: xcode10.3 - env: - - BUILD_DIR=unix - - 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" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest - - name: "macOS/Clang/Xcode 9/Shared" - os: osx - osx_image: xcode9.4 - env: - - BUILD_DIR=unix - - 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" - install: - - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest +# - name: "macOS/Xcode 12/Shared/XQuartz" +# os: osx +# osx_image: xcode12 +# env: +# - BUILD_DIR=unix +# - 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" +# Older MacOS versions + - name: "macOS/Xcode 11/Shared" + os: osx + osx_image: xcode11.7 + env: + - BUILD_DIR=unix + - 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" + - name: "macOS/Xcode 10/Shared" + os: osx + osx_image: xcode10.3 + addons: + homebrew: + packages: + - tcl-tk + update: true + env: + - BUILD_DIR=unix + - 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" + - name: "macOS/Xcode 9/Shared" + os: osx + osx_image: xcode9.4 + addons: + homebrew: + packages: + - tcl-tk + update: true + env: + - BUILD_DIR=unix + - 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" # Test on Windows with MSVC native # - name: "Windows/MSVC/Shared" # os: windows # compiler: cl # env: &vcenv @@ -240,11 +257,11 @@ # script: # - cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc all tktest # "make dist" only - name: "Linux: make dist" os: linux - dist: bionic + dist: focal compiler: gcc env: - BUILD_DIR=unix script: - make dist @@ -257,14 +274,20 @@ esac - cd ${BUILD_DIR} install: - mkdir "$HOME/install dir" - ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1) -before_script: - - export ERROR_ON_FAILURES=1 script: - make all tktest - make install +before_cache: + - |- + case $TRAVIS_OS_NAME in + osx) + brew cleanup + ;; + esac cache: directories: + - $HOME/Library/Caches/Homebrew - $HOME/AppData/Local/Temp/chocolatey - $HOME/AppData/Local/Apps/Tcl86 Index: ChangeLog ================================================================== --- ChangeLog +++ ChangeLog @@ -712,11 +712,11 @@ notably on a canvas) without reinterpreting via a string. 2011-10-27 Kevin B. Kenny * generic/tkInt.h: [Bug 3410609]: Change the event mechanism - * unix/tkUnixEvent.c: for events to use the keysym + * unix/tkUnixEvent.c: for events to use the keysym * unix/tkUnixKey.c: returned by XLookupString in preference to the one that appears in the raw X event at any level. This change allows binding to ISO_Level3_Shift-ed characters, composed characters, and similar beasts. KeyRelease events still work as they did before, as does Tk with input methods disabled. @@ -5211,11 +5211,11 @@ * doc/canvas.n, doc/listbox.n, doc/message.n: [Bug 1882495]: Fix erroneous listing of "standard" options. 2008-01-29 Joe English - * library/treeview.tcl: Fix bug in Shift-ButtonPress-1 binding (error + * library/treeview.tcl: Fix bug in Shift-Button-1 binding (error if no current focus item; reported on c.l.t.) 2008-01-29 Donal K. Fellows * doc/ttk_*.n: [Bug 1876493]: Adjusted handling of the standard Index: ChangeLog.2004 ================================================================== --- ChangeLog.2004 +++ ChangeLog.2004 @@ -3519,11 +3519,11 @@ * unix/tcl.m4: correct HP-UX ia64 --enable-64bit build flags 2003-02-13 Kevin Kenny * doc/wish.n: Added language to describe the handling of the - end-of-file character \u001a in script files. [Bug 685505] + end-of-file character \x1A in script files. [Bug 685505] 2003-02-10 Jim Ingham * macosx/tkMacOSXCursor.c (TkMacOSXInstallCursor): Set all theme cursors using SetThemeCursor or SetAnimatedThemeCursors. Index: README.md ================================================================== --- README.md +++ README.md @@ -3,10 +3,19 @@ This is the **Tk 8.7a4** source distribution. You can get any source release of Tk from [our distribution site](https://sourceforge.net/projects/tcl/files/Tcl/). +8.6 (production release, daily build) +[![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) +[![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) +[![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) +
+8.7 (in development, daily build)) +[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Amain) +[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Amain) +[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Amain) ## 1. Introduction This directory contains the sources and documentation for Tk, a cross-platform GUI toolkit implemented with the Tcl scripting language. @@ -16,17 +25,17 @@ or refer to the "changes" file in this directory, which contains a historical record of all changes to Tk. Tk is maintained, enhanced, and distributed freely by the Tcl community. Source code development and tracking of bug reports and feature requests -takes place at [core.tcl-lang.org](https://core.tcl-lang.org/). +take place at [core.tcl-lang.org](https://core.tcl-lang.org/). Tcl/Tk release and mailing list services are [hosted by SourceForge](https://sourceforge.net/projects/tcl/) with the Tcl Developer Xchange hosted at [www.tcl-lang.org](https://www.tcl-lang.org). -Tk is a freely available open source package. You can do virtually +Tk is a freely available open-source package. You can do virtually anything you like with it, such as modifying it, redistributing it, and selling it either in whole or in part. See the file `license.terms` for complete information. ## 2. See Tcl README.md Index: changes ================================================================== --- changes +++ changes @@ -331,11 +331,11 @@ *** POTENTIAL INCOMPATIBILITY *** 4/12/92 (bug fix) Fixed core dump that occurred in tkError.c when removing the first error record from the error list. -4/15/92 (bug fix) Fixed bug in tkBind.c that prevented +4/15/92 (bug fix) Fixed bug in tkBind.c that prevented event specifications from being processed correctly: the "1" was treated as a button name rather than a keysym. 4/18/92 (new feature) Added Tk_DefineCursor and Tk_UndefineCursor procedures. @@ -3486,11 +3486,11 @@ widget command, which allows a menu to operate as a menubar. On the Macintosh, the menubar is displayed accross the top of the main monitor, just like with other applications. Under Windows and Unix, the menu is attached to the toplevel window. Also, changed some semantics. Tearoff menus will now reflect changes to the menu it was -torn off from, and are deleted when the master menu is +torn off from, and are deleted when the main menu is deleted. Tearoffs also reflect more look-and-feel of the platforms they are running on. (SRP) 10/31/96 (bug fix) Under Windows, missing system cursors would generate an error instead of falling through to the Tk cursor of the @@ -3996,11 +3996,11 @@ 9/16/97 (new feature) Added "resource delete" and "resource files" command to the Mac. Also fixed "resource write" when the resource was specified by id and already existed. (JI) -9/16/97 (bug fix) Added null bindings to for the +9/16/97 (bug fix) Added null bindings to for the text and entry widget on the Macintosh. This prevents unbound command key sequences from having the character echoed to the widget. Also fixed Cut & Copy bindings. (JI) (RJ) 9/18/97 (bug fix) Revamped Macintosh focus code. Cut, Copy & Paste @@ -7525,11 +7525,11 @@ 2018-01-07 (bug)[925262] New option -state for ttk::scale (vogel) 2018-01-07 (bug)[fa8de7] Crash [ttk::checkbutton .x -variable {}] (werner) -2018-01-16 (bug)[382712] Crash in [event generate . ] (werner) +2018-01-16 (bug)[382712] Crash in [event generate . ] (werner) 2018-01-19 (bug)[657c38] Crash in menu destroy with checkbutton entry (werner) 2018-01-25 (bug)[de156e] Deny PRIMARY selection access in safe interps (nash) @@ -7720,10 +7720,154 @@ 2019-11-19 (new) Partial Emoji support in text displays (nijtmans,culler) - Released 8.6.10, Nov 21, 2019 - https://core.tcl-lang.org/tk/ for details +2019-11-25 (bug)[a95373] TkKeyEvent platform variations (werner) + +2019-11-26 (bug) workaround Win bug so test bind-34.3 passes (nijtmans) + +2019-12-03 Aqua: white cursors in dark mode (culler) + +2019-12-04 (bug)[749bd9] Aqua: systemControlAccentColor (bll,culler) + +2019-12-14 (bug)[b3b56a] ttk respect -cursor option (vogel) + +2019-12-14 (bug)[b094cb] Win: $tv -show grows widget width 1 pixel (vogel) + +2019-12-14 (bug)[02a694] spinbox options used wrong db names (vogel) + +2020-01-11 (bug)[2b8fa6] MouseWheel for ttk::scrollbar (oehlmann) + +2020-01-18 (bug)[1771594] icursor and scrollregion, canvText-14.7 (vogel) + +2020-01-18 (bug)[587937] tag list ops preserve list order (vogel) + +2020-01-18 (bug)[2830360] lose invalid state at focus event, entry-10.1 (vogel) + +2020-01-18 (bug)[077d49] string table options support null ok (vogel) + +2020-01-18 (bug)[bf93d0] Aqua: unresponsive menubar (culler) + +2020-01-31 (bug)[a196fb] restore support for unthreaded Tcl (porter,sebres) + +2020-02-09 (bug)[90a4d7] fontconfig crash when no font installed (vogel) + +2020-02-24 (bug) Aqua: incomplete floating window display (walzer) + +2020-03-11 (bug)[fb2ec3] OSX 10.15+: full screen options (nicolas,walzer) + +2020-03-12 (bug)[08e2f8] focus on unmapped windows, focus-7.1 (vogel) + +2020-03-12 (bug)[2edd84] [$c postscript] result management (gavilan) + +2020-03-22 (bug)[98662d] restore TK_MAC_DEBUG_DRAWING build (chavez) + +2020-03-29 (bug)[655fe2] tearoff menu redraw artifacts (vogel) + +2020-04-03 (bug)[efbedd] Aqua: compund button-like widget appearance (chavez) + +2020-04-14 (bug)[87bade] Aqua: improved dealing with PressAndHold (culler) + +2020-04-14 (bug)[376788] X: stop crash w/Noto Color Emoji font (nijtmans) + +2020-04-15 (bug)[89354d] Aqua: text color w/o clipping (culler) + +2020-04-15 (new) Aqua: assign Button 3 to the middle button (chavez) + +2020-04-25 (bug)[3519111] treeview horizontal scroll, entry-2.1.1 (vogel) + +2020-04-25 (bug)[141881] treeview vertical scroll, treeview-9.2 (vogel) + +2020-05-01 (bug)[2712f4] X: crash angled text w/o Xft, canvText-20.2 (vogel) + +2020-05-01 (bug)[cd8714] Win: long angled text (chavez) + +2020-05-09 (bug)[88c9e0] treeview -selectmode none focus ring (gavilan) + +2020-05-12 (new) Aqua: Rewrite of the Key event system (culler) + +2020-05-12 (bug)[411359] Aqua: stop crashes/zombies related to TouchBar (culler) + +2020-05-12 (new) Aqua: systemLinkColor (chavez) + +2020-05-16 (bug)[40ada9] crash when active button is destroyed (chavez) + +2020-05-28 (bug)[3c6660,601cea,4b50b7] Win10: ttk scale (nemethi,lanam) + +2020-06-08 (bug)[2790615] Some callbacks not eval'd in global scope (nijtmans) + +2020-06-25 Aqua: Update OSX version tests to support Big Sur (culler) + +2020-06-27 (bug)[6920b2] dup in spinbox -values causes trouble (lanam) + +2020-06-27 (bug)[5c51be] invalid mem read buffer in Tk_PhotoPut* (chavez) + +2020-06-27 (bug)[16ef16] restore bind sequence support, bind-33.(16-21) (vogel) + +2020-07-02 (bug)[2d2459] default style for combobox (bll) + +2020-07-06 (bug)[40c4bf] double free, entry-19.21 (vogel) + +2020-07-06 (bug)[e3888d] grab & warp, bind-36.1 (vogel) + +2020-07-12 (bug)[2442314] fontchooser i18n (nijtmans) + +2020-07-13 (bug)[7655f6] [*entry]: selected text drawing reform (chavez) + +2020-07-14 (bug)[09abd7] workaround invalid key codes from Debian 10 (vogel) + +2020-07-20 (bug)[cf3853] Aqua: improve bounds on non-Retina displays (chavez) + +2020-08-01 Aqua: [winfo rgb] light and dark mode support (culler) + +2020-08-15 (bug)[315104] Aqua: appearance change virtual events (culler) + +2020-08-21 (bug)[291699] mouse binding for scrollbar grip (bll) + +2020-09-08 (bug)[6c2425] buffer bounds violation (chavez) + +2020-09-08 (bug)[2a6d63] OSX 10.6 crash (hellstrom,culler) + +2020-09-08 (bug)[420feb] undefined behavior due to alignment (chavez,nijtmans) + +2020-09-10 (bug)[ab1fea] Aqua init issues (culler) + +2020-09-14 (bug)[71e18c] Aqua: crash in full screen toggle (culler) + +2020-09-18 (bug)[4f4f03] Aqua: mouse drags across title bar (nab,culler) + +2020-09-21 (bug)[d91e05] select/copy in disabled text (bll) + +2020-09-27 (TIP #581) disfavor Master/Slave terminology (nijtmans) + +2020-09-30 (bug)[59cba3] win: improve theme detection (bll,nijtmans) + +2020-10-06 (bug)[175a6e] Aqua: support tiled windows (culler) + +2020-10-07 (bug)[1fa8c3] Aqua: crash on resize during display (nab,culler) + +2020-10-16 (bug)[c2483b] Aqua: consistent finalization (culler,nijtmans) + +2020-11-06 (bug)[c9ebac] Aqua: use standard about dialog (culler) + +2020-11-07 (bug)[4ebcc0] sticky fontchooser options (roseman,vogel) + +2020-11-10 (bug)[f9fa92] Aqua: crash in color caching scheme (culler) + +2020-11-20 (bug)[7185d2] Aqua: fixes to special menu support (culler) + +2020-11-24 (bug)[4a40c6] Aqua: [wm manage] frame offset (chavez) + +2020-12-04 (bug)[3ef77f] Aqua dark mode combobox focus ring (walzer,culler) + +2020-12-15 (bug)[80e4c6] Aqua: progressbar animation (nab,culler) + +2020-12-24 (bug)[6157a8] Aqua: file dialog -filetypes (davis,culler) + +- Released 8.6.11, Dec 31, 2020 - https://core.tcl-lang.org/tk/ for details + Changes to 8.7a3 include all changes to the 8.6 line through 8.6.10, plus the following, which focuses on the high-level feature changes in this changeset (new minor version) rather than bug fixes: 2017-11-25 [TIP 161] $menu -tearoff default changed to false (roseman,vogel) Index: doc/AddOption.3 ================================================================== --- doc/AddOption.3 +++ doc/AddOption.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_AddOption 3 "" Tk "Tk Library Procedures" .so man.macros .BS Index: doc/CrtImgType.3 ================================================================== --- doc/CrtImgType.3 +++ doc/CrtImgType.3 @@ -7,19 +7,19 @@ '\" .TH Tk_CreateImageType 3 8.5 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_CreateImageType, Tk_GetImageMasterData, Tk_InitImageArgs \- define new kind of image +Tk_CreateImageType, Tk_GetImageModelData, Tk_InitImageArgs \- define new kind of image .SH SYNOPSIS .nf \fB#include \fR .sp \fBTk_CreateImageType\fR(\fItypePtr\fR) .sp ClientData -\fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR) +\fBTk_GetImageModelData\fR(\fIinterp, name, typePtrPtr\fR) .sp \fBTk_InitImageArgs\fR(\fIinterp, argc, argvPtr\fR) .SH ARGUMENTS .AS "const Tk_ImageType" *typePtrPtr .AP "const Tk_ImageType" *typePtr in @@ -69,11 +69,11 @@ .CE The fields of this structure will be described in later subsections of this entry. .PP The second major data structure manipulated by an image manager -is called an \fIimage master\fR; it contains overall information +is called an \fIimage model\fR; it contains overall information about a particular image, such as the values of the configuration options specified in an \fBimage create\fR command. There will usually be one of these structures for each invocation of the \fBimage create\fR command. .PP @@ -111,29 +111,29 @@ Tcl_Interp *\fIinterp\fR, const char *\fIname\fR, int \fIobjc\fR, Tcl_Obj *const \fIobjv\fR[], const Tk_ImageType *\fItypePtr\fR, - Tk_ImageMaster \fImaster\fR, - ClientData *\fImasterDataPtr\fR); + Tk_ImageModel \fImodel\fR, + ClientData *\fImodelDataPtr\fR); .CE The \fIinterp\fR argument is the interpreter in which the \fBimage\fR command was invoked, and \fIname\fR is the name for the new image, which was either specified explicitly in the \fBimage\fR command or generated automatically by the \fBimage\fR command. The \fIobjc\fR and \fIobjv\fR arguments describe all the configuration options for the new image (everything after the name argument to \fBimage\fR). -The \fImaster\fR argument is a token that refers to Tk's information +The \fImodel\fR argument is a token that refers to Tk's information about this image; the image manager must return this token to Tk when invoking the \fBTk_ImageChanged\fR procedure. Typically \fIcreateProc\fR will parse \fIobjc\fR and \fIobjv\fR -and create an image master data structure for the new image. +and create an image model data structure for the new image. \fIcreateProc\fR may store an arbitrary one-word value at -*\fImasterDataPtr\fR, which will be passed back to the +*\fImodelDataPtr\fR, which will be passed back to the image manager when other callbacks are invoked. -Typically the value is a pointer to the master data +Typically the value is a pointer to the model data structure for the image. .PP If \fIcreateProc\fR encounters an error, it should leave an error message in the interpreter result and return \fBTCL_ERROR\fR; otherwise it should return \fBTCL_OK\fR. @@ -146,15 +146,15 @@ calls \fBTk_GetImage\fR to use a particular image. This procedure must match the following prototype: .CS typedef ClientData \fBTk_ImageGetProc\fR( Tk_Window \fItkwin\fR, - ClientData \fImasterData\fR); + ClientData \fImodelData\fR); .CE The \fItkwin\fR argument identifies the window in which the -image will be used and \fImasterData\fR is the value -returned by \fIcreateProc\fR when the image master was created. +image will be used and \fImodelData\fR is the value +returned by \fIcreateProc\fR when the image model was created. \fIgetProc\fR will usually create a data structure for the new instance, including such things as the resources needed to display the image in the given window. \fIgetProc\fR returns a one-word token for the instance, which is typically the address of the instance data structure. @@ -219,29 +219,29 @@ Before invoking \fIdeleteProc\fR Tk will invoke \fIfreeProc\fR for each of the image's instances. \fIdeleteProc\fR must match the following prototype: .CS typedef void \fBTk_ImageDeleteProc\fR( - ClientData \fImasterData\fR); + ClientData \fImodelData\fR); .CE -The \fImasterData\fR argument will be the same as the value -stored in \fI*masterDataPtr\fR by \fIcreateProc\fR when the +The \fImodelData\fR argument will be the same as the value +stored in \fI*modelDataPtr\fR by \fIcreateProc\fR when the image was created. \fIdeleteProc\fR should release any resources associated with the image. -.SH TK_GETIMAGEMASTERDATA +.SH TK_GETIMAGEMODELDATA .PP -The procedure \fBTk_GetImageMasterData\fR may be invoked to retrieve +The procedure \fBTk_GetImageModelData\fR may be invoked to retrieve information about an image. For example, an image manager can use this -procedure to locate its image master data for an image. +procedure to locate its image model data for an image. If there exists an image named \fIname\fR in the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR is filled in with type information for the image (the \fItypePtr\fR value passed to \fBTk_CreateImageType\fR when the image type was registered) and the return value is the ClientData value returned by the \fIcreateProc\fR when the image was created (this is typically a -pointer to the image master data structure). If no such image exists +pointer to the image model data structure). If no such image exists then NULL is returned and NULL is stored at \fI*typePtrPtr\fR. .SH "LEGACY INTERFACE SUPPORT" .PP In Tk 8.2 and earlier, the definition of \fBTk_ImageCreateProc\fR was incompatibly different, with the following prototype: @@ -250,12 +250,12 @@ Tcl_Interp *\fIinterp\fR, char *\fIname\fR, int \fIargc\fR, char **\fIargv\fR, Tk_ImageType *\fItypePtr\fR, - Tk_ImageMaster \fImaster\fR, - ClientData *\fImasterDataPtr\fR); + Tk_ImageModel \fImodel\fR, + ClientData *\fImodelDataPtr\fR); .CE Legacy programs and libraries dating from those days may still contain code that defines extended Tk image types using the old interface. The Tk header file will still support this legacy interface if the code is compiled with the macro \fBUSE_OLD_IMAGE\fR @@ -278,6 +278,6 @@ Any new code written today should not make use of the legacy interfaces. Expect their support to go away in Tk 9. .SH "SEE ALSO" Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage .SH KEYWORDS -image manager, image type, instance, master +image manager, image type, instance, model Index: doc/CrtPhImgFmt.3 ================================================================== --- doc/CrtPhImgFmt.3 +++ doc/CrtPhImgFmt.3 @@ -7,28 +7,36 @@ '\" '\" Author: Paul Mackerras (paulus@cs.anu.edu.au), '\" Department of Computer Science, '\" Australian National University. '\" -.TH Tk_CreatePhotoImageFormat 3 8.5 Tk "Tk Library Procedures" +.TH Tk_CreatePhotoImageFormat 3 8.7 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_CreatePhotoImageFormat \- define new file format for photo images .SH SYNOPSIS .nf \fB#include \fR +.sp +.VS 8.7 +\fBTk_CreatePhotoImageFormatVersion3\fR(\fIformatVersion3Ptr\fR) +.VE 8.7 .sp \fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR) .SH ARGUMENTS -.AS "const Tk_PhotoImageFormat" *formatPtr +.AS "const Tk_PhotoImageFormatVersion3" *formatVersion3Ptr +.VS 8.7 +.AP "const Tk_PhotoImageFormatVersion3" *formatVersion3Ptr in +Structure that defines the new file format including metadata functionality. +.VE 8.7 .AP "const Tk_PhotoImageFormat" *formatPtr in Structure that defines the new file format. .BE .SH DESCRIPTION .PP -\fBTk_CreatePhotoImageFormat\fR is invoked to define a new file format +\fBTk_CreatePhotoImageFormatVersion3\fR is invoked to define a new file format for image data for use with photo images. The code that implements an image file format is called an image file format handler, or handler for short. The photo image code maintains a list of handlers that can be used to read and write data to or from a file. Some handlers may also @@ -35,27 +43,34 @@ support reading image data from a string or converting image data to a string format. The user can specify which handler to use with the \fB\-format\fR image configuration option or the \fB\-format\fR option to the \fBread\fR and \fBwrite\fR photo image subcommands. +.PP +The alternate version 2 function \fBTk_CreatePhotoImageFormat\fR has +identical functionality, but does not allow the handler to get or return +the metadata dictionary of the image. +It is described in section \fBVERSION 2 INTERFACE\fR below. .PP An image file format handler consists of a collection of procedures -plus a Tk_PhotoImageFormat structure, which contains the name of the -image file format and pointers to six procedures provided by the -handler to deal with files and strings in this format. The -Tk_PhotoImageFormat structure contains the following fields: +plus a \fBTk_PhotoImageFormatVersion3\fR structure, which contains the +name of the image file format and pointers to six procedures provided +by the handler to deal with files and strings in this format. The +Tk_PhotoImageFormatVersion3 structure contains the following fields: +.VS 8.7 .CS -typedef struct Tk_PhotoImageFormat { +typedef struct Tk_PhotoImageFormatVersion3 { const char *\fIname\fR; - Tk_ImageFileMatchProc *\fIfileMatchProc\fR; - Tk_ImageStringMatchProc *\fIstringMatchProc\fR; - Tk_ImageFileReadProc *\fIfileReadProc\fR; - Tk_ImageStringReadProc *\fIstringReadProc\fR; - Tk_ImageFileWriteProc *\fIfileWriteProc\fR; - Tk_ImageStringWriteProc *\fIstringWriteProc\fR; -} \fBTk_PhotoImageFormat\fR; + Tk_ImageFileMatchProcVersion3 *\fIfileMatchProc\fR; + Tk_ImageStringMatchProcVersion3 *\fIstringMatchProc\fR; + Tk_ImageFileReadProcVersion3 *\fIfileReadProc\fR; + Tk_ImageStringReadProcVersion3 *\fIstringReadProc\fR; + Tk_ImageFileWriteProcVersion3 *\fIfileWriteProc\fR; + Tk_ImageStringWriteProcVersion3 *\fIstringWriteProc\fR; +} \fBTk_PhotoImageFormatVersion3\fR; .CE +.VE 8.7 .PP The handler need not provide implementations of all six procedures. For example, the procedures that handle string data would not be provided for a format in which the image data are stored in binary, and could therefore contain null characters. If any procedure is not @@ -65,58 +80,68 @@ procedure, and the \fIstringMatchProc\fR procedure if it provides the \fIstringReadProc\fR procedure. .SS NAME .PP \fIformatPtr->name\fR provides a name for the image type. -Once \fBTk_CreatePhotoImageFormat\fR returns, this name may be used -in the \fB\-format\fR photo image configuration and subcommand option. +Once \fBTk_CreatePhotoImageFormatVersion3\fR returns, this name may be +used in the \fB\-format\fR photo image configuration and subcommand +option. The manual page for the photo image (photo(n)) describes how image file formats are chosen based on their names and the value given to the \fB\-format\fR option. The first character of \fIformatPtr->name\fR must not be an uppercase character from the ASCII character set (that is, one of the characters \fBA\fR-\fBZ\fR). Such names are used only for legacy interface support (see below). +.VS 8.7 .SS FILEMATCHPROC .PP \fIformatPtr->fileMatchProc\fR provides the address of a procedure for Tk to call when it is searching for an image file format handler suitable for reading data in a given file. \fIformatPtr->fileMatchProc\fR must match the following prototype: .CS -typedef int \fBTk_ImageFileMatchProc\fR( +typedef int \fBTk_ImageFileMatchProcVersion3\fR( + Tcl_Interp *\fIinterp\fR, Tcl_Channel \fIchan\fR, const char *\fIfileName\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, int *\fIwidthPtr\fR, int *\fIheightPtr\fR, - Tcl_Interp *\fIinterp\fR); + Tcl_Obj *\fImetadataOut\fR); .CE The \fIfileName\fR argument is the name of the file containing the image data, which is open for reading as \fIchan\fR. The \fIformat\fR argument contains the value given for the \fB\-format\fR option, or NULL if the option was not specified. +\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata +dictionary as described in section \fBMETADATA INTERFACE\fR below. If the data in the file appears to be in the format supported by this handler, the \fIformatPtr->fileMatchProc\fR procedure should store the width and height of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR respectively, and return 1. Otherwise it should return 0. .SS STRINGMATCHPROC .PP -\fIformatPtr->stringMatchProc\fR provides the address of a procedure for -Tk to call when it is searching for an image file format handler for +\fIformatPtr->stringMatchProc\fR provides the address of a procedure +for Tk to call when it is searching for an image file format handler suitable for reading data from a given string. \fIformatPtr->stringMatchProc\fR must match the following prototype: .CS -typedef int \fBTk_ImageStringMatchProc\fR( +typedef int \fBTk_ImageStringMatchProcVersion3\fR( + Tcl_Interp *\fIinterp\fR, Tcl_Obj *\fIdata\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, int *\fIwidthPtr\fR, int *\fIheightPtr\fR, - Tcl_Interp *\fIinterp\fR); + Tcl_Obj *\fImetadataOut\fR); .CE The \fIdata\fR argument points to the object containing the image data. The \fIformat\fR argument contains the value given for the \fB\-format\fR option, or NULL if the option was not specified. +\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata +dictionary as described in section \fBMETADATA INTERFACE\fR below. If the data in the string appears to be in the format supported by this handler, the \fIformatPtr->stringMatchProc\fR procedure should store the width and height of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR respectively, and return 1. Otherwise it should return 0. @@ -129,14 +154,16 @@ typedef int \fBTk_ImageFileReadProc\fR( Tcl_Interp *\fIinterp\fR, Tcl_Channel \fIchan\fR, const char *\fIfileName\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, PhotoHandle \fIimageHandle\fR, int \fIdestX\fR, int \fIdestY\fR, int \fIwidth\fR, int \fIheight\fR, - int \fIsrcX\fR, int \fIsrcY\fR); + int \fIsrcX\fR, int \fIsrcY\fR, + Tcl_Obj *\fImetadataOut\fR); .CE The \fIinterp\fR argument is the interpreter in which the command was invoked to read the image; it should be used for reporting errors. The image data is in the file named \fIfileName\fR, which is open for reading as \fIchan\fR. The \fIformat\fR argument contains the @@ -146,38 +173,44 @@ \fIimageHandle\fR. The subimage of the data in the file is of dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo image with its top-left corner at coordinates (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure. +\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata +dictionary as described in section \fBMETADATA INTERFACE\fR below. The return value is a standard Tcl return value. .SS STRINGREADPROC .PP -\fIformatPtr->stringReadProc\fR provides the address of a procedure for -Tk to call to read data from a string into a photo image. +\fIformatPtr->stringReadProc\fR provides the address of a procedure +for Tk to call to read data from a string into a photo image. \fIformatPtr->stringReadProc\fR must match the following prototype: .CS typedef int \fBTk_ImageStringReadProc\fR( Tcl_Interp *\fIinterp\fR, Tcl_Obj *\fIdata\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, PhotoHandle \fIimageHandle\fR, int \fIdestX\fR, int \fIdestY\fR, int \fIwidth\fR, int \fIheight\fR, - int \fIsrcX\fR, int \fIsrcY\fR); + int \fIsrcX\fR, int \fIsrcY\fR, + Tcl_Obj *\fImetadataOut\fR); .CE The \fIinterp\fR argument is the interpreter in which the command was invoked to read the image; it should be used for reporting errors. The \fIdata\fR argument points to the image data in object form. The \fIformat\fR argument contains the value given for the \fB\-format\fR option, or NULL if the option was -not specified. The image data in the string, or a subimage of it, is to -be read into the photo image identified by the handle +not specified. The image data in the string, or a subimage of it, is +to be read into the photo image identified by the handle \fIimageHandle\fR. The subimage of the data in the string is of dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo image with its top-left corner at coordinates (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure. +\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata +dictionary as described in section \fBMETADATA INTERFACE\fR below. The return value is a standard Tcl return value. .SS FILEWRITEPROC .PP \fIformatPtr->fileWriteProc\fR provides the address of a procedure for Tk to call to write data from a photo image to a file. @@ -185,10 +218,11 @@ .CS typedef int \fBTk_ImageFileWriteProc\fR( Tcl_Interp *\fIinterp\fR, const char *\fIfileName\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, Tk_PhotoImageBlock *\fIblockPtr\fR); .CE The \fIinterp\fR argument is the interpreter in which the command was invoked to write the image; it should be used for reporting errors. The image data to be written are in memory and are described by the @@ -199,20 +233,24 @@ value given for the \fB\-format\fR option, or NULL if the option was not specified. The format string can contain extra characters after the name of the format. If appropriate, the \fIformatPtr->fileWriteProc\fR procedure may interpret these characters to specify further details about the image file. +\fBmetadataIn\fR may contain metadata keys that a driver may include +into the output data. The return value is a standard Tcl return value. .SS STRINGWRITEPROC .PP -\fIformatPtr->stringWriteProc\fR provides the address of a procedure for -Tk to call to translate image data from a photo image into a string. +\fIformatPtr->stringWriteProc\fR provides the address of a procedure +for Tk to call to translate image data from a photo image into a +string. \fIformatPtr->stringWriteProc\fR must match the following prototype: .CS typedef int \fBTk_ImageStringWriteProc\fR( Tcl_Interp *\fIinterp\fR, Tcl_Obj *\fIformat\fR, + Tcl_Obj *\fImetadataIn\fR, Tk_PhotoImageBlock *\fIblockPtr\fR); .CE The \fIinterp\fR argument is the interpreter in which the command was invoked to convert the image; it should be used for reporting errors. The image data to be converted are in memory and are described by the @@ -223,11 +261,205 @@ value given for the \fB\-format\fR option, or NULL if the option was not specified. The format string can contain extra characters after the name of the format. If appropriate, the \fIformatPtr->stringWriteProc\fR procedure may interpret these characters to specify further details about the image file. +\fBmetadataIn\fR may contain metadata keys that a driver may include +into the output data. The return value is a standard Tcl return value. +.PP +.SH "METADATA INTERFACE" +.PP +Image formats contain a description of the image bitmap and may +contain additional information like image resolution or comments. +Image metadata may be read from image files and passed to the script +level by including dictionary keys into the metadata property of the +image. Image metadata may be written to image data on file write or +image data output. +.PP +.PP +.SS "METADATA KEYS" +.PP +The metadata may contain any key. +A driver will handle only a set of dictionary keys documented in the +documentation. See the photo image manual page for currently defined +keys for the system drivers. +.PP +The following rules may give guidance to name metadata keys: +.RS +Abreviation are in upper case +.RE +.RS +Words are in US English in small case (except proper nouns) +.RE +.RS +Vertical DPI is expressed as DPI/aspect. The reason is, that some +image formats may feature aspect and no resolution value. +.RE +.SS "METADATA INPUT" +.PP +Each driver function gets a Tcl object pointer \fBmetadataIn\fR as +parameter. This parameter serves to input a metadata dict to the +driver function. +It may be NULL to flag that the metadata dict is empty. +.PP +A typical driver code snipped to check for a metadata key is: +.CS +if (NULL != metadataIn) { + Tcl_Obj *itemData; + Tcl_DictObjGet(interp, metadataIn, Tcl_NewStringObj("Comment",-1), &itemData)); +.CE +.PP +The \-metadata command option data of the following commands is passed +to the driver: \fBimage create\fR, \fBconfigure\fR, \fBput\fR, +\fBread\fR, \fBdata\fR and \fBwrite\fR. +If no \-metadata command option available or not given, the metadata +property of the image is passed to the driver using the following +commands: \fBcget\fR, \fBconfigure\fR, \fBdata\fR and \fBwrite\fR. +.PP +Note that setting the \-metadata property of an image using +\fBconfigure\fR without any other option does not invoke any driver +function. +.PP +The metadata dictionary is not suited to pass options to the driver +related to the bitmap representation, as the image bitmap is not +recreated on a metadata change. The format string should be used for +this purpose. +.PP +.SS "METADATA OUTPUT" +.PP +The image match and read driver functions may set keys in a prepared +matadata dict to return them. +Those functions get a Tcl object pointer \fBmetadataOut\fR as +parameter. +metadataOut may be NULL to indicate, that no metadata return is +attended(\fBput\fR, \fBread\fR subcommands). +\fBmetadataOut\fR is initialized to an empty unshared dict object if +metadata return is attended (\fBimage create\fR command, \fBconfigure\fR +subcommand). The driver may set dict keys in this object to return +metadata. +If a match function succeeds, the metadataOut pointer is passed to the +corresponding read function. +.PP +A sample driver code snippet is: +.CS +if (NULL != metadataOut) { + Tcl_DictObjPut(NULL, metadataOut, Tcl_NewStringObj("XMP",-1), Tcl_NewStringObj(xmpMetadata); +.CE +.PP +The metadata keys returned by the driver are merged into the present +metadata property of the image or into the metadata dict given by the +\fB\-metadata\fR command line option. +At the script level, the command \fBimage create\fR and the +\fBconfigure\fR method may return metadata from the driver. +.PP +Format string options or metadata keys may influence the creation of +metadata within the driver. +For example, the creation of an expensive metadata key may depend on a +format string option or on a metadata input key. +.PP +.VE 8.7 +.SH "VERSION 2 INTERFACE" +.PP +Version 2 Interface does not include the possibility for the driver to +use the metadata dict for input or output. +.SS SYNOPSIS +\fB#include \fR +.sp +\fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR) +.SS ARGUMENTS +.AS "const Tk_PhotoImageFormat" *formatPtr +.AP "const Tk_PhotoImageFormat" *formatPtr in +Structure that defines the new file format. +.BE +.SS DESCRIPTION +A driver using the version 2 interface invokes \fBTk_CreatePhotoImageFormat\fR +for driver registration. The Tk_PhotoImageFormat structure +contains the following fields: +.CS +typedef struct Tk_PhotoImageFormat { + const char *\fIname\fR; + Tk_ImageFileMatchProc *\fIfileMatchProc\fR; + Tk_ImageStringMatchProc *\fIstringMatchProc\fR; + Tk_ImageFileReadProc *\fIfileReadProc\fR; + Tk_ImageStringReadProc *\fIstringReadProc\fR; + Tk_ImageFileWriteProc *\fIfileWriteProc\fR; + Tk_ImageStringWriteProc *\fIstringWriteProc\fR; +} \fBTk_PhotoImageFormat\fR; +.CE +.PP +.SS FILEMATCHPROC +.PP +\fIformatPtr->fileMatchProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageFileMatchProc\fR( + Tcl_Channel \fIchan\fR, + const char *\fIfileName\fR, + Tcl_Obj *\fIformat\fR, + int *\fIwidthPtr\fR, + int *\fIheightPtr\fR, + Tcl_Interp *\fIinterp\fR); +.CE +.PP +.SS STRINGMATCHPROC +.PP +\fIformatPtr->stringMatchProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageStringMatchProc\fR( + Tcl_Obj *\fIdata\fR, + Tcl_Obj *\fIformat\fR, + int *\fIwidthPtr\fR, + int *\fIheightPtr\fR, + Tcl_Interp *\fIinterp\fR); +.CE +.SS FILEREADPROC +.PP +\fIformatPtr->fileReadProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageFileReadProc\fR( + Tcl_Interp *\fIinterp\fR, + Tcl_Channel \fIchan\fR, + const char *\fIfileName\fR, + Tcl_Obj *\fIformat\fR, + PhotoHandle \fIimageHandle\fR, + int \fIdestX\fR, int \fIdestY\fR, + int \fIwidth\fR, int \fIheight\fR, + int \fIsrcX\fR, int \fIsrcY\fR); +.CE +.SS STRINGREADPROC +.PP +\fIformatPtr->stringReadProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageStringReadProc\fR( + Tcl_Interp *\fIinterp\fR, + Tcl_Obj *\fIdata\fR, + Tcl_Obj *\fIformat\fR, + PhotoHandle \fIimageHandle\fR, + int \fIdestX\fR, int \fIdestY\fR, + int \fIwidth\fR, int \fIheight\fR, + int \fIsrcX\fR, int \fIsrcY\fR); +.CE +.SS FILEWRITEPROC +.PP +\fIformatPtr->fileWriteProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageFileWriteProc\fR( + Tcl_Interp *\fIinterp\fR, + const char *\fIfileName\fR, + Tcl_Obj *\fIformat\fR, + Tk_PhotoImageBlock *\fIblockPtr\fR); +.CE +.SS STRINGWRITEPROC +.PP +\fIformatPtr->stringWriteProc\fR must match the following prototype: +.CS +typedef int \fBTk_ImageStringWriteProc\fR( + Tcl_Interp *\fIinterp\fR, + Tcl_Obj *\fIformat\fR, + Tk_PhotoImageBlock *\fIblockPtr\fR); +.CE +.PP .SH "LEGACY INTERFACE SUPPORT" .PP In Tk 8.2 and earlier, the definition of all the function pointer types stored in fields of a \fBTk_PhotoImageFormat\fR struct were incompatibly different. Legacy programs and libraries dating from Index: doc/EventHndlr.3 ================================================================== --- doc/EventHndlr.3 +++ doc/EventHndlr.3 @@ -7,20 +7,30 @@ '\" .TH Tk_CreateEventHandler 3 "" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_CreateEventHandler, Tk_DeleteEventHandler \- associate procedure callback with an X event +Tk_CreateEventHandler, Tk_DeleteEventHandler, Tk_GetButtonMask, Tk_SendVirtualEvent \- associate procedure callback with an X event .SH SYNOPSIS .nf \fB#include \fR .sp \fBTk_CreateEventHandler\fR(\fItkwin, mask, proc, clientData\fR) .sp \fBTk_DeleteEventHandler\fR(\fItkwin, mask, proc, clientData\fR) +.sp +\fBTk_GetButtonMask\fR(\fIbutton\fR) +.sp +\fBTk_SendVirtualEvent\fR(\fItkwin, eventName, detail\fR) .SH ARGUMENTS .AS "unsigned long" clientData +.AP unsigned button in +Button number. +.AP "const char" *eventName in +The name of the virtual event. +.AP Tcl_Obj *detail in +Detail information for the virtual event. .AP Tk_Window tkwin in Token for window in which events may occur. .AP "unsigned long" mask in Bit-mask of events (such as \fBButtonPressMask\fR) for which \fIproc\fR should be called. @@ -69,7 +79,12 @@ \fBTk_DeleteEventHandler\fR. .PP If multiple handlers are declared for the same type of X event on the same window, then the handlers will be invoked in the order they were created. +.PP +\fBTk_GetButtonMask\fR returns the button mask corresponding to +the button. E.g it will return \fIButton1Mask\fR for button \fIButton1\fR. +.PP +\fBTk_SendVirtualEvent\fR sends a virtual event to Tk's event queue. .SH KEYWORDS bind, callback, event, handler Index: doc/GetFont.3 ================================================================== --- doc/GetFont.3 +++ doc/GetFont.3 @@ -7,11 +7,11 @@ '\" .TH Tk_AllocFontFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_AllocFontFromObj, Tk_GetFont, Tk_GetFontFromObj, Tk_NameOfFont, Tk_FreeFontFromObj, Tk_FreeFont \- maintain database of fonts +Tk_AllocFontFromObj, Tk_GetFont, Tk_GetFontFromObj, Tk_NameOfFont, Tk_FontGetDescription, Tk_FreeFontFromObj, Tk_FreeFont \- maintain database of fonts .SH SYNOPSIS .nf \fB#include \fR .sp Tk_Font @@ -21,10 +21,13 @@ \fBTk_GetFont(\fIinterp, tkwin, string\fB)\fR .sp Tk_Font \fBTk_GetFontFromObj(\fItkwin, objPtr\fB)\fR .sp +Tcl_Obj * +\fBTk_FontGetDescription(\fItkfont\fB)\fR +.sp const char * \fBTk_NameOfFont(\fItkfont\fB)\fR .sp Tk_Font \fBTk_FreeFontFromObj(\fItkwin, objPtr\fB)\fR @@ -86,10 +89,13 @@ the same font is requested multiple times (e.g. by different windows or for different purposes), then a single Tk_Font will be shared for all uses. The underlying resources will be freed automatically when no-one is using the font anymore. .PP +The procedure \fBTk_FontGetDescription\fR returns information about the font +description as a Tcl list. One possible result is "{{DejaVu Sans} -16 bold underline}". +.PP The procedure \fBTk_NameOfFont\fR is roughly the inverse of \fBTk_GetFont\fR. Given a \fItkfont\fR that was created by \fBTk_GetFont\fR (or \fBTk_AllocFontFromObj\fR), the return value is the \fIstring\fR argument that was passed to \fBTk_GetFont\fR to create the font. The string returned by Index: doc/GetHINSTANCE.3 ================================================================== --- doc/GetHINSTANCE.3 +++ doc/GetHINSTANCE.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_GetHISTANCE 3 "" Tk "Tk Library Procedures" .so man.macros .BS Index: doc/GetHWND.3 ================================================================== --- doc/GetHWND.3 +++ doc/GetHWND.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH HWND 3 8.0 Tk "Tk Library Procedures" .so man.macros .BS Index: doc/GetPixels.3 ================================================================== --- doc/GetPixels.3 +++ doc/GetPixels.3 @@ -7,18 +7,21 @@ '\" .TH Tk_GetPixelsFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM \- translate between strings and screen units +Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM, Tk_GetDoublePixelsFromObj \- translate between strings and screen units .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTk_GetPixelsFromObj(\fIinterp, tkwin, objPtr, intPtr\fB)\fR .sp +int +\fBTk_GetDoublePixelsFromObj(\fIinterp, tkwin, objPtr, doublePtr\fB)\fR +.sp int \fBTk_GetPixels(\fIinterp, tkwin, string, intPtr\fB)\fR .sp int \fBTk_GetMMFromObj(\fIinterp, tkwin, objPtr, doublePtr\fB)\fR @@ -78,10 +81,13 @@ \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's result if \fIinterp\fR is not NULL. \fBTk_GetPixelsFromObj\fR caches information about the return value in \fIobjPtr\fR, which speeds up future calls to \fBTk_GetPixelsFromObj\fR with the same \fIobjPtr\fR. +.PP +\fBTk_GetDoublePixelsFromObj\fR is identical to \fBTk_GetPixelsFromObj\fR +except it returns a double not rounded to the nearest integer. .PP \fBTk_GetPixels\fR is identical to \fBTk_GetPixelsFromObj\fR except that the screen distance is specified with a string instead of an object. This prevents \fBTk_GetPixels\fR from caching the return value, so \fBTk_GetPixels\fR is less efficient than Index: doc/GetScroll.3 ================================================================== --- doc/GetScroll.3 +++ doc/GetScroll.3 @@ -23,17 +23,17 @@ .AS "Tcl_Interp" *fractionPtr .AP Tcl_Interp *interp in Interpreter to use for error reporting. .AP int objc in Number of Tcl_Obj's in \fIobjv\fR array. -.AP "Tcl_Obj *const" objv[] in +.AP "Tcl_Obj *const *" objv in Argument objects. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically \fBxview\fR or \fByview\fR. .AP int argc in Number of strings in \fIargv\fR array. -.AP "const char" *argv[] in +.AP "const char **" argv in Argument strings. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically \fBxview\fR or \fByview\fR. .AP double *fractionPtr out Filled in with fraction from \fBmoveto\fR option, if any. @@ -60,11 +60,12 @@ is returned as result and \fI*fractionPtr\fR is filled in with the \fIfraction\fR argument to the command, which must be a proper real value. If \fIobjv\fR has the \fBscroll\fR form, \fBTK_SCROLL_PAGES\fR or \fBTK_SCROLL_UNITS\fR is returned and \fI*stepsPtr\fR is filled -in with the \fInumber\fR value, which must be a proper integer. +in with the \fInumber\fR value, which must be a integer or a float, +but if it is a float then it is converted to an integer, rounded away from 0. If an error occurs in parsing the arguments, \fBTK_SCROLL_ERROR\fR is returned and an error message is left in interpreter \fIinterp\fR's result. .PP \fBTk_GetScrollInfo\fR is identical in function to Index: doc/Grab.3 ================================================================== --- doc/Grab.3 +++ doc/Grab.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_Grab 3 "" Tk "Tk Library Procedures" .so man.macros .BS Index: doc/HWNDToWindow.3 ================================================================== --- doc/HWNDToWindow.3 +++ doc/HWNDToWindow.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_HWNDToWindow 3 "" Tk "Tk Library Procedures" .so man.macros .BS Index: doc/ImgChanged.3 ================================================================== --- doc/ImgChanged.3 +++ doc/ImgChanged.3 @@ -12,14 +12,14 @@ Tk_ImageChanged \- notify widgets that image needs to be redrawn .SH SYNOPSIS .nf \fB#include \fR .sp -\fBTk_ImageChanged\fR(\fIimageMaster, x, y, width, height, imageWidth, imageHeight\fR) +\fBTk_ImageChanged\fR(\fImodel, x, y, width, height, imageWidth, imageHeight\fR) .SH ARGUMENTS -.AS Tk_ImageMaster imageHeight -.AP Tk_ImageMaster imageMaster in +.AS Tk_ImageModel imageHeight +.AP Tk_ImageModel model in Token for image, which was passed to image's \fIcreateProc\fR when the image was created. .AP int x in X-coordinate of upper-left corner of region that needs redisplay (measured from upper-left corner of image). @@ -40,11 +40,11 @@ An image manager calls \fBTk_ImageChanged\fR for an image whenever anything happens that requires the image to be redrawn. As a result of calling \fBTk_ImageChanged\fR, any widgets using the image are notified so that they can redisplay themselves appropriately. -The \fIimageMaster\fR argument identifies the image, and +The \fImodel\fR argument identifies the image, and \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR specify a rectangular region within the image that needs to be redrawn. \fIimageWidth\fR and \fIimageHeight\fR specify the image's (new) size. .PP Index: doc/Inactive.3 ================================================================== --- doc/Inactive.3 +++ doc/Inactive.3 @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_GetUserInactiveTime 3 8.5 Tk "Tk Library Procedures" .so man.macros .BS Index: doc/MaintGeom.3 ================================================================== --- doc/MaintGeom.3 +++ doc/MaintGeom.3 @@ -12,88 +12,88 @@ Tk_MaintainGeometry, Tk_UnmaintainGeometry \- maintain geometry of one window relative to another .SH SYNOPSIS .nf \fB#include \fR .sp -\fBTk_MaintainGeometry\fR(\fIslave, master, x, y, width, height\fR) +\fBTk_MaintainGeometry\fR(\fIwindow, container, x, y, width, height\fR) .sp -\fBTk_UnmaintainGeometry\fR(\fIslave, master\fR) +\fBTk_UnmaintainGeometry\fR(\fIwindow, container\fR) .SH ARGUMENTS -.AS Tk_Window master -.AP Tk_Window slave in +.AS Tk_Window container +.AP Tk_Window window in Window whose geometry is to be controlled. -.AP Tk_Window master in -Window relative to which \fIslave\fR's geometry will be controlled. +.AP Tk_Window container in +Window relative to which \fIwindow\fR's geometry will be controlled. .AP int x in -Desired x-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels -from the inside of \fImaster\fR's left border to the outside of -\fIslave\fR's left border. +Desired x-coordinate of \fIwindow\fR in \fIcontainer\fR, measured in pixels +from the inside of \fIcontainer\fR's left border to the outside of +\fIwindow\fR's left border. .AP int y in -Desired y-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels -from the inside of \fImaster\fR's top border to the outside of -\fIslave\fR's top border. +Desired y-coordinate of \fIwindow\fR in \fIcontainer\fR, measured in pixels +from the inside of \fIcontainer\fR's top border to the outside of +\fIwindow\fR's top border. .AP int width in -Desired width for \fIslave\fR, in pixels. +Desired width for \fIwindow\fR, in pixels. .AP int height in -Desired height for \fIslave\fR, in pixels. +Desired height for \fIwindow\fR, in pixels. .BE .SH DESCRIPTION .PP \fBTk_MaintainGeometry\fR and \fBTk_UnmaintainGeometry\fR make it -easier for geometry managers to deal with slaves whose masters are not +easier for geometry managers to deal with windows whose containers are not their parents. -Three problems arise if the master for a slave is not its parent: +Three problems arise if the container for a window is not its parent: .IP [1] -The x- and y-position of the slave must be translated from the -coordinate system of the master to that of the parent before -positioning the slave. +The x- and y-position of the window must be translated from the +coordinate system of the container to that of the parent before +positioning the window. .IP [2] -If the master window, or any of its ancestors up to the slave's -parent, is moved, then the slave must be repositioned within its +If the container window, or any of its ancestors up to the window's +parent, is moved, then the window must be repositioned within its parent in order to maintain the correct position relative to the -master. +container. .IP [3] -If the master or one of its ancestors is mapped or unmapped, then -the slave must be mapped or unmapped to correspond. +If the container or one of its ancestors is mapped or unmapped, then +the window must be mapped or unmapped to correspond. .LP -None of these problems is an issue if the parent and master are -the same. For example, if the master or one of its ancestors -is unmapped, the slave is automatically removed by the screen +None of these problems is an issue if the parent and container are +the same. For example, if the container or one of its ancestors +is unmapped, the window is automatically removed by the screen by X. .PP -\fBTk_MaintainGeometry\fR deals with these problems for slaves -whose masters are not their parents, as well as handling the simpler -case of slaves whose masters are their parents. +\fBTk_MaintainGeometry\fR deals with these problems for windows +whose containers are not their parents, as well as handling the simpler +case of windows whose container are their parents. \fBTk_MaintainGeometry\fR is typically called by a window manager -once it has decided where a slave should be positioned relative -to its master. +once it has decided where a window should be positioned relative +to its container. \fBTk_MaintainGeometry\fR translates the coordinates to the -coordinate system of \fIslave\fR's parent and then moves and -resizes the slave appropriately. +coordinate system of \fIwindow\fR's parent and then moves and +resizes the window appropriately. Furthermore, it remembers the desired position and creates event -handlers to monitor the master and all of its ancestors up -to (but not including) the slave's parent. +handlers to monitor the container and all of its ancestors up +to (but not including) the window's parent. If any of these windows is moved, mapped, or unmapped, -the slave will be adjusted so that it is mapped only when the -master is mapped and its geometry relative to the master +the window will be adjusted so that it is mapped only when the +container is mapped and its geometry relative to the container remains as specified by \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR. .PP When a window manager relinquishes control over a window, or if it decides that it does not want the window to appear on the screen under any conditions, it calls \fBTk_UnmaintainGeometry\fR. \fBTk_UnmaintainGeometry\fR unmaps the window and cancels any previous calls to \fBTk_MaintainGeometry\fR for the -\fImaster\fR\-\fIslave\fR pair, so that the slave's +\fIcontainer\fR\-\fIwindow\fR pair, so that the window's geometry and mapped state are no longer maintained automatically. \fBTk_UnmaintainGeometry\fR need not be called by a geometry -manager if the slave, the master, or any of the master's ancestors +manager if the window, the container, or any of the container's ancestors is destroyed: Tk will call it automatically. .PP If \fBTk_MaintainGeometry\fR is called repeatedly for the same -\fImaster\fR\-\fIslave\fR pair, the information from the most +\fIcontainer\fR\-\fIwindow\fR pair, the information from the most recent call supersedes any older information. -If \fBTk_UnmaintainGeometry\fR is called for a \fImaster\fR\-\fIslave\fR +If \fBTk_UnmaintainGeometry\fR is called for a \fIcontainer\fR\-\fIwindow\fR pair that is is not currently managed, the call has no effect. .SH KEYWORDS -geometry manager, map, master, parent, position, slave, unmap +geometry manager, map, container, parent, position, window, unmap Index: doc/ManageGeom.3 ================================================================== --- doc/ManageGeom.3 +++ doc/ManageGeom.3 @@ -30,11 +30,11 @@ .BE .SH DESCRIPTION .PP \fBTk_ManageGeometry\fR arranges for a particular geometry manager, described by the \fImgrPtr\fR argument, to control the geometry -of a particular slave window, given by \fItkwin\fR. +of a particular content window, given by \fItkwin\fR. If \fItkwin\fR was previously managed by some other geometry manager, the previous manager loses control in favor of the new one. If \fImgrPtr\fR is NULL, geometry management is cancelled for \fItkwin\fR. .PP @@ -42,20 +42,20 @@ the geometry manager: .CS typedef struct { const char *\fIname\fR; Tk_GeomRequestProc *\fIrequestProc\fR; - Tk_GeomLostSlaveProc *\fIlostSlaveProc\fR; + Tk_GeomLostContentProc *\fIlostContentProc\fR; } \fBTk_GeomMgr\fR; .CE The \fIname\fR field is the textual name for the geometry manager, such as \fBpack\fR or \fBplace\fR; this value will be returned by the command \fBwinfo manager\fR. .PP \fIrequestProc\fR is a procedure in the geometry manager that will be invoked whenever \fBTk_GeometryRequest\fR is called by the -slave to change its desired geometry. +content window to change its desired geometry. \fIrequestProc\fR should have arguments and results that match the type \fBTk_GeomRequestProc\fR: .CS typedef void \fBTk_GeomRequestProc\fR( ClientData \fIclientData\fR, @@ -65,26 +65,26 @@ corresponding parameters passed to \fBTk_ManageGeometry\fR. \fIclientData\fR usually points to a data structure containing application-specific information about how to manage \fItkwin\fR's geometry. .PP -The \fIlostSlaveProc\fR field of \fImgrPtr\fR points to another +The \fIlostContentProc\fR field of \fImgrPtr\fR points to another procedure in the geometry manager. -Tk will invoke \fIlostSlaveProc\fR if some other manager +Tk will invoke \fIlostContentProc\fR if some other manager calls \fBTk_ManageGeometry\fR to claim \fItkwin\fR away from the current geometry manager. -\fIlostSlaveProc\fR is not invoked if \fBTk_ManageGeometry\fR is +\fIlostContentProc\fR is not invoked if \fBTk_ManageGeometry\fR is called with a NULL value for \fImgrPtr\fR (presumably the current geometry manager has made this call, so it already knows that the window is no longer managed), nor is it called if \fImgrPtr\fR is the same as the window's current geometry manager. -\fIlostSlaveProc\fR should have +\fIlostContentProc\fR should have arguments and results that match the following prototype: .CS -typedef void \fBTk_GeomLostSlaveProc\fR( +typedef void \fBTk_GeomLostContentProc\fR( ClientData \fIclientData\fR, Tk_Window \fItkwin\fR); .CE -The parameters to \fIlostSlaveProc\fR will be identical to the +The parameters to \fIlostContentProc\fR will be identical to the corresponding parameters passed to \fBTk_ManageGeometry\fR. .SH KEYWORDS callback, geometry, managed, request, unmanaged Index: doc/NameOfImg.3 ================================================================== --- doc/NameOfImg.3 +++ doc/NameOfImg.3 @@ -12,14 +12,14 @@ .SH SYNOPSIS .nf \fB#include \fR .sp const char * -\fBTk_NameOfImage\fR(\fIimageMaster\fR) +\fBTk_NameOfImage\fR(\fIimageModel\fR) .SH ARGUMENTS -.AS Tk_ImageMaster imageMaster -.AP Tk_ImageMaster imageMaster in +.AS Tk_ImageModel imageModel +.AP Tk_ImageModel imageModel in Token for image, which was passed to image manager's \fIcreateProc\fR when the image was created. .BE .SH DESCRIPTION .PP Index: doc/SetOptions.3 ================================================================== --- doc/SetOptions.3 +++ doc/SetOptions.3 @@ -58,11 +58,11 @@ the window in which the option will be used. If \fIoptionTable\fR uses no window-dependent options, then a NULL value may be supplied for this argument. .AP int objc in Number of values in \fIobjv\fR. -.AP Tcl_Obj "*const objv[]" in +.AP Tcl_Obj "*const *objv" in Command-line arguments for setting configuring options. .AP Tk_SavedOptions *savePtr out If not NULL, the structure pointed to by this argument is filled in with the old values of any options that were modified and old values are restored automatically if an error occurs in \fBTk_SetOptions\fR. Index: doc/WindowId.3 ================================================================== --- doc/WindowId.3 +++ doc/WindowId.3 @@ -7,11 +7,11 @@ '\" .TH Tk_WindowId 3 "8.4" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_InternalBorderLeft, Tk_InternalBorderRight, Tk_InternalBorderTop, Tk_InternalBorderBottom, Tk_Visual, Tk_Depth, Tk_Colormap, Tk_Interp \- retrieve information from Tk's local data structure +Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_AlwaysShowSelection, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_InternalBorderLeft, Tk_InternalBorderRight, Tk_InternalBorderTop, Tk_InternalBorderBottom, Tk_Visual, Tk_Depth, Tk_Colormap, Tk_Interp, Tk_NewWindowObj \- retrieve information from Tk's local data structure .SH SYNOPSIS .nf \fB#include \fR .sp Window @@ -27,10 +27,13 @@ \fBTk_DisplayName\fR(\fItkwin\fR) .sp int \fBTk_ScreenNumber\fR(\fItkwin\fR) .sp +int +\fBTk_AlwaysShowSelection\fR(\fItkwin\fR) +.sp Screen * \fBTk_Screen\fR(\fItkwin\fR) .sp int \fBTk_X\fR(\fItkwin\fR) @@ -95,10 +98,13 @@ Colormap \fBTk_Colormap\fR(\fItkwin\fR) .sp Tcl_Interp * \fBTk_Interp\fR(\fItkwin\fR) +.sp +Tcl_Obj * +\fBTk_NewWindowObj\fR(\fItkwin\fR) .SH ARGUMENTS .AS Tk_Window tkwin .AP Tk_Window tkwin in Token for window. .BE @@ -125,10 +131,12 @@ corresponding to \fItkwin\fR. \fBTk_DisplayName\fR returns an ASCII string identifying \fItkwin\fR's display. \fBTk_ScreenNumber\fR returns the index of \fItkwin\fR's screen among all the screens of \fItkwin\fR's display. \fBTk_Screen\fR returns a pointer to the Xlib structure corresponding to \fItkwin\fR's screen. +\fBTk_AlwaysShowSelection\fR indicates whether text/entry widgets +should always display their selection, regardless of window focus. .PP \fBTk_X\fR, \fBTk_Y\fR, \fBTk_Width\fR, and \fBTk_Height\fR return information about \fItkwin's\fR location within its parent and its size. The location information refers to the upper-left pixel in the window, or its border if there is one. @@ -180,9 +188,11 @@ the window, \fBTk_Depth\fR returns the number of bits per pixel, and \fBTk_Colormap\fR returns the current colormap for the window. The visual characteristics are normally set from the defaults for the window's screen, but they may be overridden by calling \fBTk_SetWindowVisual\fR. +.PP +\fBTk_NewWindowObj\fR creates a new \fBTcl_Obj\fR from the window. .SH KEYWORDS attributes, colormap, depth, display, height, geometry manager, identifier, mapped, requested size, screen, top-level, visual, width, window, x, y Index: doc/bind.n ================================================================== --- doc/bind.n +++ doc/bind.n @@ -1,9 +1,9 @@ '\" '\" Copyright (c) 1990 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. -'\" Copyright (c) 1998 by Scriptics Corporation. +'\" Copyright (c) 1998 Scriptics Corporation. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH bind n 8.0 Tk "Tk Built-In Commands" @@ -199,18 +199,30 @@ substitutions you would make when binding to these events. .IP \fBMouseWheel\fR 5 Many contemporary mice support a mouse wheel, which is used for scrolling documents without using the scrollbars. By rolling the wheel, the system will generate \fBMouseWheel\fR events that the -application can use to scroll. Like \fBKey\fR events the event is -always routed to the window that currently has focus. When the event +application can use to scroll. The event is routed to the +window currently under the mouse pointer. When the event is received you can use the \fB%D\fR substitution to get the -\fIdelta\fR field for the event, which is a integer value describing how +\fIdelta\fR field for the event, which is an integer value describing how the mouse wheel has moved. The smallest value for which the -system will report is defined by the OS. The sign of the +system will report is defined by the OS. The sign of the value determines which direction your widget should scroll. Positive values should scroll up and negative values should scroll down. +.RS +.PP +Horizontal scrolling uses \fBShift-MouseWheel\fR events, with positive +\fB%D\fR \fIdelta\fR substitution indicating left scrolling and negative +right scrolling. +Horizontal scrolling events may fire from +many different hardware units such as tilt wheels or touchpads. Horizontal +scrolling can also be emulated by holding Shift and scrolling vertically. +.RE +.IP "\fBKeyPress\fR, \fBKeyRelease\fR" 5 +The \fBKeyPress\fR and \fBKeyRelease\fR events are generated +whenever a key is pressed or released. \fBKeyPress\fR and \fBKeyRelease\fR .IP "\fBKey\fR, \fBKeyRelease\fR" 5 The \fBKey\fR and \fBKeyRelease\fR events are generated whenever a key is pressed or released. \fBKey\fR and \fBKeyRelease\fR events are sent to the window which currently has the keyboard focus. .IP "\fBButton\fR, \fBButtonRelease\fR, \fBMotion\fR" 5 @@ -268,11 +280,12 @@ .RS .PP When the \fBDestroy\fR event is delivered to a widget, it is in a .QW half-dead -state: the widget still exists, but most operations on it will fail. +state: the widget still exists, but operations that involve it +may return invalid results, or return an error. .RE .IP "\fBFocusIn\fR, \fBFocusOut\fR" 5 The \fBFocusIn\fR and \fBFocusOut\fR events are generated whenever the keyboard focus changes. A \fBFocusOut\fR event is sent to the old focus window, Index: doc/bitmap.n ================================================================== --- doc/bitmap.n +++ doc/bitmap.n @@ -88,11 +88,11 @@ whose name is the same as the image. This command may be used to invoke various operations on the image. It has the following general form: .CS -\fIimageName option \fR?\fIarg arg ...\fR? +\fIimageName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for bitmap images: .TP Index: doc/button.n ================================================================== --- doc/button.n +++ doc/button.n @@ -107,11 +107,11 @@ The \fBbutton\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for button widgets: .TP Index: doc/canvas.n ================================================================== --- doc/canvas.n +++ doc/canvas.n @@ -346,17 +346,17 @@ The \fBcanvas\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following widget commands are possible for canvas widgets: .TP -\fIpathName \fBaddtag \fItag searchSpec \fR?\fIarg arg ...\fR? +\fIpathName \fBaddtag \fItag searchSpec \fR?\fIarg ...\fR? . For each item that meets the constraints specified by \fIsearchSpec\fR and the \fIarg\fRs, add \fItag\fR to the list of tags associated with the item if it is not already present on that list. @@ -600,11 +600,11 @@ If an item does not have the tag \fItagToDelete\fR then the item is unaffected by the command. If \fItagToDelete\fR is omitted then it defaults to \fItagOrId\fR. This command returns an empty string. .TP -\fIpathName \fBfind \fIsearchCommand \fR?\fIarg arg ...\fR? +\fIpathName \fBfind \fIsearchCommand \fR?\fIarg ...\fR? . This command returns a list consisting of all the items that meet the constraints specified by \fIsearchCommand\fR and \fIarg\fR's. \fISearchCommand\fR and \fIargs\fR have any of the forms @@ -1145,11 +1145,12 @@ .TP \fIpathName \fBxview scroll \fInumber what\fR . This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. -\fINumber\fR must be an integer. +\fINumber\fR must be an integer or a float, but if it is a float then +it is converted to an integer, rounded away from 0. \fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. If \fIwhat is \fBpages\fR then the view adjusts in units of nine-tenths the window's width. If \fInumber\fR is negative then information farther to the left @@ -1158,11 +1159,11 @@ If \fIwhat\fR is \fBunits\fR, the view adjusts left or right in units of the \fBxScrollIncrement\fR option, if it is greater than zero, or in units of one-tenth the window's width otherwise. .RE .TP -\fIpathName \fByview \fI?args\fR? +\fIpathName \fByview ?\fIargs\fR? . This command is used to query and change the vertical position of the information displayed in the canvas's window. It can take any of the following forms: .RS Index: doc/checkbutton.n ================================================================== --- doc/checkbutton.n +++ doc/checkbutton.n @@ -190,11 +190,11 @@ The \fBcheckbutton\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for checkbutton widgets: .TP Index: doc/chooseDirectory.n ================================================================== --- doc/chooseDirectory.n +++ doc/chooseDirectory.n @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH tk_chooseDirectory n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS Index: doc/clipboard.n ================================================================== --- doc/clipboard.n +++ doc/clipboard.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME clipboard \- Manipulate Tk clipboard .SH SYNOPSIS -\fBclipboard \fIoption\fR ?\fIarg arg ...\fR? +\fBclipboard \fIoption\fR ?\fIarg ...\fR? .BE .SH DESCRIPTION .PP This command provides a Tcl interface to the Tk clipboard, which stores data for later retrieval using the selection mechanism Index: doc/colors.n ================================================================== --- doc/colors.n +++ doc/colors.n @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" Copyright (c) 2003 ActiveState Corporation. '\" Copyright (c) 2006-2007 Daniel A. Steffen '\" Copyright (c) 2008 Donal K. Fellows '\" .TH colors n 8.3 Tk "Tk Built-In Commands" @@ -782,34 +782,27 @@ .DE .SH "PORTABILITY ISSUES" .TP \fBMac OS X\fR . -On macOS, the following additional system colors are available. -This first group contains all colors available in the HIToolbox library. -(Note that in some cases the actual color values may depend on the -current Appearance.) +On macOS, the following additional system colors are available. This +first group contains all of the HIBrush colors available in the +HIToolbox library. Note that on macOS 10.14 (Mojave) and later these +colors are unlikely to match the color actually used for the purpose +suggested by the color name. .RS .DS systemActiveAreaFill -systemAlertActiveText systemAlertBackgroundActive systemAlertBackgroundInactive -systemAlertInactiveText systemAlternatePrimaryHighlightColor systemAppleGuideCoachmark systemBevelActiveDark systemBevelActiveLight -systemBevelButtonActiveText -systemBevelButtonInactiveText -systemBevelButtonPressedText -systemBevelButtonStickyActiveText -systemBevelButtonStickyInactiveText systemBevelInactiveDark systemBevelInactiveLight systemBlack -systemBlackText systemButtonActiveDarkHighlight systemButtonActiveDarkShadow systemButtonActiveLightHighlight systemButtonActiveLightShadow systemButtonFace @@ -825,132 +818,90 @@ systemButtonInactiveLightShadow systemButtonPressedDarkHighlight systemButtonPressedDarkShadow systemButtonPressedLightHighlight systemButtonPressedLightShadow -systemButtonText systemChasingArrows -systemDialogActiveText systemDialogBackgroundActive systemDialogBackgroundInactive -systemDialogInactiveText systemDocumentWindowBackground -systemDocumentWindowTitleActiveText -systemDocumentWindowTitleInactiveText systemDragHilite systemDrawerBackground systemFinderWindowBackground systemFocusHighlight systemHighlight systemHighlightAlternate systemHighlightSecondary -systemHighlightText systemIconLabelBackground systemIconLabelBackgroundSelected -systemIconLabelSelectedText -systemIconLabelText systemListViewBackground systemListViewColumnDivider systemListViewEvenRowBackground systemListViewOddRowBackground systemListViewSeparator systemListViewSortColumnBackground -systemListViewText -systemListViewWindowHeaderBackground systemMenu systemMenuActive -systemMenuActiveText systemMenuBackground systemMenuBackgroundSelected -systemMenuDisabled -systemMenuItemActiveText -systemMenuItemDisabledText -systemMenuItemSelectedText -systemMenuText -systemMetalBackground -systemModelessDialogActiveText systemModelessDialogBackgroundActive systemModelessDialogBackgroundInactive -systemModelessDialogInactiveText systemMovableModalBackground -systemMovableModalWindowTitleActiveText -systemMovableModalWindowTitleInactiveText -systemNotificationText systemNotificationWindowBackground -systemPlacardActiveText -systemPlacardBackground -systemPlacardInactiveText -systemPlacardPressedText systemPopupArrowActive systemPopupArrowInactive systemPopupArrowPressed -systemPopupButtonActiveText -systemPopupButtonInactiveText -systemPopupButtonPressedText -systemPopupLabelActiveText -systemPopupLabelInactiveText -systemPopupWindowTitleActiveText -systemPopupWindowTitleInactiveText systemPrimaryHighlightColor -systemPushButtonActiveText -systemPushButtonInactiveText -systemPushButtonPressedText -systemRootMenuActiveText -systemRootMenuDisabledText -systemRootMenuSelectedText systemScrollBarDelimiterActive systemScrollBarDelimiterInactive -systemSecondaryGroupBoxBackground systemSecondaryHighlightColor systemSelectedTabTextColor systemSheetBackground systemSheetBackgroundOpaque systemSheetBackgroundTransparent systemStaticAreaFill -systemSystemDetailText -systemTabFrontActiveText -systemTabFrontInactiveText -systemTabNonFrontActiveText -systemTabNonFrontInactiveText -systemTabNonFrontPressedText -systemTabPaneBackground systemToolbarBackground systemTransparent systemUtilityWindowBackgroundActive systemUtilityWindowBackgroundInactive -systemUtilityWindowTitleActiveText -systemUtilityWindowTitleInactiveText systemWhite -systemWhiteText systemWindowBody -systemWindowHeaderActiveText -systemWindowHeaderBackground -systemWindowHeaderInactiveText .DE .RE . -The second group of MacOS colors below are based on Apple's "semantic" -NScolors. On OSX 10.14 (Mojave) and later these colors change value -when Dark Mode is enabled. However, the change is only observable -when the Apple window manager is drawing to the screen. So the -\fBwinfo rgb\fR command will return the color coordinates used in the -standard Aqua mode, even if Dark Mode has been selected in the system -preferences. The numbered systemWindowBackgroundColors are used in -the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets to provide a -contrasting background. Each numbered color constrasts with its -predecessor. +Tk supports all of the NSColors in the macOS System ColorList. The +convention for naming these colors is that the Tk name is generated by +capitalizing the macOS name and adding the prefix "system". On OSX +10.14 (Mojave) and later many of these "semantic" colors will appear +differently depending on whether the NSWindow in which they are used has +the Aqua or DarkAqua appearance. The System ColorList differs between +releases of macOS and some colors, such as systemLinkColor and +systemControlAccentColor, are simulated on older systems which did not +provide them. All of the colors below are available on all supported +macOS releases, but newer systems will support additional colors. .RS .DS systemControlAccentColor systemControlTextColor systemDisabledControlTextColor systemLabelColor systemLinkColor +systemPlaceholderTextColor systemSelectedTextBackgroundColor systemSelectedTextColor +systemSeparatorColor systemTextBackgroundColor systemTextColor +.DE +.RE +. +The numbered systemWindowBackgroundColors below +are used in the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets +to provide a contrasting background. Each numbered color constrasts +with its predecessor. +.RS +.DS systemWindowBackgroundColor systemWindowBackgroundColor1 systemWindowBackgroundColor2 systemWindowBackgroundColor3 systemWindowBackgroundColor4 @@ -959,35 +910,35 @@ systemWindowBackgroundColor7 .DE .RE .TP - \fBWindows\fR . On Windows, the following additional system colors are available (note that the actual color values depend on the currently active OS theme): .RS .DS .ta 6c -system3dDarkShadow systemHighlight -system3dLight systemHighlightText -systemActiveBorder systemInactiveBorder -systemActiveCaption systemInactiveCaption -systemAppWorkspace systemInactiveCaptionText -systemBackground systemInfoBackground -systemButtonFace systemInfoText -systemButtonHighlight systemMenu -systemButtonShadow systemMenuText +system3dDarkShadow systemHighlightText +system3dLight systemInactiveBorder +systemActiveBorder systemInactiveCaption +systemActiveCaption systemInactiveCaptionText +systemAppWorkspace systemInfoBackground +systemBackground systemInfoText +systemButtonFace systemMenu +systemButtonHighlight systemMenuText +systemButtonShadow systemPlaceholderText systemButtonText systemScrollbar systemCaptionText systemWindow systemDisabledText systemWindowFrame systemGrayText systemWindowText +systemHighlight .DE .RE .SH "SEE ALSO" options(n), Tk_GetColor(3) .SH KEYWORDS color, option '\" Local Variables: '\" mode: nroff '\" End: Index: doc/console.n ================================================================== --- doc/console.n +++ doc/console.n @@ -21,15 +21,18 @@ Tk toolkit loaded, and control over this interpreter is given through the \fBconsole\fR command. The behaviour of the console window is defined mainly through the contents of the \fIconsole.tcl\fR file in the Tk library. Except for TkAqua, this command is not available when Tk is loaded into a tclsh interpreter with -.QW "\fBpackage require Tk\fR" , +.QW "\fBpackage require tk\fR" , as a conventional terminal is expected to be present in that case. -In TkAqua, this command is only available when stdin is \fB/dev/null\fR -(as is the case e.g. when the application embedding Tk is started -from the Mac OS X Finder). +In TkAqua, this command is disabled when there is a startup script +and stdin is \fB/dev/null\fR (as is the case e.g. when a bundled application +embedding Tk is started by the macOS Launcher). To enable the command +in that case, define the environment variable \fBTK_CONSOLE\fR. This can be +done by modifying the Info.plist file by adding the LSEnvironment key +to the main dict and setting its value to be a dict with the key \fBTK_CONSOLE\fR. .PP .TP \fBconsole eval \fIscript\fR Evaluate the \fIscript\fR argument as a Tcl script in the console interpreter. The normal interpreter is accessed through the Index: doc/cursors.n ================================================================== --- doc/cursors.n +++ doc/cursors.n @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" '\" Copyright (c) 2006-2007 Daniel A. Steffen '\" .TH cursors n 8.3 Tk "Tk Built-In Commands" Index: doc/entry.n ================================================================== --- doc/entry.n +++ doc/entry.n @@ -188,11 +188,11 @@ .PP The \fBentry\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName subcommand \fR?\fIarg arg ...\fR? +\fIpathName subcommand \fR?\fIarg ...\fR? .CE \fISubcommand\fR and the \fIarg\fRs determine the exact behavior of the command. .SS INDICES .PP @@ -401,11 +401,12 @@ \fIFraction\fR must be a fraction between 0 and 1. .TP \fIpathName \fBxview scroll \fInumber what\fR This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. -\fINumber\fR must be an integer. +\fINumber\fR must be an integer or a float, but if it is a float then +it is converted to an integer, rounded away from 0. \fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right Index: doc/event.n ================================================================== --- doc/event.n +++ doc/event.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME event \- Miscellaneous event facilities: define virtual events and generate events .SH SYNOPSIS -\fBevent\fI option \fR?\fIarg arg ...\fR? +\fBevent\fI option \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP The \fBevent\fR command provides several facilities for dealing with window system events, such as defining virtual events and synthesizing Index: doc/focus.n ================================================================== --- doc/focus.n +++ doc/focus.n @@ -13,11 +13,11 @@ focus \- Manage the input focus .SH SYNOPSIS .nf \fBfocus\fR \fBfocus \fIwindow\fR -\fBfocus \fIoption\fR ?\fIarg arg ...\fR? +\fBfocus \fIoption\fR ?\fIarg ...\fR? .fi .BE .SH DESCRIPTION .PP The \fBfocus\fR command is used to manage the Tk input focus. Index: doc/font.n ================================================================== --- doc/font.n +++ doc/font.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME font \- Create and inspect fonts. .SH SYNOPSIS -\fBfont\fI option \fR?\fIarg arg ...\fR? +\fBfont\fI option \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP The \fBfont\fR command provides several facilities for dealing with fonts, such as defining named fonts and inspecting the actual attributes of Index: doc/fontchooser.n ================================================================== --- doc/fontchooser.n +++ doc/fontchooser.n @@ -9,11 +9,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME fontchooser \- control font selection dialog .SH SYNOPSIS -\fBtk fontchooser\fR \fBconfigure\fR ?\fI\-option value \-option value ...\fR? +\fBtk fontchooser\fR \fBconfigure\fR ?\fI\-option value ...\fR? .sp \fBtk fontchooser\fR \fBshow\fR .sp \fBtk fontchooser\fR \fBhide\fR .BE @@ -29,11 +29,11 @@ difference, all user interaction with the dialog will be communicated to the caller via callbacks or virtual events. .PP The \fBtk fontchooser\fR command can have one of the following forms: .TP -\fBtk fontchooser\fR \fBconfigure \fR?\fI\-option value \-option value ...\fR? +\fBtk fontchooser\fR \fBconfigure \fR?\fI\-option value ...\fR? . Set or query one or more of the configurations options below (analogous to Tk widget configuration). .TP \fBtk fontchooser\fR \fBshow\fR Index: doc/frame.n ================================================================== --- doc/frame.n +++ doc/frame.n @@ -118,11 +118,11 @@ name is the same as the path name of the frame's window. This command may be used to invoke various operations on the widget. It has the following general form: .PP .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE .PP \fIPathName\fR is the name of the command, which is the same as the frame widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following @@ -133,11 +133,11 @@ Returns the current value of the configuration option given by \fIoption\fR. \fIOption\fR may have any of the values accepted by the \fBframe\fR command. .TP -\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR? +\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? . Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified Index: doc/grab.n ================================================================== --- doc/grab.n +++ doc/grab.n @@ -12,11 +12,11 @@ .SH NAME grab \- Confine pointer and keyboard events to a window sub-tree .SH SYNOPSIS \fBgrab \fR?\fB\-global\fR? \fIwindow\fR .sp -\fBgrab \fIoption \fR?\fIarg arg \fR...? +\fBgrab \fIoption \fR?\fIarg \fR...? .BE .SH DESCRIPTION .PP This command implements simple pointer and keyboard grabs for Tk. Tk's grabs are different than the grabs Index: doc/grid.n ================================================================== --- doc/grid.n +++ doc/grid.n @@ -15,53 +15,53 @@ .BE .SH DESCRIPTION .PP The \fBgrid\fR command is used to communicate with the grid geometry manager that arranges widgets in rows and columns inside -of another window, called the geometry master (or master window). +of another window, called the geometry container (or container window). The \fBgrid\fR command can have any of several forms, depending on the \fIoption\fR argument: .TP -\fBgrid \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR? +\fBgrid \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR? . -If the first argument to \fBgrid\fR is suitable as the first slave +If the first argument to \fBgrid\fR is suitable as the first window argument to \fBgrid configure\fR, either a window name (any value starting with \fB.\fR) or one of the characters \fBx\fR or \fB^\fR (see the \fBRELATIVE PLACEMENT\fR section below), then the command is processed in the same way as \fBgrid configure\fR. .TP -\fBgrid anchor \fImaster\fR ?\fIanchor\fR? +\fBgrid anchor \fIwindow\fR ?\fIanchor\fR? . -The anchor value controls how to place the grid within the master +The anchor value controls how to place the grid within the container window when no row/column has any weight. See \fBTHE GRID ALGORITHM\fR below for further details. The default \fIanchor\fR is \fInw\fR. .TP -\fBgrid bbox \fImaster\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR? +\fBgrid bbox \fIwindow\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR? . With no arguments, the bounding box (in pixels) of the grid is returned. The return value consists of 4 integers. The first two are the pixel -offset from the master window (x then y) of the top-left corner of the +offset from the container window (x then y) of the top-left corner of the grid, and the second two integers are the width and height of the grid, also in pixels. If a single \fIcolumn\fR and \fIrow\fR is specified on the command line, then the bounding box for that cell is returned, where the top left cell is numbered from zero. If both \fIcolumn\fR and \fIrow\fR arguments are specified, then the bounding box spanning the rows and columns indicated is returned. .TP -\fBgrid columnconfigure \fImaster index \fR?\fI\-option value...\fR? +\fBgrid columnconfigure \fIwindow index \fR?\fI\-option value...\fR? . Query or set the column properties of the \fIindex\fR column of the -geometry master, \fImaster\fR. +geometry container, \fIwindow\fR. The valid options are \fB\-minsize\fR, \fB\-weight\fR, \fB\-uniform\fR and \fB\-pad\fR. If one or more options are provided, then \fIindex\fR may be given as a list of column indices to which the configuration options will operate on. Indices may be integers, window names or the keyword \fIall\fR. For \fIall\fR -the options apply to all columns currently occupied be slave windows. For -a window name, that window must be a slave of this master and the options -apply to all columns currently occupied be the slave. +the options apply to all columns currently occupied be content windows. For +a window name, that window must be a content of this container and the options +apply to all columns currently occupied be the content. The \fB\-minsize\fR option sets the minimum size, in screen units, that will be permitted for this column. The \fB\-weight\fR option (an integer value) sets the relative weight for apportioning any extra spaces among @@ -78,182 +78,182 @@ The \fB\-pad\fR option specifies the number of screen units that will be added to the largest window contained completely in that column when the grid geometry manager requests a size from the containing window. If only an option is specified, with no value, the current value of that option is returned. -If only the master window and index is specified, all the current settings +If only the container window and index is specified, all the current settings are returned in a list of .QW "\-option value" pairs. .TP -\fBgrid configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR? +\fBgrid configure \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR? . -The arguments consist of the names of one or more slave windows +The arguments consist of the names of one or more content windows followed by pairs of arguments that specify how -to manage the slaves. +to manage the content. The characters \fB\-\fR, \fBx\fR and \fB^\fR, can be specified instead of a window name to alter the default -location of a \fIslave\fR, as described in the \fBRELATIVE PLACEMENT\fR +location of a \fIwindow\fR, as described in the \fBRELATIVE PLACEMENT\fR section, below. The following options are supported: .RS .TP \fB\-column \fIn\fR . -Insert the slave so that it occupies the \fIn\fRth column in the grid. +Insert the window so that it occupies the \fIn\fRth column in the grid. Column numbers start with 0. If this option is not supplied, then the -slave is arranged just to the right of previous slave specified on this +window is arranged just to the right of previous window specified on this call to \fBgrid\fR, or column .QW 0 -if it is the first slave. For each -\fBx\fR that immediately precedes the \fIslave\fR, the column position +if it is the first window. For each +\fBx\fR that immediately precedes the \fIwindow\fR, the column position is incremented by one. Thus the \fBx\fR represents a blank column for this row in the grid. .TP \fB\-columnspan \fIn\fR . -Insert the slave so that it occupies \fIn\fR columns in the grid. +Insert the window so that it occupies \fIn\fR columns in the grid. The default is one column, unless the window name is followed by a \fB\-\fR, in which case the columnspan is incremented once for each immediately following \fB\-\fR. .TP -\fB\-in \fIother\fR +\fB\-in \fIcontainer\fR . -Insert the slave(s) in the master -window given by \fIother\fR. The default is the first slave's +Insert the window(s) in the container +window given by \fIcontainer\fR. The default is the first window's parent window. .TP \fB\-ipadx \fIamount\fR . The \fIamount\fR specifies how much horizontal internal padding to -leave on each side of the slave(s). This is space is added -inside the slave(s) border. +leave on each side of the content. This is space is added +inside the content border. The \fIamount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR. It defaults to 0. .TP \fB\-ipady \fIamount\fR . The \fIamount\fR specifies how much vertical internal padding to -leave on the top and bottom of the slave(s). -This space is added inside the slave(s) border. +leave on the top and bottom of the content. +This space is added inside the content border. The \fIamount\fR defaults to 0. .TP \fB\-padx \fIamount\fR . The \fIamount\fR specifies how much horizontal external padding to -leave on each side of the slave(s), in screen units. +leave on each side of the content, in screen units. \fIAmount\fR may be a list of two values to specify padding for left and right separately. The \fIamount\fR defaults to 0. -This space is added outside the slave(s) border. +This space is added outside the content border. .TP \fB\-pady \fIamount\fR . The \fIamount\fR specifies how much vertical external padding to -leave on the top and bottom of the slave(s), in screen units. +leave on the top and bottom of the content, in screen units. \fIAmount\fR may be a list of two values to specify padding for top and bottom separately. The \fIamount\fR defaults to 0. -This space is added outside the slave(s) border. +This space is added outside the content border. .TP \fB\-row \fIn\fR . -Insert the slave so that it occupies the \fIn\fRth row in the grid. +Insert the content so that it occupies the \fIn\fRth row in the grid. Row numbers start with 0. If this option is not supplied, then the -slave is arranged on the same row as the previous slave specified on this +content is arranged on the same row as the previous content specified on this call to \fBgrid\fR, or the next row after the highest occupied row -if this is the first slave. +if this is the first content. .TP \fB\-rowspan \fIn\fR . -Insert the slave so that it occupies \fIn\fR rows in the grid. +Insert the content so that it occupies \fIn\fR rows in the grid. The default is one row. If the next \fBgrid\fR command contains -\fB^\fR characters instead of \fIslaves\fR that line up with the columns -of this \fIslave\fR, then the \fBrowspan\fR of this \fIslave\fR is +\fB^\fR characters instead of \fIcontent\fR that line up with the columns +of this \fIcontent\fR, then the \fBrowspan\fR of this \fIcontent\fR is extended by one. .TP \fB\-sticky \fIstyle\fR . -If a slave's cell is larger than its requested dimensions, this -option may be used to position (or stretch) the slave within its cell. +If a content's cell is larger than its requested dimensions, this +option may be used to position (or stretch) the content within its cell. \fIStyle\fR is a string that contains zero or more of the characters \fBn\fR, \fBs\fR, \fBe\fR or \fBw\fR. The string can optionally contain spaces or commas, but they are ignored. Each letter refers to a side (north, south, -east, or west) that the slave will +east, or west) that the content will .QW stick to. If both \fBn\fR and \fBs\fR (or \fBe\fR and \fBw\fR) are -specified, the slave will be stretched to fill the entire +specified, the content will be stretched to fill the entire height (or width) of its cavity. The \fB\-sticky\fR option subsumes the combination of \fB\-anchor\fR and \fB\-fill\fR that is used by \fBpack\fR. The default is .QW "" , -which causes the slave to be centered in its cavity, at its requested size. +which causes the content to be centered in its cavity, at its requested size. .LP -If any of the slaves are already managed by the geometry manager +If any of the content is already managed by the geometry manager then any unspecified options for them retain their previous values rather than receiving default values. .RE .TP -\fBgrid forget \fIslave \fR?\fIslave ...\fR? +\fBgrid forget \fIwindow \fR?\fIwindow ...\fR? . -Removes each of the \fIslave\fRs from grid for its -master and unmaps their windows. -The slaves will no longer be managed by the grid geometry manager. +Removes each of the \fIwindow\fRs from grid for its +container and unmaps their windows. +The content will no longer be managed by the grid geometry manager. The configuration options for that window are forgotten, so that if the -slave is managed once more by the grid geometry manager, the initial +window is managed once more by the grid geometry manager, the initial default settings are used. .RS .PP -.VS TIP518 -If the last slave of the master becomes unmanaged, this will also send -the virtual event \fB<>\fR to the master; the master +.VS "TIP 518" +If the last content window of the container becomes unmanaged, this will also send +the virtual event \fB<>\fR to the container; the container may choose to resize itself (or otherwise respond) to such a change. -.VE TIP518 +.VE "TIP 518" .RE .TP -\fBgrid info \fIslave\fR +\fBgrid info \fIwindow\fR . Returns a list whose elements are the current configuration state of -the slave given by \fIslave\fR in the same option-value form that +the content given by \fIwindow\fR in the same option-value form that might be specified to \fBgrid configure\fR. The first two elements of the list are -.QW "\fB\-in \fImaster\fR" -where \fImaster\fR is the slave's master. +.QW "\fB\-in \fIcontainer\fR" +where \fIcontainer\fR is the windows's container window. .TP -\fBgrid location \fImaster x y\fR +\fBgrid location \fIwindow x y\fR . -Given \fIx\fR and \fIy\fR values in screen units relative to the master window, +Given \fIx\fR and \fIy\fR values in screen units relative to the container window, the column and row number at that \fIx\fR and \fIy\fR location is returned. For locations that are above or to the left of the grid, \fB\-1\fR is returned. .TP -\fBgrid propagate \fImaster\fR ?\fIboolean\fR? +\fBgrid propagate \fIwindow\fR ?\fIboolean\fR? . If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR -then propagation is enabled for \fImaster\fR, which must be a window +then propagation is enabled for \fIwindow\fR, which must be a window name (see \fBGEOMETRY PROPAGATION\fR below). If \fIboolean\fR has a false boolean value then propagation is -disabled for \fImaster\fR. +disabled for \fIwindow\fR. In either of these cases an empty string is returned. If \fIboolean\fR is omitted then the command returns \fB0\fR or \fB1\fR to indicate whether propagation is currently enabled -for \fImaster\fR. +for \fIwindow\fR. Propagation is enabled by default. .TP -\fBgrid rowconfigure \fImaster index \fR?\fI\-option value...\fR? +\fBgrid rowconfigure \fIwindow index \fR?\fI\-option value...\fR? . Query or set the row properties of the \fIindex\fR row of the -geometry master, \fImaster\fR. +geometry container, \fIwindow\fR. The valid options are \fB\-minsize\fR, \fB\-weight\fR, \fB\-uniform\fR and \fB\-pad\fR. If one or more options are provided, then \fIindex\fR may be given as a list of row indices to which the configuration options will operate on. Indices may be integers, window names or the keyword \fIall\fR. For \fIall\fR -the options apply to all rows currently occupied be slave windows. For -a window name, that window must be a slave of this master and the options -apply to all rows currently occupied be the slave. +the options apply to all rows currently occupied by content windows. For +a window name, that window must be a content window of this container and the options +apply to all rows currently occupied by the container window. The \fB\-minsize\fR option sets the minimum size, in screen units, that will be permitted for this row. The \fB\-weight\fR option (an integer value) sets the relative weight for apportioning any extra spaces among @@ -270,103 +270,106 @@ The \fB\-pad\fR option specifies the number of screen units that will be added to the largest window contained completely in that row when the grid geometry manager requests a size from the containing window. If only an option is specified, with no value, the current value of that option is returned. -If only the master window and index is specified, all the current settings +If only the container window and index is specified, all the current settings are returned in a list of .QW "-option value" pairs. .TP -\fBgrid remove \fIslave \fR?\fIslave ...\fR? +\fBgrid remove \fIwindow \fR?\fIwindow ...\fR? . -Removes each of the \fIslave\fRs from grid for its -master and unmaps their windows. -The slaves will no longer be managed by the grid geometry manager. +Removes each of the \fIwindow\fRs from grid for its +container and unmaps their windows. +The content will no longer be managed by the grid geometry manager. However, the configuration options for that window are remembered, -so that if the -slave is managed once more by the grid geometry manager, the previous -values are retained. +so that if the content window is managed once more by the grid +geometry manager, the previous values are retained. .RS .PP -.VS TIP518 -If the last slave of the master becomes unmanaged, this will also send -the virtual event \fB<>\fR to the master; the master +.VS "TIP 518" +If the last content window of the container becomes unmanaged, this will also send +the virtual event \fB<>\fR to the container; the container may choose to resize itself (or otherwise respond) to such a change. -.VE TIP518 +.VE "TIP 518" .RE .TP -\fBgrid size \fImaster\fR +\fBgrid size \fIcontainer\fR . -Returns the size of the grid (in columns then rows) for \fImaster\fR. -The size is determined either by the \fIslave\fR occupying the largest +Returns the size of the grid (in columns then rows) for \fIcontainer\fR. +The size is determined either by the \fIcontent\fR occupying the largest row or column, or the largest column or row with a \fB\-minsize\fR, \fB\-weight\fR, or \fB\-pad\fR that is non-zero. .TP -\fBgrid slaves \fImaster\fR ?\fI\-option value\fR? +\fBgrid content \fIwindow\fR ?\fI\-option value\fR? . -If no options are supplied, a list of all of the slaves in \fImaster\fR -are returned, most recently manages first. +If no options are supplied, a list of all of the content in \fIwindow\fR +is returned, most recently managed first. \fIOption\fR can be either \fB\-row\fR or \fB\-column\fR which -causes only the slaves in the row (or column) specified by \fIvalue\fR +causes only the content in the row (or column) specified by \fIvalue\fR to be returned. +.TP +\fBgrid slaves \fIwindow\fR ?\fI\-option value\fR? +. +Synonym for . \fBgrid content \fIwindow\fR ?\fI\-option value\fR? .SH "RELATIVE PLACEMENT" .PP The \fBgrid\fR command contains a limited set of capabilities that permit layouts to be created without specifying the row and column -information for each slave. This permits slaves to be rearranged, +information for each content. This permits content to be rearranged, added, or removed without the need to explicitly specify row and column information. -When no column or row information is specified for a \fIslave\fR, +When no column or row information is specified for a \fIcontent\fR, default values are chosen for \fB\-column\fR, \fB\-row\fR, \fB\-columnspan\fR and \fB\-rowspan\fR -at the time the \fIslave\fR is managed. The values are chosen -based upon the current layout of the grid, the position of the \fIslave\fR -relative to other \fIslave\fRs in the same grid command, and the presence +at the time the \fIcontent\fR is managed. The values are chosen +based upon the current layout of the grid, the position of the \fIcontent\fR +relative to other \fIcontent\fRs in the same grid command, and the presence of the characters \fB\-\fR, \fBx\fR, and \fB^\fR in \fBgrid\fR -command where \fIslave\fR names are normally expected. +command where \fIcontent\fR names are normally expected. .RS .TP \fB\-\fR . -This increases the \fB\-columnspan\fR of the \fIslave\fR to the left. Several +This increases the \fB\-columnspan\fR of the \fIcontent\fR to the left. Several \fB\-\fR's in a row will successively increase the number of columns spanned. A \fB\-\fR -may not follow a \fB^\fR or a \fBx\fR, nor may it be the first \fIslave\fR +may not follow a \fB^\fR or a \fBx\fR, nor may it be the first \fIcontent\fR argument to \fBgrid configure\fR. .TP \fBx\fR . -This leaves an empty column between the \fIslave\fR on the left and -the \fIslave\fR on the right. +This leaves an empty column between the \fIcontent\fR on the left and +the \fIcontent\fR on the right. .TP \fB^\fR . -This extends the \fB\-rowspan\fR of the \fIslave\fR above the \fB^\fR's +This extends the \fB\-rowspan\fR of the \fIcontent\fR above the \fB^\fR's in the grid. The number of \fB^\fR's in a row must match the number of -columns spanned by the \fIslave\fR above it. +columns spanned by the \fIcontent\fR above it. .RE .SH "THE GRID ALGORITHM" .PP -The grid geometry manager lays out its slaves in three steps. -In the first step, the minimum size needed to fit all of the slaves +The grid geometry manager lays out its content in three steps. +In the first step, the minimum size needed to fit all of the content is computed, then (if propagation is turned on), a request is made -of the master window to become that size. +of the container window to become that size. In the second step, the requested size is compared against the actual size -of the master. If the sizes are different, then spaces is added to or taken +of the container. If the sizes are different, then spaces is added to or taken away from the layout as needed. -For the final step, each slave is positioned in its row(s) and column(s) +For the final step, each content is positioned in its row(s) and column(s) based on the setting of its \fIsticky\fR flag. .PP To compute the minimum size of a layout, the grid geometry manager -first looks at all slaves whose \fB\-columnspan\fR and \fB\-rowspan\fR values are one, +first looks at all content whose \fB\-columnspan\fR and \fB\-rowspan\fR values are one, and computes the nominal size of each row or column to be either the \fIminsize\fR for that row or column, or the sum of the \fIpad\fRding -plus the size of the largest slave, whichever is greater. After that +plus the size of the largest content, whichever is greater. After that the rows or columns in each uniform group adapt to each other. Then -the slaves whose row-spans or column-spans are greater than one are +the content whose row-spans or column-spans are greater than one are examined. If a group of rows or columns need to be increased in size -in order to accommodate these slaves, then extra space is added to each +in order to accommodate these content, then extra space is added to each row or column in the group according to its \fIweight\fR. For each group whose weights are all zero, the additional space is apportioned equally. .PP When multiple rows or columns belong to a uniform group, the space @@ -383,50 +386,50 @@ \fIk\fR is chosen so that no row or column becomes smaller than its minimum size. For example, if all rows or columns in a group have the same weight, then each row or column will have the same size as the largest row or column in the group. .PP -For masters whose size is larger than the requested layout, the additional +For containers whose size is larger than the requested layout, the additional space is apportioned according to the row and column weights. If all of -the weights are zero, the layout is placed within its master according to +the weights are zero, the layout is placed within its container according to the \fIanchor\fR value. -For masters whose size is smaller than the requested layout, space is taken +For containers whose size is smaller than the requested layout, space is taken away from columns and rows according to their weights. However, once a column or row shrinks to its minsize, its weight is taken to be zero. If more space needs to be removed from a layout than would be permitted, as when all the rows or columns are at their minimum sizes, the layout is placed and clipped according to the \fIanchor\fR value. .SH "GEOMETRY PROPAGATION" .PP -The grid geometry manager normally computes how large a master must be to -just exactly meet the needs of its slaves, and it sets the -requested width and height of the master to these dimensions. +The grid geometry manager normally computes how large a container must be to +just exactly meet the needs of its content, and it sets the +requested width and height of the container to these dimensions. This causes geometry information to propagate up through a window hierarchy to a top-level window so that the entire sub-tree sizes itself to fit the needs of the leaf windows. However, the \fBgrid propagate\fR command may be used to -turn off propagation for one or more masters. +turn off propagation for one or more containers. If propagation is disabled then grid will not set -the requested width and height of the master window. -This may be useful if, for example, you wish for a master +the requested width and height of the container window. +This may be useful if, for example, you wish for a container window to have a fixed size that you specify. -.SH "RESTRICTIONS ON MASTER WINDOWS" +.SH "RESTRICTIONS ON CONTAINER WINDOWS" .PP -The master for each slave must either be the slave's parent -(the default) or a descendant of the slave's parent. +The container for each content must either be the content's parent +(the default) or a descendant of the content's parent. This restriction is necessary to guarantee that the -slave can be placed over any part of its master that is -visible without danger of the slave being clipped by its parent. -In addition, all slaves in one call to \fBgrid\fR must have the same master. +content can be placed over any part of its container that is +visible without danger of the content being clipped by its parent. +In addition, all content in one call to \fBgrid\fR must have the same container. .SH "STACKING ORDER" .PP -If the master for a slave is not its parent then you must make sure -that the slave is higher in the stacking order than the master. -Otherwise the master will obscure the slave and it will appear as -if the slave has not been managed correctly. -The easiest way to make sure the slave is higher than the master is -to create the master window first: the most recently created window +If the container for a content is not its parent then you must make sure +that the content is higher in the stacking order than the container. +Otherwise the container will obscure the content and it will appear as +if the content has not been managed correctly. +The easiest way to make sure the content is higher than the container is +to create the container window first: the most recently created window will be highest in the stacking order. .SH CREDITS .PP The \fBgrid\fR command is based on ideas taken from the \fIGridBag\fR geometry manager written by Doug. Stein, and the \fBblt_table\fR geometry Index: doc/image.n ================================================================== --- doc/image.n +++ doc/image.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME image \- Create and manipulate images .SH SYNOPSIS -\fBimage\fR \fIoption \fR?\fIarg arg ...\fR? +\fBimage\fR \fIoption \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP The \fBimage\fR command is used to create, delete, and query images. It can take several different forms, depending on the Index: doc/keysyms.n ================================================================== --- doc/keysyms.n +++ doc/keysyms.n @@ -1,7 +1,7 @@ '\" -'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH keysyms n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS @@ -10,11 +10,11 @@ keysyms \- keysyms recognized by Tk .BE .SH DESCRIPTION .PP Tk recognizes many keysyms when specifying key bindings (e.g., -.QW "\fBbind\fR \fB. \fR" ). +.QW "\fBbind\fR \fB. <\fR\fIkeysym\fR\fB>\fR" ). The following list enumerates the keysyms that will be recognized by Tk. Note that not all keysyms will be valid on all platforms, and some keysyms are also available on platforms that have a different native name for that key. For example, on Unix systems, the presence @@ -22,25 +22,25 @@ keyboard modifier map. This list shows keysyms along with their decimal and hexadecimal values. .PP .CS space 32 0x20 -exclam 33 0x21 +! (exclam) 33 0x21 quotedbl 34 0x22 numbersign 35 0x23 dollar 36 0x24 -percent 37 0x25 -ampersand 38 0x26 -apostrophe 39 0x27 -parenleft 40 0x28 -parenright 41 0x29 -asterisk 42 0x2A -plus 43 0x2B -comma 44 0x2C +% (percent) 37 0x25 +& (ampersand) 38 0x26 +' (apostrophe) 39 0x27 +( (parenleft) 40 0x28 +) (parenright) 41 0x29 +* (asterisk) 42 0x2A ++ (plus) 43 0x2B +, (comma) 44 0x2C minus 45 0x2D -period 46 0x2E -slash 47 0x2F +. (period) 46 0x2E +/ (slash) 47 0x2F 0 48 0x30 1 49 0x31 2 50 0x32 3 51 0x33 4 52 0x34 @@ -47,17 +47,17 @@ 5 53 0x35 6 54 0x36 7 55 0x37 8 56 0x38 9 57 0x39 -colon 58 0x3A +: (colon) 58 0x3A semicolon 59 0x3B less 60 0x3C -equal 61 0x3D += (equal) 61 0x3D greater 62 0x3E -question 63 0x3F -at 64 0x40 +? (question) 63 0x3F +@ (at) 64 0x40 A 65 0x41 B 66 0x42 C 67 0x43 D 68 0x44 E 69 0x45 @@ -83,13 +83,13 @@ Y 89 0x59 Z 90 0x5A bracketleft 91 0x5B backslash 92 0x5C bracketright 93 0x5D -asciicircum 94 0x5E -underscore 95 0x5F -grave 96 0x60 +^ (asciicircum) 94 0x5E +_ (underscore) 95 0x5F +` (grave) 96 0x60 a 97 0x61 b 98 0x62 c 99 0x63 d 100 0x64 e 101 0x65 @@ -113,120 +113,120 @@ w 119 0x77 x 120 0x78 y 121 0x79 z 122 0x7A braceleft 123 0x7B -bar 124 0x7C +| (bar) 124 0x7C braceright 125 0x7D -asciitilde 126 0x7E +~ (asciitilde) 126 0x7E nobreakspace 160 0xA0 -exclamdown 161 0xA1 -cent 162 0xA2 -sterling 163 0xA3 -currency 164 0xA4 -yen 165 0xA5 -brokenbar 166 0xA6 -section 167 0xA7 -diaeresis 168 0xA8 -copyright 169 0xA9 -ordfeminine 170 0xAA -guillemotleft 171 0xAB -notsign 172 0xAC +\(r! (exclamdown) 161 0xA1 +\(ct (cent) 162 0xA2 +\(Po (sterling) 163 0xA3 +\(Cs (currency) 164 0xA4 +\(Ye (yen) 165 0xA5 +\(bb (brokenbar) 166 0xA6 +\(sc (section) 167 0xA7 +\(ad (diaeresis) 168 0xA8 +\(co (copyright) 169 0xA9 +\(Of (ordfeminine) 170 0xAA +\(Fo (guillemotleft) 171 0xAB +\(no (notsign) 172 0xAC hyphen 173 0xAD -registered 174 0xAE -macron 175 0xAF -degree 176 0xB0 -plusminus 177 0xB1 -twosuperior 178 0xB2 -threesuperior 179 0xB3 -acute 180 0xB4 -mu 181 0xB5 -paragraph 182 0xB6 -periodcentered 183 0xB7 -cedilla 184 0xB8 -onesuperior 185 0xB9 -masculine 186 0xBA -guillemotright 187 0xBB -onequarter 188 0xBC -onehalf 189 0xBD -threequarters 190 0xBE -questiondown 191 0xBF -Agrave 192 0xC0 -Aacute 193 0xC1 -Acircumflex 194 0xC2 -Atilde 195 0xC3 -Adiaeresis 196 0xC4 -Aring 197 0xC5 -AE 198 0xC6 -Ccedilla 199 0xC7 -Egrave 200 0xC8 -Eacute 201 0xC9 -Ecircumflex 202 0xCA -Ediaeresis 203 0xCB -Igrave 204 0xCC -Iacute 205 0xCD -Icircumflex 206 0xCE -Idiaeresis 207 0xCF -ETH 208 0xD0 -Ntilde 209 0xD1 -Ograve 210 0xD2 -Oacute 211 0xD3 -Ocircumflex 212 0xD4 -Otilde 213 0xD5 -Odiaeresis 214 0xD6 -multiply 215 0xD7 -Oslash 216 0xD8 -Ugrave 217 0xD9 -Uacute 218 0xDA -Ucircumflex 219 0xDB -Udiaeresis 220 0xDC -Yacute 221 0xDD -THORN 222 0xDE -ssharp 223 0xDF -agrave 224 0xE0 -aacute 225 0xE1 -acircumflex 226 0xE2 -atilde 227 0xE3 -adiaeresis 228 0xE4 -aring 229 0xE5 -ae 230 0xE6 -ccedilla 231 0xE7 -egrave 232 0xE8 -eacute 233 0xE9 -ecircumflex 234 0xEA -ediaeresis 235 0xEB -igrave 236 0xEC -iacute 237 0xED -icircumflex 238 0xEE -idiaeresis 239 0xEF -eth 240 0xF0 -ntilde 241 0xF1 -ograve 242 0xF2 -oacute 243 0xF3 -ocircumflex 244 0xF4 -otilde 245 0xF5 -odiaeresis 246 0xF6 -division 247 0xF7 -oslash 248 0xF8 -ugrave 249 0xF9 -uacute 250 0xFA -ucircumflex 251 0xFB -udiaeresis 252 0xFC -yacute 253 0xFD -thorn 254 0xFE -ydiaeresis 255 0xFF +\(rg (registered) 174 0xAE +\(a- (macron) 175 0xAF +\(de (degree) 176 0xB0 +\(+- (plusminus) 177 0xB1 +\(S2 (twosuperior) 178 0xB2 +\(S3 (threesuperior) 179 0xB3 +\(aa (acute) 180 0xB4 +\(mc (mu) 181 0xB5 +\(ps (paragraph) 182 0xB6 +\(pc (periodcentered) 183 0xB7 +\(ac (cedilla) 184 0xB8 +\(S1 (onesuperior) 185 0xB9 +\(Om (masculine) 186 0xBA +\(Fc (guillemotright) 187 0xBB +\(14 (onequarter) 188 0xBC +\(12 (onehalf) 189 0xBD +\(34 (threequarters) 190 0xBE +\(r? (questiondown) 191 0xBF +\(`A (Agrave) 192 0xC0 +\('A (Aacute) 193 0xC1 +\(^A (Acircumflex) 194 0xC2 +\(~A (Atilde) 195 0xC3 +\(:A (Adiaeresis) 196 0xC4 +\(oA (Aring) 197 0xC5 +\(AE (AE) 198 0xC6 +\(,C (Ccedilla) 199 0xC7 +\(`E (Egrave) 200 0xC8 +\('E (Eacute) 201 0xC9 +\(^E (Ecircumflex) 202 0xCA +\(:E (Ediaeresis) 203 0xCB +\(`I (Igrave) 204 0xCC +\('I (Iacute) 205 0xCD +\(^I (Icircumflex) 206 0xCE +\(:I (Idiaeresis) 207 0xCF +\(-D (ETH) 208 0xD0 +\(~N (Ntilde) 209 0xD1 +\(`O (Ograve) 210 0xD2 +\('O (Oacute) 211 0xD3 +\(^O (Ocircumflex) 212 0xD4 +\(~O (Otilde) 213 0xD5 +\(:O (Odiaeresis) 214 0xD6 +\(mu (multiply) 215 0xD7 +\(/O (Oslash) 216 0xD8 +\(`U (Ugrave) 217 0xD9 +\('U (Uacute) 218 0xDA +\(^U (Ucircumflex) 219 0xDB +\(:U (Udiaeresis) 220 0xDC +\('Y (Yacute) 221 0xDD +\(TP (THORN) 222 0xDE +\(ss (ssharp) 223 0xDF +\(`a (agrave) 224 0xE0 +\('a (aacute) 225 0xE1 +\(^a (acircumflex) 226 0xE2 +\(~a (atilde) 227 0xE3 +\(:a (adiaeresis) 228 0xE4 +\(oa (aring) 229 0xE5 +\(ae (ae) 230 0xE6 +\(,c (ccedilla) 231 0xE7 +\(`e (egrave) 232 0xE8 +\('e (eacute) 233 0xE9 +\(^e (ecircumflex) 234 0xEA +\(:e (ediaeresis) 235 0xEB +\(`i (igrave) 236 0xEC +\('i (iacute) 237 0xED +\(^i (icircumflex) 238 0xEE +\(:i (idiaeresis) 239 0xEF +\(Sd (eth) 240 0xF0 +\(~n (ntilde) 241 0xF1 +\(`o (ograve) 242 0xF2 +\('o (oacute) 243 0xF3 +\(^o (ocircumflex) 244 0xF4 +\(~o (otilde) 245 0xF5 +\(:o (odiaeresis) 246 0xF6 +\(di (division) 247 0xF7 +\(/o (oslash) 248 0xF8 +\(`u (ugrave) 249 0xF9 +\('u (uacute) 250 0xFA +\(^u (ucircumflex) 251 0xFB +\(:u (udiaeresis) 252 0xFC +\('y (yacute) 253 0xFD +\(Tp (thorn) 254 0xFE +\(:y (ydiaeresis) 255 0xFF +.CE +.CS Aogonek 417 0x1A1 breve 418 0x1A2 Lstroke 419 0x1A3 Lcaron 421 0x1A5 Sacute 422 0x1A6 Scaron 425 0x1A9 Scedilla 426 0x1AA Tcaron 427 0x1AB Zacute 428 0x1AC -.CE -.CS Zcaron 430 0x1AE Zabovedot 431 0x1AF aogonek 433 0x1B1 ogonek 434 0x1B2 lstroke 435 0x1B3 @@ -392,10 +392,12 @@ kana_RO 1243 0x4DB kana_WA 1244 0x4DC kana_N 1245 0x4DD voicedsound 1246 0x4DE semivoicedsound 1247 0x4DF +.CE +.CS Arabic_comma 1452 0x5AC Arabic_semicolon 1467 0x5BB Arabic_question_mark 1471 0x5BF Arabic_hamza 1473 0x5C1 Arabic_maddaonalef 1474 0x5C2 @@ -427,12 +429,10 @@ Arabic_feh 1505 0x5E1 Arabic_qaf 1506 0x5E2 Arabic_kaf 1507 0x5E3 Arabic_lam 1508 0x5E4 Arabic_meem 1509 0x5E5 -.CE -.CS Arabic_noon 1510 0x5E6 Arabic_ha 1511 0x5E7 Arabic_waw 1512 0x5E8 Arabic_alefmaksura 1513 0x5E9 Arabic_yeh 1514 0x5EA @@ -542,13 +542,15 @@ Greek_ALPHAaccent 1953 0x7A1 Greek_EPSILONaccent 1954 0x7A2 Greek_ETAaccent 1955 0x7A3 Greek_IOTAaccent 1956 0x7A4 Greek_IOTAdieresis 1957 0x7A5 +Greek_IOTAaccentdiaeresis 1958 0x7A6 Greek_OMICRONaccent 1959 0x7A7 Greek_UPSILONaccent 1960 0x7A8 Greek_UPSILONdieresis 1961 0x7A9 +Greek_UPSILONaccentdieresis 1962 0x7AA Greek_OMEGAaccent 1963 0x7AB Greek_accentdieresis 1966 0x7AE Greek_horizbar 1967 0x7AF Greek_alphaaccent 1969 0x7B1 Greek_epsilonaccent 1970 0x7B2 @@ -608,10 +610,12 @@ Greek_upsilon 2037 0x7F5 Greek_phi 2038 0x7F6 Greek_chi 2039 0x7F7 Greek_psi 2040 0x7F8 Greek_omega 2041 0x7F9 +.CE +.CS leftradical 2209 0x8A1 topleftradical 2210 0x8A2 horizconnector 2211 0x8A3 topintegral 2212 0x8A4 botintegral 2213 0x8A5 @@ -631,12 +635,10 @@ topvertsummationconnector 2227 0x8B3 botvertsummationconnector 2228 0x8B4 toprightsummation 2229 0x8B5 botrightsummation 2230 0x8B6 rightmiddlesummation 2231 0x8B7 -.CE -.CS lessthanequal 2236 0x8BC notequal 2237 0x8BD greaterthanequal 2238 0x8BE integral 2239 0x8BF therefore 2240 0x8C0 @@ -814,10 +816,12 @@ hebrew_zade 3318 0xCF6 hebrew_qoph 3319 0xCF7 hebrew_resh 3320 0xCF8 hebrew_shin 3321 0xCF9 hebrew_taw 3322 0xCFA +.CE +.CS Thai_kokai 3489 0xDA1 Thai_khokhai 3490 0xDA2 Thai_khokhuat 3491 0xDA3 Thai_khokhwai 3492 0xDA4 Thai_khokhon 3493 0xDA5 @@ -992,11 +996,13 @@ Hangul_J_YeorinHieuh 3834 0xEFA Korean_Won 3839 0xEFF OE 5052 0x13BC oe 5053 0x13BD Ydiaeresis 5054 0x13BE -EuroSign 8364 0x20AC +\(eu (EuroSign) 8364 0x20AC +.CE +.CS 3270_Duplicate 64769 0xFD01 3270_FieldMark 64770 0xFD02 3270_Right2 64771 0xFD03 3270_Left2 64772 0xFD04 3270_BackTab 64773 0xFD05 @@ -1163,10 +1169,12 @@ Pointer_EnableKeys 65273 0xFEF9 Pointer_Accelerate 65274 0xFEFA Pointer_DfltBtnNext 65275 0xFEFB Pointer_DfltBtnPrev 65276 0xFEFC Pointer_Drag5 65277 0xFEFD +.CE +.CS BackSpace 65288 0xFF08 Tab 65289 0xFF09 Linefeed 65290 0xFF0A Clear 65291 0xFF0B Return 65293 0xFF0D @@ -1213,22 +1221,17 @@ Down 65364 0xFF54 Prior 65365 0xFF55 Next 65366 0xFF56 End 65367 0xFF57 Begin 65368 0xFF58 -Win_L 65371 0xFF5B -Win_R 65372 0xFF5C -.CE -.CS -App 65373 0xFF5D Select 65376 0xFF60 Print 65377 0xFF61 Execute 65378 0xFF62 Insert 65379 0xFF63 Undo 65381 0xFF65 Redo 65382 0xFF66 -Menu 65383 0xFF67 +Menu (App) 65383 0xFF67 Find 65384 0xFF68 Cancel 65385 0xFF69 Help 65386 0xFF6A Break 65387 0xFF6B Mode_switch 65406 0xFF7E @@ -1311,12 +1314,12 @@ Shift_Lock 65510 0xFFE6 Meta_L 65511 0xFFE7 Meta_R 65512 0xFFE8 Alt_L 65513 0xFFE9 Alt_R 65514 0xFFEA -Super_L 65515 0xFFEB -Super_R 65516 0xFFEC +Super_L (Win_L) 65515 0xFFEB +Super_R (Win_R) 65516 0xFFEC Hyper_L 65517 0xFFED Hyper_R 65518 0xFFEE braille_dot_1 65521 0xFFF1 braille_dot_2 65522 0xFFF2 braille_dot_3 65523 0xFFF3 @@ -1326,719 +1329,12 @@ braille_dot_7 65527 0xFFF7 braille_dot_8 65528 0xFFF8 braille_dot_9 65529 0xFFF9 braille_dot_10 65530 0xFFFA Delete 65535 0xFFFF -Ibreve 16777516 0x100012C -ibreve 16777517 0x100012D -Wcircumflex 16777588 0x1000174 -wcircumflex 16777589 0x1000175 -Ycircumflex 16777590 0x1000176 -ycircumflex 16777591 0x1000177 -SCHWA 16777615 0x100018F -Obarred 16777631 0x100019F -Ohorn 16777632 0x10001A0 -ohorn 16777633 0x10001A1 -Uhorn 16777647 0x10001AF -uhorn 16777648 0x10001B0 -Zstroke 16777653 0x10001B5 -zstroke 16777654 0x10001B6 -EZH 16777655 0x10001B7 -Ocaron 16777681 0x10001D1 -ocaron 16777682 0x10001D2 -Gcaron 16777702 0x10001E6 -gcaron 16777703 0x10001E7 -schwa 16777817 0x1000259 -obarred 16777845 0x1000275 -ezh 16777874 0x1000292 -Cyrillic_GHE_bar 16778386 0x1000492 -Cyrillic_ghe_bar 16778387 0x1000493 -Cyrillic_ZHE_descender 16778390 0x1000496 -Cyrillic_zhe_descender 16778391 0x1000497 -Cyrillic_KA_descender 16778394 0x100049A -Cyrillic_ka_descender 16778395 0x100049B -Cyrillic_KA_vertstroke 16778396 0x100049C -Cyrillic_ka_vertstroke 16778397 0x100049D -Cyrillic_EN_descender 16778402 0x10004A2 -Cyrillic_en_descender 16778403 0x10004A3 -Cyrillic_U_straight 16778414 0x10004AE -Cyrillic_u_straight 16778415 0x10004AF -Cyrillic_U_straight_bar 16778416 0x10004B0 -Cyrillic_u_straight_bar 16778417 0x10004B1 -Cyrillic_HA_descender 16778418 0x10004B2 -Cyrillic_ha_descender 16778419 0x10004B3 -Cyrillic_CHE_descender 16778422 0x10004B6 -Cyrillic_che_descender 16778423 0x10004B7 -Cyrillic_CHE_vertstroke 16778424 0x10004B8 -Cyrillic_che_vertstroke 16778425 0x10004B9 -Cyrillic_SHHA 16778426 0x10004BA -Cyrillic_shha 16778427 0x10004BB -Cyrillic_SCHWA 16778456 0x10004D8 -Cyrillic_schwa 16778457 0x10004D9 -Cyrillic_I_macron 16778466 0x10004E2 -Cyrillic_i_macron 16778467 0x10004E3 -Cyrillic_O_bar 16778472 0x10004E8 -Cyrillic_o_bar 16778473 0x10004E9 -Cyrillic_U_macron 16778478 0x10004EE -Cyrillic_u_macron 16778479 0x10004EF -Armenian_AYB 16778545 0x1000531 -Armenian_BEN 16778546 0x1000532 -Armenian_GIM 16778547 0x1000533 -Armenian_DA 16778548 0x1000534 -Armenian_YECH 16778549 0x1000535 -Armenian_ZA 16778550 0x1000536 -Armenian_E 16778551 0x1000537 -Armenian_AT 16778552 0x1000538 -Armenian_TO 16778553 0x1000539 -Armenian_ZHE 16778554 0x100053A -Armenian_INI 16778555 0x100053B -Armenian_LYUN 16778556 0x100053C -Armenian_KHE 16778557 0x100053D -Armenian_TSA 16778558 0x100053E -Armenian_KEN 16778559 0x100053F -Armenian_HO 16778560 0x1000540 -Armenian_DZA 16778561 0x1000541 -Armenian_GHAT 16778562 0x1000542 -Armenian_TCHE 16778563 0x1000543 -Armenian_MEN 16778564 0x1000544 -Armenian_HI 16778565 0x1000545 -Armenian_NU 16778566 0x1000546 -Armenian_SHA 16778567 0x1000547 -Armenian_VO 16778568 0x1000548 -Armenian_CHA 16778569 0x1000549 -Armenian_PE 16778570 0x100054A -Armenian_JE 16778571 0x100054B -Armenian_RA 16778572 0x100054C -Armenian_SE 16778573 0x100054D -Armenian_VEV 16778574 0x100054E -Armenian_TYUN 16778575 0x100054F -Armenian_RE 16778576 0x1000550 -Armenian_TSO 16778577 0x1000551 -Armenian_VYUN 16778578 0x1000552 -Armenian_PYUR 16778579 0x1000553 -Armenian_KE 16778580 0x1000554 -Armenian_O 16778581 0x1000555 -Armenian_FE 16778582 0x1000556 -Armenian_apostrophe 16778586 0x100055A -Armenian_accent 16778587 0x100055B -Armenian_exclam 16778588 0x100055C -Armenian_separation_mark 16778589 0x100055D -Armenian_question 16778590 0x100055E -Armenian_ayb 16778593 0x1000561 -Armenian_ben 16778594 0x1000562 -Armenian_gim 16778595 0x1000563 -Armenian_da 16778596 0x1000564 -Armenian_yech 16778597 0x1000565 -Armenian_za 16778598 0x1000566 -Armenian_e 16778599 0x1000567 -Armenian_at 16778600 0x1000568 -Armenian_to 16778601 0x1000569 -Armenian_zhe 16778602 0x100056A -Armenian_ini 16778603 0x100056B -Armenian_lyun 16778604 0x100056C -Armenian_khe 16778605 0x100056D -Armenian_tsa 16778606 0x100056E -Armenian_ken 16778607 0x100056F -Armenian_ho 16778608 0x1000570 -Armenian_dza 16778609 0x1000571 -Armenian_ghat 16778610 0x1000572 -Armenian_tche 16778611 0x1000573 -Armenian_men 16778612 0x1000574 -Armenian_hi 16778613 0x1000575 -Armenian_nu 16778614 0x1000576 -Armenian_sha 16778615 0x1000577 -Armenian_vo 16778616 0x1000578 -Armenian_cha 16778617 0x1000579 -Armenian_pe 16778618 0x100057A -Armenian_je 16778619 0x100057B -Armenian_ra 16778620 0x100057C -Armenian_se 16778621 0x100057D -Armenian_vev 16778622 0x100057E -Armenian_tyun 16778623 0x100057F -Armenian_re 16778624 0x1000580 -Armenian_tso 16778625 0x1000581 -Armenian_vyun 16778626 0x1000582 -Armenian_pyur 16778627 0x1000583 -Armenian_ke 16778628 0x1000584 -Armenian_o 16778629 0x1000585 -Armenian_fe 16778630 0x1000586 -Armenian_ligature_ew 16778631 0x1000587 -Armenian_full_stop 16778633 0x1000589 -Armenian_hyphen 16778634 0x100058A -Arabic_madda_above 16778835 0x1000653 -Arabic_hamza_above 16778836 0x1000654 -Arabic_hamza_below 16778837 0x1000655 -Arabic_0 16778848 0x1000660 -Arabic_1 16778849 0x1000661 -Arabic_2 16778850 0x1000662 -Arabic_3 16778851 0x1000663 -Arabic_4 16778852 0x1000664 -Arabic_5 16778853 0x1000665 -Arabic_6 16778854 0x1000666 -Arabic_7 16778855 0x1000667 -Arabic_8 16778856 0x1000668 -Arabic_9 16778857 0x1000669 -Arabic_percent 16778858 0x100066A -Arabic_superscript_alef 16778864 0x1000670 -Arabic_tteh 16778873 0x1000679 -Arabic_peh 16778878 0x100067E -Arabic_tcheh 16778886 0x1000686 -Arabic_ddal 16778888 0x1000688 -Arabic_rreh 16778897 0x1000691 -Arabic_jeh 16778904 0x1000698 -Arabic_veh 16778916 0x10006A4 -Arabic_keheh 16778921 0x10006A9 -Arabic_gaf 16778927 0x10006AF -Arabic_noon_ghunna 16778938 0x10006BA -Arabic_heh_doachashmee 16778942 0x10006BE -Arabic_heh_goal 16778945 0x10006C1 -Farsi_yeh 16778956 0x10006CC -Arabic_yeh_baree 16778962 0x10006D2 -Arabic_fullstop 16778964 0x10006D4 -Farsi_0 16778992 0x10006F0 -Farsi_1 16778993 0x10006F1 -Farsi_2 16778994 0x10006F2 -Farsi_3 16778995 0x10006F3 -Farsi_4 16778996 0x10006F4 -Farsi_5 16778997 0x10006F5 -Farsi_6 16778998 0x10006F6 -Farsi_7 16778999 0x10006F7 -Farsi_8 16779000 0x10006F8 -Farsi_9 16779001 0x10006F9 -Sinh_ng 16780674 0x1000D82 -Sinh_h2 16780675 0x1000D83 -Sinh_a 16780677 0x1000D85 -Sinh_aa 16780678 0x1000D86 -Sinh_ae 16780679 0x1000D87 -Sinh_aee 16780680 0x1000D88 -Sinh_i 16780681 0x1000D89 -Sinh_ii 16780682 0x1000D8A -Sinh_u 16780683 0x1000D8B -Sinh_uu 16780684 0x1000D8C -Sinh_ri 16780685 0x1000D8D -Sinh_rii 16780686 0x1000D8E -Sinh_lu 16780687 0x1000D8F -Sinh_luu 16780688 0x1000D90 -Sinh_e 16780689 0x1000D91 -Sinh_ee 16780690 0x1000D92 -Sinh_ai 16780691 0x1000D93 -Sinh_o 16780692 0x1000D94 -Sinh_oo 16780693 0x1000D95 -Sinh_au 16780694 0x1000D96 -Sinh_ka 16780698 0x1000D9A -Sinh_kha 16780699 0x1000D9B -Sinh_ga 16780700 0x1000D9C -Sinh_gha 16780701 0x1000D9D -Sinh_ng2 16780702 0x1000D9E -Sinh_nga 16780703 0x1000D9F -Sinh_ca 16780704 0x1000DA0 -Sinh_cha 16780705 0x1000DA1 -Sinh_ja 16780706 0x1000DA2 -Sinh_jha 16780707 0x1000DA3 -Sinh_nya 16780708 0x1000DA4 -Sinh_jnya 16780709 0x1000DA5 -Sinh_nja 16780710 0x1000DA6 -Sinh_tta 16780711 0x1000DA7 -Sinh_ttha 16780712 0x1000DA8 -Sinh_dda 16780713 0x1000DA9 -Sinh_ddha 16780714 0x1000DAA -Sinh_nna 16780715 0x1000DAB -Sinh_ndda 16780716 0x1000DAC -Sinh_tha 16780717 0x1000DAD -Sinh_thha 16780718 0x1000DAE -Sinh_dha 16780719 0x1000DAF -Sinh_dhha 16780720 0x1000DB0 -Sinh_na 16780721 0x1000DB1 -Sinh_ndha 16780723 0x1000DB3 -Sinh_pa 16780724 0x1000DB4 -Sinh_pha 16780725 0x1000DB5 -Sinh_ba 16780726 0x1000DB6 -Sinh_bha 16780727 0x1000DB7 -Sinh_ma 16780728 0x1000DB8 -Sinh_mba 16780729 0x1000DB9 -Sinh_ya 16780730 0x1000DBA -Sinh_ra 16780731 0x1000DBB -Sinh_la 16780733 0x1000DBD -Sinh_va 16780736 0x1000DC0 -Sinh_sha 16780737 0x1000DC1 -Sinh_ssha 16780738 0x1000DC2 -Sinh_sa 16780739 0x1000DC3 -Sinh_ha 16780740 0x1000DC4 -Sinh_lla 16780741 0x1000DC5 -Sinh_fa 16780742 0x1000DC6 -Sinh_al 16780746 0x1000DCA -Sinh_aa2 16780751 0x1000DCF -Sinh_ae2 16780752 0x1000DD0 -Sinh_aee2 16780753 0x1000DD1 -Sinh_i2 16780754 0x1000DD2 -Sinh_ii2 16780755 0x1000DD3 -Sinh_u2 16780756 0x1000DD4 -Sinh_uu2 16780758 0x1000DD6 -Sinh_ru2 16780760 0x1000DD8 -Sinh_e2 16780761 0x1000DD9 -Sinh_ee2 16780762 0x1000DDA -Sinh_ai2 16780763 0x1000DDB -Sinh_o2 16780764 0x1000DDC -Sinh_oo2 16780765 0x1000DDD -Sinh_au2 16780766 0x1000DDE -Sinh_lu2 16780767 0x1000DDF -Sinh_ruu2 16780786 0x1000DF2 -Sinh_luu2 16780787 0x1000DF3 -Sinh_kunddaliya 16780788 0x1000DF4 -Georgian_an 16781520 0x10010D0 -Georgian_ban 16781521 0x10010D1 -Georgian_gan 16781522 0x10010D2 -Georgian_don 16781523 0x10010D3 -Georgian_en 16781524 0x10010D4 -Georgian_vin 16781525 0x10010D5 -Georgian_zen 16781526 0x10010D6 -Georgian_tan 16781527 0x10010D7 -Georgian_in 16781528 0x10010D8 -Georgian_kan 16781529 0x10010D9 -Georgian_las 16781530 0x10010DA -Georgian_man 16781531 0x10010DB -Georgian_nar 16781532 0x10010DC -Georgian_on 16781533 0x10010DD -Georgian_par 16781534 0x10010DE -Georgian_zhar 16781535 0x10010DF -Georgian_rae 16781536 0x10010E0 -Georgian_san 16781537 0x10010E1 -Georgian_tar 16781538 0x10010E2 -Georgian_un 16781539 0x10010E3 -Georgian_phar 16781540 0x10010E4 -Georgian_khar 16781541 0x10010E5 -Georgian_ghan 16781542 0x10010E6 -Georgian_qar 16781543 0x10010E7 -Georgian_shin 16781544 0x10010E8 -Georgian_chin 16781545 0x10010E9 -Georgian_can 16781546 0x10010EA -Georgian_jil 16781547 0x10010EB -Georgian_cil 16781548 0x10010EC -Georgian_char 16781549 0x10010ED -Georgian_xan 16781550 0x10010EE -Georgian_jhan 16781551 0x10010EF -Georgian_hae 16781552 0x10010F0 -Georgian_he 16781553 0x10010F1 -Georgian_hie 16781554 0x10010F2 -Georgian_we 16781555 0x10010F3 -Georgian_har 16781556 0x10010F4 -Georgian_hoe 16781557 0x10010F5 -Georgian_fi 16781558 0x10010F6 -Babovedot 16784898 0x1001E02 -babovedot 16784899 0x1001E03 -Dabovedot 16784906 0x1001E0A -dabovedot 16784907 0x1001E0B -Fabovedot 16784926 0x1001E1E -fabovedot 16784927 0x1001E1F -Lbelowdot 16784950 0x1001E36 -lbelowdot 16784951 0x1001E37 -Mabovedot 16784960 0x1001E40 -mabovedot 16784961 0x1001E41 -Pabovedot 16784982 0x1001E56 -pabovedot 16784983 0x1001E57 -Sabovedot 16784992 0x1001E60 -sabovedot 16784993 0x1001E61 -Tabovedot 16785002 0x1001E6A -tabovedot 16785003 0x1001E6B -Wgrave 16785024 0x1001E80 -wgrave 16785025 0x1001E81 -Wacute 16785026 0x1001E82 -wacute 16785027 0x1001E83 -Wdiaeresis 16785028 0x1001E84 -wdiaeresis 16785029 0x1001E85 -Xabovedot 16785034 0x1001E8A -xabovedot 16785035 0x1001E8B -Abelowdot 16785056 0x1001EA0 -abelowdot 16785057 0x1001EA1 -Ahook 16785058 0x1001EA2 -ahook 16785059 0x1001EA3 -Acircumflexacute 16785060 0x1001EA4 -acircumflexacute 16785061 0x1001EA5 -Acircumflexgrave 16785062 0x1001EA6 -acircumflexgrave 16785063 0x1001EA7 -Acircumflexhook 16785064 0x1001EA8 -acircumflexhook 16785065 0x1001EA9 -Acircumflextilde 16785066 0x1001EAA -acircumflextilde 16785067 0x1001EAB -Acircumflexbelowdot 16785068 0x1001EAC -acircumflexbelowdot 16785069 0x1001EAD -Abreveacute 16785070 0x1001EAE -abreveacute 16785071 0x1001EAF -Abrevegrave 16785072 0x1001EB0 -abrevegrave 16785073 0x1001EB1 -Abrevehook 16785074 0x1001EB2 -abrevehook 16785075 0x1001EB3 -Abrevetilde 16785076 0x1001EB4 -abrevetilde 16785077 0x1001EB5 -Abrevebelowdot 16785078 0x1001EB6 -abrevebelowdot 16785079 0x1001EB7 -Ebelowdot 16785080 0x1001EB8 -ebelowdot 16785081 0x1001EB9 -Ehook 16785082 0x1001EBA -ehook 16785083 0x1001EBB -Etilde 16785084 0x1001EBC -etilde 16785085 0x1001EBD -Ecircumflexacute 16785086 0x1001EBE -ecircumflexacute 16785087 0x1001EBF -Ecircumflexgrave 16785088 0x1001EC0 -ecircumflexgrave 16785089 0x1001EC1 -Ecircumflexhook 16785090 0x1001EC2 -ecircumflexhook 16785091 0x1001EC3 -Ecircumflextilde 16785092 0x1001EC4 -ecircumflextilde 16785093 0x1001EC5 -Ecircumflexbelowdot 16785094 0x1001EC6 -ecircumflexbelowdot 16785095 0x1001EC7 -Ihook 16785096 0x1001EC8 -ihook 16785097 0x1001EC9 -Ibelowdot 16785098 0x1001ECA -ibelowdot 16785099 0x1001ECB -Obelowdot 16785100 0x1001ECC -obelowdot 16785101 0x1001ECD -Ohook 16785102 0x1001ECE -ohook 16785103 0x1001ECF -Ocircumflexacute 16785104 0x1001ED0 -ocircumflexacute 16785105 0x1001ED1 -Ocircumflexgrave 16785106 0x1001ED2 -ocircumflexgrave 16785107 0x1001ED3 -Ocircumflexhook 16785108 0x1001ED4 -ocircumflexhook 16785109 0x1001ED5 -Ocircumflextilde 16785110 0x1001ED6 -ocircumflextilde 16785111 0x1001ED7 -Ocircumflexbelowdot 16785112 0x1001ED8 -ocircumflexbelowdot 16785113 0x1001ED9 -Ohornacute 16785114 0x1001EDA -ohornacute 16785115 0x1001EDB -Ohorngrave 16785116 0x1001EDC -ohorngrave 16785117 0x1001EDD -Ohornhook 16785118 0x1001EDE -ohornhook 16785119 0x1001EDF -Ohorntilde 16785120 0x1001EE0 -ohorntilde 16785121 0x1001EE1 -Ohornbelowdot 16785122 0x1001EE2 -ohornbelowdot 16785123 0x1001EE3 -Ubelowdot 16785124 0x1001EE4 -ubelowdot 16785125 0x1001EE5 -Uhook 16785126 0x1001EE6 -uhook 16785127 0x1001EE7 -Uhornacute 16785128 0x1001EE8 -uhornacute 16785129 0x1001EE9 -Uhorngrave 16785130 0x1001EEA -uhorngrave 16785131 0x1001EEB -Uhornhook 16785132 0x1001EEC -uhornhook 16785133 0x1001EED -Uhorntilde 16785134 0x1001EEE -uhorntilde 16785135 0x1001EEF -Uhornbelowdot 16785136 0x1001EF0 -uhornbelowdot 16785137 0x1001EF1 -Ygrave 16785138 0x1001EF2 -ygrave 16785139 0x1001EF3 -Ybelowdot 16785140 0x1001EF4 -ybelowdot 16785141 0x1001EF5 -Yhook 16785142 0x1001EF6 -yhook 16785143 0x1001EF7 -Ytilde 16785144 0x1001EF8 -ytilde 16785145 0x1001EF9 -zerosuperior 16785520 0x1002070 -foursuperior 16785524 0x1002074 -fivesuperior 16785525 0x1002075 -sixsuperior 16785526 0x1002076 -sevensuperior 16785527 0x1002077 -eightsuperior 16785528 0x1002078 -ninesuperior 16785529 0x1002079 -zerosubscript 16785536 0x1002080 -onesubscript 16785537 0x1002081 -twosubscript 16785538 0x1002082 -threesubscript 16785539 0x1002083 -foursubscript 16785540 0x1002084 -fivesubscript 16785541 0x1002085 -sixsubscript 16785542 0x1002086 -sevensubscript 16785543 0x1002087 -eightsubscript 16785544 0x1002088 -ninesubscript 16785545 0x1002089 -EcuSign 16785568 0x10020A0 -ColonSign 16785569 0x10020A1 -CruzeiroSign 16785570 0x10020A2 -FFrancSign 16785571 0x10020A3 -LiraSign 16785572 0x10020A4 -MillSign 16785573 0x10020A5 -NairaSign 16785574 0x10020A6 -PesetaSign 16785575 0x10020A7 -RupeeSign 16785576 0x10020A8 -WonSign 16785577 0x10020A9 -NewSheqelSign 16785578 0x10020AA -DongSign 16785579 0x10020AB -partdifferential 16785922 0x1002202 -emptyset 16785925 0x1002205 -elementof 16785928 0x1002208 -notelementof 16785929 0x1002209 -containsas 16785931 0x100220B -squareroot 16785946 0x100221A -cuberoot 16785947 0x100221B -fourthroot 16785948 0x100221C -dintegral 16785964 0x100222C -tintegral 16785965 0x100222D -because 16785973 0x1002235 -notapproxeq 16785991 0x1002247 -approxeq 16785992 0x1002248 -notidentical 16786018 0x1002262 -stricteq 16786019 0x1002263 -braille_blank 16787456 0x1002800 -braille_dots_1 16787457 0x1002801 -braille_dots_2 16787458 0x1002802 -braille_dots_12 16787459 0x1002803 -braille_dots_3 16787460 0x1002804 -braille_dots_13 16787461 0x1002805 -braille_dots_23 16787462 0x1002806 -braille_dots_123 16787463 0x1002807 -braille_dots_4 16787464 0x1002808 -braille_dots_14 16787465 0x1002809 -braille_dots_24 16787466 0x100280A -braille_dots_124 16787467 0x100280B -braille_dots_34 16787468 0x100280C -braille_dots_134 16787469 0x100280D -braille_dots_234 16787470 0x100280E -braille_dots_1234 16787471 0x100280F -braille_dots_5 16787472 0x1002810 -braille_dots_15 16787473 0x1002811 -braille_dots_25 16787474 0x1002812 -braille_dots_125 16787475 0x1002813 -braille_dots_35 16787476 0x1002814 -braille_dots_135 16787477 0x1002815 -braille_dots_235 16787478 0x1002816 -braille_dots_1235 16787479 0x1002817 -braille_dots_45 16787480 0x1002818 -braille_dots_145 16787481 0x1002819 -braille_dots_245 16787482 0x100281A -braille_dots_1245 16787483 0x100281B -braille_dots_345 16787484 0x100281C -braille_dots_1345 16787485 0x100281D -braille_dots_2345 16787486 0x100281E -braille_dots_12345 16787487 0x100281F -braille_dots_6 16787488 0x1002820 -braille_dots_16 16787489 0x1002821 -braille_dots_26 16787490 0x1002822 -braille_dots_126 16787491 0x1002823 -braille_dots_36 16787492 0x1002824 -braille_dots_136 16787493 0x1002825 -braille_dots_236 16787494 0x1002826 -braille_dots_1236 16787495 0x1002827 -braille_dots_46 16787496 0x1002828 -braille_dots_146 16787497 0x1002829 -braille_dots_246 16787498 0x100282A -braille_dots_1246 16787499 0x100282B -braille_dots_346 16787500 0x100282C -braille_dots_1346 16787501 0x100282D -braille_dots_2346 16787502 0x100282E -braille_dots_12346 16787503 0x100282F -braille_dots_56 16787504 0x1002830 -braille_dots_156 16787505 0x1002831 -braille_dots_256 16787506 0x1002832 -braille_dots_1256 16787507 0x1002833 -braille_dots_356 16787508 0x1002834 -braille_dots_1356 16787509 0x1002835 -braille_dots_2356 16787510 0x1002836 -braille_dots_12356 16787511 0x1002837 -braille_dots_456 16787512 0x1002838 -braille_dots_1456 16787513 0x1002839 -braille_dots_2456 16787514 0x100283A -braille_dots_12456 16787515 0x100283B -braille_dots_3456 16787516 0x100283C -braille_dots_13456 16787517 0x100283D -braille_dots_23456 16787518 0x100283E -braille_dots_123456 16787519 0x100283F -braille_dots_7 16787520 0x1002840 -braille_dots_17 16787521 0x1002841 -braille_dots_27 16787522 0x1002842 -braille_dots_127 16787523 0x1002843 -braille_dots_37 16787524 0x1002844 -braille_dots_137 16787525 0x1002845 -braille_dots_237 16787526 0x1002846 -braille_dots_1237 16787527 0x1002847 -braille_dots_47 16787528 0x1002848 -braille_dots_147 16787529 0x1002849 -braille_dots_247 16787530 0x100284A -braille_dots_1247 16787531 0x100284B -braille_dots_347 16787532 0x100284C -braille_dots_1347 16787533 0x100284D -braille_dots_2347 16787534 0x100284E -braille_dots_12347 16787535 0x100284F -braille_dots_57 16787536 0x1002850 -braille_dots_157 16787537 0x1002851 -braille_dots_257 16787538 0x1002852 -braille_dots_1257 16787539 0x1002853 -braille_dots_357 16787540 0x1002854 -braille_dots_1357 16787541 0x1002855 -braille_dots_2357 16787542 0x1002856 -braille_dots_12357 16787543 0x1002857 -braille_dots_457 16787544 0x1002858 -braille_dots_1457 16787545 0x1002859 -braille_dots_2457 16787546 0x100285A -braille_dots_12457 16787547 0x100285B -braille_dots_3457 16787548 0x100285C -braille_dots_13457 16787549 0x100285D -braille_dots_23457 16787550 0x100285E -braille_dots_123457 16787551 0x100285F -braille_dots_67 16787552 0x1002860 -braille_dots_167 16787553 0x1002861 -braille_dots_267 16787554 0x1002862 -braille_dots_1267 16787555 0x1002863 -braille_dots_367 16787556 0x1002864 -braille_dots_1367 16787557 0x1002865 -braille_dots_2367 16787558 0x1002866 -braille_dots_12367 16787559 0x1002867 -braille_dots_467 16787560 0x1002868 -braille_dots_1467 16787561 0x1002869 -braille_dots_2467 16787562 0x100286A -braille_dots_12467 16787563 0x100286B -braille_dots_3467 16787564 0x100286C -braille_dots_13467 16787565 0x100286D -braille_dots_23467 16787566 0x100286E -braille_dots_123467 16787567 0x100286F -braille_dots_567 16787568 0x1002870 -braille_dots_1567 16787569 0x1002871 -braille_dots_2567 16787570 0x1002872 -braille_dots_12567 16787571 0x1002873 -braille_dots_3567 16787572 0x1002874 -braille_dots_13567 16787573 0x1002875 -braille_dots_23567 16787574 0x1002876 -braille_dots_123567 16787575 0x1002877 -braille_dots_4567 16787576 0x1002878 -braille_dots_14567 16787577 0x1002879 -braille_dots_24567 16787578 0x100287A -braille_dots_124567 16787579 0x100287B -braille_dots_34567 16787580 0x100287C -braille_dots_134567 16787581 0x100287D -braille_dots_234567 16787582 0x100287E -braille_dots_1234567 16787583 0x100287F -braille_dots_8 16787584 0x1002880 -braille_dots_18 16787585 0x1002881 -braille_dots_28 16787586 0x1002882 -braille_dots_128 16787587 0x1002883 -braille_dots_38 16787588 0x1002884 -braille_dots_138 16787589 0x1002885 -braille_dots_238 16787590 0x1002886 -braille_dots_1238 16787591 0x1002887 -braille_dots_48 16787592 0x1002888 -braille_dots_148 16787593 0x1002889 -braille_dots_248 16787594 0x100288A -braille_dots_1248 16787595 0x100288B -braille_dots_348 16787596 0x100288C -braille_dots_1348 16787597 0x100288D -braille_dots_2348 16787598 0x100288E -braille_dots_12348 16787599 0x100288F -braille_dots_58 16787600 0x1002890 -braille_dots_158 16787601 0x1002891 -braille_dots_258 16787602 0x1002892 -braille_dots_1258 16787603 0x1002893 -braille_dots_358 16787604 0x1002894 -braille_dots_1358 16787605 0x1002895 -braille_dots_2358 16787606 0x1002896 -braille_dots_12358 16787607 0x1002897 -braille_dots_458 16787608 0x1002898 -braille_dots_1458 16787609 0x1002899 -braille_dots_2458 16787610 0x100289A -braille_dots_12458 16787611 0x100289B -braille_dots_3458 16787612 0x100289C -braille_dots_13458 16787613 0x100289D -braille_dots_23458 16787614 0x100289E -braille_dots_123458 16787615 0x100289F -braille_dots_68 16787616 0x10028A0 -braille_dots_168 16787617 0x10028A1 -braille_dots_268 16787618 0x10028A2 -braille_dots_1268 16787619 0x10028A3 -braille_dots_368 16787620 0x10028A4 -braille_dots_1368 16787621 0x10028A5 -braille_dots_2368 16787622 0x10028A6 -braille_dots_12368 16787623 0x10028A7 -braille_dots_468 16787624 0x10028A8 -braille_dots_1468 16787625 0x10028A9 -braille_dots_2468 16787626 0x10028AA -braille_dots_12468 16787627 0x10028AB -braille_dots_3468 16787628 0x10028AC -braille_dots_13468 16787629 0x10028AD -braille_dots_23468 16787630 0x10028AE -braille_dots_123468 16787631 0x10028AF -braille_dots_568 16787632 0x10028B0 -braille_dots_1568 16787633 0x10028B1 -braille_dots_2568 16787634 0x10028B2 -braille_dots_12568 16787635 0x10028B3 -braille_dots_3568 16787636 0x10028B4 -braille_dots_13568 16787637 0x10028B5 -braille_dots_23568 16787638 0x10028B6 -braille_dots_123568 16787639 0x10028B7 -braille_dots_4568 16787640 0x10028B8 -braille_dots_14568 16787641 0x10028B9 -braille_dots_24568 16787642 0x10028BA -braille_dots_124568 16787643 0x10028BB -braille_dots_34568 16787644 0x10028BC -braille_dots_134568 16787645 0x10028BD -braille_dots_234568 16787646 0x10028BE -braille_dots_1234568 16787647 0x10028BF -braille_dots_78 16787648 0x10028C0 -braille_dots_178 16787649 0x10028C1 -braille_dots_278 16787650 0x10028C2 -braille_dots_1278 16787651 0x10028C3 -braille_dots_378 16787652 0x10028C4 -braille_dots_1378 16787653 0x10028C5 -braille_dots_2378 16787654 0x10028C6 -braille_dots_12378 16787655 0x10028C7 -braille_dots_478 16787656 0x10028C8 -braille_dots_1478 16787657 0x10028C9 -braille_dots_2478 16787658 0x10028CA -braille_dots_12478 16787659 0x10028CB -braille_dots_3478 16787660 0x10028CC -braille_dots_13478 16787661 0x10028CD -braille_dots_23478 16787662 0x10028CE -braille_dots_123478 16787663 0x10028CF -braille_dots_578 16787664 0x10028D0 -braille_dots_1578 16787665 0x10028D1 -braille_dots_2578 16787666 0x10028D2 -braille_dots_12578 16787667 0x10028D3 -braille_dots_3578 16787668 0x10028D4 -braille_dots_13578 16787669 0x10028D5 -braille_dots_23578 16787670 0x10028D6 -braille_dots_123578 16787671 0x10028D7 -braille_dots_4578 16787672 0x10028D8 -braille_dots_14578 16787673 0x10028D9 -braille_dots_24578 16787674 0x10028DA -braille_dots_124578 16787675 0x10028DB -braille_dots_34578 16787676 0x10028DC -braille_dots_134578 16787677 0x10028DD -braille_dots_234578 16787678 0x10028DE -braille_dots_1234578 16787679 0x10028DF -braille_dots_678 16787680 0x10028E0 -braille_dots_1678 16787681 0x10028E1 -braille_dots_2678 16787682 0x10028E2 -braille_dots_12678 16787683 0x10028E3 -braille_dots_3678 16787684 0x10028E4 -braille_dots_13678 16787685 0x10028E5 -braille_dots_23678 16787686 0x10028E6 -braille_dots_123678 16787687 0x10028E7 -braille_dots_4678 16787688 0x10028E8 -braille_dots_14678 16787689 0x10028E9 -braille_dots_24678 16787690 0x10028EA -braille_dots_124678 16787691 0x10028EB -braille_dots_34678 16787692 0x10028EC -braille_dots_134678 16787693 0x10028ED -braille_dots_234678 16787694 0x10028EE -braille_dots_1234678 16787695 0x10028EF -braille_dots_5678 16787696 0x10028F0 -braille_dots_15678 16787697 0x10028F1 -braille_dots_25678 16787698 0x10028F2 -braille_dots_125678 16787699 0x10028F3 -braille_dots_35678 16787700 0x10028F4 -braille_dots_135678 16787701 0x10028F5 -braille_dots_235678 16787702 0x10028F6 -braille_dots_1235678 16787703 0x10028F7 -braille_dots_45678 16787704 0x10028F8 -braille_dots_145678 16787705 0x10028F9 -braille_dots_245678 16787706 0x10028FA -braille_dots_1245678 16787707 0x10028FB -braille_dots_345678 16787708 0x10028FC -braille_dots_1345678 16787709 0x10028FD -braille_dots_2345678 16787710 0x10028FE -braille_dots_12345678 16787711 0x10028FF +.CE +.CS SunFA_Grave 268828416 0x1005FF00 SunFA_Circum 268828417 0x1005FF01 SunFA_Tilde 268828418 0x1005FF02 SunFA_Acute 268828419 0x1005FF03 SunFA_Diaeresis 268828420 0x1005FF04 Index: doc/label.n ================================================================== --- doc/label.n +++ doc/label.n @@ -73,11 +73,11 @@ The \fBlabel\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for label widgets: .TP Index: doc/labelframe.n ================================================================== --- doc/labelframe.n +++ doc/labelframe.n @@ -93,11 +93,11 @@ The \fBlabelframe\fR command creates a new Tcl command whose name is the same as the path name of the labelframe's window. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIPathName\fR is the name of the command, which is the same as the labelframe widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for frame widgets: @@ -106,11 +106,11 @@ Returns the current value of the configuration option given by \fIoption\fR. \fIOption\fR may have any of the values accepted by the \fBlabelframe\fR command. .TP -\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR? +\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified with no \fIvalue\fR, then the command returns a list describing the Index: doc/listbox.n ================================================================== --- doc/listbox.n +++ doc/listbox.n @@ -134,11 +134,11 @@ The \fBlistbox\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for listbox widgets: .TP @@ -381,11 +381,12 @@ .TP \fIpathName \fBxview scroll \fInumber what\fR . This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. -\fINumber\fR must be an integer. +\fINumber\fR must be an integer or a float, but if it is a float then +it is converted to an integer, rounded away from 0. \fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left @@ -560,11 +561,11 @@ .IP [16] In \fBextended\fR mode, the Escape key cancels the most recent selection and restores all the elements in the selected range to their previous selection state. .IP [17] -Control-slash selects everything in the widget, except in +Control-/ selects everything in the widget, except in \fBsingle\fR and \fBbrowse\fR modes, in which case it selects the active element and deselects everything else. .IP [18] Control-backslash deselects everything in the widget, except in \fBbrowse\fR mode where it has no effect. Index: doc/loadTk.n ================================================================== --- doc/loadTk.n +++ doc/loadTk.n @@ -9,11 +9,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME safe::loadTk \- Load Tk into a safe interpreter. .SH SYNOPSIS -\fBsafe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? +\fBsafe::loadTk \fIchild\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? .BE .SH DESCRIPTION .PP Safe Tk is based on Safe Tcl, which provides a mechanism that allows restricted and mediated access to auto-loading and packages for safe @@ -41,17 +41,17 @@ .SH "SECURITY ISSUES" .PP Please read the \fBsafe\fR manual page for Tcl to learn about the basic security considerations for Safe Tcl. .PP -\fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the master +\fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the parent interpreter to the virtual access path of the safe interpreter so that auto-loading will work in the safe interpreter. .PP -Tk initialization is now safe with respect to not trusting the slave's state -for startup. \fBsafe::loadTk\fR registers the slave's name so when the Tk -initialization (\fBTk_SafeInit\fR) is called and in turn calls the master's +Tk initialization is now safe with respect to not trusting the child's state +for startup. \fBsafe::loadTk\fR registers the child's name so when the Tk +initialization (\fBTk_SafeInit\fR) is called and in turn calls the parent's \fBsafe::InitTk\fR it will return the desired \fBargv\fR equivalent (\fB\-use\fR \fIwindowId\fR, correct \fB\-display\fR, etc.) .PP When \fB\-use\fR is not used, the new toplevel created is specially decorated so the user is always aware that the user interface presented comes from a @@ -60,10 +60,10 @@ On X11, conflicting \fB\-use\fR and \fB\-display\fR are likely to generate a fatal X error. .SH "SEE ALSO" safe(n), interp(n), library(n), load(n), package(n), source(n), unknown(n) .SH KEYWORDS -alias, auto-loading, auto_mkindex, load, master interpreter, safe -interpreter, slave interpreter, source +alias, auto-loading, auto_mkindex, load, parent interpreter, safe +interpreter, child interpreter, source '\" Local Variables: '\" mode: nroff '\" End: Index: doc/menu.n ================================================================== --- doc/menu.n +++ doc/menu.n @@ -38,11 +38,11 @@ which specifies whether or not the menu should include a tear-off entry at the top. If so, it will exist as entry 0 of the menu and the other entries will number starting at 1. The default menu bindings arrange for the menu to be torn off when the tear-off entry is invoked. -This option is ignored under Aqua/Mac OS X, where menus cannot +This option is ignored under Aqua/MacOS, where menus cannot be torn off. .OP \-tearoffcommand tearOffCommand TearOffCommand If this option has a non-empty value, then it specifies a Tcl command to invoke whenever the menu is torn off. The actual command will consist of the value of this option, followed by a space, followed @@ -52,11 +52,11 @@ .QW "\fBa b\fR" and menu \fB.x.y\fR is torn off to create a new menu \fB.x.tearoff1\fR, then the command .QW "\fBa b .x.y .x.tearoff1\fR" will be invoked. -This option is ignored under Aqua/Mac OS X, where menus cannot +This option is ignored under Aqua/MacOS, where menus cannot be torn off. .OP \-title title Title The string will be used to title the window created when this menu is torn off. If the title is NULL, then the window will have the title of the menubutton or the text of the cascade item from which this menu @@ -301,11 +301,11 @@ The \fBmenu\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. .PP Many of the widget commands for a menu take as one argument an @@ -521,22 +521,22 @@ supported by all entry types. .TP \fB\-activebackground \fIvalue\fR . Specifies a background color to use for displaying this entry when it -is active. -If this option is specified as an empty string (the default), then the +is active. This option is ignored on Aqua/MacOS. +If it is specified as an empty string (the default), then the \fB\-activebackground\fR option for the overall menu is used. If the \fBtk_strictMotif\fR variable has been set to request strict Motif compliance, then this option is ignored and the \fB\-background\fR option is used in its place. This option is not available for separator or tear-off entries. .TP \fB\-activeforeground \fIvalue\fR . Specifies a foreground color to use for displaying this entry when it -is active. +is active. This option is ignored on Aqua/macOS. If this option is specified as an empty string (the default), then the \fB\-activeforeground\fR option for the overall menu is used. This option is not available for separator or tear-off entries. .TP \fB\-accelerator \fIvalue\fR @@ -550,11 +550,12 @@ .TP \fB\-background \fIvalue\fR . Specifies a background color to use for displaying this entry when it is in the normal state (neither active nor disabled). -If this option is specified as an empty string (the default), then the +This option is ignored on Aqua/macOS. +If it is specified as an empty string (the default), then the \fB\-background\fR option for the overall menu is used. This option is not available for separator or tear-off entries. .TP \fB\-bitmap \fIvalue\fR . @@ -571,11 +572,11 @@ \fB\-columnbreak \fIvalue\fR . When this option is zero, the entry appears below the previous entry. When this option is one, the entry appears at the top of a new column in the menu. -This option is ignored on Aqua/Mac OS X, where menus are always a single +This option is ignored on Aqua/macOS, where menus are always a single column. .TP \fB\-command \fIvalue\fR . Specifies a Tcl command to execute when the menu entry is invoked. @@ -601,11 +602,12 @@ .TP \fB\-foreground \fIvalue\fR . Specifies a foreground color to use for displaying this entry when it is in the normal state (neither active nor disabled). -If this option is specified as an empty string (the default), then the +This option is ignored on Aqua/macOS. +If it is specified as an empty string (the default), then the \fB\-foreground\fR option for the overall menu is used. This option is not available for separator or tear-off entries. .TP \fB\-hidemargin \fIvalue\fR . Index: doc/menubar.n ================================================================== --- doc/menubar.n +++ doc/menubar.n @@ -12,11 +12,11 @@ .SH NAME tk_menuBar, tk_bindForTraversal \- Obsolete support for menu bars .SH SYNOPSIS \fBtk_menuBar \fIframe \fR?\fImenu menu ...\fR? .sp -\fBtk_bindForTraversal \fIarg arg ... \fR +\fBtk_bindForTraversal \fIarg ... \fR .BE .SH DESCRIPTION .PP These procedures were used in Tk 3.6 and earlier releases to help manage pulldown menus and to implement keyboard traversal of menus. Index: doc/menubutton.n ================================================================== --- doc/menubutton.n +++ doc/menubutton.n @@ -115,11 +115,11 @@ The \fBmenubutton\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for menubutton widgets: .TP Index: doc/message.n ================================================================== --- doc/message.n +++ doc/message.n @@ -104,11 +104,11 @@ The \fBmessage\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for message widgets: .TP Index: doc/options.n ================================================================== --- doc/options.n +++ doc/options.n @@ -228,12 +228,11 @@ Specifies a help text string to display if no text is otherwise displayed, that is when the widget is empty. The placeholder text is displayed using the values of the \fB\-font\fR and \fB\-justify\fR options. .OP \-placeholderforeground placeholderForeground PlaceholderForeground Specifies the foreground color to use when the placeholder text is -displayed. If this option is the empty string, the default color gray70 -is used. +displayed. The default color is platform-specific. .OP \-relief relief Relief Specifies the 3-D effect desired for the widget. Acceptable values are \fBraised\fR, \fBsunken\fR, \fBflat\fR, \fBridge\fR, \fBsolid\fR, and \fBgroove\fR. The value Index: doc/pack.n ================================================================== --- doc/pack.n +++ doc/pack.n @@ -20,253 +20,257 @@ a geometry manager that arranges the children of a parent by packing them in order around the edges of the parent. The \fBpack\fR command can have any of several forms, depending on the \fIoption\fR argument: .TP -\fBpack \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR? +\fBpack \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR? If the first argument to \fBpack\fR is a window name (any value starting with .QW . ), then the command is processed in the same way as \fBpack configure\fR. .TP -\fBpack configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR? -The arguments consist of the names of one or more slave windows +\fBpack configure \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR? +The arguments consist of the names of one or more content windows followed by pairs of arguments that specify how -to manage the slaves. +to manage the content. See \fBTHE PACKER ALGORITHM\fR below for details on how the options are used by the packer. The following options are supported: .RS .TP \fB\-after \fIother\fR \fIOther\fR must the name of another window. -Use its master as the master for the slaves, and insert -the slaves just after \fIother\fR in the packing order. +Use its container as the container for the content, and insert +the content just after \fIother\fR in the packing order. .TP \fB\-anchor \fIanchor\fR \fIAnchor\fR must be a valid anchor position such as \fBn\fR -or \fBsw\fR; it specifies where to position each slave in its +or \fBsw\fR; it specifies where to position each content in its parcel. Defaults to \fBcenter\fR. .TP \fB\-before \fIother\fR \fIOther\fR must the name of another window. -Use its master as the master for the slaves, and insert -the slaves just before \fIother\fR in the packing order. +Use its container as the container for the content, and insert +the content just before \fIother\fR in the packing order. .TP \fB\-expand \fIboolean\fR -Specifies whether the slaves should be expanded to consume -extra space in their master. +Specifies whether the content should be expanded to consume +extra space in their container. \fIBoolean\fR may have any proper boolean value, such as \fB1\fR or \fBno\fR. Defaults to 0. .TP \fB\-fill \fIstyle\fR -If a slave's parcel is larger than its requested dimensions, this -option may be used to stretch the slave. +If a content's parcel is larger than its requested dimensions, this +option may be used to stretch the content. \fIStyle\fR must have one of the following values: .RS .TP \fBnone\fR -Give the slave its requested dimensions plus any internal padding +Give the content its requested dimensions plus any internal padding requested with \fB\-ipadx\fR or \fB\-ipady\fR. This is the default. .TP \fBx\fR -Stretch the slave horizontally to fill the entire width of its +Stretch the content horizontally to fill the entire width of its parcel (except leave external padding as specified by \fB\-padx\fR). .TP \fBy\fR -Stretch the slave vertically to fill the entire height of its +Stretch the content vertically to fill the entire height of its parcel (except leave external padding as specified by \fB\-pady\fR). .TP \fBboth\fR -Stretch the slave both horizontally and vertically. +Stretch the content both horizontally and vertically. .RE .TP -\fB\-in \fIother\fR -Insert the slave(s) at the end of the packing order for the master -window given by \fIother\fR. +\fB\-in \fIcontainer\fR +Insert the window at the end of the packing order for the container +window given by \fIcontainer\fR. .TP \fB\-ipadx \fIamount\fR \fIAmount\fR specifies how much horizontal internal padding to -leave on each side of the slave(s). +leave on each side of the content. \fIAmount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR. It defaults to 0. .TP \fB\-ipady \fIamount\fR \fIAmount\fR specifies how much vertical internal padding to -leave on each side of the slave(s). +leave on each side of the content. \fIAmount\fR defaults to 0. .TP \fB\-padx \fIamount\fR \fIAmount\fR specifies how much horizontal external padding to -leave on each side of the slave(s). \fIAmount\fR may be a list +leave on each side of the content. \fIAmount\fR may be a list of two values to specify padding for left and right separately. \fIAmount\fR defaults to 0. .TP \fB\-pady \fIamount\fR \fIAmount\fR specifies how much vertical external padding to -leave on each side of the slave(s). \fIAmount\fR may be a list +leave on each side of the content. \fIAmount\fR may be a list of two values to specify padding for top and bottom separately. \fIAmount\fR defaults to 0. .TP \fB\-side \fIside\fR -Specifies which side of the master the slave(s) will be packed against. +Specifies which side of the container the content will be packed against. Must be \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR. Defaults to \fBtop\fR. .LP If no \fB\-in\fR, \fB\-after\fR or \fB\-before\fR option is specified -then each of the slaves will be inserted at the end of the packing list +then each of the content will be inserted at the end of the packing list for its parent unless it is already managed by the packer (in which case it will be left where it is). -If one of these options is specified then all the slaves will be +If one of these options is specified then all the content will be inserted at the specified point. -If any of the slaves are already managed by the geometry manager +If any of the content are already managed by the geometry manager then any unspecified options for them retain their previous values rather than receiving default values. .RE .TP -\fBpack forget \fIslave \fR?\fIslave ...\fR? -Removes each of the \fIslave\fRs from the packing order for its -master and unmaps their windows. -The slaves will no longer be managed by the packer. +\fBpack forget \fIwindow \fR?\fIwindow ...\fR? +Removes each of the \fIwindow\fRs from the packing order for its +container and unmaps their windows. +The content will no longer be managed by the packer. .RS .PP -.VS TIP518 -If the last slave of the master becomes unmanaged, this will also send -the virtual event \fB<>\fR to the master; the master +.VS "TIP 518" +If the last content window of the container becomes unmanaged, this will also send +the virtual event \fB<>\fR to the container; the container may choose to resize itself (or otherwise respond) to such a change. -.VE TIP518 +.VE "TIP 518" .RE .TP -\fBpack info \fIslave\fR +\fBpack info \fIwindow\fR Returns a list whose elements are the current configuration state of -the slave given by \fIslave\fR in the same option-value form that +the window given by \fIwindow\fR in the same option-value form that might be specified to \fBpack configure\fR. The first two elements of the list are -.QW "\fB\-in \fImaster\fR" -where \fImaster\fR is the slave's master. +.QW "\fB\-in \fIcontainer\fR" +where \fIcontainer\fR is the window's container. .TP -\fBpack propagate \fImaster\fR ?\fIboolean\fR? +\fBpack propagate \fIcontainer\fR ?\fIboolean\fR? If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR -then propagation is enabled for \fImaster\fR, which must be a window +then propagation is enabled for \fIcontainer\fR, which must be a window name (see \fBGEOMETRY PROPAGATION\fR below). If \fIboolean\fR has a false boolean value then propagation is -disabled for \fImaster\fR. +disabled for \fIcontainer\fR. In either of these cases an empty string is returned. If \fIboolean\fR is omitted then the command returns \fB0\fR or \fB1\fR to indicate whether propagation is currently enabled -for \fImaster\fR. +for \fIcontainer\fR. Propagation is enabled by default. .TP -\fBpack slaves \fImaster\fR -Returns a list of all of the slaves in the packing order for \fImaster\fR. -The order of the slaves in the list is the same as their order in +\fBpack content \fIwindow\fR +Returns a list of all of the content windows in the packing order for \fIwindow\fR. +The order of the content windows in the list is the same as their order in the packing order. -If \fImaster\fR has no slaves then an empty string is returned. +If \fIwindow\fR has no content then an empty string is returned. +.TP +\fBpack slaves \fIwindow\fR +. +Synonym for . \fBpack content \fIwindow\fR .SH "THE PACKER ALGORITHM" .PP -For each master the packer maintains an ordered list of slaves -called the \fIpacking list\fR. +For each container the packer maintains an ordered list of content +windows called the \fIpacking list\fR. The \fB\-in\fR, \fB\-after\fR, and \fB\-before\fR configuration -options are used to specify the master for each slave and the slave's +options are used to specify the container for each content and the content's position in the packing list. -If none of these options is given for a slave then the slave +If none of these options is given for a content then the content is added to the end of the packing list for its parent. .PP -The packer arranges the slaves for a master by scanning the +The packer arranges the content windows for a container by scanning the packing list in order. -At the time it processes each slave, a rectangular area within -the master is still unallocated. -This area is called the \fIcavity\fR; for the first slave it -is the entire area of the master. +At the time it processes each content, a rectangular area within +the container is still unallocated. +This area is called the \fIcavity\fR; for the first content it +is the entire area of the container. .PP -For each slave the packer carries out the following steps: +For each content the packer carries out the following steps: .IP [1] -The packer allocates a rectangular \fIparcel\fR for the slave -along the side of the cavity given by the slave's \fB\-side\fR option. +The packer allocates a rectangular \fIparcel\fR for the content +along the side of the cavity given by the content's \fB\-side\fR option. If the side is top or bottom then the width of the parcel is the width of the cavity and its height is the requested height -of the slave plus the \fB\-ipady\fR and \fB\-pady\fR options. +of the content plus the \fB\-ipady\fR and \fB\-pady\fR options. For the left or right side the height of the parcel is the height of the cavity and the width is the requested width -of the slave plus the \fB\-ipadx\fR and \fB\-padx\fR options. +of the content plus the \fB\-ipadx\fR and \fB\-padx\fR options. The parcel may be enlarged further because of the \fB\-expand\fR option (see \fBEXPANSION\fR below) .IP [2] -The packer chooses the dimensions of the slave. -The width will normally be the slave's requested width plus +The packer chooses the dimensions of the content. +The width will normally be the content's requested width plus twice its \fB\-ipadx\fR option and the height will normally be -the slave's requested height plus twice its \fB\-ipady\fR +the content's requested height plus twice its \fB\-ipady\fR option. However, if the \fB\-fill\fR option is \fBx\fR or \fBboth\fR -then the width of the slave is expanded to fill the width of the parcel, +then the width of the content is expanded to fill the width of the parcel, minus twice the \fB\-padx\fR option. If the \fB\-fill\fR option is \fBy\fR or \fBboth\fR -then the height of the slave is expanded to fill the width of the parcel, +then the height of the content is expanded to fill the width of the parcel, minus twice the \fB\-pady\fR option. .IP [3] -The packer positions the slave over its parcel. -If the slave is smaller than the parcel then the \fB\-anchor\fR -option determines where in the parcel the slave will be placed. +The packer positions the content over its parcel. +If the content is smaller than the parcel then the \fB\-anchor\fR +option determines where in the parcel the content will be placed. If \fB\-padx\fR or \fB\-pady\fR is non-zero, then the given amount of external padding will always be left between the -slave and the edges of the parcel. +content and the edges of the parcel. .PP -Once a given slave has been packed, the area of its parcel +Once a given content has been packed, the area of its parcel is subtracted from the cavity, leaving a smaller rectangular -cavity for the next slave. -If a slave does not use all of its parcel, the unused space -in the parcel will not be used by subsequent slaves. +cavity for the next content. +If a content does not use all of its parcel, the unused space +in the parcel will not be used by subsequent content. If the cavity should become too small to meet the needs of -a slave then the slave will be given whatever space is +a content then the content will be given whatever space is left in the cavity. -If the cavity shrinks to zero size, then all remaining slaves +If the cavity shrinks to zero size, then all remaining content on the packing list will be unmapped from the screen until -the master window becomes large enough to hold them again. +the container window becomes large enough to hold them again. .SS "EXPANSION" .PP -If a master window is so large that there will be extra space -left over after all of its slaves have been packed, then the -extra space is distributed uniformly among all of the slaves +If a container window is so large that there will be extra space +left over after all of its content have been packed, then the +extra space is distributed uniformly among all of the content for which the \fB\-expand\fR option is set. Extra horizontal space is distributed among the expandable -slaves whose \fB\-side\fR is \fBleft\fR or \fBright\fR, +content whose \fB\-side\fR is \fBleft\fR or \fBright\fR, and extra vertical space is distributed among the expandable -slaves whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR. +content whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR. .SS "GEOMETRY PROPAGATION" .PP -The packer normally computes how large a master must be to -just exactly meet the needs of its slaves, and it sets the -requested width and height of the master to these dimensions. +The packer normally computes how large a container must be to +just exactly meet the needs of its content, and it sets the +requested width and height of the container to these dimensions. This causes geometry information to propagate up through a window hierarchy to a top-level window so that the entire sub-tree sizes itself to fit the needs of the leaf windows. However, the \fBpack propagate\fR command may be used to -turn off propagation for one or more masters. +turn off propagation for one or more containers. If propagation is disabled then the packer will not set the requested width and height of the packer. -This may be useful if, for example, you wish for a master +This may be useful if, for example, you wish for a container window to have a fixed size that you specify. -.SH "RESTRICTIONS ON MASTER WINDOWS" +.SH "RESTRICTIONS ON CONTAINER WINDOWS" .PP -The master for each slave must either be the slave's parent -(the default) or a descendant of the slave's parent. +The container for each content must either be the content's parent +(the default) or a descendant of the content's parent. This restriction is necessary to guarantee that the -slave can be placed over any part of its master that is -visible without danger of the slave being clipped by its parent. +content can be placed over any part of its container that is +visible without danger of the content being clipped by its parent. .SH "PACKING ORDER" .PP -If the master for a slave is not its parent then you must make sure -that the slave is higher in the stacking order than the master. -Otherwise the master will obscure the slave and it will appear as -if the slave has not been packed correctly. -The easiest way to make sure the slave is higher than the master is -to create the master window first: the most recently created window +If the container for a content is not its parent then you must make sure +that the content is higher in the stacking order than the container. +Otherwise the container will obscure the content and it will appear as +if the content has not been packed correctly. +The easiest way to make sure the content is higher than the container is +to create the container window first: the most recently created window will be highest in the stacking order. Or, you can use the \fBraise\fR and \fBlower\fR commands to change -the stacking order of either the master or the slave. +the stacking order of either the container or the content. .SH EXAMPLE .PP .CS # Make the widgets label .t \-text "This widget is at the top" \-bg red Index: doc/panedwindow.n ================================================================== --- doc/panedwindow.n +++ doc/panedwindow.n @@ -90,11 +90,11 @@ The \fBpanedwindow\fR command creates a new Tcl command whose name is the same as the path name of the panedwindow's window. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIPathName\fR is the name of the command, which is the same as the panedwindow widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for panedwindow widgets: @@ -328,11 +328,11 @@ .PP When a pane is resized from outside (e.g. it is packed to expand and fill, and the containing toplevel is resized), space is added to the final (rightmost or bottommost) pane in the window. .PP -Unlike slave windows managed by e.g. pack or grid, the panes managed by a +Unlike child windows managed by e.g. pack or grid, the panes managed by a panedwindow do not change width or height to accommodate changes in the requested widths or heights of the panes, once these have become mapped. Therefore it may be advisable, particularly when creating layouts interactively, to not add a pane to the panedwindow widget until after the geometry requests of that pane has been finalized (i.e., all components of Index: doc/photo.n ================================================================== --- doc/photo.n +++ doc/photo.n @@ -26,11 +26,11 @@ \fIimageName \fBdata\fR ?\fIoption value(s) ...\fR? \fIimageName \fBget \fIx y\fR ?\fIoption\fR? \fIimageName \fBput \fIdata\fR ?\fIoption value(s) ...\fR? \fIimageName \fBread \fIfilename\fR ?\fIoption value(s) ...\fR? \fIimageName \fBredither\fR -\fIimageName \fBtransparency \fIsubcommand \fR?\fIarg arg ...\fR? +\fIimageName \fBtransparency \fIsubcommand \fR?\fIarg ...\fR? \fIimageName \fBwrite \fIfilename\fR ?\fIoption value(s) ...\fR? .fi .BE .SH DESCRIPTION .PP @@ -99,10 +99,20 @@ . Specifies the height of the image, in pixels. This option is useful primarily in situations where the user wishes to build up the contents of the image piece by piece. A value of zero (the default) allows the image to expand or shrink vertically to fit the data stored in it. +.VS 8.7 +.TP +\fB\-metadata \fImetadata\fR +. +Set the metadata dictionary of the image. +Additional keys may be set within the metadata dictionary of the image, +if image data is processed due to a \fB\-file\fR or \fB\-data\fR options +and the driver outputs any metadata keys. +See section \fBMETADATA DICTIONARY\fR below. +.VE 8.7 .TP \fB\-palette \fIpalette-spec\fR . Specifies the resolution of the color cube to be allocated for displaying this image, and thus the number of colors used from the @@ -126,11 +136,11 @@ whose name is the same as the image. This command may be used to invoke various operations on the image. It has the following general form: .CS -\fIimageName option \fR?\fIarg arg ...\fR? +\fIimageName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. .PP Those options that write data to the image generally expand the size @@ -144,11 +154,11 @@ .TP \fIimageName \fBblank\fR . Blank the image; that is, set the entire image to have no data, so it will be displayed as transparent, and the background of whatever -window it is displayed in will show through. +window it is displayed in will show through. The metadata dict of the image is not changed. .TP \fIimageName \fBcget\fR \fIoption\fR . Returns the current value of the configuration option given by \fIoption\fR. @@ -167,10 +177,14 @@ one or more \fIoption\-value\fR pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. \fIOption\fR may have any of the values accepted by the \fBimage create\fR \fBphoto\fR command. +.VS 8.7 +Note: setting the \fB\-metadata\fR option without any other option +will not invoke the image format driver to recreate the bitmap. +.VE 8.7 .TP \fIimageName \fBcopy\fR \fIsourceImage\fR ?\fIoption value(s) ...\fR? . Copies a region from the image called \fIsourceImage\fR (which must be a photo image) to the image called \fIimageName\fR, possibly with @@ -285,13 +299,22 @@ .TP \fB\-grayscale\fR . If this options is specified, the data will not contain color information. All pixel data will be transformed into grayscale. -.RE .VS 8.7 .TP +\fB\-metadata\fR \fImetadata\fR +. +Image format handler may use metadata to be included in the returned +data string. +The specified \fImetadata\fR is passed to the driver for inclusion in the +data. +If no \fB\-metadata\fR option is given, the current metadata of the +image is used. +.VE 8.7 +.RE \fIimageName \fBget\fR \fIx y\fR ?\fB-withalpha\fR? . Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the image as a list of three integers between 0 and 255, representing the red, green and blue components respectively. If the \fB-withalpha\fR @@ -320,10 +343,19 @@ \fIformat-name\fR will be used while searching for an image data format handler to read the data. Note: the value of this option must be a Tcl list. This means that the braces may be omitted if the argument has only one word. Also, instead of braces, double quotes may be used for quoting. +.VS 8.7 +.TP +\fB\-metadata\fR \fImetadata\fR +. +A specified \fImetadata\fR is passed to the image format driver when interpreting +the data. +Note: The current metadata of the image is not passed to the format driver +and is not changed by the command. +.VE 8.7 .TP \fB\-to \fIx1 y1\fR ?\fIx2 y2\fR? . Specifies the coordinates of the top-left corner (\fIx1\fR,\fIy1\fR) of the region of \fIimageName\fR into which the image data will be @@ -365,10 +397,19 @@ specified, the region extends from (\fIx1,y1\fR) to the bottom-right corner of the image in the image file. If all four coordinates are specified, they specify diagonally opposite corners or the region. The default, if this option is not specified, is the whole of the image in the image file. +.VS 8.7 +.TP +\fB\-metadata\fR \fImetadata\fR +. +A specified \fImetadata\fR is passed to the image format driver when interpreting +the data. +Note: The current metadata of the image is not passed to the format driver +and is not changed by the command. +.VE 8.7 .TP \fB\-shrink\fR . If this option, the size of \fIimageName\fR will be reduced, if necessary, so that the region into which the image file data are read @@ -392,11 +433,11 @@ dithered image may not be exactly correct. Normally the difference is not noticeable, but if it is a problem, this command can be used to recalculate the dithered image in each window where the image is displayed. .TP -\fIimageName \fBtransparency \fIsubcommand \fR?\fIarg arg ...\fR? +\fIimageName \fBtransparency \fIsubcommand \fR?\fIarg ...\fR? . Allows examination and manipulation of the transparency information in the photo image. Several subcommands are available: .RS .VS 8.7 @@ -458,10 +499,20 @@ .TP \fB\-grayscale\fR . If this options is specified, the data will not contain color information. All pixel data will be transformed into grayscale. +.VS 8.7 +.TP +\fB\-metadata\fR \fBmetadata\fR +. +Image format handler may use metadata to be included in the written file. +The specified \fImetadata\fR is passed to the driver for inclusion in the +file. +If no \fB\-metadata\fR option is given, the current metadata of the +image is used. +.VE 8.7 .RE .SH "IMAGE FORMATS" .PP The photo image code is structured to allow handlers for additional image file formats to be added easily. The photo image code maintains @@ -680,10 +731,43 @@ this option is used, it specifies the maximum number of shades of each primary color to try to allocate. It can also be used to force the image to be displayed in shades of gray, even on a color display, by giving a single number rather than three numbers separated by slashes. +.VS 8.7 +.SH "METADATA DICTIONARY" +.PP +Each image has a metadata dictionary property. +This dictionary is not relevant to the bitmap representation of the +image, but may contain additional information like resolution or +comments. +Image format drivers may output metadata when image data is +parsed, or may use metadata to be included in image files or formats. +.SS "METADATA KEYS" +.PP +Each image format driver supports an individual set of metadata dictionary +keys. Predefined keys are: +.TP +DPI +. +Horizontal image resolution in DPI as a double value. +Supported by format \fBpng\fR. +.TP +aspect +. +Aspect ratio horizontal divided by vertical as double value. +Supported by formats \fBgif\fR and \fBpng\fR. +.TP +comment +. +Image text comment. +Supported by formats \fBgif\fR and \fBpng\fR. +.PP +It is valid to set any key in the metadata dict. +A format driver will ignore keys it does not handle. +.PP +.VE 8.7 .SH CREDITS .PP The photo image type was designed and implemented by Paul Mackerras, based on his earlier photo widget and some suggestions from John Ousterhout. Index: doc/place.n ================================================================== --- doc/place.n +++ doc/place.n @@ -16,30 +16,30 @@ .BE .SH DESCRIPTION .PP The placer is a geometry manager for Tk. It provides simple fixed placement of windows, where you specify -the exact size and location of one window, called the \fIslave\fR, -within another window, called the \fImaster\fR. +the exact size and location of one window, called the \fIcontent\fR, +within another window, called the \fIcontainer\fR. The placer also provides rubber-sheet placement, where you specify the -size and location of the slave in terms of the dimensions of -the master, so that the slave changes size and location -in response to changes in the size of the master. +size and location of the content in terms of the dimensions of +the container, so that the content changes size and location +in response to changes in the size of the container. Lastly, the placer allows you to mix these styles of placement so -that, for example, the slave has a fixed width and height but is -centered inside the master. +that, for example, the content has a fixed width and height but is +centered inside the container. .PP .TP \fBplace \fIwindow option value \fR?\fIoption value ...\fR? -Arrange for the placer to manage the geometry of a slave whose +Arrange for the placer to manage the geometry of a content whose pathName is \fIwindow\fR. The remaining arguments consist of one or more \fIoption\-value\fR pairs that specify the way in which \fIwindow\fR's geometry is managed. \fIOption\fR may have any of the values accepted by the \fBplace configure\fR command. .TP \fBplace configure \fIwindow \fR?\fIoption\fR? ?\fIvalue option value ...\fR? -Query or modify the geometry options of the slave given by +Query or modify the geometry options of the content given by \fIwindow\fR. If no \fIoption\fR is specified, this command returns a list describing the available options (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified with no \fIvalue\fR, then the command returns a list describing the one named option (this list will be identical to the corresponding @@ -57,31 +57,31 @@ \fB\-relx\fR, and \fB\-rely\fR options. The anchor point is in terms of the outer area of \fIwindow\fR including its border, if any. Thus if \fIwhere\fR is \fBse\fR then the lower-right corner of \fIwindow\fR's border will appear at the given (x,y) location -in the master. +in the container. The anchor position defaults to \fBnw\fR. .TP \fB\-bordermode \fImode\fR \fIMode\fR determines the degree to which borders within the -master are used in determining the placement of the slave. +container are used in determining the placement of the content. The default and most common value is \fBinside\fR. -In this case the placer considers the area of the master to -be the innermost area of the master, inside any border: +In this case the placer considers the area of the container to +be the innermost area of the container, inside any border: an option of \fB\-x 0\fR corresponds to an x-coordinate just inside the border and an option of \fB\-relwidth 1.0\fR -means \fIwindow\fR will fill the area inside the master's +means \fIwindow\fR will fill the area inside the container's border. .RS .PP If \fImode\fR is \fBoutside\fR then the placer considers -the area of the master to include its border; +the area of the container to include its border; this mode is typically used when placing \fIwindow\fR -outside its master, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR. +outside its container, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR. Lastly, \fImode\fR may be specified as \fBignore\fR, in which -case borders are ignored: the area of the master is considered +case borders are ignored: the area of the container is considered to be its official X area, which includes any internal border but no external border. A bordermode of \fBignore\fR is probably not very useful. .RE .TP @@ -92,65 +92,65 @@ border, if any. If \fIsize\fR is an empty string, or if no \fB\-height\fR or \fB\-relheight\fR option is specified, then the height requested internally by the window will be used. .TP -\fB\-in \fImaster\fR -\fIMaster\fR specifies the path name of the window relative +\fB\-in \fIcontainer\fR +\fIContainer\fR specifies the path name of the window relative to which \fIwindow\fR is to be placed. -\fIMaster\fR must either be \fIwindow\fR's parent or a descendant +\fIContainer\fR must either be \fIwindow\fR's parent or a descendant of \fIwindow\fR's parent. -In addition, \fImaster\fR and \fIwindow\fR must both be descendants +In addition, \fIcontainer\fR and \fIwindow\fR must both be descendants of the same top-level window. These restrictions are necessary to guarantee -that \fIwindow\fR is visible whenever \fImaster\fR is visible. -If this option is not specified then the master defaults to +that \fIwindow\fR is visible whenever \fIcontainer\fR is visible. +If this option is not specified then the other window defaults to \fIwindow\fR's parent. .TP \fB\-relheight \fIsize\fR \fISize\fR specifies the height for \fIwindow\fR. In this case the height is specified as a floating-point number -relative to the height of the master: 0.5 means \fIwindow\fR will -be half as high as the master, 1.0 means \fIwindow\fR will have -the same height as the master, and so on. -If both \fB\-height\fR and \fB\-relheight\fR are specified for a slave, +relative to the height of the container: 0.5 means \fIwindow\fR will +be half as high as the container, 1.0 means \fIwindow\fR will have +the same height as the container, and so on. +If both \fB\-height\fR and \fB\-relheight\fR are specified for a content, their values are summed. For example, \fB\-relheight 1.0 \-height \-2\fR -makes the slave 2 pixels shorter than the master. +makes the content 2 pixels shorter than the container. .TP \fB\-relwidth \fIsize\fR \fISize\fR specifies the width for \fIwindow\fR. In this case the width is specified as a floating-point number -relative to the width of the master: 0.5 means \fIwindow\fR will -be half as wide as the master, 1.0 means \fIwindow\fR will have -the same width as the master, and so on. -If both \fB\-width\fR and \fB\-relwidth\fR are specified for a slave, +relative to the width of the container: 0.5 means \fIwindow\fR will +be half as wide as the container, 1.0 means \fIwindow\fR will have +the same width as the container, and so on. +If both \fB\-width\fR and \fB\-relwidth\fR are specified for a content, their values are summed. For example, \fB\-relwidth 1.0 \-width 5\fR -makes the slave 5 pixels wider than the master. +makes the content 5 pixels wider than the container. .TP \fB\-relx \fIlocation\fR -\fILocation\fR specifies the x-coordinate within the master window +\fILocation\fR specifies the x-coordinate within the container window of the anchor point for \fIwindow\fR. In this case the location is specified in a relative fashion as a floating-point number: 0.0 corresponds to the left edge -of the master and 1.0 corresponds to the right edge of the master. +of the container and 1.0 corresponds to the right edge of the container. \fILocation\fR need not be in the range 0.0\-1.0. -If both \fB\-x\fR and \fB\-relx\fR are specified for a slave +If both \fB\-x\fR and \fB\-relx\fR are specified for a content then their values are summed. For example, \fB\-relx 0.5 \-x \-2\fR -positions the left edge of the slave 2 pixels to the left of the -center of its master. +positions the left edge of the content 2 pixels to the left of the +center of its container. .TP \fB\-rely \fIlocation\fR -\fILocation\fR specifies the y-coordinate within the master window +\fILocation\fR specifies the y-coordinate within the container window of the anchor point for \fIwindow\fR. In this case the value is specified in a relative fashion as a floating-point number: 0.0 corresponds to the top edge -of the master and 1.0 corresponds to the bottom edge of the master. +of the container and 1.0 corresponds to the bottom edge of the container. \fILocation\fR need not be in the range 0.0\-1.0. -If both \fB\-y\fR and \fB\-rely\fR are specified for a slave +If both \fB\-y\fR and \fB\-rely\fR are specified for a content then their values are summed. For example, \fB\-rely 0.5 \-x 3\fR -positions the top edge of the slave 3 pixels below the -center of its master. +positions the top edge of the content 3 pixels below the +center of its container. .TP \fB\-width \fIsize\fR \fISize\fR specifies the width for \fIwindow\fR in screen units (i.e. any of the forms accepted by \fBTk_GetPixels\fR). The width will be the outer width of \fIwindow\fR including its @@ -158,22 +158,22 @@ If \fIsize\fR is an empty string, or if no \fB\-width\fR or \fB\-relwidth\fR option is specified, then the width requested internally by the window will be used. .TP \fB\-x \fIlocation\fR -\fILocation\fR specifies the x-coordinate within the master window +\fILocation\fR specifies the x-coordinate within the container window of the anchor point for \fIwindow\fR. The location is specified in screen units (i.e. any of the forms accepted by \fBTk_GetPixels\fR) and need not lie within the bounds -of the master window. +of the container window. .TP \fB\-y \fIlocation\fR -\fILocation\fR specifies the y-coordinate within the master window +\fILocation\fR specifies the y-coordinate within the container window of the anchor point for \fIwindow\fR. The location is specified in screen units (i.e. any of the forms accepted by \fBTk_GetPixels\fR) and need not lie within the bounds -of the master window. +of the container window. .PP If the same value is specified separately with two different options, such as \fB\-x\fR and \fB\-relx\fR, then the most recent option is used and the older one is ignored. .RE @@ -189,23 +189,27 @@ Returns a list giving the current configuration of \fIwindow\fR. The list consists of \fIoption\-value\fR pairs in exactly the same form as might be specified to the \fBplace configure\fR command. .TP +\fBplace content \fIwindow\fR +Returns a list of all the content windows for which \fIwindow\fR is the container. +If there is no content for \fIwindow\fR then an empty string is returned. +.TP \fBplace slaves \fIwindow\fR -Returns a list of all the slave windows for which \fIwindow\fR is the master. -If there are no slaves for \fIwindow\fR then an empty string is returned. +. +Synonym for . \fBplace content \fIwindow\fR .PP If the configuration of a window has been retrieved with \fBplace info\fR, that configuration can be restored later by first using \fBplace forget\fR to erase any existing information for the window and then invoking \fBplace configure\fR with the saved information. .SH "FINE POINTS" .PP -It is not necessary for the master window to be the parent -of the slave window. +It is not necessary for the container window to be the parent +of the content window. This feature is useful in at least two situations. First, for complex window layouts it means you can create a hierarchy of subwindows whose only purpose is to assist in the layout of the parent. The @@ -219,24 +223,24 @@ do not reflect the geometry-management hierarchy and users can specify options for the real children without being aware of the structure of the geometry-management hierarchy. .PP -A second reason for having a master different than the slave's +A second reason for having a container different than the content's parent is to tie two siblings together. For example, the placer can be used to force a window always to be positioned centered just below one of its siblings by specifying the configuration .CS \fB\-in \fIsibling\fB \-relx 0.5 \-rely 1.0 \-anchor n \-bordermode outside\fR .CE -Whenever the sibling is repositioned in the future, the slave +Whenever the sibling is repositioned in the future, the content will be repositioned as well. .PP Unlike many other geometry managers (such as the packer) the placer does not make any attempt to manipulate the geometry of -the master windows or the parents of slave windows (i.e. it does not +the container windows or the parents of content windows (i.e. it does not set their requested sizes). To control the sizes of these windows, make them windows like frames and canvases that provide configuration options for this purpose. .SH EXAMPLE .PP @@ -247,9 +251,9 @@ \fBplace\fR .l \-relwidth .3 \-relx .35 \-relheight .3 \-rely .35 .CE .SH "SEE ALSO" grid(n), pack(n) .SH KEYWORDS -geometry manager, height, location, master, place, rubber sheet, slave, width +geometry manager, height, location, container, place, rubber sheet, content, width '\" Local Variables: '\" mode: nroff '\" End: Index: doc/radiobutton.n ================================================================== --- doc/radiobutton.n +++ doc/radiobutton.n @@ -174,11 +174,11 @@ The \fBradiobutton\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for radiobutton widgets: .TP Index: doc/scale.n ================================================================== --- doc/scale.n +++ doc/scale.n @@ -136,11 +136,11 @@ The \fBscale\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for scale widgets: .TP Index: doc/scrollbar.n ================================================================== --- doc/scrollbar.n +++ doc/scrollbar.n @@ -101,11 +101,11 @@ The \fBscrollbar\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for scrollbar widgets: .TP @@ -221,20 +221,23 @@ It is up to the widget to define the meaning of a page; typically it is slightly less than what fits in the window, so that there is a slight overlap between the old and new views. \fINumber\fR is either 1, which means the next page should become visible, or \-1, which means that the previous page should -become visible. +become visible. Fractional number are rounded away from 0, so +scrolling 0.001 pages has the same effect as scrolling 1 page. .TP \fIprefix \fBscroll \fInumber \fBunits\fR . The widget should adjust its view by \fInumber\fR units. The units are defined in whatever way makes sense for the widget, such as characters or lines in a text widget. \fINumber\fR is either 1, which means one unit should scroll off the top or left of the window, or \-1, which means that one unit -should scroll off the bottom or right of the window. +should scroll off the bottom or right of the window. Fractional +numbers are rounded away from 0, so scrolling 0.001 units has +the same effect as scrolling 1 unit. .SH "OLD COMMAND SYNTAX" .PP In versions of Tk before 4.0, the \fBset\fR and \fBget\fR widget commands used a different form. This form is still supported for backward compatibility, but it Index: doc/selection.n ================================================================== --- doc/selection.n +++ doc/selection.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME selection \- Manipulate the X selection .SH SYNOPSIS -\fBselection \fIoption\fR ?\fIarg arg ...\fR? +\fBselection \fIoption\fR ?\fIarg ...\fR? .BE .SH DESCRIPTION .PP This command provides a Tcl interface to the X selection mechanism and implements the full selection functionality described in the @@ -148,11 +148,11 @@ .PP .SH PORTABILITY ISSUES .PP On X11, the \fBPRIMARY\fR selection is a system-wide feature of the X server, allowing communication between different processes that are X11 clients. .PP -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. +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. .PP .SH SECURITY .PP A safe interpreter cannot read from the \fBPRIMARY\fR selection because its \fBselection\fR command is hidden. For this reason the \fBPRIMARY\fR selection cannot be written to the Tk widgets of a safe interpreter. .PP Index: doc/send.n ================================================================== --- doc/send.n +++ doc/send.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME send \- Execute a command in a different application .SH SYNOPSIS -\fBsend ?\fIoptions\fR? \fIapp cmd \fR?\fIarg arg ...\fR? +\fBsend ?\fIoptions\fR? \fIapp cmd \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP This command arranges for \fIcmd\fR (and \fIarg\fRs) to be executed in the application named by \fIapp\fR. It returns the result or Index: doc/spinbox.n ================================================================== --- doc/spinbox.n +++ doc/spinbox.n @@ -222,11 +222,11 @@ .PP Also, the \fB-validate\fR option will set itself to \fBnone\fR when the spinbox value gets changed because of adjustment of \fB-from\fR or \fB-to\fR and the \fB-validatecommand\fR returns false. For instance .CS - \fIspinbox pathName \-from 1 \-to 10 \-validate all \-vcmd {return 0}\fR + \fIspinbox pathName \-from 1 \-to 10 \-validate all \-validatecommand {return 0}\fR .CE will in fact set the \fB-validate\fR option to \fBnone\fR because the default value for the spinbox gets changed (due to the \fB-from\fR and \fB-to\fR options) to a value not accepted by the validation script. .PP @@ -237,11 +237,11 @@ .PP The \fBspinbox\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. .SS INDICES .PP @@ -468,11 +468,12 @@ \fIFraction\fR must be a fraction between 0 and 1. .TP \fIpathName \fBxview scroll \fInumber what\fR This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. -\fINumber\fR must be an integer. +\fINumber\fR must be an integer or a float, but if it is a float then +it is converted to an integer, rounded away from 0. \fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right ADDED doc/sysnotify.n Index: doc/sysnotify.n ================================================================== --- /dev/null +++ doc/sysnotify.n @@ -0,0 +1,61 @@ +.\" Text automatically generated by txt2man +'\" +'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +.TH tk sysnotify n "" Tk "Tk Built-In Commands" +.so man.macros +.SH NAME +sysnotify \- Creates a notification window with a title and message. +.SH SYNOPSIS +\fBtk sysnotify\fR \fItitle\fR \fImessage\fR +.BE +.SH DESCRIPTION +.PP +The \fBtk sysnotify\fR command creates a platform-specific system notification alert. Its intent is to provide a brief, unobtrusive notification to the user by popping up a window that briefly appears in a corner of the screen. +.SH EXAMPLE +.PP +Here is an example of the \fBtk sysnotify\fR code: +.CS + tk sysnotify "Alert" "This is just a test of the Tk System Notification Code." +.CE +.SH PLATFORM NOTES +.PP +The macOS and Windows versions are native implementations using system +API's. The X11 version has a conditional dependency on libnotify, and +falls back to a Tcl-only implementation if libnotify is not installed. On +each platform the notification includes a platform-specific default image to +accompany the text. +. +.TP +\fBmacOS\fR +. +The macOS version embeds two separate under-the-hood implementations +using different notification APIs. The choice of which one to use +depends on which version of the OS is being run and the state of the +Tk application code. The newer API, introduced in macOS 10.14, +requires that the application accessing the API be code-signed, or the +notification will not display. (A self-signed certificate seems to be +sufficient.) The older API was deprecated but not removed in macOS +11.0. Tk uses the newer API only for signed applications running on +macOS 10.14 or newer. Otherwise it falls back to the older API. A +quirk which developers should be aware of is that if an unsigned +version of Wish (or an application derived from it) is installed on +top of a signed version after the signed version has been registered +with System Preferences then neither API will be allowed to show +notifications, making Tk's automatic fallback to the older API +ineffective. To re-enable notifications the application must be +deleted from Apple's System Preferences Notifications section. (There +is no removal button, so this is done by selecting the application and +pressing the Delete key.) +. +.TP +\fBWindows\fR +. +The image is taken from the systray i.e. a sysnotify can only be +called when a systray was installed. +. +.SH KEYWORDS +notify, alert ADDED doc/systray.n Index: doc/systray.n ================================================================== --- /dev/null +++ doc/systray.n @@ -0,0 +1,65 @@ +.\" Text automatically generated by txt2man +'\" +'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +.TH tk systray n "" Tk "Tk Built-In Commands" +.so man.macros +.SH NAME +systray \- Creates an icon display in the platform-specific system tray. +.SH SYNOPSIS +\fBtk systray create \fI-image image\fR \fI?-text text\fR? \fI?-button1 callback?\fR \fI?-button3 callback?\fR +.sp +\fBtk systray configure \fI?option? ?value option value ...?\fR +.sp +\fBtk systray destroy\fR +.BE +.BE +.SH DESCRIPTION +.PP +The \fBtk systray create\fR command creates an icon in the platform-specific +tray. The widget is configured with a Tk image for the icon display, an +optional string for display in a tooltip, and optional callbacks that are +bound to and . +.PP +The \fBtk systray configure\fR command sets one or more options of the systray +icon. Configurable options are the same as for the \fBcreate\fR subcommand. When +a single option name is given, the command returns the current valus of this +option. When no option is given this command returns the list of all options and +their current value. +.PP + The \fBtk systray destroy\fR command removes the icon from display and +deallocates it. +.PP +From a user-interface standpoint, only one icon per interpreter is +supported; attempts to create additional icons will return an error. The +existing tray icon can be modified with different images and +strings to indicate app state. Loading additional interpreters into a +running instance of Wish will allow additional icons to be displayed. +.SH EXAMPLE +.PP +Here is an example of the \fBtk systray\fR code: +.CS + image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw== + tk systray create -image book -text "tk systray sample" -button1 {puts "Here is the tk systray output"} -button3 {puts "here is alternate output"} +.CE +.PP +Here is an example of modifying the \fBtk systray\fR icon: +.CS + image create photo book_page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7 + tk systray configure -image book_page -text "Updated sample" -button1 {puts "Different output from the tk systray"} -button3 {puts "and more different output from the tk systray"} +.CE +.SH PLATFORM NOTES +.PP +The X11 implementation is supported on a "best efforts" basis because it is +dependent on the window manager. The "text" flag, which is implemented as +a tooltip, does not always display if the WM does not support such features; +the systray icon itself may not even display with some window managers. +.PP +On Windows, the Tk image provided in the \fI-image\fR option must be a +photo image. On other platforms either a bitmap image or a photo image +may be provided. +.SH KEYWORDS +image, callback Index: doc/text.n ================================================================== --- doc/text.n +++ doc/text.n @@ -1050,11 +1050,11 @@ .PP The \fBtext\fR command creates a new Tcl command whose name is the same as the path name of the text's window. This command may be used to invoke various operations on the widget. It has the following general form: .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE \fIPathName\fR is the name of the command, which is the same as the text widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following commands are possible for text widgets: .TP @@ -1080,11 +1080,11 @@ satisfied and 0 if it is not. \fIOp\fR must be one of the operators <, <=, ==, >=, >, or !=. If \fIop\fR is == then 1 is returned if the two indices refer to the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR refers to an earlier character in the text than \fIindex2\fR, and so on. .TP -\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR? +\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? . Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified with no \fIvalue\fR, then the command @@ -1093,11 +1093,11 @@ specified). If one or more \fIoption\-value\fR pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. \fIOption\fR may have any of the values accepted by the \fBtext\fR command. .TP -\fIpathName \fBcount\fR \fI?options\fR? \fIindex1 index2\fR +\fIpathName \fBcount\fR ?\fIoptions\fR? \fIindex1 index2\fR . Counts the number of relevant things between the two indices. If \fIindex1\fR is after \fIindex2\fR, the result will be a negative number (and this holds for each of the possible options). The actual items which are counted depend on the options given. The result is a list of integers, one for the result of @@ -1279,11 +1279,11 @@ window is its Tk pathname, unless the window has not been created yet. (It must have a create script.) In this case an empty string is returned, and you must query the window by its index position to get more information. .RE .TP -\fIpathName \fBedit \fIoption \fR?\fIarg arg ...\fR? +\fIpathName \fBedit \fIoption \fR?\fIarg ...\fR? . This command controls the undo mechanism and the modified flag. The exact behavior of the command depends on the \fIoption\fR argument that follows the \fBedit\fR argument. The following forms of the command are currently supported: @@ -1347,14 +1347,14 @@ order passed to \fIpathName \fBget\fR. If the \fB\-displaychars\fR option is given, then, within each range, only those characters which are not elided will be returned. This may have the effect that some of the returned ranges are empty strings. .TP -\fIpathName \fBimage \fIoption \fR?\fIarg arg ...\fR? +\fIpathName \fBimage \fIoption \fR?\fIarg ...\fR? . This command is used to manipulate embedded images. The behavior of the -command depends on the \fIoption\fR argument that follows the \fBtag\fR +command depends on the \fIoption\fR argument that follows the \fBimage\fR argument. The following forms of the command are currently supported: .RS .TP \fIpathName \fBimage cget \fIindex option\fR . @@ -1412,11 +1412,11 @@ \fIchars\fR\-\fItagList\fR argument pairs are present, they produce the same effect as if a separate \fIpathName \fBinsert\fR widget command had been issued for each pair, in order. The last \fItagList\fR argument may be omitted. .TP -\fIpathName \fBmark \fIoption \fR?\fIarg arg ...\fR? +\fIpathName \fBmark \fIoption \fR?\fIarg ...\fR? . This command is used to manipulate marks. The exact behavior of the command depends on the \fIoption\fR argument that follows the \fBmark\fR argument. The following forms of the command are currently supported: .RS @@ -1692,11 +1692,11 @@ as all line heights are up-to-date. If there are no pending line metrics calculations, the scheduling is immediate. The command returns the empty string. \fBbgerror\fR is called on \fIcommand\fR failure. .RE .TP -\fIpathName \fBtag \fIoption \fR?\fIarg arg ...\fR? +\fIpathName \fBtag \fIoption \fR?\fIarg ...\fR? . This command is used to manipulate tags. The exact behavior of the command depends on the \fIoption\fR argument that follows the \fBtag\fR argument. The following forms of the command are currently supported: .RS @@ -1859,11 +1859,11 @@ characters in the specified range (e.g. \fIindex1\fR is past the end of the file or \fIindex2\fR is less than or equal to \fIindex1\fR) then the command has no effect. This command returns an empty string. .RE .TP -\fIpathName \fBwindow \fIoption \fR?\fIarg arg ...\fR? +\fIpathName \fBwindow \fIoption \fR?\fIarg ...\fR? . This command is used to manipulate embedded windows. The behavior of the command depends on the \fIoption\fR argument that follows the \fBwindow\fR argument. The following forms of the command are currently supported: .RS Index: doc/tk.n ================================================================== --- doc/tk.n +++ doc/tk.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME tk \- Manipulate Tk internal state .SH SYNOPSIS -\fBtk\fR \fIoption \fR?\fIarg arg ...\fR? +\fBtk\fR \fIoption \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP The \fBtk\fR command provides access to miscellaneous elements of Tk's internal state. @@ -109,10 +109,22 @@ after the scaling factor is changed will use the new scaling factor, but it is undefined whether existing widgets will resize themselves dynamically to accommodate the new scaling factor. .RE .TP +\fBtk sysnotify \fP \fItitle\fP? \fImessage\fP? +. +The \fBtk sysnotify\fP command creates a platform-specific system +notification alert. Its intent is to provide a brief, unobtrusive +notification to the user by popping up a window that briefly appears in a +corner of the screen. For more details see the see the \fBsysnotify\fR manual page. +.TP +\fBtk systray create\fP \fIsubcommand...\fP +. +The \fBtk systray\fP command creates an icon in the platform-specific +tray. For more details see the see the \fBsystray\fR manual page. +.TP \fBtk useinputmethods \fR?\fB\-displayof \fIwindow\fR? ?\fIboolean\fR? . Sets and queries the state of whether Tk should use XIM (X Input Methods) for filtering events. The resulting state is returned. XIM is used in some locales (i.e., Japanese, Korean), to handle special input devices. This @@ -125,11 +137,11 @@ . Returns the current Tk windowing system, one of \fBx11\fR (X11-based), \fBwin32\fR (MS Windows), or \fBaqua\fR (Mac OS X Aqua). .SH "SEE ALSO" -busy(n), fontchooser(n), send(n), winfo(n) +busy(n), fontchooser(n), send(n), sysnotify(n), systray(n), winfo(n) .SH KEYWORDS -application name, send +application name, send, sysnotify, systray '\" Local Variables: '\" mode: nroff '\" End: Index: doc/tk_mac.n ================================================================== --- doc/tk_mac.n +++ doc/tk_mac.n @@ -216,15 +216,21 @@ The Aqua/Mac OS X defines additional dialogs that applications should support. .TP \fB::tk::mac::standardAboutPanel\fR . -Brings the standard Cocoa about panel to the front, with all its information -filled in from your application bundle files (standard about panel with no -options specified). See Apple Technote TN2179 and the AppKit documentation for --[NSApplication orderFrontStandardAboutPanelWithOptions:] for details on the -Info.plist keys and app bundle files used by the about panel. +Brings the standard Cocoa about panel to the front with information filled in +from the application bundle files. The panel displays the application icon and +the values associated to the info.plist keys named CFBundleName, +CFBundleShortVersionString, NSAboutPanelOptionVersion and +NSHumanReadableCopyright. If a file named \fICredits.html\fR or +\fICredits.rtf\fR exists in the bundle's Resources directory then its contents +will be displayed in a scrolling text box at the bottom of the dialog. See the +documentation for -[NSApplication orderFrontStandardAboutPanelWithOptions:] +for more details. A hook is also provided for a custom About dialog. If a Tcl +proc named tkAboutDialog is defined in the main interpreter then that +procedure will be called instead of opening the standardAboutPanel. .SH "SYSTEM CONFIGURATION" .PP There are a number of additional global configuration options that control the details of how Tk renders by default. .TP Index: doc/tkvars.n ================================================================== --- doc/tkvars.n +++ doc/tkvars.n @@ -48,11 +48,11 @@ The patch level is incremented for each new release or patch, and it uniquely identifies an official version of Tk. .RS .PP This value is normally the same as the result of -.QW "\fBpackage require\fR \fBTk\fR" . +.QW "\fBpackage require\fR \fBtk\fR" . .RE .TP \fBtk_strictMotif\fR . This variable is set to zero by default. Index: doc/toplevel.n ================================================================== --- doc/toplevel.n +++ doc/toplevel.n @@ -38,11 +38,13 @@ .VE "8.7, TIP262" .OP \-class class Class Specifies a class for the window. This class will be used when querying the option database for the window's other options, and it will also be used later for -other purposes such as bindings. +other purposes such as bindings. Some window managers display the +class name for windows in their dock while some others display the +window title. The \fB\-class\fR option may not be changed with the \fBconfigure\fR widget command. .OP \-colormap colormap Colormap Specifies a colormap to use for the window. The value may be either \fBnew\fR, in which case a new colormap is @@ -137,11 +139,11 @@ name is the same as the path name of the toplevel's window. This command may be used to invoke various operations on the widget. It has the following general form: .PP .CS -\fIpathName option \fR?\fIarg arg ...\fR? +\fIpathName option \fR?\fIarg ...\fR? .CE .PP \fIPathName\fR is the name of the command, which is the same as the toplevel widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact behavior of the command. The following Index: doc/ttk_Geometry.3 ================================================================== --- doc/ttk_Geometry.3 +++ doc/ttk_Geometry.3 @@ -64,12 +64,13 @@ .AP short border in Extra padding (in pixels) to add uniformly to each side of a region. .AP short bottom in Extra padding (in pixels) to add to the bottom of a region. .AP Ttk_Box box in -.AP "Ttk_Box *" box_rtn out Specifies a rectangular region. +.AP "Ttk_Box *" box_rtn out +A rectangular region. .AP int height in The height in pixels of a region. .AP "Tcl_Interp *" interp in Used to store error messages. .AP int left in @@ -77,33 +78,34 @@ .AP "Tcl_Obj *" objPtr in String value contains a symbolic name to be converted to an enumerated value or bitmask. Internal rep may be be modified to cache corresponding value. .AP Ttk_Padding padding in -.AP "Ttk_Padding *" padding_rtn out Extra padding to add on the inside of a region. +.AP "Ttk_Padding *" padding_rtn out +Padding present in the inside of a region. .AP Ttk_Box parcel in A rectangular region, allocated from a cavity. .AP int relief in One of the standard Tk relief options -(TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, etc.). +(\fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, etc.). See \fBTk_GetReliefFromObj\fR. .AP short right in Extra padding (in pixels) to add to the right side of a region. .AP Ttk_Side side in One of \fBTTK_SIDE_LEFT\fR, \fBTTK_SIDE_TOP\fR, \fBTTK_SIDE_RIGHT\fR, or \fBTTK_SIDE_BOTTOM\fR. .AP unsigned sticky in A bitmask containing one or more of the bits \fBTTK_STICK_W\fR (west, or left), -\fBTTK_STICK_E\fR (east, or right, +\fBTTK_STICK_E\fR (east, or right), \fBTTK_STICK_N\fR (north, or top), and \fBTTK_STICK_S\fR (south, or bottom). -\fBTTK_FILL_X\fR is defined as a synonym for (TTK_STICK_W|TTK_STICK_E), -\fBTTK_FILL_Y\fR is a synonym for (TTK_STICK_N|TTK_STICK_S), -and \fBTTK_FILL_BOTH\fR and \fBTTK_STICK_ALL\fR -are synonyms for (TTK_FILL_X|TTK_FILL_Y). +\fBTTK_FILL_X\fR is defined as a synonym for (\fBTTK_STICK_W\fR|\fBTTK_STICK_E\fR), +\fBTTK_FILL_Y\fR is a synonym for (\fBTTK_STICK_N\fR|\fBTTK_STICK_S\fR), +and \fBTTK_FILL_BOTH\fR +is a synonym for (\fBTTK_FILL_X\fR|\fBTTK_FILL_Y\fR). See also: \fIgrid(n)\fR. .AP Tk_Window tkwin in Window whose screen geometry determines the conversion between absolute units and pixels. .AP short top in Index: doc/ttk_button.n ================================================================== --- doc/ttk_button.n +++ doc/ttk_button.n @@ -46,12 +46,14 @@ .\" .OP \-anchor anchor Anchor .\" .OP \-relief relief Relief .SH "WIDGET COMMAND" .PP In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -commands, buttons support the following additional widget commands: +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +button widgets support the following additional commands: .TP \fIpathName \fBinvoke\fR Invokes the command associated with the button. .SH "STANDARD STYLES" .PP Index: doc/ttk_checkbutton.n ================================================================== --- doc/ttk_checkbutton.n +++ doc/ttk_checkbutton.n @@ -35,13 +35,14 @@ The name of a global variable whose value is linked to the widget. Defaults to the widget pathname if not specified. .SH "WIDGET COMMAND" .PP In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -commands, checkbuttons support the following additional -widget commands: +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +checkbutton widgets support the following additional commands: .TP \fIpathname\fB invoke\fR Toggles between the selected and deselected states and evaluates the associated \fB\-command\fR. If the widget is currently selected, sets the \fB\-variable\fR Index: doc/ttk_combobox.n ================================================================== --- doc/ttk_combobox.n +++ doc/ttk_combobox.n @@ -17,11 +17,11 @@ A \fBttk::combobox\fR combines a text field with a pop-down list of values; the user may select the value of the text field from among the values in the list. .SO ttk_widget \-class \-cursor \-takefocus -\-style \-placeholder +\-style \-placeholder \-placeholderforeground .SE .\" ALSO: Other entry widget options .SH "WIDGET-SPECIFIC OPTIONS" .OP \-exportselection exportSelection ExportSelection Boolean value. @@ -53,19 +53,15 @@ .OP \-width width Width Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. .SH "WIDGET COMMAND" .PP -The following subcommands are possible for combobox widgets: -'\".TP -'\"\fIpathName \fBcget\fR \fIoption\fR -'\"Returns the current value of the specified \fIoption\fR. -'\"See \fIttk::widget(n)\fR. -'\".TP -'\"\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -'\"Modify or query widget options. -'\"See \fIttk::widget(n)\fR. +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +combobox widgets support the following additional commands: .TP \fIpathName \fBcurrent\fR ?\fInewIndex\fR? If \fInewIndex\fR is supplied, sets the combobox value to the element at position \fInewIndex\fR in the list of \fB\-values\fR (in addition to integers, the \fBend\fR index is supported and indicates @@ -73,41 +69,22 @@ Otherwise, returns the index of the current value in the list of \fB\-values\fR or \fB\-1\fR if the current value does not appear in the list. .TP \fIpathName \fBget\fR Returns the current value of the combobox. -'\".TP -'\"\fIpathName \fBidentify \fIx y\fR -'\"Returns the name of the element at position \fIx\fR, \fIy\fR. -'\"See \fIttk::widget(n)\fR. -'\".TP -'\"\fIpathName \fBinstate \fIstateSpec\fR ?\fIscript\fR? -'\"Test the widget state. -'\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBset\fR \fIvalue\fR Sets the value of the combobox to \fIvalue\fR. -'\".TP -'\"\fIpathName \fBstate\fR ?\fIstateSpec\fR? -'\"Modify or query the widget state. -'\"See \fIttk::widget(n)\fR. .PP The combobox widget also supports the following \fBttk::entry\fR -widget subcommands (see \fIttk::entry(n)\fR for details): +widget commands: .DS .ta 5.5c 11c \fBbbox\fR \fBdelete\fR \fBicursor\fR \fBindex\fR \fBinsert\fR \fBselection\fR \fBxview\fR .DE -The combobox widget also supports the following generic \fBttk::widget\fR -widget subcommands (see \fIttk::widget(n)\fR for details): -.DS -.ta 5.5c 11c -\fBcget\fR \fBconfigure\fR \fBidentify\fR -\fBinstate\fR \fBstate\fR -.DE .SH "VIRTUAL EVENTS" .PP The combobox widget generates a \fB<>\fR virtual event when the user selects an element from the list of values. If the selection action unposts the listbox, @@ -140,15 +117,19 @@ .br \fB\-fieldbackground\fP \fIcolor\fP .RS Can only be changed when using non-native and non-graphical themes. .RE +\fB\-insertcolor\fP \fIcolor\fP +.br \fB\-insertwidth\fP \fIamount\fP .br \fB\-lightcolor\fP \fIcolor\fP .br \fB\-padding\fP \fIpadding\fP +.br +\fB\-placeholderforeground\fP \fIcolor\fP .br \fB\-postoffset\fP \fIpadding\fP .br \fB\-selectbackground\fP \fIcolor\fP .RS Index: doc/ttk_entry.n ================================================================== --- doc/ttk_entry.n +++ doc/ttk_entry.n @@ -24,11 +24,11 @@ standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command. .SO ttk_widget \-class \-cursor \-font \-foreground \-style -\-takefocus \-xscrollcommand \-placeholder +\-takefocus \-xscrollcommand \-placeholder \-placeholderforeground .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-exportselection exportSelection ExportSelection A boolean value specifying whether or not a selection in the widget should be linked to the X selection. @@ -137,11 +137,15 @@ .QW \fBsel.l\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. .SH "WIDGET COMMAND" .PP -The following subcommands are possible for entry widgets: +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR, \fBstyle\fR and \fBxview\fR +commands (see \fBttk::widget\fR), +entry widgets support the following additional commands: .TP \fIpathName \fBbbox \fIindex\fR Returns a list of four numbers describing the bounding box of the character given by \fIindex\fR. The first two elements of the list give the x and y coordinates of @@ -148,18 +152,10 @@ the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. -'\".TP -'\"\fIpathName \fBcget\fR \fIoption\fR -'\"Returns the current value of the specified \fIoption\fR. -'\"See \fIttk::widget(n)\fR. -'\".TP -'\"\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -'\"Modify or query widget options. -'\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR? Delete one or more elements of the entry. \fIFirst\fR is the index of the first character to delete, and \fIlast\fR is the index of the character just after the last @@ -172,25 +168,17 @@ Returns the entry's string. .TP \fIpathName \fBicursor \fIindex\fR Arrange for the insert cursor to be displayed just before the character given by \fIindex\fR. Returns the empty string. -'\".TP -'\"\fIpathName \fBidentify \fIx y\fR -'\"Returns the name of the element at position \fIx\fR, \fIy\fR, -'\"or the empty string if the coordinates are outside the window. .TP \fIpathName \fBindex\fI index\fR Returns the numerical index corresponding to \fIindex\fR. .TP \fIpathName \fBinsert \fIindex string\fR Insert \fIstring\fR just before the character indicated by \fIindex\fR. Returns the empty string. -'\".TP -'\"\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? -'\"Test the widget state. -'\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBselection \fIoption arg\fR This command is used to adjust the selection within an entry. It has several forms, depending on \fIoption\fR: .RS @@ -209,29 +197,17 @@ the one indexed by \fIstart\fR and ending with the one just before \fIend\fR. If \fIend\fR refers to the same character as \fIstart\fR or an earlier one, then the entry's selection is cleared. .RE -'\".TP -'\"\fIpathName \fBstate\fR ?\fIstateSpec\fR? -'\"Modify or query the widget state. -'\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBvalidate\fR Force revalidation, independent of the conditions specified by the \fB\-validate\fR option. Returns 0 if validation fails, 1 if it succeeds. Sets or clears the \fBinvalid\fR state accordingly. See \fBVALIDATION\fR below for more details. -.PP -The entry widget also supports the following generic \fBttk::widget\fR -widget subcommands (see \fIttk::widget(n)\fR for details): -.DS -.ta 5.5c 11c -\fBcget\fR \fBconfigure\fR \fBidentify\fR -\fBinstate\fR \fBstate\fR \fBxview\fR -.DE .SH VALIDATION .PP The \fB\-validate\fR, \fB\-validatecommand\fR, and \fB\-invalidcommand\fR options are used to enable entry widget validation. .SS "VALIDATION MODES" @@ -445,16 +421,20 @@ \fB\-fieldbackground\fP \fIcolor\fP .RS Some themes use a graphical background and their field background colors cannot be changed. .RE \fB\-foreground\fP \fIcolor\fP +.br +\fB\-insertcolor\fP \fIcolor\fP .br \fB\-insertwidth\fP \fIamount\fP .br \fB\-lightcolor\fP \fIcolor\fP .br \fB\-padding\fP \fIpadding\fP +.br +\fB\-placeholderforeground\fP \fIcolor\fP .br \fB\-relief\fP \fIrelief\fP .br \fB\-selectbackground\fP \fIcolor\fP .br Index: doc/ttk_frame.n ================================================================== --- doc/ttk_frame.n +++ doc/ttk_frame.n @@ -33,13 +33,14 @@ If specified, the widget's requested width in pixels. .OP \-height height Height If specified, the widget's requested height in pixels. .SH "WIDGET COMMAND" .PP -Supports the standard widget commands -\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR; -see \fIttk::widget(n)\fR. +Frame widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .SH "NOTES" .PP Note that if the \fBpack\fR, \fBgrid\fR, or other geometry managers are used to manage the children of the \fBframe\fR, by the GM's requested size will normally take precedence Index: doc/ttk_intro.n ================================================================== --- doc/ttk_intro.n +++ doc/ttk_intro.n @@ -84,11 +84,11 @@ .CS ttk::\fBstyle layout\fR Horizontal.TScrollbar { Scrollbar.trough \-children { Scrollbar.leftarrow \-side left \-sticky w Scrollbar.rightarrow \-side right \-sticky e - Scrollbar.thumb \-side left \-expand true \-sticky ew + Scrollbar.thumb \-sticky ew } } .CE .PP By default, the layout for a widget is the same as its class name. Index: doc/ttk_label.n ================================================================== --- doc/ttk_label.n +++ doc/ttk_label.n @@ -40,13 +40,14 @@ then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. .SH "WIDGET COMMAND" .PP -Supports the standard widget commands -\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR; -see \fIttk::widget(n)\fR. +Label widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .SH "STYLING OPTIONS" .PP The class name for a \fBttk::label\fP is \fBTLabel\fP. .PP Dynamic states: \fBdisabled\fP, \fBreadonly\fP. Index: doc/ttk_labelframe.n ================================================================== --- doc/ttk_labelframe.n +++ doc/ttk_labelframe.n @@ -60,13 +60,14 @@ sets the keyboard focus to the first child of the \fBttk::labelframe\fR widget. .OP \-width width Width If specified, the widget's requested width in pixels. .SH "WIDGET COMMAND" .PP -Supports the standard widget commands -\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR; -see \fIttk::widget(n)\fR. +Labelframe widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .SH "STYLING OPTIONS" .PP The class name for a \fBttk::labelframe\fP is \fBTLabelframe\fP. The text label has a class of \fBTLabelframe.Label\fP. Index: doc/ttk_menubutton.n ================================================================== --- doc/ttk_menubutton.n +++ doc/ttk_menubutton.n @@ -36,13 +36,14 @@ .\" not documented: may go away: .\" .OP \-anchor anchor Anchor .\" .OP \-padding padding Pad .SH "WIDGET COMMAND" .PP -Menubutton widgets support the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -methods. No other widget methods are used. +Menubutton widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .SH "STANDARD STYLES" .PP \fBTtk::menubutton\fR widgets support the \fBToolbutton\fR style in all standard themes, which is useful for creating widgets for toolbars. .SH "STYLING OPTIONS" Index: doc/ttk_notebook.n ================================================================== --- doc/ttk_notebook.n +++ doc/ttk_notebook.n @@ -18,11 +18,11 @@ .fi .BE .SH DESCRIPTION A \fBttk::notebook\fR widget manages a collection of windows and displays a single one at a time. -Each slave window is associated with a \fItab\fR, +Each content window is associated with a \fItab\fR, which the user may select to change the currently-displayed window. .SO ttk_widget \-class \-cursor \-takefocus \-style .SE @@ -54,15 +54,15 @@ .OP \-state state State Either \fBnormal\fR, \fBdisabled\fR or \fBhidden\fR. If \fBdisabled\fR, then the tab is not selectable. If \fBhidden\fR, then the tab is not shown. .OP \-sticky sticky Sticky -Specifies how the slave window is positioned within the pane area. +Specifies how the content window is positioned within the pane area. Value is a string containing zero or more of the characters \fBn, s, e,\fR or \fBw\fR. Each letter refers to a side (north, south, east, or west) -that the slave window will +that the content window will .QW stick to, as per the \fBgrid\fR geometry manager. .OP \-padding padding Padding Specifies the amount of extra space to add between the notebook and this pane. Syntax is the same as for the widget \fB\-padding\fR option. @@ -84,11 +84,11 @@ The \fItabid\fR argument to the following commands may take any of the following forms: .IP \(bu An integer between zero and the number of tabs; .IP \(bu -The name of a slave window; +The name of a content window; .IP \(bu A positional specification of the form .QW @\fIx\fR,\fIy\fR , which identifies the tab .IP \(bu @@ -100,23 +100,23 @@ .QW \fBend\fR , which returns the number of tabs (only valid for .QW "\fIpathname \fBindex\fR" ). .SH "WIDGET COMMAND" +.PP +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +notebook widgets support the following additional commands: .TP \fIpathname \fBadd \fIwindow\fR ?\fIoptions...\fR? Adds a new tab to the notebook. See \fBTAB OPTIONS\fR for the list of available \fIoptions\fR. If \fIwindow\fR is currently managed by the notebook but hidden, it is restored to its previous position. .TP -\fIpathname \fBconfigure\fR ?\fIoptions\fR? -See \fIttk::widget(n)\fR. -.TP -\fIpathname \fBcget \fIoption\fR -See \fIttk::widget(n)\fR. -.TP \fIpathname \fBforget \fItabid\fR Removes the tab specified by \fItabid\fR, unmaps and unmanages the associated window. .TP \fIpathname \fBhide \fItabid\fR @@ -149,23 +149,17 @@ or the name of a managed subwindow. If \fIsubwindow\fR is already managed by the notebook, moves it to the specified position. See \fBTAB OPTIONS\fR for the list of available options. .TP -\fIpathname \fBinstate \fIstatespec \fR?\fIscript...\fR? -See \fIttk::widget(n)\fR. -.TP \fIpathname \fBselect\fR ?\fItabid\fR? Selects the specified tab. -The associated slave window will be displayed, +The associated content window will be displayed, and the previously-selected window (if different) is unmapped. If \fItabid\fR is omitted, returns the widget name of the currently selected pane. .TP -\fIpathname \fBstate\fR ?\fIstatespec\fR? -See \fIttk::widget(n)\fR. -.TP \fIpathname \fBtab \fItabid\fR ?\fI\-option \fR?\fIvalue ...\fR Query or modify the options of the specific tab. If no \fI\-option\fR is specified, returns a dictionary of the tab option values. If one \fI\-option\fR is specified, Index: doc/ttk_panedwindow.n ================================================================== --- doc/ttk_panedwindow.n +++ doc/ttk_panedwindow.n @@ -46,13 +46,16 @@ .OP \-weight weight Weight An integer specifying the relative stretchability of the pane. When the paned window is resized, the extra space is added or subtracted to each pane proportionally to its \fB\-weight\fR. .SH "WIDGET COMMAND" -Supports the standard \fBconfigure\fR, \fBcget\fR, \fBstate\fR, -and \fBinstate\fR commands; see \fIttk::widget(n)\fR for details. -Additional commands: +.PP +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +panedwindow widgets support the following additional commands: .TP \fIpathname \fBadd \fIsubwindow options...\fR Adds a new pane to the window. See \fBPANE OPTIONS\fR for the list of available options. .TP @@ -104,18 +107,10 @@ .\" Full story: "total size" is either the -height (resp -width), .\" or the actual window height (resp actual window width), .\" depending on which changed most recently. Returns the new position of sash number \fIindex\fR. .\" Full story: new position may be different than the requested position. -.PP -The panedwindow widget also supports the following generic \fBttk::widget\fR -widget subcommands (see \fIttk::widget(n)\fR for details): -.DS -.ta 5.5c 11c -\fBcget\fR \fBconfigure\fR -\fBinstate\fR \fBstate\fR -.DE .SH "VIRTUAL EVENTS" .PP The panedwindow widget generates an \fB<>\fR virtual event on LeaveNotify/NotifyInferior events, because Tk does not execute binding scripts for events when the pointer crosses from a parent to a child. The Index: doc/ttk_progressbar.n ================================================================== --- doc/ttk_progressbar.n +++ doc/ttk_progressbar.n @@ -64,33 +64,22 @@ If specified to an existing variable, the \fB\-value\fR of the progress bar is automatically set to the value of the variable whenever the latter is modified. .SH "WIDGET COMMAND" .PP -.TP -\fIpathName \fBcget \fIoption\fR -Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR. -.TP -\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -Modify or query widget options; see \fIttk::widget(n)\fR. -.TP -\fIpathName \fBidentify \fIx y\fR -Returns the name of the element at position \fIx\fR, \fIy\fR. -See \fIttk::widget(n)\fR. -.TP -\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? -Test the widget state; see \fIttk::widget(n)\fR. +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +progressbar widgets support the following additional commands: .TP \fIpathName \fBstart\fR ?\fIinterval\fR? Begin autoincrement mode: schedules a recurring timer event that calls \fBstep\fR every \fIinterval\fR milliseconds. If omitted, \fIinterval\fR defaults to 50 milliseconds (20 steps/second). .TP -\fIpathName \fBstate\fR ?\fIstateSpec\fR? -Modify or query the widget state; see \fIttk::widget(n)\fR. -.TP \fIpathName \fBstep\fR ?\fIamount\fR? Increments the \fB\-value\fR by \fIamount\fR. \fIamount\fR defaults to 1.0 if omitted. .TP \fIpathName \fBstop\fR Index: doc/ttk_radiobutton.n ================================================================== --- doc/ttk_radiobutton.n +++ doc/ttk_radiobutton.n @@ -35,13 +35,14 @@ The name of a global variable whose value is linked to the widget. Default value is \fB::selectedButton\fR. .SH "WIDGET COMMAND" .PP In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -commands, radiobuttons support the following additional -widget commands: +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +radiobutton widgets support the following additional commands: .TP \fIpathname\fB invoke\fR Sets the \fB\-variable\fR to the \fB\-value\fR, selects the widget, and evaluates the associated \fB\-command\fR. Returns the result of the \fB\-command\fR, or the empty Index: doc/ttk_scale.n ================================================================== --- doc/ttk_scale.n +++ doc/ttk_scale.n @@ -49,49 +49,30 @@ value of the variable changes, the scale will update to reflect this value. Whenever the scale is manipulated interactively, the variable will be modified to reflect the scale's new value. .SH "WIDGET COMMAND" .PP -.TP -\fIpathName \fBcget \fIoption\fR -. -Returns the current value of the specified \fIoption\fR; see -\fIttk::widget(n)\fR. -.TP -\fIpathName \fBconfigure \fR?\fIoption\fR? ?\fIvalue option value ...\fR? -. -Modify or query widget options; see \fIttk::widget(n)\fR. +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +scale widgets support the following additional commands: .TP \fIpathName \fBget \fR?\fIx y\fR? -. Get the current value of the \fB\-value\fR option, or the value corresponding to the coordinates \fIx,y\fR if they are specified. \fIX\fR and \fIy\fR are pixel coordinates relative to the scale widget origin. .TP -\fIpathName \fBidentify \fIx y\fR -Returns the name of the element at position \fIx\fR, \fIy\fR. -See \fIttk::widget(n)\fR. -.TP -\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? -. -Test the widget state; see \fIttk::widget(n)\fR. -.TP \fIpathName \fBset \fIvalue\fR -. Set the value of the widget (i.e. the \fB\-value\fR option) to \fIvalue\fR. The value will be clipped to the range given by the \fB\-from\fR and \fB\-to\fR options. Note that setting the linked variable (i.e. the variable named in the \fB\-variable\fR option) does not cause such clipping. -.TP -\fIpathName \fBstate\fR ?\fIstateSpec\fR? -. -Modify or query the widget state; see \fIttk::widget(n)\fR. .SH "INTERNAL COMMANDS" .PP .TP \fIpathName \fBcoords \fR?\fIvalue\fR? -. Get the coordinates corresponding to \fIvalue\fR, or the coordinates corresponding to the current value of the \fB\-value\fR option if \fIvalue\fR is omitted. .SH "STYLING OPTIONS" .PP Index: doc/ttk_scrollbar.n ================================================================== --- doc/ttk_scrollbar.n +++ doc/ttk_scrollbar.n @@ -45,36 +45,25 @@ .OP \-orient orient Orient One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the scrollbar. .SH "WIDGET COMMAND" .PP -.TP -\fIpathName \fBcget \fIoption\fR -Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR. -.TP -\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -Modify or query widget options; see \fIttk::widget(n)\fR. +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +commands (see \fBttk::widget\fR), +scrollbar widgets support the following additional commands: .TP \fIpathName \fBget\fR Returns the scrollbar settings in the form of a list whose elements are the arguments to the most recent \fBset\fR widget command. .TP -\fIpathName \fBidentify \fIx y\fR -Returns the name of the element at position \fIx\fR, \fIy\fR. -See \fIttk::widget(n)\fR. -.TP -\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? -Test the widget state; see \fIttk::widget(n)\fR. -.TP \fIpathName \fBset \fIfirst last\fR This command is normally invoked by the scrollbar's associated widget from an \fB\-xscrollcommand\fR or \fB\-yscrollcommand\fR callback. Specifies the visible range to be displayed. \fIfirst\fR and \fIlast\fR are real fractions between 0 and 1. -.TP -\fIpathName \fBstate\fR ?\fIstateSpec\fR? -Modify or query the widget state; see \fIttk::widget(n)\fR. .SH "INTERNAL COMMANDS" .PP The following widget commands are used internally by the \fBTScrollbar\fP widget class bindings. .TP Index: doc/ttk_separator.n ================================================================== --- doc/ttk_separator.n +++ doc/ttk_separator.n @@ -24,13 +24,14 @@ .OP \-orient orient Orient One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the separator. .SH "WIDGET COMMAND" .PP -Separator widgets support the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -methods. No other widget methods are used. +Separator widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .PP .SH "STYLING OPTIONS" .PP The class name for a \fBttk::separator\fP is \fBTSeparator\fP. .PP Index: doc/ttk_sizegrip.n ================================================================== --- doc/ttk_sizegrip.n +++ doc/ttk_sizegrip.n @@ -21,13 +21,14 @@ \-class \-cursor \-style \-takefocus .SE .SH "WIDGET COMMAND" .PP -Sizegrip widgets support the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR -methods. No other widget methods are used. +Sizegrip widgets support the standard commands +\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR, +\fBstate\fR and \fBstyle\fR +(see \fBttk::widget\fR). .SH "PLATFORM-SPECIFIC NOTES" .PP On Mac OSX, toplevel windows automatically include a built-in size grip by default. Adding a \fBttk::sizegrip\fR there is harmless, since Index: doc/ttk_spinbox.n ================================================================== --- doc/ttk_spinbox.n +++ doc/ttk_spinbox.n @@ -20,11 +20,11 @@ of the \fBttk::entry\fR widget including support of the \fB\-textvariable\fR option to link the value displayed by the widget to a Tcl variable. .SO ttk_widget \-class \-cursor \-state \-style -\-takefocus \-xscrollcommand \-placeholder +\-takefocus \-xscrollcommand \-placeholder \-placeholderforeground .SE .SO ttk_entry \-validate \-validatecommand .SE .SH "WIDGET-SPECIFIC OPTIONS" @@ -105,13 +105,19 @@ .br \fB\-fieldbackground\fP \fIcolor\fP .br \fB\-foreground\fP \fIcolor\fP .br +\fB\-insertcolor\fP \fIcolor\fP +.br +\fB\-insertwidth\fP \fIamount\fP +.br \fB\-lightcolor\fP \fIcolor\fP .br \fB\-padding\fP \fIpadding\fP +.br +\fB\-placeholderforeground\fP \fIcolor\fP .br \fB\-selectbackground\fP \fIcolor\fP .br \fB\-selectforeground\fP \fIcolor\fP .PP Index: doc/ttk_style.n ================================================================== --- doc/ttk_style.n +++ doc/ttk_style.n @@ -25,39 +25,27 @@ By default, the style name is the same as the widget's class; this may be overridden by the \fB\-style\fR option. .PP A \fItheme\fR is a collection of elements and styles which controls the overall look and feel of an application. +The +.QW . +style is the theme root style on which derived styles are based. .SH DESCRIPTION .PP The \fBttk::style\fR command takes the following arguments: .TP \fBttk::style configure \fIstyle\fR ?\fI\-option\fR ?\fIvalue option value...\fR? ? Sets the default value of the specified option(s) in \fIstyle\fR. -.TP -\fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? -Sets dynamic values of the specified option(s) in \fIstyle\fR. -Each \fIstatespec / value\fR pair is examined in order; -the value corresponding to the first matching \fIstatespec\fR -is used. -.TP -\fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? -Returns the value specified for \fI\-option\fR in style \fIstyle\fR -in state \fIstate\fR, using the standard lookup rules for element options. -\fIstate\fR is a list of state names; if omitted, -it defaults to all bits off (the -.QW normal -state). -If the \fIdefault\fR argument is present, it is used as a fallback -value in case no specification for \fI\-option\fR is found. -.\" Otherwise -- signal error? return empty string? Leave unspecified for now. -.TP -\fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? -Define the widget layout for style \fIstyle\fR. -See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. -If \fIlayoutSpec\fR is omitted, return the layout specification -for style \fIstyle\fR. +If \fIstyle\fR does not exist, it is created. +If only \fIstyle\fR and \fI-option\fR are specified, get the default value +for option \fI-option\fR of style \fIstyle\fR. +If only \fIstyle\fR is specified, get the default value for all options +of style \fIstyle\fR. +.TP +\fBttk::style element\fR \fIargs\fR +.RS .TP \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR? Creates a new element in the current theme of type \fItype\fR. The only cross-platform built-in element type is \fIimage\fR (see \fBttk_image\fR(n)) but themes may define other element types @@ -68,51 +56,110 @@ \fBttk::style element names\fR Returns the list of elements defined in the current theme. .TP \fBttk::style element options \fIelement\fR Returns the list of \fIelement\fR's options. +.RE +.TP +\fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? +Define the widget layout for style \fIstyle\fR. +See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. +If \fIlayoutSpec\fR is omitted, return the layout specification +for style \fIstyle\fR. +.TP +\fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? +Returns the value specified for \fI\-option\fR in style \fIstyle\fR +in state \fIstate\fR, using the standard lookup rules for element options. +\fIstate\fR is a list of state names; if omitted, +it defaults to all bits off (the +.QW normal +state). +If the \fIdefault\fR argument is present, it is used as a fallback +value in case no specification for \fI\-option\fR is found. +.\" Otherwise -- signal error? return empty string? Leave unspecified for now. +If \fIstyle\fR does not exist, it is created. +.TP +\fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? +Sets dynamic (state dependent) values of the specified option(s) in \fIstyle\fR. +Each \fIstatespec / value\fR pair is examined in order; +the value corresponding to the first matching \fIstatespec\fR +is used. +If \fIstyle\fR does not exist, it is created. +If only \fIstyle\fR and \fI-option\fR are specified, get the dynamic values +for option \fI-option\fR of style \fIstyle\fR. +If only \fIstyle\fR is specified, get the dynamic values for all options +of style \fIstyle\fR. +.TP +\fBttk::style theme\fR \fIargs\fR +.RS .TP \fBttk::style theme create\fR \fIthemeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ? Creates a new theme. It is an error if \fIthemeName\fR already exists. If \fB\-parent\fR is specified, the new theme will inherit styles, elements, and layouts from the parent theme \fIbasedon\fR. If \fB\-settings\fR is present, \fIscript\fR is evaluated in the context of the new theme as per \fBttk::style theme settings\fR. .TP +\fBttk::style theme names\fR +Returns a list of all known themes. +.TP \fBttk::style theme settings \fIthemeName\fR \fIscript\fR Temporarily sets the current theme to \fIthemeName\fR, evaluate \fIscript\fR, then restore the previous theme. Typically \fIscript\fR simply defines styles and elements, though arbitrary Tcl code may appear. .TP -\fBttk::style theme names\fR -Returns a list of all known themes. +\fBttk::style theme styles\fR ?\fIthemeName\fR? +Returns a list of all styles in \fIthemeName\fR. If \fIthemeName\fR +is omitted, the current theme is used. .TP \fBttk::style theme use\fR ?\fIthemeName\fR? Without an argument the result is the name of the current theme. Otherwise this command sets the current theme to \fIthemeName\fR, and refreshes all widgets. +.RE .SH LAYOUTS .PP A \fIlayout\fR specifies a list of elements, each followed by one or more options specifying how to arrange the element. The layout mechanism uses a simplified version of the \fBpack\fR geometry manager: given an initial cavity, each element is allocated a parcel. +Then the parcel actually used by the element is adjusted within +the allocated parcel. Valid options are: +.\" -border should remain undocumented for now (dubious usefulness) +.\" .TP +.\" \fB\-border\fR \fIboolean\fR +.\" Specifies whether the element is drawn after its children. Defaults to 0. +.TP +\fB\-children { \fIsublayout...\fB }\fR +Specifies a list of elements to place inside the element. +.TP +\fB\-expand\fR \fIboolean\fR +Specifies whether the allocated parcel is the entire cavity. If so, +simultaneous specification of \fB\-side\fR is ignored. +Defaults to 0. .TP \fB\-side \fIside\fR Specifies which side of the cavity to place the element; one of \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR. -If omitted, the element occupies the entire cavity. +For instance, \fB\-side top\fR allocates the parcel along the top of +the cavity having width and height respectively the width of the cavity +and the height of the element. +If omitted, the allocated parcel is the entire cavity (same effect +as \fB\-expand\fR 1). .TP \fB\-sticky\fR \fB[\fInswe\fB]\fR -Specifies where the element is placed inside its allocated parcel. -.TP -\fB\-children { \fIsublayout... \fB}\fR -Specifies a list of elements to place inside the element. -.\" Also: -border, -unit, -expand: may go away. +Specifies the actual parcel position and size inside the allocated parcel. +If specified as an empty string then the actual parcel is centered in +the allocated parcel. Default is \fBnswe\fR. +.\" -unit should remain undocumented for now (dubious usefulness) +.\" .TP +.\" \fB\-unit\fR \fIboolean\fR +.\" Specifies whether the element propagates its state to its children. +.\" Defaults to 0. .PP For example: .CS ttk::style layout Horizontal.TScrollbar { Scrollbar.trough \-children { Index: doc/ttk_treeview.n ================================================================== --- doc/ttk_treeview.n +++ doc/ttk_treeview.n @@ -90,10 +90,15 @@ \fBNOTE:\fR Column #0 always refers to the tree column, even if \fB\-show tree\fR is not specified. .RE .SH "WIDGET COMMAND" .PP +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBinstate\fR, +\fBstate\fR, \fBstyle\fR, \fBxview\fR and \fByview\fR +commands (see \fBttk::widget\fR), +treeview widgets support the following additional commands: .TP \fIpathname \fBbbox \fIitem\fR ?\fIcolumn\fR? Returns the bounding box (relative to the treeview widget's window) of the specified \fIitem\fR in the form \fIx y width height\fR. @@ -100,13 +105,10 @@ If \fIcolumn\fR is specified, returns the bounding box of that cell. If the \fIitem\fR is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns the empty list. .TP -\fIpathname \fBcget \fIoption\fR -Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR. -.TP \fIpathname \fBchildren \fIitem\fR ?\fInewchildren\fR? If \fInewchildren\fR is not specified, returns the list of children belonging to \fIitem\fR. .RS .PP @@ -158,13 +160,10 @@ column separator. .PP Use \fIpathname column #0\fR to configure the tree column. .RE .TP -\fIpathname \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -Modify or query widget options; see \fIttk::widget(n)\fR. -.TP \fIpathname \fBdelete \fIitemList\fR Deletes each of the items in \fIitemList\fR and all of their descendants. The root item may not be deleted. See also: \fBdetach\fR. .TP @@ -270,13 +269,10 @@ \fIpathname \fBinsert\fR returns the item identifier of the newly created item. See \fBITEM OPTIONS\fR for the list of available options. .RE .TP -\fIpathname \fBinstate \fIstatespec\fR ?\fIscript\fR? -Test the widget state; see \fIttk::widget(n)\fR. -.TP \fIpathname \fBitem \fIitem\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? Query or modify the options for the specified \fIitem\fR. If no \fI\-option\fR is specified, returns a dictionary of option/value pairs. If a single \fI\-option\fR is specified, @@ -336,13 +332,10 @@ With two arguments, returns the current value of the specified \fIcolumn\fR. With three arguments, sets the value of column \fIcolumn\fR in item \fIitem\fR to the specified \fIvalue\fR. See also \fBCOLUMN IDENTIFIERS\fR. .TP -\fIpathname \fBstate\fR ?\fIstateSpec\fR? -Modify or query the widget state; see \fIttk::widget(n)\fR. -.TP \fIpathName \fBtag \fIargs...\fR .RS .TP \fIpathName \fBtag add \fItag items\fR Adds the specified \fItag\fR to each of the listed \fIitems\fR. @@ -396,17 +389,10 @@ Removes the specified \fItag\fR from each of the listed \fIitems\fR. If \fIitems\fR is omitted, removes \fItag\fR from each item in the tree. If \fItag\fR is not present for a particular item, then the \fB\-tags\fR for that item are unchanged. .RE -.PP -The treeview widget also supports the following generic \fBttk::widget\fR -widget subcommands (see \fIttk::widget(n)\fR for details): -.DS -.ta 5.5c 11c -\fBxview\fR \fByview\fR -.DE .SH "ITEM OPTIONS" .PP The following item options may be specified for items in the \fBinsert\fR and \fBitem\fR widget commands. .OP \-text text Text Index: doc/ttk_widget.n ================================================================== --- doc/ttk_widget.n +++ doc/ttk_widget.n @@ -150,17 +150,18 @@ acceptable to \fBTk_GetPixels\fR. If this option is less than or equal to zero, then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. .SH "ENTRY OPTIONS" -The following option is supported by entry, spinbox and combobox: +The following options are supported by entry, spinbox and combobox: .OP \-placeholder placeHolder PlaceHolder Specifies a help text string to display if no text is otherwise displayed, that is when the widget is empty. The placeholder text is displayed using -the values of the \fB\-font\fR and \fB\-justify\fR options. The foreground -color of the placeholder text can be changed using the -\fB\-placeholderforeground\fR style option. +the values of the \fB\-font\fR, \fB\-justify\fR and +\fB\-placeholderforeground\fR options. +.OP \-placeholderforeground placeHolderForeground PlaceHolderForeground +Specifies the foreground color of the placeholder text. .SH "COMPATIBILITY OPTIONS" This option is only available for themed widgets that have .QW corresponding traditional Tk widgets. .OP \-state state State @@ -171,16 +172,14 @@ but the \fBstate\fR widget command does not affect the \fB\-state\fR option. .SH COMMANDS .TP \fIpathName \fBcget \fIoption\fR -. Returns the current value of the configuration option given by \fIoption\fR. .TP \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? -. Query or modify the configuration options of the widget. If one or more \fIoption\-value\fR pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. @@ -192,29 +191,27 @@ .\" Note: Ttk widgets don't use TK_OPTION_SYNONYM. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR. .TP \fIpathName \fBidentify element \fIx y\fR -. Returns the name of the element under the point given by \fIx\fR and \fIy\fR, or an empty string if the point does not lie within any element. \fIx\fR and \fIy\fR are pixel coordinates relative to the widget. -Some widgets accept other \fBidentify\fR subcommands. +Some widgets accept other \fBidentify\fR subcommands described +in these widgets documentation. .TP \fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? -. Test the widget's state. If \fIscript\fR is not specified, returns 1 if the widget state matches \fIstatespec\fR and 0 otherwise. If \fIscript\fR is specified, equivalent to .CS if {[\fIpathName\fR instate \fIstateSpec\fR]} \fIscript\fR .CE .TP \fIpathName \fBstate\fR ?\fIstateSpec\fR? -. Modify or inquire widget state. If \fIstateSpec\fR is present, sets the widget state: for each flag in \fIstateSpec\fR, sets the corresponding flag or clears it if prefixed by an exclamation point. .RS @@ -226,10 +223,13 @@ will restore \fIpathName\fR to the original state. If \fIstateSpec\fR is not specified, returns a list of the currently-enabled state flags. .RE .TP +\fIpathName \fBstyle\fR +Return the style used by the widget. +.TP \fIpathName \fBxview \fIargs\fR This command is used to query and change the horizontal position of the content in the widget's window. It can take any of the following forms: .RS @@ -254,11 +254,12 @@ \fIFraction\fR must be a fraction between 0 and 1. .TP \fIpathName \fBxview scroll \fInumber what\fR This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. -\fINumber\fR must be an integer. +\fINumber\fR must be an integer or a float, but if it is a float then +it is converted to an integer, rounded away from 0. \fIWhat\fR must be either \fBpages\fR or \fBunits\fR. '\" or an abbreviation of one of these, but we don't document that. If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left Index: doc/winfo.n ================================================================== --- doc/winfo.n +++ doc/winfo.n @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME winfo \- Return window-related information .SH SYNOPSIS -\fBwinfo\fR \fIoption \fR?\fIarg arg ...\fR? +\fBwinfo\fR \fIoption \fR?\fIarg ...\fR? .BE .SH DESCRIPTION .PP The \fBwinfo\fR command is used to retrieve information about windows managed by Tk. It can take any of a number of different forms, Index: doc/wish.1 ================================================================== --- doc/wish.1 +++ doc/wish.1 @@ -10,11 +10,11 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME wish \- Simple windowing shell .SH SYNOPSIS -\fBwish\fR ?\fB\-encoding \fIname\fR? ?\fIfileName arg arg ...\fR? +\fBwish\fR ?\fB\-encoding \fIname\fR? ?\fIfileName arg ...\fR? .SH OPTIONS .IP "\fB\-encoding \fIname\fR" 20 Specifies the encoding of the text stored in \fIfileName\fR. This option is only recognized prior to the \fIfileName\fR argument. .IP "\fB\-colormap \fInew\fR" 20 Index: doc/wm.n ================================================================== --- doc/wm.n +++ doc/wm.n @@ -706,22 +706,22 @@ should display this string in \fIwindow\fR's title bar). In this case the command returns an empty string. If \fIstring\fR is not specified then the command returns the current title for the \fIwindow\fR. The title for a window defaults to its name. .TP -\fBwm transient \fIwindow\fR ?\fImaster\fR? +\fBwm transient \fIwindow\fR ?\fIcontainer\fR? . -If \fImaster\fR is specified, then the window manager is informed that +If \fIcontainer\fR is specified, then the window manager is informed that \fIwindow\fR is a transient window (e.g. pull-down menu) working on -behalf of \fImaster\fR (where \fImaster\fR is the path name for a -top-level window). If \fImaster\fR is specified as an empty string +behalf of \fIcontainer\fR (where \fIcontainer\fR is the path name for a +top-level window). If \fIcontainer\fR is specified as an empty string then \fIwindow\fR is marked as not being a transient window any more. Otherwise the command returns the path name of \fIwindow\fR's current -master, or an empty string if \fIwindow\fR is not currently a +container, or an empty string if \fIwindow\fR is not currently a transient window. A transient window will mirror state changes in the -master and inherit the state of the master when initially mapped. The -directed graph with an edge from each transient to its master must be +container and inherit the state of the container when initially mapped. The +directed graph with an edge from each transient to its container must be acyclic. In particular, it is an error to attempt to make a window a transient of itself. The window manager may also decorate a transient window differently, removing some features normally present (e.g., minimize and maximize buttons) though this is entirely at the discretion of the window manager. Index: generic/ks_names.h ================================================================== --- generic/ks_names.h +++ generic/ks_names.h @@ -18,16 +18,11 @@ { "Return", 0xFF0D }, { "Pause", 0xFF13 }, { "Scroll_Lock", 0xFF14 }, { "Sys_Req", 0xFF15 }, { "Escape", 0xFF1B }, -{ "Delete", 0xFFFF }, { "Multi_key", 0xFF20 }, -{ "Codeinput", 0xFF37 }, -{ "SingleCandidate", 0xFF3C }, -{ "MultipleCandidate", 0xFF3D }, -{ "PreviousCandidate", 0xFF3E }, { "Kanji", 0xFF21 }, { "Muhenkan", 0xFF22 }, { "Henkan_Mode", 0xFF23 }, { "Henkan", 0xFF23 }, { "Romaji", 0xFF24 }, @@ -41,13 +36,25 @@ { "Massyo", 0xFF2C }, { "Kana_Lock", 0xFF2D }, { "Kana_Shift", 0xFF2E }, { "Eisu_Shift", 0xFF2F }, { "Eisu_toggle", 0xFF30 }, -{ "Kanji_Bangou", 0xFF37 }, -{ "Zen_Koho", 0xFF3D }, -{ "Mae_Koho", 0xFF3E }, +{ "Hangul", 0xFF31 }, +{ "Hangul_Start", 0xFF32 }, +{ "Hangul_End", 0xFF33 }, +{ "Hangul_Hanja", 0xFF34 }, +{ "Hangul_Jamo", 0xFF35 }, +{ "Hangul_Romaja", 0xFF36 }, +{ "Codeinput", 0xFF37 }, +{ "Hangul_Jeonja", 0xFF38 }, +{ "Hangul_Banja", 0xFF39 }, +{ "Hangul_PreHanja", 0xFF3A }, +{ "Hangul_PostHanja", 0xFF3B }, +{ "SingleCandidate", 0xFF3C }, +{ "MultipleCandidate", 0xFF3D }, +{ "PreviousCandidate", 0xFF3E }, +{ "Hangul_Special", 0xFF3F }, { "Home", 0xFF50 }, { "Left", 0xFF51 }, { "Up", 0xFF52 }, { "Right", 0xFF53 }, { "Down", 0xFF54 }, @@ -55,26 +62,32 @@ { "Page_Up", 0xFF55 }, { "Next", 0xFF56 }, { "Page_Down", 0xFF56 }, { "End", 0xFF57 }, { "Begin", 0xFF58 }, -{ "Win_L", 0xFF5B }, -{ "Win_R", 0xFF5C }, -{ "App", 0xFF5D }, { "Select", 0xFF60 }, { "Print", 0xFF61 }, { "Execute", 0xFF62 }, { "Insert", 0xFF63 }, { "Undo", 0xFF65 }, { "Redo", 0xFF66 }, { "Menu", 0xFF67 }, +#ifndef TK_NO_DEPRECATED +{ "App", 0xFF67 }, +#endif { "Find", 0xFF68 }, { "Cancel", 0xFF69 }, { "Help", 0xFF6A }, { "Break", 0xFF6B }, { "Mode_switch", 0xFF7E }, +#ifndef TK_NO_DEPRECATED { "script_switch", 0xFF7E }, +{ "kana_switch", 0xFF7E }, +{ "Arabic_switch", 0xFF7E }, +{ "Greek_switch", 0xFF7E }, +{ "Hebrew_switch", 0xFF7E }, +#endif { "Num_Lock", 0xFF7F }, { "KP_Space", 0xFF80 }, { "KP_Tab", 0xFF89 }, { "KP_Enter", 0xFF8D }, { "KP_F1", 0xFF91 }, @@ -92,11 +105,10 @@ { "KP_Page_Down", 0xFF9B }, { "KP_End", 0xFF9C }, { "KP_Begin", 0xFF9D }, { "KP_Insert", 0xFF9E }, { "KP_Delete", 0xFF9F }, -{ "KP_Equal", 0xFFBD }, { "KP_Multiply", 0xFFAA }, { "KP_Add", 0xFFAB }, { "KP_Separator", 0xFFAC }, { "KP_Subtract", 0xFFAD }, { "KP_Decimal", 0xFFAE }, @@ -109,10 +121,11 @@ { "KP_5", 0xFFB5 }, { "KP_6", 0xFFB6 }, { "KP_7", 0xFFB7 }, { "KP_8", 0xFFB8 }, { "KP_9", 0xFFB9 }, +{ "KP_Equal", 0xFFBD }, { "F1", 0xFFBE }, { "F2", 0xFFBF }, { "F3", 0xFFC0 }, { "F4", 0xFFC1 }, { "F5", 0xFFC2 }, @@ -180,22 +193,35 @@ { "Meta_L", 0xFFE7 }, { "Meta_R", 0xFFE8 }, { "Alt_L", 0xFFE9 }, { "Alt_R", 0xFFEA }, { "Super_L", 0xFFEB }, +#ifndef TK_NO_DEPRECATED +{ "Win_L", 0xFFEB }, +#endif { "Super_R", 0xFFEC }, +#ifndef TK_NO_DEPRECATED +{ "Win_R", 0xFFEC }, +#endif { "Hyper_L", 0xFFED }, { "Hyper_R", 0xFFEE }, +{ "braille_dot_1", 0xFFF1 }, +{ "braille_dot_2", 0xFFF2 }, +{ "braille_dot_3", 0xFFF3 }, +{ "braille_dot_4", 0xFFF4 }, +{ "braille_dot_5", 0xFFF5 }, +{ "braille_dot_6", 0xFFF6 }, +{ "braille_dot_7", 0xFFF7 }, +{ "braille_dot_8", 0xFFF8 }, +{ "braille_dot_9", 0xFFF9 }, +{ "braille_dot_10", 0xFFFA }, +{ "Delete", 0xFFFF }, { "ISO_Lock", 0xFE01 }, { "ISO_Level2_Latch", 0xFE02 }, { "ISO_Level3_Shift", 0xFE03 }, { "ISO_Level3_Latch", 0xFE04 }, { "ISO_Level3_Lock", 0xFE05 }, -{ "ISO_Level5_Shift", 0xFE11 }, -{ "ISO_Level5_Latch", 0xFE12 }, -{ "ISO_Level5_Lock", 0xFE13 }, -{ "ISO_Group_Shift", 0xFF7E }, { "ISO_Group_Latch", 0xFE06 }, { "ISO_Group_Lock", 0xFE07 }, { "ISO_Next_Group", 0xFE08 }, { "ISO_Next_Group_Lock", 0xFE09 }, { "ISO_Prev_Group", 0xFE0A }, @@ -202,10 +228,13 @@ { "ISO_Prev_Group_Lock", 0xFE0B }, { "ISO_First_Group", 0xFE0C }, { "ISO_First_Group_Lock", 0xFE0D }, { "ISO_Last_Group", 0xFE0E }, { "ISO_Last_Group_Lock", 0xFE0F }, +{ "ISO_Level5_Shift", 0xFE11 }, +{ "ISO_Level5_Latch", 0xFE12 }, +{ "ISO_Level5_Lock", 0xFE13 }, { "ISO_Left_Tab", 0xFE20 }, { "ISO_Move_Line_Up", 0xFE21 }, { "ISO_Move_Line_Down", 0xFE22 }, { "ISO_Partial_Line_Up", 0xFE23 }, { "ISO_Partial_Line_Down", 0xFE24 }, @@ -258,14 +287,21 @@ { "dead_belowbreve", 0xFE6B }, { "dead_belowdiaeresis", 0xFE6C }, { "dead_invertedbreve", 0xFE6D }, { "dead_belowcomma", 0xFE6E }, { "dead_currency", 0xFE6F }, -{ "dead_lowline", 0xFE90 }, -{ "dead_aboveverticalline", 0xFE91 }, -{ "dead_belowverticalline", 0xFE92 }, -{ "dead_longsolidusoverlay", 0xFE93 }, +{ "AccessX_Enable", 0xFE70 }, +{ "AccessX_Feedback_Enable", 0xFE71 }, +{ "RepeatKeys_Enable", 0xFE72 }, +{ "SlowKeys_Enable", 0xFE73 }, +{ "BounceKeys_Enable", 0xFE74 }, +{ "StickyKeys_Enable", 0xFE75 }, +{ "MouseKeys_Enable", 0xFE76 }, +{ "MouseKeys_Accel_Enable", 0xFE77 }, +{ "Overlay1_Enable", 0xFE78 }, +{ "Overlay2_Enable", 0xFE79 }, +{ "AudibleBell_Enable", 0xFE7A }, { "dead_a", 0xFE80 }, { "dead_A", 0xFE81 }, { "dead_e", 0xFE82 }, { "dead_E", 0xFE83 }, { "dead_i", 0xFE84 }, @@ -275,26 +311,25 @@ { "dead_u", 0xFE88 }, { "dead_U", 0xFE89 }, { "dead_small_schwa", 0xFE8A }, { "dead_capital_schwa", 0xFE8B }, { "dead_greek", 0xFE8C }, +{ "dead_lowline", 0xFE90 }, +{ "dead_aboveverticalline", 0xFE91 }, +{ "dead_belowverticalline", 0xFE92 }, +{ "dead_longsolidusoverlay", 0xFE93 }, +{ "ch", 0xFEA0 }, +{ "Ch", 0xFEA1 }, +{ "CH", 0xFEA2 }, +{ "c_h", 0xFEA3 }, +{ "C_h", 0xFEA4 }, +{ "C_H", 0xFEA5 }, { "First_Virtual_Screen", 0xFED0 }, { "Prev_Virtual_Screen", 0xFED1 }, { "Next_Virtual_Screen", 0xFED2 }, { "Last_Virtual_Screen", 0xFED4 }, { "Terminate_Server", 0xFED5 }, -{ "AccessX_Enable", 0xFE70 }, -{ "AccessX_Feedback_Enable", 0xFE71 }, -{ "RepeatKeys_Enable", 0xFE72 }, -{ "SlowKeys_Enable", 0xFE73 }, -{ "BounceKeys_Enable", 0xFE74 }, -{ "StickyKeys_Enable", 0xFE75 }, -{ "MouseKeys_Enable", 0xFE76 }, -{ "MouseKeys_Accel_Enable", 0xFE77 }, -{ "Overlay1_Enable", 0xFE78 }, -{ "Overlay2_Enable", 0xFE79 }, -{ "AudibleBell_Enable", 0xFE7A }, { "Pointer_Left", 0xFEE0 }, { "Pointer_Right", 0xFEE1 }, { "Pointer_Up", 0xFEE2 }, { "Pointer_Down", 0xFEE3 }, { "Pointer_UpLeft", 0xFEE4 }, @@ -316,21 +351,15 @@ { "Pointer_Drag_Dflt", 0xFEF4 }, { "Pointer_Drag1", 0xFEF5 }, { "Pointer_Drag2", 0xFEF6 }, { "Pointer_Drag3", 0xFEF7 }, { "Pointer_Drag4", 0xFEF8 }, -{ "Pointer_Drag5", 0xFEFD }, { "Pointer_EnableKeys", 0xFEF9 }, { "Pointer_Accelerate", 0xFEFA }, { "Pointer_DfltBtnNext", 0xFEFB }, { "Pointer_DfltBtnPrev", 0xFEFC }, -{ "ch", 0xFEA0 }, -{ "Ch", 0xFEA1 }, -{ "CH", 0xFEA2 }, -{ "c_h", 0xFEA3 }, -{ "C_h", 0xFEA4 }, -{ "C_H", 0xFEA5 }, +{ "Pointer_Drag5", 0xFEFD }, { "3270_Duplicate", 0xFD01 }, { "3270_FieldMark", 0xFD02 }, { "3270_Right2", 0xFD03 }, { "3270_Left2", 0xFD04 }, { "3270_BackTab", 0xFD05 }, @@ -358,24 +387,29 @@ { "3270_ExSelect", 0xFD1B }, { "3270_CursorSelect", 0xFD1C }, { "3270_PrintScreen", 0xFD1D }, { "3270_Enter", 0xFD1E }, { "space", 0x20 }, +#ifndef TK_NO_DEPRECATED { "exclam", 0x21 }, +#endif { "quotedbl", 0x22 }, { "numbersign", 0x23 }, { "dollar", 0x24 }, +#ifndef TK_NO_DEPRECATED { "percent", 0x25 }, { "ampersand", 0x26 }, { "apostrophe", 0x27 }, { "quoteright", 0x27 }, { "parenleft", 0x28 }, { "parenright", 0x29 }, { "asterisk", 0x2A }, { "plus", 0x2B }, { "comma", 0x2C }, +#endif { "minus", 0x2D }, +#ifndef TK_NO_DEPRECATED { "period", 0x2E }, { "slash", 0x2F }, { "0", 0x30 }, { "1", 0x31 }, { "2", 0x32 }, @@ -385,14 +419,18 @@ { "6", 0x36 }, { "7", 0x37 }, { "8", 0x38 }, { "9", 0x39 }, { "colon", 0x3A }, +#endif { "semicolon", 0x3B }, { "less", 0x3C }, +#ifndef TK_NO_DEPRECATED { "equal", 0x3D }, +#endif { "greater", 0x3E }, +#ifndef TK_NO_DEPRECATED { "question", 0x3F }, { "at", 0x40 }, { "A", 0x41 }, { "B", 0x42 }, { "C", 0x43 }, @@ -417,13 +455,15 @@ { "V", 0x56 }, { "W", 0x57 }, { "X", 0x58 }, { "Y", 0x59 }, { "Z", 0x5A }, +#endif { "bracketleft", 0x5B }, { "backslash", 0x5C }, { "bracketright", 0x5D }, +#ifndef TK_NO_DEPRECATED { "asciicircum", 0x5E }, { "underscore", 0x5F }, { "grave", 0x60 }, { "quoteleft", 0x60 }, { "a", 0x61 }, @@ -450,15 +490,21 @@ { "v", 0x76 }, { "w", 0x77 }, { "x", 0x78 }, { "y", 0x79 }, { "z", 0x7A }, +#endif { "braceleft", 0x7B }, +#ifndef TK_NO_DEPRECATED { "bar", 0x7C }, +#endif { "braceright", 0x7D }, +#ifndef TK_NO_DEPRECATED { "asciitilde", 0x7E }, +#endif { "nobreakspace", 0xA0 }, +#ifndef TK_NO_DEPRECATED { "exclamdown", 0xA1 }, { "cent", 0xA2 }, { "sterling", 0xA3 }, { "currency", 0xA4 }, { "yen", 0xA5 }, @@ -548,20 +594,18 @@ { "ocircumflex", 0xF4 }, { "otilde", 0xF5 }, { "odiaeresis", 0xF6 }, { "division", 0xF7 }, { "oslash", 0xF8 }, -#ifndef TK_NO_DEPRECATED -{ "ooblique", 0xF8 }, -#endif { "ugrave", 0xF9 }, { "uacute", 0xFA }, { "ucircumflex", 0xFB }, { "udiaeresis", 0xFC }, { "yacute", 0xFD }, { "thorn", 0xFE }, { "ydiaeresis", 0xFF }, +#endif /* TK_NO_DEPRECATED */ { "Aogonek", 0x1A1 }, { "breve", 0x1A2 }, { "Lstroke", 0x1A3 }, { "Lcaron", 0x1A5 }, { "Sacute", 0x1A6 }, @@ -678,36 +722,10 @@ { "omacron", 0x3F2 }, { "kcedilla", 0x3F3 }, { "uogonek", 0x3F9 }, { "utilde", 0x3FD }, { "umacron", 0x3FE }, -{ "Wcircumflex", 0x1000174 }, -{ "wcircumflex", 0x1000175 }, -{ "Ycircumflex", 0x1000176 }, -{ "ycircumflex", 0x1000177 }, -{ "Babovedot", 0x1001E02 }, -{ "babovedot", 0x1001E03 }, -{ "Dabovedot", 0x1001E0A }, -{ "dabovedot", 0x1001E0B }, -{ "Fabovedot", 0x1001E1E }, -{ "fabovedot", 0x1001E1F }, -{ "Mabovedot", 0x1001E40 }, -{ "mabovedot", 0x1001E41 }, -{ "Pabovedot", 0x1001E56 }, -{ "pabovedot", 0x1001E57 }, -{ "Sabovedot", 0x1001E60 }, -{ "sabovedot", 0x1001E61 }, -{ "Tabovedot", 0x1001E6A }, -{ "tabovedot", 0x1001E6B }, -{ "Wgrave", 0x1001E80 }, -{ "wgrave", 0x1001E81 }, -{ "Wacute", 0x1001E82 }, -{ "wacute", 0x1001E83 }, -{ "Wdiaeresis", 0x1001E84 }, -{ "wdiaeresis", 0x1001E85 }, -{ "Ygrave", 0x1001EF2 }, -{ "ygrave", 0x1001EF3 }, { "OE", 0x13BC }, { "oe", 0x13BD }, { "Ydiaeresis", 0x13BE }, { "overline", 0x47E }, { "kana_fullstop", 0x4A1 }, @@ -786,40 +804,11 @@ { "kana_RO", 0x4DB }, { "kana_WA", 0x4DC }, { "kana_N", 0x4DD }, { "voicedsound", 0x4DE }, { "semivoicedsound", 0x4DF }, -{ "kana_switch", 0xFF7E }, -{ "Farsi_0", 0x10006F0 }, -{ "Farsi_1", 0x10006F1 }, -{ "Farsi_2", 0x10006F2 }, -{ "Farsi_3", 0x10006F3 }, -{ "Farsi_4", 0x10006F4 }, -{ "Farsi_5", 0x10006F5 }, -{ "Farsi_6", 0x10006F6 }, -{ "Farsi_7", 0x10006F7 }, -{ "Farsi_8", 0x10006F8 }, -{ "Farsi_9", 0x10006F9 }, -{ "Arabic_percent", 0x100066A }, -{ "Arabic_superscript_alef", 0x1000670 }, -{ "Arabic_tteh", 0x1000679 }, -{ "Arabic_peh", 0x100067E }, -{ "Arabic_tcheh", 0x1000686 }, -{ "Arabic_ddal", 0x1000688 }, -{ "Arabic_rreh", 0x1000691 }, { "Arabic_comma", 0x5AC }, -{ "Arabic_fullstop", 0x10006D4 }, -{ "Arabic_0", 0x1000660 }, -{ "Arabic_1", 0x1000661 }, -{ "Arabic_2", 0x1000662 }, -{ "Arabic_3", 0x1000663 }, -{ "Arabic_4", 0x1000664 }, -{ "Arabic_5", 0x1000665 }, -{ "Arabic_6", 0x1000666 }, -{ "Arabic_7", 0x1000667 }, -{ "Arabic_8", 0x1000668 }, -{ "Arabic_9", 0x1000669 }, { "Arabic_semicolon", 0x5BB }, { "Arabic_question_mark", 0x5BF }, { "Arabic_hamza", 0x5C1 }, { "Arabic_maddaonalef", 0x5C2 }, { "Arabic_hamzaonalef", 0x5C3 }, @@ -866,54 +855,10 @@ { "Arabic_fatha", 0x5EE }, { "Arabic_damma", 0x5EF }, { "Arabic_kasra", 0x5F0 }, { "Arabic_shadda", 0x5F1 }, { "Arabic_sukun", 0x5F2 }, -{ "Arabic_madda_above", 0x1000653 }, -{ "Arabic_hamza_above", 0x1000654 }, -{ "Arabic_hamza_below", 0x1000655 }, -{ "Arabic_jeh", 0x1000698 }, -{ "Arabic_veh", 0x10006A4 }, -{ "Arabic_keheh", 0x10006A9 }, -{ "Arabic_gaf", 0x10006AF }, -{ "Arabic_noon_ghunna", 0x10006BA }, -{ "Arabic_heh_doachashmee", 0x10006BE }, -{ "Farsi_yeh", 0x10006CC }, -{ "Arabic_farsi_yeh", 0x10006CC }, -{ "Arabic_yeh_baree", 0x10006D2 }, -{ "Arabic_heh_goal", 0x10006C1 }, -{ "Arabic_switch", 0xFF7E }, -{ "Cyrillic_GHE_bar", 0x1000492 }, -{ "Cyrillic_ghe_bar", 0x1000493 }, -{ "Cyrillic_ZHE_descender", 0x1000496 }, -{ "Cyrillic_zhe_descender", 0x1000497 }, -{ "Cyrillic_KA_descender", 0x100049A }, -{ "Cyrillic_ka_descender", 0x100049B }, -{ "Cyrillic_KA_vertstroke", 0x100049C }, -{ "Cyrillic_ka_vertstroke", 0x100049D }, -{ "Cyrillic_EN_descender", 0x10004A2 }, -{ "Cyrillic_en_descender", 0x10004A3 }, -{ "Cyrillic_U_straight", 0x10004AE }, -{ "Cyrillic_u_straight", 0x10004AF }, -{ "Cyrillic_U_straight_bar", 0x10004B0 }, -{ "Cyrillic_u_straight_bar", 0x10004B1 }, -{ "Cyrillic_HA_descender", 0x10004B2 }, -{ "Cyrillic_ha_descender", 0x10004B3 }, -{ "Cyrillic_CHE_descender", 0x10004B6 }, -{ "Cyrillic_che_descender", 0x10004B7 }, -{ "Cyrillic_CHE_vertstroke", 0x10004B8 }, -{ "Cyrillic_che_vertstroke", 0x10004B9 }, -{ "Cyrillic_SHHA", 0x10004BA }, -{ "Cyrillic_shha", 0x10004BB }, -{ "Cyrillic_SCHWA", 0x10004D8 }, -{ "Cyrillic_schwa", 0x10004D9 }, -{ "Cyrillic_I_macron", 0x10004E2 }, -{ "Cyrillic_i_macron", 0x10004E3 }, -{ "Cyrillic_O_bar", 0x10004E8 }, -{ "Cyrillic_o_bar", 0x10004E9 }, -{ "Cyrillic_U_macron", 0x10004EE }, -{ "Cyrillic_u_macron", 0x10004EF }, { "Serbian_dje", 0x6A1 }, { "Macedonia_gje", 0x6A2 }, { "Cyrillic_io", 0x6A3 }, { "Ukrainian_ie", 0x6A4 }, #ifndef TK_NO_DEPRECATED @@ -1052,11 +997,13 @@ { "Greek_ALPHAaccent", 0x7A1 }, { "Greek_EPSILONaccent", 0x7A2 }, { "Greek_ETAaccent", 0x7A3 }, { "Greek_IOTAaccent", 0x7A4 }, { "Greek_IOTAdieresis", 0x7A5 }, +#ifndef TK_NO_DEPRECATED { "Greek_IOTAdiaeresis", 0x7A5 }, +#endif { "Greek_IOTAaccentdiaeresis", 0x7A6 }, { "Greek_OMICRONaccent", 0x7A7 }, { "Greek_UPSILONaccent", 0x7A8 }, { "Greek_UPSILONdieresis", 0x7A9 }, { "Greek_UPSILONaccentdieresis", 0x7AA }, @@ -1123,11 +1070,10 @@ { "Greek_upsilon", 0x7F5 }, { "Greek_phi", 0x7F6 }, { "Greek_chi", 0x7F7 }, { "Greek_psi", 0x7F8 }, { "Greek_omega", 0x7F9 }, -{ "Greek_switch", 0xFF7E }, { "leftradical", 0x8A1 }, { "topleftradical", 0x8A2 }, { "horizconnector", 0x8A3 }, { "topintegral", 0x8A4 }, { "botintegral", 0x8A5 }, @@ -1361,11 +1307,10 @@ { "hebrew_shin", 0xCF9 }, { "hebrew_taw", 0xCFA }, #ifndef TK_NO_DEPRECATED { "hebrew_taf", 0xCFA }, #endif -{ "Hebrew_switch", 0xFF7E }, { "Thai_kokai", 0xDA1 }, { "Thai_khokhai", 0xDA2 }, { "Thai_khokhuat", 0xDA3 }, { "Thai_khokhwai", 0xDA4 }, { "Thai_khokhon", 0xDA5 }, @@ -1446,26 +1391,10 @@ { "Thai_lekha", 0xDF5 }, { "Thai_lekhok", 0xDF6 }, { "Thai_lekchet", 0xDF7 }, { "Thai_lekpaet", 0xDF8 }, { "Thai_lekkao", 0xDF9 }, -{ "Hangul", 0xFF31 }, -{ "Hangul_Start", 0xFF32 }, -{ "Hangul_End", 0xFF33 }, -{ "Hangul_Hanja", 0xFF34 }, -{ "Hangul_Jamo", 0xFF35 }, -{ "Hangul_Romaja", 0xFF36 }, -{ "Hangul_Codeinput", 0xFF37 }, -{ "Hangul_Jeonja", 0xFF38 }, -{ "Hangul_Banja", 0xFF39 }, -{ "Hangul_PreHanja", 0xFF3A }, -{ "Hangul_PostHanja", 0xFF3B }, -{ "Hangul_SingleCandidate", 0xFF3C }, -{ "Hangul_MultipleCandidate", 0xFF3D }, -{ "Hangul_PreviousCandidate", 0xFF3E }, -{ "Hangul_Special", 0xFF3F }, -{ "Hangul_switch", 0xFF7E }, { "Hangul_Kiyeog", 0xEA1 }, { "Hangul_SsangKiyeog", 0xEA2 }, { "Hangul_KiyeogSios", 0xEA3 }, { "Hangul_Nieun", 0xEA4 }, { "Hangul_NieunJieuj", 0xEA5 }, @@ -1553,640 +1482,10 @@ { "Hangul_AraeAE", 0xEF7 }, { "Hangul_J_PanSios", 0xEF8 }, { "Hangul_J_KkogjiDalrinIeung", 0xEF9 }, { "Hangul_J_YeorinHieuh", 0xEFA }, { "Korean_Won", 0xEFF }, -{ "Armenian_ligature_ew", 0x1000587 }, -{ "Armenian_full_stop", 0x1000589 }, -{ "Armenian_verjaket", 0x1000589 }, -{ "Armenian_separation_mark", 0x100055D }, -{ "Armenian_but", 0x100055D }, -{ "Armenian_hyphen", 0x100058A }, -{ "Armenian_yentamna", 0x100058A }, -{ "Armenian_exclam", 0x100055C }, -{ "Armenian_amanak", 0x100055C }, -{ "Armenian_accent", 0x100055B }, -{ "Armenian_shesht", 0x100055B }, -{ "Armenian_question", 0x100055E }, -{ "Armenian_paruyk", 0x100055E }, -{ "Armenian_AYB", 0x1000531 }, -{ "Armenian_ayb", 0x1000561 }, -{ "Armenian_BEN", 0x1000532 }, -{ "Armenian_ben", 0x1000562 }, -{ "Armenian_GIM", 0x1000533 }, -{ "Armenian_gim", 0x1000563 }, -{ "Armenian_DA", 0x1000534 }, -{ "Armenian_da", 0x1000564 }, -{ "Armenian_YECH", 0x1000535 }, -{ "Armenian_yech", 0x1000565 }, -{ "Armenian_ZA", 0x1000536 }, -{ "Armenian_za", 0x1000566 }, -{ "Armenian_E", 0x1000537 }, -{ "Armenian_e", 0x1000567 }, -{ "Armenian_AT", 0x1000538 }, -{ "Armenian_at", 0x1000568 }, -{ "Armenian_TO", 0x1000539 }, -{ "Armenian_to", 0x1000569 }, -{ "Armenian_ZHE", 0x100053A }, -{ "Armenian_zhe", 0x100056A }, -{ "Armenian_INI", 0x100053B }, -{ "Armenian_ini", 0x100056B }, -{ "Armenian_LYUN", 0x100053C }, -{ "Armenian_lyun", 0x100056C }, -{ "Armenian_KHE", 0x100053D }, -{ "Armenian_khe", 0x100056D }, -{ "Armenian_TSA", 0x100053E }, -{ "Armenian_tsa", 0x100056E }, -{ "Armenian_KEN", 0x100053F }, -{ "Armenian_ken", 0x100056F }, -{ "Armenian_HO", 0x1000540 }, -{ "Armenian_ho", 0x1000570 }, -{ "Armenian_DZA", 0x1000541 }, -{ "Armenian_dza", 0x1000571 }, -{ "Armenian_GHAT", 0x1000542 }, -{ "Armenian_ghat", 0x1000572 }, -{ "Armenian_TCHE", 0x1000543 }, -{ "Armenian_tche", 0x1000573 }, -{ "Armenian_MEN", 0x1000544 }, -{ "Armenian_men", 0x1000574 }, -{ "Armenian_HI", 0x1000545 }, -{ "Armenian_hi", 0x1000575 }, -{ "Armenian_NU", 0x1000546 }, -{ "Armenian_nu", 0x1000576 }, -{ "Armenian_SHA", 0x1000547 }, -{ "Armenian_sha", 0x1000577 }, -{ "Armenian_VO", 0x1000548 }, -{ "Armenian_vo", 0x1000578 }, -{ "Armenian_CHA", 0x1000549 }, -{ "Armenian_cha", 0x1000579 }, -{ "Armenian_PE", 0x100054A }, -{ "Armenian_pe", 0x100057A }, -{ "Armenian_JE", 0x100054B }, -{ "Armenian_je", 0x100057B }, -{ "Armenian_RA", 0x100054C }, -{ "Armenian_ra", 0x100057C }, -{ "Armenian_SE", 0x100054D }, -{ "Armenian_se", 0x100057D }, -{ "Armenian_VEV", 0x100054E }, -{ "Armenian_vev", 0x100057E }, -{ "Armenian_TYUN", 0x100054F }, -{ "Armenian_tyun", 0x100057F }, -{ "Armenian_RE", 0x1000550 }, -{ "Armenian_re", 0x1000580 }, -{ "Armenian_TSO", 0x1000551 }, -{ "Armenian_tso", 0x1000581 }, -{ "Armenian_VYUN", 0x1000552 }, -{ "Armenian_vyun", 0x1000582 }, -{ "Armenian_PYUR", 0x1000553 }, -{ "Armenian_pyur", 0x1000583 }, -{ "Armenian_KE", 0x1000554 }, -{ "Armenian_ke", 0x1000584 }, -{ "Armenian_O", 0x1000555 }, -{ "Armenian_o", 0x1000585 }, -{ "Armenian_FE", 0x1000556 }, -{ "Armenian_fe", 0x1000586 }, -{ "Armenian_apostrophe", 0x100055A }, -{ "Georgian_an", 0x10010D0 }, -{ "Georgian_ban", 0x10010D1 }, -{ "Georgian_gan", 0x10010D2 }, -{ "Georgian_don", 0x10010D3 }, -{ "Georgian_en", 0x10010D4 }, -{ "Georgian_vin", 0x10010D5 }, -{ "Georgian_zen", 0x10010D6 }, -{ "Georgian_tan", 0x10010D7 }, -{ "Georgian_in", 0x10010D8 }, -{ "Georgian_kan", 0x10010D9 }, -{ "Georgian_las", 0x10010DA }, -{ "Georgian_man", 0x10010DB }, -{ "Georgian_nar", 0x10010DC }, -{ "Georgian_on", 0x10010DD }, -{ "Georgian_par", 0x10010DE }, -{ "Georgian_zhar", 0x10010DF }, -{ "Georgian_rae", 0x10010E0 }, -{ "Georgian_san", 0x10010E1 }, -{ "Georgian_tar", 0x10010E2 }, -{ "Georgian_un", 0x10010E3 }, -{ "Georgian_phar", 0x10010E4 }, -{ "Georgian_khar", 0x10010E5 }, -{ "Georgian_ghan", 0x10010E6 }, -{ "Georgian_qar", 0x10010E7 }, -{ "Georgian_shin", 0x10010E8 }, -{ "Georgian_chin", 0x10010E9 }, -{ "Georgian_can", 0x10010EA }, -{ "Georgian_jil", 0x10010EB }, -{ "Georgian_cil", 0x10010EC }, -{ "Georgian_char", 0x10010ED }, -{ "Georgian_xan", 0x10010EE }, -{ "Georgian_jhan", 0x10010EF }, -{ "Georgian_hae", 0x10010F0 }, -{ "Georgian_he", 0x10010F1 }, -{ "Georgian_hie", 0x10010F2 }, -{ "Georgian_we", 0x10010F3 }, -{ "Georgian_har", 0x10010F4 }, -{ "Georgian_hoe", 0x10010F5 }, -{ "Georgian_fi", 0x10010F6 }, -{ "Xabovedot", 0x1001E8A }, -{ "Ibreve", 0x100012C }, -{ "Zstroke", 0x10001B5 }, -{ "Gcaron", 0x10001E6 }, -{ "Ocaron", 0x10001D1 }, -{ "Obarred", 0x100019F }, -{ "xabovedot", 0x1001E8B }, -{ "ibreve", 0x100012D }, -{ "zstroke", 0x10001B6 }, -{ "gcaron", 0x10001E7 }, -{ "ocaron", 0x10001D2 }, -{ "obarred", 0x1000275 }, -{ "SCHWA", 0x100018F }, -{ "schwa", 0x1000259 }, -{ "EZH", 0x10001B7 }, -{ "ezh", 0x1000292 }, -{ "Lbelowdot", 0x1001E36 }, -{ "lbelowdot", 0x1001E37 }, -{ "Abelowdot", 0x1001EA0 }, -{ "abelowdot", 0x1001EA1 }, -{ "Ahook", 0x1001EA2 }, -{ "ahook", 0x1001EA3 }, -{ "Acircumflexacute", 0x1001EA4 }, -{ "acircumflexacute", 0x1001EA5 }, -{ "Acircumflexgrave", 0x1001EA6 }, -{ "acircumflexgrave", 0x1001EA7 }, -{ "Acircumflexhook", 0x1001EA8 }, -{ "acircumflexhook", 0x1001EA9 }, -{ "Acircumflextilde", 0x1001EAA }, -{ "acircumflextilde", 0x1001EAB }, -{ "Acircumflexbelowdot", 0x1001EAC }, -{ "acircumflexbelowdot", 0x1001EAD }, -{ "Abreveacute", 0x1001EAE }, -{ "abreveacute", 0x1001EAF }, -{ "Abrevegrave", 0x1001EB0 }, -{ "abrevegrave", 0x1001EB1 }, -{ "Abrevehook", 0x1001EB2 }, -{ "abrevehook", 0x1001EB3 }, -{ "Abrevetilde", 0x1001EB4 }, -{ "abrevetilde", 0x1001EB5 }, -{ "Abrevebelowdot", 0x1001EB6 }, -{ "abrevebelowdot", 0x1001EB7 }, -{ "Ebelowdot", 0x1001EB8 }, -{ "ebelowdot", 0x1001EB9 }, -{ "Ehook", 0x1001EBA }, -{ "ehook", 0x1001EBB }, -{ "Etilde", 0x1001EBC }, -{ "etilde", 0x1001EBD }, -{ "Ecircumflexacute", 0x1001EBE }, -{ "ecircumflexacute", 0x1001EBF }, -{ "Ecircumflexgrave", 0x1001EC0 }, -{ "ecircumflexgrave", 0x1001EC1 }, -{ "Ecircumflexhook", 0x1001EC2 }, -{ "ecircumflexhook", 0x1001EC3 }, -{ "Ecircumflextilde", 0x1001EC4 }, -{ "ecircumflextilde", 0x1001EC5 }, -{ "Ecircumflexbelowdot", 0x1001EC6 }, -{ "ecircumflexbelowdot", 0x1001EC7 }, -{ "Ihook", 0x1001EC8 }, -{ "ihook", 0x1001EC9 }, -{ "Ibelowdot", 0x1001ECA }, -{ "ibelowdot", 0x1001ECB }, -{ "Obelowdot", 0x1001ECC }, -{ "obelowdot", 0x1001ECD }, -{ "Ohook", 0x1001ECE }, -{ "ohook", 0x1001ECF }, -{ "Ocircumflexacute", 0x1001ED0 }, -{ "ocircumflexacute", 0x1001ED1 }, -{ "Ocircumflexgrave", 0x1001ED2 }, -{ "ocircumflexgrave", 0x1001ED3 }, -{ "Ocircumflexhook", 0x1001ED4 }, -{ "ocircumflexhook", 0x1001ED5 }, -{ "Ocircumflextilde", 0x1001ED6 }, -{ "ocircumflextilde", 0x1001ED7 }, -{ "Ocircumflexbelowdot", 0x1001ED8 }, -{ "ocircumflexbelowdot", 0x1001ED9 }, -{ "Ohornacute", 0x1001EDA }, -{ "ohornacute", 0x1001EDB }, -{ "Ohorngrave", 0x1001EDC }, -{ "ohorngrave", 0x1001EDD }, -{ "Ohornhook", 0x1001EDE }, -{ "ohornhook", 0x1001EDF }, -{ "Ohorntilde", 0x1001EE0 }, -{ "ohorntilde", 0x1001EE1 }, -{ "Ohornbelowdot", 0x1001EE2 }, -{ "ohornbelowdot", 0x1001EE3 }, -{ "Ubelowdot", 0x1001EE4 }, -{ "ubelowdot", 0x1001EE5 }, -{ "Uhook", 0x1001EE6 }, -{ "uhook", 0x1001EE7 }, -{ "Uhornacute", 0x1001EE8 }, -{ "uhornacute", 0x1001EE9 }, -{ "Uhorngrave", 0x1001EEA }, -{ "uhorngrave", 0x1001EEB }, -{ "Uhornhook", 0x1001EEC }, -{ "uhornhook", 0x1001EED }, -{ "Uhorntilde", 0x1001EEE }, -{ "uhorntilde", 0x1001EEF }, -{ "Uhornbelowdot", 0x1001EF0 }, -{ "uhornbelowdot", 0x1001EF1 }, -{ "Ybelowdot", 0x1001EF4 }, -{ "ybelowdot", 0x1001EF5 }, -{ "Yhook", 0x1001EF6 }, -{ "yhook", 0x1001EF7 }, -{ "Ytilde", 0x1001EF8 }, -{ "ytilde", 0x1001EF9 }, -{ "Ohorn", 0x10001A0 }, -{ "ohorn", 0x10001A1 }, -{ "Uhorn", 0x10001AF }, -{ "uhorn", 0x10001B0 }, -{ "EcuSign", 0x10020A0 }, -{ "ColonSign", 0x10020A1 }, -{ "CruzeiroSign", 0x10020A2 }, -{ "FFrancSign", 0x10020A3 }, -{ "LiraSign", 0x10020A4 }, -{ "MillSign", 0x10020A5 }, -{ "NairaSign", 0x10020A6 }, -{ "PesetaSign", 0x10020A7 }, -{ "RupeeSign", 0x10020A8 }, -{ "WonSign", 0x10020A9 }, -{ "NewSheqelSign", 0x10020AA }, -{ "DongSign", 0x10020AB }, -{ "EuroSign", 0x20AC }, -{ "zerosuperior", 0x1002070 }, -{ "foursuperior", 0x1002074 }, -{ "fivesuperior", 0x1002075 }, -{ "sixsuperior", 0x1002076 }, -{ "sevensuperior", 0x1002077 }, -{ "eightsuperior", 0x1002078 }, -{ "ninesuperior", 0x1002079 }, -{ "zerosubscript", 0x1002080 }, -{ "onesubscript", 0x1002081 }, -{ "twosubscript", 0x1002082 }, -{ "threesubscript", 0x1002083 }, -{ "foursubscript", 0x1002084 }, -{ "fivesubscript", 0x1002085 }, -{ "sixsubscript", 0x1002086 }, -{ "sevensubscript", 0x1002087 }, -{ "eightsubscript", 0x1002088 }, -{ "ninesubscript", 0x1002089 }, -{ "partdifferential", 0x1002202 }, -{ "emptyset", 0x1002205 }, -{ "elementof", 0x1002208 }, -{ "notelementof", 0x1002209 }, -{ "containsas", 0x100220B }, -{ "squareroot", 0x100221A }, -{ "cuberoot", 0x100221B }, -{ "fourthroot", 0x100221C }, -{ "dintegral", 0x100222C }, -{ "tintegral", 0x100222D }, -{ "because", 0x1002235 }, -{ "approxeq", 0x1002248 }, -{ "notapproxeq", 0x1002247 }, -{ "notidentical", 0x1002262 }, -{ "stricteq", 0x1002263 }, -{ "braille_dot_1", 0xFFF1 }, -{ "braille_dot_2", 0xFFF2 }, -{ "braille_dot_3", 0xFFF3 }, -{ "braille_dot_4", 0xFFF4 }, -{ "braille_dot_5", 0xFFF5 }, -{ "braille_dot_6", 0xFFF6 }, -{ "braille_dot_7", 0xFFF7 }, -{ "braille_dot_8", 0xFFF8 }, -{ "braille_dot_9", 0xFFF9 }, -{ "braille_dot_10", 0xFFFA }, -{ "braille_blank", 0x1002800 }, -{ "braille_dots_1", 0x1002801 }, -{ "braille_dots_2", 0x1002802 }, -{ "braille_dots_12", 0x1002803 }, -{ "braille_dots_3", 0x1002804 }, -{ "braille_dots_13", 0x1002805 }, -{ "braille_dots_23", 0x1002806 }, -{ "braille_dots_123", 0x1002807 }, -{ "braille_dots_4", 0x1002808 }, -{ "braille_dots_14", 0x1002809 }, -{ "braille_dots_24", 0x100280A }, -{ "braille_dots_124", 0x100280B }, -{ "braille_dots_34", 0x100280C }, -{ "braille_dots_134", 0x100280D }, -{ "braille_dots_234", 0x100280E }, -{ "braille_dots_1234", 0x100280F }, -{ "braille_dots_5", 0x1002810 }, -{ "braille_dots_15", 0x1002811 }, -{ "braille_dots_25", 0x1002812 }, -{ "braille_dots_125", 0x1002813 }, -{ "braille_dots_35", 0x1002814 }, -{ "braille_dots_135", 0x1002815 }, -{ "braille_dots_235", 0x1002816 }, -{ "braille_dots_1235", 0x1002817 }, -{ "braille_dots_45", 0x1002818 }, -{ "braille_dots_145", 0x1002819 }, -{ "braille_dots_245", 0x100281A }, -{ "braille_dots_1245", 0x100281B }, -{ "braille_dots_345", 0x100281C }, -{ "braille_dots_1345", 0x100281D }, -{ "braille_dots_2345", 0x100281E }, -{ "braille_dots_12345", 0x100281F }, -{ "braille_dots_6", 0x1002820 }, -{ "braille_dots_16", 0x1002821 }, -{ "braille_dots_26", 0x1002822 }, -{ "braille_dots_126", 0x1002823 }, -{ "braille_dots_36", 0x1002824 }, -{ "braille_dots_136", 0x1002825 }, -{ "braille_dots_236", 0x1002826 }, -{ "braille_dots_1236", 0x1002827 }, -{ "braille_dots_46", 0x1002828 }, -{ "braille_dots_146", 0x1002829 }, -{ "braille_dots_246", 0x100282A }, -{ "braille_dots_1246", 0x100282B }, -{ "braille_dots_346", 0x100282C }, -{ "braille_dots_1346", 0x100282D }, -{ "braille_dots_2346", 0x100282E }, -{ "braille_dots_12346", 0x100282F }, -{ "braille_dots_56", 0x1002830 }, -{ "braille_dots_156", 0x1002831 }, -{ "braille_dots_256", 0x1002832 }, -{ "braille_dots_1256", 0x1002833 }, -{ "braille_dots_356", 0x1002834 }, -{ "braille_dots_1356", 0x1002835 }, -{ "braille_dots_2356", 0x1002836 }, -{ "braille_dots_12356", 0x1002837 }, -{ "braille_dots_456", 0x1002838 }, -{ "braille_dots_1456", 0x1002839 }, -{ "braille_dots_2456", 0x100283A }, -{ "braille_dots_12456", 0x100283B }, -{ "braille_dots_3456", 0x100283C }, -{ "braille_dots_13456", 0x100283D }, -{ "braille_dots_23456", 0x100283E }, -{ "braille_dots_123456", 0x100283F }, -{ "braille_dots_7", 0x1002840 }, -{ "braille_dots_17", 0x1002841 }, -{ "braille_dots_27", 0x1002842 }, -{ "braille_dots_127", 0x1002843 }, -{ "braille_dots_37", 0x1002844 }, -{ "braille_dots_137", 0x1002845 }, -{ "braille_dots_237", 0x1002846 }, -{ "braille_dots_1237", 0x1002847 }, -{ "braille_dots_47", 0x1002848 }, -{ "braille_dots_147", 0x1002849 }, -{ "braille_dots_247", 0x100284A }, -{ "braille_dots_1247", 0x100284B }, -{ "braille_dots_347", 0x100284C }, -{ "braille_dots_1347", 0x100284D }, -{ "braille_dots_2347", 0x100284E }, -{ "braille_dots_12347", 0x100284F }, -{ "braille_dots_57", 0x1002850 }, -{ "braille_dots_157", 0x1002851 }, -{ "braille_dots_257", 0x1002852 }, -{ "braille_dots_1257", 0x1002853 }, -{ "braille_dots_357", 0x1002854 }, -{ "braille_dots_1357", 0x1002855 }, -{ "braille_dots_2357", 0x1002856 }, -{ "braille_dots_12357", 0x1002857 }, -{ "braille_dots_457", 0x1002858 }, -{ "braille_dots_1457", 0x1002859 }, -{ "braille_dots_2457", 0x100285A }, -{ "braille_dots_12457", 0x100285B }, -{ "braille_dots_3457", 0x100285C }, -{ "braille_dots_13457", 0x100285D }, -{ "braille_dots_23457", 0x100285E }, -{ "braille_dots_123457", 0x100285F }, -{ "braille_dots_67", 0x1002860 }, -{ "braille_dots_167", 0x1002861 }, -{ "braille_dots_267", 0x1002862 }, -{ "braille_dots_1267", 0x1002863 }, -{ "braille_dots_367", 0x1002864 }, -{ "braille_dots_1367", 0x1002865 }, -{ "braille_dots_2367", 0x1002866 }, -{ "braille_dots_12367", 0x1002867 }, -{ "braille_dots_467", 0x1002868 }, -{ "braille_dots_1467", 0x1002869 }, -{ "braille_dots_2467", 0x100286A }, -{ "braille_dots_12467", 0x100286B }, -{ "braille_dots_3467", 0x100286C }, -{ "braille_dots_13467", 0x100286D }, -{ "braille_dots_23467", 0x100286E }, -{ "braille_dots_123467", 0x100286F }, -{ "braille_dots_567", 0x1002870 }, -{ "braille_dots_1567", 0x1002871 }, -{ "braille_dots_2567", 0x1002872 }, -{ "braille_dots_12567", 0x1002873 }, -{ "braille_dots_3567", 0x1002874 }, -{ "braille_dots_13567", 0x1002875 }, -{ "braille_dots_23567", 0x1002876 }, -{ "braille_dots_123567", 0x1002877 }, -{ "braille_dots_4567", 0x1002878 }, -{ "braille_dots_14567", 0x1002879 }, -{ "braille_dots_24567", 0x100287A }, -{ "braille_dots_124567", 0x100287B }, -{ "braille_dots_34567", 0x100287C }, -{ "braille_dots_134567", 0x100287D }, -{ "braille_dots_234567", 0x100287E }, -{ "braille_dots_1234567", 0x100287F }, -{ "braille_dots_8", 0x1002880 }, -{ "braille_dots_18", 0x1002881 }, -{ "braille_dots_28", 0x1002882 }, -{ "braille_dots_128", 0x1002883 }, -{ "braille_dots_38", 0x1002884 }, -{ "braille_dots_138", 0x1002885 }, -{ "braille_dots_238", 0x1002886 }, -{ "braille_dots_1238", 0x1002887 }, -{ "braille_dots_48", 0x1002888 }, -{ "braille_dots_148", 0x1002889 }, -{ "braille_dots_248", 0x100288A }, -{ "braille_dots_1248", 0x100288B }, -{ "braille_dots_348", 0x100288C }, -{ "braille_dots_1348", 0x100288D }, -{ "braille_dots_2348", 0x100288E }, -{ "braille_dots_12348", 0x100288F }, -{ "braille_dots_58", 0x1002890 }, -{ "braille_dots_158", 0x1002891 }, -{ "braille_dots_258", 0x1002892 }, -{ "braille_dots_1258", 0x1002893 }, -{ "braille_dots_358", 0x1002894 }, -{ "braille_dots_1358", 0x1002895 }, -{ "braille_dots_2358", 0x1002896 }, -{ "braille_dots_12358", 0x1002897 }, -{ "braille_dots_458", 0x1002898 }, -{ "braille_dots_1458", 0x1002899 }, -{ "braille_dots_2458", 0x100289A }, -{ "braille_dots_12458", 0x100289B }, -{ "braille_dots_3458", 0x100289C }, -{ "braille_dots_13458", 0x100289D }, -{ "braille_dots_23458", 0x100289E }, -{ "braille_dots_123458", 0x100289F }, -{ "braille_dots_68", 0x10028A0 }, -{ "braille_dots_168", 0x10028A1 }, -{ "braille_dots_268", 0x10028A2 }, -{ "braille_dots_1268", 0x10028A3 }, -{ "braille_dots_368", 0x10028A4 }, -{ "braille_dots_1368", 0x10028A5 }, -{ "braille_dots_2368", 0x10028A6 }, -{ "braille_dots_12368", 0x10028A7 }, -{ "braille_dots_468", 0x10028A8 }, -{ "braille_dots_1468", 0x10028A9 }, -{ "braille_dots_2468", 0x10028AA }, -{ "braille_dots_12468", 0x10028AB }, -{ "braille_dots_3468", 0x10028AC }, -{ "braille_dots_13468", 0x10028AD }, -{ "braille_dots_23468", 0x10028AE }, -{ "braille_dots_123468", 0x10028AF }, -{ "braille_dots_568", 0x10028B0 }, -{ "braille_dots_1568", 0x10028B1 }, -{ "braille_dots_2568", 0x10028B2 }, -{ "braille_dots_12568", 0x10028B3 }, -{ "braille_dots_3568", 0x10028B4 }, -{ "braille_dots_13568", 0x10028B5 }, -{ "braille_dots_23568", 0x10028B6 }, -{ "braille_dots_123568", 0x10028B7 }, -{ "braille_dots_4568", 0x10028B8 }, -{ "braille_dots_14568", 0x10028B9 }, -{ "braille_dots_24568", 0x10028BA }, -{ "braille_dots_124568", 0x10028BB }, -{ "braille_dots_34568", 0x10028BC }, -{ "braille_dots_134568", 0x10028BD }, -{ "braille_dots_234568", 0x10028BE }, -{ "braille_dots_1234568", 0x10028BF }, -{ "braille_dots_78", 0x10028C0 }, -{ "braille_dots_178", 0x10028C1 }, -{ "braille_dots_278", 0x10028C2 }, -{ "braille_dots_1278", 0x10028C3 }, -{ "braille_dots_378", 0x10028C4 }, -{ "braille_dots_1378", 0x10028C5 }, -{ "braille_dots_2378", 0x10028C6 }, -{ "braille_dots_12378", 0x10028C7 }, -{ "braille_dots_478", 0x10028C8 }, -{ "braille_dots_1478", 0x10028C9 }, -{ "braille_dots_2478", 0x10028CA }, -{ "braille_dots_12478", 0x10028CB }, -{ "braille_dots_3478", 0x10028CC }, -{ "braille_dots_13478", 0x10028CD }, -{ "braille_dots_23478", 0x10028CE }, -{ "braille_dots_123478", 0x10028CF }, -{ "braille_dots_578", 0x10028D0 }, -{ "braille_dots_1578", 0x10028D1 }, -{ "braille_dots_2578", 0x10028D2 }, -{ "braille_dots_12578", 0x10028D3 }, -{ "braille_dots_3578", 0x10028D4 }, -{ "braille_dots_13578", 0x10028D5 }, -{ "braille_dots_23578", 0x10028D6 }, -{ "braille_dots_123578", 0x10028D7 }, -{ "braille_dots_4578", 0x10028D8 }, -{ "braille_dots_14578", 0x10028D9 }, -{ "braille_dots_24578", 0x10028DA }, -{ "braille_dots_124578", 0x10028DB }, -{ "braille_dots_34578", 0x10028DC }, -{ "braille_dots_134578", 0x10028DD }, -{ "braille_dots_234578", 0x10028DE }, -{ "braille_dots_1234578", 0x10028DF }, -{ "braille_dots_678", 0x10028E0 }, -{ "braille_dots_1678", 0x10028E1 }, -{ "braille_dots_2678", 0x10028E2 }, -{ "braille_dots_12678", 0x10028E3 }, -{ "braille_dots_3678", 0x10028E4 }, -{ "braille_dots_13678", 0x10028E5 }, -{ "braille_dots_23678", 0x10028E6 }, -{ "braille_dots_123678", 0x10028E7 }, -{ "braille_dots_4678", 0x10028E8 }, -{ "braille_dots_14678", 0x10028E9 }, -{ "braille_dots_24678", 0x10028EA }, -{ "braille_dots_124678", 0x10028EB }, -{ "braille_dots_34678", 0x10028EC }, -{ "braille_dots_134678", 0x10028ED }, -{ "braille_dots_234678", 0x10028EE }, -{ "braille_dots_1234678", 0x10028EF }, -{ "braille_dots_5678", 0x10028F0 }, -{ "braille_dots_15678", 0x10028F1 }, -{ "braille_dots_25678", 0x10028F2 }, -{ "braille_dots_125678", 0x10028F3 }, -{ "braille_dots_35678", 0x10028F4 }, -{ "braille_dots_135678", 0x10028F5 }, -{ "braille_dots_235678", 0x10028F6 }, -{ "braille_dots_1235678", 0x10028F7 }, -{ "braille_dots_45678", 0x10028F8 }, -{ "braille_dots_145678", 0x10028F9 }, -{ "braille_dots_245678", 0x10028FA }, -{ "braille_dots_1245678", 0x10028FB }, -{ "braille_dots_345678", 0x10028FC }, -{ "braille_dots_1345678", 0x10028FD }, -{ "braille_dots_2345678", 0x10028FE }, -{ "braille_dots_12345678", 0x10028FF }, -{ "Sinh_ng", 0x1000D82 }, -{ "Sinh_h2", 0x1000D83 }, -{ "Sinh_a", 0x1000D85 }, -{ "Sinh_aa", 0x1000D86 }, -{ "Sinh_ae", 0x1000D87 }, -{ "Sinh_aee", 0x1000D88 }, -{ "Sinh_i", 0x1000D89 }, -{ "Sinh_ii", 0x1000D8A }, -{ "Sinh_u", 0x1000D8B }, -{ "Sinh_uu", 0x1000D8C }, -{ "Sinh_ri", 0x1000D8D }, -{ "Sinh_rii", 0x1000D8E }, -{ "Sinh_lu", 0x1000D8F }, -{ "Sinh_luu", 0x1000D90 }, -{ "Sinh_e", 0x1000D91 }, -{ "Sinh_ee", 0x1000D92 }, -{ "Sinh_ai", 0x1000D93 }, -{ "Sinh_o", 0x1000D94 }, -{ "Sinh_oo", 0x1000D95 }, -{ "Sinh_au", 0x1000D96 }, -{ "Sinh_ka", 0x1000D9A }, -{ "Sinh_kha", 0x1000D9B }, -{ "Sinh_ga", 0x1000D9C }, -{ "Sinh_gha", 0x1000D9D }, -{ "Sinh_ng2", 0x1000D9E }, -{ "Sinh_nga", 0x1000D9F }, -{ "Sinh_ca", 0x1000DA0 }, -{ "Sinh_cha", 0x1000DA1 }, -{ "Sinh_ja", 0x1000DA2 }, -{ "Sinh_jha", 0x1000DA3 }, -{ "Sinh_nya", 0x1000DA4 }, -{ "Sinh_jnya", 0x1000DA5 }, -{ "Sinh_nja", 0x1000DA6 }, -{ "Sinh_tta", 0x1000DA7 }, -{ "Sinh_ttha", 0x1000DA8 }, -{ "Sinh_dda", 0x1000DA9 }, -{ "Sinh_ddha", 0x1000DAA }, -{ "Sinh_nna", 0x1000DAB }, -{ "Sinh_ndda", 0x1000DAC }, -{ "Sinh_tha", 0x1000DAD }, -{ "Sinh_thha", 0x1000DAE }, -{ "Sinh_dha", 0x1000DAF }, -{ "Sinh_dhha", 0x1000DB0 }, -{ "Sinh_na", 0x1000DB1 }, -{ "Sinh_ndha", 0x1000DB3 }, -{ "Sinh_pa", 0x1000DB4 }, -{ "Sinh_pha", 0x1000DB5 }, -{ "Sinh_ba", 0x1000DB6 }, -{ "Sinh_bha", 0x1000DB7 }, -{ "Sinh_ma", 0x1000DB8 }, -{ "Sinh_mba", 0x1000DB9 }, -{ "Sinh_ya", 0x1000DBA }, -{ "Sinh_ra", 0x1000DBB }, -{ "Sinh_la", 0x1000DBD }, -{ "Sinh_va", 0x1000DC0 }, -{ "Sinh_sha", 0x1000DC1 }, -{ "Sinh_ssha", 0x1000DC2 }, -{ "Sinh_sa", 0x1000DC3 }, -{ "Sinh_ha", 0x1000DC4 }, -{ "Sinh_lla", 0x1000DC5 }, -{ "Sinh_fa", 0x1000DC6 }, -{ "Sinh_al", 0x1000DCA }, -{ "Sinh_aa2", 0x1000DCF }, -{ "Sinh_ae2", 0x1000DD0 }, -{ "Sinh_aee2", 0x1000DD1 }, -{ "Sinh_i2", 0x1000DD2 }, -{ "Sinh_ii2", 0x1000DD3 }, -{ "Sinh_u2", 0x1000DD4 }, -{ "Sinh_uu2", 0x1000DD6 }, -{ "Sinh_ru2", 0x1000DD8 }, -{ "Sinh_e2", 0x1000DD9 }, -{ "Sinh_ee2", 0x1000DDA }, -{ "Sinh_ai2", 0x1000DDB }, -{ "Sinh_o2", 0x1000DDC }, -{ "Sinh_oo2", 0x1000DDD }, -{ "Sinh_au2", 0x1000DDE }, -{ "Sinh_lu2", 0x1000DDF }, -{ "Sinh_ruu2", 0x1000DF2 }, -{ "Sinh_luu2", 0x1000DF3 }, -{ "Sinh_kunddaliya", 0x1000DF4 }, { "XF86ModeLock", 0x1008FF01 }, { "XF86MonBrightnessUp", 0x1008FF02 }, { "XF86MonBrightnessDown", 0x1008FF03 }, { "XF86KbdLightOnOff", 0x1008FF04 }, { "XF86KbdBrightnessUp", 0x1008FF05 }, Index: generic/nanosvg.h ================================================================== --- generic/nanosvg.h +++ generic/nanosvg.h @@ -31,31 +31,32 @@ #ifdef __cplusplus extern "C" { #endif -// NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes. -// -// The library suits well for anything from rendering scalable icons in your editor application to prototyping a game. -// -// NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request! -// -// The shapes in the SVG images are transformed by the viewBox and converted to specified units. -// That is, you should get the same looking data as your designed in your favorite app. -// -// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose -// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters. -// -// The units passed to NanoVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'. -// DPI (dots-per-inch) controls how the unit conversion is done. -// -// If you don't know or care about the units stuff, "px" and 96 should get you going. +/* NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes. + * + * The library suits well for anything from rendering scalable icons in your editor application to prototyping a game. + * + * NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request! + * + * The shapes in the SVG images are transformed by the viewBox and converted to specified units. + * That is, you should get the same looking data as your designed in your favorite app. + * + * NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose + * to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters. + * + * The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'. + * DPI (dots-per-inch) controls how the unit conversion is done. + * + * If you don't know or care about the units stuff, "px" and 96 should get you going. + */ /* Example Usage: - // Load - NSVGImage* image; + // Load SVG + NSVGimage* image; image = nsvgParseFromFile("test.svg", "px", 96); printf("size: %f x %f\n", image->width, image->height); // Use... for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) { for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { @@ -83,12 +84,12 @@ #ifndef NANOSVG_free #define NANOSVG_free free #endif -// float emulation for MS VC6++ compiler -#if (_MSC_VER == 1200) +/* float emulation for MS VC6++ compiler */ +#if defined(_MSC_VER) && (_MSC_VER == 1200) #define tanf(a) (float)tan(a) #define cosf(a) (float)cos(a) #define sinf(a) (float)sin(a) #define sqrtf(a) (float)sqrt(a) #define fabsf(a) (float)fabs(a) @@ -96,12 +97,12 @@ #define atan2f(a,b) (float)atan2(a,b) #define ceilf(a) (float)ceil(a) #define fmodf(a,b) (float)fmod(a,b) #define floorf(a) (float)floor(a) #endif -// float emulation for MS VC8++ compiler -#if (_MSC_VER == 1400) +/* float emulation for MS VC8++ compiler */ +#if defined(_MSC_VER) && (_MSC_VER == 1400) #define fabsf(a) (float)fabs(a) #endif enum NSVGpaintType { NSVG_PAINT_NONE = 0, @@ -158,68 +159,68 @@ }; } NSVGpaint; typedef struct NSVGpath { - float* pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... - int npts; // Total number of bezier points. - char closed; // Flag indicating if shapes should be treated as closed. - float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. - struct NSVGpath* next; // Pointer to next path, or NULL if last element. + float* pts; /* Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... */ + int npts; /* Total number of bezier points. */ + char closed; /* Flag indicating if shapes should be treated as closed. */ + float bounds[4]; /* Tight bounding box of the shape [minx,miny,maxx,maxy]. */ + struct NSVGpath* next; /* Pointer to next path, or NULL if last element. */ } NSVGpath; typedef struct NSVGshape { - char id[64]; // Optional 'id' attr of the shape or its group - NSVGpaint fill; // Fill paint - NSVGpaint stroke; // Stroke paint - float opacity; // Opacity of the shape. - float strokeWidth; // Stroke width (scaled). - float strokeDashOffset; // Stroke dash offset (scaled). - float strokeDashArray[8]; // Stroke dash array (scaled). - char strokeDashCount; // Number of dash values in dash array. - char strokeLineJoin; // Stroke join type. - char strokeLineCap; // Stroke cap type. - float miterLimit; // Miter limit - char fillRule; // Fill rule, see NSVGfillRule. - unsigned char flags; // Logical or of NSVG_FLAGS_* flags - float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. - NSVGpath* paths; // Linked list of paths in the image. - struct NSVGshape* next; // Pointer to next shape, or NULL if last element. + char id[64]; /* Optional 'id' attr of the shape or its group */ + NSVGpaint fill; /* Fill paint */ + NSVGpaint stroke; /* Stroke paint */ + float opacity; /* Opacity of the shape. */ + float strokeWidth; /* Stroke width (scaled). */ + float strokeDashOffset; /* Stroke dash offset (scaled). */ + float strokeDashArray[8]; /* Stroke dash array (scaled). */ + char strokeDashCount; /* Number of dash values in dash array. */ + char strokeLineJoin; /* Stroke join type. */ + char strokeLineCap; /* Stroke cap type. */ + float miterLimit; /* Miter limit */ + char fillRule; /* Fill rule, see NSVGfillRule. */ + unsigned char flags; /* Logical or of NSVG_FLAGS_* flags */ + float bounds[4]; /* Tight bounding box of the shape [minx,miny,maxx,maxy]. */ + NSVGpath* paths; /* Linked list of paths in the image. */ + struct NSVGshape* next; /* Pointer to next shape, or NULL if last element. */ } NSVGshape; typedef struct NSVGimage { - float width; // Width of the image. - float height; // Height of the image. - NSVGshape* shapes; // Linked list of shapes in the image. + float width; /* Width of the image. */ + float height; /* Height of the image. */ + NSVGshape* shapes; /* Linked list of shapes in the image. */ } NSVGimage; -// Parses SVG file from a file, returns SVG image as paths. +/* Parses SVG file from a file, returns SVG image as paths. */ NANOSVG_SCOPE NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi); -// Parses SVG file from a null terminated string, returns SVG image as paths. -// Important note: changes the string. +/* Parses SVG file from a null terminated string, returns SVG image as paths. */ +/* Important note: changes the string. */ NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi); -// Deletes list of paths. +/* Deletes list of paths. */ NANOSVG_SCOPE void nsvgDelete(NSVGimage* image); #ifdef __cplusplus } #endif -#endif // NANOSVG_H +#endif /* NANOSVG_H */ #ifdef NANOSVG_IMPLEMENTATION #include #include #include #define NSVG_PI (3.14159265358979323846264338327f) -#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs. +#define NSVG_KAPPA90 (0.5522847493f) /* Length proportional to radius of a cubic bezier handle for 90deg arcs. */ #define NSVG_ALIGN_MIN 0 #define NSVG_ALIGN_MID 1 #define NSVG_ALIGN_MAX 2 #define NSVG_ALIGN_NONE 0 @@ -228,18 +229,18 @@ #define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0) #define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16)) #ifdef _MSC_VER - #pragma warning (disable: 4996) // Switch off security warnings - #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings + #pragma warning (disable: 4996) /* Switch off security warnings */ + #pragma warning (disable: 4100) /* Switch off unreferenced formal parameter warnings */ #ifdef __cplusplus #define NSVG_INLINE inline #else #define NSVG_INLINE #endif - #if !defined(strtoll) // old MSVC versions do not have strtoll() + #if !defined(strtoll) /* old MSVC versions do not have strtoll() */ #define strtoll _strtoi64 #endif #else #define NSVG_INLINE inline #endif @@ -253,30 +254,25 @@ static int nsvg__isdigit(char c) { return c >= '0' && c <= '9'; } -static int nsvg__isnum(char c) -{ - return strchr("0123456789+-.eE", c) != 0; -} - static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; } static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; } -// Simple XML parser +/* Simple XML parser */ #define NSVG_XML_TAG 1 #define NSVG_XML_CONTENT 2 #define NSVG_XML_MAX_ATTRIBS 256 static void nsvg__parseContent(char* s, void (*contentCb)(void* ud, const char* s), void* ud) { - // Trim start white spaces + /* Trim start white spaces */ while (*s && nsvg__isspace(*s)) s++; if (!*s) return; if (contentCb) (*contentCb)(ud, s); @@ -287,77 +283,77 @@ void (*endelCb)(void* ud, const char* el), void* ud) { const char* attr[NSVG_XML_MAX_ATTRIBS]; int nattr = 0; - char* name; + char* cbname; int start = 0; int end = 0; char quote; - // Skip white space after the '<' + /* Skip white space after the '<' */ while (*s && nsvg__isspace(*s)) s++; - // Check if the tag is end tag + /* Check if the tag is end tag */ if (*s == '/') { s++; end = 1; } else { start = 1; } - // Skip comments, data and preprocessor stuff. + /* Skip comments, data and preprocessor stuff. */ if (!*s || *s == '?' || *s == '!') return; - // Get tag name - name = s; + /* Get tag name */ + cbname = s; while (*s && !nsvg__isspace(*s)) s++; if (*s) { *s++ = '\0'; } - // Get attribs + /* Get attribs */ while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) { char* name = NULL; char* value = NULL; - // Skip white space before the attrib name + /* Skip white space before the attrib name */ while (*s && nsvg__isspace(*s)) s++; if (!*s) break; if (*s == '/') { end = 1; break; } name = s; - // Find end of the attrib name. + /* Find end of the attrib name. */ while (*s && !nsvg__isspace(*s) && *s != '=') s++; if (*s) { *s++ = '\0'; } - // Skip until the beginning of the value. + /* Skip until the beginning of the value. */ while (*s && *s != '\"' && *s != '\'') s++; if (!*s) break; quote = *s; s++; - // Store value and find the end of it. + /* Store value and find the end of it. */ value = s; while (*s && *s != quote) s++; if (*s) { *s++ = '\0'; } - // Store only well formed attributes + /* Store only well formed attributes */ if (name && value) { attr[nattr++] = name; attr[nattr++] = value; } } - // List terminator + /* List terminator */ attr[nattr++] = 0; attr[nattr++] = 0; - // Call callbacks. + /* Call callbacks. */ if (start && startelCb) - (*startelCb)(ud, name, attr); + (*startelCb)(ud, cbname, attr); if (end && endelCb) - (*endelCb)(ud, name); + (*endelCb)(ud, cbname); } NANOSVG_SCOPE int nsvg__parseXML(char* input, void (*startelCb)(void* ud, const char* el, const char** attr), @@ -368,17 +364,17 @@ char* s = input; char* mark = s; int state = NSVG_XML_CONTENT; while (*s) { if (*s == '<' && state == NSVG_XML_CONTENT) { - // Start of a tag + /* Start of a tag */ *s++ = '\0'; nsvg__parseContent(mark, contentCb, ud); mark = s; state = NSVG_XML_TAG; } else if (*s == '>' && state == NSVG_XML_TAG) { - // Start of a content or new tag. + /* Start of a content or new tag. */ *s++ = '\0'; nsvg__parseContent(mark, contentCb, ud); nsvg__parseElement(mark, startelCb, endelCb, ud); mark = s; state = NSVG_XML_CONTENT; @@ -618,22 +614,22 @@ float* v0 = &curve[0]; float* v1 = &curve[2]; float* v2 = &curve[4]; float* v3 = &curve[6]; - // Start the bounding box by end points + /* Start the bounding box by end points */ bounds[0] = nsvg__minf(v0[0], v3[0]); bounds[1] = nsvg__minf(v0[1], v3[1]); bounds[2] = nsvg__maxf(v0[0], v3[0]); bounds[3] = nsvg__maxf(v0[1], v3[1]); - // Bezier curve fits inside the convex hull of it's control points. - // If control points are inside the bounds, we're done. + /* Bezier curve fits inside the convex hull of it's control points. */ + /* If control points are inside the bounds, we're done. */ if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds)) return; - // Add bezier curve inflection points in X and Y. + /* Add bezier curve inflection points in X and Y. */ for (i = 0; i < 2; i++) { a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i]; b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i]; c = 3.0 * v1[i] - 3.0 * v0[i]; count = 0; @@ -671,11 +667,11 @@ p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage)); if (p->image == NULL) goto error; memset(p->image, 0, sizeof(NSVGimage)); - // Init style + /* Init style */ nsvg__xformIdentity(p->attr[0].xform); memset(p->attr[0].id, 0, sizeof p->attr[0].id); p->attr[0].fillColor = NSVG_RGB(0,0,0); p->attr[0].strokeColor = NSVG_RGB(0,0,0); p->attr[0].opacity = 1; @@ -793,13 +789,15 @@ } } static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y) { - nsvg__addPoint(p, cpx1, cpy1); - nsvg__addPoint(p, cpx2, cpy2); - nsvg__addPoint(p, x, y); + if (p->npts > 0) { + nsvg__addPoint(p, cpx1, cpy1); + nsvg__addPoint(p, cpx2, cpy2); + nsvg__addPoint(p, x, y); + } } static NSVGattrib* nsvg__getAttr(NSVGparser* p) { return &p->attr[p->attrHead]; @@ -855,21 +853,23 @@ case NSVG_UNITS_PC: return c.value / 6.0f * p->dpi; case NSVG_UNITS_MM: return c.value / 25.4f * p->dpi; case NSVG_UNITS_CM: return c.value / 2.54f * p->dpi; case NSVG_UNITS_IN: return c.value * p->dpi; case NSVG_UNITS_EM: return c.value * attr->fontSize; - case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; // x-height of Helvetica. + case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; /* x-height of Helvetica. */ case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length; default: return c.value; } return c.value; } static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id) { NSVGgradientData* grad = p->gradients; - while (grad) { + if (id == NULL || *id == '\0') + return NULL; + while (grad != NULL) { if (strcmp(grad->id, id) == 0) return grad; grad = grad->next; } return NULL; @@ -882,30 +882,37 @@ NSVGgradientData* ref = NULL; NSVGgradientStop* stops = NULL; NSVGgradient* grad; float ox, oy, sw, sh, sl; int nstops = 0; + int refIter; data = nsvg__findGradientData(p, id); if (data == NULL) return NULL; - // TODO: use ref to fill in all unset values too. + /* TODO: use ref to fill in all unset values too. */ ref = data; + refIter = 0; while (ref != NULL) { + NSVGgradientData* nextRef = NULL; if (stops == NULL && ref->stops != NULL) { stops = ref->stops; nstops = ref->nstops; break; } - ref = nsvg__findGradientData(p, ref->ref); + nextRef = nsvg__findGradientData(p, ref->ref); + if (nextRef == ref) break; /* prevent infite loops on malformed data */ + ref = nextRef; + refIter++; + if (refIter > 32) break; /* prevent infite loops on malformed data */ } if (stops == NULL) return NULL; grad = (NSVGgradient*)NANOSVG_malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1)); if (grad == NULL) return NULL; - // The shape width and height. + /* The shape width and height. */ if (data->units == NSVG_OBJECT_SPACE) { ox = localBounds[0]; oy = localBounds[1]; sw = localBounds[2] - localBounds[0]; sh = localBounds[3] - localBounds[1]; @@ -921,11 +928,11 @@ float x1, y1, x2, y2, dx, dy; x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw); y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh); x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw); y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh); - // Calculate transform aligned to the line + /* Calculate transform aligned to the line */ dx = x2 - x1; dy = y2 - y1; grad->xform[0] = dy; grad->xform[1] = -dx; grad->xform[2] = dx; grad->xform[3] = dy; grad->xform[4] = x1; grad->xform[5] = y1; @@ -934,11 +941,11 @@ cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw); cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh); fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw); fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh); r = nsvg__convertToPixels(p, data->radial.r, 0, sl); - // Calculate transform aligned to the circle + /* Calculate transform aligned to the circle */ grad->xform[0] = r; grad->xform[1] = 0; grad->xform[2] = 0; grad->xform[3] = r; grad->xform[4] = cx; grad->xform[5] = cy; grad->fx = fx / r; grad->fy = fy / r; @@ -1022,11 +1029,11 @@ shape->opacity = attr->opacity; shape->paths = p->plist; p->plist = NULL; - // Calculate shape bounds + /* Calculate shape bounds */ shape->bounds[0] = shape->paths->bounds[0]; shape->bounds[1] = shape->paths->bounds[1]; shape->bounds[2] = shape->paths->bounds[2]; shape->bounds[3] = shape->paths->bounds[3]; for (path = shape->paths->next; path != NULL; path = path->next) { @@ -1034,11 +1041,11 @@ shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]); shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]); shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]); } - // Set fill + /* Set fill */ if (attr->hasFill == 0) { shape->fill.type = NSVG_PAINT_NONE; } else if (attr->hasFill == 1) { shape->fill.type = NSVG_PAINT_COLOR; shape->fill.color = attr->fillColor; @@ -1051,11 +1058,11 @@ if (shape->fill.gradient == NULL) { shape->fill.type = NSVG_PAINT_NONE; } } - // Set stroke + /* Set stroke */ if (attr->hasStroke == 0) { shape->stroke.type = NSVG_PAINT_NONE; } else if (attr->hasStroke == 1) { shape->stroke.type = NSVG_PAINT_COLOR; shape->stroke.color = attr->strokeColor; @@ -1067,14 +1074,14 @@ shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type); if (shape->stroke.gradient == NULL) shape->stroke.type = NSVG_PAINT_NONE; } - // Set flags + /* Set flags */ shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00); - // Add to tail + /* Add to tail */ if (p->image->shapes == NULL) p->image->shapes = shape; else p->shapesTail->next = shape; p->shapesTail = shape; @@ -1096,10 +1103,14 @@ if (p->npts < 4) return; if (closed) nsvg__lineTo(p, p->pts[0], p->pts[1]); + + /* Expect 1 + N*3 points (N = number of cubic bezier segments). */ + if ((p->npts % 3) != 1) + return; path = (NSVGpath*)NANOSVG_malloc(sizeof(NSVGpath)); if (path == NULL) goto error; memset(path, 0, sizeof(NSVGpath)); @@ -1106,15 +1117,15 @@ path->pts = (float*)NANOSVG_malloc(p->npts*2*sizeof(float)); if (path->pts == NULL) goto error; path->closed = closed; path->npts = p->npts; - // Transform path. + /* Transform path. */ for (i = 0; i < p->npts; ++i) nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform); - // Find bounds + /* Find bounds */ for (i = 0; i < path->npts-1; i += 3) { curve = &path->pts[i*2]; nsvg__curveBounds(bounds, curve); if (i == 0) { path->bounds[0] = bounds[0]; @@ -1139,35 +1150,35 @@ if (path->pts != NULL) NANOSVG_free(path->pts); NANOSVG_free(path); } } -// We roll our own string to float because the std library one uses locale and messes things up. +/* We roll our own string to float because the std library one uses locale and messes things up. */ static double nsvg__atof(const char* s) { char* cur = (char*)s; char* end = NULL; double res = 0.0, sign = 1.0; -#if (_MSC_VER == 1200) +#if defined(_MSC_VER) && (_MSC_VER == 1200) __int64 intPart = 0, fracPart = 0; #else long long intPart = 0, fracPart = 0; #endif char hasIntPart = 0, hasFracPart = 0; - // Parse optional sign + /* Parse optional sign */ if (*cur == '+') { cur++; } else if (*cur == '-') { sign = -1; cur++; } - // Parse integer part + /* Parse integer part */ if (nsvg__isdigit(*cur)) { - // Parse digit sequence -#if (_MSC_VER == 1200) + /* Parse digit sequence */ +#if defined(_MSC_VER) && (_MSC_VER == 1200) intPart = strtol(cur, &end, 10); #else intPart = strtoll(cur, &end, 10); #endif if (cur != end) { @@ -1175,16 +1186,16 @@ hasIntPart = 1; cur = end; } } - // Parse fractional part. + /* Parse fractional part. */ if (*cur == '.') { - cur++; // Skip '.' + cur++; /* Skip '.' */ if (nsvg__isdigit(*cur)) { - // Parse digit sequence -#if (_MSC_VER == 1200) + /* Parse digit sequence */ +#if defined(_MSC_VER) && (_MSC_VER == 1200) fracPart = strtol(cur, &end, 10); #else fracPart = strtoll(cur, &end, 10); #endif if (cur != end) { @@ -1193,19 +1204,19 @@ cur = end; } } } - // A valid number should have integer or fractional part. + /* A valid number should have integer or fractional part. */ if (!hasIntPart && !hasFracPart) return 0.0; - // Parse optional exponent + /* Parse optional exponent */ if (*cur == 'e' || *cur == 'E') { int expPart = 0; - cur++; // skip 'E' - expPart = strtol(cur, &end, 10); // Parse digit sequence with sign + cur++; /* skip 'E' */ + expPart = strtol(cur, &end, 10); /* Parse digit sequence with sign */ if (cur != end) { res *= pow(10.0, (double)expPart); } } @@ -1216,31 +1227,31 @@ static const char* nsvg__parseNumber(const char* s, char* it, const int size) { const int last = size-1; int i = 0; - // sign + /* sign */ if (*s == '-' || *s == '+') { if (i < last) it[i++] = *s; s++; } - // integer part + /* integer part */ while (*s && nsvg__isdigit(*s)) { if (i < last) it[i++] = *s; s++; } if (*s == '.') { - // decimal point + /* decimal point */ if (i < last) it[i++] = *s; s++; - // fraction part + /* fraction part */ while (*s && nsvg__isdigit(*s)) { if (i < last) it[i++] = *s; s++; } } - // exponent + /* exponent */ if (*s == 'e' || *s == 'E') { if (i < last) it[i++] = *s; s++; if (*s == '-' || *s == '+') { if (i < last) it[i++] = *s; @@ -1257,17 +1268,17 @@ } static const char* nsvg__getNextPathItem(const char* s, char* it) { it[0] = '\0'; - // Skip white spaces and commas + /* Skip white spaces and commas */ while (*s && (nsvg__isspace(*s) || *s == ',')) s++; if (!*s) return s; if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) { s = nsvg__parseNumber(s, it, 64); } else { - // Parse command + /* Parse command */ it[0] = *s++; it[1] = '\0'; return s; } @@ -1276,12 +1287,12 @@ static unsigned int nsvg__parseColorHex(const char* str) { unsigned int c = 0, r = 0, g = 0, b = 0; int n = 0; - str++; // skip # - // Calculate number of characters. + str++; /* skip # */ + /* Calculate number of characters. */ while(str[n] && !nsvg__isspace(str[n])) n++; if (n == 6) { sscanf(str, "%x", &c); } else if (n == 3) { @@ -1528,10 +1539,19 @@ return NSVG_UNITS_EM; else if (units[0] == 'e' && units[1] == 'x') return NSVG_UNITS_EX; return NSVG_UNITS_USER; } + +static int nsvg__isCoordinate(const char* s) +{ + /* optional sign */ + if (*s == '-' || *s == '+') + s++; + /* must have at least one digit, or start by a dot */ + return (nsvg__isdigit(*s) || *s == '.'); +} static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str) { NSVGcoordinate coord = {0, NSVG_UNITS_USER}; char units[32]=""; @@ -1668,38 +1688,45 @@ } static void nsvg__parseTransform(float* xform, const char* str) { float t[6]; + int len; nsvg__xformIdentity(xform); while (*str) { if (strncmp(str, "matrix", 6) == 0) - str += nsvg__parseMatrix(t, str); + len = nsvg__parseMatrix(t, str); else if (strncmp(str, "translate", 9) == 0) - str += nsvg__parseTranslate(t, str); + len = nsvg__parseTranslate(t, str); else if (strncmp(str, "scale", 5) == 0) - str += nsvg__parseScale(t, str); + len = nsvg__parseScale(t, str); else if (strncmp(str, "rotate", 6) == 0) - str += nsvg__parseRotate(t, str); + len = nsvg__parseRotate(t, str); else if (strncmp(str, "skewX", 5) == 0) - str += nsvg__parseSkewX(t, str); + len = nsvg__parseSkewX(t, str); else if (strncmp(str, "skewY", 5) == 0) - str += nsvg__parseSkewY(t, str); + len = nsvg__parseSkewY(t, str); else{ ++str; continue; } + if (len != 0) { + str += len; + } else { + ++str; + continue; + } nsvg__xformPremultiply(xform, t); } } static void nsvg__parseUrl(char* id, const char* str) { int i = 0; - str += 4; // "url("; + str += 4; /* "url("; */ if (*str == '#') str++; while (i < 63 && *str != ')') { id[i] = *str++; i++; @@ -1713,11 +1740,11 @@ return NSVG_CAP_BUTT; else if (strcmp(str, "round") == 0) return NSVG_CAP_ROUND; else if (strcmp(str, "square") == 0) return NSVG_CAP_SQUARE; - // TODO: handle inherit. + /* TODO: handle inherit. */ return NSVG_CAP_BUTT; } static char nsvg__parseLineJoin(const char* str) { @@ -1725,31 +1752,31 @@ return NSVG_JOIN_MITER; else if (strcmp(str, "round") == 0) return NSVG_JOIN_ROUND; else if (strcmp(str, "bevel") == 0) return NSVG_JOIN_BEVEL; - // TODO: handle inherit. + /* TODO: handle inherit. */ return NSVG_JOIN_MITER; } static char nsvg__parseFillRule(const char* str) { if (strcmp(str, "nonzero") == 0) return NSVG_FILLRULE_NONZERO; else if (strcmp(str, "evenodd") == 0) return NSVG_FILLRULE_EVENODD; - // TODO: handle inherit. + /* TODO: handle inherit. */ return NSVG_FILLRULE_NONZERO; } static const char* nsvg__getNextDashItem(const char* s, char* it) { int n = 0; it[0] = '\0'; - // Skip white spaces and commas + /* Skip white spaces and commas */ while (*s && (nsvg__isspace(*s) || *s == ',')) s++; - // Advance until whitespace, comma or end. + /* Advance until whitespace, comma or end. */ while (*s && (!nsvg__isspace(*s) && *s != ',')) { if (n < 63) it[n++] = *s; s++; } @@ -1761,15 +1788,15 @@ { char item[64]; int count = 0, i; float sum = 0.0f; - // Handle "none" + /* Handle "none" */ if (str[0] == 'n') return 0; - // Parse dashes + /* Parse dashes */ while (*str) { str = nsvg__getNextDashItem(str, item); if (!*item) break; if (count < NSVG_MAX_DASHES) strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p))); @@ -1794,11 +1821,11 @@ if (strcmp(name, "style") == 0) { nsvg__parseStyle(p, value); } else if (strcmp(name, "display") == 0) { if (strcmp(value, "none") == 0) attr->visible &= ~NSVG_VIS_DISPLAY; - // Don't reset ->visible on display:inline, one display:none hides the whole subtree + /* Don't reset ->visible on display:inline, one display:none hides the whole subtree */ } else if (strcmp(name, "visibility") == 0) { if (strcmp(value, "hidden") == 0) { attr->visible &= ~NSVG_VIS_VISIBLE; } else if (strcmp(value, "visible") == 0) { @@ -1886,11 +1913,11 @@ str = start; while (str < end && *str != ':') ++str; val = str; - // Right Trim + /* Right Trim */ while (str > start && (*str == ':' || nsvg__isspace(*str))) --str; ++str; n = (int)(str - start); if (n > 511) n = 511; @@ -1911,17 +1938,17 @@ { const char* start; const char* end; while (*str) { - // Left Trim + /* Left Trim */ while(*str && nsvg__isspace(*str)) ++str; start = str; while(*str && *str != ';') ++str; end = str; - // Right Trim + /* Right Trim */ while (end > start && (*end == ';' || nsvg__isspace(*end))) --end; ++end; nsvg__parseNameValue(p, start, end); if (*str) ++str; @@ -1964,12 +1991,15 @@ case 'C': return 6; case 'a': case 'A': return 7; + case 'z': + case 'Z': + return 0; } - return 0; + return -1; } static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) { if (rel) { @@ -2089,11 +2119,11 @@ cy = args[1]; x2 = args[2]; y2 = args[3]; } - // Convert to cubic bezier + /* Convert to cubic bezier */ cx1 = x1 + 2.0f/3.0f*(cx - x1); cy1 = y1 + 2.0f/3.0f*(cy - y1); cx2 = x2 + 2.0f/3.0f*(cx - x2); cy2 = y2 + 2.0f/3.0f*(cy - y2); @@ -2122,11 +2152,11 @@ } cx = 2*x1 - *cpx2; cy = 2*y1 - *cpy2; - // Convert to cubix bezier + /* Convert to cubix bezier */ cx1 = x1 + 2.0f/3.0f*(cx - x1); cy1 = y1 + 2.0f/3.0f*(cy - y1); cx2 = x2 + 2.0f/3.0f*(cx - x2); cy2 = y2 + 2.0f/3.0f*(cy - y2); @@ -2154,11 +2184,11 @@ return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r); } static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) { - // Ported from canvg (https://code.google.com/p/canvg/) + /* Ported from canvg (https://code.google.com/p/canvg/) */ float rx, ry, rotx; float x1, y1, x2, y2, cx, cy, dx, dy, d; float x1p, y1p, cxp, cyp, s, sa, sb; float ux, uy, vx, vy, a1, da; float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6]; @@ -2165,18 +2195,18 @@ float sinrx, cosrx; int fa, fs; int i, ndivs; float hda, kappa; - rx = fabsf(args[0]); // y radius - ry = fabsf(args[1]); // x radius - rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle - fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc - fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction - x1 = *cpx; // start point + rx = fabsf(args[0]); /* y radius */ + ry = fabsf(args[1]); /* x radius */ + rotx = args[2] / 180.0f * NSVG_PI; /* x rotation angle */ + fa = fabsf(args[3]) > 1e-6 ? 1 : 0; /* Large arc */ + fs = fabsf(args[4]) > 1e-6 ? 1 : 0; /* Sweep direction */ + x1 = *cpx; /* start point */ y1 = *cpy; - if (rel) { // end point + if (rel) { /* end point */ x2 = *cpx + args[5]; y2 = *cpy + args[6]; } else { x2 = args[5]; y2 = args[6]; @@ -2184,32 +2214,32 @@ dx = x1 - x2; dy = y1 - y2; d = sqrtf(dx*dx + dy*dy); if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) { - // The arc degenerates to a line + /* The arc degenerates to a line */ nsvg__lineTo(p, x2, y2); *cpx = x2; *cpy = y2; return; } sinrx = sinf(rotx); cosrx = cosf(rotx); - // Convert to center point parameterization. - // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes - // 1) Compute x1', y1' + /* Convert to center point parameterization. */ + /* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes */ + /* 1) Compute x1', y1' */ x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f; y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f; d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry); if (d > 1) { d = sqrtf(d); rx *= d; ry *= d; } - // 2) Compute cx', cy' + /* 2) Compute cx', cy' */ s = 0.0f; sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p); sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p); if (sa < 0.0f) sa = 0.0f; if (sb > 0.0f) @@ -2217,37 +2247,37 @@ if (fa == fs) s = -s; cxp = s * rx * y1p / ry; cyp = s * -ry * x1p / rx; - // 3) Compute cx,cy from cx',cy' + /* 3) Compute cx,cy from cx',cy' */ cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp; cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp; - // 4) Calculate theta1, and delta theta. + /* 4) Calculate theta1, and delta theta. */ ux = (x1p - cxp) / rx; uy = (y1p - cyp) / ry; vx = (-x1p - cxp) / rx; vy = (-y1p - cyp) / ry; - a1 = nsvg__vecang(1.0f,0.0f, ux,uy); // Initial angle - da = nsvg__vecang(ux,uy, vx,vy); // Delta angle + a1 = nsvg__vecang(1.0f,0.0f, ux,uy); /* Initial angle */ + da = nsvg__vecang(ux,uy, vx,vy); /* Delta angle */ -// if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; -// if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; +/* if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; */ +/* if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; */ if (fs == 0 && da > 0) da -= 2 * NSVG_PI; else if (fs == 1 && da < 0) da += 2 * NSVG_PI; - // Approximate the arc using cubic spline segments. + /* Approximate the arc using cubic spline segments. */ t[0] = cosrx; t[1] = sinrx; t[2] = -sinrx; t[3] = cosrx; t[4] = cx; t[5] = cy; - // Split arc into max 90 degree segments. - // The loop assumes an iteration per end point (including start and end), this +1. + /* Split arc into max 90 degree segments. */ + /* The loop assumes an iteration per end point (including start and end), this +1. */ ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f); hda = (da / (float)ndivs) / 2.0f; kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); if (da < 0.0f) kappa = -kappa; @@ -2254,12 +2284,12 @@ for (i = 0; i <= ndivs; i++) { a = a1 + da * ((float)i/(float)ndivs); dx = cosf(a); dy = sinf(a); - nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position - nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent + nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); /* position */ + nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); /* tangent */ if (i > 0) nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y); px = x; py = y; ptanx = tanx; @@ -2275,10 +2305,11 @@ const char* s = NULL; char cmd = '\0'; float args[10]; int nargs; int rargs = 0; + char initPoint; float cpx, cpy, cpx2, cpy2; const char* tmp[4]; char closedFlag; int i; char item[64]; @@ -2297,29 +2328,31 @@ if (s) { nsvg__resetPath(p); cpx = 0; cpy = 0; cpx2 = 0; cpy2 = 0; + initPoint = 0; closedFlag = 0; nargs = 0; while (*s) { s = nsvg__getNextPathItem(s, item); if (!*item) break; - if (nsvg__isnum(item[0])) { + if (cmd != '\0' && nsvg__isCoordinate(item)) { if (nargs < 10) args[nargs++] = (float)nsvg__atof(item); if (nargs >= rargs) { switch (cmd) { case 'm': case 'M': nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0); - // Moveto can be followed by multiple coordinate pairs, - // which should be treated as linetos. + /* Moveto can be followed by multiple coordinate pairs, */ + /* which should be treated as linetos. */ cmd = (cmd == 'm') ? 'l' : 'L'; rargs = nsvg__getArgsPerElement(cmd); cpx2 = cpx; cpy2 = cpy; + initPoint = 1; break; case 'l': case 'L': nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0); cpx2 = cpx; cpy2 = cpy; @@ -2365,38 +2398,47 @@ } nargs = 0; } } else { cmd = item[0]; - rargs = nsvg__getArgsPerElement(cmd); if (cmd == 'M' || cmd == 'm') { - // Commit path. + /* Commit path. */ if (p->npts > 0) nsvg__addPath(p, closedFlag); - // Start new subpath. + /* Start new subpath. */ nsvg__resetPath(p); closedFlag = 0; nargs = 0; - } else if (cmd == 'Z' || cmd == 'z') { + } else if (initPoint == 0) { + /* Do not allow other commands until initial point has been set (moveTo called once). */ + cmd = '\0'; + } + if (cmd == 'Z' || cmd == 'z') { closedFlag = 1; - // Commit path. + /* Commit path. */ if (p->npts > 0) { - // Move current point to first point + /* Move current point to first point */ cpx = p->pts[0]; cpy = p->pts[1]; cpx2 = cpx; cpy2 = cpy; nsvg__addPath(p, closedFlag); } - // Start new subpath. + /* Start new subpath. */ nsvg__resetPath(p); nsvg__moveTo(p, cpx, cpy); closedFlag = 0; nargs = 0; } + rargs = nsvg__getArgsPerElement(cmd); + if (rargs == -1) { + /* Command not recognized */ + cmd = '\0'; + rargs = 0; + } } } - // Commit path. + /* Commit path. */ if (p->npts) nsvg__addPath(p, closedFlag); } nsvg__addShape(p); @@ -2406,11 +2448,11 @@ { float x = 0.0f; float y = 0.0f; float w = 0.0f; float h = 0.0f; - float rx = -1.0f; // marks not set + float rx = -1.0f; /* marks not set */ float ry = -1.0f; int i; for (i = 0; attr[i]; i += 2) { if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { @@ -2437,11 +2479,11 @@ nsvg__moveTo(p, x, y); nsvg__lineTo(p, x+w, y); nsvg__lineTo(p, x+w, y+h); nsvg__lineTo(p, x, y+h); } else { - // Rounded rectangle + /* Rounded rectangle */ nsvg__moveTo(p, x+rx, y); nsvg__lineTo(p, x+w-rx, y); nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry); nsvg__lineTo(p, x+w, y+h-ry); nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h); @@ -2594,28 +2636,28 @@ p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); } else if (strcmp(attr[i], "viewBox") == 0) { sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight); } else if (strcmp(attr[i], "preserveAspectRatio") == 0) { if (strstr(attr[i + 1], "none") != 0) { - // No uniform scaling + /* No uniform scaling */ p->alignType = NSVG_ALIGN_NONE; } else { - // Parse X align + /* Parse X align */ if (strstr(attr[i + 1], "xMin") != 0) p->alignX = NSVG_ALIGN_MIN; else if (strstr(attr[i + 1], "xMid") != 0) p->alignX = NSVG_ALIGN_MID; else if (strstr(attr[i + 1], "xMax") != 0) p->alignX = NSVG_ALIGN_MAX; - // Parse X align + /* Parse X align */ if (strstr(attr[i + 1], "yMin") != 0) p->alignY = NSVG_ALIGN_MIN; else if (strstr(attr[i + 1], "yMid") != 0) p->alignY = NSVG_ALIGN_MID; else if (strstr(attr[i + 1], "yMax") != 0) p->alignY = NSVG_ALIGN_MAX; - // Parse meet/slice + /* Parse meet/slice */ p->alignType = NSVG_ALIGN_MEET; if (strstr(attr[i + 1], "slice") != 0) p->alignType = NSVG_ALIGN_SLICE; } } @@ -2706,19 +2748,19 @@ for (i = 0; attr[i]; i += 2) { nsvg__parseAttr(p, attr[i], attr[i + 1]); } - // Add stop to the last gradient. + /* Add stop to the last gradient. */ grad = p->gradients; if (grad == NULL) return; grad->nstops++; grad->stops = (NSVGgradientStop*)NANOSVG_realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops); if (grad->stops == NULL) return; - // Insert + /* Insert */ idx = grad->nstops-1; for (i = 0; i < grad->nstops-1; i++) { if (curAttr->stopOffset < grad->stops[i].offset) { idx = i; break; @@ -2738,11 +2780,11 @@ static void nsvg__startElement(void* ud, const char* el, const char** attr) { NSVGparser* p = (NSVGparser*)ud; if (p->defsFlag) { - // Skip everything but gradients in defs + /* Skip everything but gradients in defs */ if (strcmp(el, "linearGradient") == 0) { nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); } else if (strcmp(el, "radialGradient") == 0) { nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); } else if (strcmp(el, "stop") == 0) { @@ -2753,11 +2795,11 @@ if (strcmp(el, "g") == 0) { nsvg__pushAttr(p); nsvg__parseAttribs(p, attr); } else if (strcmp(el, "path") == 0) { - if (p->pathFlag) // Do not allow nested paths. + if (p->pathFlag) /* Do not allow nested paths. */ return; nsvg__pushAttr(p); nsvg__parsePath(p, attr); nsvg__popAttr(p); } else if (strcmp(el, "rect") == 0) { @@ -2906,11 +2948,11 @@ { if (type == NSVG_ALIGN_MIN) return 0; else if (type == NSVG_ALIGN_MAX) return container - content; - // mid + /* mid */ return (container - content) * 0.5f; } static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy) { @@ -2928,11 +2970,11 @@ NSVGpath* path; float tx, ty, sx, sy, us, bounds[4], t[6], avgs; int i; float* pt; - // Guess image size if not set completely. + /* Guess image size if not set completely. */ nsvg__imageBounds(p, bounds); if (p->viewWidth == 0) { if (p->image->width > 0) { p->viewWidth = p->image->width; @@ -2956,27 +2998,27 @@ tx = -p->viewMinx; ty = -p->viewMiny; sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0; sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0; - // Unit scaling + /* Unit scaling */ us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f); - // Fix aspect ratio + /* Fix aspect ratio */ if (p->alignType == NSVG_ALIGN_MEET) { - // fit whole image into viewbox + /* fit whole image into viewbox */ sx = sy = nsvg__minf(sx, sy); tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx; ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy; } else if (p->alignType == NSVG_ALIGN_SLICE) { - // fill whole viewbox with image + /* fill whole viewbox with image */ sx = sy = nsvg__maxf(sx, sy); tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx; ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy; } - // Transform + /* Transform */ sx *= us; sy *= us; avgs = (sx+sy) / 2.0f; for (shape = p->image->shapes; shape != NULL; shape = shape->next) { shape->bounds[0] = (shape->bounds[0] + tx) * sx; @@ -3025,11 +3067,11 @@ } p->dpi = dpi; nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); - // Scale to viewBox + /* Scale to viewBox */ nsvg__scaleToViewbox(p, units); ret = p->image; p->image = NULL; @@ -3052,11 +3094,11 @@ size = ftell(fp); fseek(fp, 0, SEEK_SET); data = (char*)NANOSVG_malloc(size+1); if (data == NULL) goto error; if (fread(data, 1, size, fp) != size) goto error; - data[size] = '\0'; // Must be null terminated. + data[size] = '\0'; /* Must be null terminated. */ fclose(fp); image = nsvgParse(data, units, dpi); NANOSVG_free(data); return image; Index: generic/nanosvgrast.h ================================================================== --- generic/nanosvgrast.h +++ generic/nanosvgrast.h @@ -57,35 +57,36 @@ unsigned char* img = malloc(w*h*4); // Rasterize nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4); */ -// Allocated rasterizer context. +/* Allocated rasterizer context. */ NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void); -// Rasterizes SVG image, returns RGBA image (non-premultiplied alpha) -// r - pointer to rasterizer context -// image - pointer to image to rasterize -// tx,ty - image offset (applied after scaling) -// scale - image scale -// dst - pointer to destination image data, 4 bytes per pixel (RGBA) -// w - width of the image to render -// h - height of the image to render -// stride - number of bytes per scaleline in the destination buffer +/* Rasterizes SVG image, returns RGBA image (non-premultiplied alpha) + * r - pointer to rasterizer context + * image - pointer to image to rasterize + * tx,ty - image offset (applied after scaling) + * scale - image scale + * dst - pointer to destination image data, 4 bytes per pixel (RGBA) + * w - width of the image to render + * h - height of the image to render + * stride - number of bytes per scaleline in the destination buffer NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride); + */ -// Deletes rasterizer context. +/* Deletes rasterizer context. */ NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*); #ifdef __cplusplus } #endif -#endif // NANOSVGRAST_H +#endif /* NANOSVGRAST_H */ #ifdef NANOSVGRAST_IMPLEMENTATION #include @@ -200,21 +201,21 @@ static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur) { NSVGmemPage *newp; - // If using existing chain, return the next page in chain + /* If using existing chain, return the next page in chain */ if (cur != NULL && cur->next != NULL) { return cur->next; } - // Alloc new page + /* Alloc new page */ newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage)); if (newp == NULL) return NULL; memset(newp, 0, sizeof(NSVGmemPage)); - // Add to linked list + /* Add to linked list */ if (cur != NULL) cur->next = newp; else r->pages = newp; @@ -300,11 +301,11 @@ static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1) { NSVGedge* e; - // Skip horizontal edges + /* Skip horizontal edges */ if (y0 == y1) return; if (r->nedges+1 > r->cedges) { r->cedges = r->cedges > 0 ? r->cedges * 2 : 64; @@ -386,19 +387,19 @@ int i, j; NSVGpath* path; for (path = shape->paths; path != NULL; path = path->next) { r->npoints = 0; - // Flatten path + /* Flatten path */ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0); for (i = 0; i < path->npts-1; i += 3) { float* p = &path->pts[i*2]; nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0); } - // Close path + /* Close path */ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0); - // Build edges + /* Build edges */ for (i = 0, j = r->npoints-1; i < r->npoints; j = i++) nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y); } } @@ -617,24 +618,24 @@ return divs; } static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth) { - int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); // Calculate divisions per half circle. + int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); /* Calculate divisions per half circle. */ NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0}; NSVGpoint* p0, *p1; int j, s, e; - // Build stroke edges + /* Build stroke edges */ if (closed) { - // Looping + /* Looping */ p0 = &points[npoints-1]; p1 = &points[0]; s = 0; e = npoints; } else { - // Add cap + /* Add cap */ p0 = &points[0]; p1 = &points[1]; s = 1; e = npoints-1; } @@ -642,11 +643,11 @@ if (closed) { nsvg__initClosed(&left, &right, p0, p1, lineWidth); firstLeft = left; firstRight = right; } else { - // Add cap + /* Add cap */ float dx = p1->x - p0->x; float dy = p1->y - p0->y; nsvg__normalize(&dx, &dy); if (lineCap == NSVG_CAP_BUTT) nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0); @@ -669,15 +670,15 @@ } p0 = p1++; } if (closed) { - // Loop it + /* Loop it */ nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y); nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y); } else { - // Add cap + /* Add cap */ float dx = p1->x - p0->x; float dy = p1->y - p0->y; nsvg__normalize(&dx, &dy); if (lineCap == NSVG_CAP_BUTT) nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1); @@ -694,28 +695,28 @@ NSVGpoint* p0, *p1; p0 = &r->points[r->npoints-1]; p1 = &r->points[0]; for (i = 0; i < r->npoints; i++) { - // Calculate segment direction and length + /* Calculate segment direction and length */ p0->dx = p1->x - p0->x; p0->dy = p1->y - p0->y; p0->len = nsvg__normalize(&p0->dx, &p0->dy); - // Advance + /* Advance */ p0 = p1++; } - // calculate joins + /* calculate joins */ p0 = &r->points[r->npoints-1]; p1 = &r->points[0]; for (j = 0; j < r->npoints; j++) { float dlx0, dly0, dlx1, dly1, dmr2, cross; dlx0 = p0->dy; dly0 = -p0->dx; dlx1 = p1->dy; dly1 = -p1->dx; - // Calculate extrusions + /* Calculate extrusions */ p1->dmx = (dlx0 + dlx1) * 0.5f; p1->dmy = (dly0 + dly1) * 0.5f; dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy; if (dmr2 > 0.000001f) { float s2 = 1.0f / dmr2; @@ -724,19 +725,19 @@ } p1->dmx *= s2; p1->dmy *= s2; } - // Clear flags, but keep the corner. + /* Clear flags, but keep the corner. */ p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0; - // Keep track of left turns. + /* Keep track of left turns. */ cross = p1->dx * p0->dy - p0->dx * p1->dy; if (cross > 0.0f) p1->flags |= NSVG_PT_LEFT; - // Check to see if the corner needs to be beveled. + /* Check to see if the corner needs to be beveled. */ if (p1->flags & NSVG_PT_CORNER) { if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) { p1->flags |= NSVG_PT_BEVEL; } } @@ -754,11 +755,11 @@ int lineJoin = shape->strokeLineJoin; int lineCap = shape->strokeLineCap; float lineWidth = shape->strokeWidth * scale; for (path = shape->paths; path != NULL; path = path->next) { - // Flatten path + /* Flatten path */ r->npoints = 0; nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER); for (i = 0; i < path->npts-1; i += 3) { float* p = &path->pts[i*2]; nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER); @@ -766,11 +767,11 @@ if (r->npoints < 2) continue; closed = path->closed; - // If the first and last points are the same, remove the last, mark as closed path. + /* If the first and last points are the same, remove the last, mark as closed path. */ p0 = &r->points[r->npoints-1]; p1 = &r->points[0]; if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) { r->npoints--; p0 = &r->points[r->npoints-1]; @@ -783,24 +784,24 @@ NSVGpoint cur; if (closed) nsvg__appendPathPoint(r, r->points[0]); - // Duplicate points -> points2. + /* Duplicate points -> points2. */ nsvg__duplicatePoints(r); r->npoints = 0; cur = r->points2[0]; nsvg__appendPathPoint(r, cur); - // Figure out dash offset. + /* Figure out dash offset. */ allDashLen = 0; for (j = 0; j < shape->strokeDashCount; j++) allDashLen += shape->strokeDashArray[j]; if (shape->strokeDashCount & 1) allDashLen *= 2.0f; - // Find location inside pattern + /* Find location inside pattern */ dashOffset = fmodf(shape->strokeDashOffset, allDashLen); if (dashOffset < 0.0f) dashOffset += allDashLen; while (dashOffset > shape->strokeDashArray[idash]) { @@ -813,26 +814,26 @@ float dx = r->points2[j].x - cur.x; float dy = r->points2[j].y - cur.y; float dist = sqrtf(dx*dx + dy*dy); if ((totalDist + dist) > dashLen) { - // Calculate intermediate point + /* Calculate intermediate point */ float d = (dashLen - totalDist) / dist; float x = cur.x + dx * d; float y = cur.y + dy * d; nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER); - // Stroke + /* Stroke */ if (r->npoints > 1 && dashState) { nsvg__prepareStroke(r, miterLimit, lineJoin); nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth); } - // Advance dash pattern + /* Advance dash pattern */ dashState = !dashState; idash = (idash+1) % shape->strokeDashCount; dashLen = shape->strokeDashArray[idash] * scale; - // Restart + /* Restart */ cur.x = x; cur.y = y; cur.flags = NSVG_PT_CORNER; totalDist = 0.0f; r->npoints = 0; @@ -842,11 +843,11 @@ cur = r->points2[j]; nsvg__appendPathPoint(r, cur); j++; } } - // Stroke any leftover path + /* Stroke any leftover path */ if (r->npoints > 1 && dashState) nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth); } else { nsvg__prepareStroke(r, miterLimit, lineJoin); nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth); @@ -869,28 +870,28 @@ { NSVGactiveEdge* z; float dxdy; if (r->freelist != NULL) { - // Restore from freelist. + /* Restore from freelist. */ z = r->freelist; r->freelist = z->next; } else { - // Alloc new edge. + /* Alloc new edge. */ z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge)); if (z == NULL) return NULL; } dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); -// STBTT_assert(e->y0 <= start_point); - // round dx down to avoid going too far +/* STBTT_assert(e->y0 <= start_point); */ + /* round dx down to avoid going too far */ if (dxdy < 0) z->dx = (int)(-floorf(NSVG__FIX * -dxdy)); else z->dx = (int)floorf(NSVG__FIX * dxdy); z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0))); -// z->x -= off_x * FIX; +/* z->x -= off_x * FIX; */ z->ey = e->y1; z->next = 0; z->dir = e->dir; return z; @@ -908,56 +909,57 @@ int j = x1 >> NSVG__FIXSHIFT; if (i < *xmin) *xmin = i; if (j > *xmax) *xmax = j; if (i < len && j >= 0) { if (i == j) { - // x0,x1 are the same pixel, so compute combined coverage + /* x0,x1 are the same pixel, so compute combined coverage */ scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT)); } else { - if (i >= 0) // add antialiasing for x0 + if (i >= 0) /* add antialiasing for x0 */ scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT)); else - i = -1; // clip + i = -1; /* clip */ - if (j < len) // add antialiasing for x1 + if (j < len) /* add antialiasing for x1 */ scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT)); else - j = len; // clip + j = len; /* clip */ - for (++i; i < j; ++i) // fill pixels between x0 and x1 + for (++i; i < j; ++i) /* fill pixels between x0 and x1 */ scanline[i] = (unsigned char)(scanline[i] + maxWeight); } } } -// note: this routine clips fills that extend off the edges... ideally this -// wouldn't happen, but it could happen if the truetype glyph bounding boxes -// are wrong, or if the user supplies a too-small bitmap +/* note: this routine clips fills that extend off the edges... ideally this + * wouldn't happen, but it could happen if the truetype glyph bounding boxes + * are wrong, or if the user supplies a too-small bitmap + */ static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule) { - // non-zero winding fill + /* non-zero winding fill */ int x0 = 0, w = 0; if (fillRule == NSVG_FILLRULE_NONZERO) { - // Non-zero + /* Non-zero */ while (e != NULL) { if (w == 0) { - // if we're currently at zero, we need to record the edge start point + /* if we're currently at zero, we need to record the edge start point */ x0 = e->x; w += e->dir; } else { int x1 = e->x; w += e->dir; - // if we went to zero, we need to draw + /* if we went to zero, we need to draw */ if (w == 0) nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax); } e = e->next; } } else if (fillRule == NSVG_FILLRULE_EVENODD) { - // Even-odd + /* Even-odd */ while (e != NULL) { if (w == 0) { - // if we're currently at zero, we need to record the edge start point + /* if we're currently at zero, we need to record the edge start point */ x0 = e->x; w = 1; } else { int x1 = e->x; w = 0; nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax); } @@ -1011,16 +1013,16 @@ for (i = 0; i < count; i++) { int r,g,b; int a = nsvg__div255((int)cover[0] * ca); int ia = 255 - a; - // Premultiply + /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); - // Blend over + /* Blend over */ r += nsvg__div255(ia * (int)dst[0]); g += nsvg__div255(ia * (int)dst[1]); b += nsvg__div255(ia * (int)dst[2]); a += nsvg__div255(ia * (int)dst[3]); @@ -1031,12 +1033,12 @@ cover++; dst += 4; } } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) { - // TODO: spread modes. - // TODO: plenty of opportunities to optimize. + /* TODO: spread modes. */ + /* TODO: plenty of opportunities to optimize. */ float fx, fy, dx, gy; float* t = cache->xform; int i, cr, cg, cb, ca; unsigned int c; @@ -1054,16 +1056,16 @@ ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; - // Premultiply + /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); - // Blend over + /* Blend over */ r += nsvg__div255(ia * (int)dst[0]); g += nsvg__div255(ia * (int)dst[1]); b += nsvg__div255(ia * (int)dst[2]); a += nsvg__div255(ia * (int)dst[3]); @@ -1075,13 +1077,13 @@ cover++; dst += 4; fx += dx; } } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) { - // TODO: spread modes. - // TODO: plenty of opportunities to optimize. - // TODO: focus (fx,fy) + /* TODO: spread modes. */ + /* TODO: plenty of opportunities to optimize. */ + /* TODO: focus (fx,fy) */ float fx, fy, dx, gx, gy, gd; float* t = cache->xform; int i, cr, cg, cb, ca; unsigned int c; @@ -1101,16 +1103,16 @@ ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; - // Premultiply + /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); - // Blend over + /* Blend over */ r += nsvg__div255(ia * (int)dst[0]); g += nsvg__div255(ia * (int)dst[1]); b += nsvg__div255(ia * (int)dst[2]); a += nsvg__div255(ia * (int)dst[3]); @@ -1129,37 +1131,37 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule) { NSVGactiveEdge *active = NULL; int y, s; int e = 0; - int maxWeight = (255 / NSVG__SUBSAMPLES); // weight per vertical scanline + int maxWeight = (255 / NSVG__SUBSAMPLES); /* weight per vertical scanline */ int xmin, xmax; for (y = 0; y < r->height; y++) { memset(r->scanline, 0, r->width); xmin = r->width; xmax = 0; for (s = 0; s < NSVG__SUBSAMPLES; ++s) { - // find center of pixel for this scanline + /* find center of pixel for this scanline */ float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f; NSVGactiveEdge **step = &active; - // update all active edges; - // remove all active edges that terminate before the center of this scanline + /* update all active edges; */ + /* remove all active edges that terminate before the center of this scanline */ while (*step) { NSVGactiveEdge *z = *step; if (z->ey <= scany) { - *step = z->next; // delete from list -// NSVG__assert(z->valid); + *step = z->next; /* delete from list */ +/* NSVG__assert(z->valid); */ nsvg__freeActive(r, z); } else { - z->x += z->dx; // advance to position for current scanline - step = &((*step)->next); // advance through list + z->x += z->dx; /* advance to position for current scanline */ + step = &((*step)->next); /* advance through list */ } } - // resort the list if needed + /* resort the list if needed */ for (;;) { int changed = 0; step = &active; while (*step && (*step)->next) { if ((*step)->x > (*step)->next->x) { @@ -1173,40 +1175,40 @@ step = &(*step)->next; } if (!changed) break; } - // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + /* insert all edges that start before the center of this scanline -- omit ones that also end on this scanline */ while (e < r->nedges && r->edges[e].y0 <= scany) { if (r->edges[e].y1 > scany) { NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany); if (z == NULL) break; - // find insertion point + /* find insertion point */ if (active == NULL) { active = z; } else if (z->x < active->x) { - // insert at front + /* insert at front */ z->next = active; active = z; } else { - // find thing to insert AFTER + /* find thing to insert AFTER */ NSVGactiveEdge* p = active; while (p->next && p->next->x < z->x) p = p->next; - // at this point, p->next->x is NOT < z->x + /* at this point, p->next->x is NOT < z->x */ z->next = p->next; p->next = z; } } e++; } - // now process all active edges in non-zero fashion + /* now process all active edges in non-zero fashion */ if (active != NULL) nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule); } - // Blit + /* Blit */ if (xmin < 0) xmin = 0; if (xmax > r->width-1) xmax = r->width-1; if (xmin <= xmax) { nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache); } @@ -1216,11 +1218,11 @@ static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride) { int x,y; - // Unpremultiply + /* Unpremultiply */ for (y = 0; y < h; y++) { unsigned char *row = &image[y*stride]; for (x = 0; x < w; x++) { int r = row[0], g = row[1], b = row[2], a = row[3]; if (a != 0) { @@ -1230,11 +1232,11 @@ } row += 4; } } - // Defringe + /* Defringe */ for (y = 0; y < h; y++) { unsigned char *row = &image[y*stride]; for (x = 0; x < w; x++) { int r = 0, g = 0, b = 0, a = row[3], n = 0; if (a == 0) { @@ -1409,23 +1411,23 @@ r->freelist = NULL; r->nedges = 0; nsvg__flattenShape(r, shape, scale); - // Scale and translate edges + /* Scale and translate edges */ for (i = 0; i < r->nedges; i++) { e = &r->edges[i]; e->x0 = tx + e->x0; e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES; e->x1 = tx + e->x1; e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES; } - // Rasterize edges + /* Rasterize edges */ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); - // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule + /* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */ nsvg__initPaint(&cache, &shape->fill, shape->opacity); nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule); } if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) { @@ -1433,25 +1435,25 @@ r->freelist = NULL; r->nedges = 0; nsvg__flattenShapeStroke(r, shape, scale); -// dumpEdges(r, "edge.svg"); +/* dumpEdges(r, "edge.svg"); */ - // Scale and translate edges + /* Scale and translate edges */ for (i = 0; i < r->nedges; i++) { e = &r->edges[i]; e->x0 = tx + e->x0; e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES; e->x1 = tx + e->x1; e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES; } - // Rasterize edges + /* Rasterize edges */ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); - // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule + /* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */ nsvg__initPaint(&cache, &shape->stroke, shape->opacity); nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO); } } Index: generic/tk.decls ================================================================== --- generic/tk.decls +++ generic/tk.decls @@ -3,12 +3,12 @@ # This file contains the declarations for all supported public # functions that are exported by the Tk library via the stubs table. # This file is used to generate the tkDecls.h, tkPlatDecls.h, # tkStub.c, and tkPlatStub.c files. # -# Copyright (c) 1998-2000 Ajuba Solutions. -# Copyright (c) 2007 Daniel A. Steffen +# Copyright © 1998-2000 Ajuba Solutions. +# Copyright © 2007 Daniel A. Steffen # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. library tk @@ -401,11 +401,11 @@ declare 97 { Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, ClientData clientData) } declare 98 { - ClientData Tk_GetImageMasterData(Tcl_Interp *interp, + ClientData Tk_GetImageModelData(Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr) } declare 99 { Tk_ItemType *Tk_GetItemTypes(void) } @@ -470,11 +470,11 @@ } declare 116 { Tk_Window Tk_IdToWindow(Display *display, Window window) } declare 117 { - void Tk_ImageChanged(Tk_ImageMaster master, int x, int y, + void Tk_ImageChanged(Tk_ImageModel model, int x, int y, int width, int height, int imageWidth, int imageHeight) } declare 118 { int Tk_Init(Tcl_Interp *interp) } @@ -484,12 +484,12 @@ declare 120 { int Tk_IntersectTextLayout(Tk_TextLayout layout, int x, int y, int width, int height) } declare 121 { - void Tk_MaintainGeometry(Tk_Window slave, - Tk_Window master, int x, int y, int width, int height) + void Tk_MaintainGeometry(Tk_Window window, + Tk_Window container, int x, int y, int width, int height) } declare 122 { Tk_Window Tk_MainWindow(Tcl_Interp *interp) } declare 123 { @@ -537,11 +537,11 @@ } declare 136 { const char *Tk_NameOfFont(Tk_Font font) } declare 137 { - const char *Tk_NameOfImage(Tk_ImageMaster imageMaster) + const char *Tk_NameOfImage(Tk_ImageModel model) } declare 138 { const char *Tk_NameOfJoinStyle(int join) } declare 139 { @@ -690,11 +690,11 @@ } declare 180 { void Tk_Ungrab(Tk_Window tkwin) } declare 181 { - void Tk_UnmaintainGeometry(Tk_Window slave, Tk_Window master) + void Tk_UnmaintainGeometry(Tk_Window window, Tk_Window container) } declare 182 { void Tk_UnmapWindow(Tk_Window tkwin) } declare 183 { @@ -1066,16 +1066,38 @@ void Tk_CreateOldImageType(const Tk_ImageType *typePtr) } declare 273 { void Tk_CreateOldPhotoImageFormat(const Tk_PhotoImageFormat *formatPtr) } -# New in Tk8.7 + +# TIP#580 declare 274 { + int Tk_AlwaysShowSelection(Tk_Window tkwin) +} +declare 275 { + unsigned Tk_GetButtonMask(unsigned button) +} +declare 276 { + int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, Tk_Window tkwin, + Tcl_Obj *objPtr, double *doublePtr) +} +declare 277 { + Tcl_Obj *Tk_NewWindowObj(Tk_Window tkwin) +} +declare 278 { + void Tk_SendVirtualEvent(Tk_Window tkwin, const char *eventName, + Tcl_Obj *detail) +} +declare 279 { + Tcl_Obj *Tk_FontGetDescription(Tk_Font tkfont) +} + +# TIP#529 +declare 280 { void Tk_CreatePhotoImageFormatVersion3( const Tk_PhotoImageFormatVersion3 *formatPtr) } - # Define the platform specific public Tk interface. These functions are # only available on the designated platform. interface tkPlat @@ -1103,41 +1125,28 @@ UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result) } ################################ # Aqua specific functions - -declare 0 aqua { - void Tk_MacOSXSetEmbedHandler( - Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, - Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, - Tk_MacOSXEmbedGetClipProc *getClipProc, - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) -} -declare 1 aqua { - void Tk_MacOSXTurnOffMenus(void) -} -declare 2 aqua { - void Tk_MacOSXTkOwnsCursor(int tkOwnsIt) -} -declare 3 aqua { - void TkMacOSXInitMenus(Tcl_Interp *interp) -} +# Stub removed because the function no longer exists. +#declare 3 aqua { +# void TkMacOSXInitMenus(Tcl_Interp *interp) +#} declare 4 aqua { void TkMacOSXInitAppleEvents(Tcl_Interp *interp) } declare 5 aqua { - void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width, + void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width, int height, int flags) } declare 6 aqua { void TkMacOSXInvalClipRgns(Tk_Window tkwin) } -declare 7 aqua { - void *TkMacOSXGetDrawablePort(Drawable drawable) -} +# Stub removed because it just returned NULL. +#declare 7 aqua { +# void *TkMacOSXGetDrawablePort(Drawable drawable) +#} declare 8 aqua { void *TkMacOSXGetRootControl(Drawable drawable) } declare 9 aqua { void Tk_MacOSXSetupTkNotifier(void) @@ -1144,31 +1153,21 @@ } declare 10 aqua { int Tk_MacOSXIsAppInFront(void) } declare 11 aqua { - void Tk_MacOSXSetEmbedHandler_( - Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, - Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, - Tk_MacOSXEmbedGetClipProc *getClipProc, - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) + Tk_Window Tk_MacOSXGetTkWindow(void *w) } declare 12 aqua { - void Tk_MacOSXTurnOffMenus_(void) -} -declare 13 aqua { - void Tk_MacOSXTkOwnsCursor_(int tkOwnsIt) -} -declare 14 aqua { - void TkMacOSXInitMenus_(Tcl_Interp *interp) -} -declare 15 aqua { - void TkMacOSXInitAppleEvents_(Tcl_Interp *interp) + void *Tk_MacOSXGetCGContextForDrawable(Drawable drawable) +} +# Replaces TkMacOSXDrawable +declare 13 aqua { + void *Tk_MacOSXGetNSWindowForDrawable(Drawable drawable) } declare 16 aqua { - void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width, + void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width, int height, int flags) } ############################################################################## Index: generic/tk.h ================================================================== --- generic/tk.h +++ generic/tk.h @@ -92,14 +92,11 @@ # include # ifdef MAC_OSX_TK # include # endif #endif -#if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \ - || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC) -# include -#endif +#include #ifdef BUILD_tk #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT #else @@ -120,17 +117,18 @@ /* * Dummy types that are used by clients: */ +#define Tk_ImageMaster Tk_ImageModel typedef struct Tk_BindingTable_ *Tk_BindingTable; typedef struct Tk_Canvas_ *Tk_Canvas; typedef struct Tk_Cursor_ *Tk_Cursor; typedef struct Tk_ErrorHandler_ *Tk_ErrorHandler; typedef struct Tk_Font_ *Tk_Font; typedef struct Tk_Image__ *Tk_Image; -typedef struct Tk_ImageMaster_ *Tk_ImageMaster; +typedef struct Tk_ImageModel_ *Tk_ImageModel; typedef struct Tk_OptionTable_ *Tk_OptionTable; typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo; typedef struct Tk_TextLayout_ *Tk_TextLayout; typedef struct Tk_Window_ *Tk_Window; typedef struct Tk_3DBorder_ *Tk_3DBorder; @@ -648,25 +646,26 @@ * Each geometry manager (the packer, the placer, etc.) is represented by a * structure of the following form, which indicates procedures to invoke in * the geometry manager to carry out certain functions. */ +#define Tk_GeomLostSlaveProc Tk_GeomLostContentProc typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin); -typedef void (Tk_GeomLostSlaveProc) (ClientData clientData, Tk_Window tkwin); +typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin); typedef struct Tk_GeomMgr { const char *name; /* Name of the geometry manager (command used * to invoke it, or name of widget class that * allows embedded widgets). */ Tk_GeomRequestProc *requestProc; - /* Procedure to invoke when a slave's + /* Procedure to invoke when a content's * requested geometry changes. */ - Tk_GeomLostSlaveProc *lostSlaveProc; - /* Procedure to invoke when a slave is taken + Tk_GeomLostContentProc *lostContentProc; + /* Procedure to invoke when content is taken * away from one geometry manager by another. * NULL means geometry manager doesn't care - * when slaves are lost. */ + * when content lost. */ } Tk_GeomMgr; /* * Result values returned by Tk_GetScrollInfo: */ @@ -1301,23 +1300,23 @@ */ typedef struct Tk_ImageType Tk_ImageType; #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 && defined(USE_OLD_IMAGE) typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc, - char **argv, Tk_ImageType *typePtr, Tk_ImageMaster master, - ClientData *masterDataPtr); + char **argv, Tk_ImageType *typePtr, Tk_ImageModel model, + ClientData *clientDataPtr); #else typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, const char *name, int objc, - Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageMaster master, - ClientData *masterDataPtr); + Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, + ClientData *clientDataPtr); #endif /* USE_OLD_IMAGE */ -typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData masterData); -typedef void (Tk_ImageDisplayProc) (ClientData instanceData, Display *display, +typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData); +typedef void (Tk_ImageDisplayProc) (ClientData clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, int height, int drawableX, int drawableY); -typedef void (Tk_ImageFreeProc) (ClientData instanceData, Display *display); -typedef void (Tk_ImageDeleteProc) (ClientData masterData); +typedef void (Tk_ImageFreeProc) (ClientData clientData, Display *display); +typedef void (Tk_ImageDeleteProc) (ClientData clientData); typedef void (Tk_ImageChangedProc) (ClientData clientData, int x, int y, int width, int height, int imageWidth, int imageHeight); typedef int (Tk_ImagePostscriptProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass); Index: generic/tk3d.c ================================================================== --- generic/tk3d.c +++ generic/tk3d.c @@ -2,12 +2,12 @@ * tk3d.c -- * * This module provides procedures to draw borders in the * three-dimensional Motif style. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tk3d.h ================================================================== --- generic/tk3d.h +++ generic/tk3d.h @@ -1,11 +1,11 @@ /* * tk3d.h -- * * Declarations of types and functions shared by the 3d border module. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkArgv.c ================================================================== --- generic/tkArgv.c +++ generic/tkArgv.c @@ -2,12 +2,12 @@ * tkArgv.c -- * * This file contains a function that handles table-based argv-argc * parsing. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkArray.h ================================================================== --- generic/tkArray.h +++ generic/tkArray.h @@ -3,11 +3,11 @@ * * An array is a sequence of items, stored in a contiguous memory region. * Random access to any item is very fast. New items can be either appended * or prepended. An array may be traversed in the forward or backward direction. * - * Copyright (c) 2018-2019 by Gregor Cramer. + * Copyright © 2018-2019 Gregor Cramer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkAtom.c ================================================================== --- generic/tkAtom.c +++ generic/tkAtom.c @@ -4,12 +4,12 @@ * This file manages a cache of X Atoms in order to avoid interactions * with the X server. It's much like the Xmu routines, except it has a * cleaner interface (caller doesn't have to provide permanent storage * for atom names, for example). * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkBind.c ================================================================== --- generic/tkBind.c +++ generic/tkBind.c @@ -2,14 +2,14 @@ * tkBind.c -- * * This file provides functions that associate Tcl commands with X events * or sequences of X events. * - * Copyright (c) 1989-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998 by Scriptics Corporation. - * Copyright (c) 2018-2019 by Gregor Cramer. + * Copyright © 1989-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998 Scriptics Corporation. + * Copyright © 2018-2019 Gregor Cramer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -135,21 +135,14 @@ unsigned countDetailed; /* Count of multi-events, like multi-clicks, or repeated key pressing, * this count considers the detail (keySym or button). */ } Event; -/* - * We need a structure providing a list of pattern sequences. - */ - -typedef unsigned EventMask; -typedef unsigned long ModMask; - struct PatSeq; /* forward declaration */ /* We need this array for bookkeeping the last matching modifier mask per pattern. */ -TK_ARRAY_DEFINE(PSModMaskArr, ModMask); +TK_ARRAY_DEFINE(PSModMaskArr, unsigned); typedef struct PSEntry { TK_DLIST_LINKS(PSEntry); /* Makes this struct a double linked list; must be first entry. */ Window window; /* Window of last match. */ struct PatSeq* psPtr; /* Pointer to pattern sequence. */ @@ -201,11 +194,11 @@ typedef struct Tk_BindingTable_ { Event eventInfo[TK_LASTEVENT]; /* Containing the most recent event for every event type. */ PromArr *promArr; /* Contains the promoted pattern sequences. */ Event *curEvent; /* Pointing to most recent event. */ - ModMask curModMask; /* Containing the current modifier mask. */ + unsigned curModMask; /* Containing the current modifier mask. */ LookupTables lookupTables; /* Containing hash tables for fast lookup. */ Tcl_HashTable objectTable; /* Used to map from an object to a list of patterns associated with * that object. Keys are ClientData, values are (PatSeq *). */ Tcl_Interp *interp; /* Interpreter in which commands are executed. */ } BindingTable; @@ -263,11 +256,11 @@ */ typedef struct { unsigned eventType; /* Type of X event, e.g. ButtonPress. */ unsigned count; /* Multi-event count, e.g. double-clicks, triple-clicks, etc. */ - ModMask modMask; /* Mask of modifiers that must be present (zero means no modifiers + unsigned modMask; /* Mask of modifiers that must be present (zero means no modifiers * are required). */ Info info; /* Additional information that must match event. Normally this is zero, * meaning no additional information must match. For KeyPress and * KeyRelease events, it may be specified to select a particular * keystroke (zero means any keystrokes). For button events, specifies @@ -414,11 +407,11 @@ * below. */ typedef struct { const char *name; /* Name of modifier. */ - ModMask mask; /* Button/modifier mask value, such as Button1Mask. */ + unsigned mask; /* Button/modifier mask value, such as Button1Mask. */ unsigned flags; /* Various flags; see below for definitions. */ } ModInfo; /* * Flags for ModInfo structures: @@ -437,11 +430,13 @@ static const ModInfo modArray[] = { {"Control", ControlMask, 0}, {"Shift", ShiftMask, 0}, {"Lock", LockMask, 0}, {"Meta", META_MASK, 0}, +#ifndef TK_NO_DEPRECATED {"M", META_MASK, 0}, +#endif {"Alt", ALT_MASK, 0}, {"Extended", EXTENDED_MASK, 0}, {"B1", Button1Mask, 0}, {"Button1", Button1Mask, 0}, {"B2", Button2Mask, 0}, @@ -460,14 +455,24 @@ {"Button8", Button8Mask, 0}, {"B9", Button9Mask, 0}, {"Button9", Button9Mask, 0}, {"Mod1", Mod1Mask, 0}, {"M1", Mod1Mask, 0}, +#ifdef MAC_OSX_TK {"Command", Mod1Mask, 0}, +#elif defined (_WIN32) + {"Command", ControlMask, 0}, +#else + {"Command", META_MASK, 0}, +#endif {"Mod2", Mod2Mask, 0}, {"M2", Mod2Mask, 0}, +#ifdef MAC_OSX_TK {"Option", Mod2Mask, 0}, +#else + {"Option", ALT_MASK, 0}, +#endif {"Mod3", Mod3Mask, 0}, {"M3", Mod3Mask, 0}, {"Mod4", Mod4Mask, 0}, {"M4", Mod4Mask, 0}, {"Mod5", Mod5Mask, 0}, @@ -499,14 +504,18 @@ * unless you've asked about button events. */ static const EventInfo eventArray[] = { {"Key", KeyPress, KeyPressMask}, +#ifndef TK_NO_DEPRECATED {"KeyPress", KeyPress, KeyPressMask}, +#endif {"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask}, {"Button", ButtonPress, ButtonPressMask}, +#ifndef TK_NO_DEPRECATED {"ButtonPress", ButtonPress, ButtonPressMask}, +#endif {"ButtonRelease", ButtonRelease, ButtonPressMask|ButtonReleaseMask}, {"Motion", MotionNotify, ButtonPressMask|PointerMotionMask}, {"Enter", EnterNotify, EnterWindowMask}, {"Leave", LeaveNotify, LeaveWindowMask}, {"FocusIn", FocusIn, FocusChangeMask}, @@ -719,11 +728,11 @@ static void DeleteVirtualEventTable(VirtualEventTable *vetPtr); static void ExpandPercents(TkWindow *winPtr, const char *before, Event *eventPtr, unsigned scriptCount, Tcl_DString *dsPtr); static PatSeq * FindSequence(Tcl_Interp *interp, LookupTables *lookupTables, ClientData object, const char *eventString, int create, - int allowVirtual, EventMask *maskPtr); + int allowVirtual, unsigned *maskPtr); static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr); static const char * GetField(const char *p, char *copy, unsigned size); static Tcl_Obj * GetPatternObj(const PatSeq *psPtr); static int GetVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr, Tcl_Obj *virtName); @@ -735,12 +744,11 @@ PSList *psSuccList, unsigned patIndex, const Event *eventPtr, ClientData object, PatSeq **physPtrPtr); static int NameToWindow(Tcl_Interp *interp, Tk_Window main, Tcl_Obj *objPtr, Tk_Window *tkwinPtr); static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr, - TkPattern *patPtr, EventMask *eventMaskPtr); -static void DoWarp(ClientData clientData); + TkPattern *patPtr, unsigned *eventMaskPtr); static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr, Tcl_Obj *object, int onlyConsiderDetailedEvents); static void ClearLookupTable(LookupTables *lookupTables, ClientData object); static void ClearPromotionLists(Tk_BindingTable bindPtr, ClientData object); static PSEntry * MakeListEntry(PSList *pool, PatSeq *psPtr, int needModMasks); @@ -767,12 +775,12 @@ static int TestNearbyTime(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_MS; } static int TestNearbyCoords(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_PIXELS; } static int IsSubsetOf( - ModMask lhsMask, /* this is a subset */ - ModMask rhsMask) /* of this bit field? */ + unsigned lhsMask, /* this is a subset */ + unsigned rhsMask) /* of this bit field? */ { return (lhsMask & rhsMask) == lhsMask; } static const char* @@ -798,12 +806,14 @@ static unsigned GetButtonNumber( const char *field) { + unsigned button; assert(field); - return (field[0] >= '1' && field[0] <= '9' && field[1] == '\0') ? field[0] - '0' : 0; + button = (field[0] >= '1' && field[0] <= '9' && field[1] == '\0') ? field[0] - '0' : 0; + return (button > 3) ? (button + 4) : button; } static Time CurrentTimeInMilliSecs(void) { @@ -955,15 +965,14 @@ } } static PSEntry * FreePatSeqEntry( - PSList *pool, + TCL_UNUSED(PSList *), PSEntry *entry) { PSEntry *next = PSList_Next(entry); - (void)pool; PSModMaskArr_Free(&entry->lastModMaskArr); ckfree(entry); return next; } @@ -975,27 +984,27 @@ { assert(dispPtr); if (dispPtr->metaModMask) { if (modMask & META_MASK) { - modMask &= ~(ModMask)META_MASK; + modMask &= ~META_MASK; modMask |= dispPtr->metaModMask; } } if (dispPtr->altModMask) { if (modMask & ALT_MASK) { - modMask &= ~(ModMask)ALT_MASK; + modMask &= ~ALT_MASK; modMask |= dispPtr->altModMask; } } return modMask; } static int ButtonNumberFromState( - ModMask state) + unsigned state) { if (!(state & ALL_BUTTONS)) { return 0; } if (state & Button1Mask) { return 1; } if (state & Button2Mask) { return 2; } if (state & Button3Mask) { return 3; } @@ -1646,11 +1655,11 @@ * 1 means append to that binding. If the existing binding is * for a callback function and not a Tcl command string, the * existing binding will always be replaced. */ { PatSeq *psPtr; - EventMask eventMask; + unsigned eventMask; char *oldStr; char *newStr; assert(bindPtr); assert(object); @@ -2171,11 +2180,11 @@ Tcl_Interp *interp; ScreenInfo *screenPtr; TkDisplay *dispPtr; TkDisplay *oldDispPtr; Event *curEvent; - TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *)tkwin; BindInfo *bindInfoPtr; Tcl_InterpState interpState; LookupTables *physTables; PatSeq *psPtr[2]; PatSeq *matchPtrBuf[32]; @@ -2461,11 +2470,10 @@ if (eventPtr->type != VirtualEvent) { LookupTables *virtTables = &bindInfoPtr->virtualEventTable.lookupTables; PatSeq *matchPtr = matchPtrArr[k]; PatSeq *mPtr; - PSList *psl[2]; /* * Note that virtual events cannot promote. */ @@ -2739,12 +2747,12 @@ /* helper function */ static int CompareModMasks( const PSModMaskArr *fstModMaskArr, const PSModMaskArr *sndModMaskArr, - ModMask fstModMask, - ModMask sndModMask) + unsigned fstModMask, + unsigned sndModMask) { int fstCount = 0; int sndCount = 0; int i; @@ -2764,15 +2772,15 @@ } } else { assert(PSModMaskArr_Size(fstModMaskArr) == PSModMaskArr_Size(sndModMaskArr)); for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) { - ModMask fstModMask = *PSModMaskArr_Get(fstModMaskArr, i); - ModMask sndModMask = *PSModMaskArr_Get(sndModMaskArr, i); + unsigned fstiModMask = *PSModMaskArr_Get(fstModMaskArr, i); + unsigned sndiModMask = *PSModMaskArr_Get(sndModMaskArr, i); - if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; } - if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; } + if (IsSubsetOf(fstiModMask, sndiModMask)) { ++sndCount; } + if (IsSubsetOf(sndiModMask, fstiModMask)) { ++fstCount; } } } /* Finally compare modifier masks of last pattern. */ @@ -2798,11 +2806,11 @@ { Window window; PSEntry *psEntry; PatSeq *bestPtr; PatSeq *bestPhysPtr; - ModMask bestModMask; + unsigned bestModMask; const PSModMaskArr *bestModMaskArr = NULL; int i, isModKeyOnly = 0; assert(dispPtr); assert(bindPtr); @@ -2865,12 +2873,12 @@ /* * Resolve the modifier mask for Alt and Mod keys. Unfortunately this * cannot be done in ParseEventDescription, otherwise this function would * be the better place. */ - ModMask modMask = ResolveModifiers(dispPtr, patPtr->modMask); - ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); + unsigned modMask = ResolveModifiers(dispPtr, patPtr->modMask); + unsigned curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); psEntry->expired = 1; /* remove it from promotion list */ psEntry->keepIt = 0; /* don't keep matching patterns */ if (IsSubsetOf(modMask, curModMask)) { @@ -3000,12 +3008,12 @@ } while (1) { char numStorage[TCL_INTEGER_SPACE]; const char *string; - Tcl_WideInt number; /* signed */ - Tcl_WideUInt unumber; /* unsigned */ + long long number; /* signed */ + unsigned long long unumber; /* unsigned */ /* * Find everything up to the next % character and append it to the * result string. */ @@ -3518,11 +3526,11 @@ * * Add a new definition for a virtual event. If the virtual event is * already defined, the new definition augments those that already exist. * * Results: - * The return value is TCL_ERROR if an error occured while creating the + * The return value is TCL_ERROR if an error occurred while creating the * virtual binding. In this case, an error message will be left in the * interp's result. If all went well then the return value is TCL_OK. * * Side effects: * The virtual event may cause future calls to Tk_BindEvent to behave @@ -3862,11 +3870,11 @@ Tcl_QueuePosition pos; TkPattern pat; Tk_Window tkwin; Tk_Window tkwin2; TkWindow *mainPtr; - EventMask eventMask; + unsigned eventMask; Tcl_Obj *userDataObj; int synch; int warp; unsigned count; unsigned flags; @@ -4046,10 +4054,13 @@ case EVENT_BUTTON: if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) { return TCL_ERROR; } if (flags & BUTTON) { + if (number >= Button4) { + number += (Button8 - Button4); + } event.general.xbutton.button = number; } else { badOpt = 1; } break; @@ -4399,35 +4410,19 @@ */ event.virt.user_data = userDataObj; Tcl_IncrRefCount(userDataObj); } - /* - * Now we have constructed the event, inject it into the event handling - * code. - */ - - if (synch) { - Tk_HandleEvent(&event.general); - } else { - Tk_QueueWindowEvent(&event.general, pos); - } - /* * We only allow warping if the window is mapped. */ if (warp && Tk_IsMapped(tkwin)) { TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display); Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window); - if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) { - Tcl_DoWhenIdle(DoWarp, dispPtr); - dispPtr->flags |= TK_DISPLAY_IN_WARP; - } - if (warpWindow != dispPtr->warpWindow) { if (warpWindow) { Tcl_Preserve(warpWindow); } if (dispPtr->warpWindow) { @@ -4436,10 +4431,35 @@ dispPtr->warpWindow = warpWindow; } dispPtr->warpMainwin = mainWin; dispPtr->warpX = event.general.xmotion.x; dispPtr->warpY = event.general.xmotion.y; + + /* + * Warping with respect to a window will be done when Tk_handleEvent + * below will run the event handlers and in particular TkPointerEvent. + * This allows to make grabs and warping work together robustly, that + * is without depending on a precise sequence of events. + * Warping with respect to the whole screen (i.e. dispPtr->warpWindow + * is NULL) is run directly here. + */ + + if (!dispPtr->warpWindow) { + TkpWarpPointer(dispPtr); + XForceScreenSaver(dispPtr->display, ScreenSaverReset); + } + } + + /* + * Now we have constructed the event, inject it into the event handling + * code. + */ + + if (synch) { + Tk_HandleEvent(&event.general); + } else { + Tk_QueueWindowEvent(&event.general, pos); } } Tcl_ResetResult(interp); return TCL_OK; @@ -4508,50 +4528,51 @@ } /* *------------------------------------------------------------------------- * - * DoWarp -- + * TkDoWarpWrtWin -- * - * Perform Warping of X pointer. Executed as an idle handler only. + * Perform warping of mouse pointer with respect to a window. * * Results: * None * * Side effects: - * X Pointer will move to a new location. + * Mouse pointer moves to a new location. * *------------------------------------------------------------------------- */ -static void -DoWarp( - ClientData clientData) +void +TkDoWarpWrtWin( + TkDisplay *dispPtr) { - TkDisplay *dispPtr = (TkDisplay *)clientData; - - assert(clientData); + assert(dispPtr); /* - * DoWarp was scheduled only if the window was mapped. It needs to be - * still mapped at the time the present idle callback is executed. Also - * one needs to guard against window destruction in the meantime. - * Finally, the case warpWindow == NULL is special in that it means - * the whole screen. + * A NULL warpWindow means warping with respect to the whole screen. + * We want to warp here only if we're warping with respect to a window. */ - if (!dispPtr->warpWindow || - (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None)) { - TkpWarpPointer(dispPtr); - XForceScreenSaver(dispPtr->display, ScreenSaverReset); - } - if (dispPtr->warpWindow) { - Tcl_Release(dispPtr->warpWindow); - dispPtr->warpWindow = NULL; + + /* + * Warping with respect to a window can only be done if the window is + * mapped. This was checked in HandleEvent. The window needs to be + * still mapped at the time the present code is executed. Also + * one needs to guard against window destruction in the meantime, + * which could have happened as a side effect of an event handler. + */ + + if (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None) { + TkpWarpPointer(dispPtr); + XForceScreenSaver(dispPtr->display, ScreenSaverReset); + } + Tcl_Release(dispPtr->warpWindow); + dispPtr->warpWindow = NULL; } - dispPtr->flags &= ~TK_DISPLAY_IN_WARP; } /* *------------------------------------------------------------------------- * @@ -4634,11 +4655,11 @@ * documentation for details. */ int create, /* 0 means don't create the entry if it doesn't already exist. * 1 means create. */ int allowVirtual, /* 0 means that virtual events are not allowed in the sequence. * 1 otherwise. */ - EventMask *maskPtr) /* *maskPtr is filled in with the event types on which this + unsigned *maskPtr) /* *maskPtr is filled in with the event types on which this * pattern sequence depends. */ { unsigned patsBufSize = 1; unsigned numPats; unsigned totalCount = 0; @@ -4648,12 +4669,12 @@ PatSeq *psPtr; Tcl_HashEntry *hPtr; int isNew; unsigned count; unsigned maxCount = 0; - EventMask eventMask = 0; - ModMask modMask = 0; + unsigned eventMask = 0; + unsigned modMask = 0; PatternTableKey key; assert(lookupTables); assert(eventString); @@ -4823,14 +4844,14 @@ ParseEventDescription( Tcl_Interp *interp, /* For error messages. */ const char **eventStringPtr,/* On input, holds a pointer to start of event string. On exit, * gets pointer to rest of string after parsed event. */ TkPattern *patPtr, /* Filled with the pattern parsed from the event string. */ - EventMask *eventMaskPtr) /* Filled with event mask of matched event. */ + unsigned *eventMaskPtr) /* Filled with event mask of matched event. */ { const char *p; - EventMask eventMask = 0; + unsigned eventMask = 0; unsigned count = 1; assert(eventStringPtr); assert(patPtr); assert(eventMaskPtr); @@ -4999,21 +5020,21 @@ patPtr, 0, Tcl_ObjPrintf("specified button \"%s\" for non-button event", field), "NON_BUTTON"); } #if SUPPORT_ADDITIONAL_MOTION_SYNTAX - patPtr->modMask |= TkGetButtonMask(button); + patPtr->modMask |= Tk_GetButtonMask(button); p = SkipFieldDelims(p); while (*p && *p != '>') { p = SkipFieldDelims(GetField(p, field, sizeof(field))); if ((button = GetButtonNumber(field)) == 0) { return FinalizeParseEventDescription( interp, patPtr, 0, Tcl_ObjPrintf("bad button number \"%s\"", field), "BUTTON"); } - patPtr->modMask |= TkGetButtonMask(button); + patPtr->modMask |= Tk_GetButtonMask(button); } patPtr->info = ButtonNumberFromState(patPtr->modMask); #endif } else { return FinalizeParseEventDescription( @@ -5139,11 +5160,11 @@ Tcl_AppendToObj(patternObj, &c, 1); } else if (patPtr->eventType == VirtualEvent) { assert(patPtr->name); Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->name); } else { - ModMask modMask; + unsigned modMask; const ModInfo *modPtr; /* * It's a more general event specification. First check for "Double", * "Triple", "Quadruple", then modifiers, then event type, then keysym @@ -5187,20 +5208,20 @@ } break; } case ButtonPress: case ButtonRelease: - assert(patPtr->info <= Button9); - Tcl_AppendPrintfToObj(patternObj, "-%d", (int) patPtr->info); + assert(patPtr->info <= 13); + Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned) ((patPtr->info > 7) ? (patPtr->info - 4) : patPtr->info)); break; #if PRINT_SHORT_MOTION_SYNTAX case MotionNotify: { - ModMask mask = patPtr->modMask; + unsigned mask = patPtr->modMask; while (mask & ALL_BUTTONS) { - int button = ButtonNumberFromState(mask); - Tcl_AppendPrintfToObj(patternObj, "-%d", button); - mask &= ~TkGetButtonMask(button); + unsigned button = ButtonNumberFromState(mask); + Tcl_AppendPrintfToObj(patternObj, "-%u", (button > 7) ? (button - 4) : button); + mask &= ~Tk_GetButtonMask(button); } break; } #endif } @@ -5233,18 +5254,52 @@ KeySym TkStringToKeysym( const char *name) /* Name of a keysym. */ { #ifdef REDO_KEYSYM_LOOKUP - Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&keySymTable, name); + Tcl_HashEntry *hPtr; +#endif /* REDO_KEYSYM_LOOKUP */ + int keysym; + size_t len = TkUtfToUniChar(name, &keysym); + if (name[len] == '\0') { + if (!Tcl_UniCharIsPrint(keysym)) { + /* This form not supported */ + } else if ((unsigned)(keysym - 0x21) <= 0x5D) { + return keysym; + } else if ((unsigned)(keysym - 0xA1) <= 0x5E) { + return keysym; + } else if (keysym == 0x20AC) { + return 0x20AC; + } else { + return keysym + 0x1000000; + } + } +#ifdef REDO_KEYSYM_LOOKUP + if ((name[0] == 'U') && ((unsigned)(name[1] - '0') <= 9)) { + char *p = (char *)name + 1; + keysym = strtol(p, &p, 16); + if ((p >= name + 5) && (p <= name + 9) && !*p && (keysym >= 0x20) + && ((unsigned)(keysym - 0x7F) > 0x20)) { + if ((unsigned)(keysym - 0x21) <= 0x5D) { + return keysym; + } else if ((unsigned)(keysym - 0xA1) <= 0x5E) { + return keysym; + } else if (keysym == 0x20AC) { + return keysym; + } + return keysym + 0x1000000; + } + } +#endif +#ifdef REDO_KEYSYM_LOOKUP + hPtr = Tcl_FindHashEntry(&keySymTable, name); if (hPtr) { return (KeySym) Tcl_GetHashValue(hPtr); } - assert(name); - if (strlen(name) == 1u) { - KeySym keysym = (KeySym) (unsigned char) name[0]; + if (((unsigned)(name[0]-1) < 0x7F) && !name[1]) { + keysym = (unsigned char) name[0]; if (TkKeysymToString(keysym)) { return keysym; } } @@ -5273,20 +5328,41 @@ const char * TkKeysymToString( KeySym keysym) { #ifdef REDO_KEYSYM_LOOKUP - Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym); + Tcl_HashEntry *hPtr; +#endif + + if ((unsigned)(keysym - 0x21) <= 0x5D) { + keysym += 0x1000000; + } else if ((unsigned)(keysym - 0xA1) <= 0x5E) { + keysym += 0x1000000; + } else if (keysym == 0x20AC) { + keysym += 0x1000000; + } + if ((keysym >= 0x1000020) && (keysym <= 0x110FFFF) + && ((unsigned)(keysym - 0x100007F) > 0x20)) { + char buf[10]; + if (Tcl_UniCharIsPrint(keysym-0x1000000)) { + buf[TkUniCharToUtf(keysym - 0x1000000, buf)] = '\0'; + } else if (keysym >= 0x1010000) { + sprintf(buf, "U%08X", (int)(keysym - 0x1000000)); + } else { + sprintf(buf, "U%04X", (int)(keysym - 0x1000000)); + } + return Tk_GetUid(buf); + } + +#ifdef REDO_KEYSYM_LOOKUP + hPtr = Tcl_FindHashEntry(&nameTable, INT2PTR(keysym)); if (hPtr) { return (const char *)Tcl_GetHashValue(hPtr); } #endif /* REDO_KEYSYM_LOOKUP */ - if (keysym > (KeySym)0x1008FFFF) { - return NULL; - } return XKeysymToString(keysym); } /* *---------------------------------------------------------------------- @@ -5314,39 +5390,10 @@ TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp); BindingTable *bindPtr = winPtr->mainPtr->bindingTable; return &bindPtr->curEvent->xev; } - -/* - *---------------------------------------------------------------------- - * - * TkpCancelWarp -- - * - * This function cancels an outstanding pointer warp and - * is called during tear down of the display. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkpCancelWarp( - TkDisplay *dispPtr) -{ - assert(dispPtr); - - if (dispPtr->flags & TK_DISPLAY_IN_WARP) { - Tcl_CancelIdleCall(DoWarp, dispPtr); - dispPtr->flags &= ~TK_DISPLAY_IN_WARP; - } -} /* *---------------------------------------------------------------------- * * TkpDumpPS -- Index: generic/tkBitmap.c ================================================================== --- generic/tkBitmap.c +++ generic/tkBitmap.c @@ -3,12 +3,12 @@ * * This file maintains a database of read-only bitmaps for the Tk * toolkit. This allows bitmaps to be shared between widgets and also * avoids interactions with the X server. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkBusy.c ================================================================== --- generic/tkBusy.c +++ generic/tkBusy.c @@ -123,14 +123,13 @@ */ static void BusyCustodyProc( ClientData clientData, /* Information about the busy window. */ - Tk_Window tkwin) /* Not used. */ + TCL_UNUSED(Tk_Window)) /* Not used. */ { Busy *busyPtr = (Busy *)clientData; - (void)tkwin; Tk_DeleteEventHandler(busyPtr->tkBusy, StructureNotifyMask, BusyEventProc, busyPtr); TkpHideBusyWindow(busyPtr); busyPtr->tkBusy = NULL; @@ -156,18 +155,15 @@ *---------------------------------------------------------------------- */ static void BusyGeometryProc( - ClientData dummy, /* Information about window that got new + TCL_UNUSED(void *), /* Information about window that got new * preferred geometry. */ - Tk_Window tkwin) /* Other Tk-related information about the + TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { - (void)dummy; - (void)tkwin; - /* Should never get here */ } /* *---------------------------------------------------------------------- @@ -807,21 +803,21 @@ BUSY_BUSYWINDOW, BUSY_CGET, BUSY_CONFIGURE, BUSY_CURRENT, BUSY_FORGET, BUSY_HOLD, BUSY_STATUS }; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "options ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "options ?arg ...?"); return TCL_ERROR; } /* * [tk busy ] command shortcut. */ if (Tcl_GetString(objv[1])[0] == '.') { if (objc%2 == 1) { - Tcl_WrongNumArgs(interp, 1, objv, "window ?option value ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "window ?-option value ...?"); return TCL_ERROR; } return HoldBusy(busyTablePtr, interp, objv[1], objc-2, objv+2); } @@ -863,11 +859,11 @@ Tcl_Release(busyPtr); return result; case BUSY_CONFIGURE: if (objc < 3) { - Tcl_WrongNumArgs(interp, 2, objv, "window ?option? ?value ...?"); + Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?"); return TCL_ERROR; } busyPtr = GetBusy(interp, busyTablePtr, objv[2]); if (busyPtr == NULL) { return TCL_ERROR; @@ -898,11 +894,11 @@ hPtr = Tcl_NextHashEntry(&cursor)) { busyPtr = (Busy *)Tcl_GetHashValue(hPtr); if (pattern == NULL || Tcl_StringCaseMatch(Tk_PathName(busyPtr->tkRef), pattern, 0)) { Tcl_ListObjAppendElement(interp, objPtr, - TkNewWindowObj(busyPtr->tkRef)); + Tk_NewWindowObj(busyPtr->tkRef)); } } Tcl_SetObjResult(interp, objPtr); return TCL_OK; } @@ -920,11 +916,11 @@ Tcl_EventuallyFree(busyPtr, (Tcl_FreeProc *)DestroyBusy); return TCL_OK; case BUSY_HOLD: if (objc < 3 || objc%2 != 1) { - Tcl_WrongNumArgs(interp, 2, objv, "window ?option value ...?"); + Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?"); return TCL_ERROR; } return HoldBusy(busyTablePtr, interp, objv[2], objc-3, objv+3); case BUSY_STATUS: Index: generic/tkButton.c ================================================================== --- generic/tkButton.c +++ generic/tkButton.c @@ -3,12 +3,12 @@ * * This module implements a collection of button-like widgets for the Tk * toolkit. The widgets implemented include buttons, checkbuttons, * radiobuttons, and labels. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -758,11 +758,11 @@ if (ConfigureButton(interp, butPtr, objc - 2, objv + 2) != TCL_OK) { Tk_DestroyWindow(butPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(butPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(butPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- Index: generic/tkButton.h ================================================================== --- generic/tkButton.h +++ generic/tkButton.h @@ -2,11 +2,11 @@ * tkButton.h -- * * Declarations of types and functions used to implement button-like * widgets. * - * Copyright (c) 1996-1998 by Sun Microsystems, Inc. + * Copyright © 1996-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkCanvArc.c ================================================================== --- generic/tkCanvArc.c +++ generic/tkCanvArc.c @@ -1,12 +1,12 @@ /* * tkCanvArc.c -- * * This file implements arc items for canvas widgets. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -705,16 +705,15 @@ *-------------------------------------------------------------- */ static void DeleteArc( - Tk_Canvas canvas, /* Info about overall canvas. */ + TCL_UNUSED(Tk_Canvas), /* Info about overall canvas. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { - ArcItem *arcPtr = (ArcItem *) itemPtr; - (void)canvas; + ArcItem *arcPtr = (ArcItem *)itemPtr; Tk_DeleteOutline(display, &(arcPtr->outline)); if (arcPtr->numOutlinePoints != 0) { ckfree(arcPtr->outlinePtr); } @@ -792,17 +791,17 @@ /* * Make sure that the first coordinates are the lowest ones. */ if (arcPtr->bbox[1] > arcPtr->bbox[3]) { - double tmp = arcPtr->bbox[3]; + tmp = arcPtr->bbox[3]; arcPtr->bbox[3] = arcPtr->bbox[1]; arcPtr->bbox[1] = tmp; } if (arcPtr->bbox[0] > arcPtr->bbox[2]) { - double tmp = arcPtr->bbox[2]; + tmp = arcPtr->bbox[2]; arcPtr->bbox[2] = arcPtr->bbox[0]; arcPtr->bbox[0] = tmp; } @@ -898,23 +897,21 @@ DisplayArc( Tk_Canvas canvas, /* Canvas that contains item. */ Tk_Item *itemPtr, /* Item to be displayed. */ Display *display, /* Display on which to draw item. */ Drawable drawable, /* Pixmap or window in which to draw item. */ - int x, int y, /* Describes region of canvas that must be */ - int width, int height) /* redisplayed (not used). */ + TCL_UNUSED(int), /* Describes region of canvas that must be */ + TCL_UNUSED(int), /* redisplayed (not used). */ + TCL_UNUSED(int), + TCL_UNUSED(int)) { ArcItem *arcPtr = (ArcItem *) itemPtr; short x1, y1, x2, y2; int start, extent, dashnumber; double lineWidth; Tk_State state = itemPtr->state; Pixmap stipple; - (void)x; - (void)y; - (void)width; - (void)height; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } lineWidth = arcPtr->outline.width; @@ -1646,11 +1643,11 @@ /* * First compute the two points that lie at the centers of the ends of the * curved arc segment, which are marked with X's in the figure below: * * - * * * * + * * * * * * * * * * * * * * * * * * * * * * * X * * X @@ -1999,11 +1996,11 @@ static int ArcToPostscript( Tcl_Interp *interp, /* Leave Postscript or error message here. */ Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ - int prepass) /* 1 means this is a prepass to collect font + TCL_UNUSED(int)) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; double y1, y2, ang1, ang2; @@ -2012,11 +2009,10 @@ XColor *fillColor; Pixmap fillStipple; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; - (void)prepass; y1 = Tk_CanvasPsY(canvas, arcPtr->bbox[1]); y2 = Tk_CanvasPsY(canvas, arcPtr->bbox[3]); ang1 = arcPtr->start; ang2 = ang1 + arcPtr->extent; @@ -2195,22 +2191,20 @@ *-------------------------------------------------------------- */ static int StyleParseProc( - ClientData dummy, /* some flags.*/ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Used for reporting errors. */ - Tk_Window tkwin, /* Window containing canvas widget. */ + TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset) /* Offset into item. */ { int c; size_t length; Style *stylePtr = (Style *) (widgRec + offset); - (void)dummy; - (void)tkwin; if (value == NULL || *value == 0) { *stylePtr = PIESLICE_STYLE; return TCL_OK; } @@ -2260,22 +2254,19 @@ *-------------------------------------------------------------- */ static const char * StylePrintProc( - ClientData dummy, /* Ignored. */ - Tk_Window tkwin, /* Ignored. */ + TCL_UNUSED(void *), /* Ignored. */ + TCL_UNUSED(Tk_Window), /* Ignored. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset, /* Offset into item. */ - Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with + TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ { Style *stylePtr = (Style *) (widgRec + offset); - (void)dummy; - (void)tkwin; - (void)freeProcPtr; if (*stylePtr == ARC_STYLE) { return "arc"; } else if (*stylePtr == CHORD_STYLE) { return "chord"; Index: generic/tkCanvBmap.c ================================================================== --- generic/tkCanvBmap.c +++ generic/tkCanvBmap.c @@ -1,12 +1,12 @@ /* * tkCanvBmap.c -- * * This file implements bitmap items for canvas widgets. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkCanvImg.c ================================================================== --- generic/tkCanvImg.c +++ generic/tkCanvImg.c @@ -1,12 +1,12 @@ /* * tkCanvImg.c -- * * This file implements image items for canvas widgets. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkCanvLine.c ================================================================== --- generic/tkCanvLine.c +++ generic/tkCanvLine.c @@ -1,13 +1,13 @@ /* * tkCanvLine.c -- * * This file implements line items for canvas widgets. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -603,16 +603,15 @@ *-------------------------------------------------------------- */ static void DeleteLine( - Tk_Canvas canvas, /* Info about overall canvas widget. */ + TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { LineItem *linePtr = (LineItem *) itemPtr; - (void)canvas; Tk_DeleteOutline(display, &linePtr->outline); if (linePtr->coordPtr != NULL) { ckfree(linePtr->coordPtr); } @@ -708,11 +707,11 @@ } } tsoffset = &linePtr->outline.tsoffset; if (tsoffset->flags & TK_OFFSET_INDEX) { - double *coordPtr = linePtr->coordPtr + coordPtr = linePtr->coordPtr + (tsoffset->flags & ~TK_OFFSET_INDEX); if (tsoffset->flags <= 0) { coordPtr = linePtr->coordPtr; if ((linePtr->arrow == ARROWS_FIRST) @@ -832,24 +831,21 @@ DisplayLine( Tk_Canvas canvas, /* Canvas that contains item. */ Tk_Item *itemPtr, /* Item to be displayed. */ Display *display, /* Display on which to draw item. */ Drawable drawable, /* Pixmap or window in which to draw item. */ - int x, int y, int width, int height) - /* Describes region of canvas that must be - * redisplayed (not used). */ + TCL_UNUSED(int), /* Describes region of canvas that must be */ + TCL_UNUSED(int), /* redisplayed (not used). */ + TCL_UNUSED(int), + TCL_UNUSED(int)) { - LineItem *linePtr = (LineItem *) itemPtr; + LineItem *linePtr = (LineItem *)itemPtr; XPoint staticPoints[MAX_STATIC_POINTS*3]; XPoint *pointPtr; double linewidth; int numPoints; Tk_State state = itemPtr->state; - (void)x; - (void)y; - (void)width; - (void)height; if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) { return; } @@ -1699,12 +1695,10 @@ linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { - int i; - i = 2*(linePtr->numPoints-1); linePtr->coordPtr[i] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1]; ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; @@ -1764,11 +1758,11 @@ } *indexPtr = idx; return TCL_OK; } - string = TkGetStringFromObj(obj, &length); + string = Tcl_GetStringFromObj(obj, &length); if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; char *end; @@ -1929,13 +1923,13 @@ *-------------------------------------------------------------- */ static int ParseArrowShape( - ClientData dummy, /* Not used. */ + TCL_UNUSED(void *), /* Not used. */ Tcl_Interp *interp, /* Used for error reporting. */ - Tk_Window tkwin, /* Not used. */ + TCL_UNUSED(Tk_Window), /* Not used. */ const char *value, /* Textual specification of arrow shape. */ char *recordPtr, /* Pointer to item record in which to store * arrow information. */ TkSizeT offset) /* Offset of shape information in widget * record. */ @@ -1942,12 +1936,10 @@ { LineItem *linePtr = (LineItem *) recordPtr; double a, b, c; int argc; const char **argv = NULL; - (void)dummy; - (void)tkwin; if ((size_t)offset != offsetof(LineItem, arrowShapeA)) { Tcl_Panic("ParseArrowShape received bogus offset"); } @@ -1999,23 +1991,20 @@ *-------------------------------------------------------------- */ static const char * PrintArrowShape( - ClientData dummy, /* Not used. */ - Tk_Window tkwin, /* Window associated with linePtr's widget. */ + TCL_UNUSED(void *), /* Not used. */ + TCL_UNUSED(Tk_Window), /* Window associated with linePtr's widget. */ char *recordPtr, /* Pointer to item record containing current * shape information. */ - TkSizeT offset, /* Offset of arrow information in record. */ + TCL_UNUSED(TkSizeT), /* Offset of arrow information in record. */ Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free * string here. */ { LineItem *linePtr = (LineItem *) recordPtr; char *buffer = (char *)ckalloc(120); - (void)dummy; - (void)tkwin; - (void)offset; sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA, linePtr->arrowShapeB, linePtr->arrowShapeC); *freeProcPtr = TCL_DYNAMIC; return buffer; @@ -2039,22 +2028,20 @@ *-------------------------------------------------------------- */ static int ArrowParseProc( - ClientData dummy, /* some flags.*/ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Used for reporting errors. */ - Tk_Window tkwin, /* Window containing canvas widget. */ + TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset) /* Offset into item. */ { int c; size_t length; Arrows *arrowPtr = (Arrows *) (widgRec + offset); - (void)dummy; - (void)tkwin; if (value == NULL || *value == 0) { *arrowPtr = ARROWS_NONE; return TCL_OK; } @@ -2108,22 +2095,19 @@ *-------------------------------------------------------------- */ static const char * ArrowPrintProc( - ClientData dummy, /* Ignored. */ - Tk_Window tkwin, /* Window containing canvas widget. */ + TCL_UNUSED(void *), /* Ignored. */ + TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset, /* Offset into item. */ - Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with + TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ { Arrows *arrowPtr = (Arrows *) (widgRec + offset); - (void)dummy; - (void)tkwin; - (void)freeProcPtr; switch (*arrowPtr) { case ARROWS_FIRST: return "first"; case ARROWS_LAST: @@ -2314,11 +2298,11 @@ static int LineToPostscript( Tcl_Interp *interp, /* Leave Postscript or error message here. */ Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ - int prepass) /* 1 means this is a prepass to collect font + TCL_UNUSED(int)) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; int style; @@ -2326,11 +2310,10 @@ XColor *color; Pixmap stipple; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; - (void)prepass; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } Index: generic/tkCanvPoly.c ================================================================== --- generic/tkCanvPoly.c +++ generic/tkCanvPoly.c @@ -1,13 +1,13 @@ /* * tkCanvPoly.c -- * * This file implements polygon items for canvas widgets. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-2000 Ajuba Solutions. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -874,16 +874,14 @@ DisplayPolygon( Tk_Canvas canvas, /* Canvas that contains item. */ Tk_Item *itemPtr, /* Item to be displayed. */ Display *display, /* Display on which to draw item. */ Drawable drawable, /* Pixmap or window in which to draw item. */ - TCL_UNUSED(int), - TCL_UNUSED(int), + TCL_UNUSED(int), /* Describes region of canvas that must be */ + TCL_UNUSED(int), /* redisplayed (not used). */ TCL_UNUSED(int), TCL_UNUSED(int)) - /* Describes region of canvas that must be - * redisplayed (not used). */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; Tk_State state = itemPtr->state; Pixmap stipple = polyPtr->fillStipple; double linewidth = polyPtr->outline.width; @@ -1690,11 +1688,11 @@ } *indexPtr = idx; return TCL_OK; } - string = TkGetStringFromObj(obj, &length); + string = Tcl_GetStringFromObj(obj, &length); if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; char *end; Index: generic/tkCanvPs.c ================================================================== --- generic/tkCanvPs.c +++ generic/tkCanvPs.c @@ -3,12 +3,12 @@ * * This module provides Postscript output support for canvases, including * the "postscript" widget command plus a few utility functions used for * generating Postscript. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -1601,11 +1601,11 @@ switch (colorLevel) { case 0: { /* * Generate data for image in monochrome mode. No attempt at * dithering is made--instead, just set a threshold. To handle - * transparecies we need to output two lines: one for the black + * transparencies we need to output two lines: one for the black * pixels, one for the white ones. */ unsigned char mask = 0x80; unsigned char data = 0x00; Index: generic/tkCanvText.c ================================================================== --- generic/tkCanvText.c +++ generic/tkCanvText.c @@ -1,12 +1,12 @@ /* * tkCanvText.c -- * * This file implements text items for canvas widgets. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -1018,11 +1018,11 @@ TkSizeT byteCount; char *newStr, *text; const char *string; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - string = TkGetStringFromObj(obj, &byteCount); + string = Tcl_GetStringFromObj(obj, &byteCount); text = textPtr->text; if (index == TCL_INDEX_NONE) { index = 0; @@ -1373,11 +1373,11 @@ */ static int GetTextIndex( Tcl_Interp *interp, /* Used for error reporting. */ - Tk_Canvas canvas, /* Canvas containing item. */ + TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */ Tk_Item *itemPtr, /* Item for which the index is being * specified. */ Tcl_Obj *obj, /* Specification of a particular character in * itemPtr's text. */ TkSizeT *indexPtr) /* Where to store converted character @@ -1386,11 +1386,10 @@ TextItem *textPtr = (TextItem *) itemPtr; TkSizeT length, idx; int c; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; const char *string; - (void)canvas; if (TCL_OK == TkGetIntForIndex(obj, textPtr->numChars - 1, 1, &idx)) { if (idx == TCL_INDEX_NONE) { idx = 0; } else if (idx > textPtr->numChars) { @@ -1398,11 +1397,11 @@ } *indexPtr = idx; return TCL_OK; } - string = TkGetStringFromObj(obj, &length); + string = Tcl_GetStringFromObj(obj, &length); c = string[0]; if ((c == 'i') && (strncmp(string, "insert", length) == 0)) { *indexPtr = textPtr->insertPos; @@ -1424,11 +1423,11 @@ return TCL_ERROR; } *indexPtr = textInfoPtr->selectLast; } else if (c == '@') { int x, y; - double tmp, c = textPtr->cosine, s = textPtr->sine; + double tmp, cs = textPtr->cosine, s = textPtr->sine; char *end; const char *p; p = string+1; tmp = strtod(p, &end); @@ -1443,11 +1442,11 @@ } y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5); x -= (int) textPtr->drawOrigin[0]; y -= (int) textPtr->drawOrigin[1]; *indexPtr = Tk_PointToChar(textPtr->textLayout, - (int) (x*c - y*s), (int) (y*c + x*s)); + (int) (x*cs - y*s), (int) (y*cs + x*s)); } else { /* * Some of the paths here leave messages in the interp's result, so we * have to clear it out before storing our own message. */ @@ -1476,18 +1475,17 @@ *-------------------------------------------------------------- */ static void SetTextCursor( - Tk_Canvas canvas, /* Record describing canvas widget. */ + TCL_UNUSED(Tk_Canvas), /* Record describing canvas widget. */ Tk_Item *itemPtr, /* Text item in which cursor position is to be * set. */ TkSizeT index) /* Character index of character just before * which cursor is to be positioned. */ { TextItem *textPtr = (TextItem *) itemPtr; - (void)canvas; if (index == TCL_INDEX_NONE) { textPtr->insertPos = 0; } else if (index > textPtr->numChars) { textPtr->insertPos = textPtr->numChars; @@ -1516,11 +1514,11 @@ *-------------------------------------------------------------- */ static TkSizeT GetSelText( - Tk_Canvas canvas, /* Canvas containing selection. */ + TCL_UNUSED(Tk_Canvas), /* Canvas containing selection. */ Tk_Item *itemPtr, /* Text item containing selection. */ TkSizeT offset, /* Byte offset within selection of first * character to be returned. */ char *buffer, /* Location in which to place selection. */ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer, @@ -1530,11 +1528,10 @@ TextItem *textPtr = (TextItem *) itemPtr; TkSizeT byteCount; char *text; const char *selStart, *selEnd; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - (void)canvas; if (((int)textInfoPtr->selectFirst < 0) || (textInfoPtr->selectFirst + 1 > textInfoPtr->selectLast + 1)) { return 0; } Index: generic/tkCanvUtil.c ================================================================== --- generic/tkCanvUtil.c +++ generic/tkCanvUtil.c @@ -2,11 +2,11 @@ * tkCanvUtil.c -- * * This file contains a collection of utility functions used by the * implementations of various canvas item types. * - * Copyright (c) 1994 Sun Microsystems, Inc. + * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -772,11 +772,11 @@ if (methods == NULL) { methods = InitSmoothMethods(interp); } /* - * Backward compatability hack. + * Backward compatibility hack. */ if (strncmp(value, "bezier", length) == 0) { smooth = &tkBezierSmoothMethod; } Index: generic/tkCanvWind.c ================================================================== --- generic/tkCanvWind.c +++ generic/tkCanvWind.c @@ -1,12 +1,12 @@ /* * tkCanvWind.c -- * * This file implements window items for canvas widgets. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -85,11 +85,11 @@ static void TranslateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); static int WinItemCoords(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); -static void WinItemLostSlaveProc(ClientData clientData, +static void WinItemLostContentProc(ClientData clientData, Tk_Window tkwin); static void WinItemRequestProc(ClientData clientData, Tk_Window tkwin); static void WinItemStructureProc(ClientData clientData, XEvent *eventPtr); @@ -142,11 +142,11 @@ */ static const Tk_GeomMgr canvasGeomType = { "canvas", /* name */ WinItemRequestProc, /* requestProc */ - WinItemLostSlaveProc, /* lostSlaveProc */ + WinItemLostContentProc, /* lostContentProc */ }; /* *-------------------------------------------------------------- * @@ -1100,29 +1100,29 @@ } /* *-------------------------------------------------------------- * - * WinItemLostSlaveProc -- + * WinItemLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all canvas-related information about the slave. + * Forgets all canvas-related information about the content window. * *-------------------------------------------------------------- */ static void -WinItemLostSlaveProc( - ClientData clientData, /* WindowItem structure for slave window that +WinItemLostContentProc( + ClientData clientData, /* WindowItem structure for content window window that * was stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ + Tk_Window tkwin) /* Tk's handle for the content window. */ { WindowItem *winItemPtr = (WindowItem *)clientData; Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas); (void)tkwin; Index: generic/tkCanvas.c ================================================================== --- generic/tkCanvas.c +++ generic/tkCanvas.c @@ -3,13 +3,13 @@ * * This module implements canvas widgets for the Tk toolkit. A canvas * displays a background and a collection of graphical objects such as * rectangles, lines, and texts. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -797,11 +797,11 @@ CanvasFetchSelection, canvasPtr, XA_STRING); if (ConfigureCanvas(interp, canvasPtr, argc-2, argv+2, 0) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, TkNewWindowObj(canvasPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(canvasPtr->tkwin)); return TCL_OK; error: Tk_DestroyWindow(canvasPtr->tkwin); return TCL_ERROR; @@ -837,12 +837,12 @@ Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent * compiler warning. */ TagSearch *searchPtr = NULL;/* Allocated by first TagSearchScan, freed by * TagSearchDestroy */ - int index; - static const char *const optionStrings[] = { + int idx; + static const char *const canvasOptionStrings[] = { "addtag", "bbox", "bind", "canvasx", "canvasy", "cget", "configure", "coords", "create", "dchars", "delete", "dtag", "find", "focus", "gettags", "icursor", "image", "imove", "index", "insert", @@ -850,11 +850,11 @@ "lower", "move", "moveto", "postscript", "raise", "rchars", "rotate", "scale", "scan", "select", "type", "xview", "yview", NULL }; - enum options { + enum canvasOptionStringsEnum { CANV_ADDTAG, CANV_BBOX, CANV_BIND, CANV_CANVASX, CANV_CANVASY, CANV_CGET, CANV_CONFIGURE, CANV_COORDS, CANV_CREATE, CANV_DCHARS, CANV_DELETE, CANV_DTAG, CANV_FIND, CANV_FOCUS, CANV_GETTAGS, CANV_ICURSOR, CANV_IMAGE, CANV_IMOVE, CANV_INDEX, CANV_INSERT, @@ -867,18 +867,18 @@ if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[1], canvasOptionStrings, "option", 0, + &idx) != TCL_OK) { return TCL_ERROR; } Tcl_Preserve(canvasPtr); result = TCL_OK; - switch ((enum options) index) { + switch ((enum canvasOptionStringsEnum)idx) { case CANV_ADDTAG: if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "tag searchCommand ?arg ...?"); result = TCL_ERROR; goto done; @@ -986,11 +986,11 @@ canvasPtr->bindingTable = Tk_CreateBindingTable(interp); } if (objc == 5) { int append = 0; - unsigned long mask; + unsigned int mask; const char *argv4 = Tcl_GetString(objv[4]); if (argv4[0] == 0) { result = Tk_DeleteBinding(interp, canvasPtr->bindingTable, object, Tcl_GetString(objv[3])); @@ -1034,11 +1034,11 @@ object, Tcl_GetString(objv[3]), argv4, append); if (mask == 0) { result = TCL_ERROR; goto done; } - if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask + if (mask & ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, canvasPtr->bindingTable, @@ -1245,11 +1245,10 @@ break; } case CANV_CREATE: { Tk_ItemType *typePtr; Tk_ItemType *matchPtr = NULL; - Tk_Item *itemPtr; int isNew = 0; Tcl_HashEntry *entryPtr; const char *arg; TkSizeT length; @@ -1256,11 +1255,11 @@ if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?"); result = TCL_ERROR; goto done; } - arg = TkGetStringFromObj(objv[2], &length); + arg = Tcl_GetStringFromObj(objv[2], &length); c = arg[0]; /* * Lock because the list of types is a global resource that could be * updated by another thread. That's fairly unlikely, but not @@ -1661,11 +1660,10 @@ break; } } break; case CANV_LOWER: { - Tk_Item *itemPtr; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?belowThis?"); result = TCL_ERROR; goto done; @@ -1925,22 +1923,22 @@ if (objc < 5) { Tcl_WrongNumArgs(interp, 2, objv, "mark|dragto x y ?dragGain?"); result = TCL_ERROR; } else if (Tcl_GetIndexFromObj(interp, objv[2], optionStrings, - "scan option", 0, &index) != TCL_OK) { + "scan option", 0, &idx) != TCL_OK) { result = TCL_ERROR; - } else if ((objc != 5) && (objc != 5+index)) { - Tcl_WrongNumArgs(interp, 3, objv, index?"x y ?gain?":"x y"); + } else if ((objc != 5) && (objc != 5+idx)) { + Tcl_WrongNumArgs(interp, 3, objv, idx?"x y ?gain?":"x y"); result = TCL_ERROR; } else if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){ result = TCL_ERROR; } else if ((objc == 6) && (Tcl_GetIntFromObj(interp, objv[5], &gain) != TCL_OK)) { result = TCL_ERROR; - } else if (!index) { + } else if (!idx) { canvasPtr->scanX = x; canvasPtr->scanXOrigin = canvasPtr->xOrigin; canvasPtr->scanY = y; canvasPtr->scanYOrigin = canvasPtr->yOrigin; } else { @@ -2501,11 +2499,11 @@ * *---------------------------------------------------------------------- */ static void DecomposeMaskToShiftAndBits( - unsigned long mask, /* The pixel mask to examine */ + unsigned int mask, /* The pixel mask to examine */ int *shift, /* Where to put the shift count (position of lowest bit) */ int *bits) /* Where to put the bit count (width of the pixel mask) */ { int i; @@ -2847,11 +2845,11 @@ #ifdef DEBUG_DRAWCANVAS Tcl_AppendResult(interp, " {", NULL); #endif for(x = 0; x < blockPtr.width; ++x) { - unsigned long pixel = 0; + unsigned int pixel = 0; switch (ximagePtr->bits_per_pixel) { /* * Get an 8 bit pixel from the XImage. @@ -2879,11 +2877,11 @@ * Grab a 32 bit pixel from the XImage, and correct the * byte order as necessary. */ case 32 : - pixel = *((unsigned long *)(ximagePtr->data + bytesPerPixel * x + pixel = *((unsigned int *)(ximagePtr->data + bytesPerPixel * x + ximagePtr->bytes_per_line * y)); if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst) || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst)) pixel = BYTE_SWAP32(pixel); break; @@ -3761,11 +3759,11 @@ /* * Allocate buffer for rewritten tags (after de-escaping). */ searchPtr->rewritebufferAllocated = 100; - searchPtr->rewritebuffer =(char *) ckalloc(searchPtr->rewritebufferAllocated); + searchPtr->rewritebuffer = (char *)ckalloc(searchPtr->rewritebufferAllocated); } TagSearchExprInit(&searchPtr->expr); /* * How long is the tagOrId? @@ -4594,11 +4592,11 @@ if (itemPtr->tagSpace == itemPtr->numTags) { Tk_Uid *newTagPtr; itemPtr->tagSpace += 5; - newTagPtr = (Tk_Uid*)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid)); + newTagPtr = (Tk_Uid *)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid)); memcpy((void *) newTagPtr, itemPtr->tagPtr, itemPtr->numTags * sizeof(Tk_Uid)); if (itemPtr->tagPtr != itemPtr->staticTagSpace) { ckfree(itemPtr->tagPtr); } @@ -5080,11 +5078,11 @@ CanvasBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; - unsigned long mask; + unsigned mask; Tcl_Preserve(canvasPtr); /* * This code below keeps track of the current modifier state in @@ -5093,11 +5091,11 @@ */ switch (eventPtr->type) { case ButtonPress: case ButtonRelease: - mask = TkGetButtonMask(eventPtr->xbutton.button); + mask = Tk_GetButtonMask(eventPtr->xbutton.button); /* * For button press events, repick the current item using the button * state before the event, then process the event. For button release * events, first process the event, then repick the current item using @@ -5176,11 +5174,11 @@ XEvent *eventPtr) /* Event describing location of mouse cursor. * Must be EnterWindow, LeaveWindow, * ButtonRelease, or MotionNotify. */ { double coords[2]; - unsigned long buttonDown; + unsigned int buttonDown; Tk_Item *prevItemPtr; SearchUids *searchUids = GetStaticUids(); /* * Check whether or not a button is down. If so, we'll log entry and exit Index: generic/tkCanvas.h ================================================================== --- generic/tkCanvas.h +++ generic/tkCanvas.h @@ -1,13 +1,13 @@ /* * tkCanvas.h -- * * Declarations shared among all the files that implement canvas widgets. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * Copyright (c) 1998 by Scriptics Corporation. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. + * Copyright © 1998 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkClipboard.c ================================================================== --- generic/tkClipboard.c +++ generic/tkClipboard.c @@ -3,12 +3,12 @@ * * This file manages the clipboard for the Tk toolkit, maintaining a * collection of data buffers that will be supplied on demand to * requesting applications. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -171,20 +171,16 @@ *---------------------------------------------------------------------- */ static TkSizeT ClipboardWindowHandler( - ClientData dummy, /* Not used. */ - TkSizeT offset, /* Return selection bytes starting at this + TCL_UNUSED(void *), /* Not used. */ + TCL_UNUSED(TkSizeT), /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ - TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */ + TCL_UNUSED(TkSizeT)) /* Maximum # of bytes to store at buffer. */ { - (void)dummy; - (void)offset; - (void)maxBytes; - buffer[0] = '.'; buffer[1] = 0; return 1; } @@ -456,11 +452,11 @@ enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE }; int subIndex; TkSizeT length; for (i = 2; i < objc - 1; i++) { - string = TkGetStringFromObj(objv[i], &length); + string = Tcl_GetStringFromObj(objv[i], &length); if (string[0] != '-') { break; } /* @@ -639,15 +635,14 @@ *---------------------------------------------------------------------- */ int TkClipInit( - Tcl_Interp *dummy, /* Interpreter to use for error reporting. */ + TCL_UNUSED(Tcl_Interp *), /* Interpreter to use for error reporting. */ TkDisplay *dispPtr)/* Display to initialize. */ { XSetWindowAttributes atts; - (void)dummy; dispPtr->clipTargetPtr = NULL; dispPtr->clipboardActive = 0; dispPtr->clipboardAppPtr = NULL; @@ -708,16 +703,14 @@ static int ClipboardGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ - Tcl_Interp *dummy, /* Interpreter used for error reporting (not + TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { - (void)dummy; - Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1); return TCL_OK; } /* Index: generic/tkCmds.c ================================================================== --- generic/tkCmds.c +++ generic/tkCmds.c @@ -2,13 +2,13 @@ * tkCmds.c -- * * This file contains a collection of Tk-related Tcl commands that didn't * fit in any particular file of the toolkit. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2000 Scriptics Corporation. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2000 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -895,17 +895,16 @@ return TCL_OK; } int WindowingsystemCmd( - ClientData dummy, /* Main window associated with interpreter. */ + TCL_UNUSED(void *), /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { const char *windowingsystem; - (void)dummy; if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } @@ -1112,20 +1111,16 @@ } static char * WaitVariableProc( ClientData clientData, /* Pointer to integer to set to 1. */ - Tcl_Interp *dummy, /* Interpreter containing variable. */ - const char *name1, /* Name of variable. */ - const char *name2, /* Second part of variable name. */ - int flags) /* Information about what happened. */ + TCL_UNUSED(Tcl_Interp *), /* Interpreter containing variable. */ + TCL_UNUSED(const char *), /* Name of variable. */ + TCL_UNUSED(const char *), /* Second part of variable name. */ + TCL_UNUSED(int)) /* Information about what happened. */ { int *donePtr = (int *)clientData; - (void)dummy; - (void)name1; - (void)name2; - (void)flags; *donePtr = 1; return NULL; } @@ -1172,20 +1167,19 @@ *---------------------------------------------------------------------- */ int Tk_UpdateObjCmd( - ClientData dummy, /* Main window associated with interpreter. */ + TCL_UNUSED(void *), /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const updateOptions[] = {"idletasks", NULL}; int flags, index; TkDisplay *dispPtr; int code = TCL_OK; - (void)dummy; if (objc == 1) { flags = TCL_DONT_WAIT; } else if (objc == 2) { if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, "option", 0, @@ -1739,11 +1733,27 @@ return TCL_ERROR; } if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) { return TCL_ERROR; } +#ifdef TK_HAS_DYNAMIC_COLORS + + /* + * Make sure that the TkColor used for the winfo rgb command is + * destroyed when we are through with it, so we do not get stale RGB + * values next time. + */ + + { + Colormap temp = Tk_Colormap(tkwin); + Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP; + colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); + Tk_Colormap(tkwin) = temp; + } +#else colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); +#endif if (colorPtr == NULL) { return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d %d", colorPtr->red, colorPtr->green, colorPtr->blue)); @@ -1850,11 +1860,11 @@ TkSizeT length; if (objc < 1) { return 0; } - string = TkGetStringFromObj(objv[0], &length); + string = Tcl_GetStringFromObj(objv[0], &length); if ((length >= 2) && (strncmp(string, "-displayof", length) == 0)) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-displayof\" missing", -1)); @@ -1888,18 +1898,15 @@ *---------------------------------------------------------------------- */ int TkDeadAppObjCmd( - ClientData dummy, /* Dummy. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ + TCL_UNUSED(int), /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - (void)dummy; - (void)objc; - Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't invoke \"%s\" command: application has been destroyed", Tcl_GetString(objv[0]))); return TCL_ERROR; } Index: generic/tkColor.c ================================================================== --- generic/tkColor.c +++ generic/tkColor.c @@ -3,12 +3,12 @@ * * This file maintains a database of color values for the Tk toolkit, in * order to avoid round-trips to the server to map color names to pixel * values. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkColor.h ================================================================== --- generic/tkColor.h +++ generic/tkColor.h @@ -1,11 +1,11 @@ /* * tkColor.h -- * * Declarations of data types and functions used by the Tk color module. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkConfig.c ================================================================== --- generic/tkConfig.c +++ generic/tkConfig.c @@ -2,11 +2,11 @@ * tkConfig.c -- * * This file contains functions that manage configuration options for * widgets and other things. * - * Copyright (c) 1997-1998 Sun Microsystems, Inc. + * Copyright © 1997-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -65,11 +65,11 @@ Tcl_Obj *monoColorPtr; /* For color and border options, this is an * alternate default value to use on * monochrome displays. */ struct TkOption *synonymPtr; /* For synonym options, this points to the - * master entry. */ + * original entry. */ const struct Tk_ObjCustomOption *custom; /* For TK_OPTION_CUSTOM. */ } extra; int flags; /* Miscellaneous flag values; see below for * definitions. */ @@ -235,12 +235,12 @@ optionPtr->extra.monoColorPtr = NULL; optionPtr->flags = 0; if (specPtr->type == TK_OPTION_SYNONYM) { /* - * This is a synonym option; find the master option that it refers - * to and create a pointer from the synonym to the master. + * This is a synonym option; find the original option that it refers + * to and create a pointer from the synonym to the origin. */ for (specPtr2 = templatePtr, i = 0; ; specPtr2++, i++) { if (specPtr2->type == TK_OPTION_END) { Tcl_Panic("Tk_CreateOptionTable couldn't find synonym"); @@ -661,11 +661,11 @@ if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; } if (internalPtr != NULL) { if (valuePtr != NULL) { - value = TkGetStringFromObj(valuePtr, &length); + value = Tcl_GetStringFromObj(valuePtr, &length); newStr = (char *)ckalloc(length + 1); strcpy(newStr, value); } else { newStr = NULL; } @@ -1403,12 +1403,10 @@ char *ptr = (char *) &savePtr->items[i].internalForm; CLANG_ASSERT(internalPtr); switch (specPtr->type) { case TK_OPTION_BOOLEAN: - *((int *) internalPtr) = *((int *) ptr); - break; case TK_OPTION_INT: *((int *) internalPtr) = *((int *) ptr); break; case TK_OPTION_DOUBLE: *((double *) internalPtr) = *((double *) ptr); @@ -1497,13 +1495,12 @@ if (savePtr->nextPtr != NULL) { Tk_FreeSavedOptions(savePtr->nextPtr); ckfree(savePtr->nextPtr); } - for (count = savePtr->numItems, - savedOptionPtr = &savePtr->items[savePtr->numItems-1]; - count > 0; count--, savedOptionPtr--) { + for (count = savePtr->numItems; count > 0; count--) { + savedOptionPtr = &savePtr->items[count-1]; if (savedOptionPtr->optionPtr->flags & OPTION_NEEDS_FREEING) { FreeResources(savedOptionPtr->optionPtr, savedOptionPtr->valuePtr, (char *) &savedOptionPtr->internalForm, savePtr->tkwin); } if (savedOptionPtr->valuePtr != NULL) { @@ -1872,110 +1869,110 @@ { Tcl_Obj *objPtr; void *internalPtr; /* Points to internal value of option in * record. */ - internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset; objPtr = NULL; - switch (optionPtr->specPtr->type) { - case TK_OPTION_BOOLEAN: - objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); - break; - case TK_OPTION_INT: - objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); - break; - case TK_OPTION_DOUBLE: - objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); - break; - case TK_OPTION_STRING: - objPtr = Tcl_NewStringObj(*((char **) internalPtr), -1); - break; - case TK_OPTION_STRING_TABLE: - objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[ - *((int *) internalPtr)], -1); - break; - case TK_OPTION_COLOR: { - XColor *colorPtr = *((XColor **) internalPtr); - - if (colorPtr != NULL) { - objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1); - } - break; - } - case TK_OPTION_FONT: { - Tk_Font tkfont = *((Tk_Font *) internalPtr); - - if (tkfont != NULL) { - objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1); - } - break; - } - case TK_OPTION_STYLE: { - Tk_Style style = *((Tk_Style *) internalPtr); - - if (style != NULL) { - objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1); - } - break; - } - case TK_OPTION_BITMAP: { - Pixmap pixmap = *((Pixmap *) internalPtr); - - if (pixmap != None) { - objPtr = Tcl_NewStringObj( + if (optionPtr->specPtr->internalOffset != TCL_INDEX_NONE) { + internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset; + switch (optionPtr->specPtr->type) { + case TK_OPTION_BOOLEAN: + case TK_OPTION_INT: + objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + break; + case TK_OPTION_DOUBLE: + objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); + break; + case TK_OPTION_STRING: + objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1); + break; + case TK_OPTION_STRING_TABLE: + objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[ + *((int *) internalPtr)], -1); + break; + case TK_OPTION_COLOR: { + XColor *colorPtr = *((XColor **)internalPtr); + + if (colorPtr != NULL) { + objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1); + } + break; + } + case TK_OPTION_FONT: { + Tk_Font tkfont = *((Tk_Font *)internalPtr); + + if (tkfont != NULL) { + objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1); + } + break; + } + case TK_OPTION_STYLE: { + Tk_Style style = *((Tk_Style *)internalPtr); + + if (style != NULL) { + objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1); + } + break; + } + case TK_OPTION_BITMAP: { + Pixmap pixmap = *((Pixmap *)internalPtr); + + if (pixmap != None) { + objPtr = Tcl_NewStringObj( Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), -1); - } - break; - } - case TK_OPTION_BORDER: { - Tk_3DBorder border = *((Tk_3DBorder *) internalPtr); - - if (border != NULL) { - objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1); - } - break; - } - case TK_OPTION_RELIEF: - objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *) internalPtr)), -1); - break; - case TK_OPTION_CURSOR: { - Tk_Cursor cursor = *((Tk_Cursor *) internalPtr); - - if (cursor != NULL) { - objPtr = Tcl_NewStringObj( - Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1); - } - break; - } - case TK_OPTION_JUSTIFY: - objPtr = Tcl_NewStringObj(Tk_NameOfJustify( - *((Tk_Justify *) internalPtr)), -1); - break; - case TK_OPTION_ANCHOR: - objPtr = Tcl_NewStringObj(Tk_NameOfAnchor( - *((Tk_Anchor *) internalPtr)), -1); - break; - case TK_OPTION_PIXELS: - objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); - break; - case TK_OPTION_WINDOW: { - Tk_Window tkwin = *((Tk_Window *) internalPtr); - - if (tkwin != NULL) { - objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1); - } - break; - } - case TK_OPTION_CUSTOM: { - const Tk_ObjCustomOption *custom = optionPtr->extra.custom; - - objPtr = custom->getProc(custom->clientData, tkwin, (char *)recordPtr, - optionPtr->specPtr->internalOffset); - break; - } - default: - Tcl_Panic("bad option type in GetObjectForOption"); + } + break; + } + case TK_OPTION_BORDER: { + Tk_3DBorder border = *((Tk_3DBorder *)internalPtr); + + if (border != NULL) { + objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1); + } + break; + } + case TK_OPTION_RELIEF: + objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *)internalPtr)), -1); + break; + case TK_OPTION_CURSOR: { + Tk_Cursor cursor = *((Tk_Cursor *)internalPtr); + + if (cursor != NULL) { + objPtr = Tcl_NewStringObj( + Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1); + } + break; + } + case TK_OPTION_JUSTIFY: + objPtr = Tcl_NewStringObj(Tk_NameOfJustify( + *((Tk_Justify *)internalPtr)), -1); + break; + case TK_OPTION_ANCHOR: + objPtr = Tcl_NewStringObj(Tk_NameOfAnchor( + *((Tk_Anchor *)internalPtr)), -1); + break; + case TK_OPTION_PIXELS: + objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + break; + case TK_OPTION_WINDOW: { + tkwin = *((Tk_Window *) internalPtr); + + if (tkwin != NULL) { + objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1); + } + break; + } + case TK_OPTION_CUSTOM: { + const Tk_ObjCustomOption *custom = optionPtr->extra.custom; + + objPtr = custom->getProc(custom->clientData, tkwin, (char *)recordPtr, + optionPtr->specPtr->internalOffset); + break; + } + default: + Tcl_Panic("bad option type in GetObjectForOption"); + } } if (objPtr == NULL) { objPtr = Tcl_NewObj(); } return objPtr; @@ -2063,11 +2060,11 @@ *---------------------------------------------------------------------- */ Tcl_Obj * TkDebugConfig( - Tcl_Interp *dummy, /* Interpreter in which the table is + TCL_UNUSED(Tcl_Interp *), /* Interpreter in which the table is * defined. */ Tk_OptionTable table) /* Table about which information is to be * returned. May not necessarily exist in the * interpreter anymore. */ { @@ -2075,11 +2072,10 @@ Tcl_HashEntry *hashEntryPtr; Tcl_HashSearch search; Tcl_Obj *objPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)dummy; objPtr = Tcl_NewObj(); if (!tablePtr || !tsdPtr->initialized) { return objPtr; } Index: generic/tkConsole.c ================================================================== --- generic/tkConsole.c +++ generic/tkConsole.c @@ -3,11 +3,11 @@ * * This file implements a Tcl console for systems that may not otherwise * have access to a console. It uses the Text widget and provides special * access via a console command. * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. + * Copyright © 1995-1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -65,11 +65,11 @@ * This structure describes the channel type structure for file based IO: */ static const Tcl_ChannelType consoleChannelType = { "console", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v4 channel */ + TCL_CHANNEL_VERSION_5, /* v5 channel */ (Tcl_DriverCloseProc *)ConsoleClose, /* Close proc. */ ConsoleInput, /* Input proc. */ ConsoleOutput, /* Output proc. */ NULL, /* Seek proc. */ NULL, /* Set option proc. */ @@ -559,21 +559,16 @@ *---------------------------------------------------------------------- */ static int ConsoleInput( - void *dummy, /* Unused. */ - char *buf, /* Where to store data read. */ - int bufSize, /* How much space is available in the + TCL_UNUSED(void *), + TCL_UNUSED(char *), /* Where to store data read. */ + TCL_UNUSED(int), /* How much space is available in the * buffer? */ - int *errorCode) /* Where to store error code. */ + TCL_UNUSED(int *)) /* Where to store error code. */ { - (void)dummy; - (void)buf; - (void)bufSize; - (void)errorCode; - return 0; /* Always return EOF. */ } /* *---------------------------------------------------------------------- @@ -592,15 +587,14 @@ */ static int ConsoleClose( ClientData instanceData, - Tcl_Interp *dummy) /* Unused. */ + TCL_UNUSED(Tcl_Interp *)) { ChannelData *data = (ChannelData *)instanceData; ConsoleInfo *info = data->info; - (void)dummy; if (info) { if (info->refCount-- <= 1) { /* * Assuming the Tcl_Interp * fields must already be NULL. @@ -643,17 +637,15 @@ *---------------------------------------------------------------------- */ static void ConsoleWatch( - ClientData dummy, /* Device ID for the channel. */ - int mask) /* OR-ed combination of TCL_READABLE, + TCL_UNUSED(void *), /* Device ID for the channel. */ + TCL_UNUSED(int)) /* OR-ed combination of TCL_READABLE, * TCL_WRITABLE and TCL_EXCEPTION, for the * events we are interested in. */ { - (void)dummy; - (void)mask; } /* *---------------------------------------------------------------------- * @@ -671,20 +663,16 @@ *---------------------------------------------------------------------- */ static int ConsoleHandle( - ClientData dummy, /* Device ID for the channel. */ - int direction, /* TCL_READABLE or TCL_WRITABLE to indicate + TCL_UNUSED(void *), /* Device ID for the channel. */ + TCL_UNUSED(int), /* TCL_READABLE or TCL_WRITABLE to indicate * which direction of the channel is being * requested. */ - ClientData *handlePtr) /* Where to store handle */ + TCL_UNUSED(void **)) /* Where to store handle */ { - (void)dummy; - (void)direction; - (void)handlePtr; - return TCL_ERROR; } /* *---------------------------------------------------------------------- @@ -822,11 +810,11 @@ return TCL_ERROR; } if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "no active master interp", -1)); + "no active parent interp", -1)); Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NO_INTERP", NULL); return TCL_ERROR; } Tcl_Preserve(otherInterp); @@ -945,11 +933,11 @@ /* *---------------------------------------------------------------------- * * ConsoleEventProc -- * - * This event function is registered on the main window of the slave + * This event function is registered on the main window of the child * interpreter. If the user or a running script causes the main window to * be destroyed, then we need to inform the console interpreter by * invoking "::tk::ConsoleExit". * * Results: Index: generic/tkCursor.c ================================================================== --- generic/tkCursor.c +++ generic/tkCursor.c @@ -3,12 +3,12 @@ * * This file maintains a database of read-only cursors for the Tk * toolkit. This allows cursors to be shared between widgets and also * avoids round-trips to the X server. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkDList.h ================================================================== --- generic/tkDList.h +++ generic/tkDList.h @@ -5,11 +5,11 @@ * are doubly linked so that an arbitrary element can be removed without * a need to traverse the list. New elements can be added to the list * before or after an existing element or at the head/tail of the list. * A list may be traversed in the forward or backward direction. * - * Copyright (c) 2018 by Gregor Cramer. + * Copyright © 2018 Gregor Cramer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkDecls.h ================================================================== --- generic/tkDecls.h +++ generic/tkDecls.h @@ -1,11 +1,11 @@ /* * tkDecls.h -- * * Declarations of functions in the platform independent public Tcl API. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -353,11 +353,11 @@ EXTERN Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, ClientData clientData); /* 98 */ -EXTERN ClientData Tk_GetImageMasterData(Tcl_Interp *interp, +EXTERN ClientData Tk_GetImageModelData(Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr); /* 99 */ EXTERN Tk_ItemType * Tk_GetItemTypes(void); /* 100 */ @@ -409,11 +409,11 @@ /* 115 */ EXTERN void Tk_HandleEvent(XEvent *eventPtr); /* 116 */ EXTERN Tk_Window Tk_IdToWindow(Display *display, Window window); /* 117 */ -EXTERN void Tk_ImageChanged(Tk_ImageMaster master, int x, int y, +EXTERN void Tk_ImageChanged(Tk_ImageModel model, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 118 */ EXTERN int Tk_Init(Tcl_Interp *interp); /* 119 */ @@ -420,12 +420,12 @@ EXTERN Atom Tk_InternAtom(Tk_Window tkwin, const char *name); /* 120 */ EXTERN int Tk_IntersectTextLayout(Tk_TextLayout layout, int x, int y, int width, int height); /* 121 */ -EXTERN void Tk_MaintainGeometry(Tk_Window slave, - Tk_Window master, int x, int y, int width, +EXTERN void Tk_MaintainGeometry(Tk_Window window, + Tk_Window container, int x, int y, int width, int height); /* 122 */ EXTERN Tk_Window Tk_MainWindow(Tcl_Interp *interp); /* 123 */ EXTERN void Tk_MakeWindowExist(Tk_Window tkwin); @@ -459,11 +459,11 @@ /* 135 */ EXTERN const char * Tk_NameOfCursor(Display *display, Tk_Cursor cursor); /* 136 */ EXTERN const char * Tk_NameOfFont(Tk_Font font); /* 137 */ -EXTERN const char * Tk_NameOfImage(Tk_ImageMaster imageMaster); +EXTERN const char * Tk_NameOfImage(Tk_ImageModel model); /* 138 */ EXTERN const char * Tk_NameOfJoinStyle(int join); /* 139 */ EXTERN const char * Tk_NameOfJustify(Tk_Justify justify); /* 140 */ @@ -592,12 +592,12 @@ Tk_TextLayout layout, int x, int y, int underline); /* 180 */ EXTERN void Tk_Ungrab(Tk_Window tkwin); /* 181 */ -EXTERN void Tk_UnmaintainGeometry(Tk_Window slave, - Tk_Window master); +EXTERN void Tk_UnmaintainGeometry(Tk_Window window, + Tk_Window container); /* 182 */ EXTERN void Tk_UnmapWindow(Tk_Window tkwin); /* 183 */ EXTERN void Tk_UnsetGrid(Tk_Window tkwin); /* 184 */ @@ -877,10 +877,25 @@ EXTERN void Tk_CreateOldImageType(const Tk_ImageType *typePtr); /* 273 */ EXTERN void Tk_CreateOldPhotoImageFormat( const Tk_PhotoImageFormat *formatPtr); /* 274 */ +EXTERN int Tk_AlwaysShowSelection(Tk_Window tkwin); +/* 275 */ +EXTERN unsigned Tk_GetButtonMask(unsigned button); +/* 276 */ +EXTERN int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, + Tk_Window tkwin, Tcl_Obj *objPtr, + double *doublePtr); +/* 277 */ +EXTERN Tcl_Obj * Tk_NewWindowObj(Tk_Window tkwin); +/* 278 */ +EXTERN void Tk_SendVirtualEvent(Tk_Window tkwin, + const char *eventName, Tcl_Obj *detail); +/* 279 */ +EXTERN Tcl_Obj * Tk_FontGetDescription(Tk_Font tkfont); +/* 280 */ EXTERN void Tk_CreatePhotoImageFormatVersion3( const Tk_PhotoImageFormatVersion3 *formatPtr); typedef struct { const struct TkPlatStubs *tkPlatStubs; @@ -989,11 +1004,11 @@ Tk_Font (*tk_GetFont) (Tcl_Interp *interp, Tk_Window tkwin, const char *str); /* 93 */ Tk_Font (*tk_GetFontFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 94 */ void (*tk_GetFontMetrics) (Tk_Font font, Tk_FontMetrics *fmPtr); /* 95 */ GC (*tk_GetGC) (Tk_Window tkwin, unsigned long valueMask, XGCValues *valuePtr); /* 96 */ Tk_Image (*tk_GetImage) (Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, ClientData clientData); /* 97 */ - ClientData (*tk_GetImageMasterData) (Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr); /* 98 */ + ClientData (*tk_GetImageModelData) (Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr); /* 98 */ Tk_ItemType * (*tk_GetItemTypes) (void); /* 99 */ int (*tk_GetJoinStyle) (Tcl_Interp *interp, const char *str, int *joinPtr); /* 100 */ int (*tk_GetJustify) (Tcl_Interp *interp, const char *str, Tk_Justify *justifyPtr); /* 101 */ int (*tk_GetNumMainWindows) (void); /* 102 */ Tk_Uid (*tk_GetOption) (Tk_Window tkwin, const char *name, const char *className); /* 103 */ @@ -1008,15 +1023,15 @@ Visual * (*tk_GetVisual) (Tcl_Interp *interp, Tk_Window tkwin, const char *str, int *depthPtr, Colormap *colormapPtr); /* 112 */ void (*tk_GetVRootGeometry) (Tk_Window tkwin, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 113 */ int (*tk_Grab) (Tcl_Interp *interp, Tk_Window tkwin, int grabGlobal); /* 114 */ void (*tk_HandleEvent) (XEvent *eventPtr); /* 115 */ Tk_Window (*tk_IdToWindow) (Display *display, Window window); /* 116 */ - void (*tk_ImageChanged) (Tk_ImageMaster master, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */ + void (*tk_ImageChanged) (Tk_ImageModel model, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */ int (*tk_Init) (Tcl_Interp *interp); /* 118 */ Atom (*tk_InternAtom) (Tk_Window tkwin, const char *name); /* 119 */ int (*tk_IntersectTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height); /* 120 */ - void (*tk_MaintainGeometry) (Tk_Window slave, Tk_Window master, int x, int y, int width, int height); /* 121 */ + void (*tk_MaintainGeometry) (Tk_Window window, Tk_Window container, int x, int y, int width, int height); /* 121 */ Tk_Window (*tk_MainWindow) (Tcl_Interp *interp); /* 122 */ void (*tk_MakeWindowExist) (Tk_Window tkwin); /* 123 */ void (*tk_ManageGeometry) (Tk_Window tkwin, const Tk_GeomMgr *mgrPtr, ClientData clientData); /* 124 */ void (*tk_MapWindow) (Tk_Window tkwin); /* 125 */ int (*tk_MeasureChars) (Tk_Font tkfont, const char *source, int numBytes, int maxPixels, int flags, int *lengthPtr); /* 126 */ @@ -1028,11 +1043,11 @@ const char * (*tk_NameOfBitmap) (Display *display, Pixmap bitmap); /* 132 */ const char * (*tk_NameOfCapStyle) (int cap); /* 133 */ const char * (*tk_NameOfColor) (XColor *colorPtr); /* 134 */ const char * (*tk_NameOfCursor) (Display *display, Tk_Cursor cursor); /* 135 */ const char * (*tk_NameOfFont) (Tk_Font font); /* 136 */ - const char * (*tk_NameOfImage) (Tk_ImageMaster imageMaster); /* 137 */ + const char * (*tk_NameOfImage) (Tk_ImageModel model); /* 137 */ const char * (*tk_NameOfJoinStyle) (int join); /* 138 */ const char * (*tk_NameOfJustify) (Tk_Justify justify); /* 139 */ const char * (*tk_NameOfRelief) (int relief); /* 140 */ Tk_Window (*tk_NameToWindow) (Tcl_Interp *interp, const char *pathName, Tk_Window tkwin); /* 141 */ void (*tk_OwnSelection) (Tk_Window tkwin, Atom selection, Tk_LostSelProc *proc, ClientData clientData); /* 142 */ @@ -1072,11 +1087,11 @@ int (*tk_TextWidth) (Tk_Font font, const char *str, int numBytes); /* 176 */ void (*tk_UndefineCursor) (Tk_Window window); /* 177 */ void (*tk_UnderlineChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int x, int y, int firstByte, int lastByte); /* 178 */ void (*tk_UnderlineTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int underline); /* 179 */ void (*tk_Ungrab) (Tk_Window tkwin); /* 180 */ - void (*tk_UnmaintainGeometry) (Tk_Window slave, Tk_Window master); /* 181 */ + void (*tk_UnmaintainGeometry) (Tk_Window window, Tk_Window container); /* 181 */ void (*tk_UnmapWindow) (Tk_Window tkwin); /* 182 */ void (*tk_UnsetGrid) (Tk_Window tkwin); /* 183 */ void (*tk_UpdatePointer) (Tk_Window tkwin, int x, int y, int state); /* 184 */ Pixmap (*tk_AllocBitmapFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr); /* 185 */ Tk_3DBorder (*tk_Alloc3DBorderFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr); /* 186 */ @@ -1165,12 +1180,18 @@ long (*tk_GetUserInactiveTime) (Display *dpy); /* 269 */ void (*tk_ResetUserInactiveTime) (Display *dpy); /* 270 */ Tcl_Interp * (*tk_Interp) (Tk_Window tkwin); /* 271 */ void (*tk_CreateOldImageType) (const Tk_ImageType *typePtr); /* 272 */ void (*tk_CreateOldPhotoImageFormat) (const Tk_PhotoImageFormat *formatPtr); /* 273 */ + int (*tk_AlwaysShowSelection) (Tk_Window tkwin); /* 274 */ + unsigned (*tk_GetButtonMask) (unsigned button); /* 275 */ + int (*tk_GetDoublePixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 276 */ + Tcl_Obj * (*tk_NewWindowObj) (Tk_Window tkwin); /* 277 */ + void (*tk_SendVirtualEvent) (Tk_Window tkwin, const char *eventName, Tcl_Obj *detail); /* 278 */ + Tcl_Obj * (*tk_FontGetDescription) (Tk_Font tkfont); /* 279 */ void (*tk_CreatePhotoImageFormatVersion3) ( - const Tk_PhotoImageFormatVersion3 *formatPtr); /* 274 */ + const Tk_PhotoImageFormatVersion3 *formatPtr); /* 280 */ } TkStubs; extern const TkStubs *tkStubsPtr; #ifdef __cplusplus @@ -1377,12 +1398,12 @@ (tkStubsPtr->tk_GetFontMetrics) /* 95 */ #define Tk_GetGC \ (tkStubsPtr->tk_GetGC) /* 96 */ #define Tk_GetImage \ (tkStubsPtr->tk_GetImage) /* 97 */ -#define Tk_GetImageMasterData \ - (tkStubsPtr->tk_GetImageMasterData) /* 98 */ +#define Tk_GetImageModelData \ + (tkStubsPtr->tk_GetImageModelData) /* 98 */ #define Tk_GetItemTypes \ (tkStubsPtr->tk_GetItemTypes) /* 99 */ #define Tk_GetJoinStyle \ (tkStubsPtr->tk_GetJoinStyle) /* 100 */ #define Tk_GetJustify \ @@ -1727,12 +1748,24 @@ (tkStubsPtr->tk_Interp) /* 271 */ #define Tk_CreateOldImageType \ (tkStubsPtr->tk_CreateOldImageType) /* 272 */ #define Tk_CreateOldPhotoImageFormat \ (tkStubsPtr->tk_CreateOldPhotoImageFormat) /* 273 */ +#define Tk_AlwaysShowSelection \ + (tkStubsPtr->tk_AlwaysShowSelection) /* 274 */ +#define Tk_GetButtonMask \ + (tkStubsPtr->tk_GetButtonMask) /* 275 */ +#define Tk_GetDoublePixelsFromObj \ + (tkStubsPtr->tk_GetDoublePixelsFromObj) /* 276 */ +#define Tk_NewWindowObj \ + (tkStubsPtr->tk_NewWindowObj) /* 277 */ +#define Tk_SendVirtualEvent \ + (tkStubsPtr->tk_SendVirtualEvent) /* 278 */ +#define Tk_FontGetDescription \ + (tkStubsPtr->tk_FontGetDescription) /* 279 */ #define Tk_CreatePhotoImageFormatVersion3 \ - (tkStubsPtr->tk_CreatePhotoImageFormatVersion3) /* 274 */ + (tkStubsPtr->tk_CreatePhotoImageFormatVersion3) /* 280 */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ @@ -1746,11 +1779,11 @@ #define Tk_FreeXId(display,xid) #undef Tk_GetStyleFromObj #undef Tk_FreeStyleFromObj #define Tk_GetStyleFromObj(obj) Tk_AllocStyleFromObj(NULL, obj) #define Tk_FreeStyleFromObj(obj) /* no-op */ - +#define Tk_GetImageMasterData Tk_GetImageModelData #if defined(_WIN32) && defined(UNICODE) # define Tk_MainEx Tk_MainExW EXTERN void Tk_MainExW(int argc, wchar_t **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); @@ -1767,7 +1800,9 @@ #undef Tk_CreateOldPhotoImageFormat #endif /* TK_NO_DEPRECATED */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT + +#undef TkUnusedStubEntry #endif /* _TKDECLS */ Index: generic/tkEntry.c ================================================================== --- generic/tkEntry.c +++ generic/tkEntry.c @@ -4,14 +4,14 @@ * This module implements entry and spinbox widgets for the Tk toolkit. * An entry displays a string and allows the string to be edited. A * spinbox expands on the entry by adding up/down buttons that control * the value of the entry widget. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2000 Ajuba Solutions. - * Copyright (c) 2002 ActiveState Corporation. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2000 Ajuba Solutions. + * Copyright © 2002 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -572,11 +572,11 @@ (ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK)) { Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(entryPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -735,11 +735,11 @@ } if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } case COMMAND_INSERT: { TkSizeT index; @@ -1682,11 +1682,11 @@ /* * Hide the selection whenever we don't have the focus, unless we * always want to show selection. */ - if (TkpAlwaysShowSelection(entryPtr->tkwin)) { + if (Tk_AlwaysShowSelection(entryPtr->tkwin)) { showSelection = 1; } else { showSelection = (entryPtr->flags & GOT_FOCUS); } @@ -1764,38 +1764,60 @@ fm.ascent + fm.descent, 0, TK_RELIEF_FLAT); } } } - /* - * Draw the text in two pieces: first the unselected portion, then the - * selected portion on top of it. - */ - - if ((entryPtr->numChars != 0) || (entryPtr->placeholderChars == 0)) { - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - entryPtr->leftIndex, entryPtr->numChars); - } else { - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->placeholderGC, + if ((entryPtr->numChars == 0) && (entryPtr->placeholderChars != 0)) { + + /* + * Draw the placeholder text. + */ + + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->placeholderGC, entryPtr->placeholderLayout, entryPtr->placeholderX, entryPtr->layoutY, entryPtr->placeholderLeftIndex, entryPtr->placeholderChars); - } - - if (showSelection && (entryPtr->state != STATE_DISABLED) - && (entryPtr->selTextGC != entryPtr->textGC) - && (entryPtr->selectFirst + 1 < entryPtr->selectLast + 1)) { - int selFirst; - - if (entryPtr->selectFirst + 1 < entryPtr->leftIndex + 1) { - selFirst = entryPtr->leftIndex; - } else { - selFirst = entryPtr->selectFirst; - } - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - selFirst, entryPtr->selectLast); + + } else { + + if (showSelection && (entryPtr->state != STATE_DISABLED) + && (entryPtr->selTextGC != entryPtr->textGC) + && (entryPtr->selectFirst + 1 < entryPtr->selectLast + 1)) { + + /* + * Draw the selected and unselected portions separately. + */ + + TkSizeT selFirst; + + if (entryPtr->selectFirst + 1 < entryPtr->leftIndex + 1) { + selFirst = entryPtr->leftIndex; + } else { + selFirst = entryPtr->selectFirst; + } + if (entryPtr->leftIndex < selFirst) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, selFirst); + } + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + selFirst, entryPtr->selectLast); + if (entryPtr->selectLast < entryPtr->numChars) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->selectLast, entryPtr->numChars); + } + } else { + + /* + * Draw the entire visible text + */ + + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, entryPtr->numChars); + } } if (entryPtr->type == TK_SPINBOX) { int startx, height, inset, pad, tHeight, xWidth; Spinbox *sbPtr = (Spinbox *) entryPtr; @@ -2666,11 +2688,11 @@ } *indexPtr = idx; return TCL_OK; } - string = TkGetStringFromObj(indexObj, &length); + string = Tcl_GetStringFromObj(indexObj, &length); switch (string[0]) { case 'a': if (strncmp(string, "anchor", length) != 0) { goto badIndex; @@ -2954,11 +2976,11 @@ * next time the focus enters the window. On Unix, we need to clear the * selection since it is always visible. * This is controlled by ::tk::AlwaysShowSelection. */ - if (TkpAlwaysShowSelection(entryPtr->tkwin) + if (Tk_AlwaysShowSelection(entryPtr->tkwin) && (entryPtr->selectFirst != TCL_INDEX_NONE) && entryPtr->exportSelection && (!Tcl_IsSafe(entryPtr->interp))) { entryPtr->selectFirst = TCL_INDEX_NONE; entryPtr->selectLast = TCL_INDEX_NONE; EventuallyRedraw(entryPtr); @@ -3383,21 +3405,25 @@ char *p; Tcl_DString script; if (entryPtr->validateCmd == NULL || entryPtr->validate == VALIDATE_NONE) { + if (entryPtr->flags & VALIDATING) { + entryPtr->flags |= VALIDATE_ABORT; + } return (varValidate ? TCL_ERROR : TCL_OK); } /* - * If we're already validating, then we're hitting a loop condition Return - * and set validate to 0 to disallow further validations and prevent - * current validation from finishing + * If we're already validating, then we're hitting a loop condition. Set + * validate to none to disallow further validations, arrange for flags + * to prevent current validation from finishing, and return. */ if (entryPtr->flags & VALIDATING) { entryPtr->validate = VALIDATE_NONE; + entryPtr->flags |= VALIDATE_ABORT; return (varValidate ? TCL_ERROR : TCL_OK); } entryPtr->flags |= VALIDATING; @@ -3779,11 +3805,11 @@ } if (ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(entryPtr->tkwin)); return TCL_OK; error: Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; @@ -3967,11 +3993,11 @@ } if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } case SB_CMD_INSERT: { TkSizeT index; @@ -4405,11 +4431,11 @@ const char *bytes; Tcl_Obj **listv; Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv); for (i = 0; i < listc; i++) { - bytes = TkGetStringFromObj(listv[i], &elemLen); + bytes = Tcl_GetStringFromObj(listv[i], &elemLen); if ((length == elemLen) && (memcmp(bytes, entryPtr->string, length) == 0)) { sbPtr->eIndex = i; break; Index: generic/tkEntry.h ================================================================== --- generic/tkEntry.h +++ generic/tkEntry.h @@ -4,11 +4,11 @@ * This module defined the structures for the Entry & SpinBox widgets. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * Copyright (c) 2002 Apple Inc. + * Copyright © 2002 Apple Inc. */ #ifndef _TKENTRY #define _TKENTRY Index: generic/tkError.c ================================================================== --- generic/tkError.c +++ generic/tkError.c @@ -4,12 +4,12 @@ * This file provides a high-performance mechanism for selectively * dealing with errors that occur in talking to the X server. This is * useful, for example, when communicating with a window that may not * exist. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkEvent.c ================================================================== --- generic/tkEvent.c +++ generic/tkEvent.c @@ -2,14 +2,14 @@ * tkEvent.c -- * * This file provides basic low-level facilities for managing X events in * Tk. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * Copyright (c) 1998-2000 Ajuba Solutions. - * Copyright (c) 2004 George Peter Staplin + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. + * Copyright © 1998-2000 Ajuba Solutions. + * Copyright © 2004 George Peter Staplin * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -511,13 +511,16 @@ } /* *---------------------------------------------------------------------- * - * TkGetButtonMask -- + * Tk_GetButtonMask -- * - * Return the proper Button${n}Mask for the button. + * Return the proper Button${n}Mask for the button. Don't care about + * Button4 - Button7, because those are not actually buttons: Those + * are used for the horizontal or vertical mouse wheels. Button4Mask + * and higher is actually used for Button 8 and higher. * * Results: * A button mask. * * Side effects: @@ -524,18 +527,18 @@ * None. * *---------------------------------------------------------------------- */ -static const unsigned long buttonMasks[] = { - 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask, - Button6Mask, Button7Mask, Button8Mask, Button9Mask +static const unsigned buttonMasks[] = { + 0, Button1Mask, Button2Mask, Button3Mask, 0, 0, 0, 0, Button4Mask, \ + Button5Mask, Button6Mask, Button7Mask, Button8Mask, Button9Mask }; -unsigned long -TkGetButtonMask( - unsigned int button) +unsigned +Tk_GetButtonMask( + unsigned button) { return (button > Button9) ? 0 : buttonMasks[button]; } /* @@ -689,11 +692,11 @@ unsigned long mask, /* Events for which proc should be called. */ Tk_EventProc *proc, /* Function to call for each selected event */ ClientData clientData) /* Arbitrary data to pass to proc. */ { TkEventHandler *handlerPtr; - TkWindow *winPtr = (TkWindow *) token; + TkWindow *winPtr = (TkWindow *)token; /* * Skim through the list of existing handlers to (a) compute the overall * event mask for the window (so we can pass this new value to the X * system) and (b) see if there's already a handler declared with the same @@ -1038,14 +1041,13 @@ */ static int TkXErrorHandler( ClientData clientData, /* Pointer to flag we set. */ - XErrorEvent *errEventPtr) /* X error info. */ + TCL_UNUSED(XErrorEvent *)) /* X error info. */ { int *error = (int *)clientData; - (void)errEventPtr; *error = 1; return 0; } @@ -1136,10 +1138,27 @@ InProgress ip; Tcl_Interp *interp = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + +#if !defined(_WIN32) && !defined(MAC_OSX_TK) + if ((eventPtr->xbutton.button >= Button4) && (eventPtr->xbutton.button < Button8)) { + if (eventPtr->type == ButtonRelease) { + return; + } else if (eventPtr->type == ButtonPress) { + int but = eventPtr->xbutton.button; + eventPtr->type = MouseWheelEvent; + eventPtr->xany.send_event = -1; + eventPtr->xkey.keycode = (but & 1) ? -120 : 120; + if (but > Button5) { + eventPtr->xkey.state ^= ShiftMask; + } + } + } +#endif + /* * If the generic handler processed this event we are done and can return. */ if (InvokeGenericHandlers(tsdPtr, eventPtr)) { @@ -2001,14 +2020,13 @@ *---------------------------------------------------------------------- */ void TkFinalize( - ClientData dummy) /* Arbitrary value to pass to proc. */ + TCL_UNUSED(void *)) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr; - (void)dummy; #if defined(_WIN32) && !defined(STATIC_BUILD) if (!tclStubsPtr) { return; } @@ -2054,16 +2072,15 @@ *---------------------------------------------------------------------- */ void TkFinalizeThread( - ClientData dummy) /* Arbitrary value to pass to proc. */ + TCL_UNUSED(void *)) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)dummy; Tcl_DeleteThreadExitHandler(TkFinalizeThread, NULL); if (tsdPtr != NULL) { tsdPtr->inExit = 1; Index: generic/tkFileFilter.c ================================================================== --- generic/tkFileFilter.c +++ generic/tkFileFilter.c @@ -2,11 +2,11 @@ * tkFileFilter.c -- * * Process the -filetypes option for the file dialogs on Windows and the * Mac. * - * Copyright (c) 1996 Sun Microsystems, Inc. + * Copyright © 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -261,11 +261,11 @@ * require further code refactoring. */ for (i=0; i 0 && globList != NULL) { for (i=0; imainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->topLevelPtr == topLevelPtr) { - Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) + Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window) tlFocusPtr->focusWinPtr)); return TCL_OK; } } - Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) topLevelPtr)); + Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window) topLevelPtr)); return TCL_OK; } break; default: Tcl_Panic("bad const entries to focusOptions in focus command"); Index: generic/tkFont.c ================================================================== --- generic/tkFont.c +++ generic/tkFont.c @@ -2,19 +2,22 @@ * tkFont.c -- * * This file maintains a database of fonts for the Tk toolkit. It also * provides several utility functions for measuring and displaying text. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #include "tkFont.h" +#if defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" /* Defines TK_DRAW_IN_CONTEXT */ +#endif /* * The following structure is used to keep track of all the fonts that exist * in the current application. It must be stored in the TkMainInfo for the * application. @@ -91,11 +94,11 @@ const char *string; /* The string that was layed out. */ int width; /* The maximum width of all lines in the text * layout. */ int numChunks; /* Number of chunks actually used in following * array. */ - LayoutChunk chunks[1]; /* Array of chunks. The actual size will be + LayoutChunk chunks[TKFLEXARRAY];/* Array of chunks. The actual size will be * maxChunks. THIS FIELD MUST BE THE LAST IN * THE STRUCTURE. */ } TextLayout; /* @@ -551,11 +554,11 @@ * If there were fewer than 3 args, or args remain, that's an error. */ if (objc < 3 || n < objc) { Tcl_WrongNumArgs(interp, 2, objv, - "font ?-displayof window? ?option? ?--? ?char?"); + "font ?-displayof window? ?-option? ?--? ?char?"); return TCL_ERROR; } /* * The 'charPtr' arg must be a single Unicode. @@ -728,19 +731,19 @@ } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; } - string = TkGetStringFromObj(objv[3 + skip], &length); + string = Tcl_GetStringFromObj(objv[3 + skip], &length); Tcl_SetObjResult(interp, Tcl_NewWideIntObj( Tk_TextWidth(tkfont, string, length))); Tk_FreeFont(tkfont); break; } case FONT_METRICS: { Tk_Font tkfont; - int skip, index, i; + int skip, i; const TkFontMetrics *fmPtr; static const char *const switches[] = { "-ascent", "-descent", "-linespace", "-fixed", NULL }; @@ -748,11 +751,11 @@ if (skip < 0) { return TCL_ERROR; } if ((objc < 3) || ((objc - skip) > 4)) { Tcl_WrongNumArgs(interp, 2, objv, - "font ?-displayof window? ?option?"); + "font ?-displayof window? ?-option?"); return TCL_ERROR; } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; @@ -879,11 +882,11 @@ * [NSView drawRect] method is drawing. The best that we can do in * that situation is to abort the recomputation and hope for the best. * This is ignored on other platforms. */ - if (!TkpWillDrawWidget(NULL)) { + if (TkpWillDrawWidget(NULL)) { return; } fiPtr->updatePending = 0; RecomputeWidgets(fiPtr->mainPtr->winPtr); @@ -1357,15 +1360,14 @@ *---------------------------------------------------------------------- */ static int SetFontFromAny( - Tcl_Interp *dummy, /* Used for error reporting if not NULL. */ + TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { const Tcl_ObjType *typePtr; - (void)dummy; /* * Free the old internalRep before setting the new one. */ @@ -1964,11 +1966,11 @@ * break. */ int *widthPtr, /* Filled with width of string. */ int *heightPtr) /* Filled with height of string. */ { TkFont *fontPtr = (TkFont *) tkfont; - const char *start, *end, *special; + const char *start, *endp, *special; int n, y, bytesThisChunk, maxChunks, curLine, layoutHeight; int baseline, height, curX, newX, maxWidth, *lineLengths; TextLayout *layoutPtr; LayoutChunk *chunkPtr; const TkFontMetrics *fmPtr; @@ -1997,12 +1999,12 @@ wrapLength = -1; } maxChunks = 1; - layoutPtr = (TextLayout *)ckalloc(sizeof(TextLayout) - + (maxChunks-1) * sizeof(LayoutChunk)); + layoutPtr = (TextLayout *)ckalloc(offsetof(TextLayout, chunks) + + maxChunks * sizeof(LayoutChunk)); layoutPtr->tkfont = tkfont; layoutPtr->string = string; layoutPtr->numChunks = 0; baseline = fmPtr->ascent; @@ -2012,16 +2014,16 @@ * Divide the string up into simple strings and measure each string. */ curX = 0; - end = Tcl_UtfAtIndex(string, numChars); + endp = Tcl_UtfAtIndex(string, numChars); special = string; flags &= TK_IGNORE_TABS | TK_IGNORE_NEWLINES; flags |= TK_WHOLE_WORDS | TK_AT_LEAST_ONE; - for (start = string; start < end; ) { + for (start = string; start < endp; ) { if (start >= special) { /* * Find the next special character in the string. * * INTL: Note that it is safe to increment by byte, because we are @@ -2028,11 +2030,11 @@ * looking for 7-bit characters that will appear unchanged in * UTF-8. At some point we may need to support the full Unicode * whitespace set. */ - for (special = start; special < end; special++) { + for (special = start; special < endp; special++) { if (!(flags & TK_IGNORE_NEWLINES)) { if ((*special == '\n') || (*special == '\r')) { break; } } @@ -2062,11 +2064,11 @@ start += bytesThisChunk; curX = newX; } } - if ((start == special) && (special < end)) { + if ((start == special) && (special < endp)) { /* * Handle the special character. * * INTL: Special will be pointing at a 7-bit character so we can * safely treat it as a single byte. @@ -2079,11 +2081,11 @@ NewChunk(&layoutPtr, &maxChunks, start, 1, curX, newX, baseline)->numDisplayChars = -1; start++; curX = newX; flags &= ~TK_AT_LEAST_ONE; - if ((start < end) && + if ((start < endp) && ((wrapLength <= 0) || (newX <= wrapLength))) { /* * More chars can still fit on this line. */ @@ -2101,11 +2103,11 @@ * No more characters are going to go on this line, either because no * more characters can fit or there are no more characters left. * Consume all extra spaces at end of line. */ - while ((start < end) && isspace(UCHAR(*start))) { /* INTL: ISO space */ + while ((start < endp) && isspace(UCHAR(*start))) { /* INTL: ISO space */ if (!(flags & TK_IGNORE_NEWLINES)) { if ((*start == '\n') || (*start == '\r')) { break; } } @@ -2289,16 +2291,20 @@ Tk_TextLayout layout, /* Layout information, from a previous call to * Tk_ComputeTextLayout(). */ int x, int y, /* Upper-left hand corner of rectangle in * which to draw (pixels). */ int firstChar, /* The index of the first character to draw - * from the given text item. 0 specfies the + * from the given text item. 0 specifies the * beginning. */ int lastChar) /* The index just after the last character to * draw from the given text item. A number < 0 * means to draw all characters. */ { +#if 0 + /* Use TkDrawAngledTextLayout() implementation - testing purposes at this point */ + TkDrawAngledTextLayout(display, drawable, gc, layout, x, y, 0.0, firstChar, lastChar); +#else TextLayout *layoutPtr = (TextLayout *) layout; int i, numDisplayChars, drawX; const char *firstByte, *lastByte; LayoutChunk *chunkPtr; @@ -2324,20 +2330,28 @@ } if (lastChar < numDisplayChars) { numDisplayChars = lastChar; } lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars); +#ifdef TK_DRAW_IN_CONTEXT + TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont, + chunkPtr->start, chunkPtr->numBytes, + firstByte - chunkPtr->start, lastByte - firstByte, + x+chunkPtr->x, y+chunkPtr->y); +#else /* !TK_DRAW_IN_CONTEXT */ Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y); +#endif /* TK_DRAW_IN_CONTEXT */ } firstChar -= chunkPtr->numChars; lastChar -= chunkPtr->numChars; if (lastChar <= 0) { break; } chunkPtr++; } +#endif /* Use TkDrawAngledTextLayout() implementation */ } void TkDrawAngledTextLayout( Display *display, /* Display on which to draw. */ @@ -2348,11 +2362,11 @@ * Tk_ComputeTextLayout(). */ int x, int y, /* Upper-left hand corner of rectangle in * which to draw (pixels). */ double angle, int firstChar, /* The index of the first character to draw - * from the given text item. 0 specfies the + * from the given text item. 0 specifies the * beginning. */ int lastChar) /* The index just after the last character to * draw from the given text item. A number < 0 * means to draw all characters. */ { @@ -2386,10 +2400,25 @@ } if (lastChar < numDisplayChars) { numDisplayChars = lastChar; } lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars); +#ifdef TK_DRAW_IN_CONTEXT + dx = cosA * (chunkPtr->x) + sinA * (chunkPtr->y); + dy = -sinA * (chunkPtr->x) + cosA * (chunkPtr->y); + if (angle == 0.0) { + TkpDrawCharsInContext(display, drawable, gc, + layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, + firstByte - chunkPtr->start, lastByte - firstByte, + (int)(x + dx), (int)(y + dy)); + } else { + TkpDrawAngledCharsInContext(display, drawable, gc, + layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, + firstByte - chunkPtr->start, lastByte - firstByte, + x+dx, y+dy, angle); + } +#else /* !TK_DRAW_IN_CONTEXT */ dx = cosA * (chunkPtr->x + drawX) + sinA * (chunkPtr->y); dy = -sinA * (chunkPtr->x + drawX) + cosA * (chunkPtr->y); if (angle == 0.0) { Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, @@ -2396,10 +2425,11 @@ (int)(x + dx), (int)(y + dy)); } else { TkDrawAngledChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, x+dx, y+dy, angle); } +#endif /* TK_DRAW_IN_CONTEXT */ } firstChar -= chunkPtr->numChars; lastChar -= chunkPtr->numChars; if (lastChar <= 0) { break; @@ -2705,21 +2735,20 @@ /* Filled with the width and height of the * bounding box for the character specified by * index, if non-NULL. */ { TextLayout *layoutPtr = (TextLayout *) layout; - LayoutChunk *chunkPtr; + LayoutChunk *chunkPtr = layoutPtr->chunks; int i, x = 0, w; Tk_Font tkfont; TkFont *fontPtr; const char *end; if (index < 0) { return 0; } - chunkPtr = layoutPtr->chunks; tkfont = layoutPtr->tkfont; fontPtr = (TkFont *) tkfont; for (i = 0; i < layoutPtr->numChunks; i++) { if (chunkPtr->numDisplayChars < 0) { @@ -3313,11 +3342,11 @@ goto noMapping; } sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { - ps = TkGetStringFromObj(psObj, &len); + ps = Tcl_GetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! */ @@ -3368,21 +3397,20 @@ */ static int ConfigAttributesObj( Tcl_Interp *interp, /* Interp for error return. */ - Tk_Window tkwin, /* For display on which font will be used. */ + TCL_UNUSED(Tk_Window), /* For display on which font will be used. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[], /* Command line options. */ TkFontAttributes *faPtr) /* Font attributes structure whose fields are * to be modified. Structure must already be * properly initialized. */ { int i, n, index; Tcl_Obj *optionPtr, *valuePtr; const char *value; - (void)tkwin; for (i = 0; i < objc; i += 2) { optionPtr = objv[i]; if (Tcl_GetIndexFromObj(interp, optionPtr, fontOpt, "option", 1, @@ -3540,10 +3568,61 @@ Tcl_ListObjAppendElement(NULL, resultPtr, valuePtr); } Tcl_SetObjResult(interp, resultPtr); return TCL_OK; } + +/* + *--------------------------------------------------------------------------- + * + * Tk_FontGetDescription -- + * + * Return information about the font description as a Tcl list. One + * possible result is "{{DejaVu Sans} -16 bold underline}". + * + * Results: + * The list of descriptions. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +Tcl_Obj * +Tk_FontGetDescription( + Tk_Font tkfont) /* Font whose description is desired. */ +{ + const TkFontAttributes *faPtr = GetFontAttributes(tkfont); + Tcl_Obj *resultPtr = Tcl_NewObj(); + const char *str; + + str = faPtr->family; + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, str ? -1 : 0)); + if (faPtr->size >= 0.0) { + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewWideIntObj((int)(faPtr->size + 0.5))); + } else { + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewWideIntObj(-(int)(-faPtr->size + 0.5))); + } + if (faPtr->weight != TK_FW_NORMAL) { + str = TkFindStateString(weightMap, faPtr->weight); + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1)); + } + if (faPtr->slant != TK_FS_ROMAN) { + str = TkFindStateString(slantMap, faPtr->slant); + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1)); + } + if (faPtr->underline) { + str = TkFindStateString(underlineMap, faPtr->underline); + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1)); + } + if (faPtr->overstrike) { + str = TkFindStateString(overstrikeMap, faPtr->overstrike); + Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1)); + } + return resultPtr; +} /* *--------------------------------------------------------------------------- * * ParseFontNameObj -- @@ -3744,11 +3823,11 @@ layoutPtr = *layoutPtrPtr; maxChunks = *maxPtr; if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; - s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk)); + s = offsetof(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk)); layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; *maxPtr = maxChunks; } Index: generic/tkFont.h ================================================================== --- generic/tkFont.h +++ generic/tkFont.h @@ -3,11 +3,11 @@ * * Declarations for interfaces between the generic and platform-specific * parts of the font package. This information is not visible outside of * the font package. * - * Copyright (c) 1996-1997 Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkFrame.c ================================================================== --- generic/tkFrame.c +++ generic/tkFrame.c @@ -3,12 +3,12 @@ * * This module implements "frame", "labelframe" and "toplevel" widgets * for the Tk toolkit. Frames are windows with a background color and * possibly a 3-D effect, but not much else in the way of attributes. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -342,11 +342,11 @@ int x, int y, int width, int height, int imgWidth, int imgHeight); static void FrameCmdDeletedProc(ClientData clientData); static void FrameEventProc(ClientData clientData, XEvent *eventPtr); -static void FrameLostSlaveProc(ClientData clientData, +static void FrameLostContentProc(ClientData clientData, Tk_Window tkwin); static void FrameRequestProc(ClientData clientData, Tk_Window tkwin); static void FrameStructureProc(ClientData clientData, XEvent *eventPtr); @@ -374,11 +374,11 @@ */ static const Tk_GeomMgr frameGeomType = { "labelframe", /* name */ FrameRequestProc, /* requestProc */ - FrameLostSlaveProc /* lostSlaveProc */ + FrameLostContentProc /* lostContentProc */ }; /* *-------------------------------------------------------------- * @@ -545,11 +545,11 @@ */ className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { - arg = TkGetStringFromObj(objv[i], &length); + arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-class", length) == 0)) { @@ -730,11 +730,11 @@ TkpMakeContainer(framePtr->tkwin); } if (type == TYPE_TOPLEVEL) { Tcl_DoWhenIdle(MapFrame, framePtr); } - Tcl_SetObjResult(interp, TkNewWindowObj(newWin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(newWin)); return TCL_OK; error: if (newWin != NULL) { Tk_DestroyWindow(newWin); @@ -818,11 +818,11 @@ * Don't allow the options -class, -colormap, -container, -screen, * -use, or -visual to be changed. */ for (i = 2; i < objc; i++) { - const char *arg = TkGetStringFromObj(objv[i], &length); + const char *arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } c = arg[1]; @@ -837,11 +837,11 @@ || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", length) == 0)) || ((c == 'v') && (strncmp(arg, "-visual", length) == 0))) { -#ifdef SUPPORT_CONFIG_EMBEDDED +#ifdef _WIN32 if (c == 'u') { const char *string = Tcl_GetString(objv[i+1]); if (TkpUseWindow(interp, framePtr->tkwin, string) != TCL_OK) { @@ -2014,29 +2014,29 @@ } /* *-------------------------------------------------------------- * - * FrameLostSlaveProc -- + * FrameLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all frame-related information about the slave. + * Forgets all frame-related information about the content window. * *-------------------------------------------------------------- */ static void -FrameLostSlaveProc( - ClientData clientData, /* Frame structure for slave window that was +FrameLostContentProc( + ClientData clientData, /* Frame structure for content window window that was * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ + Tk_Window tkwin) /* Tk's handle for the content window window. */ { Frame *framePtr = (Frame *)clientData; Labelframe *labelframePtr = (Labelframe *)clientData; (void)tkwin; Index: generic/tkGC.c ================================================================== --- generic/tkGC.c +++ generic/tkGC.c @@ -2,12 +2,12 @@ * tkGC.c -- * * This file maintains a database of read-only graphics contexts for the * Tk toolkit, in order to allow GC's to be shared. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkGeometry.c ================================================================== --- generic/tkGeometry.c +++ generic/tkGeometry.c @@ -2,82 +2,82 @@ * tkGeometry.c -- * * This file contains generic Tk code for geometry management (stuff * that's used by all geometry managers). * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" /* * Data structures of the following type are used by Tk_MaintainGeometry. For - * each slave managed by Tk_MaintainGeometry, there is one of these structures - * associated with its master. + * each content managed by Tk_MaintainGeometry, there is one of these structures + * associated with its container. */ -typedef struct MaintainSlave { - Tk_Window slave; /* The slave window being positioned. */ - Tk_Window master; /* The master that determines slave's +typedef struct MaintainContent { + Tk_Window content; /* The content window being positioned. */ + Tk_Window container; /* The container that determines content's * position; it must be a descendant of - * slave's parent. */ - int x, y; /* Desired position of slave relative to - * master. */ - int width, height; /* Desired dimensions of slave. */ - struct MaintainSlave *nextPtr; + * content's parent. */ + int x, y; /* Desired position of content relative to + * container. */ + int width, height; /* Desired dimensions of content. */ + struct MaintainContent *nextPtr; /* Next in list of Maintains associated with - * master. */ -} MaintainSlave; + * container. */ +} MaintainContent; /* - * For each window that has been specified as a master to Tk_MaintainGeometry, + * For each window that has been specified as a content to Tk_MaintainGeometry, * there is a structure of the following type: */ -typedef struct MaintainMaster { +typedef struct MaintainContainer { Tk_Window ancestor; /* The lowest ancestor of this window for * which we have *not* created a * StructureNotify handler. May be the same as * the window itself. */ int checkScheduled; /* Non-zero means that there is already a call * to MaintainCheckProc scheduled as an idle * handler. */ - MaintainSlave *slavePtr; /* First in list of all slaves associated with - * this master. */ -} MaintainMaster; + MaintainContent *contentPtr; /* First in list of all content associated with + * this container. */ +} MaintainContainer; /* * Prototypes for static procedures in this file: */ static void MaintainCheckProc(ClientData clientData); -static void MaintainMasterProc(ClientData clientData, +static void MaintainContainerProc(ClientData clientData, XEvent *eventPtr); -static void MaintainSlaveProc(ClientData clientData, +static void MaintainContentProc(ClientData clientData, XEvent *eventPtr); /* *-------------------------------------------------------------- * * Tk_ManageGeometry -- * * Arrange for a particular procedure to manage the geometry of a given - * slave window. + * content window. * * Results: * None. * * Side effects: * Proc becomes the new geometry manager for tkwin, replacing any * previous geometry manager. The geometry manager will be notified (by * calling procedures in *mgrPtr) when interesting things happen in the * future. If there was an existing geometry manager for tkwin different - * from the new one, it is notified by calling its lostSlaveProc. + * from the new one, it is notified by calling its lostContentProc. * *-------------------------------------------------------------- */ void @@ -93,12 +93,12 @@ TkWindow *winPtr = (TkWindow *) tkwin; if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL) && ((winPtr->geomMgrPtr != mgrPtr) || (winPtr->geomData != clientData)) - && (winPtr->geomMgrPtr->lostSlaveProc != NULL)) { - winPtr->geomMgrPtr->lostSlaveProc(winPtr->geomData, tkwin); + && (winPtr->geomMgrPtr->lostContentProc != NULL)) { + winPtr->geomMgrPtr->lostContentProc(winPtr->geomData, tkwin); } winPtr->geomMgrPtr = mgrPtr; winPtr->geomData = clientData; } @@ -216,11 +216,11 @@ winPtr->internalBorderBottom = bottom; changed = 1; } /* - * All the slaves for which this is the master window must now be + * All the content for which this is the container window must now be * repositioned to take account of the new internal border width. To * signal all the geometry managers to do this, trigger a ConfigureNotify * event. This will cause geometry managers to recompute everything. */ @@ -301,82 +301,82 @@ } /* *---------------------------------------------------------------------- * - * TkSetGeometryMaster -- + * TkSetGeometryContainer -- * - * Set a geometry master for this window. Only one master may own + * Set a geometry container for this window. Only one container may own * a window at any time. * * Results: * A standard Tcl result. * * Side effects: - * The geometry master is recorded for the window. + * The geometry container is recorded for the window. * *---------------------------------------------------------------------- */ int -TkSetGeometryMaster( +TkSetGeometryContainer( Tcl_Interp *interp, /* Current interpreter, for error. */ - Tk_Window tkwin, /* Window that will have geometry master + Tk_Window tkwin, /* Window that will have geometry container * set. */ - const char *master) /* The master identity. */ + const char *name) /* The name of the geometry manager. */ { TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->geomMgrName != NULL && - strcmp(winPtr->geomMgrName, master) == 0) { + strcmp(winPtr->geomMgrName, name) == 0) { return TCL_OK; } if (winPtr->geomMgrName != NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "cannot use geometry manager %s inside %s which already" - " has slaves managed by %s", - master, Tk_PathName(tkwin), winPtr->geomMgrName)); + "cannot use geometry manager %s inside %s because" + " %s is already managing it's content windows", + name, Tk_PathName(tkwin), winPtr->geomMgrName)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL); } return TCL_ERROR; } - winPtr->geomMgrName = (char *)ckalloc(strlen(master) + 1); - strcpy(winPtr->geomMgrName, master); + winPtr->geomMgrName = (char *)ckalloc(strlen(name) + 1); + strcpy(winPtr->geomMgrName, name); return TCL_OK; } /* *---------------------------------------------------------------------- * - * TkFreeGeometryMaster -- + * TkFreeGeometryContainer -- * - * Remove a geometry master for this window. Only one master may own + * Remove a geometry container for this window. Only one container may own * a window at any time. * * Results: * None. * * Side effects: - * The geometry master is cleared for the window. + * The geometry container is cleared for the window. * *---------------------------------------------------------------------- */ void -TkFreeGeometryMaster( - Tk_Window tkwin, /* Window that will have geometry master +TkFreeGeometryContainer( + Tk_Window tkwin, /* Window that will have geometry container * cleared. */ - const char *master) /* The master identity. */ + const char *name) /* The name of the geometry manager. */ { TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->geomMgrName != NULL && - strcmp(winPtr->geomMgrName, master) != 0) { + strcmp(winPtr->geomMgrName, name) != 0) { Tcl_Panic("Trying to free %s from geometry manager %s", - winPtr->geomMgrName, master); + winPtr->geomMgrName, name); } if (winPtr->geomMgrName != NULL) { ckfree(winPtr->geomMgrName); winPtr->geomMgrName = NULL; } @@ -385,24 +385,24 @@ /* *---------------------------------------------------------------------- * * Tk_MaintainGeometry -- * - * This procedure is invoked by geometry managers to handle slaves whose - * master's are not their parents. It translates the desired geometry for - * the slave into the coordinate system of the parent and respositions - * the slave if it isn't already at the right place. Furthermore, it sets - * up event handlers so that if the master (or any of its ancestors up to - * the slave's parent) is mapped, unmapped, or moved, then the slave will + * This procedure is invoked by geometry managers to handle content whose + * container's are not their parents. It translates the desired geometry for + * the content into the coordinate system of the parent and respositions + * the content if it isn't already at the right place. Furthermore, it sets + * up event handlers so that if the container (or any of its ancestors up to + * the content's parent) is mapped, unmapped, or moved, then the content will * be adjusted to match. * * Results: * None. * * Side effects: * Event handlers are created and state is allocated to keep track of - * slave. Note: if slave was already managed for master by + * content. Note: if content was already managed for container by * Tk_MaintainGeometry, then the previous information is replaced with * the new information. The caller must eventually call * Tk_UnmaintainGeometry to eliminate the correspondence (or, the state * is automatically freed when either window is destroyed). * @@ -409,44 +409,43 @@ *---------------------------------------------------------------------- */ void Tk_MaintainGeometry( - Tk_Window slave, /* Slave for geometry management. */ - Tk_Window master, /* Master for slave; must be a descendant of - * slave's parent. */ - int x, int y, /* Desired position of slave within master. */ - int width, int height) /* Desired dimensions for slave. */ + Tk_Window window, /* Window for geometry management. */ + Tk_Window container, /* Container for window; must be a descendant of + * window's parent. */ + int x, int y, /* Desired position of window within container. */ + int width, int height) /* Desired dimensions for window. */ { Tcl_HashEntry *hPtr; - MaintainMaster *masterPtr; - MaintainSlave *slavePtr; + MaintainContainer *containerPtr; + MaintainContent *contentPtr; int isNew, map; Tk_Window ancestor, parent; - TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) container)->dispPtr; - ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master; + ((TkWindow *)window)->maintainerPtr = (TkWindow *)container; - ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master; - if (master == Tk_Parent(slave)) { + if (container == Tk_Parent(window)) { /* - * If the slave is a direct descendant of the master, don't bother + * If the window is a direct descendant of the container, don't bother * setting up the extra infrastructure for management, just make a * call to Tk_MoveResizeWindow; the parent/child relationship will * take care of the rest. */ - Tk_MoveResizeWindow(slave, x, y, width, height); + Tk_MoveResizeWindow(window, x, y, width, height); /* - * Map the slave if the master is already mapped; otherwise, wait - * until the master is mapped later (in which case mapping the slave + * Map the window if the container is already mapped; otherwise, wait + * until the container is mapped later (in which case mapping the window * is taken care of elsewhere). */ - if (Tk_IsMapped(master)) { - Tk_MapWindow(slave); + if (Tk_IsMapped(container)) { + Tk_MapWindow(window); } return; } if (!dispPtr->geomInit) { @@ -453,88 +452,88 @@ dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); } /* - * See if there is already a MaintainMaster structure for the master; if + * See if there is already a MaintainContainer structure for the container; if * not, then create one. */ - parent = Tk_Parent(slave); + parent = Tk_Parent(window); hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable, - (char *) master, &isNew); + (char *) container, &isNew); if (!isNew) { - masterPtr = (MaintainMaster *)Tcl_GetHashValue(hPtr); + containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr); } else { - masterPtr = (MaintainMaster *)ckalloc(sizeof(MaintainMaster)); - masterPtr->ancestor = master; - masterPtr->checkScheduled = 0; - masterPtr->slavePtr = NULL; - Tcl_SetHashValue(hPtr, masterPtr); + containerPtr = (MaintainContainer *)ckalloc(sizeof(MaintainContainer)); + containerPtr->ancestor = container; + containerPtr->checkScheduled = 0; + containerPtr->contentPtr = NULL; + Tcl_SetHashValue(hPtr, containerPtr); } /* - * Create a MaintainSlave structure for the slave if there isn't already + * Create a MaintainContent structure for the window if there isn't already * one. */ - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if (slavePtr->slave == slave) { - goto gotSlave; + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if (contentPtr->content == window) { + goto gotContent; } } - slavePtr = (MaintainSlave *)ckalloc(sizeof(MaintainSlave)); - slavePtr->slave = slave; - slavePtr->master = master; - slavePtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = slavePtr; - Tk_CreateEventHandler(slave, StructureNotifyMask, MaintainSlaveProc, - slavePtr); + contentPtr = (MaintainContent *)ckalloc(sizeof(MaintainContent)); + contentPtr->content = window; + contentPtr->container = container; + contentPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = contentPtr; + Tk_CreateEventHandler(window, StructureNotifyMask, MaintainContentProc, + contentPtr); /* * Make sure that there are event handlers registered for all the windows - * between master and slave's parent (including master but not slave's - * parent). There may already be handlers for master and some of its - * ancestors (masterPtr->ancestor tells how many). + * between container and windows's parent (including container but not window's + * parent). There may already be handlers for container and some of its + * ancestors (containerPtr->ancestor tells how many). */ - for (ancestor = master; ancestor != parent; + for (ancestor = container; ancestor != parent; ancestor = Tk_Parent(ancestor)) { - if (ancestor == masterPtr->ancestor) { + if (ancestor == containerPtr->ancestor) { Tk_CreateEventHandler(ancestor, StructureNotifyMask, - MaintainMasterProc, masterPtr); - masterPtr->ancestor = Tk_Parent(ancestor); + MaintainContainerProc, containerPtr); + containerPtr->ancestor = Tk_Parent(ancestor); } } /* * Fill in up-to-date information in the structure, then update the window * if it's not currently in the right place or state. */ - gotSlave: - slavePtr->x = x; - slavePtr->y = y; - slavePtr->width = width; - slavePtr->height = height; + gotContent: + contentPtr->x = x; + contentPtr->y = y; + contentPtr->width = width; + contentPtr->height = height; map = 1; - for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) { + for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) { if (!Tk_IsMapped(ancestor) && (ancestor != parent)) { map = 0; } if (ancestor == parent) { - if ((x != Tk_X(slavePtr->slave)) - || (y != Tk_Y(slavePtr->slave)) - || (width != Tk_Width(slavePtr->slave)) - || (height != Tk_Height(slavePtr->slave))) { - Tk_MoveResizeWindow(slavePtr->slave, x, y, width, height); + if ((x != Tk_X(contentPtr->content)) + || (y != Tk_Y(contentPtr->content)) + || (width != Tk_Width(contentPtr->content)) + || (height != Tk_Height(contentPtr->content))) { + Tk_MoveResizeWindow(contentPtr->content, x, y, width, height); } if (map) { - Tk_MapWindow(slavePtr->slave); + Tk_MapWindow(contentPtr->content); } else { - Tk_UnmapWindow(slavePtr->slave); + Tk_UnmapWindow(contentPtr->content); } break; } x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width; y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width; @@ -545,41 +544,40 @@ *---------------------------------------------------------------------- * * Tk_UnmaintainGeometry -- * * This procedure cancels a previous Tk_MaintainGeometry call, so that - * the relationship between slave and master is no longer maintained. + * the relationship between window and container is no longer maintained. * * Results: * None. * * Side effects: - * The slave is unmapped and state is released, so that slave won't track - * master any more. If we weren't previously managing slave relative to - * master, then this procedure has no effect. + * The window is unmapped and state is released, so that window won't track + * container any more. If we weren't previously managing window relative to + * container, then this procedure has no effect. * *---------------------------------------------------------------------- */ void Tk_UnmaintainGeometry( - Tk_Window slave, /* Slave for geometry management. */ - Tk_Window master) /* Master for slave; must be a descendant of - * slave's parent. */ + Tk_Window window, /* WIndow for geometry management. */ + Tk_Window container) /* Container for window; must be a descendant of + * window's parent. */ { Tcl_HashEntry *hPtr; - MaintainMaster *masterPtr; - MaintainSlave *slavePtr, *prevPtr; + MaintainContainer *containerPtr; + MaintainContent *contentPtr, *prevPtr; Tk_Window ancestor; - TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) window)->dispPtr; - ((TkWindow *)slave)->maintainerPtr = NULL; + ((TkWindow *)window)->maintainerPtr = NULL; - ((TkWindow *)slave)->maintainerPtr = NULL; - if (master == Tk_Parent(slave)) { + if (container == Tk_Parent(window)) { /* - * If the slave is a direct descendant of the master, + * If the window is a direct descendant of the container, * Tk_MaintainGeometry will not have set up any of the extra * infrastructure. Don't even bother to look for it, just return. */ return; } @@ -587,192 +585,192 @@ if (!dispPtr->geomInit) { dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); } - if (!(((TkWindow *) slave)->flags & TK_ALREADY_DEAD)) { - Tk_UnmapWindow(slave); - } - hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, master); - if (hPtr == NULL) { - return; - } - masterPtr = (MaintainMaster *)Tcl_GetHashValue(hPtr); - slavePtr = masterPtr->slavePtr; - if (slavePtr->slave == slave) { - masterPtr->slavePtr = slavePtr->nextPtr; - } else { - for (prevPtr = slavePtr, slavePtr = slavePtr->nextPtr; ; - prevPtr = slavePtr, slavePtr = slavePtr->nextPtr) { - if (slavePtr == NULL) { - return; - } - if (slavePtr->slave == slave) { - prevPtr->nextPtr = slavePtr->nextPtr; - break; - } - } - } - Tk_DeleteEventHandler(slavePtr->slave, StructureNotifyMask, - MaintainSlaveProc, slavePtr); - ckfree(slavePtr); - if (masterPtr->slavePtr == NULL) { - if (masterPtr->ancestor != NULL) { - for (ancestor = master; ; ancestor = Tk_Parent(ancestor)) { - Tk_DeleteEventHandler(ancestor, StructureNotifyMask, - MaintainMasterProc, masterPtr); - if (ancestor == masterPtr->ancestor) { - break; - } - } - } - if (masterPtr->checkScheduled) { - Tcl_CancelIdleCall(MaintainCheckProc, masterPtr); - } - Tcl_DeleteHashEntry(hPtr); - ckfree(masterPtr); + if (!(((TkWindow *) window)->flags & TK_ALREADY_DEAD)) { + Tk_UnmapWindow(window); + } + hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, container); + if (hPtr == NULL) { + return; + } + containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr); + contentPtr = containerPtr->contentPtr; + if (contentPtr->content == window) { + containerPtr->contentPtr = contentPtr->nextPtr; + } else { + for (prevPtr = contentPtr, contentPtr = contentPtr->nextPtr; ; + prevPtr = contentPtr, contentPtr = contentPtr->nextPtr) { + if (contentPtr == NULL) { + return; + } + if (contentPtr->content == window) { + prevPtr->nextPtr = contentPtr->nextPtr; + break; + } + } + } + Tk_DeleteEventHandler(contentPtr->content, StructureNotifyMask, + MaintainContentProc, contentPtr); + ckfree(contentPtr); + if (containerPtr->contentPtr == NULL) { + if (containerPtr->ancestor != NULL) { + for (ancestor = container; ; ancestor = Tk_Parent(ancestor)) { + Tk_DeleteEventHandler(ancestor, StructureNotifyMask, + MaintainContainerProc, containerPtr); + if (ancestor == containerPtr->ancestor) { + break; + } + } + } + if (containerPtr->checkScheduled) { + Tcl_CancelIdleCall(MaintainCheckProc, containerPtr); + } + Tcl_DeleteHashEntry(hPtr); + ckfree(containerPtr); } } /* *---------------------------------------------------------------------- * - * MaintainMasterProc -- + * MaintainContainerProc -- * * This procedure is invoked by the Tk event dispatcher in response to - * StructureNotify events on the master or one of its ancestors, on + * StructureNotify events on the container or one of its ancestors, on * behalf of Tk_MaintainGeometry. * * Results: * None. * * Side effects: * It schedules a call to MaintainCheckProc, which will eventually caused * the postions and mapped states to be recalculated for all the - * maintained slaves of the master. Or, if the master window is being + * maintained windows of the container. Or, if the container window is being * deleted then state is cleaned up. * *---------------------------------------------------------------------- */ static void -MaintainMasterProc( - ClientData clientData, /* Pointer to MaintainMaster structure for the - * master window. */ +MaintainContainerProc( + ClientData clientData, /* Pointer to MaintainContainer structure for the + * container window. */ XEvent *eventPtr) /* Describes what just happened. */ { - MaintainMaster *masterPtr = (MaintainMaster *)clientData; - MaintainSlave *slavePtr; + MaintainContainer *containerPtr = (MaintainContainer *)clientData; + MaintainContent *contentPtr; int done; if ((eventPtr->type == ConfigureNotify) || (eventPtr->type == MapNotify) || (eventPtr->type == UnmapNotify)) { - if (!masterPtr->checkScheduled) { - masterPtr->checkScheduled = 1; - Tcl_DoWhenIdle(MaintainCheckProc, masterPtr); + if (!containerPtr->checkScheduled) { + containerPtr->checkScheduled = 1; + Tcl_DoWhenIdle(MaintainCheckProc, containerPtr); } } else if (eventPtr->type == DestroyNotify) { /* - * Delete all of the state associated with this master, but be careful - * not to use masterPtr after the last slave is deleted, since its + * Delete all of the state associated with this container, but be careful + * not to use containerPtr after the last window is deleted, since its * memory will have been freed. */ done = 0; do { - slavePtr = masterPtr->slavePtr; - if (slavePtr->nextPtr == NULL) { + contentPtr = containerPtr->contentPtr; + if (contentPtr->nextPtr == NULL) { done = 1; } - Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master); + Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container); } while (!done); } } /* *---------------------------------------------------------------------- * - * MaintainSlaveProc -- + * MaintainContentProc -- * * This procedure is invoked by the Tk event dispatcher in response to - * StructureNotify events on a slave being managed by + * StructureNotify events on a window being managed by * Tk_MaintainGeometry. * * Results: * None. * * Side effects: * If the event is a DestroyNotify event then the Maintain state and - * event handlers for this slave are deleted. + * event handlers for this window are deleted. * *---------------------------------------------------------------------- */ static void -MaintainSlaveProc( - ClientData clientData, /* Pointer to MaintainSlave structure for - * master-slave pair. */ +MaintainContentProc( + ClientData clientData, /* Pointer to MaintainContent structure for + * container-window pair. */ XEvent *eventPtr) /* Describes what just happened. */ { - MaintainSlave *slavePtr = (MaintainSlave *)clientData; + MaintainContent *contentPtr = (MaintainContent *)clientData; if (eventPtr->type == DestroyNotify) { - Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master); + Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container); } } /* *---------------------------------------------------------------------- * * MaintainCheckProc -- * * This procedure is invoked by the Tk event dispatcher as an idle - * handler, when a master or one of its ancestors has been reconfigured, - * mapped, or unmapped. Its job is to scan all of the slaves for the - * master and reposition them, map them, or unmap them as needed to - * maintain their geometry relative to the master. + * handler, when a container or one of its ancestors has been reconfigured, + * mapped, or unmapped. Its job is to scan all of the windows for the + * container and reposition them, map them, or unmap them as needed to + * maintain their geometry relative to the container. * * Results: * None. * * Side effects: - * Slaves can get repositioned, mapped, or unmapped. + * Windows can get repositioned, mapped, or unmapped. * *---------------------------------------------------------------------- */ static void MaintainCheckProc( - ClientData clientData) /* Pointer to MaintainMaster structure for the - * master window. */ + ClientData clientData) /* Pointer to MaintainContainer structure for the + * container window. */ { - MaintainMaster *masterPtr = (MaintainMaster *)clientData; - MaintainSlave *slavePtr; + MaintainContainer *containerPtr = (MaintainContainer *)clientData; + MaintainContent *contentPtr; Tk_Window ancestor, parent; int x, y, map; - masterPtr->checkScheduled = 0; - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - parent = Tk_Parent(slavePtr->slave); - x = slavePtr->x; - y = slavePtr->y; + containerPtr->checkScheduled = 0; + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + parent = Tk_Parent(contentPtr->content); + x = contentPtr->x; + y = contentPtr->y; map = 1; - for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) { + for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) { if (!Tk_IsMapped(ancestor) && (ancestor != parent)) { map = 0; } if (ancestor == parent) { - if ((x != Tk_X(slavePtr->slave)) - || (y != Tk_Y(slavePtr->slave))) { - Tk_MoveWindow(slavePtr->slave, x, y); + if ((x != Tk_X(contentPtr->content)) + || (y != Tk_Y(contentPtr->content))) { + Tk_MoveWindow(contentPtr->content, x, y); } if (map) { - Tk_MapWindow(slavePtr->slave); + Tk_MapWindow(contentPtr->content); } else { - Tk_UnmapWindow(slavePtr->slave); + Tk_UnmapWindow(contentPtr->content); } break; } x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width; y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width; Index: generic/tkGet.c ================================================================== --- generic/tkGet.c +++ generic/tkGet.c @@ -4,12 +4,12 @@ * This file contains a number of "Tk_GetXXX" procedures, which parse * text strings into useful forms for Tk. This file has the simpler * functions, like Tk_GetDirection and Tk_GetUid. The more complex * functions like Tk_GetColor are in separate files. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -491,15 +491,14 @@ *---------------------------------------------------------------------- */ static void FreeUidThreadExitProc( - ClientData dummy) /* Not used. */ + TCL_UNUSED(void *)) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)dummy; Tcl_DeleteHashTable(&tsdPtr->uidTable); tsdPtr->initialized = 0; } @@ -693,10 +692,15 @@ double *doublePtr) /* Place to store converted result. */ { char *end; double d; + if (!tkwin) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad screen")); + Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL); + return TCL_ERROR; + } d = strtod((char *) string, &end); if (end == string) { goto error; } while ((*end != '\0') && isspace(UCHAR(*end))) { Index: generic/tkGrab.c ================================================================== --- generic/tkGrab.c +++ generic/tkGrab.c @@ -1,12 +1,12 @@ /* * tkGrab.c -- * * This file provides functions that implement grabs for Tk. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -213,11 +213,11 @@ /* * First check for a window name or "-global" as the first argument. */ - arg = TkGetStringFromObj(objv[1], &len); + arg = Tcl_GetStringFromObj(objv[1], &len); if (arg[0] == '.') { /* [grab window] */ if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "?-global? window"); return TCL_ERROR; @@ -268,20 +268,20 @@ if (tkwin == NULL) { return TCL_ERROR; } dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr->eventualGrabWinPtr != NULL) { - Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) + Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window) dispPtr->eventualGrabWinPtr)); } } else { Tcl_Obj *resultObj = Tcl_NewObj(); for (dispPtr = TkGetDisplayList(); dispPtr != NULL; dispPtr = dispPtr->nextPtr) { if (dispPtr->eventualGrabWinPtr != NULL) { - Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj( + Tcl_ListObjAppendElement(NULL, resultObj, Tk_NewWindowObj( (Tk_Window) dispPtr->eventualGrabWinPtr)); } } Tcl_SetObjResult(interp, resultObj); } @@ -664,10 +664,13 @@ * TkPointerEvent -- * * This function is called for each pointer-related event, before the * event has been processed. It does various things to make grabs work * correctly. + * Also, this function takes care of warping the mouse pointer with + * respect to a given window, both when there is a grab in effect and + * when there is none. * * Results: * If the return value is 1 it means the event should be processed (event * handlers should be invoked). If the return value is 0 it means the * event should be ignored in order to make grabs work correctly. In some @@ -675,10 +678,11 @@ * * Side effects: * Grab state information may be updated. New events may also be pushed * back onto the event queue to replace or augment the one passed in * here. + * The mouse pointer may be moved. * *---------------------------------------------------------------------- */ int @@ -770,15 +774,29 @@ return 0; } } return 1; } + + if ((eventPtr->type == MotionNotify) && !appGrabbed) { + + /* + * Warp the mouse pointer with respect to window dispPtr->warpWindow + * if such a window was set in HandleEventGenerate. + */ + + TkDoWarpWrtWin(dispPtr); + } if (!appGrabbed) { return 1; } + /* + * From this point on, there is a grab in effect. + */ + if (eventPtr->type == MotionNotify) { /* * When grabs are active, X reports motion events relative to the * window under the pointer. Instead, it should report the events * relative to the window the button went down in, if there is a @@ -797,10 +815,17 @@ if (winPtr2 != winPtr) { TkChangeEventWindow(eventPtr, winPtr2); Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD); return 0; } + + /* + * Warp the mouse pointer with respect to window dispPtr->warpWindow + * if such a window was set in HandleEventGenerate. + */ + + TkDoWarpWrtWin(dispPtr); return 1; } /* * Process ButtonPress and ButtonRelease events: @@ -869,11 +894,11 @@ return 1; } } else { if (eventPtr->xbutton.button != AnyButton && ((eventPtr->xbutton.state & ALL_BUTTONS) - == TkGetButtonMask(eventPtr->xbutton.button))) { + == Tk_GetButtonMask(eventPtr->xbutton.button))) { ReleaseButtonGrab(dispPtr); /* Note 4. */ } } if (winPtr2 != winPtr) { TkChangeEventWindow(eventPtr, winPtr2); @@ -1368,16 +1393,15 @@ */ static int GrabWinEventProc( Tcl_Event *evPtr, /* Event of type NewGrabWinEvent. */ - int flags) /* Flags argument to Tcl_DoOneEvent: indicates + TCL_UNUSED(int)) /* Flags argument to Tcl_DoOneEvent: indicates * what kinds of events are being processed * right now. */ { NewGrabWinEvent *grabEvPtr = (NewGrabWinEvent *) evPtr; - (void)flags; grabEvPtr->dispPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow( grabEvPtr->dispPtr->display, grabEvPtr->grabWindow); return 1; } Index: generic/tkGrid.c ================================================================== --- generic/tkGrid.c +++ generic/tkGrid.c @@ -1,11 +1,11 @@ /* * tkGrid.c -- * * Grid based geometry manager. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -64,11 +64,11 @@ */ #define GRID_DEFAULT_ANCHOR TK_ANCHOR_NW /* - * Structure to hold information for grid masters. A slot is either a row or + * Structure to hold information for grid containers. A slot is either a row or * column. */ typedef struct SlotInfo { int minSize; /* The minimum size of this slot (in pixels). @@ -78,11 +78,11 @@ * this slot doesn't resize. Extra space in * the layout is given distributed among slots * inproportion to their weights. */ int pad; /* Extra padding, in pixels, required for this * slot. This amount is "added" to the largest - * slave in the slot. */ + * content in the slot. */ Tk_Uid uniform; /* Value of -uniform option. It is used to * group slots that should have the same * size. */ int offset; /* This is a cached value used for * introspection. It is the pixel offset of @@ -97,17 +97,17 @@ * Structure to hold information during layout calculations. There is one of * these for each slot, an array for each of the rows or columns. */ typedef struct GridLayout { - struct Gridder *binNextPtr; /* The next slave window in this bin. Each bin - * contains a list of all slaves whose spans + struct Gridder *binNextPtr; /* The next content window in this bin. Each bin + * contains a list of all content whose spans * are >1 and whose right edges fall in this * slot. */ int minSize; /* Minimum size needed for this slot, in * pixels. This is the space required to hold - * any slaves contained entirely in this slot, + * any content contained entirely in this slot, * adjusted for any slot constrants, such as * size or padding. */ int pad; /* Padding needed for this slot */ int weight; /* Slot weight, controls resizing. */ Tk_Uid uniform; /* Value of -uniform option. It is used to @@ -122,55 +122,55 @@ * edge of the slot calculated from * bottom/right to top/left. */ } GridLayout; /* - * Keep one of these for each geometry master. + * Keep one of these for each geometry container. */ typedef struct { SlotInfo *columnPtr; /* Pointer to array of column constraints. */ SlotInfo *rowPtr; /* Pointer to array of row constraints. */ - int columnEnd; /* The last column occupied by any slave. */ + int columnEnd; /* The last column occupied by any content. */ int columnMax; /* The number of columns with constraints. */ int columnSpace; /* The number of slots currently allocated for * column constraints. */ - int rowEnd; /* The last row occupied by any slave. */ + int rowEnd; /* The last row occupied by any content. */ int rowMax; /* The number of rows with constraints. */ int rowSpace; /* The number of slots currently allocated for * row constraints. */ int startX; /* Pixel offset of this layout within its - * master. */ + * container. */ int startY; /* Pixel offset of this layout within its - * master. */ + * container. */ Tk_Anchor anchor; /* Value of anchor option: specifies where a * grid without weight should be placed. */ -} GridMaster; +} GridContainer; /* * For each window that the grid cares about (either because the window is - * managed by the grid or because the window has slaves that are managed by + * managed by the grid or because the window has content that are managed by * the grid), there is a structure of the following type: */ typedef struct Gridder { Tk_Window tkwin; /* Tk token for window. NULL means that the * window has been deleted, but the gridder * hasn't had a chance to clean up yet because * the structure is still in use. */ - struct Gridder *masterPtr; /* Master window within which this window is + struct Gridder *containerPtr; /* Container window within which this window is * managed (NULL means this window isn't * managed by the gridder). */ - struct Gridder *nextPtr; /* Next window managed within same master. + struct Gridder *nextPtr; /* Next window managed within same container. * List order doesn't matter. */ - struct Gridder *slavePtr; /* First in list of slaves managed inside this - * window (NULL means no grid slaves). */ - GridMaster *masterDataPtr; /* Additional data for geometry master. */ - Tcl_Obj *in; /* Store master name when removed. */ + struct Gridder *contentPtr; /* First in list of content managed inside this + * window (NULL means no grid content). */ + GridContainer *containerDataPtr; /* Additional data for geometry container. */ + Tcl_Obj *in; /* Store container name when removed. */ int column, row; /* Location in the grid (starting from * zero). */ - int numCols, numRows; /* Number of columns or rows this slave spans. + int numCols, numRows; /* Number of columns or rows this content spans. * Should be at least 1. */ int padX, padY; /* Total additional pixels to leave around the * window. Some is of this space is on each * side. This is space *outside* the window: * we'll allocate extra space in frame but @@ -183,27 +183,27 @@ * each side). */ int sticky; /* which sides of its cavity this window * sticks to. See below for definitions */ int doubleBw; /* Twice the window's last known border width. * If this changes, the window must be - * re-arranged within its master. */ + * re-arranged within its container. */ int *abortPtr; /* If non-NULL, it means that there is a * nested call to ArrangeGrid already working * on this window. *abortPtr may be set to 1 * to abort that nested call. This happens, - * for example, if tkwin or any of its slaves + * for example, if tkwin or any of its content * is deleted. */ int flags; /* Miscellaneous flags; see below for * definitions. */ /* * These fields are used temporarily for layout calculations only. */ - struct Gridder *binNextPtr; /* Link to next span>1 slave in this bin. */ + struct Gridder *binNextPtr; /* Link to next span>1 content in this bin. */ int size; /* Nominal size (width or height) in pixels of - * the slave. This includes the padding. */ + * the content. This includes the padding. */ } Gridder; /* * Flag values for "sticky"ness. The 16 combinations subsume the packer's * notion of anchor and fill. @@ -233,36 +233,36 @@ /* * Flag values for Grid structures: * * REQUESTED_RELAYOUT 1 means a Tcl_DoWhenIdle request has already - * been made to re-arrange all the slaves of this + * been made to re-arrange all the content of this * window. * DONT_PROPAGATE 1 means don't set this window's requested - * size. 0 means if this window is a master then + * size. 0 means if this window is a container then * Tk will set its requested size to fit the - * needs of its slaves. - * ALLOCED_MASTER 1 means that Grid has allocated itself as - * geometry master for this window. + * needs of its content. + * ALLOCED_CONTAINER 1 means that Grid has allocated itself as + * geometry container for this window. */ #define REQUESTED_RELAYOUT 1 #define DONT_PROPAGATE 2 -#define ALLOCED_MASTER 4 +#define ALLOCED_CONTAINER 4 /* * Prototypes for procedures used only in this file: */ -static void AdjustForSticky(Gridder *slavePtr, int *xPtr, +static void AdjustForSticky(Gridder *contentPtr, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); static int AdjustOffsets(int width, int elements, SlotInfo *slotPtr); static void ArrangeGrid(ClientData clientData); -static int CheckSlotData(Gridder *masterPtr, int slot, +static int CheckSlotData(Gridder *containerPtr, int slot, int slotType, int checkOnly); -static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin, +static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin, int objc, Tcl_Obj *const objv[]); static void DestroyGrid(void *memPtr); static Gridder * GetGrid(Tk_Window tkwin); static int GridAnchorCommand(Tk_Window tkwin, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); @@ -282,35 +282,35 @@ static int GridRowColumnConfigureCommand(Tk_Window tkwin, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int GridSizeCommand(Tk_Window tkwin, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int GridSlavesCommand(Tk_Window tkwin, Tcl_Interp *interp, +static int GridContentCommand(Tk_Window tkwin, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void GridStructureProc(ClientData clientData, XEvent *eventPtr); -static void GridLostSlaveProc(ClientData clientData, +static void GridLostContentProc(ClientData clientData, Tk_Window tkwin); static void GridReqProc(ClientData clientData, Tk_Window tkwin); -static void InitMasterData(Gridder *masterPtr); +static void InitContainerData(Gridder *containerPtr); static Tcl_Obj * NewPairObj(Tcl_WideInt, Tcl_WideInt); static Tcl_Obj * NewQuadObj(Tcl_WideInt, Tcl_WideInt, Tcl_WideInt, Tcl_WideInt); static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn, int maxOffset); static void SetGridSize(Gridder *gridPtr); -static int SetSlaveColumn(Tcl_Interp *interp, Gridder *slavePtr, +static int SetContentColumn(Tcl_Interp *interp, Gridder *contentPtr, int column, int numCols); -static int SetSlaveRow(Tcl_Interp *interp, Gridder *slavePtr, +static int SetContentRow(Tcl_Interp *interp, Gridder *contentPtr, int row, int numRows); static Tcl_Obj * StickyToObj(int flags); static int StringToSticky(const char *string); static void Unlink(Gridder *gridPtr); static const Tk_GeomMgr gridMgrType = { "grid", /* name */ GridReqProc, /* requestProc */ - GridLostSlaveProc, /* lostSlaveProc */ + GridLostContentProc, /* lostContentProc */ }; /* *---------------------------------------------------------------------- * @@ -336,45 +336,58 @@ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window)clientData; static const char *const optionStrings[] = { "anchor", "bbox", "columnconfigure", "configure", - "forget", "info", "location", "propagate", "remove", - "rowconfigure", "size", "slaves", NULL + "content", "forget", "info", "location", "propagate", + "remove", "rowconfigure", "size", "slaves", NULL + }; + static const char *const optionStringsNoDep[] = { + "anchor", "bbox", "columnconfigure", "configure", + "content", "forget", "info", "location", "propagate", + "remove", "rowconfigure", "size", NULL }; enum options { GRID_ANCHOR, GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE, - GRID_FORGET, GRID_INFO, GRID_LOCATION, GRID_PROPAGATE, GRID_REMOVE, - GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES + GRID_CONTENT, GRID_FORGET, GRID_INFO, GRID_LOCATION, GRID_PROPAGATE, + GRID_REMOVE, GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES }; int index; if (objc >= 2) { const char *argv1 = Tcl_GetString(objv[1]); if ((argv1[0] == '.') || (argv1[0] == REL_SKIP) || (argv1[0] == REL_VERT)) { - return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + return ConfigureContent(interp, tkwin, objc-1, objv+1); } } if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + if (Tcl_GetIndexFromObjStruct(NULL, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { + /* + * Call it again without the deprecated ones to get a proper error + * message. This works well since there can't be any ambiguity between + * deprecated and new options. + */ + + Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep, + sizeof(char *), "option", 0, &index); return TCL_ERROR; } switch ((enum options) index) { case GRID_ANCHOR: return GridAnchorCommand(tkwin, interp, objc, objv); case GRID_BBOX: return GridBboxCommand(tkwin, interp, objc, objv); case GRID_CONFIGURE: - return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + return ConfigureContent(interp, tkwin, objc-2, objv+2); case GRID_FORGET: case GRID_REMOVE: return GridForgetRemoveCommand(tkwin, interp, objc, objv); case GRID_INFO: return GridInfoCommand(tkwin, interp, objc, objv); @@ -383,19 +396,20 @@ case GRID_PROPAGATE: return GridPropagateCommand(tkwin, interp, objc, objv); case GRID_SIZE: return GridSizeCommand(tkwin, interp, objc, objv); case GRID_SLAVES: - return GridSlavesCommand(tkwin, interp, objc, objv); + case GRID_CONTENT: + return GridContentCommand(tkwin, interp, objc, objv); /* * Sample argument combinations: - * grid columnconfigure -option - * grid columnconfigure -option value -option value - * grid rowconfigure - * grid rowconfigure -option - * grid rowconfigure -option value -option value. + * grid columnconfigure -option + * grid columnconfigure -option value -option value + * grid rowconfigure + * grid rowconfigure -option + * grid rowconfigure -option value -option value. */ case GRID_COLUMNCONFIGURE: case GRID_ROWCONFIGURE: return GridRowColumnConfigureCommand(tkwin, interp, objc, objv); @@ -429,35 +443,35 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; - GridMaster *gridPtr; + Tk_Window container; + Gridder *containerPtr; + GridContainer *gridPtr; Tk_Anchor old; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?anchor?"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); if (objc == 3) { - gridPtr = masterPtr->masterDataPtr; + gridPtr = containerPtr->containerDataPtr; Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfAnchor(gridPtr?gridPtr->anchor:GRID_DEFAULT_ANCHOR), -1)); return TCL_OK; } - InitMasterData(masterPtr); - gridPtr = masterPtr->masterDataPtr; + InitContainerData(containerPtr); + gridPtr = containerPtr->containerDataPtr; old = gridPtr->anchor; if (Tk_GetAnchorFromObj(interp, objv[3], &gridPtr->anchor) != TCL_OK) { return TCL_ERROR; } @@ -464,16 +478,16 @@ /* * Only request a relayout if the anchor changes. */ if (old != gridPtr->anchor) { - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + if (!(containerPtr->flags & REQUESTED_RELAYOUT)) { + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } } return TCL_OK; } @@ -498,28 +512,28 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; /* master grid record */ - GridMaster *gridPtr; /* pointer to grid data */ + Tk_Window container; + Gridder *containerPtr; /* container grid record */ + GridContainer *gridPtr; /* pointer to grid data */ int row, column; /* origin for bounding box */ int row2, column2; /* end of bounding box */ int endX, endY; /* last column/row in the layout */ int x=0, y=0; /* starting pixels for this bounding box */ int width, height; /* size of the bounding box */ if (objc!=3 && objc != 5 && objc != 7) { - Tcl_WrongNumArgs(interp, 2, objv, "master ?column row ?column row??"); + Tcl_WrongNumArgs(interp, 2, objv, "window ?column row ?column row??"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); if (objc >= 5) { if (Tcl_GetIntFromObj(interp, objv[3], &column) != TCL_OK) { return TCL_ERROR; } @@ -537,17 +551,17 @@ if (Tcl_GetIntFromObj(interp, objv[6], &row2) != TCL_OK) { return TCL_ERROR; } } - gridPtr = masterPtr->masterDataPtr; + gridPtr = containerPtr->containerDataPtr; if (gridPtr == NULL) { Tcl_SetObjResult(interp, NewQuadObj(0, 0, 0, 0)); return TCL_OK; } - SetGridSize(masterPtr); + SetGridSize(containerPtr); endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); if ((endX == 0) || (endY == 0)) { Tcl_SetObjResult(interp, NewQuadObj(0, 0, 0, 0)); @@ -628,71 +642,71 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window slave; - Gridder *slavePtr; + Tk_Window content; + Gridder *contentPtr; int i; const char *string = Tcl_GetString(objv[1]); char c = string[0]; for (i = 2; i < objc; i++) { - if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) { return TCL_ERROR; } - slavePtr = GetGrid(slave); - if (slavePtr->masterPtr != NULL) { + contentPtr = GetGrid(content); + if (contentPtr->containerPtr != NULL) { /* * For "forget", reset all the settings to their defaults */ if (c == 'f') { - slavePtr->column = -1; - slavePtr->row = -1; - slavePtr->numCols = 1; - slavePtr->numRows = 1; - slavePtr->padX = 0; - slavePtr->padY = 0; - slavePtr->padLeft = 0; - slavePtr->padTop = 0; - slavePtr->iPadX = 0; - slavePtr->iPadY = 0; - if (slavePtr->in != NULL) { - Tcl_DecrRefCount(slavePtr->in); - slavePtr->in = NULL; - } - slavePtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; - if (slavePtr->flags & REQUESTED_RELAYOUT) { - Tcl_CancelIdleCall(ArrangeGrid, slavePtr); - } - slavePtr->flags = 0; - slavePtr->sticky = 0; + contentPtr->column = -1; + contentPtr->row = -1; + contentPtr->numCols = 1; + contentPtr->numRows = 1; + contentPtr->padX = 0; + contentPtr->padY = 0; + contentPtr->padLeft = 0; + contentPtr->padTop = 0; + contentPtr->iPadX = 0; + contentPtr->iPadY = 0; + if (contentPtr->in != NULL) { + Tcl_DecrRefCount(contentPtr->in); + contentPtr->in = NULL; + } + contentPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; + if (contentPtr->flags & REQUESTED_RELAYOUT) { + Tcl_CancelIdleCall(ArrangeGrid, contentPtr); + } + contentPtr->flags = 0; + contentPtr->sticky = 0; } else { /* - * When removing, store name of master to be able to - * restore it later, even if the master is recreated. + * When removing, store name of container to be able to + * restore it later, even if the container is recreated. */ - if (slavePtr->in != NULL) { - Tcl_DecrRefCount(slavePtr->in); - slavePtr->in = NULL; - } - if (slavePtr->masterPtr != NULL) { - slavePtr->in = Tcl_NewStringObj( - Tk_PathName(slavePtr->masterPtr->tkwin), -1); - Tcl_IncrRefCount(slavePtr->in); - } - } - Tk_ManageGeometry(slave, NULL, NULL); - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + if (contentPtr->in != NULL) { + Tcl_DecrRefCount(contentPtr->in); + contentPtr->in = NULL; + } + if (contentPtr->containerPtr != NULL) { + contentPtr->in = Tcl_NewStringObj( + Tk_PathName(contentPtr->containerPtr->tkwin), -1); + Tcl_IncrRefCount(contentPtr->in); + } + } + Tk_ManageGeometry(content, NULL, NULL); + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, + contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } } return TCL_OK; } @@ -718,44 +732,44 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Gridder *slavePtr; - Tk_Window slave; + Gridder *contentPtr; + Tk_Window content; Tcl_Obj *infoObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &content) != TCL_OK) { return TCL_ERROR; } - slavePtr = GetGrid(slave); - if (slavePtr->masterPtr == NULL) { + contentPtr = GetGrid(content); + if (contentPtr->containerPtr == NULL) { Tcl_ResetResult(interp); return TCL_OK; } infoObj = Tcl_NewObj(); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1), - TkNewWindowObj(slavePtr->masterPtr->tkwin)); + Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1), - Tcl_NewWideIntObj(slavePtr->column)); + Tcl_NewWideIntObj(contentPtr->column)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1), - Tcl_NewWideIntObj(slavePtr->row)); + Tcl_NewWideIntObj(contentPtr->row)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1), - Tcl_NewWideIntObj(slavePtr->numCols)); + Tcl_NewWideIntObj(contentPtr->numCols)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1), - Tcl_NewWideIntObj(slavePtr->numRows)); - TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX); - TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY); - TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft, slavePtr->padX); - TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY); + Tcl_NewWideIntObj(contentPtr->numRows)); + TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX); + TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY); + TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft, contentPtr->padX); + TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-sticky", -1), - StickyToObj(slavePtr->sticky)); + StickyToObj(contentPtr->sticky)); Tcl_SetObjResult(interp, infoObj); return TCL_OK; } /* @@ -780,70 +794,70 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; /* Master grid record. */ - GridMaster *gridPtr; /* Pointer to grid data. */ + Tk_Window container; + Gridder *containerPtr; /* Container grid record. */ + GridContainer *gridPtr; /* Pointer to grid data. */ SlotInfo *slotPtr; - int x, y; /* Offset in pixels, from edge of master. */ + int x, y; /* Offset in pixels, from edge of container. */ int i, j; /* Corresponding column and row indeces. */ int endX, endY; /* End of grid. */ if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "master x y"); + Tcl_WrongNumArgs(interp, 2, objv, "window x y"); + return TCL_ERROR; + } + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (Tk_GetPixelsFromObj(interp, container, objv[3], &x) != TCL_OK) { return TCL_ERROR; } - - if (Tk_GetPixelsFromObj(interp, master, objv[3], &x) != TCL_OK) { - return TCL_ERROR; - } - if (Tk_GetPixelsFromObj(interp, master, objv[4], &y) != TCL_OK) { + if (Tk_GetPixelsFromObj(interp, container, objv[4], &y) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); - if (masterPtr->masterDataPtr == NULL) { + containerPtr = GetGrid(container); + if (containerPtr->containerDataPtr == NULL) { Tcl_SetObjResult(interp, NewPairObj(-1, -1)); return TCL_OK; } - gridPtr = masterPtr->masterDataPtr; + gridPtr = containerPtr->containerDataPtr; /* * Update any pending requests. This is not always the steady state value, * as more configure events could be in the pipeline, but its as close as * its easy to get. */ - while (masterPtr->flags & REQUESTED_RELAYOUT) { - Tcl_CancelIdleCall(ArrangeGrid, masterPtr); - ArrangeGrid(masterPtr); + while (containerPtr->flags & REQUESTED_RELAYOUT) { + Tcl_CancelIdleCall(ArrangeGrid, containerPtr); + ArrangeGrid(containerPtr); } - SetGridSize(masterPtr); + SetGridSize(containerPtr); endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); - slotPtr = masterPtr->masterDataPtr->columnPtr; - if (x < masterPtr->masterDataPtr->startX) { + slotPtr = containerPtr->containerDataPtr->columnPtr; + if (x < containerPtr->containerDataPtr->startX) { i = -1; } else { - x -= masterPtr->masterDataPtr->startX; + x -= containerPtr->containerDataPtr->startX; for (i = 0; slotPtr[i].offset < x && i < endX; i++) { /* null body */ } } - slotPtr = masterPtr->masterDataPtr->rowPtr; - if (y < masterPtr->masterDataPtr->startY) { + slotPtr = containerPtr->containerDataPtr->rowPtr; + if (y < containerPtr->containerDataPtr->startY) { j = -1; } else { - y -= masterPtr->masterDataPtr->startY; + y -= containerPtr->containerDataPtr->startY; for (j = 0; slotPtr[j].offset < y && j < endY; j++) { /* null body */ } } @@ -873,26 +887,26 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; + Tk_Window container; + Gridder *containerPtr; int propagate, old; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); if (objc == 3) { Tcl_SetObjResult(interp, - Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); + Tcl_NewBooleanObj(!(containerPtr->flags & DONT_PROPAGATE))); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { return TCL_ERROR; } @@ -899,43 +913,43 @@ /* * Only request a relayout if the propagation bit changes. */ - old = !(masterPtr->flags & DONT_PROPAGATE); + old = !(containerPtr->flags & DONT_PROPAGATE); if (propagate != old) { if (propagate) { /* - * If we have slaves, we need to register as geometry master. - */ - - if (masterPtr->slavePtr != NULL) { - if (TkSetGeometryMaster(interp, master, "grid") != TCL_OK) { - return TCL_ERROR; - } - masterPtr->flags |= ALLOCED_MASTER; - } - masterPtr->flags &= ~DONT_PROPAGATE; - } else { - if (masterPtr->flags & ALLOCED_MASTER) { - TkFreeGeometryMaster(master, "grid"); - masterPtr->flags &= ~ALLOCED_MASTER; - } - masterPtr->flags |= DONT_PROPAGATE; - } - - /* - * Re-arrange the master to allow new geometry information to - * propagate upwards to the master's master. - */ - - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + * If we have content, we need to register as geometry container. + */ + + if (containerPtr->contentPtr != NULL) { + if (TkSetGeometryContainer(interp, container, "grid") != TCL_OK) { + return TCL_ERROR; + } + containerPtr->flags |= ALLOCED_CONTAINER; + } + containerPtr->flags &= ~DONT_PROPAGATE; + } else { + if (containerPtr->flags & ALLOCED_CONTAINER) { + TkFreeGeometryContainer(container, "grid"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + } + containerPtr->flags |= DONT_PROPAGATE; + } + + /* + * Re-arrange the container to allow new geometry information to + * propagate upwards to the container's container. + */ + + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + if (!(containerPtr->flags & REQUESTED_RELAYOUT)) { + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } } return TCL_OK; } @@ -961,12 +975,12 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master, slave; - Gridder *masterPtr, *slavePtr; + Tk_Window container, content; + Gridder *containerPtr, *contentPtr; SlotInfo *slotPtr = NULL; int slot; /* the column or row number */ int slotType; /* COLUMN or ROW */ int size; /* the configuration value */ int lObjc; /* Number of items in index list */ @@ -982,15 +996,15 @@ }; int index; Tcl_Obj *listCopy; if (((objc % 2 != 0) && (objc > 6)) || (objc < 4)) { - Tcl_WrongNumArgs(interp, 2, objv, "master index ?-option value ...?"); + Tcl_WrongNumArgs(interp, 2, objv, "window index ?-option value ...?"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } listCopy = Tcl_DuplicateObj(objv[3]); Tcl_IncrRefCount(listCopy); @@ -1007,11 +1021,11 @@ Tcl_SetErrorCode(interp, "TK", "GRID", "NO_INDEX", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); first = 0; last = 0; if ((objc == 4) || (objc == 5)) { if (lObjc != 1) { @@ -1027,15 +1041,15 @@ "allowed)", NULL); Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_FORMAT", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } - ok = CheckSlotData(masterPtr, slot, slotType, /* checkOnly */ 1); + ok = CheckSlotData(containerPtr, slot, slotType, /* checkOnly */ 1); if (ok == TCL_OK) { slotPtr = (slotType == COLUMN) ? - masterPtr->masterDataPtr->columnPtr : - masterPtr->masterDataPtr->rowPtr; + containerPtr->containerDataPtr->columnPtr : + containerPtr->containerDataPtr->rowPtr; } /* * Return all of the options for this row or column. If the request is * out of range, return all 0's. @@ -1099,40 +1113,40 @@ Tcl_DecrRefCount(listCopy); return TCL_OK; } for (j = 0; j < lObjc; j++) { - int allSlaves = 0; + int allContent = 0; if (Tcl_GetIntFromObj(NULL, lObjv[j], &slot) == TCL_OK) { first = slot; last = slot; - slavePtr = NULL; + contentPtr = NULL; } else if (strcmp(Tcl_GetString(lObjv[j]), "all") == 0) { /* - * Make sure master is initialised. + * Make sure container is initialised. */ - InitMasterData(masterPtr); + InitContainerData(containerPtr); - slavePtr = masterPtr->slavePtr; - if (slavePtr == NULL) { + contentPtr = containerPtr->contentPtr; + if (contentPtr == NULL) { continue; } - allSlaves = 1; - } else if (TkGetWindowFromObj(NULL, tkwin, lObjv[j], &slave) + allContent = 1; + } else if (TkGetWindowFromObj(NULL, tkwin, lObjv[j], &content) == TCL_OK) { /* - * Is it gridded in this master? + * Is it gridded in this container? */ - slavePtr = GetGrid(slave); - if (slavePtr->masterPtr != masterPtr) { + contentPtr = GetGrid(content); + if (contentPtr->containerPtr != containerPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the window \"%s\" is not managed by \"%s\"", Tcl_GetString(lObjv[j]), Tcl_GetString(objv[2]))); - Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MASTER", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MANAGED", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -1145,19 +1159,19 @@ /* * The outer loop is only to handle "all". */ do { - if (slavePtr != NULL) { + if (contentPtr != NULL) { first = (slotType == COLUMN) ? - slavePtr->column : slavePtr->row; + contentPtr->column : contentPtr->row; last = first - 1 + ((slotType == COLUMN) ? - slavePtr->numCols : slavePtr->numRows); + contentPtr->numCols : contentPtr->numRows); } for (slot = first; slot <= last; slot++) { - ok = CheckSlotData(masterPtr, slot, slotType, /*checkOnly*/ 0); + ok = CheckSlotData(containerPtr, slot, slotType, /*checkOnly*/ 0); if (ok != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" is out of range", Tcl_GetString(lObjv[j]))); Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_RANGE", @@ -1164,12 +1178,12 @@ NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } slotPtr = (slotType == COLUMN) ? - masterPtr->masterDataPtr->columnPtr : - masterPtr->masterDataPtr->rowPtr; + containerPtr->containerDataPtr->columnPtr : + containerPtr->containerDataPtr->rowPtr; /* * Loop through each option value pair, setting the values as * required. */ @@ -1179,11 +1193,11 @@ sizeof(char *), "option", 0, &index) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } if (index == ROWCOL_MINSIZE) { - if (Tk_GetPixelsFromObj(interp, master, objv[i+1], + if (Tk_GetPixelsFromObj(interp, container, objv[i+1], &size) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } else { slotPtr[slot].minSize = size; @@ -1206,11 +1220,11 @@ if (slotPtr[slot].uniform != NULL && slotPtr[slot].uniform[0] == 0) { slotPtr[slot].uniform = NULL; } } else if (index == ROWCOL_PAD) { - if (Tk_GetPixelsFromObj(interp, master, objv[i+1], + if (Tk_GetPixelsFromObj(interp, container, objv[i+1], &size) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } else if (size < 0) { Tcl_DecrRefCount(listCopy); @@ -1219,14 +1233,14 @@ slotPtr[slot].pad = size; } } } } - if (slavePtr != NULL) { - slavePtr = slavePtr->nextPtr; + if (contentPtr != NULL) { + contentPtr = contentPtr->nextPtr; } - } while ((allSlaves == 1) && (slavePtr != NULL)); + } while ((allContent == 1) && (contentPtr != NULL)); } Tcl_DecrRefCount(listCopy); /* * We changed a property, re-arrange the table, and check for constraint @@ -1233,36 +1247,36 @@ * shrinkage. A null slotPtr will occur for 'all' checks. */ if (slotPtr != NULL) { if (slotType == ROW) { - int last = masterPtr->masterDataPtr->rowMax - 1; + last = containerPtr->containerDataPtr->rowMax - 1; while ((last >= 0) && (slotPtr[last].weight == 0) && (slotPtr[last].pad == 0) && (slotPtr[last].minSize == 0) && (slotPtr[last].uniform == NULL)) { last--; } - masterPtr->masterDataPtr->rowMax = last+1; + containerPtr->containerDataPtr->rowMax = last+1; } else { - int last = masterPtr->masterDataPtr->columnMax - 1; + last = containerPtr->containerDataPtr->columnMax - 1; while ((last >= 0) && (slotPtr[last].weight == 0) && (slotPtr[last].pad == 0) && (slotPtr[last].minSize == 0) && (slotPtr[last].uniform == NULL)) { last--; } - masterPtr->masterDataPtr->columnMax = last + 1; + containerPtr->containerDataPtr->columnMax = last + 1; } } - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + if (!(containerPtr->flags & REQUESTED_RELAYOUT)) { + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } return TCL_OK; negativeIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -1294,27 +1308,27 @@ Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; - GridMaster *gridPtr; /* pointer to grid data */ + Tk_Window container; + Gridder *containerPtr; + GridContainer *gridPtr; /* pointer to grid data */ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); - if (masterPtr->masterDataPtr != NULL) { - SetGridSize(masterPtr); - gridPtr = masterPtr->masterDataPtr; + if (containerPtr->containerDataPtr != NULL) { + SetGridSize(containerPtr); + gridPtr = containerPtr->containerDataPtr; Tcl_SetObjResult(interp, NewPairObj( MAX(gridPtr->columnEnd, gridPtr->columnMax), MAX(gridPtr->rowEnd, gridPtr->rowMax))); } else { Tcl_SetObjResult(interp, NewPairObj(0, 0)); @@ -1323,41 +1337,41 @@ } /* *---------------------------------------------------------------------- * - * GridSlavesCommand -- + * GridContentCommand -- * - * Implementation of the [grid slaves] subcommand. See the user + * Implementation of the [grid content] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: - * Places a list of slaves of the specified window in the interpreter's - * result field. + * Places a list of content windows of the specified window in the + * interpreter's result field. * *---------------------------------------------------------------------- */ static int -GridSlavesCommand( +GridContentCommand( Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window master; - Gridder *masterPtr; /* master grid record */ - Gridder *slavePtr; + Tk_Window container; + Gridder *containerPtr; /* container grid record */ + Gridder *contentPtr; int i, value, index; int row = -1, column = -1; static const char *const optionStrings[] = { "-column", "-row", NULL }; - enum options { SLAVES_COLUMN, SLAVES_ROW }; + enum options { CONTENT_COLUMN, CONTENT_ROW }; Tcl_Obj *res; if ((objc < 3) || ((objc % 2) == 0)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?"); return TCL_ERROR; @@ -1375,34 +1389,34 @@ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%d is an invalid value: should NOT be < 0", value)); Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL); return TCL_ERROR; } - if (index == SLAVES_COLUMN) { + if (index == CONTENT_COLUMN) { column = value; } else { row = value; } } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); + containerPtr = GetGrid(container); res = Tcl_NewListObj(0, NULL); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if ((column >= 0) && (slavePtr->column > column - || slavePtr->column+slavePtr->numCols-1 < column)) { + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if ((column >= 0) && (contentPtr->column > column + || contentPtr->column+contentPtr->numCols-1 < column)) { + continue; + } + if ((row >= 0) && (contentPtr->row > row || + contentPtr->row+contentPtr->numRows-1 < row)) { continue; } - if ((row >= 0) && (slavePtr->row > row || - slavePtr->row+slavePtr->numRows-1 < row)) { - continue; - } - Tcl_ListObjAppendElement(interp,res, TkNewWindowObj(slavePtr->tkwin)); + Tcl_ListObjAppendElement(interp,res, Tk_NewWindowObj(contentPtr->tkwin)); } Tcl_SetObjResult(interp, res); return TCL_OK; } @@ -1426,54 +1440,52 @@ static void GridReqProc( ClientData clientData, /* Grid's information about window that got * new preferred geometry. */ - Tk_Window tkwin) /* Other Tk-related information about the + TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { Gridder *gridPtr = (Gridder *)clientData; - (void)tkwin; - gridPtr = gridPtr->masterPtr; + gridPtr = gridPtr->containerPtr; if (gridPtr && !(gridPtr->flags & REQUESTED_RELAYOUT)) { gridPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, gridPtr); } } /* *---------------------------------------------------------------------- * - * GridLostSlaveProc -- + * GridLostContentProc -- * * This procedure is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all grid-related information about the slave. + * Forgets all grid-related information about the content. * *---------------------------------------------------------------------- */ static void -GridLostSlaveProc( - ClientData clientData, /* Grid structure for slave window that was +GridLostContentProc( + ClientData clientData, /* Grid structure for content window that was * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ -{ - Gridder *slavePtr = (Gridder *)clientData; - (void)tkwin; - - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */ +{ + Gridder *contentPtr = (Gridder *)clientData; + + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } /* *---------------------------------------------------------------------- * @@ -1643,48 +1655,48 @@ /* *---------------------------------------------------------------------- * * AdjustForSticky -- * - * This procedure adjusts the size of a slave in its cavity based on its + * This procedure adjusts the size of a content in its cavity based on its * "sticky" flags. * * Results: * The input x, y, width, and height are changed to represent the desired - * coordinates of the slave. + * coordinates of the content. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void AdjustForSticky( - Gridder *slavePtr, /* Slave window to arrange in its cavity. */ + Gridder *contentPtr, /* Content window to arrange in its cavity. */ int *xPtr, /* Pixel location of the left edge of the cavity. */ int *yPtr, /* Pixel location of the top edge of the cavity. */ int *widthPtr, /* Width of the cavity (in pixels). */ int *heightPtr) /* Height of the cavity (in pixels). */ { - int diffx = 0; /* Cavity width - slave width. */ - int diffy = 0; /* Cavity hight - slave height. */ - int sticky = slavePtr->sticky; - - *xPtr += slavePtr->padLeft; - *widthPtr -= slavePtr->padX; - *yPtr += slavePtr->padTop; - *heightPtr -= slavePtr->padY; - - if (*widthPtr > (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX)) { - diffx = *widthPtr - (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX); - *widthPtr = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX; - } - - if (*heightPtr > (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY)) { - diffy = *heightPtr - (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY); - *heightPtr = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY; + int diffx = 0; /* Cavity width - content width. */ + int diffy = 0; /* Cavity hight - content height. */ + int sticky = contentPtr->sticky; + + *xPtr += contentPtr->padLeft; + *widthPtr -= contentPtr->padX; + *yPtr += contentPtr->padTop; + *heightPtr -= contentPtr->padY; + + if (*widthPtr > (Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX)) { + diffx = *widthPtr - (Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX); + *widthPtr = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->iPadX; + } + + if (*heightPtr > (Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY)) { + diffy = *heightPtr - (Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY); + *heightPtr = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->iPadY; } if (sticky&STICK_EAST && sticky&STICK_WEST) { *widthPtr += diffx; } @@ -1711,172 +1723,171 @@ * * Results: * None. * * Side effects: - * The slaves of masterPtr may get resized or moved. + * The content of containerPtr may get resized or moved. * *---------------------------------------------------------------------- */ static void ArrangeGrid( - ClientData clientData) /* Structure describing master whose slaves + ClientData clientData) /* Structure describing container whose content * are to be re-layed out. */ { - Gridder *masterPtr = (Gridder *)clientData; - Gridder *slavePtr; - GridMaster *slotPtr = masterPtr->masterDataPtr; + Gridder *containerPtr = (Gridder *)clientData; + Gridder *contentPtr; + GridContainer *slotPtr = containerPtr->containerDataPtr; int abort; int width, height; /* Requested size of layout, in pixels. */ int realWidth, realHeight; /* Actual size layout should take-up. */ int usedX, usedY; - masterPtr->flags &= ~REQUESTED_RELAYOUT; + containerPtr->flags &= ~REQUESTED_RELAYOUT; /* - * If the master has no slaves anymore, then don't change the master size. - * Otherwise there is no way to "relinquish" control over the master + * If the container has no content anymore, then don't change the container size. + * Otherwise there is no way to "relinquish" control over the container * so another geometry manager can take over. */ - if (masterPtr->slavePtr == NULL) { + if (containerPtr->contentPtr == NULL) { return; } - if (masterPtr->masterDataPtr == NULL) { + if (containerPtr->containerDataPtr == NULL) { return; } /* * Abort any nested call to ArrangeGrid for this window, since we'll do * everything necessary here, and set up so this call can be aborted if * necessary. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - masterPtr->abortPtr = &abort; + containerPtr->abortPtr = &abort; abort = 0; - Tcl_Preserve(masterPtr); + Tcl_Preserve(containerPtr); /* * Call the constraint engine to fill in the row and column offsets. */ - SetGridSize(masterPtr); - width = ResolveConstraints(masterPtr, COLUMN, 0); - height = ResolveConstraints(masterPtr, ROW, 0); - width += Tk_InternalBorderLeft(masterPtr->tkwin) + - Tk_InternalBorderRight(masterPtr->tkwin); - height += Tk_InternalBorderTop(masterPtr->tkwin) + - Tk_InternalBorderBottom(masterPtr->tkwin); - - if (width < Tk_MinReqWidth(masterPtr->tkwin)) { - width = Tk_MinReqWidth(masterPtr->tkwin); - } - if (height < Tk_MinReqHeight(masterPtr->tkwin)) { - height = Tk_MinReqHeight(masterPtr->tkwin); - } - - if (((width != Tk_ReqWidth(masterPtr->tkwin)) - || (height != Tk_ReqHeight(masterPtr->tkwin))) - && !(masterPtr->flags & DONT_PROPAGATE)) { - Tk_GeometryRequest(masterPtr->tkwin, width, height); + SetGridSize(containerPtr); + width = ResolveConstraints(containerPtr, COLUMN, 0); + height = ResolveConstraints(containerPtr, ROW, 0); + width += Tk_InternalBorderLeft(containerPtr->tkwin) + + Tk_InternalBorderRight(containerPtr->tkwin); + height += Tk_InternalBorderTop(containerPtr->tkwin) + + Tk_InternalBorderBottom(containerPtr->tkwin); + + if (width < Tk_MinReqWidth(containerPtr->tkwin)) { + width = Tk_MinReqWidth(containerPtr->tkwin); + } + if (height < Tk_MinReqHeight(containerPtr->tkwin)) { + height = Tk_MinReqHeight(containerPtr->tkwin); + } + + if (((width != Tk_ReqWidth(containerPtr->tkwin)) + || (height != Tk_ReqHeight(containerPtr->tkwin))) + && !(containerPtr->flags & DONT_PROPAGATE)) { + Tk_GeometryRequest(containerPtr->tkwin, width, height); if (width>1 && height>1) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } - masterPtr->abortPtr = NULL; - Tcl_Release(masterPtr); + containerPtr->abortPtr = NULL; + Tcl_Release(containerPtr); return; } /* - * If the currently requested layout size doesn't match the master's + * If the currently requested layout size doesn't match the container's * window size, then adjust the slot offsets according to the weights. If * all of the weights are zero, place the layout according to the anchor * value. */ - realWidth = Tk_Width(masterPtr->tkwin) - - Tk_InternalBorderLeft(masterPtr->tkwin) - - Tk_InternalBorderRight(masterPtr->tkwin); - realHeight = Tk_Height(masterPtr->tkwin) - - Tk_InternalBorderTop(masterPtr->tkwin) - - Tk_InternalBorderBottom(masterPtr->tkwin); + realWidth = Tk_Width(containerPtr->tkwin) - + Tk_InternalBorderLeft(containerPtr->tkwin) - + Tk_InternalBorderRight(containerPtr->tkwin); + realHeight = Tk_Height(containerPtr->tkwin) - + Tk_InternalBorderTop(containerPtr->tkwin) - + Tk_InternalBorderBottom(containerPtr->tkwin); usedX = AdjustOffsets(realWidth, MAX(slotPtr->columnEnd, slotPtr->columnMax), slotPtr->columnPtr); usedY = AdjustOffsets(realHeight, MAX(slotPtr->rowEnd, slotPtr->rowMax), slotPtr->rowPtr); - TkComputeAnchor(masterPtr->masterDataPtr->anchor, masterPtr->tkwin, + TkComputeAnchor(containerPtr->containerDataPtr->anchor, containerPtr->tkwin, 0, 0, usedX, usedY, &slotPtr->startX, &slotPtr->startY); /* - * Now adjust the actual size of the slave to its cavity by computing the + * Now adjust the actual size of the content to its cavity by computing the * cavity size, and adjusting the widget according to its stickyness. */ - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL && !abort; - slavePtr = slavePtr->nextPtr) { + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL && !abort; + contentPtr = contentPtr->nextPtr) { int x, y; /* Top left coordinate */ - int width, height; /* Slot or slave size */ - int col = slavePtr->column; - int row = slavePtr->row; + int col = contentPtr->column; + int row = contentPtr->row; x = (col>0) ? slotPtr->columnPtr[col-1].offset : 0; y = (row>0) ? slotPtr->rowPtr[row-1].offset : 0; - width = slotPtr->columnPtr[slavePtr->numCols+col-1].offset - x; - height = slotPtr->rowPtr[slavePtr->numRows+row-1].offset - y; + width = slotPtr->columnPtr[contentPtr->numCols+col-1].offset - x; + height = slotPtr->rowPtr[contentPtr->numRows+row-1].offset - y; x += slotPtr->startX; y += slotPtr->startY; - AdjustForSticky(slavePtr, &x, &y, &width, &height); + AdjustForSticky(contentPtr, &x, &y, &width, &height); /* * Now put the window in the proper spot. (This was taken directly - * from tkPack.c.) If the slave is a child of the master, then do this + * from tkPack.c.) If the content is a child of the container, then do this * here. Otherwise let Tk_MaintainGeometry do the work. */ - if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) { + if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) { if ((width <= 0) || (height <= 0)) { - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - if ((x != Tk_X(slavePtr->tkwin)) - || (y != Tk_Y(slavePtr->tkwin)) - || (width != Tk_Width(slavePtr->tkwin)) - || (height != Tk_Height(slavePtr->tkwin))) { - Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height); + if ((x != Tk_X(contentPtr->tkwin)) + || (y != Tk_Y(contentPtr->tkwin)) + || (width != Tk_Width(contentPtr->tkwin)) + || (height != Tk_Height(contentPtr->tkwin))) { + Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height); } if (abort) { break; } /* - * Don't map the slave if the master isn't mapped: wait until - * the master gets mapped later. + * Don't map the content if the container isn't mapped: wait until + * the container gets mapped later. */ - if (Tk_IsMapped(masterPtr->tkwin)) { - Tk_MapWindow(slavePtr->tkwin); + if (Tk_IsMapped(containerPtr->tkwin)) { + Tk_MapWindow(contentPtr->tkwin); } } } else if ((width <= 0) || (height <= 0)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin, x, y, + Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin, x, y, width, height); } } - masterPtr->abortPtr = NULL; - Tcl_Release(masterPtr); + containerPtr->abortPtr = NULL; + Tcl_Release(containerPtr); } /* *---------------------------------------------------------------------- * @@ -1890,33 +1901,33 @@ * The offset (in pixels) from the left/top edge of this layout is * returned. * * Side effects: * The slot offsets are copied into the SlotInfo structure for the - * geometry master. + * geometry container. * *---------------------------------------------------------------------- */ static int ResolveConstraints( - Gridder *masterPtr, /* The geometry master for this grid. */ + Gridder *containerPtr, /* The geometry container for this grid. */ int slotType, /* Either ROW or COLUMN. */ int maxOffset) /* The actual maximum size of this layout in * pixels, or 0 (not currently used). */ { SlotInfo *slotPtr; /* Pointer to row/col constraints. */ - Gridder *slavePtr; /* List of slave windows in this grid. */ + Gridder *contentPtr; /* List of content windows in this grid. */ int constraintCount; /* Count of rows or columns that have * constraints. */ int slotCount; /* Last occupied row or column. */ int gridCount; /* The larger of slotCount and * constraintCount. */ GridLayout *layoutPtr; /* Temporary layout structure. */ int requiredSize; /* The natural size of the grid (pixels). * This is the minimum size needed to - * accommodate all of the slaves at their + * accommodate all of the content at their * requested sizes. */ int offset; /* The pixel offset of the right edge of the * current slot from the beginning of the * layout. */ int slot; /* The current slot. */ @@ -1929,11 +1940,11 @@ UniformGroup *uniformGroupPtr; /* Uniform groups data. */ int uniformGroups; /* Number of currently used uniform groups. */ int uniformGroupsAlloced; /* Size of allocated space for uniform * groups. */ - int weight, minSize; + int minSize; int prevGrow, accWeight, grow; /* * For typical sized tables, we'll use stack space for the layout data to * avoid the overhead of a malloc and free for every layout. @@ -1940,17 +1951,17 @@ */ GridLayout layoutData[TYPICAL_SIZE + 1]; if (slotType == COLUMN) { - constraintCount = masterPtr->masterDataPtr->columnMax; - slotCount = masterPtr->masterDataPtr->columnEnd; - slotPtr = masterPtr->masterDataPtr->columnPtr; + constraintCount = containerPtr->containerDataPtr->columnMax; + slotCount = containerPtr->containerDataPtr->columnEnd; + slotPtr = containerPtr->containerDataPtr->columnPtr; } else { - constraintCount = masterPtr->masterDataPtr->rowMax; - slotCount = masterPtr->masterDataPtr->rowEnd; - slotPtr = masterPtr->masterDataPtr->rowPtr; + constraintCount = containerPtr->containerDataPtr->rowMax; + slotCount = containerPtr->containerDataPtr->rowEnd; + slotPtr = containerPtr->containerDataPtr->rowPtr; } /* * Make sure there is enough memory for the layout. */ @@ -1996,52 +2007,52 @@ layoutPtr[slot].binNextPtr = NULL; } /* * Step 2. - * Slaves with a span of 1 are used to determine the minimum size of each - * slot. Slaves whose span is two or more slots don't contribute to the + * Content with a span of 1 are used to determine the minimum size of each + * slot. Content whose span is two or more slots don't contribute to the * minimum size of each slot directly, but can cause slots to grow if * their size exceeds the the sizes of the slots they span. * - * Bin all slaves whose spans are > 1 by their right edges. This allows + * Bin all content whose spans are > 1 by their right edges. This allows * the computation on minimum and maximum possible layout sizes at each - * slot boundary, without the need to re-sort the slaves. + * slot boundary, without the need to re-sort the content. */ switch (slotType) { case COLUMN: - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - int rightEdge = slavePtr->column + slavePtr->numCols - 1; - - slavePtr->size = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->padX - + slavePtr->iPadX + slavePtr->doubleBw; - if (slavePtr->numCols > 1) { - slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; - layoutPtr[rightEdge].binNextPtr = slavePtr; + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + int rightEdge = contentPtr->column + contentPtr->numCols - 1; + + contentPtr->size = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->padX + + contentPtr->iPadX + contentPtr->doubleBw; + if (contentPtr->numCols > 1) { + contentPtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; + layoutPtr[rightEdge].binNextPtr = contentPtr; } else if (rightEdge >= 0) { - int size = slavePtr->size + layoutPtr[rightEdge].pad; + int size = contentPtr->size + layoutPtr[rightEdge].pad; if (size > layoutPtr[rightEdge].minSize) { layoutPtr[rightEdge].minSize = size; } } } break; case ROW: - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - int rightEdge = slavePtr->row + slavePtr->numRows - 1; - - slavePtr->size = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->padY - + slavePtr->iPadY + slavePtr->doubleBw; - if (slavePtr->numRows > 1) { - slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; - layoutPtr[rightEdge].binNextPtr = slavePtr; + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + int rightEdge = contentPtr->row + contentPtr->numRows - 1; + + contentPtr->size = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->padY + + contentPtr->iPadY + contentPtr->doubleBw; + if (contentPtr->numRows > 1) { + contentPtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; + layoutPtr[rightEdge].binNextPtr = contentPtr; } else if (rightEdge >= 0) { - int size = slavePtr->size + layoutPtr[rightEdge].pad; + int size = contentPtr->size + layoutPtr[rightEdge].pad; if (size > layoutPtr[rightEdge].minSize) { layoutPtr[rightEdge].minSize = size; } } @@ -2058,10 +2069,11 @@ uniformGroupsAlloced = UNIFORM_PREALLOC; uniformGroups = 0; for (slot = 0; slot < gridCount; slot++) { if (layoutPtr[slot].uniform != NULL) { + int weight; for (start = 0; start < uniformGroups; start++) { if (uniformGroupPtr[start].group == layoutPtr[slot].uniform) { break; } } @@ -2110,11 +2122,11 @@ for (slot = 0; slot < gridCount; slot++) { if (layoutPtr[slot].uniform != NULL) { for (start = 0; start < uniformGroups; start++) { if (uniformGroupPtr[start].group == layoutPtr[slot].uniform) { - weight = layoutPtr[slot].weight; + int weight = layoutPtr[slot].weight; weight = weight > 0 ? weight : 1; layoutPtr[slot].minSize = uniformGroupPtr[start].minSize * weight; break; } @@ -2128,20 +2140,20 @@ } /* * Step 3. * Determine the minimum slot offsets going from left to right that would - * fit all of the slaves. This determines the minimum + * fit all of the content. This determines the minimum */ for (offset=0,slot=0; slot < gridCount; slot++) { layoutPtr[slot].minOffset = layoutPtr[slot].minSize + offset; - for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL; - slavePtr = slavePtr->binNextPtr) { + for (contentPtr = layoutPtr[slot].binNextPtr; contentPtr != NULL; + contentPtr = contentPtr->binNextPtr) { int span = (slotType == COLUMN) ? - slavePtr->numCols : slavePtr->numRows; - int required = slavePtr->size + layoutPtr[slot - span].minOffset; + contentPtr->numCols : contentPtr->numRows; + int required = contentPtr->size + layoutPtr[slot - span].minOffset; if (required > layoutPtr[slot].minOffset) { layoutPtr[slot].minOffset = required; } } @@ -2148,11 +2160,11 @@ offset = layoutPtr[slot].minOffset; } /* * At this point, we know the minimum required size of the entire layout. - * It might be prudent to stop here if our "master" will resize itself to + * It might be prudent to stop here if our "container" will resize itself to * this size. */ requiredSize = offset; if (maxOffset > offset) { @@ -2169,15 +2181,15 @@ for (slot=0; slot < gridCount; slot++) { layoutPtr[slot].maxOffset = offset; } for (slot=gridCount-1; slot > 0;) { - for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL; - slavePtr = slavePtr->binNextPtr) { + for (contentPtr = layoutPtr[slot].binNextPtr; contentPtr != NULL; + contentPtr = contentPtr->binNextPtr) { int span = (slotType == COLUMN) ? - slavePtr->numCols : slavePtr->numRows; - int require = offset - slavePtr->size; + contentPtr->numCols : contentPtr->numRows; + int require = offset - contentPtr->size; int startSlot = slot - span; if (startSlot >=0 && require < layoutPtr[startSlot].maxOffset) { layoutPtr[startSlot].maxOffset = require; } @@ -2383,11 +2395,11 @@ } /* * Step 6. * All of the space has been apportioned; copy the layout information back - * into the master. + * into the container. */ for (slot=0; slot < gridCount; slot++) { slotPtr[slot].offset = layoutPtr[slot].minOffset; } @@ -2442,14 +2454,14 @@ if (!isNew) { return (Gridder *)Tcl_GetHashValue(hPtr); } gridPtr = (Gridder *)ckalloc(sizeof(Gridder)); gridPtr->tkwin = tkwin; - gridPtr->masterPtr = NULL; - gridPtr->masterDataPtr = NULL; + gridPtr->containerPtr = NULL; + gridPtr->containerDataPtr = NULL; gridPtr->nextPtr = NULL; - gridPtr->slavePtr = NULL; + gridPtr->contentPtr = NULL; gridPtr->binNextPtr = NULL; gridPtr->column = -1; gridPtr->row = -1; gridPtr->numCols = 1; @@ -2465,11 +2477,11 @@ gridPtr->abortPtr = NULL; gridPtr->flags = 0; gridPtr->sticky = 0; gridPtr->size = 0; gridPtr->in = NULL; - gridPtr->masterDataPtr = NULL; + gridPtr->containerDataPtr = NULL; Tcl_SetHashValue(hPtr, gridPtr); Tk_CreateEventHandler(tkwin, StructureNotifyMask, GridStructureProc, gridPtr); return gridPtr; } @@ -2477,120 +2489,120 @@ /* *---------------------------------------------------------------------- * * SetGridSize -- * - * This internal procedure sets the size of the grid occupied by slaves. + * This internal procedure sets the size of the grid occupied by content. * * Results: * None * * Side effects: - * The width and height arguments are filled in the master data + * The width and height arguments are filled in the container data * structure. Additional space is allocated for the constraints to * accommodate the offsets. * *---------------------------------------------------------------------- */ static void SetGridSize( - Gridder *masterPtr) /* The geometry master for this grid. */ + Gridder *containerPtr) /* The geometry container for this grid. */ { - Gridder *slavePtr; /* Current slave window. */ + Gridder *contentPtr; /* Current content window. */ int maxX = 0, maxY = 0; - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - maxX = MAX(maxX, slavePtr->numCols + slavePtr->column); - maxY = MAX(maxY, slavePtr->numRows + slavePtr->row); - } - masterPtr->masterDataPtr->columnEnd = maxX; - masterPtr->masterDataPtr->rowEnd = maxY; - CheckSlotData(masterPtr, maxX, COLUMN, CHECK_SPACE); - CheckSlotData(masterPtr, maxY, ROW, CHECK_SPACE); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + maxX = MAX(maxX, contentPtr->numCols + contentPtr->column); + maxY = MAX(maxY, contentPtr->numRows + contentPtr->row); + } + containerPtr->containerDataPtr->columnEnd = maxX; + containerPtr->containerDataPtr->rowEnd = maxY; + CheckSlotData(containerPtr, maxX, COLUMN, CHECK_SPACE); + CheckSlotData(containerPtr, maxY, ROW, CHECK_SPACE); } /* *---------------------------------------------------------------------- * - * SetSlaveColumn -- + * SetContentColumn -- * - * Update column data for a slave, checking that MAX_ELEMENT bound + * Update column data for a content, checking that MAX_ELEMENT bound * is not passed. * * Results: * TCL_ERROR if out of bounds, TCL_OK otherwise * * Side effects: - * Slave fields are updated. + * Content fields are updated. * *---------------------------------------------------------------------- */ static int -SetSlaveColumn( +SetContentColumn( Tcl_Interp *interp, /* Interp for error message. */ - Gridder *slavePtr, /* Slave to be updated. */ + Gridder *contentPtr, /* Content to be updated. */ int column, /* New column or -1 to be unchanged. */ int numCols) /* New columnspan or -1 to be unchanged. */ { int newColumn, newNumCols, lastCol; - newColumn = (column >= 0) ? column : slavePtr->column; - newNumCols = (numCols >= 1) ? numCols : slavePtr->numCols; + newColumn = (column >= 0) ? column : contentPtr->column; + newNumCols = (numCols >= 1) ? numCols : contentPtr->numCols; lastCol = ((newColumn >= 0) ? newColumn : 0) + newNumCols; if (lastCol >= MAX_ELEMENT) { Tcl_SetObjResult(interp, Tcl_NewStringObj("column out of bounds",-1)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_COLUMN", NULL); return TCL_ERROR; } - slavePtr->column = newColumn; - slavePtr->numCols = newNumCols; + contentPtr->column = newColumn; + contentPtr->numCols = newNumCols; return TCL_OK; } /* *---------------------------------------------------------------------- * - * SetSlaveRow -- + * SetContentRow -- * - * Update row data for a slave, checking that MAX_ELEMENT bound + * Update row data for a content, checking that MAX_ELEMENT bound * is not passed. * * Results: * TCL_ERROR if out of bounds, TCL_OK otherwise * * Side effects: - * Slave fields are updated. + * Content fields are updated. * *---------------------------------------------------------------------- */ static int -SetSlaveRow( +SetContentRow( Tcl_Interp *interp, /* Interp for error message. */ - Gridder *slavePtr, /* Slave to be updated. */ + Gridder *contentPtr, /* Content to be updated. */ int row, /* New row or -1 to be unchanged. */ int numRows) /* New rowspan or -1 to be unchanged. */ { int newRow, newNumRows, lastRow; - newRow = (row >= 0) ? row : slavePtr->row; - newNumRows = (numRows >= 1) ? numRows : slavePtr->numRows; + newRow = (row >= 0) ? row : contentPtr->row; + newNumRows = (numRows >= 1) ? numRows : contentPtr->numRows; lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows; if (lastRow >= MAX_ELEMENT) { Tcl_SetObjResult(interp, Tcl_NewStringObj("row out of bounds", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_ROW", NULL); return TCL_ERROR; } - slavePtr->row = newRow; - slavePtr->numRows = newNumRows; + contentPtr->row = newRow; + contentPtr->numRows = newNumRows; return TCL_OK; } /* *---------------------------------------------------------------------- @@ -2602,21 +2614,21 @@ * * Results: * TRUE if the index is OK, False otherwise. * * Side effects: - * A new master grid structure may be created. If so, then it is + * A new container grid structure may be created. If so, then it is * initialized. In addition, additional storage for a row or column * constraints may be allocated, and the constraint maximums are * adjusted. * *---------------------------------------------------------------------- */ static int CheckSlotData( - Gridder *masterPtr, /* The geometry master for this grid. */ + Gridder *containerPtr, /* The geometry container for this grid. */ int slot, /* Which slot to look at. */ int slotType, /* ROW or COLUMN. */ int checkOnly) /* Don't allocate new space if true. */ { int numSlot; /* Number of slots already allocated (Space) */ @@ -2628,84 +2640,84 @@ if (slot < 0 || slot >= MAX_ELEMENT) { return TCL_ERROR; } - if ((checkOnly == CHECK_ONLY) && (masterPtr->masterDataPtr == NULL)) { + if ((checkOnly == CHECK_ONLY) && (containerPtr->containerDataPtr == NULL)) { return TCL_ERROR; } /* * If we need to allocate more space, allocate a little extra to avoid * repeated re-alloc's for large tables. We need enough space to hold all * of the offsets as well. */ - InitMasterData(masterPtr); - end = (slotType == ROW) ? masterPtr->masterDataPtr->rowMax : - masterPtr->masterDataPtr->columnMax; + InitContainerData(containerPtr); + end = (slotType == ROW) ? containerPtr->containerDataPtr->rowMax : + containerPtr->containerDataPtr->columnMax; if (checkOnly == CHECK_ONLY) { return ((end < slot) ? TCL_ERROR : TCL_OK); } else { - numSlot = (slotType == ROW) ? masterPtr->masterDataPtr->rowSpace - : masterPtr->masterDataPtr->columnSpace; + numSlot = (slotType == ROW) ? containerPtr->containerDataPtr->rowSpace + : containerPtr->containerDataPtr->columnSpace; if (slot >= numSlot) { int newNumSlot = slot + PREALLOC; size_t oldSize = numSlot * sizeof(SlotInfo); size_t newSize = newNumSlot * sizeof(SlotInfo); SlotInfo *newSI = (SlotInfo *)ckalloc(newSize); SlotInfo *oldSI = (slotType == ROW) - ? masterPtr->masterDataPtr->rowPtr - : masterPtr->masterDataPtr->columnPtr; + ? containerPtr->containerDataPtr->rowPtr + : containerPtr->containerDataPtr->columnPtr; memcpy(newSI, oldSI, oldSize); memset(newSI+numSlot, 0, newSize - oldSize); ckfree(oldSI); if (slotType == ROW) { - masterPtr->masterDataPtr->rowPtr = newSI; - masterPtr->masterDataPtr->rowSpace = newNumSlot; + containerPtr->containerDataPtr->rowPtr = newSI; + containerPtr->containerDataPtr->rowSpace = newNumSlot; } else { - masterPtr->masterDataPtr->columnPtr = newSI; - masterPtr->masterDataPtr->columnSpace = newNumSlot; + containerPtr->containerDataPtr->columnPtr = newSI; + containerPtr->containerDataPtr->columnSpace = newNumSlot; } } if (slot >= end && checkOnly != CHECK_SPACE) { if (slotType == ROW) { - masterPtr->masterDataPtr->rowMax = slot+1; + containerPtr->containerDataPtr->rowMax = slot+1; } else { - masterPtr->masterDataPtr->columnMax = slot+1; + containerPtr->containerDataPtr->columnMax = slot+1; } } return TCL_OK; } } /* *---------------------------------------------------------------------- * - * InitMasterData -- + * InitContainerData -- * * This internal procedure is used to allocate and initialize the data - * for a geometry master, if the data doesn't exist already. + * for a geometry container, if the data doesn't exist already. * * Results: * none * * Side effects: - * A new master grid structure may be created. If so, then it is + * A new container grid structure may be created. If so, then it is * initialized. * *---------------------------------------------------------------------- */ static void -InitMasterData( - Gridder *masterPtr) +InitContainerData( + Gridder *containerPtr) { - if (masterPtr->masterDataPtr == NULL) { - GridMaster *gridPtr = masterPtr->masterDataPtr = (GridMaster *) - ckalloc(sizeof(GridMaster)); + if (containerPtr->containerDataPtr == NULL) { + GridContainer *gridPtr = containerPtr->containerDataPtr = (GridContainer *) + ckalloc(sizeof(GridContainer)); size_t size = sizeof(SlotInfo) * TYPICAL_SIZE; gridPtr->columnEnd = 0; gridPtr->columnMax = 0; gridPtr->columnPtr = (SlotInfo *)ckalloc(size); @@ -2726,69 +2738,69 @@ /* *---------------------------------------------------------------------- * * Unlink -- * - * Remove a grid from its master's list of slaves. + * Remove a grid from its container's list of content. * * Results: * None. * * Side effects: - * The master will be scheduled for re-arranging, and the size of the + * The container will be scheduled for re-arranging, and the size of the * grid will be adjusted accordingly * *---------------------------------------------------------------------- */ static void Unlink( - Gridder *slavePtr) /* Window to unlink. */ + Gridder *contentPtr) /* Window to unlink. */ { - Gridder *masterPtr, *slavePtr2; + Gridder *containerPtr, *contentPtr2; - masterPtr = slavePtr->masterPtr; - if (masterPtr == NULL) { + containerPtr = contentPtr->containerPtr; + if (containerPtr == NULL) { return; } - if (masterPtr->slavePtr == slavePtr) { - masterPtr->slavePtr = slavePtr->nextPtr; + if (containerPtr->contentPtr == contentPtr) { + containerPtr->contentPtr = contentPtr->nextPtr; } else { - for (slavePtr2=masterPtr->slavePtr ; ; slavePtr2=slavePtr2->nextPtr) { - if (slavePtr2 == NULL) { + for (contentPtr2=containerPtr->contentPtr ; ; contentPtr2=contentPtr2->nextPtr) { + if (contentPtr2 == NULL) { Tcl_Panic("Unlink couldn't find previous window"); } - if (slavePtr2->nextPtr == slavePtr) { - slavePtr2->nextPtr = slavePtr->nextPtr; + if (contentPtr2->nextPtr == contentPtr) { + contentPtr2->nextPtr = contentPtr->nextPtr; break; } } } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + if (!(containerPtr->flags & REQUESTED_RELAYOUT)) { + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - SetGridSize(slavePtr->masterPtr); - slavePtr->masterPtr = NULL; + SetGridSize(contentPtr->containerPtr); + contentPtr->containerPtr = NULL; /* - * If we have emptied this master from slaves it means we are no longer + * If we have emptied this container from content it means we are no longer * handling it and should mark it as free. * - * Send the event "NoManagedChild" to the master to inform it about there + * Send the event "NoManagedChild" to the container to inform it about there * being no managed children inside it. */ - if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) { - TkFreeGeometryMaster(masterPtr->tkwin, "grid"); - masterPtr->flags &= ~ALLOCED_MASTER; - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) { + TkFreeGeometryContainer(containerPtr->tkwin, "grid"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL); } } /* *---------------------------------------------------------------------- @@ -2796,11 +2808,11 @@ * DestroyGrid -- * * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release to * clean up the internal structure of a grid at a safe time (when no-one * is using it anymore). Cleaning up the grid involves freeing the main - * structure for all windows and the master structure for geometry + * structure for all windows and the container structure for geometry * managers. * * Results: * None. * @@ -2814,18 +2826,18 @@ DestroyGrid( void *memPtr) /* Info about window that is now dead. */ { Gridder *gridPtr = (Gridder *)memPtr; - if (gridPtr->masterDataPtr != NULL) { - if (gridPtr->masterDataPtr->rowPtr != NULL) { - ckfree(gridPtr->masterDataPtr -> rowPtr); - } - if (gridPtr->masterDataPtr->columnPtr != NULL) { - ckfree(gridPtr->masterDataPtr -> columnPtr); - } - ckfree(gridPtr->masterDataPtr); + if (gridPtr->containerDataPtr != NULL) { + if (gridPtr->containerDataPtr->rowPtr != NULL) { + ckfree(gridPtr->containerDataPtr -> rowPtr); + } + if (gridPtr->containerDataPtr->columnPtr != NULL) { + ckfree(gridPtr->containerDataPtr -> columnPtr); + } + ckfree(gridPtr->containerDataPtr); } if (gridPtr->in != NULL) { Tcl_DecrRefCount(gridPtr->in); } ckfree(gridPtr); @@ -2842,11 +2854,11 @@ * Results: * None. * * Side effects: * If a window was just deleted, clean up all its grid-related - * information. If it was just resized, re-configure its slaves, if any. + * information. If it was just resized, re-configure its content, if any. * *---------------------------------------------------------------------- */ static void @@ -2857,95 +2869,95 @@ { Gridder *gridPtr = (Gridder *)clientData; TkDisplay *dispPtr = ((TkWindow *) gridPtr->tkwin)->dispPtr; if (eventPtr->type == ConfigureNotify) { - if ((gridPtr->slavePtr != NULL) + if ((gridPtr->contentPtr != NULL) && !(gridPtr->flags & REQUESTED_RELAYOUT)) { gridPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, gridPtr); } - if ((gridPtr->masterPtr != NULL) && + if ((gridPtr->containerPtr != NULL) && (gridPtr->doubleBw != 2*Tk_Changes(gridPtr->tkwin)->border_width)) { - if (!(gridPtr->masterPtr->flags & REQUESTED_RELAYOUT)) { + if (!(gridPtr->containerPtr->flags & REQUESTED_RELAYOUT)) { gridPtr->doubleBw = 2*Tk_Changes(gridPtr->tkwin)->border_width; - gridPtr->masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, gridPtr->masterPtr); + gridPtr->containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, gridPtr->containerPtr); } } } else if (eventPtr->type == DestroyNotify) { - Gridder *slavePtr, *nextPtr; + Gridder *contentPtr, *nextPtr; - if (gridPtr->masterPtr != NULL) { + if (gridPtr->containerPtr != NULL) { Unlink(gridPtr); } - for (slavePtr = gridPtr->slavePtr; slavePtr != NULL; - slavePtr = nextPtr) { - Tk_ManageGeometry(slavePtr->tkwin, NULL, NULL); - Tk_UnmapWindow(slavePtr->tkwin); - slavePtr->masterPtr = NULL; - nextPtr = slavePtr->nextPtr; - slavePtr->nextPtr = NULL; + for (contentPtr = gridPtr->contentPtr; contentPtr != NULL; + contentPtr = nextPtr) { + Tk_ManageGeometry(contentPtr->tkwin, NULL, NULL); + Tk_UnmapWindow(contentPtr->tkwin); + contentPtr->containerPtr = NULL; + nextPtr = contentPtr->nextPtr; + contentPtr->nextPtr = NULL; } Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->gridHashTable, gridPtr->tkwin)); if (gridPtr->flags & REQUESTED_RELAYOUT) { Tcl_CancelIdleCall(ArrangeGrid, gridPtr); } gridPtr->tkwin = NULL; Tcl_EventuallyFree(gridPtr, (Tcl_FreeProc *)DestroyGrid); } else if (eventPtr->type == MapNotify) { - if ((gridPtr->slavePtr != NULL) + if ((gridPtr->contentPtr != NULL) && !(gridPtr->flags & REQUESTED_RELAYOUT)) { gridPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, gridPtr); } } else if (eventPtr->type == UnmapNotify) { - Gridder *slavePtr; + Gridder *contentPtr; - for (slavePtr = gridPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - Tk_UnmapWindow(slavePtr->tkwin); + for (contentPtr = gridPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + Tk_UnmapWindow(contentPtr->tkwin); } } } /* *---------------------------------------------------------------------- * - * ConfigureSlaves -- + * ConfigureContent -- * * This implements the guts of the "grid configure" command. Given a list - * of slaves and configuration options, it arranges for the grid to - * manage the slaves and sets the specified options. Arguments consist + * of content and configuration options, it arranges for the grid to + * manage the content and sets the specified options. Arguments consist * of windows or window shortcuts followed by "-option value" pairs. * * Results: * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is returned * and the interp's result is set to contain an error message. * * Side effects: - * Slave windows get taken over by the grid. + * Content windows get taken over by the grid. * *---------------------------------------------------------------------- */ static int -ConfigureSlaves( +ConfigureContent( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Window tkwin, /* Any window in application containing - * slaves. Used to look up slave names. */ + * content. Used to look up content names. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[]) /* Argument objects: contains one or more * window names followed by any number of * "option value" pairs. Caller must make sure * that there is at least one window name. */ { - Gridder *masterPtr = NULL; - Gridder *slavePtr; - Tk_Window other, slave, parent, ancestor; - TkWindow *master; + Gridder *containerPtr = NULL; + Gridder *contentPtr; + Tk_Window other, content, parent, ancestor; + TkWindow *container; int i, j, tmp; int numWindows; int width; int defaultRow = -1; int defaultColumn = 0; /* Default column number */ @@ -2972,43 +2984,43 @@ firstChar = 0; for (numWindows=0, i=0; i < objc; i++) { TkSizeT length; char prevChar = firstChar; - string = TkGetStringFromObj(objv[i], &length); + string = Tcl_GetStringFromObj(objv[i], &length); firstChar = string[0]; if (firstChar == '.') { /* - * Check that windows are valid, and locate the first slave's - * parent window (default for -in). - */ - - if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { - return TCL_ERROR; - } - if (masterPtr == NULL) { - /* - * Is there any saved -in from a removed slave? - * If there is, it becomes default for -in. - * If the stored master does not exist, just ignore it. - */ - - struct Gridder *slavePtr = GetGrid(slave); - if (slavePtr->in != NULL) { - if (TkGetWindowFromObj(interp, slave, slavePtr->in, &parent) - == TCL_OK) { - masterPtr = GetGrid(parent); - InitMasterData(masterPtr); - } - } - } - if (masterPtr == NULL) { - parent = Tk_Parent(slave); - if (parent != NULL) { - masterPtr = GetGrid(parent); - InitMasterData(masterPtr); + * Check that windows are valid, and locate the first content's + * parent window (default for -in). + */ + + if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) { + return TCL_ERROR; + } + if (containerPtr == NULL) { + /* + * Is there any saved -in from a removed content? + * If there is, it becomes default for -in. + * If the stored container does not exist, just ignore it. + */ + + contentPtr = GetGrid(content); + if (contentPtr->in != NULL) { + if (TkGetWindowFromObj(interp, content, contentPtr->in, &parent) + == TCL_OK) { + containerPtr = GetGrid(parent); + InitContainerData(containerPtr); + } + } + } + if (containerPtr == NULL) { + parent = Tk_Parent(content); + if (parent != NULL) { + containerPtr = GetGrid(parent); + InitContainerData(containerPtr); } } numWindows++; continue; } @@ -3072,12 +3084,12 @@ if (index == CONF_IN) { if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(other); - InitMasterData(masterPtr); + containerPtr = GetGrid(other); + InitContainerData(containerPtr); } else if (index == CONF_ROW) { if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || tmp < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad row value \"%s\": must be a non-negative integer", @@ -3089,27 +3101,27 @@ } } /* * If no -row is given, use the next row after the highest occupied row - * of the master. + * of the container. */ if (defaultRow < 0) { - if (masterPtr != NULL && masterPtr->masterDataPtr != NULL) { - SetGridSize(masterPtr); - defaultRow = masterPtr->masterDataPtr->rowEnd; + if (containerPtr != NULL && containerPtr->containerDataPtr != NULL) { + SetGridSize(containerPtr); + defaultRow = containerPtr->containerDataPtr->rowEnd; } else { defaultRow = 0; } } /* - * Iterate over all of the slave windows and short-cuts, parsing options - * for each slave. It's a bit wasteful to re-parse the options for each - * slave, but things get too messy if we try to parse the arguments just - * once at the beginning. For example, if a slave already is managed we + * Iterate over all of the content windows and short-cuts, parsing options + * for each content. It's a bit wasteful to re-parse the options for each + * content, but things get too messy if we try to parse the arguments just + * once at the beginning. For example, if a content already is managed we * want to just change a few existing values without resetting everything. * If there are multiple windows, the -in option only gets processed for * the first window. */ @@ -3118,11 +3130,11 @@ string = Tcl_GetString(objv[j]); firstChar = string[0]; /* * '^' and 'x' cause us to skip a column. '-' is processed as part of - * its preceeding slave. + * its preceeding content. */ if ((firstChar == REL_VERT) || (firstChar == REL_SKIP)) { defaultColumn++; continue; @@ -3131,38 +3143,38 @@ continue; } for (defaultColumnSpan = 1; j + defaultColumnSpan < numWindows; defaultColumnSpan++) { - const char *string = Tcl_GetString(objv[j + defaultColumnSpan]); + string = Tcl_GetString(objv[j + defaultColumnSpan]); if (*string != REL_HORIZ) { break; } } - if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &content) != TCL_OK) { return TCL_ERROR; } - if (Tk_TopWinHierarchy(slave)) { + if (Tk_TopWinHierarchy(content)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't manage \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } - slavePtr = GetGrid(slave); + contentPtr = GetGrid(content); /* * The following statement is taken from tkPack.c: * - * "If the slave isn't currently managed, reset all of its + * "If the content isn't currently managed, reset all of its * configuration information to default values (there could be old * values left from a previous packer)." * - * I [D.S.] disagree with this statement. If a slave is disabled + * I [D.S.] disagree with this statement. If a content is disabled * (using "forget") and then re-enabled, I submit that 90% of the time * the programmer will want it to retain its old configuration * information. If the programmer doesn't want this behavior, then the * defaults can be reestablished by hand, without having to worry * about keeping track of the old state. @@ -3179,11 +3191,11 @@ "bad column value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); return TCL_ERROR; } - if (SetSlaveColumn(interp, slavePtr, tmp, -1) != TCL_OK) { + if (SetContentColumn(interp, contentPtr, tmp, -1) != TCL_OK) { return TCL_ERROR; } break; case CONF_COLUMNSPAN: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK @@ -3192,28 +3204,28 @@ "bad columnspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); return TCL_ERROR; } - if (SetSlaveColumn(interp, slavePtr, -1, tmp) != TCL_OK) { + if (SetContentColumn(interp, contentPtr, -1, tmp) != TCL_OK) { return TCL_ERROR; } break; case CONF_IN: if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } - if (other == slave) { + if (other == content) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "window can't be managed in itself", -1)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } positionGiven = 1; - masterPtr = GetGrid(other); - InitMasterData(masterPtr); + containerPtr = GetGrid(other); + InitContainerData(containerPtr); break; case CONF_STICKY: { int sticky = StringToSticky(Tcl_GetString(objv[i+1])); if (sticky == -1) { @@ -3222,44 +3234,44 @@ " a string containing n, e, s, and/or w", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); return TCL_ERROR; } - slavePtr->sticky = sticky; + contentPtr->sticky = sticky; break; } case CONF_IPADX: - if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1], + if ((Tk_GetPixelsFromObj(NULL, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadX = tmp * 2; + contentPtr->iPadX = tmp * 2; break; case CONF_IPADY: - if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1], + if ((Tk_GetPixelsFromObj(NULL, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadY = tmp * 2; + contentPtr->iPadY = tmp * 2; break; case CONF_PADX: if (TkParsePadAmount(interp, tkwin, objv[i+1], - &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { + &contentPtr->padLeft, &contentPtr->padX) != TCL_OK) { return TCL_ERROR; } break; case CONF_PADY: if (TkParsePadAmount(interp, tkwin, objv[i+1], - &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { + &contentPtr->padTop, &contentPtr->padY) != TCL_OK) { return TCL_ERROR; } break; case CONF_ROW: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK @@ -3268,11 +3280,11 @@ "bad row value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); return TCL_ERROR; } - if (SetSlaveRow(interp, slavePtr, tmp, -1) != TCL_OK) { + if (SetContentRow(interp, contentPtr, tmp, -1) != TCL_OK) { return TCL_ERROR; } break; case CONF_ROWSPAN: if ((Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK) @@ -3281,147 +3293,147 @@ "bad rowspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); return TCL_ERROR; } - if (SetSlaveRow(interp, slavePtr, -1, tmp) != TCL_OK) { + if (SetContentRow(interp, contentPtr, -1, tmp) != TCL_OK) { return TCL_ERROR; } break; } } /* - * If no position was specified via -in and the slave is already + * If no position was specified via -in and the content is already * packed, then leave it in its current location. */ - if (!positionGiven && (slavePtr->masterPtr != NULL)) { - masterPtr = slavePtr->masterPtr; + if (!positionGiven && (contentPtr->containerPtr != NULL)) { + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } /* * If the same -in window is passed in again, then just leave it in * its current location. */ - if (positionGiven && (masterPtr == slavePtr->masterPtr)) { + if (positionGiven && (containerPtr == contentPtr->containerPtr)) { goto scheduleLayout; } /* - * Make sure we have a geometry master. We look at: - * 1) the -in flag - * 2) the parent of the first slave. - */ - - parent = Tk_Parent(slave); - if (masterPtr == NULL) { - masterPtr = GetGrid(parent); - InitMasterData(masterPtr); - } - - if (slavePtr->masterPtr != NULL && slavePtr->masterPtr != masterPtr) { - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - slavePtr->masterPtr = NULL; - } - - if (slavePtr->masterPtr == NULL) { - Gridder *tempPtr = masterPtr->slavePtr; - - slavePtr->masterPtr = masterPtr; - masterPtr->slavePtr = slavePtr; - slavePtr->nextPtr = tempPtr; + * Make sure we have a geometry container. We look at: + * 1) the -in flag + * 2) the parent of the first content. + */ + + parent = Tk_Parent(content); + if (containerPtr == NULL) { + containerPtr = GetGrid(parent); + InitContainerData(containerPtr); + } + + if (contentPtr->containerPtr != NULL && contentPtr->containerPtr != containerPtr) { + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + contentPtr->containerPtr = NULL; + } + + if (contentPtr->containerPtr == NULL) { + Gridder *tempPtr = containerPtr->contentPtr; + + contentPtr->containerPtr = containerPtr; + containerPtr->contentPtr = contentPtr; + contentPtr->nextPtr = tempPtr; } /* - * Make sure that the slave's parent is either the master or an - * ancestor of the master, and that the master and slave aren't the + * Make sure that the content's parent is either the container or an + * ancestor of the container, and that the container and content aren't the * same. */ - for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { + for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put %s inside %s", Tcl_GetString(objv[j]), - Tk_PathName(masterPtr->tkwin))); + "can't put \"%s\" inside \"%s\"", Tcl_GetString(objv[j]), + Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); - Unlink(slavePtr); + Unlink(contentPtr); return TCL_ERROR; } } /* * Check for management loops. */ - for (master = (TkWindow *)masterPtr->tkwin; master != NULL; - master = (TkWindow *)TkGetGeomMaster(master)) { - if (master == (TkWindow *)slave) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put %s inside %s, would cause management loop", - Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); - Unlink(slavePtr); - return TCL_ERROR; - } - } - if (masterPtr->tkwin != Tk_Parent(slave)) { - ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin; - } - - Tk_ManageGeometry(slave, &gridMgrType, slavePtr); - - if (!(masterPtr->flags & DONT_PROPAGATE)) { - if (TkSetGeometryMaster(interp, masterPtr->tkwin, "grid") - != TCL_OK) { - Tk_ManageGeometry(slave, NULL, NULL); - Unlink(slavePtr); - return TCL_ERROR; - } - masterPtr->flags |= ALLOCED_MASTER; + for (container = (TkWindow *)containerPtr->tkwin; container != NULL; + container = (TkWindow *)TkGetContainer(container)) { + if (container == (TkWindow *)content) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "can't put \"%s\" inside \"%s\": would cause management loop", + Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); + Unlink(contentPtr); + return TCL_ERROR; + } + } + if (containerPtr->tkwin != Tk_Parent(content)) { + ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin; + } + + Tk_ManageGeometry(content, &gridMgrType, contentPtr); + + if (!(containerPtr->flags & DONT_PROPAGATE)) { + if (TkSetGeometryContainer(interp, containerPtr->tkwin, "grid") + != TCL_OK) { + Tk_ManageGeometry(content, NULL, NULL); + Unlink(contentPtr); + return TCL_ERROR; + } + containerPtr->flags |= ALLOCED_CONTAINER; } /* * Assign default position information. */ - if (slavePtr->column == -1) { - if (SetSlaveColumn(interp, slavePtr, defaultColumn,-1) != TCL_OK){ - return TCL_ERROR; - } - } - if (SetSlaveColumn(interp, slavePtr, -1, - slavePtr->numCols + defaultColumnSpan - 1) != TCL_OK) { - return TCL_ERROR; - } - if (slavePtr->row == -1) { - if (SetSlaveRow(interp, slavePtr, defaultRow, -1) != TCL_OK) { - return TCL_ERROR; - } - } - defaultColumn += slavePtr->numCols; - defaultColumnSpan = 1; - - /* - * Arrange for the master to be re-arranged at the first idle moment. - */ - - scheduleLayout: - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, masterPtr); + if (contentPtr->column == -1) { + if (SetContentColumn(interp, contentPtr, defaultColumn,-1) != TCL_OK){ + return TCL_ERROR; + } + } + if (SetContentColumn(interp, contentPtr, -1, + contentPtr->numCols + defaultColumnSpan - 1) != TCL_OK) { + return TCL_ERROR; + } + if (contentPtr->row == -1) { + if (SetContentRow(interp, contentPtr, defaultRow, -1) != TCL_OK) { + return TCL_ERROR; + } + } + defaultColumn += contentPtr->numCols; + defaultColumnSpan = 1; + + /* + * Arrange for the container to be re-arranged at the first idle moment. + */ + + scheduleLayout: + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + if (!(containerPtr->flags & REQUESTED_RELAYOUT)) { + containerPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, containerPtr); } } /* * Now look for all the "^"'s. @@ -3433,13 +3445,13 @@ struct Gridder *otherPtr; int match; /* Found a match for the ^ */ int lastRow, lastColumn; /* Implied end of table. */ string = Tcl_GetString(objv[j]); - firstChar = string[0]; + firstChar = string[0]; - if (firstChar == '.') { + if (firstChar == '.') { lastWindow = string; numSkip = 0; } if (firstChar == REL_SKIP) { numSkip++; @@ -3446,23 +3458,23 @@ } if (firstChar != REL_VERT) { continue; } - if (masterPtr == NULL) { + if (containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "can't use '^', cant find master", -1)); + "can't use '^', can't find container window", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } /* * Count the number of consecutive ^'s starting from this position. */ for (width = 1; width + j < numWindows; width++) { - const char *string = Tcl_GetString(objv[j+width]); + string = Tcl_GetString(objv[j+width]); if (*string != REL_VERT) { break; } } @@ -3482,56 +3494,56 @@ } lastColumn += numSkip; match = 0; - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - - if (slavePtr->column == lastColumn - && slavePtr->row + slavePtr->numRows - 1 == lastRow) { - if (slavePtr->numCols <= width) { - if (SetSlaveRow(interp, slavePtr, -1, - slavePtr->numRows + 1) != TCL_OK) { + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + + if (contentPtr->column == lastColumn + && contentPtr->row + contentPtr->numRows - 1 == lastRow) { + if (contentPtr->numCols <= width) { + if (SetContentRow(interp, contentPtr, -1, + contentPtr->numRows + 1) != TCL_OK) { return TCL_ERROR; } match++; - j += slavePtr->numCols - 1; - lastWindow = Tk_PathName(slavePtr->tkwin); + j += contentPtr->numCols - 1; + lastWindow = Tk_PathName(contentPtr->tkwin); numSkip = 0; break; } } } if (!match) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "can't find slave to extend with \"^\"", -1)); + "can't find content to extend with \"^\"", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } } - if (masterPtr == NULL) { + if (containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "can't determine master window", -1)); + "can't determine container window", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } - SetGridSize(masterPtr); + SetGridSize(containerPtr); /* - * If we have emptied this master from slaves it means we are no longer + * If we have emptied this container from content it means we are no longer * handling it and should mark it as free. * - * Send the event "NoManagedChild" to the master to inform it about there + * Send the event "NoManagedChild" to the container to inform it about there * being no managed children inside it. */ - if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) { - TkFreeGeometryMaster(masterPtr->tkwin, "grid"); - masterPtr->flags &= ~ALLOCED_MASTER; - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + if (containerPtr->contentPtr == NULL && containerPtr->flags & ALLOCED_CONTAINER) { + TkFreeGeometryContainer(containerPtr->tkwin, "grid"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL); } return TCL_OK; } Index: generic/tkImage.c ================================================================== --- generic/tkImage.c +++ generic/tkImage.c @@ -2,12 +2,12 @@ * tkImage.c -- * * This module implements the image protocol, which allows lots of * different kinds of images to be used in lots of different widgets. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -24,12 +24,12 @@ * "re-get" the image later if the manager * changes). */ Display *display; /* Display for tkwin. Needed because when the * image is eventually freed tkwin may not * exist anymore. */ - struct ImageMaster *masterPtr; - /* Master for this image (identifiers image + struct ImageModel *modelPtr; + /* Model for this image (identifiers image * manager, for example). */ ClientData instanceData; /* One word argument to pass to image manager * when dealing with this image instance. */ Tk_ImageChangedProc *changeProc; /* Code in widget to call when image changes @@ -38,21 +38,21 @@ struct Image *nextPtr; /* Next in list of all image instances * associated with the same name. */ } Image; /* - * For each image master there is one of the following structures, which + * For each image model there is one of the following structures, which * represents a name in the image table and all of the images instantiated * from it. Entries in mainPtr->imageTable point to these structures. */ -typedef struct ImageMaster { +typedef struct ImageModel { Tk_ImageType *typePtr; /* Information about image type. NULL means * that no image manager owns this image: the * image was deleted. */ - ClientData masterData; /* One-word argument to pass to image mgr when - * dealing with the master, as opposed to + ClientData modelData; /* One-word argument to pass to image mgr when + * dealing with the model, as opposed to * instances. */ int width, height; /* Last known dimensions for image. */ Tcl_HashTable *tablePtr; /* Pointer to hash table containing image (the * imageTable field in some TkMainInfo * structure). */ @@ -62,11 +62,11 @@ Image *instancePtr; /* Pointer to first in list of instances * derived from this name. */ int deleted; /* Flag set when image is being deleted. */ TkWindow *winPtr; /* Main window of interpreter (used to detect * when the world is falling apart.) */ -} ImageMaster; +} ImageModel; typedef struct { Tk_ImageType *imageTypeList;/* First in a list of all known image * types. */ Tk_ImageType *oldImageTypeList; @@ -80,12 +80,12 @@ /* * Prototypes for local functions: */ static void ImageTypeThreadExitProc(ClientData clientData); -static void DeleteImage(ImageMaster *masterPtr); -static void EventuallyDeleteImage(ImageMaster *masterPtr, +static void DeleteImage(ImageModel *modelPtr); +static void EventuallyDeleteImage(ImageModel *modelPtr, int forgetImageHashNow); /* *---------------------------------------------------------------------- * @@ -102,16 +102,15 @@ *---------------------------------------------------------------------- */ static void ImageTypeThreadExitProc( - ClientData dummy) /* not used */ + TCL_UNUSED(void *)) { Tk_ImageType *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)dummy; while (tsdPtr->oldImageTypeList != NULL) { freePtr = tsdPtr->oldImageTypeList; tsdPtr->oldImageTypeList = tsdPtr->oldImageTypeList->nextPtr; ckfree(freePtr); @@ -217,11 +216,11 @@ IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH }; TkWindow *winPtr = (TkWindow *)clientData; int i, isNew, firstOption, index; Tk_ImageType *typePtr; - ImageMaster *masterPtr; + ImageModel *modelPtr; Image *imagePtr; Tcl_HashEntry *hPtr; Tcl_HashSearch search; char idString[16 + TCL_INTEGER_SPACE]; TkDisplay *dispPtr = winPtr->dispPtr; @@ -296,11 +295,11 @@ name = arg; firstOption = 4; /* * Need to check if the _command_ that we are about to create is - * the name of the current master widget command (normally "." but + * the name of the current model widget command (normally "." but * could have been renamed) and fail in that case before a really * nasty and hard to stop crash happens. */ topWin = (TkWindow *) TkToplevelWindowForCommand(interp, name); @@ -317,41 +316,41 @@ * Create the data structure for the new image. */ hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew); if (isNew) { - masterPtr = (ImageMaster *)ckalloc(sizeof(ImageMaster)); - masterPtr->typePtr = NULL; - masterPtr->masterData = NULL; - masterPtr->width = masterPtr->height = 1; - masterPtr->tablePtr = &winPtr->mainPtr->imageTable; - masterPtr->hPtr = hPtr; - masterPtr->instancePtr = NULL; - masterPtr->deleted = 0; - masterPtr->winPtr = winPtr->mainPtr->winPtr; - Tcl_Preserve(masterPtr->winPtr); - Tcl_SetHashValue(hPtr, masterPtr); + modelPtr = (ImageModel *)ckalloc(sizeof(ImageModel)); + modelPtr->typePtr = NULL; + modelPtr->modelData = NULL; + modelPtr->width = modelPtr->height = 1; + modelPtr->tablePtr = &winPtr->mainPtr->imageTable; + modelPtr->hPtr = hPtr; + modelPtr->instancePtr = NULL; + modelPtr->deleted = 0; + modelPtr->winPtr = winPtr->mainPtr->winPtr; + Tcl_Preserve(modelPtr->winPtr); + Tcl_SetHashValue(hPtr, modelPtr); } else { /* * An image already exists by this name. Disconnect the instances - * from the master. + * from the model. */ - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->typePtr != NULL) { - for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->typePtr != NULL) { + for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { - masterPtr->typePtr->freeProc(imagePtr->instanceData, + modelPtr->typePtr->freeProc(imagePtr->instanceData, imagePtr->display); imagePtr->changeProc(imagePtr->widgetClientData, 0, 0, - masterPtr->width, masterPtr->height, - masterPtr->width, masterPtr->height); + modelPtr->width, modelPtr->height, + modelPtr->width, modelPtr->height); } - masterPtr->typePtr->deleteProc(masterPtr->masterData); - masterPtr->typePtr = NULL; + modelPtr->typePtr->deleteProc(modelPtr->modelData); + modelPtr->typePtr = NULL; } - masterPtr->deleted = 0; + modelPtr->deleted = 0; } /* * Call the image type manager so that it can perform its own * initialization, then re-"get" for any existing instances of the @@ -360,37 +359,35 @@ objv += firstOption; objc -= firstOption; args = (Tcl_Obj **) objv; if (oldimage) { - int i; - args = (Tcl_Obj **)ckalloc((objc+1) * sizeof(Tcl_Obj *)); for (i = 0; i < objc; i++) { args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]); } args[objc] = NULL; } - Tcl_Preserve(masterPtr); + Tcl_Preserve(modelPtr); if (typePtr->createProc(interp, name, objc, args, typePtr, - (Tk_ImageMaster)masterPtr, &masterPtr->masterData) != TCL_OK){ - EventuallyDeleteImage(masterPtr, 0); - Tcl_Release(masterPtr); + (Tk_ImageModel)modelPtr, &modelPtr->modelData) != TCL_OK){ + EventuallyDeleteImage(modelPtr, 0); + Tcl_Release(modelPtr); if (oldimage) { ckfree(args); } return TCL_ERROR; } - Tcl_Release(masterPtr); + Tcl_Release(modelPtr); if (oldimage) { ckfree(args); } - masterPtr->typePtr = typePtr; - for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; + modelPtr->typePtr = typePtr; + for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin, - masterPtr->masterData); + modelPtr->modelData); } Tcl_SetObjResult(interp, Tcl_NewStringObj( (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1)); break; } @@ -399,15 +396,15 @@ arg = Tcl_GetString(objv[i]); hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg); if (hPtr == NULL) { goto alreadyDeleted; } - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->deleted) { + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->deleted) { goto alreadyDeleted; } - DeleteImage(masterPtr); + DeleteImage(modelPtr); } break; case IMAGE_NAMES: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); @@ -414,12 +411,12 @@ return TCL_ERROR; } hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search); resultObj = Tcl_NewObj(); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->deleted) { + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->deleted) { continue; } Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1)); } @@ -448,11 +445,11 @@ case IMAGE_INUSE: case IMAGE_TYPE: case IMAGE_WIDTH: /* * These operations all parse virtually identically. First check to - * see if three args are given. Then get a non-deleted master from the + * see if three args are given. Then get a non-deleted model from the * third arg. */ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "name"); @@ -462,35 +459,35 @@ arg = Tcl_GetString(objv[2]); hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg); if (hPtr == NULL) { goto alreadyDeleted; } - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->deleted) { + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->deleted) { goto alreadyDeleted; } /* * Now we read off the specific piece of data we were asked for. */ switch ((enum options) index) { case IMAGE_HEIGHT: - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->height)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(modelPtr->height)); break; case IMAGE_INUSE: Tcl_SetObjResult(interp, Tcl_NewBooleanObj( - masterPtr->typePtr && masterPtr->instancePtr)); + modelPtr->typePtr && modelPtr->instancePtr)); break; case IMAGE_TYPE: - if (masterPtr->typePtr != NULL) { + if (modelPtr->typePtr != NULL) { Tcl_SetObjResult(interp, - Tcl_NewStringObj(masterPtr->typePtr->name, -1)); + Tcl_NewStringObj(modelPtr->typePtr->name, -1)); } break; case IMAGE_WIDTH: - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->width)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(modelPtr->width)); break; default: Tcl_Panic("can't happen"); } break; @@ -522,11 +519,11 @@ *---------------------------------------------------------------------- */ void Tk_ImageChanged( - Tk_ImageMaster imageMaster, /* Image that needs redisplay. */ + Tk_ImageModel imageModel, /* Image that needs redisplay. */ int x, int y, /* Coordinates of upper-left pixel of region * of image that needs to be redrawn. */ int width, int height, /* Dimensions (in pixels) of region of image * to redraw. If either dimension is zero then * the image doesn't need to be redrawn @@ -533,16 +530,16 @@ * (perhaps all that happened is that its size * changed). */ int imageWidth, int imageHeight) /* New dimensions of image. */ { - ImageMaster *masterPtr = (ImageMaster *) imageMaster; + ImageModel *modelPtr = (ImageModel *) imageModel; Image *imagePtr; - masterPtr->width = imageWidth; - masterPtr->height = imageHeight; - for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; + modelPtr->width = imageWidth; + modelPtr->height = imageHeight; + for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->changeProc(imagePtr->widgetClientData, x, y, width, height, imageWidth, imageHeight); } } @@ -550,32 +547,32 @@ /* *---------------------------------------------------------------------- * * Tk_NameOfImage -- * - * Given a token for an image master, this function returns the name of + * Given a token for an image model, this function returns the name of * the image. * * Results: - * The return value is the string name for imageMaster. + * The return value is the string name for imageModel. * * Side effects: * None. * *---------------------------------------------------------------------- */ const char * Tk_NameOfImage( - Tk_ImageMaster imageMaster) /* Token for image. */ + Tk_ImageModel imageModel) /* Token for image. */ { - ImageMaster *masterPtr = (ImageMaster *) imageMaster; + ImageModel *modelPtr = (ImageModel *) imageModel; - if (masterPtr->hPtr == NULL) { + if (modelPtr->hPtr == NULL) { return NULL; } - return (const char *)Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr); + return (const char *)Tcl_GetHashKey(modelPtr->tablePtr, modelPtr->hPtr); } /* *---------------------------------------------------------------------- * @@ -609,34 +606,34 @@ /* Function to invoke when redisplay is needed * because image's pixels or size changed. */ ClientData clientData) /* One-word argument to pass to damageProc. */ { Tcl_HashEntry *hPtr; - ImageMaster *masterPtr; + ImageModel *modelPtr; Image *imagePtr; hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name); if (hPtr == NULL) { goto noSuchImage; } - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->typePtr == NULL) { + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->typePtr == NULL) { goto noSuchImage; } - if (masterPtr->deleted) { + if (modelPtr->deleted) { goto noSuchImage; } imagePtr = (Image *)ckalloc(sizeof(Image)); imagePtr->tkwin = tkwin; imagePtr->display = Tk_Display(tkwin); - imagePtr->masterPtr = masterPtr; + imagePtr->modelPtr = modelPtr; imagePtr->instanceData = - masterPtr->typePtr->getProc(tkwin, masterPtr->masterData); + modelPtr->typePtr->getProc(tkwin, modelPtr->modelData); imagePtr->changeProc = changeProc; imagePtr->widgetClientData = clientData; - imagePtr->nextPtr = masterPtr->instancePtr; - masterPtr->instancePtr = imagePtr; + imagePtr->nextPtr = modelPtr->instancePtr; + modelPtr->instancePtr = imagePtr; return (Tk_Image) imagePtr; noSuchImage: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -668,43 +665,43 @@ Tk_FreeImage( Tk_Image image) /* Token for image that is no longer needed by * a widget. */ { Image *imagePtr = (Image *) image; - ImageMaster *masterPtr = imagePtr->masterPtr; + ImageModel *modelPtr = imagePtr->modelPtr; Image *prevPtr; /* * Clean up the particular instance. */ - if (masterPtr->typePtr != NULL) { - masterPtr->typePtr->freeProc(imagePtr->instanceData, + if (modelPtr->typePtr != NULL) { + modelPtr->typePtr->freeProc(imagePtr->instanceData, imagePtr->display); } - prevPtr = masterPtr->instancePtr; + prevPtr = modelPtr->instancePtr; if (prevPtr == imagePtr) { - masterPtr->instancePtr = imagePtr->nextPtr; + modelPtr->instancePtr = imagePtr->nextPtr; } else { while (prevPtr->nextPtr != imagePtr) { prevPtr = prevPtr->nextPtr; } prevPtr->nextPtr = imagePtr->nextPtr; } ckfree(imagePtr); /* - * If there are no more instances left for the master, and if the master - * image has been deleted, then delete the master too. + * If there are no more instances left for the model, and if the model + * image has been deleted, then delete the model too. */ - if ((masterPtr->typePtr == NULL) && (masterPtr->instancePtr == NULL)) { - if (masterPtr->hPtr != NULL) { - Tcl_DeleteHashEntry(masterPtr->hPtr); + if ((modelPtr->typePtr == NULL) && (modelPtr->instancePtr == NULL)) { + if (modelPtr->hPtr != NULL) { + Tcl_DeleteHashEntry(modelPtr->hPtr); } - Tcl_Release(masterPtr->winPtr); - ckfree(masterPtr); + Tcl_Release(modelPtr->winPtr); + ckfree(modelPtr); } } /* *---------------------------------------------------------------------- @@ -740,13 +737,13 @@ XImage *ximage; Pixmap pmap; GC newGC; XGCValues gcValues; - if (imagePtr->masterPtr->typePtr == NULL) { + if (imagePtr->modelPtr->typePtr == NULL) { /* - * No master for image, so nothing to display on postscript. + * No model for image, so nothing to display on postscript. */ return TCL_OK; } @@ -753,13 +750,13 @@ /* * Check if an image specific postscript-generation function exists; * otherwise go on with generic code. */ - if (imagePtr->masterPtr->typePtr->postscriptProc != NULL) { - return imagePtr->masterPtr->typePtr->postscriptProc( - imagePtr->masterPtr->masterData, interp, tkwin, psinfo, + if (imagePtr->modelPtr->typePtr->postscriptProc != NULL) { + return imagePtr->modelPtr->typePtr->postscriptProc( + imagePtr->modelPtr->modelData, interp, tkwin, psinfo, x, y, width, height, prepass); } if (prepass) { return TCL_OK; @@ -836,13 +833,13 @@ /* Coordinates in drawable that correspond to * imageX and imageY. */ { Image *imagePtr = (Image *) image; - if (imagePtr->masterPtr->typePtr == NULL) { + if (imagePtr->modelPtr->typePtr == NULL) { /* - * No master for image, so nothing to display. + * No model for image, so nothing to display. */ return; } @@ -858,17 +855,17 @@ if (imageY < 0) { height += imageY; drawableY -= imageY; imageY = 0; } - if ((imageX + width) > imagePtr->masterPtr->width) { - width = imagePtr->masterPtr->width - imageX; + if ((imageX + width) > imagePtr->modelPtr->width) { + width = imagePtr->modelPtr->width - imageX; } - if ((imageY + height) > imagePtr->masterPtr->height) { - height = imagePtr->masterPtr->height - imageY; + if ((imageY + height) > imagePtr->modelPtr->height) { + height = imagePtr->modelPtr->height - imageY; } - imagePtr->masterPtr->typePtr->displayProc(imagePtr->instanceData, + imagePtr->modelPtr->typePtr->displayProc(imagePtr->instanceData, imagePtr->display, drawable, imageX, imageY, width, height, drawableX, drawableY); } /* @@ -894,12 +891,12 @@ int *widthPtr, /* Return width of image here. */ int *heightPtr) /* Return height of image here. */ { Image *imagePtr = (Image *) image; - *widthPtr = imagePtr->masterPtr->width; - *heightPtr = imagePtr->masterPtr->height; + *widthPtr = imagePtr->modelPtr->width; + *heightPtr = imagePtr->modelPtr->height; } /* *---------------------------------------------------------------------- * @@ -932,11 +929,11 @@ } hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name); if (hPtr == NULL) { return; } - DeleteImage((ImageMaster *)Tcl_GetHashValue(hPtr)); + DeleteImage((ImageModel *)Tcl_GetHashValue(hPtr)); } /* *---------------------------------------------------------------------- * @@ -947,43 +944,43 @@ * Results: * None. * * Side effects: * The connection is dropped between instances of this image and an image - * master. Image instances will redisplay themselves as empty areas, but + * model. Image instances will redisplay themselves as empty areas, but * existing instances will not be deleted. * *---------------------------------------------------------------------- */ static void DeleteImage( - ImageMaster *masterPtr) /* Pointer to main data structure for image. */ + ImageModel *modelPtr) /* Pointer to main data structure for image. */ { Image *imagePtr; Tk_ImageType *typePtr; - typePtr = masterPtr->typePtr; - masterPtr->typePtr = NULL; + typePtr = modelPtr->typePtr; + modelPtr->typePtr = NULL; if (typePtr != NULL) { - for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; + for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { typePtr->freeProc(imagePtr->instanceData, imagePtr->display); imagePtr->changeProc(imagePtr->widgetClientData, 0, 0, - masterPtr->width, masterPtr->height, masterPtr->width, - masterPtr->height); - } - typePtr->deleteProc(masterPtr->masterData); - } - if (masterPtr->instancePtr == NULL) { - if (masterPtr->hPtr != NULL) { - Tcl_DeleteHashEntry(masterPtr->hPtr); - } - Tcl_Release(masterPtr->winPtr); - ckfree(masterPtr); - } else { - masterPtr->deleted = 1; + modelPtr->width, modelPtr->height, modelPtr->width, + modelPtr->height); + } + typePtr->deleteProc(modelPtr->modelData); + } + if (modelPtr->instancePtr == NULL) { + if (modelPtr->hPtr != NULL) { + Tcl_DeleteHashEntry(modelPtr->hPtr); + } + Tcl_Release(modelPtr->winPtr); + ckfree(modelPtr); + } else { + modelPtr->deleted = 1; } } /* *---------------------------------------------------------------------- @@ -1003,20 +1000,20 @@ *---------------------------------------------------------------------- */ static void EventuallyDeleteImage( - ImageMaster *masterPtr, /* Pointer to main data structure for image. */ + ImageModel *modelPtr, /* Pointer to main data structure for image. */ int forgetImageHashNow) /* Flag to say whether the hash table is about * to vanish. */ { if (forgetImageHashNow) { - masterPtr->hPtr = NULL; + modelPtr->hPtr = NULL; } - if (!masterPtr->deleted) { - masterPtr->deleted = 1; - Tcl_EventuallyFree(masterPtr, (Tcl_FreeProc *) DeleteImage); + if (!modelPtr->deleted) { + modelPtr->deleted = 1; + Tcl_EventuallyFree(modelPtr, (Tcl_FreeProc *) DeleteImage); } } /* *---------------------------------------------------------------------- @@ -1044,22 +1041,22 @@ Tcl_HashSearch search; Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - EventuallyDeleteImage((ImageMaster *)Tcl_GetHashValue(hPtr), 1); + EventuallyDeleteImage((ImageModel *)Tcl_GetHashValue(hPtr), 1); } Tcl_DeleteHashTable(&mainPtr->imageTable); } /* *---------------------------------------------------------------------- * - * Tk_GetImageMasterData -- + * Tk_GetImageModelData -- * * Given the name of an image, this function returns the type of the - * image and the clientData associated with its master. + * image and the clientData associated with its model. * * Results: * If there is no image by the given name, then NULL is returned and a * NULL value is stored at *typePtrPtr. Otherwise the return value is the * clientData returned by the createProc when the image was created and a @@ -1070,34 +1067,34 @@ * *---------------------------------------------------------------------- */ ClientData -Tk_GetImageMasterData( +Tk_GetImageModelData( Tcl_Interp *interp, /* Interpreter in which the image was * created. */ const char *name, /* Name of image. */ const Tk_ImageType **typePtrPtr) /* Points to location to fill in with pointer * to type information for image. */ { TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp); Tcl_HashEntry *hPtr; - ImageMaster *masterPtr; + ImageModel *modelPtr; hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name); if (hPtr == NULL) { *typePtrPtr = NULL; return NULL; } - masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr); - if (masterPtr->deleted) { + modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); + if (modelPtr->deleted) { *typePtrPtr = NULL; return NULL; } - *typePtrPtr = masterPtr->typePtr; - return masterPtr->masterData; + *typePtrPtr = modelPtr->typePtr; + return modelPtr->modelData; } /* *---------------------------------------------------------------------- * Index: generic/tkImgBmap.c ================================================================== --- generic/tkImgBmap.c +++ generic/tkImgBmap.c @@ -1,27 +1,27 @@ /* * tkImgBmap.c -- * * This procedure implements images of type "bitmap" for Tk. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1999 by Scriptics Corporation. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" /* - * The following data structure represents the master for a bitmap + * The following data structure represents the model for a bitmap * image: */ -typedef struct BitmapMaster { - Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means the +typedef struct { + Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the * image is being deleted. */ Tcl_Interp *interp; /* Interpreter for application that is using * image. */ Tcl_Command imageCmd; /* Token for image command (used to delete it * when the image goes away). NULL means the @@ -38,22 +38,22 @@ char *dataString; /* Value of -data option (malloc'ed). */ char *maskFileString; /* Value of -maskfile option (malloc'ed). */ char *maskDataString; /* Value of -maskdata option (malloc'ed). */ struct BitmapInstance *instancePtr; /* First in list of all instances associated - * with this master. */ -} BitmapMaster; + * with this model. */ +} BitmapModel; /* * The following data structure represents all of the instances of an image * that lie within a particular window: */ typedef struct BitmapInstance { size_t refCount; /* Number of instances that share this data * structure. */ - BitmapMaster *masterPtr; /* Pointer to master for image. */ + BitmapModel *modelPtr; /* Pointer to model for image. */ Tk_Window tkwin; /* Window in which the instances will be * displayed. */ XColor *fg; /* Foreground color for displaying image. */ XColor *bg; /* Background color for displaying image. */ Pixmap bitmap; /* The bitmap to display. */ @@ -63,11 +63,11 @@ * None means there was an error while setting * up the instance, so it cannot be * displayed. */ struct BitmapInstance *nextPtr; /* Next in list of all instance structures - * associated with masterPtr (NULL means end + * associated with modelPtr (NULL means end * of list). */ } BitmapInstance; /* * The type record for bitmap images: @@ -74,11 +74,11 @@ */ static int GetByte(Tcl_Channel chan); static int ImgBmapCreate(Tcl_Interp *interp, const char *name, int argc, Tcl_Obj *const objv[], - const Tk_ImageType *typePtr, Tk_ImageMaster master, + const Tk_ImageType *typePtr, Tk_ImageModel model, ClientData *clientDataPtr); static ClientData ImgBmapGet(Tk_Window tkwin, ClientData clientData); static void ImgBmapDisplay(ClientData clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, int height, @@ -106,21 +106,21 @@ * Information used for parsing configuration specs: */ static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_UID, "-background", NULL, NULL, - "", offsetof(BitmapMaster, bgUid), 0, NULL}, + "", offsetof(BitmapModel, bgUid), 0, NULL}, {TK_CONFIG_STRING, "-data", NULL, NULL, - NULL, offsetof(BitmapMaster, dataString), TK_CONFIG_NULL_OK, NULL}, + NULL, offsetof(BitmapModel, dataString), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_STRING, "-file", NULL, NULL, - NULL, offsetof(BitmapMaster, fileString), TK_CONFIG_NULL_OK, NULL}, + NULL, offsetof(BitmapModel, fileString), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_UID, "-foreground", NULL, NULL, - "#000000", offsetof(BitmapMaster, fgUid), 0, NULL}, + "#000000", offsetof(BitmapModel, fgUid), 0, NULL}, {TK_CONFIG_STRING, "-maskdata", NULL, NULL, - NULL, offsetof(BitmapMaster, maskDataString), TK_CONFIG_NULL_OK, NULL}, + NULL, offsetof(BitmapModel, maskDataString), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_STRING, "-maskfile", NULL, NULL, - NULL, offsetof(BitmapMaster, maskFileString), TK_CONFIG_NULL_OK, NULL}, + NULL, offsetof(BitmapModel, maskFileString), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; /* * The following data structure is used to describe the state of parsing a @@ -147,11 +147,11 @@ static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[]); static void ImgBmapCmdDeletedProc(ClientData clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); -static int ImgBmapConfigureMaster(BitmapMaster *masterPtr, +static int ImgBmapConfigureModel(BitmapModel *modelPtr, int argc, Tcl_Obj *const objv[], int flags); static int NextBitmapWord(ParseInfo *parseInfoPtr); /* *---------------------------------------------------------------------- @@ -176,63 +176,63 @@ const char *name, /* Name to use for image. */ int argc, /* Number of arguments. */ Tcl_Obj *const argv[], /* Argument objects for options (doesn't * include image name or type). */ const Tk_ImageType *typePtr,/* Pointer to our type record (not used). */ - Tk_ImageMaster master, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - BitmapMaster *masterPtr = (BitmapMaster *)ckalloc(sizeof(BitmapMaster)); + BitmapModel *modelPtr = (BitmapModel *)ckalloc(sizeof(BitmapModel)); (void)typePtr; - masterPtr->tkMaster = master; - masterPtr->interp = interp; - masterPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgBmapCmd, - masterPtr, ImgBmapCmdDeletedProc); - masterPtr->width = masterPtr->height = 0; - masterPtr->data = NULL; - masterPtr->maskData = NULL; - masterPtr->fgUid = NULL; - masterPtr->bgUid = NULL; - masterPtr->fileString = NULL; - masterPtr->dataString = NULL; - masterPtr->maskFileString = NULL; - masterPtr->maskDataString = NULL; - masterPtr->instancePtr = NULL; - if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) { - ImgBmapDelete(masterPtr); + modelPtr->tkModel = model; + modelPtr->interp = interp; + modelPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgBmapCmd, + modelPtr, ImgBmapCmdDeletedProc); + modelPtr->width = modelPtr->height = 0; + modelPtr->data = NULL; + modelPtr->maskData = NULL; + modelPtr->fgUid = NULL; + modelPtr->bgUid = NULL; + modelPtr->fileString = NULL; + modelPtr->dataString = NULL; + modelPtr->maskFileString = NULL; + modelPtr->maskDataString = NULL; + modelPtr->instancePtr = NULL; + if (ImgBmapConfigureModel(modelPtr, argc, argv, 0) != TCL_OK) { + ImgBmapDelete(modelPtr); return TCL_ERROR; } - *clientDataPtr = masterPtr; + *clientDataPtr = modelPtr; return TCL_OK; } /* *---------------------------------------------------------------------- * - * ImgBmapConfigureMaster -- + * ImgBmapConfigureModel -- * * This procedure is called when a bitmap image is created or * reconfigured. It process configuration options and resets any * instances of the image. * * Results: * A standard Tcl return value. If TCL_ERROR is returned then an error - * message is left in the masterPtr->interp's result. + * message is left in the modelPtr->interp's result. * * Side effects: * Existing instances of the image will be redisplayed to match the new * configuration options. * *---------------------------------------------------------------------- */ static int -ImgBmapConfigureMaster( - BitmapMaster *masterPtr, /* Pointer to data structure describing +ImgBmapConfigureModel( + BitmapModel *modelPtr, /* Pointer to data structure describing * overall bitmap image to (reconfigure). */ int objc, /* Number of entries in objv. */ Tcl_Obj *const objv[], /* Pairs of configuration options for image. */ int flags) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ @@ -244,12 +244,12 @@ for (dummy1 = 0; dummy1 < objc; dummy1++) { argv[dummy1] = Tcl_GetString(objv[dummy1]); } argv[objc] = NULL; - if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp), - configSpecs, objc, argv, (char *) masterPtr, flags) != TCL_OK) { + if (Tk_ConfigureWidget(modelPtr->interp, Tk_MainWindow(modelPtr->interp), + configSpecs, objc, argv, (char *) modelPtr, flags) != TCL_OK) { ckfree(argv); return TCL_ERROR; } ckfree(argv); @@ -256,48 +256,48 @@ /* * Parse the bitmap and/or mask to create binary data. Make sure that the * bitmap and mask have the same dimensions. */ - if (masterPtr->data != NULL) { - ckfree(masterPtr->data); - masterPtr->data = NULL; - } - if ((masterPtr->fileString != NULL) || (masterPtr->dataString != NULL)) { - masterPtr->data = TkGetBitmapData(masterPtr->interp, - masterPtr->dataString, masterPtr->fileString, - &masterPtr->width, &masterPtr->height, &dummy1, &dummy2); - if (masterPtr->data == NULL) { + if (modelPtr->data != NULL) { + ckfree(modelPtr->data); + modelPtr->data = NULL; + } + if ((modelPtr->fileString != NULL) || (modelPtr->dataString != NULL)) { + modelPtr->data = TkGetBitmapData(modelPtr->interp, + modelPtr->dataString, modelPtr->fileString, + &modelPtr->width, &modelPtr->height, &dummy1, &dummy2); + if (modelPtr->data == NULL) { return TCL_ERROR; } } - if (masterPtr->maskData != NULL) { - ckfree(masterPtr->maskData); - masterPtr->maskData = NULL; - } - if ((masterPtr->maskFileString != NULL) - || (masterPtr->maskDataString != NULL)) { - if (masterPtr->data == NULL) { - Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj( + if (modelPtr->maskData != NULL) { + ckfree(modelPtr->maskData); + modelPtr->maskData = NULL; + } + if ((modelPtr->maskFileString != NULL) + || (modelPtr->maskDataString != NULL)) { + if (modelPtr->data == NULL) { + Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj( "can't have mask without bitmap", -1)); - Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP", + Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP", "NO_BITMAP", NULL); return TCL_ERROR; } - masterPtr->maskData = TkGetBitmapData(masterPtr->interp, - masterPtr->maskDataString, masterPtr->maskFileString, + modelPtr->maskData = TkGetBitmapData(modelPtr->interp, + modelPtr->maskDataString, modelPtr->maskFileString, &maskWidth, &maskHeight, &dummy1, &dummy2); - if (masterPtr->maskData == NULL) { + if (modelPtr->maskData == NULL) { return TCL_ERROR; } - if ((maskWidth != masterPtr->width) - || (maskHeight != masterPtr->height)) { - ckfree(masterPtr->maskData); - masterPtr->maskData = NULL; - Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj( + if ((maskWidth != modelPtr->width) + || (maskHeight != modelPtr->height)) { + ckfree(modelPtr->maskData); + modelPtr->maskData = NULL; + Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj( "bitmap and mask have different sizes", -1)); - Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP", + Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP", "MASK_SIZE", NULL); return TCL_ERROR; } } @@ -305,27 +305,27 @@ * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { ImgBmapConfigureInstance(instancePtr); } - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width, - masterPtr->height, masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width, + modelPtr->height, modelPtr->width, modelPtr->height); return TCL_OK; } /* *---------------------------------------------------------------------- * * ImgBmapConfigureInstance -- * * This procedure is called to create displaying information for a bitmap - * image instance based on the configuration information in the master. - * It is invoked both when new instances are created and when the master + * image instance based on the configuration information in the model. + * It is invoked both when new instances are created and when the model * is reconfigured. * * Results: * None. * @@ -338,25 +338,25 @@ static void ImgBmapConfigureInstance( BitmapInstance *instancePtr)/* Instance to reconfigure. */ { - BitmapMaster *masterPtr = instancePtr->masterPtr; + BitmapModel *modelPtr = instancePtr->modelPtr; XColor *colorPtr; XGCValues gcValues; GC gc; unsigned int mask; Pixmap oldBitmap, oldMask; /* - * For each of the options in masterPtr, translate the string form into an + * For each of the options in modelPtr, translate the string form into an * internal form appropriate for instancePtr. */ - if (*masterPtr->bgUid != 0) { - colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin, - masterPtr->bgUid); + if (*modelPtr->bgUid != 0) { + colorPtr = Tk_GetColor(modelPtr->interp, instancePtr->tkwin, + modelPtr->bgUid); if (colorPtr == NULL) { goto error; } } else { colorPtr = NULL; @@ -364,12 +364,12 @@ if (instancePtr->bg != NULL) { Tk_FreeColor(instancePtr->bg); } instancePtr->bg = colorPtr; - colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin, - masterPtr->fgUid); + colorPtr = Tk_GetColor(modelPtr->interp, instancePtr->tkwin, + modelPtr->fgUid); if (colorPtr == NULL) { goto error; } if (instancePtr->fg != NULL) { Tk_FreeColor(instancePtr->fg); @@ -386,33 +386,33 @@ oldBitmap = instancePtr->bitmap; instancePtr->bitmap = None; oldMask = instancePtr->mask; instancePtr->mask = None; - if (masterPtr->data != NULL) { + if (modelPtr->data != NULL) { instancePtr->bitmap = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), - masterPtr->data, (unsigned) masterPtr->width, - (unsigned) masterPtr->height); + modelPtr->data, (unsigned) modelPtr->width, + (unsigned) modelPtr->height); } - if (masterPtr->maskData != NULL) { + if (modelPtr->maskData != NULL) { instancePtr->mask = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), - masterPtr->maskData, (unsigned) masterPtr->width, - (unsigned) masterPtr->height); + modelPtr->maskData, (unsigned) modelPtr->width, + (unsigned) modelPtr->height); } if (oldMask != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } if (oldBitmap != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap); } - if (masterPtr->data != NULL) { + if (modelPtr->data != NULL) { gcValues.foreground = instancePtr->fg->pixel; gcValues.graphics_exposures = False; mask = GCForeground|GCGraphicsExposures; if (instancePtr->bg != NULL) { gcValues.background = instancePtr->bg->pixel; @@ -443,14 +443,14 @@ if (instancePtr->gc != NULL) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = NULL; - Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf( + Tcl_AppendObjToErrorInfo(modelPtr->interp, Tcl_ObjPrintf( "\n (while configuring image \"%s\")", Tk_NameOfImage( - masterPtr->tkMaster))); - Tcl_BackgroundException(masterPtr->interp, TCL_ERROR); + modelPtr->tkModel))); + Tcl_BackgroundException(modelPtr->interp, TCL_ERROR); } /* *---------------------------------------------------------------------- * @@ -749,17 +749,17 @@ *-------------------------------------------------------------- */ static int ImgBmapCmd( - ClientData clientData, /* Information about the image master. */ + ClientData clientData, /* Information about the image model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const bmapOptions[] = {"cget", "configure", NULL}; - BitmapMaster *masterPtr = (BitmapMaster *)clientData; + BitmapModel *modelPtr = (BitmapModel *)clientData; int index; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; @@ -773,21 +773,21 @@ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) masterPtr, Tcl_GetString(objv[2]), 0); + (char *) modelPtr, Tcl_GetString(objv[2]), 0); case 1: /* configure */ if (objc == 2) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, NULL, 0); + configSpecs, (char *) modelPtr, NULL, 0); } else if (objc == 3) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, + configSpecs, (char *) modelPtr, Tcl_GetString(objv[2]), 0); } else { - return ImgBmapConfigureMaster(masterPtr, objc-2, objv+2, + return ImgBmapConfigureModel(modelPtr, objc-2, objv+2, TK_CONFIG_ARGV_ONLY); } default: Tcl_Panic("bad const entries to bmapOptions in ImgBmapCmd"); return TCL_OK; @@ -814,22 +814,22 @@ static ClientData ImgBmapGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ - ClientData masterData) /* Pointer to our master structure for the + ClientData modelData) /* Pointer to our model structure for the * image. */ { - BitmapMaster *masterPtr = (BitmapMaster *)masterData; + BitmapModel *modelPtr = (BitmapModel *)modelData; BitmapInstance *instancePtr; /* * See if there is already an instance for this window. If so then just * re-use it. */ - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { if (instancePtr->tkwin == tkwin) { instancePtr->refCount++; return instancePtr; } @@ -840,28 +840,28 @@ * the image. */ instancePtr = (BitmapInstance *)ckalloc(sizeof(BitmapInstance)); instancePtr->refCount = 1; - instancePtr->masterPtr = masterPtr; + instancePtr->modelPtr = modelPtr; instancePtr->tkwin = tkwin; instancePtr->fg = NULL; instancePtr->bg = NULL; instancePtr->bitmap = None; instancePtr->mask = None; instancePtr->gc = NULL; - instancePtr->nextPtr = masterPtr->instancePtr; - masterPtr->instancePtr = instancePtr; + instancePtr->nextPtr = modelPtr->instancePtr; + modelPtr->instancePtr = instancePtr; ImgBmapConfigureInstance(instancePtr); /* * If this is the first instance, must set the size of the image. */ if (instancePtr->nextPtr == NULL) { - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, - masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, modelPtr->width, + modelPtr->height); } return instancePtr; } @@ -973,14 +973,14 @@ Tk_FreePixmap(display, instancePtr->mask); } if (instancePtr->gc != NULL) { Tk_FreeGC(display, instancePtr->gc); } - if (instancePtr->masterPtr->instancePtr == instancePtr) { - instancePtr->masterPtr->instancePtr = instancePtr->nextPtr; + if (instancePtr->modelPtr->instancePtr == instancePtr) { + instancePtr->modelPtr->instancePtr = instancePtr->nextPtr; } else { - for (prevPtr = instancePtr->masterPtr->instancePtr; + for (prevPtr = instancePtr->modelPtr->instancePtr; prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body */ } prevPtr->nextPtr = instancePtr->nextPtr; } @@ -990,11 +990,11 @@ /* *---------------------------------------------------------------------- * * ImgBmapDelete -- * - * This procedure is called by the image code to delete the master + * This procedure is called by the image code to delete the model * structure for an image. * * Results: * None. * @@ -1004,30 +1004,30 @@ *---------------------------------------------------------------------- */ static void ImgBmapDelete( - ClientData masterData) /* Pointer to BitmapMaster structure for + ClientData modelData) /* Pointer to BitmapModel structure for * image. Must not have any more instances. */ { - BitmapMaster *masterPtr = (BitmapMaster *)masterData; + BitmapModel *modelPtr = (BitmapModel *)modelData; - if (masterPtr->instancePtr != NULL) { + if (modelPtr->instancePtr != NULL) { Tcl_Panic("tried to delete bitmap image when instances still exist"); } - masterPtr->tkMaster = NULL; - if (masterPtr->imageCmd != NULL) { - Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd); - } - if (masterPtr->data != NULL) { - ckfree(masterPtr->data); - } - if (masterPtr->maskData != NULL) { - ckfree(masterPtr->maskData); - } - Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); - ckfree(masterPtr); + modelPtr->tkModel = NULL; + if (modelPtr->imageCmd != NULL) { + Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd); + } + if (modelPtr->data != NULL) { + ckfree(modelPtr->data); + } + if (modelPtr->maskData != NULL) { + ckfree(modelPtr->maskData); + } + Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0); + ckfree(modelPtr); } /* *---------------------------------------------------------------------- * @@ -1045,18 +1045,18 @@ *---------------------------------------------------------------------- */ static void ImgBmapCmdDeletedProc( - ClientData clientData) /* Pointer to BitmapMaster structure for + ClientData clientData) /* Pointer to BitmapModel structure for * image. */ { - BitmapMaster *masterPtr = (BitmapMaster *)clientData; + BitmapModel *modelPtr = (BitmapModel *)clientData; - masterPtr->imageCmd = NULL; - if (masterPtr->tkMaster != NULL) { - Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); + modelPtr->imageCmd = NULL; + if (modelPtr->tkModel != NULL) { + Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkModel)); } } /* *---------------------------------------------------------------------- @@ -1080,11 +1080,11 @@ { char buffer; size_t size; size = Tcl_Read(chan, &buffer, 1); - if ((size + 1) < 2) { + if (size != 1) { return EOF; } else { return buffer; } } @@ -1195,11 +1195,11 @@ Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass) { - BitmapMaster *masterPtr = (BitmapMaster *)clientData; + BitmapModel *modelPtr = (BitmapModel *)clientData; Tcl_InterpState interpState; Tcl_Obj *psObj; if (prepass) { return TCL_OK; @@ -1207,21 +1207,21 @@ /* * There is nothing to do for bitmaps with zero width or height. */ - if (width<=0 || height<=0 || masterPtr->width<=0 || masterPtr->height<=0){ + if (width<=0 || height<=0 || modelPtr->width<=0 || modelPtr->height<=0){ return TCL_OK; } /* * Some postscript implementations cannot handle bitmap strings longer * than about 60k characters. If the bitmap data is that big or bigger, * we bail out. */ - if (masterPtr->width*masterPtr->height > 60000) { + if (modelPtr->width*modelPtr->height > 60000) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unable to generate postscript for bitmaps larger than 60000" " pixels", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); return TCL_ERROR; @@ -1256,48 +1256,48 @@ * there is no background mask, then color the complete rectangle that * encloses the bitmap. If there is a background mask, then only apply * color to the bits specified by the mask. */ - if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) { + if ((modelPtr->bgUid != NULL) && (modelPtr->bgUid[0] != '\000')) { XColor color; - TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid, + TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), modelPtr->bgUid, &color); Tcl_ResetResult(interp); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); - if (masterPtr->maskData == NULL) { + if (modelPtr->maskData == NULL) { Tcl_AppendToObj(psObj, "0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto " "closepath fill\n", -1); } else { - ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height, - masterPtr->maskData); + ImgBmapPsImagemask(psObj, modelPtr->width, modelPtr->height, + modelPtr->maskData); } } /* * Draw the bitmap foreground, assuming there is one. */ - if ((masterPtr->fgUid != NULL) && (masterPtr->data != NULL)) { + if ((modelPtr->fgUid != NULL) && (modelPtr->data != NULL)) { XColor color; - TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid, + TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), modelPtr->fgUid, &color); Tcl_ResetResult(interp); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); - ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height, - masterPtr->data); + ImgBmapPsImagemask(psObj, modelPtr->width, modelPtr->height, + modelPtr->data); } /* * Plug the accumulated postscript back into the result. */ Index: generic/tkImgGIF.c ================================================================== --- generic/tkImgGIF.c +++ generic/tkImgGIF.c @@ -6,14 +6,14 @@ * read using the -data option of the photo image. The data may be given * as a binary string in a Tcl_Obj or by representing the data as BASE64 * encoded ascii. Derived from the giftoppm code found in the pbmplus * package and tkImgFmtPPM.c in the tk4.0b2 distribution. * - * Copyright (c) Reed Wade (wade@cs.utk.edu), University of Tennessee - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright (c) 1997 Australian National University - * Copyright (c) 2005-2010 Donal K. Fellows + * Copyright © Reed Wade (wade@cs.utk.edu), University of Tennessee + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 1997 Australian National University + * Copyright © 2005-2010 Donal K. Fellows * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * This file also contains code from the giftoppm program, which is @@ -354,14 +354,14 @@ *---------------------------------------------------------------------- */ static int FileMatchGIF( - TCL_UNUSED(Tcl_Interp *), /* not used */ + TCL_UNUSED(Tcl_Interp *), /* not used */ Tcl_Channel chan, /* The image file, open for reading. */ TCL_UNUSED(const char *), /* The name of the image file. */ - TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */ @@ -852,11 +852,11 @@ { unsigned char *data, header[10]; TkSizeT got, length; MFile handle; - data = TkGetByteArrayFromObj(dataObj, &length); + data = Tcl_GetByteArrayFromObj(dataObj, &length); /* * Header is a minimum of 10 bytes. */ @@ -922,11 +922,11 @@ Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { MFile handle, *hdlPtr = &handle; TkSizeT length; const char *xferFormat; - unsigned char *data = TkGetByteArrayFromObj(dataObj, &length); + unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length); mInit(data, hdlPtr, length); /* * Check whether the data is Base64 encoded by doing a character-by- @@ -1179,12 +1179,12 @@ Tcl_Interp *interp, unsigned char *imagePtr, Tcl_Channel chan, int len, int rows, unsigned char cmap[MAXCOLORMAPSIZE][4], - TCL_UNUSED(int), - TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(int), int interlace, int transparent) { unsigned char initialCodeSize; int xpos = 0, ypos = 0, pass = 0, i, count; Index: generic/tkImgListFormat.c ================================================================== --- generic/tkImgListFormat.c +++ generic/tkImgListFormat.c @@ -10,14 +10,14 @@ * * This image format cannot read/write files, it is meant for string * data only. * * - * Copyright (c) 1994 The Australian National University. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2002-2003 Donal K. Fellows - * Copyright (c) 2003 ActiveState Corporation. + * Copyright © 1994 The Australian National University. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2002-2003 Donal K. Fellows + * Copyright © 2003 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Authors: @@ -779,11 +779,11 @@ /* * Find out which color format we have */ - specString = TkGetStringFromObj(specObj, &charCount); + specString = Tcl_GetStringFromObj(specObj, &charCount); if (charCount == 0) { /* Empty string */ *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0; return TCL_OK; Index: generic/tkImgPNG.c ================================================================== --- generic/tkImgPNG.c +++ generic/tkImgPNG.c @@ -1,12 +1,12 @@ /* * tkImgPNG.c -- * * A Tk photo image file handler for PNG files. * - * Copyright (c) 2006-2008 Muonics, Inc. - * Copyright (c) 2008 Donal K. Fellows + * Copyright © 2006-2008 Muonics, Inc. + * Copyright © 2008 Donal K. Fellows * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -334,11 +334,11 @@ if (objPtr) { Tcl_IncrRefCount(objPtr); pngPtr->objDataPtr = objPtr; pngPtr->strDataBuf = - TkGetByteArrayFromObj(objPtr, &pngPtr->strDataLen); + Tcl_GetByteArrayFromObj(objPtr, &pngPtr->strDataLen); } /* * Initialize the palette transparency table to fully opaque. */ @@ -645,14 +645,14 @@ } else if (pngPtr->strDataBuf) { return ReadByteArray(interp, pngPtr, destPtr, destSz, crcPtr); } while (destSz) { - size_t blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); + TkSizeT blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); - blockSz = (size_t)Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); - if (blockSz == (size_t)-1) { + blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); + if (blockSz == TCL_IO_FAILURE) { /* TODO: failure info... */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "channel read failed: %s", Tcl_PosixError(interp))); return TCL_ERROR; } @@ -1285,11 +1285,11 @@ /* * If reading from string, reset position and try base64 decode. */ if (mismatch && pngPtr->strDataBuf) { - pngPtr->strDataBuf = TkGetByteArrayFromObj(pngPtr->objDataPtr, + pngPtr->strDataBuf = Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &pngPtr->strDataLen); pngPtr->base64Data = pngPtr->strDataBuf; if (ReadData(interp, pngPtr, sigBuf, PNG_SIG_SZ, NULL) == TCL_ERROR) { return TCL_ERROR; @@ -1808,13 +1808,13 @@ UnfilterLine( Tcl_Interp *interp, PNGImage *pngPtr) { unsigned char *thisLine = - Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, NULL); + Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL); unsigned char *lastLine = - Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, NULL); + Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, (int *)NULL); #define PNG_FILTER_NONE 0 #define PNG_FILTER_SUB 1 #define PNG_FILTER_UP 2 #define PNG_FILTER_AVG 3 @@ -1940,11 +1940,11 @@ int shifts = 0; /* Number of channels extracted from byte */ int offset = 0; /* Current offset into pixelPtr */ int colStep = 1; /* Column increment each pass */ int pixStep = 0; /* extra pixelPtr increment each pass */ unsigned char lastPixel[6]; - unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, NULL); + unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL); p++; if (UnfilterLine(interp, pngPtr) == TCL_ERROR) { return TCL_ERROR; } @@ -2246,16 +2246,16 @@ * Inflate, processing each output buffer's worth as a line of pixels, * until we cannot fill the buffer any more. */ getNextLine: - TkGetByteArrayFromObj(pngPtr->thisLineObj, &len1); + Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len1); if (Tcl_ZlibStreamGet(pngPtr->stream, pngPtr->thisLineObj, pngPtr->phaseSize - len1) == TCL_ERROR) { return TCL_ERROR; } - TkGetByteArrayFromObj(pngPtr->thisLineObj, &len2); + Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2); if (len2 == (TkSizeT)pngPtr->phaseSize) { if (pngPtr->phase > 7) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra data after final scan line of final phase", @@ -2395,11 +2395,11 @@ Tcl_Obj **objv = NULL; int objc = 0; static const char *const fmtOptions[] = { "-alpha", NULL }; - enum fmtOptions { + enum fmtOptionsEnum { OPT_ALPHA }; /* * Extract elements of format specification as a list. @@ -2432,11 +2432,11 @@ } objc--; objv++; - switch ((enum fmtOptions) optIndex) { + switch ((enum fmtOptionsEnum) optIndex) { case OPT_ALPHA: if (Tcl_GetDoubleFromObj(interp, objv[0], &pngPtr->alpha) == TCL_ERROR) { return TCL_ERROR; } @@ -2816,11 +2816,11 @@ static int FileMatchPNG( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tcl_Channel chan, /* The image file, open for reading. */ TCL_UNUSED(const char *), /* The name of the image file. */ - TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */ @@ -2868,11 +2868,11 @@ Tcl_Obj *fmtObj, /* User-specified format object, or NULL. */ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */ Tk_PhotoHandle imageHandle, /* The photo image to write into. */ int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ - TCL_UNUSED(int), /* Dimensions of block of photo image to be + TCL_UNUSED(int), /* Dimensions of block of photo image to be * written to. */ TCL_UNUSED(int), TCL_UNUSED(int), /* Coordinates of top-left pixel to be used in * image being read. */ TCL_UNUSED(int), @@ -2923,11 +2923,11 @@ static int StringMatchPNG( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tcl_Obj *pObjData, /* the object containing the image data */ - TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */ + TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */ int *widthPtr, /* where to put the string width */ int *heightPtr, /* where to put the string height */ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */ { @@ -2934,11 +2934,11 @@ PNGImage png; int match = 0; InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE); - png.strDataBuf = TkGetByteArrayFromObj(pObjData, &png.strDataLen); + png.strDataBuf = Tcl_GetByteArrayFromObj(pObjData, &png.strDataLen); if (ReadIHDR(interp, &png) == TCL_OK) { *widthPtr = png.block.width; *heightPtr = png.block.height; match = 1; @@ -2972,11 +2972,11 @@ Tcl_Obj *pObjData, /* object containing the image */ Tcl_Obj *fmtObj, /* format object, or NULL */ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */ Tk_PhotoHandle imageHandle, /* the image to write this data into */ int destX, int destY, /* The rectangular region of the */ - TCL_UNUSED(int), /* image to copy */ + TCL_UNUSED(int), /* image to copy */ TCL_UNUSED(int), TCL_UNUSED(int), TCL_UNUSED(int), Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { @@ -3045,11 +3045,11 @@ if (pngPtr->objDataPtr) { TkSizeT objSz; unsigned char *destPtr; - TkGetByteArrayFromObj(pngPtr->objDataPtr, &objSz); + Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz); if (objSz + srcSz > INT_MAX) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image too large to store completely in byte array", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL); @@ -3429,11 +3429,11 @@ * Now get the compressed data and write it as one big IDAT chunk. */ outputObj = Tcl_NewObj(); (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1); - outputBytes = TkGetByteArrayFromObj(outputObj, &outputSize); + outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize); result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize); Tcl_DecrRefCount(outputObj); return result; } @@ -3512,11 +3512,11 @@ /* * Add a pHYs chunk if there is metadata for DPI and/or aspect * aspect = PPUy / PPUx * DPI = PPUx * 0.0254 - * The physical chunc consists of: + * The physical chunk consists of: * - Points per meter in x direction (32 bit) * - Points per meter in x direction (32 bit) * - Unit specifier: 0: no unit (only aspect), 1: Points per meter */ Index: generic/tkImgPPM.c ================================================================== --- generic/tkImgPPM.c +++ generic/tkImgPPM.c @@ -1,12 +1,12 @@ /* * tkImgPPM.c -- * * A photo image file handler for PPM (Portable PixMap) files. * - * Copyright (c) 1994 The Australian National University. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Australian National University. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Author: Paul Mackerras (paulus@cs.anu.edu.au), @@ -92,22 +92,19 @@ */ static int FileMatchPPM( Tcl_Channel chan, /* The image file, open for reading. */ - const char *fileName, /* The name of the image file. */ - Tcl_Obj *format, /* User-specified format string, or NULL. */ + TCL_UNUSED(const char *), /* The name of the image file. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw PPM * file. */ - Tcl_Interp *interp) /* unused */ + TCL_UNUSED(Tcl_Interp *)) /* unused */ { int dummy; - (void)fileName; - (void)format; - (void)interp; return ReadPPMFileHeader(chan, widthPtr, heightPtr, &dummy); } /* @@ -132,11 +129,11 @@ static int FileReadPPM( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tcl_Channel chan, /* The image file, open for reading. */ const char *fileName, /* The name of the image file. */ - Tcl_Obj *format, /* User-specified format string, or NULL. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */ Tk_PhotoHandle imageHandle, /* The photo image to write into. */ int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ int width, int height, /* Dimensions of block of photo image to be * written to. */ @@ -146,11 +143,10 @@ int fileWidth, fileHeight, maxIntensity; int nLines, h, type, bytesPerChannel = 1; size_t nBytes, count; unsigned char *pixelPtr; Tk_PhotoImageBlock block; - (void)format; type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity); if (type == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read raw PPM header from file \"%s\"", fileName)); @@ -203,11 +199,11 @@ destX + width, destY + height) != TCL_OK) { return TCL_ERROR; } if (srcY > 0) { - Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR); + Tcl_Seek(chan, (long long)srcY * block.pitch, SEEK_CUR); } nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch; if (nLines > height) { nLines = height; @@ -284,19 +280,18 @@ static int FileWritePPM( Tcl_Interp *interp, const char *fileName, - Tcl_Obj *format, + TCL_UNUSED(Tcl_Obj *), Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan; int w, h, greenOffset, blueOffset; size_t nBytes; unsigned char *pixelPtr, *pixLinePtr; char header[16 + TCL_INTEGER_SPACE * 2]; - (void)format; chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666); if (chan == NULL) { return TCL_ERROR; } @@ -373,18 +368,17 @@ */ static int StringWritePPM( Tcl_Interp *interp, - Tcl_Obj *format, + TCL_UNUSED(Tcl_Obj *), Tk_PhotoImageBlock *blockPtr) { int w, h, size, greenOffset, blueOffset; unsigned char *pixLinePtr, *byteArray; char header[16 + TCL_INTEGER_SPACE * 2]; Tcl_Obj *byteArrayObj; - (void)format; sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); /* * Construct a byte array of the right size with the header and @@ -450,20 +444,18 @@ */ static int StringMatchPPM( Tcl_Obj *dataObj, /* The image data. */ - Tcl_Obj *format, /* User-specified format string, or NULL. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw PPM * file. */ - Tcl_Interp *interp) /* unused */ + TCL_UNUSED(Tcl_Interp *)) /* unused */ { int dummy; - (void)format; - (void)interp; return ReadPPMStringHeader(dataObj, widthPtr, heightPtr, &dummy, NULL, NULL); } @@ -487,11 +479,11 @@ static int StringReadPPM( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tcl_Obj *dataObj, /* The image data. */ - Tcl_Obj *format, /* User-specified format string, or NULL. */ + TCL_UNUSED(Tcl_Obj *), /* User-specified format string, or NULL. */ Tk_PhotoHandle imageHandle, /* The photo image to write into. */ int destX, int destY, /* Coordinates of top-left pixel in photo * image to be written to. */ int width, int height, /* Dimensions of block of photo image to be * written to. */ @@ -500,11 +492,10 @@ { int fileWidth, fileHeight, maxIntensity; int nLines, nBytes, h, type, count, dataSize, bytesPerChannel = 1; unsigned char *pixelPtr, *dataBuffer; Tk_PhotoImageBlock block; - (void)format; type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight, &maxIntensity, &dataBuffer, &dataSize); if (type == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -609,11 +600,10 @@ if (maxIntensity < 0x00ff) { for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) { *p = (((int) *dataBuffer) * 255)/maxIntensity; } } else { - unsigned char *p; unsigned int value; for (p = pixelPtr,count=nBytes; count > 1; count-=2, p += 2) { value = ((unsigned int) p[0]) * 256 + ((unsigned int) p[1]); value = value * 255 / maxIntensity; @@ -775,11 +765,11 @@ char buffer[BUFFER_SIZE], c; int i, numFields, type = 0; TkSizeT dataSize; unsigned char *dataBuffer; - dataBuffer = TkGetByteArrayFromObj(dataPtr, &dataSize); + dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); /* * Read 4 space-separated fields from the string, ignoring comments (any * line that starts with "#"). */ Index: generic/tkImgPhInstance.c ================================================================== --- generic/tkImgPhInstance.c +++ generic/tkImgPhInstance.c @@ -3,14 +3,14 @@ * * Implements the rendering of images of type "photo" for Tk. Photo * images are stored in full color (32 bits per pixel including alpha * channel) and displayed using dithering if necessary. * - * Copyright (c) 1994 The Australian National University. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2002-2008 Donal K. Fellows - * Copyright (c) 2003 ActiveState Corporation. + * Copyright © 1994 The Australian National University. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2002-2008 Donal K. Fellows + * Copyright © 2003 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Author: Paul Mackerras (paulus@cs.anu.edu.au), @@ -17,13 +17,11 @@ * Department of Computer Science, * Australian National University. */ #include "tkImgPhoto.h" -#ifdef MAC_OSX_TK -#define TKPUTIMAGE_CAN_BLEND -#endif +#include "tkPort.h" /* * Declaration for internal Xlib function used here: */ #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TK) @@ -44,11 +42,11 @@ static void BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr, int xOffset, int yOffset, int width, int height); #endif static int IsValidPalette(PhotoInstance *instancePtr, const char *palette); -static int CountBits(pixel mask); +static int CountBits(unsigned mask); static void GetColorTable(PhotoInstance *instancePtr); static void FreeColorTable(ColorTable *colorPtr, int force); static void AllocateColors(ColorTable *colorPtr); static void DisposeColorTable(ClientData clientData); static int ReclaimColors(ColorTableId *id, int numColors); @@ -66,12 +64,12 @@ *---------------------------------------------------------------------- * * TkImgPhotoConfigureInstance -- * * This function is called to create displaying information for a photo - * image instance based on the configuration information in the master. - * It is invoked both when new instances are created and when the master + * image instance based on the configuration information in the model. + * It is invoked both when new instances are created and when the model * is reconfigured. * * Results: * None. * @@ -84,29 +82,29 @@ void TkImgPhotoConfigureInstance( PhotoInstance *instancePtr) /* Instance to reconfigure. */ { - PhotoMaster *masterPtr = instancePtr->masterPtr; + PhotoModel *modelPtr = instancePtr->modelPtr; XImage *imagePtr; int bitsPerPixel; ColorTable *colorTablePtr; XRectangle validBox; /* - * If the -palette configuration option has been set for the master, use + * If the -palette configuration option has been set for the model, use * the value specified for our palette, but only if it is a valid palette - * for our windows. Use the gamma value specified the master. + * for our windows. Use the gamma value specified the model. */ - if ((masterPtr->palette && masterPtr->palette[0]) - && IsValidPalette(instancePtr, masterPtr->palette)) { - instancePtr->palette = masterPtr->palette; + if ((modelPtr->palette && modelPtr->palette[0]) + && IsValidPalette(instancePtr, modelPtr->palette)) { + instancePtr->palette = modelPtr->palette; } else { instancePtr->palette = instancePtr->defaultPalette; } - instancePtr->gamma = masterPtr->gamma; + instancePtr->gamma = modelPtr->gamma; /* * If we don't currently have a color table, or if the one we have no * longer applies (e.g. because our palette or gamma has changed), get a * new one. @@ -166,29 +164,29 @@ } } } /* - * If the user has specified a width and/or height for the master which is + * If the user has specified a width and/or height for the model which is * different from our current width/height, set the size to the values * specified by the user. If we have no pixmap, we do this also, since it * has the side effect of allocating a pixmap for us. */ if ((instancePtr->pixels == None) || (instancePtr->error == NULL) - || (instancePtr->width != masterPtr->width) - || (instancePtr->height != masterPtr->height)) { + || (instancePtr->width != modelPtr->width) + || (instancePtr->height != modelPtr->height)) { TkImgPhotoInstanceSetSize(instancePtr); } /* * Redither this instance if necessary. */ - if ((masterPtr->flags & IMAGE_CHANGED) + if ((modelPtr->flags & IMAGE_CHANGED) || (instancePtr->colorTablePtr != colorTablePtr)) { - TkClipBox(masterPtr->validRegion, &validBox); + TkClipBox(modelPtr->validRegion, &validBox); if ((validBox.width > 0) && (validBox.height > 0)) { TkImgDitherInstance(instancePtr, validBox.x, validBox.y, validBox.width, validBox.height); } } @@ -214,14 +212,14 @@ ClientData TkImgPhotoGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ - ClientData masterData) /* Pointer to our master structure for the + ClientData modelData) /* Pointer to our model structure for the * image. */ { - PhotoMaster *masterPtr = (PhotoMaster *)masterData; + PhotoModel *modelPtr = (PhotoModel *)modelData; PhotoInstance *instancePtr; Colormap colormap; int mono, nRed, nGreen, nBlue, numVisuals; XVisualInfo visualInfo, *visInfoPtr; char buf[TCL_INTEGER_SPACE * 3]; @@ -254,11 +252,11 @@ * See if there is already an instance for windows using the same * colormap. If so then just re-use it. */ colormap = Tk_Colormap(tkwin); - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { if ((colormap == instancePtr->colormap) && (Tk_Display(tkwin) == instancePtr->display)) { /* * Re-use this instance. @@ -284,11 +282,11 @@ * The image isn't already in use in a window with the same colormap. Make * a new instance of the image. */ instancePtr = (PhotoInstance *)ckalloc(sizeof(PhotoInstance)); - instancePtr->masterPtr = masterPtr; + instancePtr->modelPtr = modelPtr; instancePtr->display = Tk_Display(tkwin); instancePtr->colormap = Tk_Colormap(tkwin); Tk_PreserveColormap(instancePtr->display, instancePtr->colormap); instancePtr->refCount = 1; instancePtr->colorTablePtr = NULL; @@ -295,12 +293,12 @@ instancePtr->pixels = None; instancePtr->error = NULL; instancePtr->width = 0; instancePtr->height = 0; instancePtr->imagePtr = 0; - instancePtr->nextPtr = masterPtr->instancePtr; - masterPtr->instancePtr = instancePtr; + instancePtr->nextPtr = modelPtr->instancePtr; + modelPtr->instancePtr = instancePtr; /* * Obtain information about the visual and decide on the default palette. */ @@ -356,12 +354,12 @@ /* * Make a GC with background = black and foreground = white. */ - white = Tk_GetColor(masterPtr->interp, tkwin, "white"); - black = Tk_GetColor(masterPtr->interp, tkwin, "black"); + white = Tk_GetColor(modelPtr->interp, tkwin, "white"); + black = Tk_GetColor(modelPtr->interp, tkwin, "black"); gcValues.foreground = (white != NULL)? white->pixel: WhitePixelOfScreen(Tk_Screen(tkwin)); gcValues.background = (black != NULL)? black->pixel: BlackPixelOfScreen(Tk_Screen(tkwin)); Tk_FreeColor(white); @@ -380,12 +378,12 @@ /* * If this is the first instance, must set the size of the image. */ if (instancePtr->nextPtr == NULL) { - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, - masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, + modelPtr->width, modelPtr->height); } return instancePtr; } @@ -414,13 +412,10 @@ * whereas RGB15 is the correct version and works for 15bpp+, but it * slower, so it's only used for 15bpp+. * * Note that Win32 pre-defines those operations that we really need. * - * Note that on MacOS, if the background comes from a Retina display - * then it will be twice as wide and twice as high as the photoimage. - * *---------------------------------------------------------------------- */ #ifndef TKPUTIMAGE_CAN_BLEND #ifndef _WIN32 #define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift)) @@ -444,12 +439,12 @@ * draw. */ int width, int height) /* Width & height of image to draw. */ { int x, y, line; unsigned long pixel; - unsigned char r, g, b, alpha, unalpha, *masterPtr; - unsigned char *alphaAr = iPtr->masterPtr->pix32; + unsigned char r, g, b, alpha, unalpha, *modelPtr; + unsigned char *alphaAr = iPtr->modelPtr->pix32; /* * This blending is an integer version of the Source-Over compositing rule * (see Porter&Duff, "Compositing Digital Images", proceedings of SIGGRAPH * 1984) that has been hard-coded (for speed) to work with targetting a @@ -502,14 +497,14 @@ red_mlen = 8 - CountBits(red_mask >> red_shift); green_mlen = 8 - CountBits(green_mask >> green_shift); blue_mlen = 8 - CountBits(blue_mask >> blue_shift); for (y = 0; y < height; y++) { - line = (y + yOffset) * iPtr->masterPtr->width; + line = (y + yOffset) * iPtr->modelPtr->width; for (x = 0; x < width; x++) { - masterPtr = alphaAr + ((line + x + xOffset) * 4); - alpha = masterPtr[3]; + modelPtr = alphaAr + ((line + x + xOffset) * 4); + alpha = modelPtr[3]; /* * Ignore pixels that are fully transparent */ @@ -517,13 +512,13 @@ /* * We could perhaps be more efficient than XGetPixel for * 24 and 32 bit displays, but this seems "fast enough". */ - r = masterPtr[0]; - g = masterPtr[1]; - b = masterPtr[2]; + r = modelPtr[0]; + g = modelPtr[1]; + b = modelPtr[2]; if (alpha != 255) { /* * Only blend pixels that have some transparency */ @@ -545,14 +540,14 @@ return; } #endif /* !_WIN32 */ for (y = 0; y < height; y++) { - line = (y + yOffset) * iPtr->masterPtr->width; + line = (y + yOffset) * iPtr->modelPtr->width; for (x = 0; x < width; x++) { - masterPtr = alphaAr + ((line + x + xOffset) * 4); - alpha = masterPtr[3]; + modelPtr = alphaAr + ((line + x + xOffset) * 4); + alpha = modelPtr[3]; /* * Ignore pixels that are fully transparent */ @@ -560,13 +555,13 @@ /* * We could perhaps be more efficient than XGetPixel for 24 * and 32 bit displays, but this seems "fast enough". */ - r = masterPtr[0]; - g = masterPtr[1]; - b = masterPtr[2]; + r = modelPtr[0]; + g = modelPtr[1]; + b = modelPtr[2]; if (alpha != 255) { /* * Only blend pixels that have some transparency */ @@ -636,11 +631,11 @@ /* * If TkPutImage can handle RGBA Ximages directly there is * no need to call XGetImage or to do the Porter-Duff compositing by hand. */ - unsigned char *rgbaPixels = instancePtr->masterPtr->pix32; + unsigned char *rgbaPixels = instancePtr->modelPtr->pix32; XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels, (unsigned int)instancePtr->width, (unsigned int)instancePtr->height, 0, (unsigned int)(4 * instancePtr->width)); TkPutImage(NULL, 0, display, drawable, instancePtr->gc, @@ -648,11 +643,11 @@ (unsigned int) width, (unsigned int) height); photo->data = NULL; XDestroyImage(photo); #else - if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) + if ((instancePtr->modelPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) { Tk_ErrorHandler handler; XImage *bgImg = NULL; @@ -689,18 +684,18 @@ (unsigned int) width, (unsigned int) height); XDestroyImage(bgImg); Tk_DeleteErrorHandler(handler); } else { /* - * masterPtr->region describes which parts of the image contain valid + * modelPtr->region describes which parts of the image contain valid * data. We set this region as the clip mask for the gc, setting its * origin appropriately, and use it when drawing the image. */ fallBack: TkSetRegion(display, instancePtr->gc, - instancePtr->masterPtr->validRegion); + instancePtr->modelPtr->validRegion); XSetClipOrigin(display, instancePtr->gc, drawableX - imageX, drawableY - imageY); XCopyArea(display, instancePtr->pixels, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY); @@ -779,27 +774,27 @@ void TkImgPhotoInstanceSetSize( PhotoInstance *instancePtr) /* Instance whose size is to be changed. */ { - PhotoMaster *masterPtr; + PhotoModel *modelPtr; schar *newError, *errSrcPtr, *errDestPtr; int h, offset; XRectangle validBox; Pixmap newPixmap; - masterPtr = instancePtr->masterPtr; - TkClipBox(masterPtr->validRegion, &validBox); + modelPtr = instancePtr->modelPtr; + TkClipBox(modelPtr->validRegion, &validBox); - if ((instancePtr->width != masterPtr->width) - || (instancePtr->height != masterPtr->height) + if ((instancePtr->width != modelPtr->width) + || (instancePtr->height != modelPtr->height) || (instancePtr->pixels == None)) { newPixmap = Tk_GetPixmap(instancePtr->display, RootWindow(instancePtr->display, instancePtr->visualInfo.screen), - (masterPtr->width > 0) ? masterPtr->width: 1, - (masterPtr->height > 0) ? masterPtr->height: 1, + (modelPtr->width > 0) ? modelPtr->width: 1, + (modelPtr->height > 0) ? modelPtr->height: 1, instancePtr->visualInfo.depth); if (!newPixmap) { Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in TkImgPhotoInstanceSetSize"); } @@ -825,44 +820,44 @@ Tk_FreePixmap(instancePtr->display, instancePtr->pixels); } instancePtr->pixels = newPixmap; } - if ((instancePtr->width != masterPtr->width) - || (instancePtr->height != masterPtr->height) + if ((instancePtr->width != modelPtr->width) + || (instancePtr->height != modelPtr->height) || (instancePtr->error == NULL)) { - if (masterPtr->height > 0 && masterPtr->width > 0) { + if (modelPtr->height > 0 && modelPtr->width > 0) { /* * TODO: use attemptckalloc() here once there is a strategy that * will allow us to recover from failure. Right now, there's no * such possibility. */ - newError = (schar *)ckalloc(masterPtr->height * masterPtr->width + newError = (schar *)ckalloc(modelPtr->height * modelPtr->width * 3 * sizeof(schar)); /* * Zero the new array so that we don't get bogus error values * propagating into areas we dither later. */ if ((instancePtr->error != NULL) - && ((instancePtr->width == masterPtr->width) - || (validBox.width == masterPtr->width))) { + && ((instancePtr->width == modelPtr->width) + || (validBox.width == modelPtr->width))) { if (validBox.y > 0) { memset(newError, 0, (size_t) - validBox.y * masterPtr->width * 3 * sizeof(schar)); + validBox.y * modelPtr->width * 3 * sizeof(schar)); } h = validBox.y + validBox.height; - if (h < masterPtr->height) { - memset(newError + h*masterPtr->width*3, 0, - (size_t) (masterPtr->height - h) - * masterPtr->width * 3 * sizeof(schar)); + if (h < modelPtr->height) { + memset(newError + h*modelPtr->width*3, 0, + (size_t) (modelPtr->height - h) + * modelPtr->width * 3 * sizeof(schar)); } } else { memset(newError, 0, (size_t) - masterPtr->height * masterPtr->width *3*sizeof(schar)); + modelPtr->height * modelPtr->width *3*sizeof(schar)); } } else { newError = NULL; } @@ -870,37 +865,37 @@ /* * Copy the common area over to the new array and free the old * array. */ - if (masterPtr->width == instancePtr->width) { - offset = validBox.y * masterPtr->width * 3; + if (modelPtr->width == instancePtr->width) { + offset = validBox.y * modelPtr->width * 3; memcpy(newError + offset, instancePtr->error + offset, (size_t) validBox.height - * masterPtr->width * 3 * sizeof(schar)); + * modelPtr->width * 3 * sizeof(schar)); } else if (validBox.width > 0 && validBox.height > 0) { errDestPtr = newError + - (validBox.y * masterPtr->width + validBox.x) * 3; + (validBox.y * modelPtr->width + validBox.x) * 3; errSrcPtr = instancePtr->error + (validBox.y * instancePtr->width + validBox.x) * 3; for (h = validBox.height; h > 0; --h) { memcpy(errDestPtr, errSrcPtr, validBox.width * 3 * sizeof(schar)); - errDestPtr += masterPtr->width * 3; + errDestPtr += modelPtr->width * 3; errSrcPtr += instancePtr->width * 3; } } ckfree(instancePtr->error); } instancePtr->error = newError; } - instancePtr->width = masterPtr->width; - instancePtr->height = masterPtr->height; + instancePtr->width = modelPtr->width; + instancePtr->height = modelPtr->height; } /* *---------------------------------------------------------------------- * @@ -1002,11 +997,11 @@ *---------------------------------------------------------------------- */ static int CountBits( - pixel mask) /* Value to count the 1 bits in. */ + unsigned mask) /* Value to count the 1 bits in. */ { int n; for (n=0 ; mask!=0 ; mask&=mask-1) { n++; @@ -1608,14 +1603,14 @@ } if (instancePtr->colorTablePtr != NULL) { FreeColorTable(instancePtr->colorTablePtr, 1); } - if (instancePtr->masterPtr->instancePtr == instancePtr) { - instancePtr->masterPtr->instancePtr = instancePtr->nextPtr; + if (instancePtr->modelPtr->instancePtr == instancePtr) { + instancePtr->modelPtr->instancePtr = instancePtr->nextPtr; } else { - for (prevPtr = instancePtr->masterPtr->instancePtr; + for (prevPtr = instancePtr->modelPtr->instancePtr; prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body. */ } prevPtr->nextPtr = instancePtr->nextPtr; } @@ -1627,11 +1622,11 @@ *---------------------------------------------------------------------- * * TkImgDitherInstance -- * * This function is called to update an area of an instance's pixmap by - * dithering the corresponding area of the master. + * dithering the corresponding area of the model. * * Results: * None. * * Side effects: @@ -1645,18 +1640,18 @@ PhotoInstance *instancePtr, /* The instance to be updated. */ int xStart, int yStart, /* Coordinates of the top-left pixel in the * block to be dithered. */ int width, int height) /* Dimensions of the block to be dithered. */ { - PhotoMaster *masterPtr = instancePtr->masterPtr; + PhotoModel *modelPtr = instancePtr->modelPtr; ColorTable *colorPtr = instancePtr->colorTablePtr; XImage *imagePtr; int nLines, bigEndian, i, c, x, y, xEnd, doDithering = 1; int bitsPerPixel, bytesPerLine, lineLength; unsigned char *srcLinePtr; schar *errLinePtr; - pixel firstBit, word, mask; + unsigned firstBit, word, mask; /* * Turn dithering off in certain cases where it is not needed (TrueColor, * DirectColor with many colors). */ @@ -1703,12 +1698,12 @@ imagePtr->data = (char *)ckalloc(imagePtr->bytes_per_line * nLines); bigEndian = imagePtr->bitmap_bit_order == MSBFirst; firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1; - lineLength = masterPtr->width * 3; - srcLinePtr = masterPtr->pix32 + (yStart * masterPtr->width + xStart) * 4; + lineLength = modelPtr->width * 3; + srcLinePtr = modelPtr->pix32 + (yStart * modelPtr->width + xStart) * 4; errLinePtr = instancePtr->error + yStart * lineLength + xStart * 3; xEnd = xStart + width; /* * Loop over the image, doing at most nLines lines before updating the @@ -1725,11 +1720,11 @@ yEnd = yStart + nLines; for (y = yStart; y < yEnd; ++y) { unsigned char *srcPtr = srcLinePtr; schar *errPtr = errLinePtr; unsigned char *destBytePtr = dstLinePtr; - pixel *destLongPtr = (pixel *) dstLinePtr; + unsigned *destLongPtr = (unsigned *) dstLinePtr; if (colorPtr->flags & COLOR_WINDOW) { /* * Color window. We dither the three components independently, * using Floyd-Steinberg dithering, which propagates errors @@ -1759,11 +1754,11 @@ if (y > 0) { if (x > 0) { c += errPtr[-lineLength-3]; } c += errPtr[-lineLength] * 5; - if ((x + 1) < masterPtr->width) { + if ((x + 1) < modelPtr->width) { c += errPtr[-lineLength+3] * 3; } } /* @@ -1816,11 +1811,11 @@ * Tk to use the Windows native image ordering. This * would speed up the image code for all of the common * sizes. */ - case NBBY * sizeof(pixel): + case NBBY * sizeof(unsigned): *destLongPtr++ = i; break; #endif default: XPutPixel(imagePtr, x - xStart, y - yStart, @@ -1830,11 +1825,11 @@ } else if (bitsPerPixel > 1) { /* * Multibit monochrome window. The operation here is similar * to the color window case above, except that there is only - * one component. If the master image is in color, use the + * one component. If the model image is in color, use the * luminance computed as * 0.344 * red + 0.5 * green + 0.156 * blue. */ for (x = xStart; x < xEnd; ++x) { @@ -1842,17 +1837,17 @@ if (y > 0) { if (x > 0) { c += errPtr[-lineLength-1]; } c += errPtr[-lineLength] * 5; - if (x + 1 < masterPtr->width) { + if (x + 1 < modelPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; - if (masterPtr->flags & COLOR_IMAGE) { + if (modelPtr->flags & COLOR_IMAGE) { c += (unsigned) (srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; } else { c += srcPtr[0]; } @@ -1878,11 +1873,11 @@ * Tk to use the Windows native image ordering. This * would speed up the image code for all of the common * sizes. */ - case NBBY * sizeof(pixel): + case NBBY * sizeof(unsigned): *destLongPtr++ = i; break; #endif default: XPutPixel(imagePtr, x - xStart, y - yStart, @@ -1915,17 +1910,17 @@ if (y > 0) { if (x > 0) { c += errPtr[-lineLength-1]; } c += errPtr[-lineLength] * 5; - if (x + 1 < masterPtr->width) { + if (x + 1 < modelPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; - if (masterPtr->flags & COLOR_IMAGE) { + if (modelPtr->flags & COLOR_IMAGE) { c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; } else { c += srcPtr[0]; } @@ -1944,11 +1939,11 @@ } mask = bigEndian? (mask >> 1): (mask << 1); } *destLongPtr = word; } - srcLinePtr += masterPtr->width * 4; + srcLinePtr += modelPtr->width * 4; errLinePtr += lineLength; dstLinePtr += bytesPerLine; } /* @@ -1988,12 +1983,12 @@ TkImgResetDither( PhotoInstance *instancePtr) { if (instancePtr->error) { memset(instancePtr->error, 0, - (size_t) instancePtr->masterPtr->width - * instancePtr->masterPtr->height * 3 * sizeof(schar)); + (size_t) instancePtr->modelPtr->width + * instancePtr->modelPtr->height * 3 * sizeof(schar)); } } /* * Local Variables: Index: generic/tkImgPhoto.c ================================================================== --- generic/tkImgPhoto.c +++ generic/tkImgPhoto.c @@ -3,14 +3,14 @@ * * Implements images of type "photo" for Tk. Photo images are stored in * full color (32 bits per pixel including alpha channel) and displayed * using dithering if necessary. * - * Copyright (c) 1994 The Australian National University. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2002-2003 Donal K. Fellows - * Copyright (c) 2003 ActiveState Corporation. + * Copyright © 1994 The Australian National University. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2002-2003 Donal K. Fellows + * Copyright © 2003 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Author: Paul Mackerras (paulus@cs.anu.edu.au), @@ -109,11 +109,11 @@ * Functions used in the type record for photo images. */ static int ImgPhotoCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], - const Tk_ImageType *typePtr, Tk_ImageMaster master, + const Tk_ImageType *typePtr, Tk_ImageModel model, ClientData *clientDataPtr); static void ImgPhotoDelete(ClientData clientData); static int ImgPhotoPostscript(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, int x, int y, int width, @@ -165,19 +165,19 @@ * Information used for parsing configuration specifications: */ static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_STRING, "-file", NULL, NULL, - NULL, offsetof(PhotoMaster, fileString), TK_CONFIG_NULL_OK, NULL}, + NULL, offsetof(PhotoModel, fileString), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_DOUBLE, "-gamma", NULL, NULL, - DEF_PHOTO_GAMMA, offsetof(PhotoMaster, gamma), 0, NULL}, + DEF_PHOTO_GAMMA, offsetof(PhotoModel, gamma), 0, NULL}, {TK_CONFIG_INT, "-height", NULL, NULL, - DEF_PHOTO_HEIGHT, offsetof(PhotoMaster, userHeight), 0, NULL}, + DEF_PHOTO_HEIGHT, offsetof(PhotoModel, userHeight), 0, NULL}, {TK_CONFIG_UID, "-palette", NULL, NULL, - DEF_PHOTO_PALETTE, offsetof(PhotoMaster, palette), 0, NULL}, + DEF_PHOTO_PALETTE, offsetof(PhotoModel, palette), 0, NULL}, {TK_CONFIG_INT, "-width", NULL, NULL, - DEF_PHOTO_WIDTH, offsetof(PhotoMaster, userWidth), 0, NULL}, + DEF_PHOTO_WIDTH, offsetof(PhotoModel, userWidth), 0, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; /* * Forward declarations @@ -189,17 +189,17 @@ static int ParseSubcommandOptions( struct SubcommandOptions *optPtr, Tcl_Interp *interp, int allowedOptions, int *indexPtr, int objc, Tcl_Obj *const objv[]); static void ImgPhotoCmdDeletedProc(ClientData clientData); -static int ImgPhotoConfigureMaster(Tcl_Interp *interp, - PhotoMaster *masterPtr, int objc, +static int ImgPhotoConfigureModel(Tcl_Interp *interp, + PhotoModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); -static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr); -static int ImgPhotoSetSize(PhotoMaster *masterPtr, int width, +static int ToggleComplexAlphaIfNeeded(PhotoModel *mPtr); +static int ImgPhotoSetSize(PhotoModel *modelPtr, int width, int height); -static char * ImgGetPhoto(PhotoMaster *masterPtr, +static char * ImgGetPhoto(PhotoModel *modelPtr, Tk_PhotoImageBlock *blockPtr, struct SubcommandOptions *optPtr); static int MatchFileFormat(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *formatString, Tcl_Obj *metadataInObj, @@ -388,42 +388,42 @@ const char *name, /* Name to use for image. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[], /* Argument objects for options (doesn't * include image name or type). */ TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */ - Tk_ImageMaster master, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - PhotoMaster *masterPtr; + PhotoModel *modelPtr; /* - * Allocate and initialize the photo image master record. + * Allocate and initialize the photo image model record. */ - masterPtr = (PhotoMaster *)ckalloc(sizeof(PhotoMaster)); - memset(masterPtr, 0, sizeof(PhotoMaster)); - masterPtr->tkMaster = master; - masterPtr->interp = interp; - masterPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgPhotoCmd, - masterPtr, ImgPhotoCmdDeletedProc); - masterPtr->palette = NULL; - masterPtr->pix32 = NULL; - masterPtr->instancePtr = NULL; - masterPtr->validRegion = TkCreateRegion(); + modelPtr = (PhotoModel *)ckalloc(sizeof(PhotoModel)); + memset(modelPtr, 0, sizeof(PhotoModel)); + modelPtr->tkModel = model; + modelPtr->interp = interp; + modelPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgPhotoCmd, + modelPtr, ImgPhotoCmdDeletedProc); + modelPtr->palette = NULL; + modelPtr->pix32 = NULL; + modelPtr->instancePtr = NULL; + modelPtr->validRegion = TkCreateRegion(); /* * Process configuration options given in the image create command. */ - if (ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, 0) != TCL_OK) { - ImgPhotoDelete(masterPtr); + if (ImgPhotoConfigureModel(interp, modelPtr, objc, objv, 0) != TCL_OK) { + ImgPhotoDelete(modelPtr); return TCL_ERROR; } - *clientDataPtr = masterPtr; + *clientDataPtr = modelPtr; return TCL_OK; } /* *---------------------------------------------------------------------- @@ -443,11 +443,11 @@ *---------------------------------------------------------------------- */ static int ImgPhotoCmd( - ClientData clientData, /* Information about photo master. */ + ClientData clientData, /* Information about photo model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const photoOptions[] = { @@ -458,11 +458,11 @@ PHOTO_BLANK, PHOTO_CGET, PHOTO_CONFIGURE, PHOTO_COPY, PHOTO_DATA, PHOTO_GET, PHOTO_PUT, PHOTO_READ, PHOTO_REDITHER, PHOTO_TRANS, PHOTO_WRITE }; - PhotoMaster *masterPtr = (PhotoMaster *)clientData; + PhotoModel *modelPtr = (PhotoModel *)clientData; int result, index, x, y, width, height; struct SubcommandOptions options; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_PhotoImageFormat *imageFormat; @@ -489,11 +489,11 @@ /* * photo blank command - just call Tk_PhotoBlank. */ if (objc == 2) { - Tk_PhotoBlank(masterPtr); + Tk_PhotoBlank(modelPtr); return TCL_OK; } else { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } @@ -503,26 +503,26 @@ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } - arg = TkGetStringFromObj(objv[2], &length); + arg = Tcl_GetStringFromObj(objv[2], &length); if (strncmp(arg,"-data", length) == 0) { - if (masterPtr->dataString) { - Tcl_SetObjResult(interp, masterPtr->dataString); + if (modelPtr->dataString) { + Tcl_SetObjResult(interp, modelPtr->dataString); } } else if (strncmp(arg,"-format", length) == 0) { - if (masterPtr->format) { - Tcl_SetObjResult(interp, masterPtr->format); + if (modelPtr->format) { + Tcl_SetObjResult(interp, modelPtr->format); } } else if (strncmp(arg, "-metadata", length) == 0) { - if (masterPtr->metadata) { - Tcl_SetObjResult(interp, masterPtr->metadata); + if (modelPtr->metadata) { + Tcl_SetObjResult(interp, modelPtr->metadata); } } else { Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) masterPtr, Tcl_GetString(objv[2]), 0); + (char *) modelPtr, Tcl_GetString(objv[2]), 0); } return TCL_OK; } case PHOTO_CONFIGURE: @@ -532,90 +532,90 @@ if (objc == 2) { Tcl_Obj *obj, *subobj; result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, NULL, 0); + configSpecs, (char *) modelPtr, NULL, 0); if (result != TCL_OK) { return result; } obj = Tcl_NewObj(); subobj = Tcl_NewStringObj("-data {} {} {}", 14); - if (masterPtr->dataString) { - Tcl_ListObjAppendElement(NULL, subobj, masterPtr->dataString); + if (modelPtr->dataString) { + Tcl_ListObjAppendElement(NULL, subobj, modelPtr->dataString); } else { Tcl_AppendStringsToObj(subobj, " {}", NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); - if (masterPtr->format) { - Tcl_ListObjAppendElement(NULL, subobj, masterPtr->format); + if (modelPtr->format) { + Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format); } else { Tcl_AppendStringsToObj(subobj, " {}", NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-metadata {} {} {}", 16); - if (masterPtr->metadata) { - Tcl_ListObjAppendElement(NULL, subobj, masterPtr->metadata); + if (modelPtr->metadata) { + Tcl_ListObjAppendElement(NULL, subobj, modelPtr->metadata); } else { Tcl_AppendStringsToObj(subobj, " {}", NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp)); Tcl_SetObjResult(interp, obj); return TCL_OK; } else if (objc == 3) { - const char *arg = TkGetStringFromObj(objv[2], &length); + const char *arg = Tcl_GetStringFromObj(objv[2], &length); if (length > 1 && !strncmp(arg, "-data", length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); - if (masterPtr->dataString) { + if (modelPtr->dataString) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), - masterPtr->dataString); + modelPtr->dataString); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-format", length)) { Tcl_AppendResult(interp, "-format {} {} {}", NULL); - if (masterPtr->format) { + if (modelPtr->format) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), - masterPtr->format); + modelPtr->format); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-metadata", length)) { Tcl_AppendResult(interp, "-metadata {} {} {}", NULL); - if (masterPtr->metadata) { + if (modelPtr->metadata) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), - masterPtr->metadata); + modelPtr->metadata); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, arg, 0); + configSpecs, (char *) modelPtr, arg, 0); } } else { - return ImgPhotoConfigureMaster(interp, masterPtr, objc-2, objv+2, + return ImgPhotoConfigureModel(interp, modelPtr, objc-2, objv+2, TK_CONFIG_ARGV_ONLY); } case PHOTO_COPY: /* @@ -670,11 +670,11 @@ /* * Hack to pass through the message that the place we're coming from * has a simple alpha channel. */ - if (!(((PhotoMaster *) srcHandle)->flags & COMPLEX_ALPHA)) { + if (!(((PhotoModel *) srcHandle)->flags & COMPLEX_ALPHA)) { options.compositingRule |= SOURCE_IS_SIMPLE_ALPHA_PHOTO; } /* * Fill in default values for unspecified parameters. @@ -714,11 +714,11 @@ block.pixelPtr += options.fromX * block.pixelSize + options.fromY * block.pitch; block.width = options.fromX2 - options.fromX; block.height = options.fromY2 - options.fromY; - result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) masterPtr, + result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) modelPtr, &block, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, options.zoomX, options.zoomY, options.subsampleX, options.subsampleY, options.compositingRule); @@ -728,11 +728,11 @@ * and destination are the same image, block.pixelPtr would point to * an invalid memory block (bug [5239fd749b]). */ if (options.options & OPT_SHRINK) { - if (ImgPhotoSetSize(masterPtr, options.toX2, + if (ImgPhotoSetSize(modelPtr, options.toX2, options.toY2) != TCL_OK) { if (options.background) { Tk_FreeColor(options.background); } Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -739,12 +739,12 @@ TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } } - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, - masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, + modelPtr->width, modelPtr->height); if (options.background) { Tk_FreeColor(options.background); } return result; @@ -775,14 +775,14 @@ } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?"); return TCL_ERROR; } - if ((options.fromX > masterPtr->width) - || (options.fromY > masterPtr->height) - || (options.fromX2 > masterPtr->width) - || (options.fromY2 > masterPtr->height)) { + if ((options.fromX > modelPtr->width) + || (options.fromY > modelPtr->height) + || (options.fromX2 > modelPtr->width) + || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } @@ -790,12 +790,12 @@ /* * Fill in default values for unspecified parameters. */ if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { - options.fromX2 = masterPtr->width; - options.fromY2 = masterPtr->height; + options.fromX2 = modelPtr->width; + options.fromY2 = modelPtr->height; } if (!(options.options & OPT_FORMAT)) { options.format = Tcl_NewStringObj("default", -1); freeObj = options.format; } @@ -805,11 +805,11 @@ */ if (NULL != options.metadata) { metadataIn = options.metadata; } else { - metadataIn = masterPtr->metadata; + metadataIn = modelPtr->metadata; } /* * Search for an appropriate image string format handler. */ @@ -872,11 +872,11 @@ /* * Call the handler's string write function to write out the image. */ - data = ImgGetPhoto(masterPtr, &block, &options); + data = ImgGetPhoto(modelPtr, &block, &options); if (stringWriteProc == NULL) { result = (stringWriteProcVersion3)(interp, options.format, metadataIn, &block); } else if (oldformat) { @@ -950,12 +950,12 @@ if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { return TCL_ERROR; } - if ((x < 0) || (x >= masterPtr->width) - || (y < 0) || (y >= masterPtr->height)) { + if ((x < 0) || (x >= modelPtr->width) + || (y < 0) || (y >= modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); @@ -964,11 +964,11 @@ /* * Extract the value of the desired pixel and format it as a list. */ - pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; channels[0] = Tcl_NewWideIntObj(pixelPtr[0]); channels[1] = Tcl_NewWideIntObj(pixelPtr[1]); channels[2] = Tcl_NewWideIntObj(pixelPtr[2]); channels[3] = Tcl_NewWideIntObj(pixelPtr[3]); Tcl_SetObjResult(interp, Tcl_NewListObj(channelCount, channels)); @@ -1027,19 +1027,19 @@ data = (Tcl_Obj *) Tcl_GetString(data); } if (imageFormat != NULL) { if (imageFormat->stringReadProc(interp, data, format, - (Tk_PhotoHandle) masterPtr, options.toX, options.toY, + (Tk_PhotoHandle) modelPtr, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, 0, 0) != TCL_OK) { return TCL_ERROR; } } else { if (imageFormatVersion3->stringReadProc(interp, data, format, options.metadata, - (Tk_PhotoHandle) masterPtr, options.toX, options.toY, + (Tk_PhotoHandle) modelPtr, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, 0, 0, NULL) != TCL_OK) { return TCL_ERROR; @@ -1050,11 +1050,11 @@ * SB: is the next line really needed? The stringReadProc * writes image data with Tk_PhotoPutBlock(), which in turn * takes care to notify the changed image and to set/unset the * IMAGE_CHANGED bit. */ - masterPtr->flags |= IMAGE_CHANGED; + modelPtr->flags |= IMAGE_CHANGED; return TCL_OK; } case PHOTO_READ: { Tcl_Obj *format; @@ -1144,11 +1144,11 @@ /* * If the -shrink option was specified, set the size of the image. */ if (options.options & OPT_SHRINK) { - if (ImgPhotoSetSize(masterPtr, options.toX + width, + if (ImgPhotoSetSize(modelPtr, options.toX + width, options.toY + height) != TCL_OK) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); @@ -1167,16 +1167,16 @@ format = (Tcl_Obj *) Tcl_GetString(format); } if (imageFormat != NULL) { result = imageFormat->fileReadProc(interp, chan, Tcl_GetString(options.name), - format, (Tk_PhotoHandle) masterPtr, options.toX, + format, (Tk_PhotoHandle) modelPtr, options.toX, options.toY, width, height, options.fromX, options.fromY); } else { result = imageFormatVersion3->fileReadProc(interp, chan, Tcl_GetString(options.name), - format, options.metadata, (Tk_PhotoHandle) masterPtr, + format, options.metadata, (Tk_PhotoHandle) modelPtr, options.toX, options.toY, width, height, options.fromX, options.fromY, NULL); } readCleanup: if (chan != NULL) { @@ -1194,31 +1194,31 @@ /* * Call Dither if any part of the image is not correctly dithered at * present. */ - x = masterPtr->ditherX; - y = masterPtr->ditherY; - if (masterPtr->ditherX != 0) { - Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y, - masterPtr->width - x, 1); + x = modelPtr->ditherX; + y = modelPtr->ditherY; + if (modelPtr->ditherX != 0) { + Tk_DitherPhoto((Tk_PhotoHandle) modelPtr, x, y, + modelPtr->width - x, 1); } - if (masterPtr->ditherY < masterPtr->height) { + if (modelPtr->ditherY < modelPtr->height) { x = 0; - Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, 0, - masterPtr->ditherY, masterPtr->width, - masterPtr->height - masterPtr->ditherY); + Tk_DitherPhoto((Tk_PhotoHandle)modelPtr, 0, + modelPtr->ditherY, modelPtr->width, + modelPtr->height - modelPtr->ditherY); } - if (y < masterPtr->height) { + if (y < modelPtr->height) { /* * Tell the core image code that part of the image has changed. */ - Tk_ImageChanged(masterPtr->tkMaster, x, y, - (masterPtr->width - x), (masterPtr->height - y), - masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, x, y, + (modelPtr->width - x), (modelPtr->height - y), + modelPtr->width, modelPtr->height); } return TCL_OK; case PHOTO_TRANS: { static const char *const photoTransOptions[] = { @@ -1271,12 +1271,12 @@ boolMode = 1; if (options.options & OPT_ALPHA) { boolMode = 0; } - if ((x < 0) || (x >= masterPtr->width) - || (y < 0) || (y >= masterPtr->height)) { + if ((x < 0) || (x >= modelPtr->width) + || (y < 0) || (y >= modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s transparency get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); @@ -1284,11 +1284,11 @@ } /* * Extract and return the desired value */ - pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; if (boolMode) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( ! pixelPtr[3])); } else { Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pixelPtr[3])); } @@ -1330,12 +1330,12 @@ boolMode = 1; if (options.options & OPT_ALPHA) { boolMode = 0; } - if ((x < 0) || (x >= masterPtr->width) - || (y < 0) || (y >= masterPtr->height)) { + if ((x < 0) || (x >= modelPtr->width) + || (y < 0) || (y >= modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s transparency set: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); @@ -1362,11 +1362,11 @@ /* * Set new alpha value for the pixel */ - pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; if (boolMode) { pixelPtr[3] = newVal ? 0 : 255; } else { pixelPtr[3] = newVal; } @@ -1380,26 +1380,26 @@ setBox.width = 1; setBox.height = 1; modRegion = TkCreateRegion(); TkUnionRectWithRegion(&setBox, modRegion, modRegion); if (pixelPtr[3]) { - TkUnionRectWithRegion(&setBox, masterPtr->validRegion, - masterPtr->validRegion); + TkUnionRectWithRegion(&setBox, modelPtr->validRegion, + modelPtr->validRegion); } else { - TkSubtractRegion(masterPtr->validRegion, modRegion, - masterPtr->validRegion); + TkSubtractRegion(modelPtr->validRegion, modRegion, + modelPtr->validRegion); } TkDestroyRegion(modRegion); /* * Inform the generic image code that the image * has (potentially) changed. */ - Tk_ImageChanged(masterPtr->tkMaster, x, y, 1, 1, - masterPtr->width, masterPtr->height); - masterPtr->flags &= ~IMAGE_CHANGED; + Tk_ImageChanged(modelPtr->tkModel, x, y, 1, 1, + modelPtr->width, modelPtr->height); + modelPtr->flags &= ~IMAGE_CHANGED; return TCL_OK; } } Tcl_Panic("unexpected fallthrough"); @@ -1439,14 +1439,14 @@ } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?"); return TCL_ERROR; } - if ((options.fromX > masterPtr->width) - || (options.fromY > masterPtr->height) - || (options.fromX2 > masterPtr->width) - || (options.fromY2 > masterPtr->height)) { + if ((options.fromX > modelPtr->width) + || (options.fromY > modelPtr->height) + || (options.fromX2 > modelPtr->width) + || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } @@ -1456,12 +1456,12 @@ * missing -format flag results in us having a guess from the file * extension. [Bug 2983824] */ if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { - options.fromX2 = masterPtr->width; - options.fromY2 = masterPtr->height; + options.fromX2 = modelPtr->width; + options.fromY2 = modelPtr->height; } if (options.format == NULL) { fmtString = GetExtension(Tcl_GetString(options.name)); usedExt = (fmtString != NULL); } else { @@ -1475,11 +1475,11 @@ */ if (NULL != options.metadata) { metadataIn = options.metadata; } else { - metadataIn = masterPtr->metadata; + metadataIn = modelPtr->metadata; } /* * Search for an appropriate image file format handler, and give an * error if none is found. @@ -1561,11 +1561,11 @@ /* * Call the handler's file write function to write out the image. */ - data = ImgGetPhoto(masterPtr, &block, &options); + data = ImgGetPhoto(modelPtr, &block, &options); format = options.format; if (oldformat && format) { format = (Tcl_Obj *) Tcl_GetString(options.format); } if (imageFormat != NULL) { @@ -1673,11 +1673,11 @@ /* * We can have one value specified without an option; it goes into * optPtr->name. */ - expandedOption = option = TkGetStringFromObj(objv[index], &length); + expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; continue; } @@ -1922,31 +1922,31 @@ } /* *---------------------------------------------------------------------- * - * ImgPhotoConfigureMaster -- + * ImgPhotoConfigureModel -- * * This function is called when a photo image is created or reconfigured. * It processes configuration options and resets any instances of the * image. * * Results: * A standard Tcl return value. If TCL_ERROR is returned then an error - * message is left in the masterPtr->interp's result. + * message is left in the modelPtr->interp's result. * * Side effects: * Existing instances of the image will be redisplayed to match the new * configuration options. * *---------------------------------------------------------------------- */ static int -ImgPhotoConfigureMaster( +ImgPhotoConfigureModel( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ - PhotoMaster *masterPtr, /* Pointer to data structure describing + PhotoModel *modelPtr, /* Pointer to data structure describing * overall photo image to (re)configure. */ int objc, /* Number of entries in objv. */ Tcl_Obj *const objv[], /* Pairs of configuration options for image. */ int flags) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ @@ -1964,11 +1964,11 @@ Tk_PhotoImageFormatVersion3 *imageFormatVersion3; const char **args; args = (const char **)ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { - args[j] = TkGetStringFromObj(objv[i], &length); + args[j] = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (args[j][0] == '-')) { if ((args[j][1] == 'd') && !strncmp(args[j], "-data", length)) { if (++i < objc) { data = objv[i]; @@ -2016,62 +2016,62 @@ * if the user specifies them anew. IMPORTANT: if the format changes we * have to interpret "-file" and "-data" again as well! It might be that * the format string influences how "-data" or "-file" is interpreted. */ - oldFileString = masterPtr->fileString; + oldFileString = modelPtr->fileString; if (oldFileString == NULL) { - oldData = masterPtr->dataString; + oldData = modelPtr->dataString; if (oldData != NULL) { Tcl_IncrRefCount(oldData); } } else { oldData = NULL; } - oldFormat = masterPtr->format; + oldFormat = modelPtr->format; if (oldFormat != NULL) { Tcl_IncrRefCount(oldFormat); } - oldPaletteString = masterPtr->palette; - oldGamma = masterPtr->gamma; + oldPaletteString = modelPtr->palette; + oldGamma = modelPtr->gamma; /* * Process the configuration options specified. */ if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs, - j, args, (char *) masterPtr, flags) != TCL_OK) { + j, args, (char *) modelPtr, flags) != TCL_OK) { ckfree(args); goto errorExit; } ckfree(args); /* * Regard the empty string for -file, -data, -format or -metadata as the null value. */ - if ((masterPtr->fileString != NULL) && (masterPtr->fileString[0] == 0)) { - ckfree(masterPtr->fileString); - masterPtr->fileString = NULL; + if ((modelPtr->fileString != NULL) && (modelPtr->fileString[0] == 0)) { + ckfree(modelPtr->fileString); + modelPtr->fileString = NULL; } if (data) { /* * Force into ByteArray format, which most (all) image handlers will * use anyway. Empty length means ignore the -data option. */ TkSizeT bytesize; - (void) TkGetByteArrayFromObj(data, &bytesize); + (void) Tcl_GetByteArrayFromObj(data, &bytesize); if (bytesize) { Tcl_IncrRefCount(data); } else { data = NULL; } - if (masterPtr->dataString) { - Tcl_DecrRefCount(masterPtr->dataString); + if (modelPtr->dataString) { + Tcl_DecrRefCount(modelPtr->dataString); } - masterPtr->dataString = data; + modelPtr->dataString = data; } if (format) { /* * Stringify to ignore -format "". It may come in as a list or other * object. @@ -2081,18 +2081,18 @@ if (format->length) { Tcl_IncrRefCount(format); } else { format = NULL; } - if (masterPtr->format) { - Tcl_DecrRefCount(masterPtr->format); + if (modelPtr->format) { + Tcl_DecrRefCount(modelPtr->format); } - masterPtr->format = format; + modelPtr->format = format; } if (metadataInObj) { /* - * make -metadata a dict. + * Make -metadata a dict. * Take also empty metadatas as this may be a sign to replace * existing metadata. */ int dictSize; @@ -2107,22 +2107,22 @@ if (dictSize > 0) { Tcl_IncrRefCount(metadataInObj); } else { metadataInObj = NULL; } - if (masterPtr->metadata) { - Tcl_DecrRefCount(masterPtr->metadata); + if (modelPtr->metadata) { + Tcl_DecrRefCount(modelPtr->metadata); } - masterPtr->metadata = metadataInObj; + modelPtr->metadata = metadataInObj; } /* * Set the image to the user-requested size, if any, and make sure storage * is correctly allocated for this image. */ - if (ImgPhotoSetSize(masterPtr, masterPtr->width, - masterPtr->height) != TCL_OK) { + if (ImgPhotoSetSize(modelPtr, modelPtr->width, + modelPtr->height) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } @@ -2130,13 +2130,13 @@ /* * Read in the image from the file or string if the user has specified the * -file or -data option. */ - if ((masterPtr->fileString != NULL) - && ((masterPtr->fileString != oldFileString) - || (masterPtr->format != oldFormat))) { + if ((modelPtr->fileString != NULL) + && ((modelPtr->fileString != oldFileString) + || (modelPtr->format != oldFormat))) { /* * Prevent file system access in a safe interpreter. */ @@ -2147,11 +2147,11 @@ -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); goto errorExit; } - chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0); + chan = Tcl_OpenFileChannel(interp, modelPtr->fileString, "r", 0); if (chan == NULL) { goto errorExit; } /* @@ -2165,38 +2165,38 @@ * -translation binary also sets -encoding binary */ if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) || - (MatchFileFormat(interp, chan, masterPtr->fileString, - masterPtr->format, masterPtr->metadata, metadataOutObj, + (MatchFileFormat(interp, chan, modelPtr->fileString, + modelPtr->format, modelPtr->metadata, metadataOutObj, &imageFormat, &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat) != TCL_OK)) { Tcl_Close(NULL, chan); goto errorExit; } - result = ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); + result = ImgPhotoSetSize(modelPtr, imageWidth, imageHeight); if (result != TCL_OK) { Tcl_Close(NULL, chan); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } - tempformat = masterPtr->format; + tempformat = modelPtr->format; if (oldformat && tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); } if (imageFormat != NULL) { result = imageFormat->fileReadProc(interp, chan, - masterPtr->fileString, tempformat, - (Tk_PhotoHandle) masterPtr, + modelPtr->fileString, tempformat, + (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0); } else { result = imageFormatVersion3->fileReadProc(interp, chan, - masterPtr->fileString, tempformat, masterPtr->metadata, - (Tk_PhotoHandle) masterPtr, + modelPtr->fileString, tempformat, modelPtr->metadata, + (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0, metadataOutObj); } Tcl_Close(NULL, chan); @@ -2203,61 +2203,60 @@ if (result != TCL_OK) { goto errorExit; } Tcl_ResetResult(interp); - masterPtr->flags |= IMAGE_CHANGED; + modelPtr->flags |= IMAGE_CHANGED; } - if ((masterPtr->fileString == NULL) && (masterPtr->dataString != NULL) - && ((masterPtr->dataString != oldData) - || (masterPtr->format != oldFormat))) { + if ((modelPtr->fileString == NULL) && (modelPtr->dataString != NULL) + && ((modelPtr->dataString != oldData) + || (modelPtr->format != oldFormat))) { /* * Flag that we want the metadata result dict */ metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); - if (MatchStringFormat(interp, masterPtr->dataString, - masterPtr->format, masterPtr->metadata, metadataOutObj, + if (MatchStringFormat(interp, modelPtr->dataString, + modelPtr->format, modelPtr->metadata, metadataOutObj, &imageFormat, &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { goto errorExit; } - if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) { + if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } - tempformat = masterPtr->format; - tempdata = masterPtr->dataString; + tempformat = modelPtr->format; + tempdata = modelPtr->dataString; if (oldformat) { if (tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); } tempdata = (Tcl_Obj *) Tcl_GetString(tempdata); } if (imageFormat != NULL) { if (imageFormat->stringReadProc(interp, tempdata, tempformat, - (Tk_PhotoHandle) masterPtr, 0, 0, imageWidth, imageHeight, + (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0) != TCL_OK) { goto errorExit; } } else { - if (imageFormatVersion3->stringReadProc(interp, tempdata, tempformat, - masterPtr->metadata, (Tk_PhotoHandle) masterPtr, 0, 0, + modelPtr->metadata, (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0, metadataOutObj) != TCL_OK) { goto errorExit; } } Tcl_ResetResult(interp); - masterPtr->flags |= IMAGE_CHANGED; + modelPtr->flags |= IMAGE_CHANGED; } /* * Merge driver returned metadata and master metadata */ @@ -2274,66 +2273,66 @@ /* * We have driver return metadata */ - if (masterPtr->metadata == NULL) { - masterPtr->metadata = metadataOutObj; + if (modelPtr->metadata == NULL) { + modelPtr->metadata = metadataOutObj; metadataOutObj = NULL; } else { Tcl_DictSearch search; Tcl_Obj *key, *value; int done; - if (Tcl_IsShared(masterPtr->metadata)) { - Tcl_DecrRefCount(masterPtr->metadata); - masterPtr->metadata = Tcl_DuplicateObj(masterPtr->metadata); - Tcl_IncrRefCount(masterPtr->metadata); + if (Tcl_IsShared(modelPtr->metadata)) { + Tcl_DecrRefCount(modelPtr->metadata); + modelPtr->metadata = Tcl_DuplicateObj(modelPtr->metadata); + Tcl_IncrRefCount(modelPtr->metadata); } if (Tcl_DictObjFirst(interp, metadataOutObj, &search, &key, &value, &done) != TCL_OK) { goto errorExit; } for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) { - Tcl_DictObjPut(interp, masterPtr->metadata, key, value); + Tcl_DictObjPut(interp, modelPtr->metadata, key, value); } } } } /* * Enforce a reasonable value for gamma. */ - if (masterPtr->gamma <= 0) { - masterPtr->gamma = 1.0; + if (modelPtr->gamma <= 0) { + modelPtr->gamma = 1.0; } - if ((masterPtr->gamma != oldGamma) - || (masterPtr->palette != oldPaletteString)) { - masterPtr->flags |= IMAGE_CHANGED; + if ((modelPtr->gamma != oldGamma) + || (modelPtr->palette != oldPaletteString)) { + modelPtr->flags |= IMAGE_CHANGED; } /* * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { TkImgPhotoConfigureInstance(instancePtr); } /* * Inform the generic image code that the image has (potentially) changed. */ - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width, - masterPtr->height, masterPtr->width, masterPtr->height); - masterPtr->flags &= ~IMAGE_CHANGED; + Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width, + modelPtr->height, modelPtr->width, modelPtr->height); + modelPtr->flags &= ~IMAGE_CHANGED; if (oldData != NULL) { Tcl_DecrRefCount(oldData); } if (oldFormat != NULL) { @@ -2341,11 +2340,11 @@ } if (metadataOutObj != NULL) { Tcl_DecrRefCount(metadataOutObj); } - ToggleComplexAlphaIfNeeded(masterPtr); + ToggleComplexAlphaIfNeeded(modelPtr); return TCL_OK; errorExit: if (oldData != NULL) { @@ -2371,18 +2370,18 @@ * * Results: * None. * * Side effects: - * (Re)sets COMPLEX_ALPHA flag of master. + * (Re)sets COMPLEX_ALPHA flag of model. * *---------------------------------------------------------------------- */ static int ToggleComplexAlphaIfNeeded( - PhotoMaster *mPtr) + PhotoModel *mPtr) { size_t len = (size_t)MAX(mPtr->userWidth, mPtr->width) * (size_t)MAX(mPtr->userHeight, mPtr->height) * 4; unsigned char *c = mPtr->pix32; unsigned char *end = c + len; @@ -2409,11 +2408,11 @@ /* *---------------------------------------------------------------------- * * ImgPhotoDelete -- * - * This function is called by the image code to delete the master + * This function is called by the image code to delete the model * structure for an image. * * Results: * None. * @@ -2423,44 +2422,44 @@ *---------------------------------------------------------------------- */ static void ImgPhotoDelete( - ClientData masterData) /* Pointer to PhotoMaster structure for image. + ClientData modelData) /* Pointer to PhotoModel structure for image. * Must not have any more instances. */ { - PhotoMaster *masterPtr = (PhotoMaster *)masterData; + PhotoModel *modelPtr = (PhotoModel *)modelData; PhotoInstance *instancePtr; - while ((instancePtr = masterPtr->instancePtr) != NULL) { + while ((instancePtr = modelPtr->instancePtr) != NULL) { if (instancePtr->refCount > 0) { Tcl_Panic("tried to delete photo image when instances still exist"); } Tcl_CancelIdleCall(TkImgDisposeInstance, instancePtr); TkImgDisposeInstance(instancePtr); } - masterPtr->tkMaster = NULL; - if (masterPtr->imageCmd != NULL) { - Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd); - } - if (masterPtr->pix32 != NULL) { - ckfree(masterPtr->pix32); - } - if (masterPtr->validRegion != NULL) { - TkDestroyRegion(masterPtr->validRegion); - } - if (masterPtr->dataString != NULL) { - Tcl_DecrRefCount(masterPtr->dataString); - } - if (masterPtr->format != NULL) { - Tcl_DecrRefCount(masterPtr->format); - } - if (masterPtr->metadata != NULL) { - Tcl_DecrRefCount(masterPtr->metadata); - } - Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); - ckfree(masterPtr); + modelPtr->tkModel = NULL; + if (modelPtr->imageCmd != NULL) { + Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd); + } + if (modelPtr->pix32 != NULL) { + ckfree(modelPtr->pix32); + } + if (modelPtr->validRegion != NULL) { + TkDestroyRegion(modelPtr->validRegion); + } + if (modelPtr->dataString != NULL) { + Tcl_DecrRefCount(modelPtr->dataString); + } + if (modelPtr->format != NULL) { + Tcl_DecrRefCount(modelPtr->format); + } + if (modelPtr->metadata != NULL) { + Tcl_DecrRefCount(modelPtr->metadata); + } + Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0); + ckfree(modelPtr); } /* *---------------------------------------------------------------------- * @@ -2478,18 +2477,18 @@ *---------------------------------------------------------------------- */ static void ImgPhotoCmdDeletedProc( - ClientData clientData) /* Pointer to PhotoMaster structure for + ClientData clientData) /* Pointer to PhotoModel structure for * image. */ { - PhotoMaster *masterPtr = (PhotoMaster *)clientData; + PhotoModel *modelPtr = (PhotoModel *)clientData; - masterPtr->imageCmd = NULL; - if (masterPtr->tkMaster != NULL) { - Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); + modelPtr->imageCmd = NULL; + if (modelPtr->tkModel != NULL) { + Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkModel)); } } /* *---------------------------------------------------------------------- @@ -2503,32 +2502,32 @@ * Results: * TCL_OK if successful, TCL_ERROR if failure occurred (currently just * with memory allocation.) * * Side effects: - * Storage gets reallocated, for the master and all its instances. + * Storage gets reallocated, for the model and all its instances. * *---------------------------------------------------------------------- */ static int ImgPhotoSetSize( - PhotoMaster *masterPtr, + PhotoModel *modelPtr, int width, int height) { unsigned char *newPix32 = NULL; int h, offset, pitch; unsigned char *srcPtr, *destPtr; XRectangle validBox, clipBox; TkRegion clipRegion; PhotoInstance *instancePtr; - if (masterPtr->userWidth > 0) { - width = masterPtr->userWidth; + if (modelPtr->userWidth > 0) { + width = modelPtr->userWidth; } - if (masterPtr->userHeight > 0) { - height = masterPtr->userHeight; + if (modelPtr->userHeight > 0) { + height = modelPtr->userHeight; } if (width > INT_MAX / 4) { /* Pitch overflows int */ return TCL_ERROR; @@ -2538,12 +2537,12 @@ /* * Test if we're going to (re)allocate the main buffer now, so that any * failures will leave the photo unchanged. */ - if ((width != masterPtr->width) || (height != masterPtr->height) - || (masterPtr->pix32 == NULL)) { + if ((width != modelPtr->width) || (height != modelPtr->height) + || (modelPtr->pix32 == NULL)) { unsigned newPixSize; if (pitch && height > (int)(UINT_MAX / pitch)) { return TCL_ERROR; } @@ -2566,23 +2565,23 @@ /* * We have to trim the valid region if it is currently larger than the new * image size. */ - TkClipBox(masterPtr->validRegion, &validBox); + TkClipBox(modelPtr->validRegion, &validBox); if ((validBox.x + validBox.width > width) || (validBox.y + validBox.height > height)) { clipBox.x = 0; clipBox.y = 0; clipBox.width = width; clipBox.height = height; clipRegion = TkCreateRegion(); TkUnionRectWithRegion(&clipBox, clipRegion, clipRegion); - TkIntersectRegion(masterPtr->validRegion, clipRegion, - masterPtr->validRegion); + TkIntersectRegion(modelPtr->validRegion, clipRegion, + modelPtr->validRegion); TkDestroyRegion(clipRegion); - TkClipBox(masterPtr->validRegion, &validBox); + TkClipBox(modelPtr->validRegion, &validBox); } /* * Use the reallocated storage (allocation above) for the 32-bit image and * copy over valid regions. Note that this test is true precisely when the @@ -2594,12 +2593,12 @@ * Zero the new array. The dithering code shouldn't read the areas * outside validBox, but they might be copied to another photo image * or written to a file. */ - if ((masterPtr->pix32 != NULL) - && ((width == masterPtr->width) || (width == validBox.width))) { + if ((modelPtr->pix32 != NULL) + && ((width == modelPtr->width) || (width == validBox.width))) { if (validBox.y > 0) { memset(newPix32, 0, ((size_t) validBox.y * pitch)); } h = validBox.y + validBox.height; if (h < height) { @@ -2607,75 +2606,75 @@ } } else { memset(newPix32, 0, ((size_t)height * pitch)); } - if (masterPtr->pix32 != NULL) { + if (modelPtr->pix32 != NULL) { /* * Copy the common area over to the new array array and free the * old array. */ - if (width == masterPtr->width) { + if (width == modelPtr->width) { /* * The region to be copied is contiguous. */ offset = validBox.y * pitch; - memcpy(newPix32 + offset, masterPtr->pix32 + offset, + memcpy(newPix32 + offset, modelPtr->pix32 + offset, ((size_t)validBox.height * pitch)); } else if ((validBox.width > 0) && (validBox.height > 0)) { /* * Area to be copied is not contiguous - copy line by line. */ destPtr = newPix32 + (validBox.y * width + validBox.x) * 4; - srcPtr = masterPtr->pix32 + (validBox.y * masterPtr->width + srcPtr = modelPtr->pix32 + (validBox.y * modelPtr->width + validBox.x) * 4; for (h = validBox.height; h > 0; h--) { memcpy(destPtr, srcPtr, ((size_t)validBox.width * 4)); destPtr += width * 4; - srcPtr += masterPtr->width * 4; + srcPtr += modelPtr->width * 4; } } - ckfree(masterPtr->pix32); + ckfree(modelPtr->pix32); } - masterPtr->pix32 = newPix32; - masterPtr->width = width; - masterPtr->height = height; + modelPtr->pix32 = newPix32; + modelPtr->width = width; + modelPtr->height = height; /* * Dithering will be correct up to the end of the last pre-existing * complete scanline. */ if ((validBox.x > 0) || (validBox.y > 0)) { - masterPtr->ditherX = 0; - masterPtr->ditherY = 0; + modelPtr->ditherX = 0; + modelPtr->ditherY = 0; } else if (validBox.width == width) { - if ((int) validBox.height < masterPtr->ditherY) { - masterPtr->ditherX = 0; - masterPtr->ditherY = validBox.height; - } - } else if ((masterPtr->ditherY > 0) - || ((int) validBox.width < masterPtr->ditherX)) { - masterPtr->ditherX = validBox.width; - masterPtr->ditherY = 0; + if ((int) validBox.height < modelPtr->ditherY) { + modelPtr->ditherX = 0; + modelPtr->ditherY = validBox.height; + } + } else if ((modelPtr->ditherY > 0) + || ((int) validBox.width < modelPtr->ditherX)) { + modelPtr->ditherX = validBox.width; + modelPtr->ditherY = 0; } } - ToggleComplexAlphaIfNeeded(masterPtr); + ToggleComplexAlphaIfNeeded(modelPtr); /* * Now adjust the sizes of the pixmaps for all of the instances. */ - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { TkImgPhotoInstanceSetSize(instancePtr); } return TCL_OK; @@ -2864,20 +2863,19 @@ (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); return TCL_OK; } /* - * Clear eventual set keys in the metadata object + * Check if driver has shared or changed the metadata Tcl object. + * In this case, release and recreate it. */ if (metadataOutObj != NULL) { int dictSize; - if (TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) + if (Tcl_IsShared(metadataOutObj) + || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) || dictSize > 0) { - /* - * Driver has modified the metadata dict, so clear it - */ Tcl_DecrRefCount(metadataOutObj); metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); } } @@ -3067,20 +3065,19 @@ metadataOutObj)) { break; } /* - * Clear eventual set keys in the metadata object + * Check if driver has shared or changed the metadata tcl object. + * In this case, release and recreate it. */ if (metadataOutObj != NULL) { int dictSize; - if (TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) + if (Tcl_IsShared(metadataOutObj) + || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) || dictSize > 0) { - /* - * Driver has modified the metadata dict, so clear it - */ Tcl_DecrRefCount(metadataOutObj); metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); } } @@ -3143,11 +3140,11 @@ *---------------------------------------------------------------------- * * Tk_FindPhoto -- * * This function is called to get an opaque handle (actually a - * PhotoMaster *) for a given image, which can be used in subsequent + * PhotoModel *) for a given image, which can be used in subsequent * calls to Tk_PhotoPutBlock, etc. The `name' parameter is the name of * the image. * * Results: * The handle for the photo image, or NULL if there is no photo image @@ -3165,11 +3162,11 @@ * exists. */ const char *imageName) /* Name of the desired photo image. */ { const Tk_ImageType *typePtr; ClientData clientData = - Tk_GetImageMasterData(interp, imageName, &typePtr); + Tk_GetImageModelData(interp, imageName, &typePtr); if ((typePtr == NULL) || (typePtr->name != tkPhotoImageType.name)) { return NULL; } return clientData; @@ -3208,11 +3205,11 @@ int width, int height, /* Dimensions of the area of the image to be * updated. */ int compRule) /* Compositing rule to use when processing * transparent pixels. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; Tk_PhotoImageBlock sourceBlock; unsigned char *memToFree; int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; int wLeft, hLeft, wCopy, hCopy, pitch; unsigned char *srcPtr, *srcLinePtr, *destPtr, *destLinePtr; @@ -3227,16 +3224,16 @@ return TCL_OK; } compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO; - if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) { - width = masterPtr->userWidth - x; + if ((modelPtr->userWidth != 0) && ((x + width) > modelPtr->userWidth)) { + width = modelPtr->userWidth - x; } - if ((masterPtr->userHeight != 0) - && ((y + height) > masterPtr->userHeight)) { - height = masterPtr->userHeight - y; + if ((modelPtr->userHeight != 0) + && ((y + height) > modelPtr->userHeight)) { + height = modelPtr->userHeight - y; } if ((width <= 0) || (height <= 0)) { return TCL_OK; } @@ -3253,22 +3250,22 @@ * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ sourceBlock = *blockPtr; memToFree = NULL; - if (sourceBlock.pixelPtr >= masterPtr->pix32 - && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width - * masterPtr->height * 4) { + if (sourceBlock.pixelPtr >= modelPtr->pix32 + && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width + * modelPtr->height * 4) { /* * Fix 5c51be6411: avoid reading * * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize) * - * bytes past the end of masterPtr->pix32[] when + * bytes past the end of modelPtr->pix32[] when * - * blockPtr->pixelPtr > (masterPtr->pix32 + - * 4 * masterPtr->width * masterPtr->height - + * blockPtr->pixelPtr > (modelPtr->pix32 + + * 4 * modelPtr->width * modelPtr->height - * sourceBlock.height * sourceBlock.pitch) */ unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch + sourceBlock.width * sourceBlock.pixelSize; @@ -3286,30 +3283,30 @@ } xEnd = x + width; yEnd = y + height; - if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { - if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), - MAX(yEnd, masterPtr->height)) == TCL_ERROR) { + if ((xEnd > modelPtr->width) || (yEnd > modelPtr->height)) { + if (ImgPhotoSetSize(modelPtr, MAX(xEnd, modelPtr->width), + MAX(yEnd, modelPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } goto errorExit; } } - if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY) - && (x < masterPtr->ditherX))) { + if ((y < modelPtr->ditherY) || ((y == modelPtr->ditherY) + && (x < modelPtr->ditherX))) { /* * The dithering isn't correct past the start of this block. */ - masterPtr->ditherX = x; - masterPtr->ditherY = y; + modelPtr->ditherX = x; + modelPtr->ditherY = y; } /* * If this image block could have different red, green and blue * components, mark it as a color image. @@ -3323,20 +3320,20 @@ sourceIsSimplePhoto = 1; } else { alphaOffset -= sourceBlock.offset[0]; } if ((greenOffset != 0) || (blueOffset != 0)) { - masterPtr->flags |= COLOR_IMAGE; + modelPtr->flags |= COLOR_IMAGE; } /* * Copy the data into our local 32-bit/pixel array. If we can do it with a * single memmove, we do. */ - destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; - pitch = masterPtr->width * 4; + destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; + pitch = modelPtr->width * 4; /* * Test to see if we can do the whole write in a single copy. This test is * probably too restrictive. We should also be able to do a memmove if * pixelSize == 3 and alphaOffset == 0. Maybe other cases too. @@ -3343,11 +3340,11 @@ */ if ((sourceBlock.pixelSize == 4) && (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3) && (width <= sourceBlock.width) && (height <= sourceBlock.height) - && ((height == 1) || ((x == 0) && (width == masterPtr->width) + && ((height == 1) || ((x == 0) && (width == modelPtr->width) && (sourceBlock.pitch == pitch))) && (compRule == TK_PHOTO_COMPOSITE_SET)) { memmove(destLinePtr, sourceBlock.pixelPtr + sourceBlock.offset[0], ((size_t)height * width * 4)); @@ -3525,31 +3522,31 @@ rect.x = x; rect.y = y; rect.width = width; rect.height = height; TkUnionRectWithRegion(&rect, workRgn, workRgn); - TkSubtractRegion(masterPtr->validRegion, workRgn, - masterPtr->validRegion); + TkSubtractRegion(modelPtr->validRegion, workRgn, + modelPtr->validRegion); TkDestroyRegion(workRgn); } /* * Factorize out the main part of the building of the region data to * allow for more efficient per-platform implementations. [Bug 919066] */ - TkpBuildRegionFromAlphaData(masterPtr->validRegion, (unsigned) x, + TkpBuildRegionFromAlphaData(modelPtr->validRegion, (unsigned) x, (unsigned) y, (unsigned) width, (unsigned) height, - masterPtr->pix32 + (y * masterPtr->width + x) * 4 + 3, - 4, (unsigned) masterPtr->width * 4); + modelPtr->pix32 + (y * modelPtr->width + x) * 4 + 3, + 4, (unsigned) modelPtr->width * 4); } else { rect.x = x; rect.y = y; rect.width = width; rect.height = height; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); + TkUnionRectWithRegion(&rect, modelPtr->validRegion, + modelPtr->validRegion); } /* * Check if display code needs alpha blending... */ @@ -3560,47 +3557,47 @@ * builds up large simple-alpha images by scan-lines or individual * pixels. We don't negate COMPLEX_ALPHA in this case. [Bug 1409140] * [Patch 1539990] */ - if (!(masterPtr->flags & COMPLEX_ALPHA)) { + if (!(modelPtr->flags & COMPLEX_ALPHA)) { int x1; for (x1=x ; x1pix32 + (y*masterPtr->width + x1)*4; + destLinePtr = modelPtr->pix32 + (y*modelPtr->width + x1)*4; newAlpha = destLinePtr[3]; if (newAlpha && newAlpha != 255) { - masterPtr->flags |= COMPLEX_ALPHA; + modelPtr->flags |= COMPLEX_ALPHA; break; } } } - } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) { + } else if ((alphaOffset != 0) || (modelPtr->flags & COMPLEX_ALPHA)) { /* * Check for partial transparency if alpha pixels are specified, or * rescan if we already knew such pixels existed. To restrict this * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ - ToggleComplexAlphaIfNeeded(masterPtr); + ToggleComplexAlphaIfNeeded(modelPtr); } /* * Update each instance. */ - Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, x, y, width, height); + Tk_DitherPhoto((Tk_PhotoHandle)modelPtr, x, y, width, height); /* * Tell the core image code that this image has changed. */ - Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, - masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, x, y, width, height, + modelPtr->width, modelPtr->height); if (memToFree) ckfree(memToFree); return TCL_OK; @@ -3646,11 +3643,11 @@ /* Subsampling factors for the X and Y * axes. */ int compRule) /* Compositing rule to use when processing * transparent pixels. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; Tk_PhotoImageBlock sourceBlock; unsigned char *memToFree; int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt; unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr, *destPtr, *destLinePtr; @@ -3674,16 +3671,16 @@ compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO; if (zoomX <= 0 || zoomY <= 0) { return TCL_OK; } - if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) { - width = masterPtr->userWidth - x; + if ((modelPtr->userWidth != 0) && ((x + width) > modelPtr->userWidth)) { + width = modelPtr->userWidth - x; } - if ((masterPtr->userHeight != 0) - && ((y + height) > masterPtr->userHeight)) { - height = masterPtr->userHeight - y; + if ((modelPtr->userHeight != 0) + && ((y + height) > modelPtr->userHeight)) { + height = modelPtr->userHeight - y; } if (width <= 0 || height <= 0) { return TCL_OK; } @@ -3699,22 +3696,22 @@ * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ sourceBlock = *blockPtr; memToFree = NULL; - if (sourceBlock.pixelPtr >= masterPtr->pix32 - && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width - * masterPtr->height * 4) { + if (sourceBlock.pixelPtr >= modelPtr->pix32 + && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width + * modelPtr->height * 4) { /* * Fix 5c51be6411: avoid reading * * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize) * - * bytes past the end of masterPtr->pix32[] when + * bytes past the end of modelPtr->pix32[] when * - * blockPtr->pixelPtr > (masterPtr->pix32 + - * 4 * masterPtr->width * masterPtr->height - + * blockPtr->pixelPtr > (modelPtr->pix32 + + * 4 * modelPtr->width * modelPtr->height - * sourceBlock.height * sourceBlock.pitch) */ unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch + sourceBlock.width * sourceBlock.pixelSize; @@ -3731,30 +3728,30 @@ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, cpyLen); } xEnd = x + width; yEnd = y + height; - if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { - if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), - MAX(yEnd, masterPtr->height)) == TCL_ERROR) { + if ((xEnd > modelPtr->width) || (yEnd > modelPtr->height)) { + if (ImgPhotoSetSize(modelPtr, MAX(xEnd, modelPtr->width), + MAX(yEnd, modelPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } goto errorExit; } } - if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY) - && (x < masterPtr->ditherX))) { + if ((y < modelPtr->ditherY) || ((y == modelPtr->ditherY) + && (x < modelPtr->ditherX))) { /* * The dithering isn't correct past the start of this block. */ - masterPtr->ditherX = x; - masterPtr->ditherY = y; + modelPtr->ditherX = x; + modelPtr->ditherY = y; } /* * If this image block could have different red, green and blue * components, mark it as a color image. @@ -3768,11 +3765,11 @@ sourceIsSimplePhoto = 1; } else { alphaOffset -= sourceBlock.offset[0]; } if ((greenOffset != 0) || (blueOffset != 0)) { - masterPtr->flags |= COLOR_IMAGE; + modelPtr->flags |= COLOR_IMAGE; } /* * Work out what area the pixel data in the block expands to after * subsampling and zooming. @@ -3797,20 +3794,20 @@ /* * Copy the data into our local 32-bit/pixel array. */ - destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; srcOrigPtr = sourceBlock.pixelPtr + sourceBlock.offset[0]; if (subsampleX < 0) { srcOrigPtr += (sourceBlock.width - 1) * sourceBlock.pixelSize; } if (subsampleY < 0) { srcOrigPtr += (sourceBlock.height - 1) * sourceBlock.pitch; } - pitch = masterPtr->width * 4; + pitch = modelPtr->width * 4; for (hLeft = height; hLeft > 0; ) { hCopy = MIN(hLeft, blockHt); hLeft -= hCopy; yRepeat = zoomY; srcLinePtr = srcOrigPtr; @@ -3893,26 +3890,26 @@ rect.x = x; rect.y = y; rect.width = width; rect.height = 1; TkUnionRectWithRegion(&rect, workRgn, workRgn); - TkSubtractRegion(masterPtr->validRegion, workRgn, - masterPtr->validRegion); + TkSubtractRegion(modelPtr->validRegion, workRgn, + modelPtr->validRegion); TkDestroyRegion(workRgn); } - TkpBuildRegionFromAlphaData(masterPtr->validRegion, + TkpBuildRegionFromAlphaData(modelPtr->validRegion, (unsigned)x, (unsigned)y, (unsigned)width, (unsigned)height, - &masterPtr->pix32[(y * masterPtr->width + x) * 4 + 3], 4, - (unsigned) masterPtr->width * 4); + &modelPtr->pix32[(y * modelPtr->width + x) * 4 + 3], 4, + (unsigned) modelPtr->width * 4); } else { rect.x = x; rect.y = y; rect.width = width; rect.height = height; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); + TkUnionRectWithRegion(&rect, modelPtr->validRegion, + modelPtr->validRegion); } /* * Check if display code needs alpha blending... */ @@ -3921,42 +3918,42 @@ /* * Optimize the single pixel case if we can. This speeds up code that * builds up large simple-alpha images by single pixels. We don't * negate COMPLEX_ALPHA in this case. [Bug 1409140] */ - if (!(masterPtr->flags & COMPLEX_ALPHA)) { + if (!(modelPtr->flags & COMPLEX_ALPHA)) { unsigned char newAlpha; - destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + destLinePtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4; newAlpha = destLinePtr[3]; if (newAlpha && newAlpha != 255) { - masterPtr->flags |= COMPLEX_ALPHA; + modelPtr->flags |= COMPLEX_ALPHA; } } - } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) { + } else if ((alphaOffset != 0) || (modelPtr->flags & COMPLEX_ALPHA)) { /* * Check for partial transparency if alpha pixels are specified, or * rescan if we already knew such pixels existed. To restrict this * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ - ToggleComplexAlphaIfNeeded(masterPtr); + ToggleComplexAlphaIfNeeded(modelPtr); } /* * Update each instance. */ - Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y, width, height); + Tk_DitherPhoto((Tk_PhotoHandle) modelPtr, x, y, width, height); /* * Tell the core image code that this image has changed. */ - Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width, - masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, x, y, width, height, modelPtr->width, + modelPtr->height); if (memToFree) ckfree(memToFree); return TCL_OK; @@ -3970,77 +3967,77 @@ *---------------------------------------------------------------------- * * Tk_DitherPhoto -- * * This function is called to update an area of each instance's pixmap by - * dithering the corresponding area of the image master. + * dithering the corresponding area of the image model. * * Results: * None. * * Side effects: * The pixmap of each instance of this image gets updated. The fields in - * *masterPtr indicating which area of the image is correctly dithered + * *modelPtr indicating which area of the image is correctly dithered * get updated. * *---------------------------------------------------------------------- */ void Tk_DitherPhoto( - Tk_PhotoHandle photo, /* Image master whose instances are to be + Tk_PhotoHandle photo, /* Image model whose instances are to be * updated. */ int x, int y, /* Coordinates of the top-left pixel in the * area to be dithered. */ int width, int height) /* Dimensions of the area to be dithered. */ { - PhotoMaster *masterPtr = (PhotoMaster *) photo; + PhotoModel *modelPtr = (PhotoModel *) photo; PhotoInstance *instancePtr; if ((width <= 0) || (height <= 0)) { return; } - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { TkImgDitherInstance(instancePtr, x, y, width, height); } /* * Work out whether this block will be correctly dithered and whether it * will extend the correctly dithered region. */ - if (((y < masterPtr->ditherY) - || ((y == masterPtr->ditherY) && (x <= masterPtr->ditherX))) - && ((y + height) > (masterPtr->ditherY))) { + if (((y < modelPtr->ditherY) + || ((y == modelPtr->ditherY) && (x <= modelPtr->ditherX))) + && ((y + height) > (modelPtr->ditherY))) { /* * This block starts inside (or immediately after) the correctly * dithered region, so the first scan line at least will be right. - * Furthermore this block extends into scanline masterPtr->ditherY. + * Furthermore this block extends into scanline modelPtr->ditherY. */ - if ((x == 0) && (width == masterPtr->width)) { + if ((x == 0) && (width == modelPtr->width)) { /* * We are doing the full width, therefore the dithering will be * correct to the end. */ - masterPtr->ditherX = 0; - masterPtr->ditherY = y + height; + modelPtr->ditherX = 0; + modelPtr->ditherY = y + height; } else { /* * We are doing partial scanlines, therefore the * correctly-dithered region will be extended by at most one scan * line. */ - if (x <= masterPtr->ditherX) { - masterPtr->ditherX = x + width; - if (masterPtr->ditherX >= masterPtr->width) { - masterPtr->ditherX = 0; - masterPtr->ditherY++; + if (x <= modelPtr->ditherX) { + modelPtr->ditherX = x + width; + if (modelPtr->ditherX >= modelPtr->width) { + modelPtr->ditherX = 0; + modelPtr->ditherY++; } } } } } @@ -4064,43 +4061,43 @@ void Tk_PhotoBlank( Tk_PhotoHandle handle) /* Handle for the image to be blanked. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; PhotoInstance *instancePtr; - masterPtr->ditherX = masterPtr->ditherY = 0; - masterPtr->flags = 0; + modelPtr->ditherX = modelPtr->ditherY = 0; + modelPtr->flags = 0; /* * The image has valid data nowhere. */ - if (masterPtr->validRegion != NULL) { - TkDestroyRegion(masterPtr->validRegion); + if (modelPtr->validRegion != NULL) { + TkDestroyRegion(modelPtr->validRegion); } - masterPtr->validRegion = TkCreateRegion(); + modelPtr->validRegion = TkCreateRegion(); /* * Clear out the 32-bit pixel storage array. Clear out the dithering error * arrays for each instance. */ - memset(masterPtr->pix32, 0, - ((size_t)masterPtr->width * masterPtr->height * 4)); - for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; + memset(modelPtr->pix32, 0, + ((size_t)modelPtr->width * modelPtr->height * 4)); + for (instancePtr = modelPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { TkImgResetDither(instancePtr); } /* * Tell the core image code that this image has changed. */ - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width, - masterPtr->height, masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width, + modelPtr->height, modelPtr->width, modelPtr->height); } /* *---------------------------------------------------------------------- * @@ -4126,30 +4123,30 @@ Tcl_Interp *interp, /* Interpreter for passing back error * messages, or NULL. */ Tk_PhotoHandle handle, /* Handle for the image to be expanded. */ int width, int height) /* Desired minimum dimensions of the image. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; - - if (width <= masterPtr->width) { - width = masterPtr->width; - } - if (height <= masterPtr->height) { - height = masterPtr->height; - } - if ((width != masterPtr->width) || (height != masterPtr->height)) { - if (ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width), - MAX(height, masterPtr->height)) == TCL_ERROR) { + PhotoModel *modelPtr = (PhotoModel *) handle; + + if (width <= modelPtr->width) { + width = modelPtr->width; + } + if (height <= modelPtr->height) { + height = modelPtr->height; + } + if ((width != modelPtr->width) || (height != modelPtr->height)) { + if (ImgPhotoSetSize(modelPtr, MAX(width, modelPtr->width), + MAX(height, modelPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, - masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, modelPtr->width, + modelPtr->height); } return TCL_OK; } /* @@ -4174,14 +4171,14 @@ * requested. */ int *widthPtr, int *heightPtr) /* The dimensions of the image are returned * here. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; - *widthPtr = masterPtr->width; - *heightPtr = masterPtr->height; + *widthPtr = modelPtr->width; + *heightPtr = modelPtr->height; } /* *---------------------------------------------------------------------- * @@ -4206,25 +4203,25 @@ * messages, or NULL. */ Tk_PhotoHandle handle, /* Handle for the image whose size is to be * set. */ int width, int height) /* New dimensions for the image. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; - masterPtr->userWidth = width; - masterPtr->userHeight = height; - if (ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width), - ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) { + modelPtr->userWidth = width; + modelPtr->userHeight = height; + if (ImgPhotoSetSize(modelPtr, ((width > 0) ? width: modelPtr->width), + ((height > 0) ? height: modelPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } - Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, - masterPtr->width, masterPtr->height); + Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, + modelPtr->width, modelPtr->height); return TCL_OK; } /* *---------------------------------------------------------------------- @@ -4249,13 +4246,13 @@ TkRegion TkPhotoGetValidRegion( Tk_PhotoHandle handle) /* Handle for the image whose valid region is * to obtained. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; - return masterPtr->validRegion; + return modelPtr->validRegion; } /* *---------------------------------------------------------------------- * @@ -4277,27 +4274,27 @@ *---------------------------------------------------------------------- */ static char * ImgGetPhoto( - PhotoMaster *masterPtr, /* Handle for the photo image from which image + PhotoModel *modelPtr, /* Handle for the photo image from which image * data is desired. */ Tk_PhotoImageBlock *blockPtr, /* Information about the address and layout of * the image data is returned here. */ struct SubcommandOptions *optPtr) { unsigned char *pixelPtr; int x, y, greenOffset, blueOffset, alphaOffset; - Tk_PhotoGetImage((Tk_PhotoHandle) masterPtr, blockPtr); + Tk_PhotoGetImage((Tk_PhotoHandle) modelPtr, blockPtr); blockPtr->pixelPtr += optPtr->fromY * blockPtr->pitch + optPtr->fromX * blockPtr->pixelSize; blockPtr->width = optPtr->fromX2 - optPtr->fromX; blockPtr->height = optPtr->fromY2 - optPtr->fromY; - if (!(masterPtr->flags & COLOR_IMAGE) && + if (!(modelPtr->flags & COLOR_IMAGE) && (!(optPtr->options & OPT_BACKGROUND) || ((optPtr->background->red == optPtr->background->green) && (optPtr->background->red == optPtr->background->blue)))) { blockPtr->offset[0] = blockPtr->offset[1] = blockPtr->offset[2]; } @@ -4321,11 +4318,11 @@ } greenOffset = blockPtr->offset[1] - blockPtr->offset[0]; blueOffset = blockPtr->offset[2] - blockPtr->offset[0]; if (((optPtr->options & OPT_BACKGROUND) && alphaOffset) || ((optPtr->options & OPT_GRAYSCALE) && (greenOffset||blueOffset))) { - int newPixelSize,x,y; + int newPixelSize; unsigned char *srcPtr, *destPtr; char *data; newPixelSize = (!(optPtr->options & OPT_BACKGROUND) && alphaOffset) ? 2 : 1; @@ -4474,16 +4471,16 @@ * data is desired. */ Tk_PhotoImageBlock *blockPtr) /* Information about the address and layout of * the image data is returned here. */ { - PhotoMaster *masterPtr = (PhotoMaster *) handle; + PhotoModel *modelPtr = (PhotoModel *) handle; - blockPtr->pixelPtr = masterPtr->pix32; - blockPtr->width = masterPtr->width; - blockPtr->height = masterPtr->height; - blockPtr->pitch = masterPtr->width * 4; + blockPtr->pixelPtr = modelPtr->pix32; + blockPtr->width = modelPtr->width; + blockPtr->height = modelPtr->height; + blockPtr->pitch = modelPtr->width * 4; blockPtr->pixelSize = 4; blockPtr->offset[0] = 0; blockPtr->offset[1] = 1; blockPtr->offset[2] = 2; blockPtr->offset[3] = 3; @@ -4528,11 +4525,11 @@ /* *---------------------------------------------------------------------- * * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite -- * - * These backward-compatability functions just exist to fill slots in stubs + * These backward-compatibility functions just exist to fill slots in stubs * table. For the behaviour of *_NoComposite, refer to the corresponding * function without the extra suffix, except that the compositing rule is * always "overlay" and the function always panics on memory-allocation * failure. * @@ -4569,11 +4566,11 @@ *---------------------------------------------------------------------- * * Tk_PhotoExpand_Panic, Tk_PhotoPutBlock_Panic, * Tk_PhotoPutZoomedBlock_Panic, Tk_PhotoSetSize_Panic * - * Backward compatability functions for preserving the old behaviour (i.e. + * Backward compatibility functions for preserving the old behaviour (i.e. * panic on memory allocation failure) so that extensions do not need to be * significantly updated to take account of TIP #116. These call the new * interface (i.e. the interface without the extra suffix), but panic if an * error condition is returned. * Index: generic/tkImgPhoto.h ================================================================== --- generic/tkImgPhoto.h +++ generic/tkImgPhoto.h @@ -1,14 +1,14 @@ /* * tkImgPhoto.h -- * * Declarations for images of type "photo" for Tk. * - * Copyright (c) 1994 The Australian National University. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2002-2008 Donal K. Fellows - * Copyright (c) 2003 ActiveState Corporation. + * Copyright © 1994 The Australian National University. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2002-2008 Donal K. Fellows + * Copyright © 2003 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Author: Paul Mackerras (paulus@cs.anu.edu.au), @@ -25,14 +25,15 @@ /* * Forward declarations of the structures we define. */ +#define PhotoMaster PhotoModel typedef struct ColorTableId ColorTableId; typedef struct ColorTable ColorTable; typedef struct PhotoInstance PhotoInstance; -typedef struct PhotoMaster PhotoMaster; +typedef struct PhotoModel PhotoModel; /* * A signed 8-bit integral type. If chars are unsigned and the compiler isn't * an ANSI one, then we have to use short instead (which wastes space) to get * signed behavior. @@ -46,17 +47,10 @@ # else typedef short schar; # endif #endif -/* - * An unsigned 32-bit integral type, used for pixel values. We use int rather - * than long here to accommodate those systems where longs are 64 bits. - */ - -typedef unsigned int pixel; - /* * The maximum number of pixels to transmit to the server in a single * XPutImage call. */ @@ -107,14 +101,14 @@ int numColors; /* Number of colors allocated for this map. */ XVisualInfo visualInfo; /* Information about the visual for windows * using this color table. */ - pixel redValues[256]; /* Maps 8-bit values of red intensity to a + unsigned redValues[256]; /* Maps 8-bit values of red intensity to a * pixel value or index in pixelMap. */ - pixel greenValues[256]; /* Ditto for green intensity. */ - pixel blueValues[256]; /* Ditto for blue intensity. */ + unsigned greenValues[256]; /* Ditto for green intensity. */ + unsigned blueValues[256]; /* Ditto for blue intensity. */ unsigned long *pixelMap; /* Actual pixel values allocated. */ unsigned char colorQuant[3][256]; /* Maps 8-bit intensities to quantized * intensities. The first index is 0 for red, @@ -142,15 +136,15 @@ #define COLOR_WINDOW 2 #define DISPOSE_PENDING 4 #define MAP_COLORS 8 /* - * Definition of the data associated with each photo image master. + * Definition of the data associated with each photo image model. */ -struct PhotoMaster { - Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means the +struct PhotoModel { + Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the * image is being deleted. */ Tcl_Interp *interp; /* Interpreter associated with the application * using this image. */ Tcl_Command imageCmd; /* Token for image command (used to delete it * when the image goes away). NULL means the @@ -171,15 +165,15 @@ int ditherX, ditherY; /* Location of first incorrectly dithered * pixel in image. */ TkRegion validRegion; /* Tk region indicating which parts of the * image have valid image data. */ PhotoInstance *instancePtr; /* First in the list of instances associated - * with this master. */ + * with this model. */ }; /* - * Bit definitions for the flags field of a PhotoMaster. + * Bit definitions for the flags field of a PhotoModel. * COLOR_IMAGE: 1 means that the image has different color * components. * IMAGE_CHANGED: 1 means that the instances of this image need * to be redithered. * COMPLEX_ALPHA: 1 means that the instances of this image have @@ -202,25 +196,25 @@ * The following data structure represents all of the instances of a photo * image in windows on a given screen that are using the same colormap. */ struct PhotoInstance { - PhotoMaster *masterPtr; /* Pointer to master for image. */ + PhotoModel *modelPtr; /* Pointer to model for image. */ Display *display; /* Display for windows using this instance. */ Colormap colormap; /* The image may only be used in windows with * this particular colormap. */ PhotoInstance *nextPtr; /* Pointer to the next instance in the list of - * instances associated with this master. */ + * instances associated with this model. */ #if TCL_MAJOR_VERSION > 8 size_t refCount; /* Number of instances using this structure. */ #else unsigned int refCount; /* Number of instances using this structure. */ #endif Tk_Uid palette; /* Palette for these particular instances. */ double gamma; /* Gamma value for these instances. */ Tk_Uid defaultPalette; /* Default palette to use if a palette is not - * specified for the master. */ + * specified for the model. */ ColorTable *colorTablePtr; /* Pointer to information about colors * allocated for image display in windows like * this one. */ Pixmap pixels; /* X pixmap containing dithered image. */ int width, height; /* Dimensions of the pixmap. */ Index: generic/tkImgSVGnano.c ================================================================== --- generic/tkImgSVGnano.c +++ generic/tkImgSVGnano.c @@ -1,20 +1,20 @@ /* * tkImgSVGnano.c * * A photo file handler for SVG files. * - * Copyright (c) 2013-14 Mikko Mononen memon@inside.org - * Copyright (c) 2018 Christian Gollwitzer auriocus@gmx.de - * Copyright (c) 2018 Rene Zaumseil r.zaumseil@freenet.de + * Copyright © 2013-14 Mikko Mononen memon@inside.org + * Copyright © 2018 Christian Gollwitzer auriocus@gmx.de + * Copyright © 2018 Christian Werner https://www.androwish.org/ + * Copyright © 2018 Rene Zaumseil r.zaumseil@freenet.de * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * This handler is build using the original nanosvg library files from - * https://github.com/memononen/nanosvg and the tcl extension files from - * https://github.com/auriocus/tksvg + * https://github.com/memononen/nanosvg * */ #include "tkInt.h" #define NANOSVG_malloc ckalloc @@ -50,10 +50,12 @@ Tcl_DString formatString; NSVGimage *nsvgImage; RastOpts ropts; } NSVGcache; +static const void * MemMem(const void *haystack, size_t haysize, + const void *needle, size_t needlen); static int FileMatchSVG(Tcl_Channel chan, const char *fileName, Tcl_Obj *format, int *widthPtr, int *heightPtr, Tcl_Interp *interp); static int FileReadSVG(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *format, @@ -99,10 +101,50 @@ }; /* *---------------------------------------------------------------------- * + * MemMem -- + * + * Like strstr() but operating on memory buffers with sizes. + * + *---------------------------------------------------------------------- + */ + +static const void * +MemMem(const void *haystack, size_t haylen, + const void *needle, size_t needlen) +{ + const void *hayend, *second, *p; + unsigned char first; + + if ((needlen <= 0) || (haylen < needlen)) { + return NULL; + } + hayend = (const void *) ((char *) haystack + haylen - needlen); + first = ((char *) needle)[0]; + second = (const void *) ((char *) needle + 1); + needlen -= 1; + while (haystack < hayend) { + p = memchr(haystack, first, (char *) hayend - (char *) haystack); + if (p == NULL) { + break; + } + if (needlen == 0) { + return p; + } + haystack = (const void *) ((char *) p + 1); + if (memcmp(second, haystack, needlen) == 0) { + return p; + } + } + return NULL; +} + +/* + *---------------------------------------------------------------------- + * * FileMatchSVG -- * * This function is invoked by the photo image type to see if a file * contains image data in SVG format. * @@ -130,16 +172,28 @@ RastOpts ropts; NSVGimage *nsvgImage; (void)fileName; CleanCache(interp); - if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) { + if (Tcl_ReadChars(chan, dataObj, 4096, 0) == TCL_IO_FAILURE) { + /* in case of an error reading the file */ + Tcl_DecrRefCount(dataObj); + return 0; + } + data = Tcl_GetStringFromObj(dataObj, &length); + /* should have a '' in the first 4k */ + if ((memchr(data, '>', length) == NULL) || + (MemMem(data, length, "' in the first 4k */ + testLength = (length > 4096) ? 4096 : length; + if ((memchr(data, '>', testLength) == NULL) || + (MemMem(data, testLength, " INT_MAX / 4) { + Tcl_SetObjResult(interp, Tcl_NewStringObj("image size overflow", -1)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "IMAGE_SIZE_OVERFLOW", NULL); + goto cleanRAST; + } + + imgData = (unsigned char *)attemptckalloc(wh * 4); if (imgData == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc image buffer", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL); goto cleanRAST; } @@ -692,11 +761,11 @@ NSVGcache *cachePtr = GetCachePtr(interp); if (cachePtr != NULL) { cachePtr->dataOrChan = dataOrChan; if (formatObj != NULL) { - data = TkGetStringFromObj(formatObj, &length); + data = Tcl_GetStringFromObj(formatObj, &length); Tcl_DStringAppend(&cachePtr->formatString, data, length); } cachePtr->nsvgImage = nsvgImage; cachePtr->ropts = *ropts; return 1; @@ -733,11 +802,11 @@ NSVGimage *nsvgImage = NULL; if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) && (cachePtr->dataOrChan == dataOrChan)) { if (formatObj != NULL) { - data = TkGetStringFromObj(formatObj, &length); + data = Tcl_GetStringFromObj(formatObj, &length); if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) { nsvgImage = cachePtr->nsvgImage; *ropts = cachePtr->ropts; cachePtr->nsvgImage = NULL; } Index: generic/tkImgUtil.c ================================================================== --- generic/tkImgUtil.c +++ generic/tkImgUtil.c @@ -1,11 +1,11 @@ /* * tkImgUtil.c -- * * This file contains image related utility functions. * - * Copyright (c) 1995 Sun Microsystems, Inc. + * Copyright © 1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkInt.decls ================================================================== --- generic/tkInt.decls +++ generic/tkInt.decls @@ -2,12 +2,12 @@ # # This file contains the declarations for all unsupported functions that # are exported by the Tk library. This file is used to generate the # tkIntDecls.h, tkIntPlatDecls.h, tkIntStub.c, and tkPlatStub.c files. # -# Copyright (c) 1998-1999 by Scriptics Corporation. -# Copyright (c) 2007 Daniel A. Steffen +# Copyright © 1998-1999 Scriptics Corporation. +# Copyright © 2007 Daniel A. Steffen # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. library tk @@ -633,23 +633,23 @@ void TkDrawAngledChars(Display *display,Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle) } -# Debugging / testing functions for photo images -declare 185 { - int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data, - Tcl_Obj *formatString, int *widthPtr, int *heightPtr) -} - # Support for aqua's inability to draw outside [NSView drawRect:] -declare 186 aqua { +declare 185 macosx { void TkpRedrawWidget(Tk_Window tkwin) } -declare 187 aqua { +declare 186 macosx { int TkpWillDrawWidget(Tk_Window tkwin) } + +# Debugging / testing functions for photo images +declare 187 { + int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data, + Tcl_Obj *formatString, int *widthPtr, int *heightPtr) +} ############################################################################## # Define the platform specific internal Tcl interface. These functions are @@ -916,13 +916,14 @@ void TkMacOSXClearMenubarActive(void) } declare 10 aqua { int TkMacOSXDispatchMenuEvent(int menuID, int index) } -declare 11 aqua { - void TkMacOSXInstallCursor(int resizeOverride) -} +# Now a static function +# declare 11 aqua { +# void TkMacOSXInstallCursor(int resizeOverride) +# } declare 12 aqua { void TkMacOSXHandleTearoffMenu(void) } declare 14 aqua { int TkMacOSXDoHLEvent(void *theEvent) @@ -960,13 +961,14 @@ void *TkMacOSXMakeStippleMap(Drawable d1, Drawable d2) } declare 25 aqua { void TkMacOSXMenuClick(void) } -declare 26 aqua { - void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr) -} +# The corresponding Unregister was not a stub, and this should be static. +#declare 26 aqua { +# void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr) +#} declare 27 aqua { int TkMacOSXResizable(TkWindow *winPtr) } declare 28 aqua { void TkMacOSXSetHelpMenuItemCount(void) @@ -981,13 +983,14 @@ void TkMacOSXSetUpGraphicsPort(GC gc, void *destPort) } declare 32 aqua { void TkMacOSXUpdateClipRgn(TkWindow *winPtr) } -declare 33 aqua { - void TkMacOSXUnregisterMacWindow(void *portPtr) -} +# This was not implemented. Perhaps meant to be OffScreen ? +#declare 33 aqua { +# void TkMacOSXUnregisterMacWindow(void *portPtr) +#} declare 34 aqua { int TkMacOSXUseMenuID(short macID) } declare 35 aqua { Region TkMacOSXVisableClipRgn(TkWindow *winPtr) @@ -1025,11 +1028,11 @@ } declare 47 aqua { Tk_Window TkpGetCapture(void) } declare 49 aqua { - Tk_Window TkGetTransientMaster(TkWindow *winPtr) + Tk_Window TkMacOSXGetContainer(TkWindow *winPtr) } declare 50 aqua { int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state) } declare 51 aqua { @@ -1929,10 +1932,14 @@ Status XWithdrawWindow(Display *d, Window w, int i) } declare 105 macosx { XHostAddress *XListHosts(Display *d, int *i, Bool *b) } +declare 106 macosx { + int XSetClipRectangles(Display *display, GC gc, int clip_x_origin, + int clip_y_origin, XRectangle rectangles[], int n, int ordering) +} declare 107 macosx { int XFlush(Display *display) } declare 108 macosx { int XGrabServer(Display *display) Index: generic/tkInt.h ================================================================== --- generic/tkInt.h +++ generic/tkInt.h @@ -4,11 +4,11 @@ * Declarations for things used internally by the Tk functions but not * exported outside the module. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998 by Scriptics Corporation. + * Copyright (c) 1998 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -86,10 +86,20 @@ # define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString) # define Tcl_Char16ToUtfDString Tcl_UniCharToUtfDString # define Tcl_UtfToChar16DString Tcl_UtfToUniCharDString #endif +#if defined(__GNUC__) && (__GNUC__ > 2) +# define TKFLEXARRAY 0 +#else +# define TKFLEXARRAY 1 +#endif + +#if !defined(Tcl_GetParent) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7) +# define Tcl_GetParent Tcl_GetMaster +#endif + /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast * to/from pointer from/to integer of different size". */ @@ -120,10 +130,16 @@ # define TCL_Z_MODIFIER "z" # else # define TCL_Z_MODIFIER "" # endif #endif /* !TCL_Z_MODIFIER */ +#undef TCL_LL_MODIFIER +#if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) +# define TCL_LL_MODIFIER "I64" +#else +# define TCL_LL_MODIFIER "ll" +#endif /* * Opaque type declarations: */ @@ -357,16 +373,16 @@ /* * Information used by tkGeometry.c only: */ Tcl_HashTable maintainHashTable; - /* Hash table that maps from a master's - * Tk_Window token to a list of slaves managed - * by that master. */ + /* Hash table that maps from a container's + * Tk_Window token to a list of windows managed + * by that container. */ int geomInit; -#define TkGetGeomMaster(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \ +#define TkGetContainer(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \ ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr) /* * Information used by tkGet.c only: */ @@ -440,13 +456,13 @@ /* * Information used by tkPlace.c only. */ int placeInit; /* 0 means tables below need initializing. */ - Tcl_HashTable masterTable; /* Maps from Tk_Window toke to the Master + Tcl_HashTable containerTable; /* Maps from Tk_Window token to the Container * structure for the window, if it exists. */ - Tcl_HashTable slaveTable; /* Maps from Tk_Window toke to the Slave + Tcl_HashTable contentTable; /* Maps from Tk_Window token to the Content * structure for the window, if it exists. */ /* * Information used by tkSelect.c and tkClipboard.c only: */ @@ -574,18 +590,15 @@ * Indicates that we should collapse motion events on this display * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) * Whether to use input methods for this display * TK_DISPLAY_WM_TRACING: (default off) * Whether we should do wm tracing on this display. - * TK_DISPLAY_IN_WARP: (default off) - * Indicates that we are in a pointer warp */ #define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) #define TK_DISPLAY_USE_IM (1 << 1) #define TK_DISPLAY_WM_TRACING (1 << 3) -#define TK_DISPLAY_IN_WARP (1 << 4) /* * One of the following structures exists for each error handler created by a * call to Tk_CreateErrorHandler. The structure is managed by tkError.c. */ @@ -677,11 +690,11 @@ struct ElArray *optionRootPtr; /* Top level of option hierarchy for this main * window. NULL means uninitialized. Managed * by tkOption.c. */ - Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageMaster + Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageModel * structures. Managed by tkImage.c. */ int strictMotif; /* This is linked to the tk_strictMotif global * variable. */ int alwaysShowSelection; /* This is linked to the * ::tk::AlwaysShowSelection variable. */ @@ -724,11 +737,11 @@ int screenNum; /* Index of screen for window, among all those * for dispPtr. */ Visual *visual; /* Visual to use for window. If not default, * MUST be set before X window is created. */ int depth; /* Number of bits/pixel. */ - Window window; /* X's id for window. NULL means window hasn't + Window window; /* X's id for window. None means window hasn't * actually been created yet, or it's been * deleted. */ struct TkWindow *childList; /* First in list of child windows, or NULL if * no children. List is in stacking order, * lowest window first.*/ @@ -872,13 +885,13 @@ #if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8) int ximGeneration; /* Used to invalidate XIC */ #endif /* TK_USE_INPUT_METHODS */ char *geomMgrName; /* Records the name of the geometry manager. */ struct TkWindow *maintainerPtr; - /* The geometry master for this window. The - * value is NULL if the window has no master or - * if its master is its parent. */ + /* The geometry container for this window. The + * value is NULL if the window has no container or + * if its container is its parent. */ #if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9) XIC inputContext; /* XIM input context. */ int ximGeneration; /* Used to invalidate XIC */ #endif /* TK_USE_INPUT_METHODS */ } TkWindow; @@ -892,11 +905,11 @@ XKeyEvent keyEvent; /* The real event from X11. */ #ifdef _WIN32 char trans_chars[XMaxTransChars]; /* translated characters */ unsigned char nbytes; -#elif !defined(MAC_OSC_TK) +#elif !defined(MAC_OSX_TK) char *charValuePtr; /* A pointer to a string that holds the key's * %A substitution text (before backslash * adding), or NULL if that has not been * computed yet. If non-NULL, this string was * allocated with ckalloc(). */ @@ -1002,10 +1015,15 @@ #define META_MASK (AnyModifier<<1) #define ALT_MASK (AnyModifier<<2) #define EXTENDED_MASK (AnyModifier<<3) +/* + * Buttons 8 and 9 are the Xbuttons (left and right side-buttons). On Windows/Mac, those + * are known as Buttons 4 and 5. At script level, they also get the numbers 4 and 5. + */ + #ifndef Button8 # define Button8 8 #endif #ifndef Button9 # define Button9 9 @@ -1032,12 +1050,10 @@ #define ALL_BUTTONS \ (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask \ |Button6Mask|Button7Mask|Button8Mask|Button9Mask) -MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int); - /* * Object types not declared in tkObj.c need to be mentioned here so they can * be properly registered with Tcl: */ @@ -1265,17 +1281,14 @@ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_WmObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -MODULE_SCOPE int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, - Tk_Window tkwin, Tcl_Obj *objPtr, - double *doublePtr); -MODULE_SCOPE int TkSetGeometryMaster(Tcl_Interp *interp, - Tk_Window tkwin, const char *master); -MODULE_SCOPE void TkFreeGeometryMaster(Tk_Window tkwin, - const char *master); +MODULE_SCOPE int TkSetGeometryContainer(Tcl_Interp *interp, + Tk_Window tkwin, const char *name); +MODULE_SCOPE void TkFreeGeometryContainer(Tk_Window tkwin, + const char *name); MODULE_SCOPE void TkEventInit(void); MODULE_SCOPE void TkRegisterObjTypes(void); MODULE_SCOPE int TkDeadAppObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const argv[]); @@ -1313,15 +1326,18 @@ MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *pad1Ptr, int *pad2Ptr); MODULE_SCOPE void TkFocusSplit(TkWindow *winPtr); MODULE_SCOPE void TkFocusJoin(TkWindow *winPtr); -MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin); MODULE_SCOPE void TkpDrawCharsInContext(Display * display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, int rangeStart, int rangeLength, int x, int y); +MODULE_SCOPE void TkpDrawAngledCharsInContext(Display * display, + Drawable drawable, GC gc, Tk_Font tkfont, + const char *source, int numBytes, int rangeStart, + int rangeLength, double x, double y, double angle); MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont, const char *source, int numBytes, int rangeStart, int rangeLength, int maxLength, int flags, int *lengthPtr); MODULE_SCOPE void TkUnderlineCharsInContext(Display *display, @@ -1331,41 +1347,39 @@ MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont, int c, struct TkFontAttributes *faPtr); MODULE_SCOPE void TkpDrawFrameEx(Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int highlightWidth, int borderWidth, int relief); -MODULE_SCOPE Tcl_Obj * TkNewWindowObj(Tk_Window tkwin); MODULE_SCOPE void TkpShowBusyWindow(TkBusy busy); MODULE_SCOPE void TkpHideBusyWindow(TkBusy busy); MODULE_SCOPE void TkpMakeTransparentWindowExist(Tk_Window tkwin, Window parent); MODULE_SCOPE void TkpCreateBusy(Tk_FakeWin *winPtr, Tk_Window tkRef, Window *parentPtr, Tk_Window tkParent, TkBusy busy); MODULE_SCOPE int TkBackgroundEvalObjv(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags); -MODULE_SCOPE void TkSendVirtualEvent(Tk_Window tgtWin, - const char *eventName, Tcl_Obj *detail); MODULE_SCOPE Tcl_Command TkMakeEnsemble(Tcl_Interp *interp, const char *nsname, const char *name, ClientData clientData, const TkEnsemble *map); MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE void TkInitEmbeddedConfigurationInformation( Tcl_Interp *interp); +MODULE_SCOPE void TkDoWarpWrtWin(TkDisplay *dispPtr); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); -MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr); MODULE_SCOPE int TkListCreateFrame(ClientData clientData, Tcl_Interp *interp, Tcl_Obj *listObj, int toplevel, Tcl_Obj *nameObj); MODULE_SCOPE void TkRotatePoint(double originX, double originY, double sine, double cosine, double *xPtr, double *yPtr); MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, TkSizeT, int lastOK, TkSizeT*); +#define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1) #ifdef _WIN32 #define TkParseColor XParseColor #else MODULE_SCOPE Status TkParseColor (Display * display, @@ -1410,19 +1424,12 @@ MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *); MODULE_SCOPE size_t TkUniCharToUtf(int, char *); MODULE_SCOPE const char *TkUtfPrev(const char *, const char *); #endif -#if TCL_MAJOR_VERSION > 8 -#define TkGetStringFromObj(objPtr, lenPtr) \ - (((objPtr)->bytes ? 0 : Tcl_GetString(objPtr)), \ - *(lenPtr) = (objPtr)->length, (objPtr)->bytes) -MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr, - size_t *lengthPtr); -#else -#define TkGetStringFromObj Tcl_GetStringFromObj -#define TkGetByteArrayFromObj Tcl_GetByteArrayFromObj +#if defined(_WIN32) && !defined(STATIC_BUILD) && TCL_MAJOR_VERSION < 9 +# define tcl_CreateFileHandler reserved9 #endif /* * Unsupported commands. */ Index: generic/tkIntDecls.h ================================================================== --- generic/tkIntDecls.h +++ generic/tkIntDecls.h @@ -4,11 +4,11 @@ * This file contains the declarations for all unsupported * functions that are exported by the Tk library. These * interfaces are not guaranteed to remain the same between * versions. Use at your own risk. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -556,22 +556,22 @@ /* 184 */ EXTERN void TkDrawAngledChars(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); +#ifdef MAC_OSX_TCL /* MACOSX */ /* 185 */ +EXTERN void TkpRedrawWidget(Tk_Window tkwin); +#endif /* MACOSX */ +#ifdef MAC_OSX_TCL /* MACOSX */ +/* 186 */ +EXTERN int TkpWillDrawWidget(Tk_Window tkwin); +#endif /* MACOSX */ +/* 187 */ EXTERN int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); -#ifdef MAC_OSX_TK /* AQUA */ -/* 186 */ -EXTERN void TkpRedrawWidget(Tk_Window tkwin); -#endif /* AQUA */ -#ifdef MAC_OSX_TK /* AQUA */ -/* 187 */ -EXTERN int TkpWillDrawWidget(Tk_Window tkwin); -#endif /* AQUA */ typedef struct TkIntStubs { int magic; void *hooks; @@ -785,31 +785,29 @@ const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 180 */ void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int firstChar, int lastChar); /* 181 */ void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */ int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */ void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 184 */ - int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 185 */ -#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ +#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */ + void (*reserved185)(void); +#endif /* UNIX */ +#if defined(_WIN32) /* WIN */ + void (*reserved185)(void); +#endif /* WIN */ +#ifdef MAC_OSX_TCL /* MACOSX */ + void (*tkpRedrawWidget) (Tk_Window tkwin); /* 185 */ +#endif /* MACOSX */ +#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */ void (*reserved186)(void); -#endif /* X11 */ +#endif /* UNIX */ #if defined(_WIN32) /* WIN */ void (*reserved186)(void); #endif /* WIN */ -#ifdef MAC_OSX_TK /* AQUA */ - void (*reserved186)(void); /* Dummy entry for stubs table backwards compatibility */ - void (*tkpRedrawWidget) (Tk_Window tkwin); /* 186 */ -#endif /* AQUA */ -#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ - void (*reserved187)(void); -#endif /* X11 */ -#if defined(_WIN32) /* WIN */ - void (*reserved187)(void); -#endif /* WIN */ -#ifdef MAC_OSX_TK /* AQUA */ - void (*reserved187)(void); /* Dummy entry for stubs table backwards compatibility */ - int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 187 */ -#endif /* AQUA */ +#ifdef MAC_OSX_TCL /* MACOSX */ + int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */ +#endif /* MACOSX */ + int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 187 */ } TkIntStubs; extern const TkIntStubs *tkIntStubsPtr; #ifdef __cplusplus @@ -1178,20 +1176,20 @@ (tkIntStubsPtr->tkUnderlineAngledTextLayout) /* 182 */ #define TkIntersectAngledTextLayout \ (tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */ #define TkDrawAngledChars \ (tkIntStubsPtr->tkDrawAngledChars) /* 184 */ -#define TkDebugPhotoStringMatchDef \ - (tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 185 */ -#ifdef MAC_OSX_TK /* AQUA */ +#ifdef MAC_OSX_TCL /* MACOSX */ #define TkpRedrawWidget \ - (tkIntStubsPtr->tkpRedrawWidget) /* 186 */ -#endif /* AQUA */ -#ifdef MAC_OSX_TK /* AQUA */ + (tkIntStubsPtr->tkpRedrawWidget) /* 185 */ +#endif /* MACOSX */ +#ifdef MAC_OSX_TCL /* MACOSX */ #define TkpWillDrawWidget \ - (tkIntStubsPtr->tkpWillDrawWidget) /* 187 */ -#endif /* AQUA */ + (tkIntStubsPtr->tkpWillDrawWidget) /* 186 */ +#endif /* MACOSX */ +#define TkDebugPhotoStringMatchDef \ + (tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 187 */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ @@ -1204,7 +1202,14 @@ #undef TkUnixDoOneXEvent_ #undef TkUnixSetMenubar_ #undef TkWmCleanup_ #undef TkSendCleanup_ #undef TkpTestsendCmd_ + +#if !defined(MAC_OSX_TK) +# undef TkpWillDrawWidget +# undef TkpRedrawWidget +# define TkpWillDrawWidget(w) 0 +# define TkpRedrawWidget(w) +#endif #endif /* _TKINTDECLS */ Index: generic/tkIntPlatDecls.h ================================================================== --- generic/tkIntPlatDecls.h +++ generic/tkIntPlatDecls.h @@ -4,11 +4,11 @@ * This file contains the declarations for all platform dependent * unsupported functions that are exported by the Tk library. These * interfaces are not guaranteed to remain the same between * versions. Use at your own risk. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * All rights reserved. */ #ifndef _TKINTPLATDECLS #define _TKINTPLATDECLS @@ -168,12 +168,11 @@ EXTERN unsigned int TkMacOSXButtonKeyState(void); /* 9 */ EXTERN void TkMacOSXClearMenubarActive(void); /* 10 */ EXTERN int TkMacOSXDispatchMenuEvent(int menuID, int index); -/* 11 */ -EXTERN void TkMacOSXInstallCursor(int resizeOverride); +/* Slot 11 is reserved */ /* 12 */ EXTERN void TkMacOSXHandleTearoffMenu(void); /* Slot 13 is reserved */ /* 14 */ EXTERN int TkMacOSXDoHLEvent(void *theEvent); @@ -197,13 +196,11 @@ EXTERN void TkMacOSXMakeRealWindowExist(TkWindow *winPtr); /* 24 */ EXTERN void * TkMacOSXMakeStippleMap(Drawable d1, Drawable d2); /* 25 */ EXTERN void TkMacOSXMenuClick(void); -/* 26 */ -EXTERN void TkMacOSXRegisterOffScreenWindow(Window window, - void *portPtr); +/* Slot 26 is reserved */ /* 27 */ EXTERN int TkMacOSXResizable(TkWindow *winPtr); /* 28 */ EXTERN void TkMacOSXSetHelpMenuItemCount(void); /* 29 */ @@ -212,12 +209,11 @@ EXTERN void TkMacOSXSetUpClippingRgn(Drawable drawable); /* 31 */ EXTERN void TkMacOSXSetUpGraphicsPort(GC gc, void *destPort); /* 32 */ EXTERN void TkMacOSXUpdateClipRgn(TkWindow *winPtr); -/* 33 */ -EXTERN void TkMacOSXUnregisterMacWindow(void *portPtr); +/* Slot 33 is reserved */ /* 34 */ EXTERN int TkMacOSXUseMenuID(short macID); /* 35 */ EXTERN Region TkMacOSXVisableClipRgn(TkWindow *winPtr); /* 36 */ @@ -246,11 +242,11 @@ EXTERN int TkpIsWindowFloating(void *window); /* 47 */ EXTERN Tk_Window TkpGetCapture(void); /* Slot 48 is reserved */ /* 49 */ -EXTERN Tk_Window TkGetTransientMaster(TkWindow *winPtr); +EXTERN Tk_Window TkMacOSXGetContainer(TkWindow *winPtr); /* 50 */ EXTERN int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state); /* 51 */ EXTERN void TkGenWMDestroyEvent(Tk_Window tkwin); @@ -403,11 +399,11 @@ void (*tkpWmSetState) (TkWindow *winPtr, int state); /* 6 */ void (*tkAboutDlg) (void); /* 7 */ unsigned int (*tkMacOSXButtonKeyState) (void); /* 8 */ void (*tkMacOSXClearMenubarActive) (void); /* 9 */ int (*tkMacOSXDispatchMenuEvent) (int menuID, int index); /* 10 */ - void (*tkMacOSXInstallCursor) (int resizeOverride); /* 11 */ + void (*reserved11)(void); void (*tkMacOSXHandleTearoffMenu) (void); /* 12 */ void (*reserved13)(void); int (*tkMacOSXDoHLEvent) (void *theEvent); /* 14 */ void (*reserved15)(void); Window (*tkMacOSXGetXWindow) (void *macWinPtr); /* 16 */ @@ -418,18 +414,18 @@ void (*tkMacOSXInvalidateWindow) (MacDrawable *macWin, int flag); /* 21 */ int (*tkMacOSXIsCharacterMissing) (Tk_Font tkfont, unsigned int searchChar); /* 22 */ void (*tkMacOSXMakeRealWindowExist) (TkWindow *winPtr); /* 23 */ void * (*tkMacOSXMakeStippleMap) (Drawable d1, Drawable d2); /* 24 */ void (*tkMacOSXMenuClick) (void); /* 25 */ - void (*tkMacOSXRegisterOffScreenWindow) (Window window, void *portPtr); /* 26 */ + void (*reserved26)(void); int (*tkMacOSXResizable) (TkWindow *winPtr); /* 27 */ void (*tkMacOSXSetHelpMenuItemCount) (void); /* 28 */ void (*tkMacOSXSetScrollbarGrow) (TkWindow *winPtr, int flag); /* 29 */ void (*tkMacOSXSetUpClippingRgn) (Drawable drawable); /* 30 */ void (*tkMacOSXSetUpGraphicsPort) (GC gc, void *destPort); /* 31 */ void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */ - void (*tkMacOSXUnregisterMacWindow) (void *portPtr); /* 33 */ + void (*reserved33)(void); int (*tkMacOSXUseMenuID) (short macID); /* 34 */ Region (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */ void (*tkMacOSXWinBounds) (TkWindow *winPtr, void *geometry); /* 36 */ void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */ int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */ @@ -441,11 +437,11 @@ MacDrawable * (*tkMacOSXGetHostToplevel) (TkWindow *winPtr); /* 44 */ void (*tkMacOSXPreprocessMenu) (void); /* 45 */ int (*tkpIsWindowFloating) (void *window); /* 46 */ Tk_Window (*tkpGetCapture) (void); /* 47 */ void (*reserved48)(void); - Tk_Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */ + Tk_Window (*tkMacOSXGetContainer) (TkWindow *winPtr); /* 49 */ int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */ void (*tkGenWMDestroyEvent) (Tk_Window tkwin); /* 51 */ void (*tkMacOSXSetDrawingEnabled) (TkWindow *winPtr, int flag); /* 52 */ unsigned long (*tkpGetMS) (void); /* 53 */ void * (*tkMacOSXDrawable) (Drawable drawable); /* 54 */ @@ -629,12 +625,11 @@ (tkIntPlatStubsPtr->tkMacOSXButtonKeyState) /* 8 */ #define TkMacOSXClearMenubarActive \ (tkIntPlatStubsPtr->tkMacOSXClearMenubarActive) /* 9 */ #define TkMacOSXDispatchMenuEvent \ (tkIntPlatStubsPtr->tkMacOSXDispatchMenuEvent) /* 10 */ -#define TkMacOSXInstallCursor \ - (tkIntPlatStubsPtr->tkMacOSXInstallCursor) /* 11 */ +/* Slot 11 is reserved */ #define TkMacOSXHandleTearoffMenu \ (tkIntPlatStubsPtr->tkMacOSXHandleTearoffMenu) /* 12 */ /* Slot 13 is reserved */ #define TkMacOSXDoHLEvent \ (tkIntPlatStubsPtr->tkMacOSXDoHLEvent) /* 14 */ @@ -655,12 +650,11 @@ (tkIntPlatStubsPtr->tkMacOSXMakeRealWindowExist) /* 23 */ #define TkMacOSXMakeStippleMap \ (tkIntPlatStubsPtr->tkMacOSXMakeStippleMap) /* 24 */ #define TkMacOSXMenuClick \ (tkIntPlatStubsPtr->tkMacOSXMenuClick) /* 25 */ -#define TkMacOSXRegisterOffScreenWindow \ - (tkIntPlatStubsPtr->tkMacOSXRegisterOffScreenWindow) /* 26 */ +/* Slot 26 is reserved */ #define TkMacOSXResizable \ (tkIntPlatStubsPtr->tkMacOSXResizable) /* 27 */ #define TkMacOSXSetHelpMenuItemCount \ (tkIntPlatStubsPtr->tkMacOSXSetHelpMenuItemCount) /* 28 */ #define TkMacOSXSetScrollbarGrow \ @@ -669,12 +663,11 @@ (tkIntPlatStubsPtr->tkMacOSXSetUpClippingRgn) /* 30 */ #define TkMacOSXSetUpGraphicsPort \ (tkIntPlatStubsPtr->tkMacOSXSetUpGraphicsPort) /* 31 */ #define TkMacOSXUpdateClipRgn \ (tkIntPlatStubsPtr->tkMacOSXUpdateClipRgn) /* 32 */ -#define TkMacOSXUnregisterMacWindow \ - (tkIntPlatStubsPtr->tkMacOSXUnregisterMacWindow) /* 33 */ +/* Slot 33 is reserved */ #define TkMacOSXUseMenuID \ (tkIntPlatStubsPtr->tkMacOSXUseMenuID) /* 34 */ #define TkMacOSXVisableClipRgn \ (tkIntPlatStubsPtr->tkMacOSXVisableClipRgn) /* 35 */ #define TkMacOSXWinBounds \ @@ -699,12 +692,12 @@ #define TkpIsWindowFloating \ (tkIntPlatStubsPtr->tkpIsWindowFloating) /* 46 */ #define TkpGetCapture \ (tkIntPlatStubsPtr->tkpGetCapture) /* 47 */ /* Slot 48 is reserved */ -#define TkGetTransientMaster \ - (tkIntPlatStubsPtr->tkGetTransientMaster) /* 49 */ +#define TkMacOSXGetContainer \ + (tkIntPlatStubsPtr->tkMacOSXGetContainer) /* 49 */ #define TkGenerateButtonEvent \ (tkIntPlatStubsPtr->tkGenerateButtonEvent) /* 50 */ #define TkGenWMDestroyEvent \ (tkIntPlatStubsPtr->tkGenWMDestroyEvent) /* 51 */ #define TkMacOSXSetDrawingEnabled \ @@ -796,13 +789,14 @@ #undef TkUnixSetMenubar_ #undef TkWmCleanup_ #undef TkSendCleanup_ #undef TkpTestsendCmd_ #undef TkGenerateActivateEvents_ +#undef TkMacOSXSetUpClippingRgn #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #undef TkWinGetPlatformId #define TkWinGetPlatformId() (2) /* VER_PLATFORM_WIN32_NT */ #endif /* _TKINTPLATDECLS */ Index: generic/tkIntXlibDecls.h ================================================================== --- generic/tkIntXlibDecls.h +++ generic/tkIntXlibDecls.h @@ -4,11 +4,11 @@ * This file contains the declarations for all platform dependent * unsupported functions that are exported by the Tk library. These * interfaces are not guaranteed to remain the same between * versions. Use at your own risk. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * All rights reserved. */ #ifndef _TKINTXLIBDECLS #define _TKINTXLIBDECLS @@ -35,10 +35,14 @@ #else # ifndef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT # endif #endif + +#if defined(MAC_OSX_TK) && !defined(MAC_OSX_TCL) +# define MAC_OSX_TCL 1 +#endif typedef int (*XAfterFunction) ( /* WARNING, this type not in Xlib spec */ Display* /* display */ ); @@ -763,11 +767,14 @@ EXTERN Status XIconifyWindow(Display *d, Window w, int i); /* 104 */ EXTERN Status XWithdrawWindow(Display *d, Window w, int i); /* 105 */ EXTERN XHostAddress * XListHosts(Display *d, int *i, Bool *b); -/* Slot 106 is reserved */ +/* 106 */ +EXTERN int XSetClipRectangles(Display *display, GC gc, + int clip_x_origin, int clip_y_origin, + XRectangle rectangles[], int n, int ordering); /* 107 */ EXTERN int XFlush(Display *display); /* 108 */ EXTERN int XGrabServer(Display *display); /* 109 */ @@ -1160,11 +1167,11 @@ Status (*xGetWindowAttributes) (Display *d, Window w, XWindowAttributes *x); /* 101 */ Status (*xGetWMColormapWindows) (Display *d, Window w, Window **wpp, int *ip); /* 102 */ Status (*xIconifyWindow) (Display *d, Window w, int i); /* 103 */ Status (*xWithdrawWindow) (Display *d, Window w, int i); /* 104 */ XHostAddress * (*xListHosts) (Display *d, int *i, Bool *b); /* 105 */ - void (*reserved106)(void); + int (*xSetClipRectangles) (Display *display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 106 */ int (*xFlush) (Display *display); /* 107 */ int (*xGrabServer) (Display *display); /* 108 */ int (*xUngrabServer) (Display *display); /* 109 */ int (*xFree) (void *data); /* 110 */ int (*xNoOp) (Display *display); /* 111 */ @@ -1746,11 +1753,12 @@ (tkIntXlibStubsPtr->xIconifyWindow) /* 103 */ #define XWithdrawWindow \ (tkIntXlibStubsPtr->xWithdrawWindow) /* 104 */ #define XListHosts \ (tkIntXlibStubsPtr->xListHosts) /* 105 */ -/* Slot 106 is reserved */ +#define XSetClipRectangles \ + (tkIntXlibStubsPtr->xSetClipRectangles) /* 106 */ #define XFlush \ (tkIntXlibStubsPtr->xFlush) /* 107 */ #define XGrabServer \ (tkIntXlibStubsPtr->xGrabServer) /* 108 */ #define XUngrabServer \ Index: generic/tkListbox.c ================================================================== --- generic/tkListbox.c +++ generic/tkListbox.c @@ -3,12 +3,12 @@ * * This module implements listbox widgets for the Tk toolkit. A listbox * displays a collection of strings, one per line, and provides scrolling * and selection. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -577,11 +577,11 @@ if (ConfigureListbox(interp, listPtr, objc-2, objv+2) != TCL_OK) { Tk_DestroyWindow(listPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(listPtr->tkwin)); return TCL_OK; } /* *---------------------------------------------------------------------- @@ -840,11 +840,11 @@ } result = GetListboxIndex(interp, listPtr, objv[2], 1, &index); if (result != TCL_OK) { break; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); result = TCL_OK; break; case COMMAND_INSERT: if (objc < 3) { @@ -904,11 +904,11 @@ case COMMAND_ITEMCONFIGURE: { ItemAttr *attrPtr; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, - "index ?-option? ?value? ?-option value ...?"); + "index ?-option value ...?"); result = TCL_ERROR; break; } result = GetListboxIndex(interp, listPtr, objv[2], 0, &index); @@ -1114,11 +1114,11 @@ result = Tcl_ListObjIndex(interp, listPtr->listObj, index, &el); if (result != TCL_OK) { return result; } - stringRep = TkGetStringFromObj(el, &stringLen); + stringRep = Tcl_GetStringFromObj(el, &stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); if (listPtr->justify == TK_JUSTIFY_LEFT) { x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; @@ -2077,11 +2077,11 @@ /* * Draw the actual text of this item. */ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = TkGetStringFromObj(curElement, &stringLen); + stringRep = Tcl_GetStringFromObj(curElement, &stringLen); textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; @@ -2261,11 +2261,11 @@ result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); if (result != TCL_OK) { continue; } - text = TkGetStringFromObj(element, &textLength); + text = Tcl_GetStringFromObj(element, &textLength); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength); if (pixelWidth > listPtr->maxWidth) { listPtr->maxWidth = pixelWidth; } @@ -2339,11 +2339,11 @@ /* * Check if any of the new elements are wider than the current widest; * if so, update our notion of "widest." */ - stringRep = TkGetStringFromObj(objv[i], &length); + stringRep = Tcl_GetStringFromObj(objv[i], &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth > listPtr->maxWidth) { listPtr->maxWidth = pixelWidth; } } @@ -2498,11 +2498,11 @@ * element to disappear for us to have to recompute the width. */ if (widthChanged == 0) { Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); - stringRep = TkGetStringFromObj(element, &length); + stringRep = Tcl_GetStringFromObj(element, &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth == listPtr->maxWidth) { widthChanged = 1; } } @@ -2740,11 +2740,11 @@ TkSizeT idx; const char *stringRep; result = TkGetIntForIndex(indexObj, listPtr->nElements - 1, lastOK, &idx); if (result == TCL_OK) { - if (idx + 1 > (TkSizeT)listPtr->nElements + 1) { + if ((idx != TCL_INDEX_NONE) && (idx > (TkSizeT)listPtr->nElements)) { idx = listPtr->nElements; } *indexPtr = (int)idx; return TCL_OK; } @@ -3146,11 +3146,11 @@ if (needNewline) { Tcl_DStringAppend(&selection, "\n", 1); } Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = TkGetStringFromObj(curElement, &stringLen); + stringRep = Tcl_GetStringFromObj(curElement, &stringLen); Tcl_DStringAppend(&selection, stringRep, stringLen); needNewline = 1; } } @@ -3227,11 +3227,11 @@ static void GenerateListboxSelectEvent( Listbox *listPtr) /* Information about widget. */ { - TkSendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL); + Tk_SendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL); } /* *---------------------------------------------------------------------- * Index: generic/tkMacWinMenu.c ================================================================== --- generic/tkMacWinMenu.c +++ generic/tkMacWinMenu.c @@ -2,11 +2,11 @@ * tkMacWinMenu.c -- * * This module implements the common elements of the Mac and Windows * specific features of menus. This file is not used for UNIX. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkMain.c ================================================================== --- generic/tkMain.c +++ generic/tkMain.c @@ -98,11 +98,11 @@ * always claim to be running on a tty. This probably isn't the right way * to do it. */ #if !defined(STATIC_BUILD) - if (tclStubsPtr->reserved9 && tclIntPlatStubsPtr->tclpIsAtty) { + if (tclStubsPtr->tcl_CreateFileHandler && tclIntPlatStubsPtr->tclpIsAtty) { /* We are running on Cygwin */ return tclIntPlatStubsPtr->tclpIsAtty(fd); } #endif handle = GetStdHandle(STD_INPUT_HANDLE + fd); @@ -187,11 +187,11 @@ } } #if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD) - if (tclStubsPtr->reserved9) { + if (tclStubsPtr->tcl_CreateFileHandler) { /* We are running win32 Tk under Cygwin, so let's check * whether the env("DISPLAY") variable or the -display * argument is set. If so, we really want to run the * Tk_MainEx function of libtk8.?.dll, not this one. */ if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) { @@ -219,11 +219,11 @@ Tcl_Preserve(interp); #if defined(_WIN32) #if !defined(STATIC_BUILD) /* If compiled for Win32 but running on Cygwin, don't use console */ - if (!tclStubsPtr->reserved9) + if (!tclStubsPtr->tcl_CreateFileHandler) #endif Tk_InitConsoleChannels(interp); #endif #ifdef MAC_OSX_TK @@ -401,23 +401,28 @@ */ static void StdinProc( ClientData clientData, /* The state of interactive cmd line */ - int mask) /* Not used. */ + TCL_UNUSED(int)) { char *cmd; int code; - size_t count; + TkSizeT count; InteractiveState *isPtr = (InteractiveState *)clientData; Tcl_Channel chan = isPtr->input; Tcl_Interp *interp = isPtr->interp; - (void)mask; + Tcl_DString savedEncoding; - count = (size_t)Tcl_Gets(chan, &isPtr->line); + Tcl_DStringInit(&savedEncoding); + Tcl_GetChannelOption(NULL, chan, "-encoding", &savedEncoding); + Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8"); + count = Tcl_Gets(chan, &isPtr->line); + Tcl_SetChannelOption(NULL, chan, "-encoding", Tcl_DStringValue(&savedEncoding)); + Tcl_DStringFree(&savedEncoding); - if (count == (size_t)-1 && !isPtr->gotPartial) { + if ((count == TCL_IO_FAILURE) && !isPtr->gotPartial) { if (isPtr->tty) { Tcl_Exit(0); } else { Tcl_DeleteChannelHandler(chan, StdinProc, isPtr); } Index: generic/tkMenu.c ================================================================== --- generic/tkMenu.c +++ generic/tkMenu.c @@ -4,12 +4,12 @@ * This file contains most of the code for implementing menus in Tk. It takes * care of all of the generic (platform-independent) parts of menus, and is * supplemented by platform-specific files. The geometry calculation and * drawing code for menus is in the file tkMenuDraw.c * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -37,16 +37,16 @@ * To handle all of the constraints, Tk menubars and tearoff menus are * implemented using menu clones. Menu clones are full menus in their own * right; they have a Tk window and pathname associated with them; they have a * TkMenu structure and array of entries. However, they are linked with the * original menu that they were cloned from. They reflect the attributes of the - * original, or "master", menu. So if an item is added to a menu, and that + * original, or "main", menu. So if an item is added to a menu, and that * menu has clones, then the item must be added to all of its clones also. * Menus are cloned when a menu is torn-off or when a menu is assigned as a * menubar using the "-menu" option of the toplevel's pathname configure * subcommand. When a clone is destroyed, only the clone is destroyed, but - * when the master menu is destroyed, all clones are also destroyed. This + * when the main menu is destroyed, all clones are also destroyed. This * allows the developer to just deal with one set of menus when creating and * destroying. * * Clones are rather tricky when a menu with cascade entries is cloned (such * as a menubar). Not only does the menu have to be cloned, but each cascade @@ -459,11 +459,11 @@ menuPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr, MenuCmdDeletedProc); menuPtr->active = TCL_INDEX_NONE; menuPtr->cursorPtr = NULL; - menuPtr->masterMenuPtr = menuPtr; + menuPtr->mainMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; TkMenuInitializeDrawingFields(menuPtr); Tk_SetClass(menuPtr->tkwin, "Menu"); Tk_SetClassProcs(menuPtr->tkwin, &menuClass, menuPtr); @@ -516,21 +516,21 @@ while (cascadeListPtr != NULL) { nextCascadePtr = cascadeListPtr->nextCascadePtr; /* - * If we have a new master menu, and an existing cloned menu + * If we have a new main menu, and an existing cloned menu * points to this menu in a cascade entry, we have to clone the * new menu and point the entry to the clone instead of the menu * we are creating. Otherwise, ConfigureMenuEntry will hook up the * platform-specific cascade linkages now that the menu we are * creating exists. */ - if ((menuPtr->masterMenuPtr != menuPtr) - || ((menuPtr->masterMenuPtr == menuPtr) - && ((cascadeListPtr->menuPtr->masterMenuPtr + if ((menuPtr->mainMenuPtr != menuPtr) + || ((menuPtr->mainMenuPtr == menuPtr) + && ((cascadeListPtr->menuPtr->mainMenuPtr == cascadeListPtr->menuPtr)))) { newObjv[0] = Tcl_NewStringObj("-menu", -1); newObjv[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin),-1); Tcl_IncrRefCount(newObjv[0]); Tcl_IncrRefCount(newObjv[1]); @@ -591,11 +591,11 @@ Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin)); topLevelListPtr = nextPtr; } } - Tcl_SetObjResult(interp, TkNewWindowObj(menuPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(menuPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -843,13 +843,12 @@ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1)); - } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); - } + } else + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } case MENU_INSERT: if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, @@ -1106,25 +1105,25 @@ { int i; TkMenu *menuInstancePtr; TkMenuEntry *cascadePtr, *nextCascadePtr; Tcl_Obj *newObjv[2]; - TkMenu *parentMasterMenuPtr; - TkMenuEntry *parentMasterEntryPtr; + TkMenu *parentMainMenuPtr; + TkMenuEntry *parentMainEntryPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If the menu has any cascade menu entries pointing to it, the cascade * entries need to be told that the menu is going away. We need to clear * the menu ptr field in the menu reference at this point in the code so * that everything else can forget about this menu properly. We also need - * to reset -menu field of all entries that are not master menus back to - * this entry name if this is a master menu pointed to by another master + * to reset -menu field of all entries that are not main menus back to + * this entry name if this is a main menu pointed to by another main * menu. If there is a clone menu that points to this menu, then this menu * is itself a clone, so when this menu goes away, the -menu field of the - * pointing entry must be set back to this menu's master menu name so that + * pointing entry must be set back to this menu's main menu name so that * later if another menu is created the cascade hierarchy can be * maintained. */ TkpDestroyMenu(menuPtr); @@ -1138,18 +1137,18 @@ } for (; cascadePtr != NULL; cascadePtr = nextCascadePtr) { nextCascadePtr = cascadePtr->nextCascadePtr; - if (menuPtr->masterMenuPtr != menuPtr) { + if (menuPtr->mainMenuPtr != menuPtr) { Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); - parentMasterMenuPtr = cascadePtr->menuPtr->masterMenuPtr; - parentMasterEntryPtr = - parentMasterMenuPtr->entries[cascadePtr->index]; + parentMainMenuPtr = cascadePtr->menuPtr->mainMenuPtr; + parentMainEntryPtr = + parentMainMenuPtr->entries[cascadePtr->index]; newObjv[0] = menuNamePtr; - newObjv[1] = parentMasterEntryPtr->namePtr; + newObjv[1] = parentMainEntryPtr->namePtr; /* * It is possible that the menu info is out of sync, and these * things point to NULL, so verify existence [Bug: 3402] */ @@ -1164,22 +1163,22 @@ } else { ConfigureMenuEntry(cascadePtr, 0, NULL); } } - if (menuPtr->masterMenuPtr != menuPtr) { - for (menuInstancePtr = menuPtr->masterMenuPtr; + if (menuPtr->mainMenuPtr != menuPtr) { + for (menuInstancePtr = menuPtr->mainMenuPtr; menuInstancePtr != NULL; menuInstancePtr = menuInstancePtr->nextInstancePtr) { if (menuInstancePtr->nextInstancePtr == menuPtr) { menuInstancePtr->nextInstancePtr = menuInstancePtr->nextInstancePtr->nextInstancePtr; break; } } } else if (menuPtr->nextInstancePtr != NULL) { - Tcl_Panic("Attempting to delete master menu when there are still clones"); + Tcl_Panic("Attempting to delete main menu when there are still clones"); } /* * Free up all the stuff that requires special handling, then let * Tk_FreeConfigOptions handle all the standard option-related stuff. @@ -1215,12 +1214,12 @@ * * TkDestroyMenu -- * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of a menu at a safe time (when no-one is - * using it anymore). If called on a master instance, destroys all of the - * slave instances. If called on a non-master instance, just destroys + * using it anymore). If called on a main instance, destroys all of the + * instances. If called on a non-main instance, just destroys * that instance. * * Results: * None. * @@ -1262,11 +1261,11 @@ nextTopLevelPtr = topLevelListPtr->nextPtr; TkpSetWindowMenuBar(topLevelListPtr->tkwin, NULL); topLevelListPtr = nextTopLevelPtr; } } - if (menuPtr->masterMenuPtr == menuPtr) { + if (menuPtr->mainMenuPtr == menuPtr) { while (menuPtr->nextInstancePtr != NULL) { menuInstancePtr = menuPtr->nextInstancePtr; menuPtr->nextInstancePtr = menuInstancePtr->nextInstancePtr; if (menuInstancePtr->tkwin != NULL) { Tk_Window tkwin = menuInstancePtr->tkwin; @@ -1410,11 +1409,11 @@ * Free up all the stuff that requires special handling, then let * Tk_FreeConfigOptions handle all the standard option-related stuff. */ if (mePtr->type == CASCADE_ENTRY) { - if (menuPtr->masterMenuPtr != menuPtr) { + if (menuPtr->mainMenuPtr != menuPtr) { TkMenu *destroyThis = NULL; TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr; /* * The menu as a whole is a clone. We must delete the clone of the @@ -1430,11 +1429,11 @@ * already been reset to point to the original menu. In that * case we have nothing special to do. */ if ((destroyThis != NULL) - && (destroyThis->masterMenuPtr == destroyThis)) { + && (destroyThis->mainMenuPtr == destroyThis)) { destroyThis = NULL; } } UnhookCascadeEntry(mePtr); menuRefPtr = mePtr->childMenuRefPtr; @@ -1536,18 +1535,18 @@ TkMenu *menuListPtr, *cleanupPtr; int result; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; + for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { menuListPtr->errorStructPtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions)); result = Tk_SetOptions(interp, menuListPtr, tsdPtr->menuOptionTable, objc, objv, menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL); if (result != TCL_OK) { - for (cleanupPtr = menuPtr->masterMenuPtr; + for (cleanupPtr = menuPtr->mainMenuPtr; cleanupPtr != menuListPtr; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; @@ -1577,11 +1576,11 @@ * toplevel windows. Also, since this gets called before CloneMenu * has a chance to set the menuType field, we have to look at the * menuTypeName field to tell that this is a menu bar. */ - if (menuListPtr->menuType == MASTER_MENU) { + if (menuListPtr->menuType == MAIN_MENU) { int typeFlag = TK_MAKE_MENU_POPUP; Tk_Window tkwin = menuPtr->tkwin; /* * Work out if we are the child of a menubar or a popup. @@ -1612,11 +1611,11 @@ if (menuListPtr->tearoff) { if ((menuListPtr->numEntries == 0) || (menuListPtr->entries[0]->type != TEAROFF_ENTRY)) { if (MenuNewEntry(menuListPtr, 0, TEAROFF_ENTRY) == NULL) { - for (cleanupPtr = menuPtr->masterMenuPtr; + for (cleanupPtr = menuPtr->mainMenuPtr; cleanupPtr != menuListPtr; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; @@ -1629,11 +1628,10 @@ return TCL_ERROR; } } } else if ((menuListPtr->numEntries > 0) && (menuListPtr->entries[0]->type == TEAROFF_ENTRY)) { - int i; Tcl_EventuallyFree(menuListPtr->entries[0], (Tcl_FreeProc *) DestroyMenuEntry); for (i = 0; i < (int)menuListPtr->numEntries - 1; i++) { menuListPtr->entries[i] = menuListPtr->entries[i + 1]; @@ -1662,11 +1660,11 @@ } TkEventuallyRecomputeMenu(menuListPtr); } - for (cleanupPtr = menuPtr->masterMenuPtr; cleanupPtr != NULL; + for (cleanupPtr = menuPtr->mainMenuPtr; cleanupPtr != NULL; cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_FreeSavedOptions(cleanupPtr->errorStructPtr); ckfree(cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } @@ -1710,16 +1708,16 @@ */ if (mePtr->labelPtr == NULL) { mePtr->labelLength = 0; } else { - (void)TkGetStringFromObj(mePtr->labelPtr, &mePtr->labelLength); + (void)Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength); } if (mePtr->accelPtr == NULL) { mePtr->accelLength = 0; } else { - (void)TkGetStringFromObj(mePtr->accelPtr, &mePtr->accelLength); + (void)Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength); } /* * If this is a cascade entry, the platform-specific data of the child * menu has to be updated. Also, the links that point to parents and @@ -1824,11 +1822,10 @@ mePtr->selectImage = image; if ((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY)) { Tcl_Obj *valuePtr; - const char *name; if (mePtr->namePtr == NULL) { if (mePtr->labelPtr == NULL) { mePtr->namePtr = NULL; } else { @@ -1988,18 +1985,18 @@ const char *newCascadeName; (void)dummy; /* * Cascades are kind of tricky here. This is special case #3 in the - * comment at the top of this file. Basically, if a menu is the master + * comment at the top of this file. Basically, if a menu is the main * menu of a clone chain, and has an entry with a cascade menu, the clones * of the menu will point to clones of the cascade menu. We have to * destroy the clones of the cascades, clone the new cascade menu, and * configure the entry to point to the new clone. */ - mePtr = menuPtr->masterMenuPtr->entries[index]; + mePtr = menuPtr->mainMenuPtr->entries[index]; if (mePtr->type == CASCADE_ENTRY) { oldCascadePtr = mePtr->namePtr; if (oldCascadePtr != NULL) { Tcl_IncrRefCount(oldCascadePtr); } @@ -2040,11 +2037,11 @@ cascadeMenuRefPtr = TkFindMenuReferences(menuPtr->interp, newCascadeName); } } - for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr; + for (menuListPtr = menuPtr->mainMenuPtr->nextInstancePtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { mePtr = menuListPtr->entries[index]; @@ -2127,11 +2124,12 @@ { int i; const char *string; if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) { - if (*indexPtr != TCL_INDEX_NONE) { + /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ + if (*indexPtr != TCL_INDEX_NONE || Tcl_GetString(objPtr)[0] != '-') { if (*indexPtr >= menuPtr->numEntries) { *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1); } return TCL_OK; } @@ -2359,11 +2357,11 @@ } else { index = menuPtr->numEntries; } if (index == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad index \"%s\"", Tcl_GetString(indexPtr))); + "bad menu entry index \"%s\"", Tcl_GetString(indexPtr))); Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL); return TCL_ERROR; } if (menuPtr->tearoff && (index == 0)) { index = 1; @@ -2380,11 +2378,11 @@ /* * Now we have to add an entry for every instance related to this menu. */ - for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; + for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { mePtr = MenuNewEntry(menuListPtr, index, type); if (mePtr == NULL) { return TCL_ERROR; @@ -2391,11 +2389,11 @@ } if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) { TkMenu *errorMenuPtr; TkSizeT i; - for (errorMenuPtr = menuPtr->masterMenuPtr; + for (errorMenuPtr = menuPtr->mainMenuPtr; errorMenuPtr != NULL; errorMenuPtr = errorMenuPtr->nextInstancePtr) { Tcl_EventuallyFree(errorMenuPtr->entries[index], (Tcl_FreeProc *) DestroyMenuEntry); for (i = index; i < errorMenuPtr->numEntries - 1; i++) { @@ -2415,20 +2413,20 @@ /* * If a menu has cascades, then every instance of the menu has to have * its own parallel cascade structure. So adding an entry to a menu * with clones means that the menu that the entry points to has to be - * cloned for every clone the master menu has. This is special case #2 + * cloned for every clone the main menu has. This is special case #2 * in the comment at the top of this file. */ if ((menuPtr != menuListPtr) && (type == CASCADE_ENTRY)) { if ((mePtr->namePtr != NULL) && (mePtr->childMenuRefPtr != NULL) && (mePtr->childMenuRefPtr->menuPtr != NULL)) { TkMenu *cascadeMenuPtr = - mePtr->childMenuRefPtr->menuPtr->masterMenuPtr; + mePtr->childMenuRefPtr->menuPtr->mainMenuPtr; Tcl_Obj *newCascadePtr, *newObjv[2]; Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), -1); Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1); @@ -2698,11 +2696,11 @@ int menuType, i; TkMenuReferences *menuRefPtr; Tcl_Obj *menuDupCommandArray[4]; if (newMenuTypePtr == NULL) { - menuType = MASTER_MENU; + menuType = MAIN_MENU; } else { if (Tcl_GetIndexFromObjStruct(menuPtr->interp, newMenuTypePtr, menuTypeStrings, sizeof(char *), "menu type", 0, &menuType) != TCL_OK) { return TCL_ERROR; } @@ -2733,31 +2731,31 @@ ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, newMenuNamePtr)) != NULL) && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) { TkMenu *newMenuPtr = menuRefPtr->menuPtr; Tcl_Obj *newObjv[3]; - int i, numElements; + int numElements; /* * Now put this newly created menu into the parent menu's instance * chain. */ if (menuPtr->nextInstancePtr == NULL) { menuPtr->nextInstancePtr = newMenuPtr; - newMenuPtr->masterMenuPtr = menuPtr->masterMenuPtr; + newMenuPtr->mainMenuPtr = menuPtr->mainMenuPtr; } else { - TkMenu *masterMenuPtr; + TkMenu *mainMenuPtr; - masterMenuPtr = menuPtr->masterMenuPtr; - newMenuPtr->nextInstancePtr = masterMenuPtr->nextInstancePtr; - masterMenuPtr->nextInstancePtr = newMenuPtr; - newMenuPtr->masterMenuPtr = masterMenuPtr; + mainMenuPtr = menuPtr->mainMenuPtr; + newMenuPtr->nextInstancePtr = mainMenuPtr->nextInstancePtr; + mainMenuPtr->nextInstancePtr = newMenuPtr; + newMenuPtr->mainMenuPtr = mainMenuPtr; } /* - * Add the master menu's window to the bind tags for this window after + * Add the main menu's window to the bind tags for this window after * this window's tag. This is so the user can bind to either this * clone (which may not be easy to do) or the entire menu clone * structure. */ @@ -2779,11 +2777,11 @@ &elementPtr); windowName = Tcl_GetString(elementPtr); if (strcmp(windowName, Tk_PathName(newMenuPtr->tkwin)) == 0) { Tcl_Obj *newElementPtr = Tcl_NewStringObj( - Tk_PathName(newMenuPtr->masterMenuPtr->tkwin), -1); + Tk_PathName(newMenuPtr->mainMenuPtr->tkwin), -1); /* * The newElementPtr will have its refCount incremented * here, so we don't need to worry about it any more. */ @@ -3179,11 +3177,11 @@ if (menuRefPtr->menuPtr != NULL) { TkMenu *instancePtr; menuPtr = menuRefPtr->menuPtr; - for (instancePtr = menuPtr->masterMenuPtr; + for (instancePtr = menuPtr->mainMenuPtr; instancePtr != NULL; instancePtr = instancePtr->nextInstancePtr) { if (instancePtr->menuType == MENUBAR && instancePtr->parentTopLevelPtr == tkwin) { RecursivelyDeleteMenu(instancePtr); @@ -3527,11 +3525,11 @@ { TkMenu *menuListPtr; int numDeleted, i, j; numDeleted = last + 1 - first; - for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; + for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { for (i = last; i >= first; i--) { Tcl_EventuallyFree(menuListPtr->entries[i], (Tcl_FreeProc *) DestroyMenuEntry); } for (i = last + 1; i < (int)menuListPtr->numEntries; i++) { Index: generic/tkMenu.h ================================================================== --- generic/tkMenu.h +++ generic/tkMenu.h @@ -2,11 +2,11 @@ * tkMenu.h -- * * Declarations shared among all of the files that implement menu * widgets. * - * Copyright (c) 1996-1998 by Sun Microsystems, Inc. + * Copyright © 1996-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -183,11 +183,11 @@ int index; /* Need to know which index we are. This is * zero-based. This is the top-left entry of * the menu. */ /* - * Bookeeping for master menus and cascade menus. + * Bookeeping for main menus and cascade menus. */ struct TkMenuReferences *childMenuRefPtr; /* A pointer to the hash table entry for the * child menu. Stored here when the menu entry @@ -264,11 +264,11 @@ TkMenuEntry **entries; /* Array of pointers to all the entries in the * menu. NULL means no entries. */ TkSizeT numEntries; /* Number of elements in entries. */ TkSizeT active; /* Index of active entry. TCL_INDEX_NONE means * nothing active. */ - int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See + int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See * below for definitions. */ Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a * toplevel or not. "normal", "menubar", or * "toplevel" */ @@ -349,14 +349,14 @@ * that is currently posted or NULL if no * submenu posted. */ struct TkMenu *nextInstancePtr; /* The next instance of this menu in the * chain. */ - struct TkMenu *masterMenuPtr; + struct TkMenu *mainMenuPtr; /* A pointer to the original menu for this * clone chain. Points back to this structure - * if this menu is a master menu. */ + * if this menu is a main menu. */ void *reserved1; /* not used any more. */ Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the * toplevel that owns the menu. Only * applicable for menubar clones. */ struct TkMenuReferences *menuRefPtr; @@ -432,11 +432,11 @@ * RESIZE_PENDING: Non-zero means a call to ComputeMenuGeometry * has already been scheduled. * MENU_DELETION_PENDING Non-zero means that we are currently * destroying this menu's internal structures. * This is useful when we are in the middle of - * cleaning this master menu's chain of menus up + * cleaning this main menu's chain of menus up * when TkDestroyMenu was called again on this * menu (via a destroy binding or somesuch). * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of * destroying this menu's Tk_Window. * MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu @@ -450,20 +450,20 @@ #define MENU_PLATFORM_FLAG1 (1 << 30) #define MENU_PLATFORM_FLAG2 (1 << 29) #define MENU_PLATFORM_FLAG3 (1 << 28) /* - * Each menu created by the user is a MASTER_MENU. When a menu is torn off, a + * Each menu created by the user is a MAIN_MENU. When a menu is torn off, a * TEAROFF_MENU instance is created. When a menu is assigned to a toplevel as * a menu bar, a MENUBAR instance is created. All instances have the same - * configuration information. If the master instance is deleted, all instances + * configuration information. If the main instance is deleted, all instances * are deleted. If one of the other instances is deleted, only that instance * is deleted. */ #define UNKNOWN_TYPE -1 -#define MASTER_MENU 0 +#define MAIN_MENU 0 #define TEAROFF_MENU 1 #define MENUBAR 2 /* * Various geometry definitions: Index: generic/tkMenuDraw.c ================================================================== --- generic/tkMenuDraw.c +++ generic/tkMenuDraw.c @@ -2,11 +2,11 @@ * tkMenuDraw.c -- * * This module implements the platform-independent drawing and geometry * calculations of menu widgets. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkMenubutton.c ================================================================== --- generic/tkMenubutton.c +++ generic/tkMenubutton.c @@ -2,20 +2,19 @@ * tkMenubutton.c -- * * This module implements button-like widgets that are used to invoke * pull-down menus. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #include "tkMenubutton.h" -#include "default.h" /* * The structure below defines menubutton class behavior by means of * procedures that can be invoked from generic window code. */ @@ -317,11 +316,11 @@ if (ConfigureMenuButton(interp, mbPtr, objc-2, objv+2) != TCL_OK) { Tk_DestroyWindow(mbPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(mbPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(mbPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- Index: generic/tkMenubutton.h ================================================================== --- generic/tkMenubutton.h +++ generic/tkMenubutton.h @@ -2,11 +2,11 @@ * tkMenubutton.h -- * * Declarations of types and functions used to implement the menubutton * widget. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. + * Copyright © 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkMessage.c ================================================================== --- generic/tkMessage.c +++ generic/tkMessage.c @@ -3,13 +3,13 @@ * * This module implements a message widgets for the Tk toolkit. A message * widget displays a multi-line string in a window according to a * particular aspect ratio. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-2000 by Ajuba Solutions. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -276,11 +276,11 @@ if (ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0) != TCL_OK) { Tk_DestroyWindow(msgPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(msgPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(msgPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- Index: generic/tkObj.c ================================================================== --- generic/tkObj.c +++ generic/tkObj.c @@ -1,11 +1,11 @@ /* * tkObj.c -- * * This file contains functions that implement the common Tk object types * - * Copyright (c) 1997 Sun Microsystems, Inc. + * Copyright © 1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -97,10 +97,13 @@ static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); #if TCL_MAJOR_VERSION < 9 +#ifdef __cplusplus +extern "C" { +#endif #if defined(USE_TCL_STUBS) /* Little hack to eliminate the need for "tclInt.h" here: Just copy a small portion of TclIntStubs, just enough to make it work */ typedef struct TclIntStubs { @@ -107,19 +110,22 @@ int magic; void *hooks; void (*dummy[34]) (void); /* dummy entries 0-33, not used */ int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */ } TclIntStubs; -extern const struct TclIntStubs *tclIntStubsPtr; +extern const TclIntStubs *tclIntStubsPtr; # undef Tcl_GetIntForIndex # define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \ ((int (*)(Tcl_Interp*, Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \ tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr))) #elif TCL_MINOR_VERSION < 7 extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*); -# define Tcl_GetIntForIndex TclGetIntForIndex +# define Tcl_GetIntForIndex(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr) +#endif +#ifdef __cplusplus +} #endif #endif /* * The following structure defines the implementation of the "pixel" Tcl @@ -963,16 +969,15 @@ *---------------------------------------------------------------------- */ static int SetWindowFromAny( - Tcl_Interp *dummy, /* Used for error reporting if not NULL. */ + TCL_UNUSED(Tcl_Interp *), Tcl_Obj *objPtr) /* The object to convert. */ { const Tcl_ObjType *typePtr; WindowRep *winPtr; - (void)dummy; /* * Free the old internalRep before setting the new one. */ @@ -1055,11 +1060,11 @@ } /* *---------------------------------------------------------------------- * - * TkNewWindowObj -- + * Tk_NewWindowObj -- * * This function allocates a new Tcl_Obj that refers to a particular to a * particular Tk window. * * Results: @@ -1070,11 +1075,11 @@ * *---------------------------------------------------------------------- */ Tcl_Obj * -TkNewWindowObj( +Tk_NewWindowObj( Tk_Window tkwin) { Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1); TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr; WindowRep *winPtr; Index: generic/tkOldConfig.c ================================================================== --- generic/tkOldConfig.c +++ generic/tkOldConfig.c @@ -3,12 +3,12 @@ * * This file contains the Tk_ConfigureWidget function. THIS FILE IS HERE * FOR BACKWARD COMPATIBILITY; THE NEW CONFIGURATION PACKAGE SHOULD BE * USED FOR NEW PROJECTS. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -773,106 +773,104 @@ *freeProcPtr = NULL; ptr = (char *)widgRec + specPtr->offset; result = ""; switch (specPtr->type) { case TK_CONFIG_BOOLEAN: - if (*((int *) ptr) == 0) { + if (*((int *)ptr) == 0) { result = "0"; } else { result = "1"; } break; case TK_CONFIG_INT: - sprintf(buffer, "%d", *((int *) ptr)); + sprintf(buffer, "%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_DOUBLE: - Tcl_PrintDouble(interp, *((double *) ptr), buffer); + Tcl_PrintDouble(interp, *((double *)ptr), buffer); result = buffer; break; case TK_CONFIG_STRING: - result = (*(char **) ptr); + result = (*(char **)ptr); if (result == NULL) { result = ""; } break; case TK_CONFIG_UID: { - Tk_Uid uid = *((Tk_Uid *) ptr); + Tk_Uid uid = *((Tk_Uid *)ptr); if (uid != NULL) { result = uid; } break; } case TK_CONFIG_COLOR: { - XColor *colorPtr = *((XColor **) ptr); + XColor *colorPtr = *((XColor **)ptr); if (colorPtr != NULL) { result = Tk_NameOfColor(colorPtr); } break; } case TK_CONFIG_FONT: { - Tk_Font tkfont = *((Tk_Font *) ptr); + Tk_Font tkfont = *((Tk_Font *)ptr); if (tkfont != NULL) { result = Tk_NameOfFont(tkfont); } break; } case TK_CONFIG_BITMAP: { - Pixmap pixmap = *((Pixmap *) ptr); + Pixmap pixmap = *((Pixmap *)ptr); if (pixmap != None) { result = Tk_NameOfBitmap(Tk_Display(tkwin), pixmap); } break; } case TK_CONFIG_BORDER: { - Tk_3DBorder border = *((Tk_3DBorder *) ptr); + Tk_3DBorder border = *((Tk_3DBorder *)ptr); if (border != NULL) { result = Tk_NameOf3DBorder(border); } break; } case TK_CONFIG_RELIEF: - result = Tk_NameOfRelief(*((int *) ptr)); + result = Tk_NameOfRelief(*((int *)ptr)); break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: { - Tk_Cursor cursor = *((Tk_Cursor *) ptr); + Tk_Cursor cursor = *((Tk_Cursor *)ptr); if (cursor != NULL) { result = Tk_NameOfCursor(Tk_Display(tkwin), cursor); } break; } case TK_CONFIG_JUSTIFY: - result = Tk_NameOfJustify(*((Tk_Justify *) ptr)); + result = Tk_NameOfJustify(*((Tk_Justify *)ptr)); break; case TK_CONFIG_ANCHOR: - result = Tk_NameOfAnchor(*((Tk_Anchor *) ptr)); + result = Tk_NameOfAnchor(*((Tk_Anchor *)ptr)); break; case TK_CONFIG_CAP_STYLE: - result = Tk_NameOfCapStyle(*((int *) ptr)); + result = Tk_NameOfCapStyle(*((int *)ptr)); break; case TK_CONFIG_JOIN_STYLE: - result = Tk_NameOfJoinStyle(*((int *) ptr)); + result = Tk_NameOfJoinStyle(*((int *)ptr)); break; case TK_CONFIG_PIXELS: - sprintf(buffer, "%d", *((int *) ptr)); + sprintf(buffer, "%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_MM: - Tcl_PrintDouble(interp, *((double *) ptr), buffer); + Tcl_PrintDouble(interp, *((double *)ptr), buffer); result = buffer; break; case TK_CONFIG_WINDOW: { - Tk_Window tkwin; - - tkwin = *((Tk_Window *) ptr); + tkwin = *((Tk_Window *)ptr); if (tkwin != NULL) { result = Tk_PathName(tkwin); } break; } @@ -1106,11 +1104,11 @@ entrySpace += sizeof(Tk_ConfigSpec); } /* * Now allocate our working copy's space and copy over the contents - * from the master copy. + * from the origin. */ cachedSpecs = (Tk_ConfigSpec *)ckalloc(entrySpace); memcpy(cachedSpecs, staticSpecs, entrySpace); Tcl_SetHashValue(entryPtr, cachedSpecs); @@ -1159,16 +1157,15 @@ */ static void DeleteSpecCacheTable( ClientData clientData, - Tcl_Interp *dummy) + TCL_UNUSED(Tcl_Interp *)) { Tcl_HashTable *tablePtr = (Tcl_HashTable *)clientData; Tcl_HashEntry *entryPtr; Tcl_HashSearch search; - (void)dummy; for (entryPtr = Tcl_FirstHashEntry(tablePtr,&search); entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { /* * Someone else deallocates the Tk_Uids themselves. Index: generic/tkOldTest.c ================================================================== --- generic/tkOldTest.c +++ generic/tkOldTest.c @@ -4,13 +4,13 @@ * This file contains C command functions for additional Tcl * commands that are used to test Tk's support for legacy * interfaces. These commands are not normally included in Tcl/Tk * applications; they're only used for testing. * - * Copyright (c) 1993-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright © 1993-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-1999 Scriptics Corporation. * Contributions by Don Porter, NIST, 2007. (not subject to US copyright) * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -24,29 +24,29 @@ #endif #include "tkInt.h" #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) /* - * The following data structure represents the master for a test image: + * The following data structure represents the model for a test image: */ -typedef struct TImageMaster { - Tk_ImageMaster master; /* Tk's token for image master. */ +typedef struct TImageModel { + Tk_ImageModel model; /* Tk's token for image model. */ Tcl_Interp *interp; /* Interpreter for application. */ int width, height; /* Dimensions of image. */ char *imageName; /* Name of image (malloc-ed). */ char *varName; /* Name of variable in which to log events for * image (malloc-ed). */ -} TImageMaster; +} TImageModel; /* * The following data structure represents a particular use of a particular * test image. */ typedef struct TImageInstance { - TImageMaster *masterPtr; /* Pointer to master for image. */ + TImageModel *modelPtr; /* Pointer to model for image. */ XColor *fg; /* Foreground color for drawing in image. */ GC gc; /* Graphics context for drawing in image. */ } TImageInstance; /* @@ -53,11 +53,11 @@ * The type record for test images: */ static int ImageCreate(Tcl_Interp *interp, char *name, int argc, char **argv, - Tk_ImageType *typePtr, Tk_ImageMaster master, + Tk_ImageType *typePtr, Tk_ImageModel model, ClientData *clientDataPtr); static ClientData ImageGet(Tk_Window tkwin, ClientData clientData); static void ImageDisplay(ClientData clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, @@ -144,16 +144,16 @@ char *name, /* Name to use for image. */ int argc, /* Number of arguments. */ char **argv, /* Argument strings for options (doesn't * include image name or type). */ Tk_ImageType *typePtr, /* Pointer to our type record (not used). */ - Tk_ImageMaster master, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - TImageMaster *timPtr; + TImageModel *timPtr; const char *varName; int i; (void)typePtr; varName = "log"; @@ -169,22 +169,22 @@ return TCL_ERROR; } varName = argv[i+1]; } - timPtr = (TImageMaster *)ckalloc(sizeof(TImageMaster)); - timPtr->master = master; + timPtr = (TImageModel *)ckalloc(sizeof(TImageModel)); + timPtr->model = model; timPtr->interp = interp; timPtr->width = 30; timPtr->height = 15; timPtr->imageName = (char *)ckalloc(strlen(name) + 1); strcpy(timPtr->imageName, name); timPtr->varName = (char *)ckalloc(strlen(varName) + 1); strcpy(timPtr->varName, varName); Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL); *clientDataPtr = timPtr; - Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15); + Tk_ImageChanged(model, 0, 0, 30, 15, 30, 15); return TCL_OK; } /* *---------------------------------------------------------------------- @@ -208,11 +208,11 @@ ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; int x, y, width, height; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; @@ -229,11 +229,11 @@ || (Tcl_GetIntFromObj(interp, objv[5], &height) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &timPtr->width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) { return TCL_ERROR; } - Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width, + Tk_ImageChanged(timPtr->model, x, y, width, height, timPtr->width, timPtr->height); } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be changed", NULL); return TCL_ERROR; @@ -261,23 +261,23 @@ static ClientData ImageGet( Tk_Window tkwin, /* Token for window in which image will be * used. */ - ClientData clientData) /* Pointer to TImageMaster for image. */ + ClientData clientData) /* Pointer to TImageModel for image. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; TImageInstance *instPtr; char buffer[100]; XGCValues gcValues; sprintf(buffer, "%s get", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance)); - instPtr->masterPtr = timPtr; + instPtr->modelPtr = timPtr; instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues); return instPtr; } @@ -314,19 +314,19 @@ { TImageInstance *instPtr = (TImageInstance *)clientData; char buffer[200 + TCL_INTEGER_SPACE * 6]; sprintf(buffer, "%s display %d %d %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height, + instPtr->modelPtr->imageName, imageX, imageY, width, height, drawableX, drawableY); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - if (width > (instPtr->masterPtr->width - imageX)) { - width = instPtr->masterPtr->width - imageX; + if (width > (instPtr->modelPtr->width - imageX)) { + width = instPtr->modelPtr->width - imageX; } - if (height > (instPtr->masterPtr->height - imageY)) { - height = instPtr->masterPtr->height - imageY; + if (height > (instPtr->modelPtr->height - imageY)) { + height = instPtr->modelPtr->height - imageY; } XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY, (unsigned) (width-1), (unsigned) (height-1)); XDrawLine(display, drawable, instPtr->gc, drawableX, drawableY, (int) (drawableX + width - 1), (int) (drawableY + height - 1)); @@ -358,12 +358,12 @@ Display *display) /* Display where image was to be drawn. */ { TImageInstance *instPtr = (TImageInstance *)clientData; char buffer[200]; - sprintf(buffer, "%s free", instPtr->masterPtr->imageName); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + sprintf(buffer, "%s free", instPtr->modelPtr->imageName); + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); ckfree(instPtr); } @@ -385,15 +385,15 @@ *---------------------------------------------------------------------- */ static void ImageDelete( - ClientData clientData) /* Pointer to TImageMaster for image. When + ClientData clientData) /* Pointer to TImageModel for image. When * this function is called, no more instances * exist. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; char buffer[100]; sprintf(buffer, "%s delete", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Index: generic/tkOption.c ================================================================== --- generic/tkOption.c +++ generic/tkOption.c @@ -3,12 +3,12 @@ * * This module contains functions to manage the option database, which * allows various strings to be associated with windows either by name or * by class or both. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -519,11 +519,11 @@ */ if (masqName != NULL) { char *masqClass; Tk_Uid nodeId, winClassId, winNameId; - size_t classNameLength; + TkSizeT classNameLength; Element *nodePtr, *leafPtr; static const int searchOrder[] = { EXACT_NODE_NAME, WILDCARD_NODE_NAME, EXACT_NODE_CLASS, WILDCARD_NODE_CLASS, -1 }; @@ -532,11 +532,11 @@ /* * Extract the masquerade class name from the name field. */ - classNameLength = (unsigned) (masqName - name); + classNameLength = masqName - name; masqClass = (char *)ckalloc(classNameLength + 1); strncpy(masqClass, name, classNameLength); masqClass[classNameLength] = '\0'; winClassId = Tk_GetUid(masqClass); @@ -1083,11 +1083,11 @@ * TK_MAX_PRIO. */ { const char *realName; Tcl_Obj *buffer; int result; - size_t bufferSize; + TkSizeT bufferSize; Tcl_Channel chan; Tcl_DString newName; /* * Prevent file system access in a safe interpreter. @@ -1114,11 +1114,11 @@ buffer = Tcl_NewObj(); Tcl_IncrRefCount(buffer); Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8"); bufferSize = Tcl_ReadChars(chan, buffer, -1, 0); - if (bufferSize == (size_t)-1) { + if (bufferSize == TCL_IO_FAILURE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file \"%s\": %s", fileName, Tcl_PosixError(interp))); Tcl_Close(NULL, chan); return TCL_ERROR; @@ -1418,15 +1418,14 @@ *-------------------------------------------------------------- */ static void OptionThreadExitProc( - ClientData dummy) /* not used */ + TCL_UNUSED(void *)) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)dummy; if (tsdPtr->initialized) { int i; for (i = 0; i < NUM_STACKS; i++) { Index: generic/tkPack.c ================================================================== --- generic/tkPack.c +++ generic/tkPack.c @@ -2,12 +2,12 @@ * tkPack.c -- * * This file contains code to implement the "packer" geometry manager for * Tk. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -18,28 +18,28 @@ "top", "bottom", "left", "right", NULL }; /* * For each window that the packer cares about (either because the window is - * managed by the packer or because the window has slaves that are managed by + * managed by the packer or because the window has content that are managed by * the packer), there is a structure of the following type: */ typedef struct Packer { Tk_Window tkwin; /* Tk token for window. NULL means that the * window has been deleted, but the packet * hasn't had a chance to clean up yet because * the structure is still in use. */ - struct Packer *masterPtr; /* Master window within which this window is + struct Packer *containerPtr; /* Container window within which this window is * packed (NULL means this window isn't * managed by the packer). */ - struct Packer *nextPtr; /* Next window packed within same master. List + struct Packer *nextPtr; /* Next window packed within same container. List * is priority-ordered: first on list gets * packed first. */ - struct Packer *slavePtr; /* First in list of slaves packed inside this - * window (NULL means no packed slaves). */ - Side side; /* Side of master against which this window is + struct Packer *contentPtr; /* First in list of content packed inside this + * window (NULL means no packed content). */ + Side side; /* Side of container against which this window is * packed. */ Tk_Anchor anchor; /* If frame allocated for window is larger * than window needs, this indicates how where * to position window in frame. */ int padX, padY; /* Total additional pixels to leave around the @@ -53,86 +53,86 @@ int iPadX, iPadY; /* Total extra pixels to allocate inside the * window (half of this amount will appear on * each side). */ int doubleBw; /* Twice the window's last known border width. * If this changes, the window must be - * repacked within its master. */ + * repacked within its container. */ int *abortPtr; /* If non-NULL, it means that there is a * nested call to ArrangePacking already * working on this window. *abortPtr may be * set to 1 to abort that nested call. This * happens, for example, if tkwin or any of - * its slaves is deleted. */ + * its content is deleted. */ int flags; /* Miscellaneous flags; see below for * definitions. */ } Packer; /* * Flag values for Packer structures: * * REQUESTED_REPACK: 1 means a Tcl_DoWhenIdle request has already - * been made to repack all the slaves of this + * been made to repack all the content of this * window. * FILLX: 1 means if frame allocated for window is wider * than window needs, expand window to fill * frame. 0 means don't make window any larger * than needed. * FILLY: Same as FILLX, except for height. * EXPAND: 1 means this window's frame will absorb any - * extra space in the master window. + * extra space in the container window. * OLD_STYLE: 1 means this window is being managed with the * old-style packer algorithms (before Tk version * 3.3). The main difference is that padding and * filling are done differently. * DONT_PROPAGATE: 1 means don't set this window's requested - * size. 0 means if this window is a master then + * size. 0 means if this window is a container then * Tk will set its requested size to fit the - * needs of its slaves. - * ALLOCED_MASTER 1 means that Pack has allocated itself as - * geometry master for this window. + * needs of its content. + * ALLOCED_CONTAINER 1 means that Pack has allocated itself as + * geometry container for this window. */ #define REQUESTED_REPACK 1 #define FILLX 2 #define FILLY 4 #define EXPAND 8 #define OLD_STYLE 16 #define DONT_PROPAGATE 32 -#define ALLOCED_MASTER 64 +#define ALLOCED_CONTAINER 64 /* * The following structure is the official type record for the packer: */ static void PackReqProc(ClientData clientData, Tk_Window tkwin); -static void PackLostSlaveProc(ClientData clientData, +static void PackLostContentProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr packerType = { "pack", /* name */ PackReqProc, /* requestProc */ - PackLostSlaveProc, /* lostSlaveProc */ + PackLostContentProc, /* lostContentProc */ }; /* * Forward declarations for functions defined later in this file: */ static void ArrangePacking(ClientData clientData); -static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin, +static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin, int objc, Tcl_Obj *const objv[]); static void DestroyPacker(void *memPtr); static Packer * GetPacker(Tk_Window tkwin); #ifndef TK_NO_DEPRECATED static int PackAfter(Tcl_Interp *interp, Packer *prevPtr, - Packer *masterPtr, int objc,Tcl_Obj *const objv[]); + Packer *containerPtr, int objc,Tcl_Obj *const objv[]); #endif /* !TK_NO_DEPRECATED */ static void PackStructureProc(ClientData clientData, XEvent *eventPtr); static void Unlink(Packer *packPtr); -static int XExpansion(Packer *slavePtr, int cavityWidth); -static int YExpansion(Packer *slavePtr, int cavityHeight); +static int XExpansion(Packer *contentPtr, int cavityWidth); +static int YExpansion(Packer *contentPtr, int cavityHeight); /* *------------------------------------------------------------------------ * * TkAppendPadAmount -- @@ -200,43 +200,42 @@ const char *argv2; static const char *const optionStrings[] = { #ifndef TK_NO_DEPRECATED "after", "append", "before", "unpack", #endif /* !TK_NO_DEPRECATED */ - "configure", "forget", "info", "propagate", "slaves", NULL }; + "configure", "content", "forget", "info", "propagate", "slaves", NULL }; + static const char *const optionStringsNoDep[] = { + "configure", "content", "forget", "info", "propagate", NULL }; enum options { #ifndef TK_NO_DEPRECATED PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, #endif /* !TK_NO_DEPRECATED */ - PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; + PACK_CONFIGURE, PACK_CONTENT, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; int index; if (objc >= 2) { const char *string = Tcl_GetString(objv[1]); if (string[0] == '.') { - return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + return ConfigureContent(interp, tkwin, objc-1, objv+1); } } if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + if (Tcl_GetIndexFromObjStruct(NULL, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { -#ifndef TK_NO_DEPRECATED /* * Call it again without the deprecated ones to get a proper error * message. This works well since there can't be any ambiguity between * deprecated and new options. */ - Tcl_ResetResult(interp); - Tcl_GetIndexFromObjStruct(interp, objv[1], &optionStrings[4], + Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep, sizeof(char *), "option", 0, &index); -#endif /* TK_NO_DEPRECATED */ return TCL_ERROR; } argv2 = Tcl_GetString(objv[2]); switch ((enum options) index) { @@ -247,52 +246,52 @@ if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(tkwin2); - if (prevPtr->masterPtr == NULL) { + if (prevPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } - return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, prevPtr->containerPtr, objc-3, objv+3); } case PACK_APPEND: { - Packer *masterPtr; + Packer *containerPtr; Packer *prevPtr; Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(tkwin2); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(tkwin2); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; } } - return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3); } case PACK_BEFORE: { - Packer *packPtr, *masterPtr; + Packer *packPtr, *containerPtr; Packer *prevPtr; Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); - if (packPtr->masterPtr == NULL) { + if (packPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } - masterPtr = packPtr->masterPtr; - prevPtr = masterPtr->slavePtr; + containerPtr = packPtr->containerPtr; + prevPtr = containerPtr->contentPtr; if (prevPtr == packPtr) { prevPtr = NULL; } else { for ( ; ; prevPtr = prevPtr->nextPtr) { if (prevPtr == NULL) { @@ -301,71 +300,71 @@ if (prevPtr->nextPtr == packPtr) { break; } } } - return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3); } #endif /* !TK_NO_DEPRECATED */ case PACK_CONFIGURE: if (argv2[0] != '.') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be name of window", argv2)); Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); return TCL_ERROR; } - return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + return ConfigureContent(interp, tkwin, objc-2, objv+2); case PACK_FORGET: { - Tk_Window slave; - Packer *slavePtr; + Tk_Window content; + Packer *contentPtr; int i; for (i = 2; i < objc; i++) { - if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) { continue; } - slavePtr = GetPacker(slave); - if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) { - Tk_ManageGeometry(slave, NULL, NULL); - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + contentPtr = GetPacker(content); + if ((contentPtr != NULL) && (contentPtr->containerPtr != NULL)) { + Tk_ManageGeometry(content, NULL, NULL); + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, + contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } } break; } case PACK_INFO: { - Packer *slavePtr; - Tk_Window slave; + Packer *contentPtr; + Tk_Window content; Tcl_Obj *infoObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &content) != TCL_OK) { return TCL_ERROR; } - slavePtr = GetPacker(slave); - if (slavePtr->masterPtr == NULL) { + contentPtr = GetPacker(content); + if (contentPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } infoObj = Tcl_NewObj(); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1), - TkNewWindowObj(slavePtr->masterPtr->tkwin)); + Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", -1), - Tcl_NewStringObj(Tk_NameOfAnchor(slavePtr->anchor), -1)); + Tcl_NewStringObj(Tk_NameOfAnchor(contentPtr->anchor), -1)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", -1), - Tcl_NewBooleanObj(slavePtr->flags & EXPAND)); - switch (slavePtr->flags & (FILLX|FILLY)) { + Tcl_NewBooleanObj(contentPtr->flags & EXPAND)); + switch (contentPtr->flags & (FILLX|FILLY)) { case 0: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("none", -1)); break; case FILLX: @@ -379,92 +378,93 @@ case FILLX|FILLY: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("both", -1)); break; } - TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX); - TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY); - TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft,slavePtr->padX); - TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY); + TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX); + TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY); + TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft,contentPtr->padX); + TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", -1), - Tcl_NewStringObj(sideNames[slavePtr->side], -1)); + Tcl_NewStringObj(sideNames[contentPtr->side], -1)); Tcl_SetObjResult(interp, infoObj); break; } case PACK_PROPAGATE: { - Tk_Window master; - Packer *masterPtr; + Tk_Window container; + Packer *containerPtr; int propagate; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(master); + containerPtr = GetPacker(container); if (objc == 3) { Tcl_SetObjResult(interp, - Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); + Tcl_NewBooleanObj(!(containerPtr->flags & DONT_PROPAGATE))); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { return TCL_ERROR; } if (propagate) { /* - * If we have slaves, we need to register as geometry master. - */ - - if (masterPtr->slavePtr != NULL) { - if (TkSetGeometryMaster(interp, master, "pack") != TCL_OK) { - return TCL_ERROR; - } - masterPtr->flags |= ALLOCED_MASTER; - } - masterPtr->flags &= ~DONT_PROPAGATE; - - /* - * Repack the master to allow new geometry information to - * propagate upwards to the master's master. - */ - - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); - } - } else { - if (masterPtr->flags & ALLOCED_MASTER) { - TkFreeGeometryMaster(master, "pack"); - masterPtr->flags &= ~ALLOCED_MASTER; - } - masterPtr->flags |= DONT_PROPAGATE; + * If we have content windows, we need to register as geometry container. + */ + + if (containerPtr->contentPtr != NULL) { + if (TkSetGeometryContainer(interp, container, "pack") != TCL_OK) { + return TCL_ERROR; + } + containerPtr->flags |= ALLOCED_CONTAINER; + } + containerPtr->flags &= ~DONT_PROPAGATE; + + /* + * Repack the container to allow new geometry information to + * propagate upwards to the container's container. + */ + + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); + } + } else { + if (containerPtr->flags & ALLOCED_CONTAINER) { + TkFreeGeometryContainer(container, "pack"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + } + containerPtr->flags |= DONT_PROPAGATE; } break; } - case PACK_SLAVES: { - Tk_Window master; - Packer *masterPtr, *slavePtr; + case PACK_SLAVES: + case PACK_CONTENT: { + Tk_Window container; + Packer *containerPtr, *contentPtr; Tcl_Obj *resultObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } resultObj = Tcl_NewObj(); - masterPtr = GetPacker(master); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { + containerPtr = GetPacker(container); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, - TkNewWindowObj(slavePtr->tkwin)); + Tk_NewWindowObj(contentPtr->tkwin)); } Tcl_SetObjResult(interp, resultObj); break; } #ifndef TK_NO_DEPRECATED @@ -478,15 +478,15 @@ } if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); - if ((packPtr != NULL) && (packPtr->masterPtr != NULL)) { + if ((packPtr != NULL) && (packPtr->containerPtr != NULL)) { Tk_ManageGeometry(tkwin2, NULL, NULL); - if (packPtr->masterPtr->tkwin != Tk_Parent(packPtr->tkwin)) { + if (packPtr->containerPtr->tkwin != Tk_Parent(packPtr->tkwin)) { Tk_UnmaintainGeometry(packPtr->tkwin, - packPtr->masterPtr->tkwin); + packPtr->containerPtr->tkwin); } Unlink(packPtr); Tk_UnmapWindow(packPtr->tkwin); } break; @@ -517,54 +517,52 @@ static void PackReqProc( ClientData clientData, /* Packer's information about window that got * new preferred geometry. */ - Tk_Window tkwin) /* Other Tk-related information about the + TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { Packer *packPtr = (Packer *)clientData; - (void)tkwin; - packPtr = packPtr->masterPtr; + packPtr = packPtr->containerPtr; if (!(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); } } /* *------------------------------------------------------------------------ * - * PackLostSlaveProc -- + * PackLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all packer-related information about the slave. + * Forgets all packer-related information about the content. * *------------------------------------------------------------------------ */ static void -PackLostSlaveProc( - ClientData clientData, /* Packer structure for slave window that was +PackLostContentProc( + void *clientData, /* Packer structure for content window that was * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ -{ - Packer *slavePtr = (Packer *)clientData; - (void)tkwin; - - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */ +{ + Packer *contentPtr = (Packer *)clientData; + + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } /* *------------------------------------------------------------------------ * @@ -577,26 +575,26 @@ * * Results: * None. * * Side effects: - * The packed slaves of masterPtr may get resized or moved. + * The packed content of containerPtr may get resized or moved. * *------------------------------------------------------------------------ */ static void ArrangePacking( - ClientData clientData) /* Structure describing master whose slaves + ClientData clientData) /* Structure describing container whose content * are to be re-layed out. */ { - Packer *masterPtr = (Packer *)clientData; - Packer *slavePtr; + Packer *containerPtr = (Packer *)clientData; + Packer *contentPtr; int cavityX, cavityY, cavityWidth, cavityHeight; /* These variables keep track of the * as-yet-unallocated space remaining in the - * middle of the master window. */ + * middle of the container window. */ int frameX, frameY, frameWidth, frameHeight; /* These variables keep track of the frame * allocated to the current window. */ int x, y, width, height; /* These variables are used to hold the actual * geometry of the current window. */ @@ -605,158 +603,158 @@ int borderX, borderY; int borderTop, borderBtm; int borderLeft, borderRight; int maxWidth, maxHeight, tmp; - masterPtr->flags &= ~REQUESTED_REPACK; + containerPtr->flags &= ~REQUESTED_REPACK; /* - * If the master has no slaves anymore, then leave the master's size as-is. - * Otherwise there is no way to "relinquish" control over the master + * If the container has no content anymore, then leave the container's size as-is. + * Otherwise there is no way to "relinquish" control over the container * so another geometry manager can take over. */ - if (masterPtr->slavePtr == NULL) { + if (containerPtr->contentPtr == NULL) { return; } /* * Abort any nested call to ArrangePacking for this window, since we'll do * everything necessary here, and set up so this call can be aborted if * necessary. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - masterPtr->abortPtr = &abort; + containerPtr->abortPtr = &abort; abort = 0; - Tcl_Preserve(masterPtr); + Tcl_Preserve(containerPtr); /* - * Pass #1: scan all the slaves to figure out the total amount of space + * Pass #1: scan all the content to figure out the total amount of space * needed. Two separate width and height values are computed: * * width - Holds the sum of the widths (plus padding) of all the - * slaves seen so far that were packed LEFT or RIGHT. - * height - Holds the sum of the heights (plus padding) of all the - * slaves seen so far that were packed TOP or BOTTOM. - * - * maxWidth - Gradually builds up the width needed by the master to - * just barely satisfy all the slave's needs. For each - * slave, the code computes the width needed for all the - * slaves so far and updates maxWidth if the new value is + * content seen so far that were packed LEFT or RIGHT. + * height - Holds the sum of the heights (plus padding) of all the + * content seen so far that were packed TOP or BOTTOM. + * + * maxWidth - Gradually builds up the width needed by the container to + * just barely satisfy all the content's needs. For each + * content, the code computes the width needed for all the + * content so far and updates maxWidth if the new value is * greater. * maxHeight - Same as maxWidth, except keeps height info. */ - width = maxWidth = Tk_InternalBorderLeft(masterPtr->tkwin) + - Tk_InternalBorderRight(masterPtr->tkwin); - height = maxHeight = Tk_InternalBorderTop(masterPtr->tkwin) + - Tk_InternalBorderBottom(masterPtr->tkwin); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { - tmp = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX + width; + width = maxWidth = Tk_InternalBorderLeft(containerPtr->tkwin) + + Tk_InternalBorderRight(containerPtr->tkwin); + height = maxHeight = Tk_InternalBorderTop(containerPtr->tkwin) + + Tk_InternalBorderBottom(containerPtr->tkwin); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { + tmp = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX + width; if (tmp > maxWidth) { maxWidth = tmp; } - height += Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; + height += Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; } else { - tmp = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY + height; + tmp = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY + height; if (tmp > maxHeight) { maxHeight = tmp; } - width += Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; + width += Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; } } if (width > maxWidth) { maxWidth = width; } if (height > maxHeight) { maxHeight = height; } - if (maxWidth < Tk_MinReqWidth(masterPtr->tkwin)) { - maxWidth = Tk_MinReqWidth(masterPtr->tkwin); + if (maxWidth < Tk_MinReqWidth(containerPtr->tkwin)) { + maxWidth = Tk_MinReqWidth(containerPtr->tkwin); } - if (maxHeight < Tk_MinReqHeight(masterPtr->tkwin)) { - maxHeight = Tk_MinReqHeight(masterPtr->tkwin); + if (maxHeight < Tk_MinReqHeight(containerPtr->tkwin)) { + maxHeight = Tk_MinReqHeight(containerPtr->tkwin); } /* - * If the total amount of space needed in the master window has changed, + * If the total amount of space needed in the container window has changed, * and if we're propagating geometry information, then notify the next * geometry manager up and requeue ourselves to start again after the - * master has had a chance to resize us. + * container has had a chance to resize us. */ - if (((maxWidth != Tk_ReqWidth(masterPtr->tkwin)) - || (maxHeight != Tk_ReqHeight(masterPtr->tkwin))) - && !(masterPtr->flags & DONT_PROPAGATE)) { - Tk_GeometryRequest(masterPtr->tkwin, maxWidth, maxHeight); - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (((maxWidth != Tk_ReqWidth(containerPtr->tkwin)) + || (maxHeight != Tk_ReqHeight(containerPtr->tkwin))) + && !(containerPtr->flags & DONT_PROPAGATE)) { + Tk_GeometryRequest(containerPtr->tkwin, maxWidth, maxHeight); + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); goto done; } /* - * Pass #2: scan the slaves a second time assigning new sizes. The + * Pass #2: scan the content a second time assigning new sizes. The * "cavity" variables keep track of the unclaimed space in the cavity of * the window; this shrinks inward as we allocate windows around the * edges. The "frame" variables keep track of the space allocated to the * current window and its frame. The current window is then placed * somewhere inside the frame, depending on anchor. */ - cavityX = x = Tk_InternalBorderLeft(masterPtr->tkwin); - cavityY = y = Tk_InternalBorderTop(masterPtr->tkwin); - cavityWidth = Tk_Width(masterPtr->tkwin) - - Tk_InternalBorderLeft(masterPtr->tkwin) - - Tk_InternalBorderRight(masterPtr->tkwin); - cavityHeight = Tk_Height(masterPtr->tkwin) - - Tk_InternalBorderTop(masterPtr->tkwin) - - Tk_InternalBorderBottom(masterPtr->tkwin); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { + cavityX = x = Tk_InternalBorderLeft(containerPtr->tkwin); + cavityY = y = Tk_InternalBorderTop(containerPtr->tkwin); + cavityWidth = Tk_Width(containerPtr->tkwin) - + Tk_InternalBorderLeft(containerPtr->tkwin) - + Tk_InternalBorderRight(containerPtr->tkwin); + cavityHeight = Tk_Height(containerPtr->tkwin) - + Tk_InternalBorderTop(containerPtr->tkwin) - + Tk_InternalBorderBottom(containerPtr->tkwin); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { frameWidth = cavityWidth; - frameHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; - if (slavePtr->flags & EXPAND) { - frameHeight += YExpansion(slavePtr, cavityHeight); + frameHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; + if (contentPtr->flags & EXPAND) { + frameHeight += YExpansion(contentPtr, cavityHeight); } cavityHeight -= frameHeight; if (cavityHeight < 0) { frameHeight += cavityHeight; cavityHeight = 0; } frameX = cavityX; - if (slavePtr->side == TOP) { + if (contentPtr->side == TOP) { frameY = cavityY; cavityY += frameHeight; } else { frameY = cavityY + cavityHeight; } } else { frameHeight = cavityHeight; - frameWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; - if (slavePtr->flags & EXPAND) { - frameWidth += XExpansion(slavePtr, cavityWidth); + frameWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; + if (contentPtr->flags & EXPAND) { + frameWidth += XExpansion(contentPtr, cavityWidth); } cavityWidth -= frameWidth; if (cavityWidth < 0) { frameWidth += cavityWidth; cavityWidth = 0; } frameY = cavityY; - if (slavePtr->side == LEFT) { + if (contentPtr->side == LEFT) { frameX = cavityX; cavityX += frameWidth; } else { frameX = cavityX + cavityWidth; } @@ -769,35 +767,35 @@ * handle the differences between old-style packing and the new style * (in old-style, iPadX and iPadY are always zero and padding is * completely ignored except when computing frame size). */ - if (slavePtr->flags & OLD_STYLE) { + if (contentPtr->flags & OLD_STYLE) { borderX = borderY = 0; borderTop = borderBtm = 0; borderLeft = borderRight = 0; } else { - borderX = slavePtr->padX; - borderY = slavePtr->padY; - borderLeft = slavePtr->padLeft; + borderX = contentPtr->padX; + borderY = contentPtr->padY; + borderLeft = contentPtr->padLeft; borderRight = borderX - borderLeft; - borderTop = slavePtr->padTop; + borderTop = contentPtr->padTop; borderBtm = borderY - borderTop; } - width = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->iPadX; - if ((slavePtr->flags & FILLX) + width = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->iPadX; + if ((contentPtr->flags & FILLX) || (width > (frameWidth - borderX))) { width = frameWidth - borderX; } - height = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->iPadY; - if ((slavePtr->flags & FILLY) + height = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->iPadY; + if ((contentPtr->flags & FILLY) || (height > (frameHeight - borderY))) { height = frameHeight - borderY; } - switch (slavePtr->anchor) { + switch (contentPtr->anchor) { case TK_ANCHOR_N: x = frameX + (borderLeft + frameWidth - width - borderRight)/2; y = frameY + borderTop; break; case TK_ANCHOR_NE: @@ -833,48 +831,48 @@ y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; default: Tcl_Panic("bad frame factor in ArrangePacking"); } - width -= slavePtr->doubleBw; - height -= slavePtr->doubleBw; + width -= contentPtr->doubleBw; + height -= contentPtr->doubleBw; /* * The final step is to set the position, size, and mapped/unmapped - * state of the slave. If the slave is a child of the master, then do + * state of the content. If the content is a child of the container, then do * this here. Otherwise let Tk_MaintainGeometry do the work. */ - if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) { + if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) { if ((width <= 0) || (height <= 0)) { - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - if ((x != Tk_X(slavePtr->tkwin)) - || (y != Tk_Y(slavePtr->tkwin)) - || (width != Tk_Width(slavePtr->tkwin)) - || (height != Tk_Height(slavePtr->tkwin))) { - Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height); + if ((x != Tk_X(contentPtr->tkwin)) + || (y != Tk_Y(contentPtr->tkwin)) + || (width != Tk_Width(contentPtr->tkwin)) + || (height != Tk_Height(contentPtr->tkwin))) { + Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height); } if (abort) { goto done; } /* - * Don't map the slave if the master isn't mapped: wait until - * the master gets mapped later. + * Don't map the content if the container isn't mapped: wait until + * the container gets mapped later. */ - if (Tk_IsMapped(masterPtr->tkwin)) { - Tk_MapWindow(slavePtr->tkwin); + if (Tk_IsMapped(containerPtr->tkwin)) { + Tk_MapWindow(contentPtr->tkwin); } } } else { if ((width <= 0) || (height <= 0)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin, + Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin, x, y, width, height); } } /* @@ -887,20 +885,20 @@ goto done; } } done: - masterPtr->abortPtr = NULL; - Tcl_Release(masterPtr); + containerPtr->abortPtr = NULL; + Tcl_Release(containerPtr); } /* *---------------------------------------------------------------------- * * XExpansion -- * - * Given a list of packed slaves, the first of which is packed on the + * Given a list of packed content, the first of which is packed on the * left or right and is expandable, compute how much to expand the child. * * Results: * The return value is the number of additional pixels to give to the * child. @@ -911,13 +909,13 @@ *---------------------------------------------------------------------- */ static int XExpansion( - Packer *slavePtr, /* First in list of remaining slaves. */ + Packer *contentPtr, /* First in list of remaining content. */ int cavityWidth) /* Horizontal space left for all remaining - * slaves. */ + * content. */ { int numExpand, minExpand, curExpand; int childWidth; /* @@ -931,23 +929,23 @@ * any of these points. */ minExpand = cavityWidth; numExpand = 0; - for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { - childWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { + for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { + childWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { if (numExpand) { curExpand = (cavityWidth - childWidth)/numExpand; if (curExpand < minExpand) { minExpand = curExpand; } } } else { cavityWidth -= childWidth; - if (slavePtr->flags & EXPAND) { + if (contentPtr->flags & EXPAND) { numExpand++; } } } if (numExpand) { @@ -962,11 +960,11 @@ /* *---------------------------------------------------------------------- * * YExpansion -- * - * Given a list of packed slaves, the first of which is packed on the top + * Given a list of packed content, the first of which is packed on the top * or bottom and is expandable, compute how much to expand the child. * * Results: * The return value is the number of additional pixels to give to the * child. @@ -977,13 +975,13 @@ *---------------------------------------------------------------------- */ static int YExpansion( - Packer *slavePtr, /* First in list of remaining slaves. */ + Packer *contentPtr, /* First in list of remaining content. */ int cavityHeight) /* Vertical space left for all remaining - * slaves. */ + * content. */ { int numExpand, minExpand, curExpand; int childHeight; /* @@ -990,23 +988,23 @@ * See comments for XExpansion. */ minExpand = cavityHeight; numExpand = 0; - for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { - childHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; - if ((slavePtr->side == LEFT) || (slavePtr->side == RIGHT)) { + for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { + childHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; + if ((contentPtr->side == LEFT) || (contentPtr->side == RIGHT)) { if (numExpand) { curExpand = (cavityHeight - childHeight)/numExpand; if (curExpand < minExpand) { minExpand = curExpand; } } } else { cavityHeight -= childHeight; - if (slavePtr->flags & EXPAND) { + if (contentPtr->flags & EXPAND) { numExpand++; } } } if (numExpand) { @@ -1062,13 +1060,13 @@ if (!isNew) { return (Packer *)Tcl_GetHashValue(hPtr); } packPtr = (Packer *)ckalloc(sizeof(Packer)); packPtr->tkwin = tkwin; - packPtr->masterPtr = NULL; + packPtr->containerPtr = NULL; packPtr->nextPtr = NULL; - packPtr->slavePtr = NULL; + packPtr->contentPtr = NULL; packPtr->side = TOP; packPtr->anchor = TK_ANCHOR_CENTER; packPtr->padX = packPtr->padY = 0; packPtr->padLeft = packPtr->padTop = 0; packPtr->iPadX = packPtr->iPadY = 0; @@ -1085,11 +1083,11 @@ *------------------------------------------------------------------------ * * PackAfter -- * * This function does most of the real work of adding one or more windows - * into the packing order for its master. + * into the packing order for its container. * * Results: * A standard Tcl return value. * * Side effects: @@ -1103,12 +1101,12 @@ static int PackAfter( Tcl_Interp *interp, /* Interpreter for error reporting. */ Packer *prevPtr, /* Pack windows in argv just after this * window; NULL means pack as first child of - * masterPtr. */ - Packer *masterPtr, /* Master in which to pack windows. */ + * containerPtr. */ + Packer *containerPtr, /* Container in which to pack windows. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[]) /* Array of lists, each containing 2 elements: * window name and side against which to * pack. */ { @@ -1136,33 +1134,33 @@ * Find the packer for the window to be packed, and make sure that the * window in which it will be packed is either its or a descendant of * its parent. */ - if (TkGetWindowFromObj(interp, masterPtr->tkwin, objv[0], &tkwin) + if (TkGetWindowFromObj(interp, containerPtr->tkwin, objv[0], &tkwin) != TCL_OK) { return TCL_ERROR; } parent = Tk_Parent(tkwin); - for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { + for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside %s", Tcl_GetString(objv[0]), - Tk_PathName(masterPtr->tkwin))); + "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[0]), + Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } - if (tkwin == masterPtr->tkwin) { + if (tkwin == containerPtr->tkwin) { goto badWindow; } packPtr = GetPacker(tkwin); /* @@ -1181,11 +1179,11 @@ packPtr->flags &= ~(FILLX|FILLY|EXPAND); packPtr->flags |= OLD_STYLE; for (index = 0 ; index < optionCount; index++) { Tcl_Obj *curOptPtr = options[index]; TkSizeT length; - const char *curOpt = TkGetStringFromObj(curOptPtr, &length); + const char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length); c = curOpt[0]; if ((c == 't') && (strncmp(curOpt, "top", length)) == 0) { @@ -1268,57 +1266,57 @@ if (packPtr != prevPtr) { /* * Unpack this window if it's currently packed. */ - if (packPtr->masterPtr != NULL) { - if ((packPtr->masterPtr != masterPtr) && - (packPtr->masterPtr->tkwin + if (packPtr->containerPtr != NULL) { + if ((packPtr->containerPtr != containerPtr) && + (packPtr->containerPtr->tkwin != Tk_Parent(packPtr->tkwin))) { Tk_UnmaintainGeometry(packPtr->tkwin, - packPtr->masterPtr->tkwin); + packPtr->containerPtr->tkwin); } Unlink(packPtr); } /* - * Add the window in the correct place in its master's packing + * Add the window in the correct place in its container's packing * order, then make sure that the window is managed by us. */ - packPtr->masterPtr = masterPtr; + packPtr->containerPtr = containerPtr; if (prevPtr == NULL) { - packPtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = packPtr; + packPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = packPtr; } else { packPtr->nextPtr = prevPtr->nextPtr; prevPtr->nextPtr = packPtr; } Tk_ManageGeometry(tkwin, &packerType, packPtr); - if (!(masterPtr->flags & DONT_PROPAGATE)) { - if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack") + if (!(containerPtr->flags & DONT_PROPAGATE)) { + if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack") != TCL_OK) { Tk_ManageGeometry(tkwin, NULL, NULL); Unlink(packPtr); return TCL_ERROR; } - masterPtr->flags |= ALLOCED_MASTER; + containerPtr->flags |= ALLOCED_CONTAINER; } } } /* - * Arrange for the master to be re-packed at the first idle moment. + * Arrange for the container to be re-packed at the first idle moment. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } return TCL_OK; } #endif /* !TK_NO_DEPRECATED */ @@ -1325,66 +1323,66 @@ /* *---------------------------------------------------------------------- * * Unlink -- * - * Remove a packer from its master's list of slaves. + * Remove a packer from its container's list of content. * * Results: * None. * * Side effects: - * The master will be scheduled for repacking. + * The container will be scheduled for repacking. * *---------------------------------------------------------------------- */ static void Unlink( Packer *packPtr) /* Window to unlink. */ { - Packer *masterPtr, *packPtr2; + Packer *containerPtr, *packPtr2; - masterPtr = packPtr->masterPtr; - if (masterPtr == NULL) { + containerPtr = packPtr->containerPtr; + if (containerPtr == NULL) { return; } - if (masterPtr->slavePtr == packPtr) { - masterPtr->slavePtr = packPtr->nextPtr; + if (containerPtr->contentPtr == packPtr) { + containerPtr->contentPtr = packPtr->nextPtr; } else { - for (packPtr2 = masterPtr->slavePtr; ; packPtr2 = packPtr2->nextPtr) { + for (packPtr2 = containerPtr->contentPtr; ; packPtr2 = packPtr2->nextPtr) { if (packPtr2 == NULL) { Tcl_Panic("Unlink couldn't find previous window"); } if (packPtr2->nextPtr == packPtr) { packPtr2->nextPtr = packPtr->nextPtr; break; } } } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); - } - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - - packPtr->masterPtr = NULL; - - /* - * If we have emptied this master from slaves it means we are no longer - * handling it and should mark it as free. - * - * Send the event "NoManagedChild" to the master to inform it about there + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); + } + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + + packPtr->containerPtr = NULL; + + /* + * If we have emptied this container from content it means we are no longer + * handling it and should mark it as free. + * + * Send the event "NoManagedChild" to the container to inform it about there * being no managed children inside it. */ - if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) { - TkFreeGeometryMaster(masterPtr->tkwin, "pack"); - masterPtr->flags &= ~ALLOCED_MASTER; - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) { + TkFreeGeometryContainer(containerPtr->tkwin, "pack"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL); } } /* @@ -1426,11 +1424,11 @@ * Results: * None. * * Side effects: * If a window was just deleted, clean up all its packer-related - * information. If it was just resized, repack its slaves, if any. + * information. If it was just resized, repack its content, if any. * *---------------------------------------------------------------------- */ static void @@ -1440,37 +1438,37 @@ XEvent *eventPtr) /* Describes what just happened. */ { Packer *packPtr = (Packer *)clientData; if (eventPtr->type == ConfigureNotify) { - if ((packPtr->slavePtr != NULL) + if ((packPtr->contentPtr != NULL) && !(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); } - if ((packPtr->masterPtr != NULL) + if ((packPtr->containerPtr != NULL) && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) { - if (!(packPtr->masterPtr->flags & REQUESTED_REPACK)) { + if (!(packPtr->containerPtr->flags & REQUESTED_REPACK)) { packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width; - packPtr->masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, packPtr->masterPtr); + packPtr->containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, packPtr->containerPtr); } } } else if (eventPtr->type == DestroyNotify) { - Packer *slavePtr, *nextPtr; + Packer *contentPtr, *nextPtr; - if (packPtr->masterPtr != NULL) { + if (packPtr->containerPtr != NULL) { Unlink(packPtr); } - for (slavePtr = packPtr->slavePtr; slavePtr != NULL; - slavePtr = nextPtr) { - Tk_ManageGeometry(slavePtr->tkwin, NULL, NULL); - Tk_UnmapWindow(slavePtr->tkwin); - slavePtr->masterPtr = NULL; - nextPtr = slavePtr->nextPtr; - slavePtr->nextPtr = NULL; + for (contentPtr = packPtr->contentPtr; contentPtr != NULL; + contentPtr = nextPtr) { + Tk_ManageGeometry(contentPtr->tkwin, NULL, NULL); + Tk_UnmapWindow(contentPtr->tkwin); + contentPtr->containerPtr = NULL; + nextPtr = contentPtr->nextPtr; + contentPtr->nextPtr = NULL; } if (packPtr->tkwin != NULL) { TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr; Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable, @@ -1482,67 +1480,67 @@ } packPtr->tkwin = NULL; Tcl_EventuallyFree(packPtr, (Tcl_FreeProc *) DestroyPacker); } else if (eventPtr->type == MapNotify) { /* - * When a master gets mapped, must redo the geometry computation so - * that all of its slaves get remapped. + * When a container gets mapped, must redo the geometry computation so + * that all of its content get remapped. */ - if ((packPtr->slavePtr != NULL) + if ((packPtr->contentPtr != NULL) && !(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); } } else if (eventPtr->type == UnmapNotify) { Packer *packPtr2; /* - * Unmap all of the slaves when the master gets unmapped, so that they + * Unmap all of the content when the container gets unmapped, so that they * don't bother to keep redisplaying themselves. */ - for (packPtr2 = packPtr->slavePtr; packPtr2 != NULL; + for (packPtr2 = packPtr->contentPtr; packPtr2 != NULL; packPtr2 = packPtr2->nextPtr) { Tk_UnmapWindow(packPtr2->tkwin); } } } /* *---------------------------------------------------------------------- * - * ConfigureSlaves -- + * ConfigureContent -- * * This implements the guts of the "pack configure" command. Given a list - * of slaves and configuration options, it arranges for the packer to - * manage the slaves and sets the specified options. + * of content and configuration options, it arranges for the packer to + * manage the content and sets the specified options. * * Results: * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is returned * and the interp's result is set to contain an error message. * * Side effects: - * Slave windows get taken over by the packer. + * Content windows get taken over by the packer. * *---------------------------------------------------------------------- */ static int -ConfigureSlaves( +ConfigureContent( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Window tkwin, /* Any window in application containing - * slaves. Used to look up slave names. */ + * content. Used to look up content names. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[]) /* Argument objects: contains one or more * window names followed by any number of * "option value" pairs. Caller must make sure * that there is at least one window name. */ { - Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr; - Tk_Window other, slave, parent, ancestor; - TkWindow *master; + Packer *containerPtr, *contentPtr, *prevPtr, *otherPtr; + Tk_Window other, content, parent, ancestor; + TkWindow *container; int i, j, numWindows, tmp, positionGiven; const char *string; static const char *const optionStrings[] = { "-after", "-anchor", "-before", "-expand", "-fill", "-in", "-ipadx", "-ipady", "-padx", "-pady", "-side", NULL }; @@ -1561,49 +1559,49 @@ break; } } /* - * Iterate over all of the slave windows, parsing the configuration - * options for each slave. It's a bit wasteful to re-parse the options for - * each slave, but things get too messy if we try to parse the arguments - * just once at the beginning. For example, if a slave already is packed + * Iterate over all of the content windows, parsing the configuration + * options for each content. It's a bit wasteful to re-parse the options for + * each content, but things get too messy if we try to parse the arguments + * just once at the beginning. For example, if a content already is packed * we want to just change a few existing values without resetting * everything. If there are multiple windows, the -after, -before, and -in * options only get processed for the first window. */ - masterPtr = NULL; + containerPtr = NULL; prevPtr = NULL; positionGiven = 0; for (j = 0; j < numWindows; j++) { - if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &content) != TCL_OK) { return TCL_ERROR; } - if (Tk_TopWinHierarchy(slave)) { + if (Tk_TopWinHierarchy(content)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } - slavePtr = GetPacker(slave); - slavePtr->flags &= ~OLD_STYLE; + contentPtr = GetPacker(content); + contentPtr->flags &= ~OLD_STYLE; /* - * If the slave isn't currently packed, reset all of its configuration + * If the content isn't currently packed, reset all of its configuration * information to default values (there could be old values left from * a previous packing). */ - if (slavePtr->masterPtr == NULL) { - slavePtr->side = TOP; - slavePtr->anchor = TK_ANCHOR_CENTER; - slavePtr->padX = slavePtr->padY = 0; - slavePtr->padLeft = slavePtr->padTop = 0; - slavePtr->iPadX = slavePtr->iPadY = 0; - slavePtr->flags &= ~(FILLX|FILLY|EXPAND); + if (contentPtr->containerPtr == NULL) { + contentPtr->side = TOP; + contentPtr->anchor = TK_ANCHOR_CENTER; + contentPtr->padX = contentPtr->padY = 0; + contentPtr->padLeft = contentPtr->padTop = 0; + contentPtr->iPadX = contentPtr->iPadY = 0; + contentPtr->flags &= ~(FILLX|FILLY|EXPAND); } for (i = numWindows; i < objc; i+=2) { if ((i+2) > objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -1623,25 +1621,25 @@ if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(other); - if (prevPtr->masterPtr == NULL) { + if (prevPtr->containerPtr == NULL) { notPacked: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } - masterPtr = prevPtr->masterPtr; + containerPtr = prevPtr->containerPtr; positionGiven = 1; } break; case CONF_ANCHOR: - if (Tk_GetAnchorFromObj(interp, objv[i+1], &slavePtr->anchor) + if (Tk_GetAnchorFromObj(interp, objv[i+1], &contentPtr->anchor) != TCL_OK) { return TCL_ERROR; } break; case CONF_BEFORE: @@ -1649,15 +1647,15 @@ if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } otherPtr = GetPacker(other); - if (otherPtr->masterPtr == NULL) { + if (otherPtr->containerPtr == NULL) { goto notPacked; } - masterPtr = otherPtr->masterPtr; - prevPtr = masterPtr->slavePtr; + containerPtr = otherPtr->containerPtr; + prevPtr = containerPtr->contentPtr; if (prevPtr == otherPtr) { prevPtr = NULL; } else { while (prevPtr->nextPtr != otherPtr) { prevPtr = prevPtr->nextPtr; @@ -1668,25 +1666,25 @@ break; case CONF_EXPAND: if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) { return TCL_ERROR; } - slavePtr->flags &= ~EXPAND; + contentPtr->flags &= ~EXPAND; if (tmp) { - slavePtr->flags |= EXPAND; + contentPtr->flags |= EXPAND; } break; case CONF_FILL: string = Tcl_GetString(objv[i+1]); if (strcmp(string, "none") == 0) { - slavePtr->flags &= ~(FILLX|FILLY); + contentPtr->flags &= ~(FILLX|FILLY); } else if (strcmp(string, "x") == 0) { - slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX; + contentPtr->flags = (contentPtr->flags & ~FILLY) | FILLX; } else if (strcmp(string, "y") == 0) { - slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY; + contentPtr->flags = (contentPtr->flags & ~FILLX) | FILLY; } else if (strcmp(string, "both") == 0) { - slavePtr->flags |= FILLX|FILLY; + contentPtr->flags |= FILLX|FILLY; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad fill style \"%s\": must be " "none, x, y, or both", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", NULL); @@ -1697,193 +1695,193 @@ if (j == 0) { if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(other); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(other); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; } } positionGiven = 1; } break; case CONF_IPADX: - if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadX = tmp * 2; + contentPtr->iPadX = tmp * 2; break; case CONF_IPADY: - if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadY = tmp * 2; + contentPtr->iPadY = tmp * 2; break; case CONF_PADX: - if (TkParsePadAmount(interp, slave, objv[i+1], - &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { + if (TkParsePadAmount(interp, content, objv[i+1], + &contentPtr->padLeft, &contentPtr->padX) != TCL_OK) { return TCL_ERROR; } break; case CONF_PADY: - if (TkParsePadAmount(interp, slave, objv[i+1], - &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { + if (TkParsePadAmount(interp, content, objv[i+1], + &contentPtr->padTop, &contentPtr->padY) != TCL_OK) { return TCL_ERROR; } break; case CONF_SIDE: if (Tcl_GetIndexFromObjStruct(interp, objv[i+1], sideNames, sizeof(char *), "side", TCL_EXACT, &side) != TCL_OK) { return TCL_ERROR; } - slavePtr->side = (Side) side; + contentPtr->side = (Side) side; break; } } /* - * If no position in a packing list was specified and the slave is + * If no position in a packing list was specified and the content is * already packed, then leave it in its current location in its * current packing list. */ - if (!positionGiven && (slavePtr->masterPtr != NULL)) { - masterPtr = slavePtr->masterPtr; + if (!positionGiven && (contentPtr->containerPtr != NULL)) { + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } /* - * If the slave is going to be put back after itself or the same -in + * If the content is going to be put back after itself or the same -in * window is passed in again, then just skip the whole operation, * since it won't work anyway. */ - if (prevPtr == slavePtr) { - masterPtr = slavePtr->masterPtr; + if (prevPtr == contentPtr) { + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } /* * If none of the "-in", "-before", or "-after" options has been - * specified, arrange for the slave to go at the end of the order for + * specified, arrange for the content to go at the end of the order for * its parent. */ if (!positionGiven) { - masterPtr = GetPacker(Tk_Parent(slave)); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(Tk_Parent(content)); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; } } } /* - * Make sure that the slave's parent is either the master or an - * ancestor of the master, and that the master and slave aren't the + * Make sure that the content's parent is either the container or an + * ancestor of the container, and that the container and content aren't the * same. */ - parent = Tk_Parent(slave); - for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { + parent = Tk_Parent(content); + for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside %s", Tcl_GetString(objv[j]), - Tk_PathName(masterPtr->tkwin))); + "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[j]), + Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } - if (slave == masterPtr->tkwin) { + if (content == containerPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside itself", Tcl_GetString(objv[j]))); + "can't pack \"%s\" inside itself", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } /* * Check for management loops. */ - for (master = (TkWindow *)masterPtr->tkwin; master != NULL; - master = (TkWindow *)TkGetGeomMaster(master)) { - if (master == (TkWindow *)slave) { + for (container = (TkWindow *)containerPtr->tkwin; container != NULL; + container = (TkWindow *)TkGetContainer(container)) { + if (container == (TkWindow *)content) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put %s inside %s, would cause management loop", - Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); + "can't put \"%s\" inside \"%s\": would cause management loop", + Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); return TCL_ERROR; } } - if (masterPtr->tkwin != Tk_Parent(slave)) { - ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin; - } - - /* - * Unpack the slave if it's currently packed, then position it after - * prevPtr. - */ - - if (slavePtr->masterPtr != NULL) { - if ((slavePtr->masterPtr != masterPtr) && - (slavePtr->masterPtr->tkwin - != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - } - - slavePtr->masterPtr = masterPtr; - if (prevPtr == NULL) { - slavePtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = slavePtr; - } else { - slavePtr->nextPtr = prevPtr->nextPtr; - prevPtr->nextPtr = slavePtr; - } - Tk_ManageGeometry(slave, &packerType, slavePtr); - prevPtr = slavePtr; - - if (!(masterPtr->flags & DONT_PROPAGATE)) { - if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack") - != TCL_OK) { - Tk_ManageGeometry(slave, NULL, NULL); - Unlink(slavePtr); - return TCL_ERROR; - } - masterPtr->flags |= ALLOCED_MASTER; - } - - /* - * Arrange for the master to be re-packed at the first idle moment. - */ - - scheduleLayout: - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (containerPtr->tkwin != Tk_Parent(content)) { + ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin; + } + + /* + * Unpack the content if it's currently packed, then position it after + * prevPtr. + */ + + if (contentPtr->containerPtr != NULL) { + if ((contentPtr->containerPtr != containerPtr) && + (contentPtr->containerPtr->tkwin + != Tk_Parent(contentPtr->tkwin))) { + Tk_UnmaintainGeometry(contentPtr->tkwin, + contentPtr->containerPtr->tkwin); + } + Unlink(contentPtr); + } + + contentPtr->containerPtr = containerPtr; + if (prevPtr == NULL) { + contentPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = contentPtr; + } else { + contentPtr->nextPtr = prevPtr->nextPtr; + prevPtr->nextPtr = contentPtr; + } + Tk_ManageGeometry(content, &packerType, contentPtr); + prevPtr = contentPtr; + + if (!(containerPtr->flags & DONT_PROPAGATE)) { + if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack") + != TCL_OK) { + Tk_ManageGeometry(content, NULL, NULL); + Unlink(contentPtr); + return TCL_ERROR; + } + containerPtr->flags |= ALLOCED_CONTAINER; + } + + /* + * Arrange for the container to be re-packed at the first idle moment. + */ + + scheduleLayout: + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } } return TCL_OK; } Index: generic/tkPanedWindow.c ================================================================== --- generic/tkPanedWindow.c +++ generic/tkPanedWindow.c @@ -4,12 +4,12 @@ * This module implements "paned window" widgets that are object based. A * "paned window" is a widget that manages the geometry for some number * of other widgets, placing a movable "sash" between them, which can be * used to alter the relative sizes of adjacent widgets. * - * Copyright (c) 1997 Sun Microsystems, Inc. - * Copyright (c) 2000 Ajuba Solutions. + * Copyright © 1997 Sun Microsystems, Inc. + * Copyright © 2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -68,47 +68,47 @@ ((stretch) == STRETCH_LAST && (index) == (last)) || \ ((stretch) == STRETCH_MIDDLE && (index) != (first) && (index) != (last))) typedef struct { Tk_OptionTable pwOptions; /* Token for paned window option table. */ - Tk_OptionTable slaveOpts; /* Token for slave cget option table. */ + Tk_OptionTable paneOpts; /* Token for pane cget option table. */ } OptionTables; /* * One structure of the following type is kept for each window * managed by a paned window widget. */ -typedef struct Slave { +typedef struct Pane { Tk_Window tkwin; /* Window being managed. */ int minSize; /* Minimum size of this pane, on the relevant * axis, in pixels. */ - int padx; /* Additional padding requested for slave, in + int padx; /* Additional padding requested for pane, in * the x dimension. */ - int pady; /* Additional padding requested for slave, in + int pady; /* Additional padding requested for pane, in * the y dimension. */ Tcl_Obj *widthPtr, *heightPtr; - /* Tcl_Obj rep's of slave width/height, to + /* Tcl_Obj rep's of pane width/height, to * allow for null values. */ - int width; /* Slave width. */ - int height; /* Slave height. */ + int width; /* Pane width. */ + int height; /* Pane height. */ int sticky; /* Sticky string. */ int x, y; /* Coordinates of the widget. */ int paneWidth, paneHeight; /* Pane dimensions (may be different from - * slave width/height). */ + * pane width/height). */ int sashx, sashy; /* Coordinates of the sash of the right or * bottom of this pane. */ int markx, marky; /* Coordinates of the last mark set for the * sash. */ int handlex, handley; /* Coordinates of the sash handle. */ - enum stretch stretch; /* Controls how slave grows/shrinks */ + enum stretch stretch; /* Controls how pane grows/shrinks */ int hide; /* Controls visibility of pane */ - struct PanedWindow *masterPtr; + struct PanedWindow *containerPtr; /* Paned window managing the window. */ Tk_Window after; /* Placeholder for parsing options. */ Tk_Window before; /* Placeholder for parsing options. */ -} Slave; +} Pane; /* * A data structure of the following type is kept for each paned window widget * managed by this file: */ @@ -119,11 +119,11 @@ Display *display; /* X's token for the window's display. */ Tcl_Interp *interp; /* Interpreter associated with widget. */ Tcl_Command widgetCmd; /* Token for square's widget command. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - Tk_OptionTable slaveOpts; /* Token for slave cget table. */ + Tk_OptionTable paneOpts; /* Token for pane cget table. */ Tk_3DBorder background; /* Background color. */ int borderWidth; /* Value of -borderwidth option. */ int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */ Tcl_Obj *widthPtr; /* Tcl_Obj rep for width. */ Tcl_Obj *heightPtr; /* Tcl_Obj rep for height. */ @@ -149,13 +149,13 @@ int proxyx, proxyy; /* Proxy x,y coordinates. */ Tk_3DBorder proxyBackground;/* Background color used to draw proxy. If NULL, use background. */ Tcl_Obj *proxyBorderWidthPtr; /* Tcl_Obj rep for proxyBorderWidth */ int proxyBorderWidth; /* Borderwidth used to draw proxy. */ int proxyRelief; /* Relief used to draw proxy, if TK_RELIEF_NULL then use relief. */ - Slave **slaves; /* Pointer to array of Slaves. */ - int numSlaves; /* Number of slaves. */ - int sizeofSlaves; /* Number of elements in the slaves array. */ + Pane **panes; /* Pointer to array of Panes. */ + int numPanes; /* Number of panes. */ + int sizeofPanes; /* Number of elements in the panes array. */ int flags; /* Flags for widget; see below. */ } PanedWindow; /* * Flags used for paned windows: @@ -198,29 +198,29 @@ XEvent *eventPtr); static void DisplayProxyWindow(ClientData clientData); static void PanedWindowWorldChanged(ClientData instanceData); static int PanedWindowWidgetObjCmd(ClientData clientData, Tcl_Interp *, int objc, Tcl_Obj * const objv[]); -static void PanedWindowLostSlaveProc(ClientData clientData, +static void PanedWindowLostPaneProc(ClientData clientData, Tk_Window tkwin); static void PanedWindowReqProc(ClientData clientData, Tk_Window tkwin); static void ArrangePanes(ClientData clientData); -static void Unlink(Slave *slavePtr); -static Slave * GetPane(PanedWindow *pwPtr, Tk_Window tkwin); +static void Unlink(Pane *panePtr); +static Pane * GetPane(PanedWindow *pwPtr, Tk_Window tkwin); static void GetFirstLastVisiblePane(PanedWindow *pwPtr, int *firstPtr, int *lastPtr); -static void SlaveStructureProc(ClientData clientData, +static void PaneStructureProc(ClientData clientData, XEvent *eventPtr); static int PanedWindowSashCommand(PanedWindow *pwPtr, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); static int PanedWindowProxyCommand(PanedWindow *pwPtr, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); static void ComputeGeometry(PanedWindow *pwPtr); -static int ConfigureSlaves(PanedWindow *pwPtr, +static int ConfigurePanes(PanedWindow *pwPtr, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); static void DestroyOptionTables(ClientData clientData, Tcl_Interp *interp); static int SetSticky(ClientData clientData, Tcl_Interp *interp, @@ -231,28 +231,28 @@ char *recordPtr, TkSizeT internalOffset); static void RestoreSticky(ClientData clientData, Tk_Window tkwin, char *internalPtr, char *oldInternalPtr); static void AdjustForSticky(int sticky, int cavityWidth, int cavityHeight, int *xPtr, int *yPtr, - int *slaveWidthPtr, int *slaveHeightPtr); + int *paneWidthPtr, int *paneHeightPtr); static void MoveSash(PanedWindow *pwPtr, int sash, int diff); static int ObjectIsEmpty(Tcl_Obj *objPtr); static void * ComputeSlotAddress(void *recordPtr, TkSizeT offset); static int PanedWindowIdentifyCoords(PanedWindow *pwPtr, Tcl_Interp *interp, int x, int y); /* - * Sashes are between panes only, so there is one less sash than slaves + * Sashes are between panes only, so there is one less sash than panes */ #define ValidSashIndex(pwPtr, sash) \ - (((sash) >= 0) && ((sash) < ((pwPtr)->numSlaves-1))) + (((sash) >= 0) && ((sash) < ((pwPtr)->numPanes-1))) static const Tk_GeomMgr panedWindowMgrType = { "panedwindow", /* name */ PanedWindowReqProc, /* requestProc */ - PanedWindowLostSlaveProc, /* lostSlaveProc */ + PanedWindowLostPaneProc, /* lostPaneProc */ }; /* * Information used for objv parsing. */ @@ -259,11 +259,11 @@ #define GEOMETRY 0x0001 /* * The following structure contains pointers to functions used for processing - * the custom "-sticky" option for slave windows. + * the custom "-sticky" option for panes. */ static const Tk_ObjCustomOption stickyOption = { "sticky", /* name */ SetSticky, /* setProc */ @@ -332,37 +332,37 @@ DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr), offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; -static const Tk_OptionSpec slaveOptionSpecs[] = { +static const Tk_OptionSpec paneOptionSpecs[] = { {TK_OPTION_WINDOW, "-after", NULL, NULL, - DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Slave, after), + DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Pane, after), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_WINDOW, "-before", NULL, NULL, - DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Slave, before), + DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Pane, before), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-height", NULL, NULL, - DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Slave, heightPtr), - offsetof(Slave, height), TK_OPTION_NULL_OK, 0, 0}, + DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightPtr), + offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", - DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Slave, hide), 0,0,GEOMETRY}, + DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY}, {TK_OPTION_PIXELS, "-minsize", NULL, NULL, - DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Slave, minSize), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Pane, minSize), 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Slave, padx), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Pane, padx), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Slave, pady), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Pane, pady), 0, 0, 0}, {TK_OPTION_CUSTOM, "-sticky", NULL, NULL, - DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Slave, sticky), 0, + DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky), 0, &stickyOption, 0}, {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch", - DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Slave, stretch), 0, + DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), 0, (ClientData) stretchStrings, 0}, {TK_OPTION_PIXELS, "-width", NULL, NULL, - DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Slave, widthPtr), - offsetof(Slave, width), TK_OPTION_NULL_OK, 0, 0}, + DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthPtr), + offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; /* *-------------------------------------------------------------- @@ -381,20 +381,19 @@ *-------------------------------------------------------------- */ int Tk_PanedWindowObjCmd( - ClientData dummy, /* NULL. */ + TCL_UNUSED(ClientData), /* NULL. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { PanedWindow *pwPtr; Tk_Window tkwin, parent; OptionTables *pwOpts; XSetWindowAttributes atts; - (void)dummy; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } @@ -427,11 +426,11 @@ /* * Create the paned window option tables. */ pwOpts->pwOptions = Tk_CreateOptionTable(interp, optionSpecs); - pwOpts->slaveOpts = Tk_CreateOptionTable(interp, slaveOptionSpecs); + pwOpts->paneOpts = Tk_CreateOptionTable(interp, paneOptionSpecs); } Tk_SetClass(tkwin, "Panedwindow"); /* @@ -445,11 +444,11 @@ pwPtr->interp = interp; pwPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, pwPtr, PanedWindowCmdDeletedProc); pwPtr->optionTable = pwOpts->pwOptions; - pwPtr->slaveOpts = pwOpts->slaveOpts; + pwPtr->paneOpts = pwOpts->paneOpts; pwPtr->relief = TK_RELIEF_RAISED; pwPtr->gc = NULL; pwPtr->cursor = NULL; pwPtr->sashCursor = NULL; @@ -470,11 +469,11 @@ PanedWindowEventProc, pwPtr); /* * Find the toplevel ancestor of the panedwindow, and make a proxy win as * a child of that window; this way the proxy can always float above - * slaves in the panedwindow. + * panes in the panedwindow. */ parent = Tk_Parent(pwPtr->tkwin); while (!(Tk_IsTopLevel(parent))) { parent = Tk_Parent(parent); @@ -505,11 +504,11 @@ Tk_DestroyWindow(pwPtr->proxywin); Tk_DestroyWindow(pwPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(pwPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(pwPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -547,14 +546,14 @@ PW_PANECONFIGURE, PW_PANES, PW_PROXY, PW_SASH }; Tcl_Obj *resultObj; int index, count, i, x, y; Tk_Window tkwin; - Slave *slavePtr; + Pane *panePtr; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "command", 0, &index) != TCL_OK) { @@ -568,11 +567,11 @@ if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "widget ?widget ...?"); result = TCL_ERROR; break; } - result = ConfigureSlaves(pwPtr, interp, objc, objv); + result = ConfigurePanes(pwPtr, interp, objc, objv); break; case PW_CGET: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); @@ -603,11 +602,10 @@ result = ConfigurePanedWindow(interp, pwPtr, objc - 2, objv + 2); } break; case PW_FORGET: { - int i; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "widget ?widget ...?"); result = TCL_ERROR; break; @@ -615,25 +613,25 @@ /* * Clean up each window named in the arg list. */ for (count = 0, i = 2; i < objc; i++) { - Tk_Window slave = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), + Tk_Window pane = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), pwPtr->tkwin); - if (slave == NULL) { + if (pane == NULL) { continue; } - slavePtr = GetPane(pwPtr, slave); - if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) { + panePtr = GetPane(pwPtr, pane); + if ((panePtr != NULL) && (panePtr->containerPtr != NULL)) { count++; - Tk_ManageGeometry(slave, NULL, NULL); - Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); - Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); - Unlink(slavePtr); + Tk_ManageGeometry(pane, NULL, NULL); + Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin); + Tk_DeleteEventHandler(panePtr->tkwin, StructureNotifyMask, + PaneStructureProc, panePtr); + Tk_UnmapWindow(panePtr->tkwin); + Unlink(panePtr); } if (count != 0) { ComputeGeometry(pwPtr); } } @@ -665,19 +663,19 @@ if (tkwin == NULL) { result = TCL_ERROR; break; } resultObj = NULL; - for (i = 0; i < pwPtr->numSlaves; i++) { - if (pwPtr->slaves[i]->tkwin == tkwin) { + for (i = 0; i < pwPtr->numPanes; i++) { + if (pwPtr->panes[i]->tkwin == tkwin) { resultObj = Tk_GetOptionValue(interp, - pwPtr->slaves[i], pwPtr->slaveOpts, + pwPtr->panes[i], pwPtr->paneOpts, objv[3], tkwin); } } if (resultObj == NULL) { - if (i == pwPtr->numSlaves) { + if (i == pwPtr->numPanes) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "not managed by this window", -1)); Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); } @@ -688,11 +686,11 @@ break; case PW_PANECONFIGURE: if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, - "pane ?option? ?value option value ...?"); + "pane ?-option value ...?"); result = TCL_ERROR; break; } resultObj = NULL; if (objc <= 4) { @@ -705,14 +703,14 @@ */ result = TCL_ERROR; break; } - for (i = 0; i < pwPtr->numSlaves; i++) { - if (pwPtr->slaves[i]->tkwin == tkwin) { + for (i = 0; i < pwPtr->numPanes; i++) { + if (pwPtr->panes[i]->tkwin == tkwin) { resultObj = Tk_GetOptionInfo(interp, - pwPtr->slaves[i], pwPtr->slaveOpts, + pwPtr->panes[i], pwPtr->paneOpts, (objc == 4) ? objv[3] : NULL, pwPtr->tkwin); if (resultObj == NULL) { result = TCL_ERROR; } else { @@ -720,19 +718,19 @@ } break; } } } else { - result = ConfigureSlaves(pwPtr, interp, objc, objv); + result = ConfigurePanes(pwPtr, interp, objc, objv); } break; case PW_PANES: resultObj = Tcl_NewObj(); - for (i = 0; i < pwPtr->numSlaves; i++) { + for (i = 0; i < pwPtr->numPanes; i++) { Tcl_ListObjAppendElement(NULL, resultObj, - TkNewWindowObj(pwPtr->slaves[i]->tkwin)); + Tk_NewWindowObj(pwPtr->panes[i]->tkwin)); } Tcl_SetObjResult(interp, resultObj); break; case PW_PROXY: @@ -748,41 +746,41 @@ } /* *---------------------------------------------------------------------- * - * ConfigureSlaves -- + * ConfigurePanes -- * - * Add or alter the configuration options of a slave in a paned window. + * Add or alter the configuration options of a pane in a paned window. * * Results: * Standard Tcl result. * * Side effects: - * Depends on options; may add a slave to the paned window, may alter the - * geometry management options of a slave. + * Depends on options; may add a pane to the paned window, may alter the + * geometry management options of a pane. * *---------------------------------------------------------------------- */ static int -ConfigureSlaves( +ConfigurePanes( PanedWindow *pwPtr, /* Information about paned window. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int i, firstOptionArg, j, found, doubleBw, index, numNewSlaves, haveLoc; + int i, firstOptionArg, j, found, doubleBw, index, numNewPanes, haveLoc; int insertIndex; Tk_Window tkwin = NULL, ancestor, parent; - Slave *slavePtr, **inserts, **newSlaves; - Slave options; + Pane *panePtr, **inserts, **newPanes; + Pane options; const char *arg; /* * Find the non-window name arguments; these are the configure options for - * the slaves. Also validate that the window names given are legitimate + * the panes. Also validate that the window names given are legitimate * (ie, they are real windows, they are not the panedwindow itself, etc.). */ for (i = 2; i < objc; i++) { arg = Tcl_GetString(objv[i]); @@ -816,12 +814,12 @@ Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } else { /* - * Make sure the panedwindow is the parent of the slave, - * or a descendant of the slave's parent. + * Make sure the panedwindow is the parent of the pane, + * or a descendant of the pane's parent. */ parent = Tk_Parent(tkwin); for (ancestor = pwPtr->tkwin;;ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { @@ -846,12 +844,12 @@ * into an easy-to-find location (a local variable). Also, check the * return from Tk_SetOptions once, here, so we can save a little bit of * extra testing in the for loop below. */ - memset((void *)&options, 0, sizeof(Slave)); - if (Tk_SetOptions(interp, &options, pwPtr->slaveOpts, + memset((void *)&options, 0, sizeof(Pane)); + if (Tk_SetOptions(interp, &options, pwPtr->paneOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; } @@ -864,21 +862,21 @@ index = -1; haveLoc = 0; if (options.after != NULL) { tkwin = options.after; haveLoc = 1; - for (i = 0; i < pwPtr->numSlaves; i++) { - if (options.after == pwPtr->slaves[i]->tkwin) { + for (i = 0; i < pwPtr->numPanes; i++) { + if (options.after == pwPtr->panes[i]->tkwin) { index = i + 1; break; } } } else if (options.before != NULL) { tkwin = options.before; haveLoc = 1; - for (i = 0; i < pwPtr->numSlaves; i++) { - if (options.before == pwPtr->slaves[i]->tkwin) { + for (i = 0; i < pwPtr->numPanes; i++) { + if (options.before == pwPtr->panes[i]->tkwin) { index = i; break; } } } @@ -891,59 +889,59 @@ if (haveLoc && index == -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not managed by %s", Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); - Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, + Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts, pwPtr->tkwin); return TCL_ERROR; } /* - * Allocate an array to hold, in order, the pointers to the slave + * Allocate an array to hold, in order, the pointers to the pane * structures corresponding to the windows specified. Some of those * structures may already have existed, some may be new. */ - inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); + inserts = (Pane **)ckalloc(sizeof(Pane *) * (firstOptionArg - 2)); insertIndex = 0; /* - * Populate the inserts array, creating new slave structures as necessary, + * Populate the inserts array, creating new pane structures as necessary, * applying the options to each structure as we go, and, if necessary, - * marking the spot in the original slaves array as empty (for - * pre-existing slave structures). + * marking the spot in the original panes array as empty (for + * pre-existing pane structures). */ - for (i = 0, numNewSlaves = 0; i < firstOptionArg - 2; i++) { + for (i = 0, numNewPanes = 0; i < firstOptionArg - 2; i++) { /* * We don't check that tkwin is NULL here, because the pre-pass above * guarantees that the input at this stage is good. */ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[i + 2]), pwPtr->tkwin); found = 0; - for (j = 0; j < pwPtr->numSlaves; j++) { - if (pwPtr->slaves[j] != NULL && pwPtr->slaves[j]->tkwin == tkwin) { - Tk_SetOptions(interp, pwPtr->slaves[j], - pwPtr->slaveOpts, objc - firstOptionArg, + for (j = 0; j < pwPtr->numPanes; j++) { + if (pwPtr->panes[j] != NULL && pwPtr->panes[j]->tkwin == tkwin) { + Tk_SetOptions(interp, pwPtr->panes[j], + pwPtr->paneOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); - if (pwPtr->slaves[j]->minSize < 0) { - pwPtr->slaves[j]->minSize = 0; + if (pwPtr->panes[j]->minSize < 0) { + pwPtr->panes[j]->minSize = 0; } found = 1; /* - * If the slave is supposed to move, add it to the inserts + * If the pane is supposed to move, add it to the inserts * array now; otherwise, leave it where it is. */ if (index != -1) { - inserts[insertIndex++] = pwPtr->slaves[j]; - pwPtr->slaves[j] = NULL; + inserts[insertIndex++] = pwPtr->panes[j]; + pwPtr->panes[j] = NULL; } break; } } @@ -950,11 +948,11 @@ if (found) { continue; } /* - * Make sure this slave wasn't already put into the inserts array, + * Make sure this pane wasn't already put into the inserts array, * i.e., when the user specifies the same window multiple times in a * single add commaned. */ for (j = 0; j < insertIndex; j++) { if (inserts[j]->tkwin == tkwin) { @@ -965,108 +963,108 @@ if (found) { continue; } /* - * Create a new slave structure and initialize it. All slaves start + * Create a new pane structure and initialize it. All panes start * out with their "natural" dimensions. */ - slavePtr = (Slave *)ckalloc(sizeof(Slave)); - memset(slavePtr, 0, sizeof(Slave)); - Tk_InitOptions(interp, slavePtr, pwPtr->slaveOpts, + panePtr = (Pane *)ckalloc(sizeof(Pane)); + memset(panePtr, 0, sizeof(Pane)); + Tk_InitOptions(interp, panePtr, pwPtr->paneOpts, pwPtr->tkwin); - Tk_SetOptions(interp, slavePtr, pwPtr->slaveOpts, + Tk_SetOptions(interp, panePtr, pwPtr->paneOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); - slavePtr->tkwin = tkwin; - slavePtr->masterPtr = pwPtr; - doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; - if (slavePtr->width > 0) { - slavePtr->paneWidth = slavePtr->width; - } else { - slavePtr->paneWidth = Tk_ReqWidth(tkwin) + doubleBw; - } - if (slavePtr->height > 0) { - slavePtr->paneHeight = slavePtr->height; - } else { - slavePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw; - } - if (slavePtr->minSize < 0) { - slavePtr->minSize = 0; - } - - /* - * Set up the geometry management callbacks for this slave. - */ - - Tk_CreateEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); - Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, slavePtr); - inserts[insertIndex++] = slavePtr; - numNewSlaves++; - } - - /* - * Allocate the new slaves array, then copy the slaves into it, in order. - */ - - i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves); - newSlaves = (Slave **)ckalloc(i); - memset(newSlaves, 0, i); + panePtr->tkwin = tkwin; + panePtr->containerPtr = pwPtr; + doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; + if (panePtr->width > 0) { + panePtr->paneWidth = panePtr->width; + } else { + panePtr->paneWidth = Tk_ReqWidth(tkwin) + doubleBw; + } + if (panePtr->height > 0) { + panePtr->paneHeight = panePtr->height; + } else { + panePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw; + } + if (panePtr->minSize < 0) { + panePtr->minSize = 0; + } + + /* + * Set up the geometry management callbacks for this pane. + */ + + Tk_CreateEventHandler(panePtr->tkwin, StructureNotifyMask, + PaneStructureProc, panePtr); + Tk_ManageGeometry(panePtr->tkwin, &panedWindowMgrType, panePtr); + inserts[insertIndex++] = panePtr; + numNewPanes++; + } + + /* + * Allocate the new panes array, then copy the panes into it, in order. + */ + + i = sizeof(Pane *) * (pwPtr->numPanes + numNewPanes); + newPanes = (Pane **)ckalloc(i); + memset(newPanes, 0, i); if (index == -1) { /* - * If none of the existing slaves have to be moved, just copy the old + * If none of the existing panes have to be moved, just copy the old * and append the new. */ - memcpy((void *)&(newSlaves[0]), pwPtr->slaves, - sizeof(Slave *) * pwPtr->numSlaves); - memcpy((void *)&(newSlaves[pwPtr->numSlaves]), inserts, - sizeof(Slave *) * numNewSlaves); + memcpy((void *)&(newPanes[0]), pwPtr->panes, + sizeof(Pane *) * pwPtr->numPanes); + memcpy((void *)&(newPanes[pwPtr->numPanes]), inserts, + sizeof(Pane *) * numNewPanes); } else { /* - * If some of the existing slaves were moved, the old slaves array + * If some of the existing panes were moved, the old panes array * will be partially populated, with some valid and some invalid - * entries. Walk through it, copying valid entries to the new slaves + * entries. Walk through it, copying valid entries to the new panes * array as we go; when we get to the insert location for the new - * slaves, copy the inserts array over, then finish off the old slaves + * panes, copy the inserts array over, then finish off the old panes * array. */ for (i = 0, j = 0; i < index; i++) { - if (pwPtr->slaves[i] != NULL) { - newSlaves[j] = pwPtr->slaves[i]; + if (pwPtr->panes[i] != NULL) { + newPanes[j] = pwPtr->panes[i]; j++; } } - memcpy((void *)&(newSlaves[j]), inserts, sizeof(Slave *)*insertIndex); + memcpy((void *)&(newPanes[j]), inserts, sizeof(Pane *)*insertIndex); j += firstOptionArg - 2; - for (i = index; i < pwPtr->numSlaves; i++) { - if (pwPtr->slaves[i] != NULL) { - newSlaves[j] = pwPtr->slaves[i]; + for (i = index; i < pwPtr->numPanes; i++) { + if (pwPtr->panes[i] != NULL) { + newPanes[j] = pwPtr->panes[i]; j++; } } } /* - * Make the new slaves array the paned window's slave array, and clean up. + * Make the new panes array the paned window's pane array, and clean up. */ - ckfree(pwPtr->slaves); + ckfree(pwPtr->panes); ckfree(inserts); - pwPtr->slaves = newSlaves; + pwPtr->panes = newPanes; /* - * Set the paned window's slave count to the new value. + * Set the paned window's pane count to the new value. */ - pwPtr->numSlaves += numNewSlaves; + pwPtr->numPanes += numNewPanes; - Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin); + Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts, pwPtr->tkwin); ComputeGeometry(pwPtr); return TCL_OK; } @@ -1100,11 +1098,11 @@ enum sashOptions { SASH_COORD, SASH_DRAGTO, SASH_MARK, SASH_PLACE }; int index, sash, x, y, diff; Tcl_Obj *coords[2]; - Slave *slavePtr; + Pane *panePtr; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?"); return TCL_ERROR; } @@ -1129,14 +1127,14 @@ Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } - slavePtr = pwPtr->slaves[sash]; + panePtr = pwPtr->panes[sash]; - coords[0] = Tcl_NewWideIntObj(slavePtr->sashx); - coords[1] = Tcl_NewWideIntObj(slavePtr->sashy); + coords[0] = Tcl_NewWideIntObj(panePtr->sashx); + coords[1] = Tcl_NewWideIntObj(panePtr->sashy); Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); break; case SASH_MARK: if (objc != 6 && objc != 4) { @@ -1162,15 +1160,15 @@ if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK) { return TCL_ERROR; } - pwPtr->slaves[sash]->markx = x; - pwPtr->slaves[sash]->marky = y; + pwPtr->panes[sash]->markx = x; + pwPtr->panes[sash]->marky = y; } else { - coords[0] = Tcl_NewWideIntObj(pwPtr->slaves[sash]->markx); - coords[1] = Tcl_NewWideIntObj(pwPtr->slaves[sash]->marky); + coords[0] = Tcl_NewWideIntObj(pwPtr->panes[sash]->markx); + coords[1] = Tcl_NewWideIntObj(pwPtr->panes[sash]->marky); Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); } break; case SASH_DRAGTO: @@ -1197,22 +1195,22 @@ if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK) { return TCL_ERROR; } - slavePtr = pwPtr->slaves[sash]; + panePtr = pwPtr->panes[sash]; if (pwPtr->orient == ORIENT_HORIZONTAL) { if (index == SASH_PLACE) { - diff = x - pwPtr->slaves[sash]->sashx; + diff = x - pwPtr->panes[sash]->sashx; } else { - diff = x - pwPtr->slaves[sash]->markx; + diff = x - pwPtr->panes[sash]->markx; } } else { if (index == SASH_PLACE) { - diff = y - pwPtr->slaves[sash]->sashy; + diff = y - pwPtr->panes[sash]->sashy; } else { - diff = y - pwPtr->slaves[sash]->marky; + diff = y - pwPtr->panes[sash]->marky; } } MoveSash(pwPtr, sash, diff); ComputeGeometry(pwPtr); @@ -1368,19 +1366,19 @@ pwPtr->flags |= REDRAW_PENDING; } } else if (eventPtr->type == DestroyNotify) { DestroyPanedWindow(pwPtr); } else if (eventPtr->type == UnmapNotify) { - for (i = 0; i < pwPtr->numSlaves; i++) { - if (!pwPtr->slaves[i]->hide) { - Tk_UnmapWindow(pwPtr->slaves[i]->tkwin); + for (i = 0; i < pwPtr->numPanes; i++) { + if (!pwPtr->panes[i]->hide) { + Tk_UnmapWindow(pwPtr->panes[i]->tkwin); } } } else if (eventPtr->type == MapNotify) { - for (i = 0; i < pwPtr->numSlaves; i++) { - if (!pwPtr->slaves[i]->hide) { - Tk_MapWindow(pwPtr->slaves[i]->tkwin); + for (i = 0; i < pwPtr->numPanes; i++) { + if (!pwPtr->panes[i]->hide) { + Tk_MapWindow(pwPtr->panes[i]->tkwin); } } } } @@ -1442,11 +1440,11 @@ static void DisplayPanedWindow( ClientData clientData) /* Information about window. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; - Slave *slavePtr; + Pane *panePtr; Pixmap pixmap; Tk_Window tkwin = pwPtr->tkwin; int i, sashWidth, sashHeight; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); int first, last; @@ -1495,23 +1493,23 @@ /* * Draw the sashes. */ GetFirstLastVisiblePane(pwPtr, &first, &last); - for (i = 0; i < pwPtr->numSlaves - 1; i++) { - slavePtr = pwPtr->slaves[i]; - if (slavePtr->hide || i == last) { + for (i = 0; i < pwPtr->numPanes - 1; i++) { + panePtr = pwPtr->panes[i]; + if (panePtr->hide || i == last) { continue; } if (sashWidth > 0 && sashHeight > 0) { Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, - slavePtr->sashx, slavePtr->sashy, sashWidth, sashHeight, + panePtr->sashx, panePtr->sashy, sashWidth, sashHeight, 1, pwPtr->sashRelief); } if (pwPtr->showHandle) { Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, - slavePtr->handlex, slavePtr->handley, + panePtr->handlex, panePtr->handley, pwPtr->handleSize, pwPtr->handleSize, 1, TK_RELIEF_RAISED); } } @@ -1568,27 +1566,27 @@ if (pwPtr->flags & RESIZE_PENDING) { Tcl_CancelIdleCall(ArrangePanes, pwPtr); } /* - * Clean up the slave list; foreach slave: - * o Cancel the slave's structure notification callback - * o Cancel geometry management for the slave. - * o Free memory for the slave + * Clean up the pane list; foreach pane: + * o Cancel the pane's structure notification callback + * o Cancel geometry management for the pane. + * o Free memory for the pane */ - for (i = 0; i < pwPtr->numSlaves; i++) { - Tk_DeleteEventHandler(pwPtr->slaves[i]->tkwin, StructureNotifyMask, - SlaveStructureProc, pwPtr->slaves[i]); - Tk_ManageGeometry(pwPtr->slaves[i]->tkwin, NULL, NULL); - Tk_FreeConfigOptions((char *) pwPtr->slaves[i], pwPtr->slaveOpts, + for (i = 0; i < pwPtr->numPanes; i++) { + Tk_DeleteEventHandler(pwPtr->panes[i]->tkwin, StructureNotifyMask, + PaneStructureProc, pwPtr->panes[i]); + Tk_ManageGeometry(pwPtr->panes[i]->tkwin, NULL, NULL); + Tk_FreeConfigOptions((char *) pwPtr->panes[i], pwPtr->paneOpts, pwPtr->tkwin); - ckfree(pwPtr->slaves[i]); - pwPtr->slaves[i] = NULL; + ckfree(pwPtr->panes[i]); + pwPtr->panes[i] = NULL; } - if (pwPtr->slaves) { - ckfree(pwPtr->slaves); + if (pwPtr->panes) { + ckfree(pwPtr->panes); } /* * Remove the widget command from the interpreter. */ @@ -1626,72 +1624,70 @@ static void PanedWindowReqProc( ClientData clientData, /* Paned window's information about window * that got new preferred geometry. */ - Tk_Window tkwin) /* Other Tk-related information about the + TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { - Slave *slavePtr = (Slave *)clientData; - PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr; - (void)tkwin; + Pane *panePtr = (Pane *)clientData; + PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr; if (Tk_IsMapped(pwPtr->tkwin)) { if (!(pwPtr->flags & RESIZE_PENDING)) { pwPtr->flags |= RESIZE_PENDING; Tcl_DoWhenIdle(ArrangePanes, pwPtr); } } else { - int doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; + int doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; - if (slavePtr->width <= 0) { - slavePtr->paneWidth = Tk_ReqWidth(slavePtr->tkwin) + doubleBw; + if (panePtr->width <= 0) { + panePtr->paneWidth = Tk_ReqWidth(panePtr->tkwin) + doubleBw; } - if (slavePtr->height <= 0) { - slavePtr->paneHeight = Tk_ReqHeight(slavePtr->tkwin) + doubleBw; + if (panePtr->height <= 0) { + panePtr->paneHeight = Tk_ReqHeight(panePtr->tkwin) + doubleBw; } ComputeGeometry(pwPtr); } } /* *-------------------------------------------------------------- * - * PanedWindowLostSlaveProc -- + * PanedWindowLostPaneProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a pane that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all information about the slave. Causes geometry to be + * Forgets all information about the pane. Causes geometry to be * recomputed for the panedwindow. * *-------------------------------------------------------------- */ static void -PanedWindowLostSlaveProc( - ClientData clientData, /* Grid structure for slave window that was +PanedWindowLostPaneProc( + ClientData clientData, /* Grid structure for the pane that was * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ -{ - Slave *slavePtr = (Slave *)clientData; - PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr; - (void)tkwin; - - if (pwPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); - } - Unlink(slavePtr); - Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); - slavePtr->tkwin = NULL; - ckfree(slavePtr); + TCL_UNUSED(Tk_Window)) /* Tk's handle for the pane. */ +{ + Pane *panePtr = (Pane *)clientData; + PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr; + + if (pwPtr->tkwin != Tk_Parent(panePtr->tkwin)) { + Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin); + } + Unlink(panePtr); + Tk_DeleteEventHandler(panePtr->tkwin, StructureNotifyMask, + PaneStructureProc, panePtr); + Tk_UnmapWindow(panePtr->tkwin); + panePtr->tkwin = NULL; + ckfree(panePtr); ComputeGeometry(pwPtr); } /* *-------------------------------------------------------------- @@ -1705,23 +1701,23 @@ * * Results: * None. * * Side effects: - * The slaves of masterPtr may get resized or moved. + * The panes of containerPtr may get resized or moved. * *-------------------------------------------------------------- */ static void ArrangePanes( - ClientData clientData) /* Structure describing parent whose slaves + ClientData clientData) /* Structure describing parent whose panes * are to be re-layed out. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; - Slave *slavePtr; - int i, slaveWidth, slaveHeight, slaveX, slaveY; + Pane *panePtr; + int i, newPaneWidth, newPaneHeight, paneX, paneY; int paneWidth, paneHeight, paneSize, paneMinSize; int doubleBw; int x, y; int sashWidth, sashOffset, sashCount, handleOffset; int sashReserve, sxReserve, syReserve; @@ -1732,17 +1728,17 @@ const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); pwPtr->flags &= ~(REQUESTED_RELAYOUT|RESIZE_PENDING); /* - * If the parent has no slaves anymore, then don't do anything at all: + * If the parent has no panes anymore, then don't do anything at all: * just leave the parent's size as-is. Otherwise there is no way to * "relinquish" control over the parent so another geometry manager can * take over. */ - if (pwPtr->numSlaves == 0) { + if (pwPtr->numPanes == 0) { return; } Tcl_Preserve(pwPtr); @@ -1777,41 +1773,41 @@ sashWidth = (2 * pwPtr->sashPad) + pwPtr->sashWidth; handleOffset = ((pwPtr->sashWidth - pwPtr->handleSize) / 2) + pwPtr->sashPad; } - for (i = sashCount = 0; i < pwPtr->numSlaves; i++) { - slavePtr = pwPtr->slaves[i]; + for (i = sashCount = 0; i < pwPtr->numPanes; i++) { + panePtr = pwPtr->panes[i]; - if (slavePtr->hide) { + if (panePtr->hide) { continue; } /* - * Compute the total size needed by all the slaves and the left-over, + * Compute the total size needed by all the panes and the left-over, * or shortage of space available. */ if (horizontal) { - if (slavePtr->width > 0) { - paneSize = slavePtr->width; - } else { - paneSize = slavePtr->paneWidth; - } - stretchReserve -= paneSize + (2 * slavePtr->padx); - } else { - if (slavePtr->height > 0) { - paneSize = slavePtr->height; - } else { - paneSize = slavePtr->paneHeight; - } - stretchReserve -= paneSize + (2 * slavePtr->pady); - } - if (IsStretchable(slavePtr->stretch,i,first,last) + if (panePtr->width > 0) { + paneSize = panePtr->width; + } else { + paneSize = panePtr->paneWidth; + } + stretchReserve -= paneSize + (2 * panePtr->padx); + } else { + if (panePtr->height > 0) { + paneSize = panePtr->height; + } else { + paneSize = panePtr->paneHeight; + } + stretchReserve -= paneSize + (2 * panePtr->pady); + } + if (IsStretchable(panePtr->stretch,i,first,last) && Tk_IsMapped(pwPtr->tkwin)) { paneDynSize += paneSize; - paneDynMinSize += slavePtr->minSize; + paneDynMinSize += panePtr->minSize; } if (i != last) { stretchReserve -= sashWidth; sashCount++; } @@ -1819,67 +1815,67 @@ /* * Second pass; adjust/arrange panes. */ - for (i = 0; i < pwPtr->numSlaves; i++) { - slavePtr = pwPtr->slaves[i]; + for (i = 0; i < pwPtr->numPanes; i++) { + panePtr = pwPtr->panes[i]; - if (slavePtr->hide) { - Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + if (panePtr->hide) { + Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin); + Tk_UnmapWindow(panePtr->tkwin); continue; } /* - * Compute the size of this slave. The algorithm (assuming a + * Compute the size of this pane. The algorithm (assuming a * horizontal paned window) is: * * 1. Get "base" dimensions. If a width or height is specified for - * this slave, use those values; else use the ReqWidth/ReqHeight. + * this pane, use those values; else use the ReqWidth/ReqHeight. * 2. Using base dimensions, pane dimensions, and sticky values, * determine the x and y, and actual width and height of the * widget. */ - doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; - slaveWidth = (slavePtr->width > 0 ? slavePtr->width : - Tk_ReqWidth(slavePtr->tkwin) + doubleBw); - slaveHeight = (slavePtr->height > 0 ? slavePtr->height : - Tk_ReqHeight(slavePtr->tkwin) + doubleBw); - paneMinSize = slavePtr->minSize; + doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; + newPaneWidth = (panePtr->width > 0 ? panePtr->width : + Tk_ReqWidth(panePtr->tkwin) + doubleBw); + newPaneHeight = (panePtr->height > 0 ? panePtr->height : + Tk_ReqHeight(panePtr->tkwin) + doubleBw); + paneMinSize = panePtr->minSize; /* * Calculate pane width and height. */ if (horizontal) { - if (slavePtr->width > 0) { - paneSize = slavePtr->width; + if (panePtr->width > 0) { + paneSize = panePtr->width; } else { - paneSize = slavePtr->paneWidth; + paneSize = panePtr->paneWidth; } pwSize = pwWidth; } else { - if (slavePtr->height > 0) { - paneSize = slavePtr->height; + if (panePtr->height > 0) { + paneSize = panePtr->height; } else { - paneSize = slavePtr->paneHeight; + paneSize = panePtr->paneHeight; } pwSize = pwHeight; } - if (IsStretchable(slavePtr->stretch, i, first, last)) { + if (IsStretchable(panePtr->stretch, i, first, last)) { double frac; if (paneDynSize > 0) { frac = (double)paneSize / (double)paneDynSize; } else { frac = (double)paneSize / (double)pwSize; } paneDynSize -= paneSize; - paneDynMinSize -= slavePtr->minSize; + paneDynMinSize -= panePtr->minSize; stretchAmount = (int) (frac * stretchReserve); if (paneSize + stretchAmount >= paneMinSize) { stretchReserve -= stretchAmount; paneSize += stretchAmount; } else { @@ -1900,13 +1896,13 @@ stretchReserve = paneDynMinSize - paneDynSize; } } if (horizontal) { paneWidth = paneSize; - paneHeight = pwHeight - (2 * slavePtr->pady); + paneHeight = pwHeight - (2 * panePtr->pady); } else { - paneWidth = pwWidth - (2 * slavePtr->padx); + paneWidth = pwWidth - (2 * panePtr->padx); paneHeight = paneSize; } /* * Adjust for area reserved for sashes. @@ -1930,71 +1926,71 @@ } if (pwHeight - syReserve < y + paneHeight - internalBW) { paneHeight = pwHeight - syReserve - y + internalBW; } - if (slaveWidth > paneWidth) { - slaveWidth = paneWidth; + if (newPaneWidth > paneWidth) { + newPaneWidth = paneWidth; } - if (slaveHeight > paneHeight) { - slaveHeight = paneHeight; + if (newPaneHeight > paneHeight) { + newPaneHeight = paneHeight; } - slavePtr->x = x; - slavePtr->y = y; + panePtr->x = x; + panePtr->y = y; /* * Compute the location of the sash at the right or bottom of the * parcel and the location of the next parcel. */ if (horizontal) { - x += paneWidth + (2 * slavePtr->padx); + x += paneWidth + (2 * panePtr->padx); if (x < internalBW) { x = internalBW; } - slavePtr->sashx = x + sashOffset; - slavePtr->sashy = y; - slavePtr->handlex = x + handleOffset; - slavePtr->handley = y + pwPtr->handlePad; + panePtr->sashx = x + sashOffset; + panePtr->sashy = y; + panePtr->handlex = x + handleOffset; + panePtr->handley = y + pwPtr->handlePad; x += sashWidth; } else { - y += paneHeight + (2 * slavePtr->pady); + y += paneHeight + (2 * panePtr->pady); if (y < internalBW) { y = internalBW; } - slavePtr->sashx = x; - slavePtr->sashy = y + sashOffset; - slavePtr->handlex = x + pwPtr->handlePad; - slavePtr->handley = y + handleOffset; + panePtr->sashx = x; + panePtr->sashy = y + sashOffset; + panePtr->handlex = x + pwPtr->handlePad; + panePtr->handley = y + handleOffset; y += sashWidth; } /* - * Compute the actual dimensions of the slave in the pane. + * Compute the actual dimensions of the pane in the pane. */ - slaveX = slavePtr->x; - slaveY = slavePtr->y; - AdjustForSticky(slavePtr->sticky, paneWidth, paneHeight, - &slaveX, &slaveY, &slaveWidth, &slaveHeight); + paneX = panePtr->x; + paneY = panePtr->y; + AdjustForSticky(panePtr->sticky, paneWidth, paneHeight, + &paneX, &paneY, &newPaneWidth, &newPaneHeight); - slaveX += slavePtr->padx; - slaveY += slavePtr->pady; + paneX += panePtr->padx; + paneY += panePtr->pady; /* * Now put the window in the proper spot. */ - if (slaveWidth <= 0 || slaveHeight <= 0 || - (horizontal ? slaveX - internalBW > pwWidth : - slaveY - internalBW > pwHeight)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + if (newPaneWidth <= 0 || newPaneHeight <= 0 || + (horizontal ? paneX - internalBW > pwWidth : + paneY - internalBW > pwHeight)) { + Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin); + Tk_UnmapWindow(panePtr->tkwin); } else { - Tk_MaintainGeometry(slavePtr->tkwin, pwPtr->tkwin, - slaveX, slaveY, slaveWidth, slaveHeight); + Tk_MaintainGeometry(panePtr->tkwin, pwPtr->tkwin, + paneX, paneY, newPaneWidth, newPaneHeight); } sashCount--; } Tcl_Release(pwPtr); } @@ -2002,11 +1998,11 @@ /* *---------------------------------------------------------------------- * * Unlink -- * - * Remove a slave from a paned window. + * Remove a pane from a paned window. * * Results: * None. * * Side effects: @@ -2015,61 +2011,61 @@ *---------------------------------------------------------------------- */ static void Unlink( - Slave *slavePtr) /* Window to unlink. */ + Pane *panePtr) /* Window to unlink. */ { - PanedWindow *masterPtr; + PanedWindow *containerPtr; int i, j; - masterPtr = slavePtr->masterPtr; - if (masterPtr == NULL) { + containerPtr = panePtr->containerPtr; + if (containerPtr == NULL) { return; } /* - * Find the specified slave in the panedwindow's list of slaves, then + * Find the specified pane in the panedwindow's list of panes, then * remove it from that list. */ - for (i = 0; i < masterPtr->numSlaves; i++) { - if (masterPtr->slaves[i] == slavePtr) { - for (j = i; j < masterPtr->numSlaves - 1; j++) { - masterPtr->slaves[j] = masterPtr->slaves[j + 1]; + for (i = 0; i < containerPtr->numPanes; i++) { + if (containerPtr->panes[i] == panePtr) { + for (j = i; j < containerPtr->numPanes - 1; j++) { + containerPtr->panes[j] = containerPtr->panes[j + 1]; } break; } } /* - * Clean out any -after or -before references to this slave + * Clean out any -after or -before references to this pane */ - for (i = 0; i < masterPtr->numSlaves; i++) { - if (masterPtr->slaves[i]->before == slavePtr->tkwin) { - masterPtr->slaves[i]->before = NULL; + for (i = 0; i < containerPtr->numPanes; i++) { + if (containerPtr->panes[i]->before == panePtr->tkwin) { + containerPtr->panes[i]->before = NULL; } - if (masterPtr->slaves[i]->after == slavePtr->tkwin) { - masterPtr->slaves[i]->after = NULL; + if (containerPtr->panes[i]->after == panePtr->tkwin) { + containerPtr->panes[i]->after = NULL; } } - masterPtr->flags |= REQUESTED_RELAYOUT; - if (!(masterPtr->flags & REDRAW_PENDING)) { - masterPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayPanedWindow, masterPtr); + containerPtr->flags |= REQUESTED_RELAYOUT; + if (!(containerPtr->flags & REDRAW_PENDING)) { + containerPtr->flags |= REDRAW_PENDING; + Tcl_DoWhenIdle(DisplayPanedWindow, containerPtr); } /* - * Set the slave's masterPtr to NULL, so that we can tell that the slave + * Set the pane's containerPtr to NULL, so that we can tell that the pane * is no longer attached to any panedwindow. */ - slavePtr->masterPtr = NULL; + panePtr->containerPtr = NULL; - masterPtr->numSlaves--; + containerPtr->numPanes--; } /* *---------------------------------------------------------------------- * @@ -2077,29 +2073,29 @@ * * Given a token to a Tk window, find the pane that corresponds to that * token in a given paned window. * * Results: - * Pointer to the slave structure, or NULL if the window is not managed + * Pointer to the pane structure, or NULL if the window is not managed * by this paned window. * * Side effects: * None. * *---------------------------------------------------------------------- */ -static Slave * +static Pane * GetPane( PanedWindow *pwPtr, /* Pointer to the paned window info. */ Tk_Window tkwin) /* Window to search for. */ { int i; - for (i = 0; i < pwPtr->numSlaves; i++) { - if (pwPtr->slaves[i]->tkwin == tkwin) { - return pwPtr->slaves[i]; + for (i = 0; i < pwPtr->numPanes; i++) { + if (pwPtr->panes[i]->tkwin == tkwin) { + return pwPtr->panes[i]; } } return NULL; } @@ -2126,12 +2122,12 @@ int *firstPtr, /* Returned index for first. */ int *lastPtr) /* Returned index for last. */ { int i; - for (i = 0, *lastPtr = 0, *firstPtr = -1; i < pwPtr->numSlaves; i++) { - if (pwPtr->slaves[i]->hide == 0) { + for (i = 0, *lastPtr = 0, *firstPtr = -1; i < pwPtr->numPanes; i++) { + if (pwPtr->panes[i]->hide == 0) { if (*firstPtr < 0) { *firstPtr = i; } *lastPtr = i; } @@ -2139,39 +2135,39 @@ } /* *-------------------------------------------------------------- * - * SlaveStructureProc -- + * PaneStructureProc -- * * This function is invoked whenever StructureNotify events occur for a * window that's managed by a paned window. This function's only purpose * is to clean up when windows are deleted. * * Results: * None. * * Side effects: - * The paned window slave structure associated with the window - * is freed, and the slave is disassociated from the paned + * The paned window pane structure associated with the window + * is freed, and the pane is disassociated from the paned * window which managed it. * *-------------------------------------------------------------- */ static void -SlaveStructureProc( +PaneStructureProc( ClientData clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { - Slave *slavePtr = (Slave *)clientData; - PanedWindow *pwPtr = slavePtr->masterPtr; + Pane *panePtr = (Pane *)clientData; + PanedWindow *pwPtr = panePtr->containerPtr; if (eventPtr->type == DestroyNotify) { - Unlink(slavePtr); - slavePtr->tkwin = NULL; - ckfree(slavePtr); + Unlink(panePtr); + panePtr->tkwin = NULL; + ckfree(panePtr); ComputeGeometry(pwPtr); } } /* @@ -2178,11 +2174,11 @@ *---------------------------------------------------------------------- * * ComputeGeometry -- * * Compute geometry for the paned window, including coordinates of all - * slave windows and each sash. + * panes and each sash. * * Results: * None. * * Side effects: @@ -2196,11 +2192,11 @@ PanedWindow *pwPtr) /* Pointer to the Paned Window structure. */ { int i, x, y, doubleBw, internalBw; int sashWidth, sashOffset, handleOffset; int reqWidth, reqHeight, dim; - Slave *slavePtr; + Pane *panePtr; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); pwPtr->flags |= REQUESTED_RELAYOUT; x = y = internalBw = Tk_InternalBorderLeft(pwPtr->tkwin); @@ -2222,96 +2218,96 @@ sashWidth = (2 * pwPtr->sashPad) + pwPtr->sashWidth; handleOffset = ((pwPtr->sashWidth - pwPtr->handleSize) / 2) + pwPtr->sashPad; } - for (i = 0; i < pwPtr->numSlaves; i++) { - slavePtr = pwPtr->slaves[i]; + for (i = 0; i < pwPtr->numPanes; i++) { + panePtr = pwPtr->panes[i]; - if (slavePtr->hide) { + if (panePtr->hide) { continue; } /* - * First set the coordinates for the top left corner of the slave's + * First set the coordinates for the top left corner of the pane's * parcel. */ - slavePtr->x = x; - slavePtr->y = y; + panePtr->x = x; + panePtr->y = y; /* * Make sure the pane's paned dimension is at least minsize. This * check may be redundant, since the only way to change a pane's size * is by moving a sash, and that code checks the minsize. */ if (horizontal) { - if (slavePtr->paneWidth < slavePtr->minSize) { - slavePtr->paneWidth = slavePtr->minSize; + if (panePtr->paneWidth < panePtr->minSize) { + panePtr->paneWidth = panePtr->minSize; } } else { - if (slavePtr->paneHeight < slavePtr->minSize) { - slavePtr->paneHeight = slavePtr->minSize; + if (panePtr->paneHeight < panePtr->minSize) { + panePtr->paneHeight = panePtr->minSize; } } /* * Compute the location of the sash at the right or bottom of the * parcel. */ if (horizontal) { - x += slavePtr->paneWidth + (2 * slavePtr->padx); - slavePtr->sashx = x + sashOffset; - slavePtr->sashy = y; - slavePtr->handlex = x + handleOffset; - slavePtr->handley = y + pwPtr->handlePad; + x += panePtr->paneWidth + (2 * panePtr->padx); + panePtr->sashx = x + sashOffset; + panePtr->sashy = y; + panePtr->handlex = x + handleOffset; + panePtr->handley = y + pwPtr->handlePad; x += sashWidth; } else { - y += slavePtr->paneHeight + (2 * slavePtr->pady); - slavePtr->sashx = x; - slavePtr->sashy = y + sashOffset; - slavePtr->handlex = x + pwPtr->handlePad; - slavePtr->handley = y + handleOffset; + y += panePtr->paneHeight + (2 * panePtr->pady); + panePtr->sashx = x; + panePtr->sashy = y + sashOffset; + panePtr->handlex = x + pwPtr->handlePad; + panePtr->handley = y + handleOffset; y += sashWidth; } /* - * Find the maximum height/width of the slaves, for computing the + * Find the maximum height/width of the panes, for computing the * requested height/width of the paned window. */ if (horizontal) { /* - * If the slave has an explicit height set, use that; otherwise, - * use the slave's requested height. + * If the pane has an explicit height set, use that; otherwise, + * use the pane's requested height. */ - if (slavePtr->height > 0) { - dim = slavePtr->height; + if (panePtr->height > 0) { + dim = panePtr->height; } else { - doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; - dim = Tk_ReqHeight(slavePtr->tkwin) + doubleBw; + doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; + dim = Tk_ReqHeight(panePtr->tkwin) + doubleBw; } - dim += 2 * slavePtr->pady; + dim += 2 * panePtr->pady; if (dim > reqHeight) { reqHeight = dim; } } else { /* - * If the slave has an explicit width set use that; otherwise, use - * the slave's requested width. + * If the pane has an explicit width set use that; otherwise, use + * the pane's requested width. */ - if (slavePtr->width > 0) { - dim = slavePtr->width; + if (panePtr->width > 0) { + dim = panePtr->width; } else { - doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; - dim = Tk_ReqWidth(slavePtr->tkwin) + doubleBw; + doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; + dim = Tk_ReqWidth(panePtr->tkwin) + doubleBw; } - dim += 2 * slavePtr->padx; + dim += 2 * panePtr->padx; if (dim > reqWidth) { reqWidth = dim; } } } @@ -2325,11 +2321,11 @@ * The requested width (or height) is therefore x (or y) minus the size of * one sash and padding, plus the width of the right (or bottom) border of * the paned window. * * The height (or width) is equal to the maximum height (or width) of the - * slaves, plus the width of the border of the top and bottom (or left and + * panes, plus the width of the border of the top and bottom (or left and * right) of the paned window. * * If the panedwindow has an explicit width/height set use that; * otherwise, use the requested width/height. */ @@ -2371,14 +2367,12 @@ */ static void DestroyOptionTables( ClientData clientData, /* Pointer to the OptionTables struct */ - Tcl_Interp *dummy) /* Pointer to the calling interp */ + TCL_UNUSED(Tcl_Interp *)) /* Pointer to the calling interp */ { - (void)dummy; - ckfree(clientData); } /* *---------------------------------------------------------------------- @@ -2397,21 +2391,19 @@ *---------------------------------------------------------------------- */ static Tcl_Obj * GetSticky( - ClientData dummy, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *recordPtr, /* Pointer to widget record. */ TkSizeT internalOffset) /* Offset within *recordPtr containing the * sticky value. */ { int sticky = *(int *)(recordPtr + internalOffset); char buffer[5]; char *p = &buffer[0]; - (void)dummy; - (void)tkwin; if (sticky & STICK_NORTH) { *p++ = 'n'; } if (sticky & STICK_EAST) { @@ -2447,13 +2439,13 @@ *---------------------------------------------------------------------- */ static int SetSticky( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interp; may be used for errors. */ - Tk_Window tkwin, /* Window for which option is being set. */ + TCL_UNUSED(Tk_Window), /* Window for which option is being set. */ Tcl_Obj **value, /* Pointer to the pointer to the value object. * We use a pointer to the pointer because we * may need to return a value (NULL). */ char *recordPtr, /* Pointer to storage for the widget record. */ TkSizeT internalOffset, /* Offset within *recordPtr at which the @@ -2463,12 +2455,10 @@ { int sticky = 0; char c; void *internalPtr; const char *string; - (void)dummy; - (void)tkwin; internalPtr = ComputeSlotAddress(recordPtr, internalOffset); if (flags & TK_OPTION_NULL_OK && ObjectIsEmpty(*value)) { *value = NULL; @@ -2529,32 +2519,29 @@ *---------------------------------------------------------------------- */ static void RestoreSticky( - ClientData dummy, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *internalPtr, /* Pointer to storage for value. */ char *oldInternalPtr) /* Pointer to old value. */ { - (void)dummy; - (void)tkwin; - *(int *)internalPtr = *(int *)oldInternalPtr; } /* *---------------------------------------------------------------------- * * AdjustForSticky -- * * Given the x,y coords of the top-left corner of a pane, the dimensions - * of that pane, and the dimensions of a slave, compute the x,y coords - * and actual dimensions of the slave based on the slave's sticky value. + * of that pane, and the dimensions of a pane, compute the x,y coords + * and actual dimensions of the pane based on the pane's sticky value. * * Results: - * No direct return; sets the x, y, slaveWidth and slaveHeight to correct + * No direct return; sets the x, y, paneWidth and paneHeight to correct * values. * * Side effects: * None. * @@ -2567,30 +2554,30 @@ * definition. */ int cavityWidth, /* Width of the cavity. */ int cavityHeight, /* Height of the cavity. */ int *xPtr, int *yPtr, /* Initially, coordinates of the top-left * corner of cavity; also return values for - * actual x, y coords of slave. */ - int *slaveWidthPtr, /* Slave width. */ - int *slaveHeightPtr) /* Slave height. */ -{ - int diffx = 0; /* Cavity width - slave width. */ - int diffy = 0; /* Cavity hight - slave height. */ - - if (cavityWidth > *slaveWidthPtr) { - diffx = cavityWidth - *slaveWidthPtr; - } - - if (cavityHeight > *slaveHeightPtr) { - diffy = cavityHeight - *slaveHeightPtr; + * actual x, y coords of pane. */ + int *paneWidthPtr, /* Pane width. */ + int *paneHeightPtr) /* Pane height. */ +{ + int diffx = 0; /* Cavity width - pane width. */ + int diffy = 0; /* Cavity hight - pane height. */ + + if (cavityWidth > *paneWidthPtr) { + diffx = cavityWidth - *paneWidthPtr; + } + + if (cavityHeight > *paneHeightPtr) { + diffy = cavityHeight - *paneHeightPtr; } if ((sticky & STICK_EAST) && (sticky & STICK_WEST)) { - *slaveWidthPtr += diffx; + *paneWidthPtr += diffx; } if ((sticky & STICK_NORTH) && (sticky & STICK_SOUTH)) { - *slaveHeightPtr += diffy; + *paneHeightPtr += diffy; } if (!(sticky & STICK_WEST)) { *xPtr += (sticky & STICK_EAST) ? diffx : diffx/2; } if (!(sticky & STICK_NORTH)) { @@ -2619,50 +2606,50 @@ PanedWindow *pwPtr, int sash, int diff) { int i; - int expandPane, reduceFirst, reduceLast, reduceIncr, slaveSize, sashOffset; - Slave *slavePtr; + int expandPane, reduceFirst, reduceLast, reduceIncr, paneSize, sashOffset; + Pane *panePtr; int stretchReserve = 0; int nextSash = sash + 1; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); if (diff == 0) return; /* - * Update the slave sizes with their real sizes. + * Update the pane sizes with their real sizes. */ if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { sashOffset = ((pwPtr->handleSize - pwPtr->sashWidth) / 2) + pwPtr->sashPad; } else { sashOffset = pwPtr->sashPad; } - for (i = 0; i < pwPtr->numSlaves; i++) { - slavePtr = pwPtr->slaves[i]; - if (slavePtr->hide) { + for (i = 0; i < pwPtr->numPanes; i++) { + panePtr = pwPtr->panes[i]; + if (panePtr->hide) { continue; } if (horizontal) { - slavePtr->paneWidth = slavePtr->width = slavePtr->sashx - - sashOffset - slavePtr->x - (2 * slavePtr->padx); + panePtr->paneWidth = panePtr->width = panePtr->sashx + - sashOffset - panePtr->x - (2 * panePtr->padx); } else { - slavePtr->paneHeight = slavePtr->height = slavePtr->sashy - - sashOffset - slavePtr->y - (2 * slavePtr->pady); + panePtr->paneHeight = panePtr->height = panePtr->sashy + - sashOffset - panePtr->y - (2 * panePtr->pady); } } /* * There must be a next sash since it is only possible to enter this * routine when moving an actual sash which implies there exists a visible * pane to either side of the sash. */ - while (nextSash < pwPtr->numSlaves-1 && pwPtr->slaves[nextSash]->hide) { + while (nextSash < pwPtr->numPanes-1 && pwPtr->panes[nextSash]->hide) { nextSash++; } /* * Consolidate +/-diff variables to reduce duplicate code. @@ -2669,11 +2656,11 @@ */ if (diff > 0) { expandPane = sash; reduceFirst = nextSash; - reduceLast = pwPtr->numSlaves; + reduceLast = pwPtr->numPanes; reduceIncr = 1; } else { diff = abs(diff); expandPane = nextSash; reduceFirst = sash; @@ -2685,18 +2672,18 @@ * Calculate how much room we have to stretch in and adjust diff value * accordingly. */ for (i = reduceFirst; i != reduceLast; i += reduceIncr) { - slavePtr = pwPtr->slaves[i]; - if (slavePtr->hide) { + panePtr = pwPtr->panes[i]; + if (panePtr->hide) { continue; } if (horizontal) { - stretchReserve += slavePtr->width - slavePtr->minSize; + stretchReserve += panePtr->width - panePtr->minSize; } else { - stretchReserve += slavePtr->height - slavePtr->minSize; + stretchReserve += panePtr->height - panePtr->minSize; } } if (stretchReserve <= 0) { return; } @@ -2706,42 +2693,42 @@ /* * Expand pane by diff amount. */ - slavePtr = pwPtr->slaves[expandPane]; + panePtr = pwPtr->panes[expandPane]; if (horizontal) { - slavePtr->paneWidth = slavePtr->width += diff; + panePtr->paneWidth = panePtr->width += diff; } else { - slavePtr->paneHeight = slavePtr->height += diff; + panePtr->paneHeight = panePtr->height += diff; } /* * Reduce panes, respecting minsize, until diff amount has been used. */ for (i = reduceFirst; i != reduceLast; i += reduceIncr) { - slavePtr = pwPtr->slaves[i]; - if (slavePtr->hide) { + panePtr = pwPtr->panes[i]; + if (panePtr->hide) { continue; } if (horizontal) { - slaveSize = slavePtr->width; - } else { - slaveSize = slavePtr->height; - } - if (diff > (slaveSize - slavePtr->minSize)) { - diff -= slaveSize - slavePtr->minSize; - slaveSize = slavePtr->minSize; - } else { - slaveSize -= diff; + paneSize = panePtr->width; + } else { + paneSize = panePtr->height; + } + if (diff > (paneSize - panePtr->minSize)) { + diff -= paneSize - panePtr->minSize; + paneSize = panePtr->minSize; + } else { + paneSize -= diff; i = reduceLast - reduceIncr; } if (horizontal) { - slavePtr->paneWidth = slavePtr->width = slaveSize; + panePtr->paneWidth = panePtr->width = paneSize; } else { - slavePtr->paneHeight = slavePtr->height = slaveSize; + panePtr->paneHeight = panePtr->height = paneSize; } } } /* @@ -2960,13 +2947,13 @@ pwPtr->proxyx = x; pwPtr->proxyy = y; /* * Make sure the proxy window is higher in the stacking order than the - * slaves, so that it will be visible when drawn. It would be more + * panes, so that it will be visible when drawn. It would be more * correct to push the proxy window just high enough to appear above - * the highest slave, but it's much easier to just force it all the + * the highest pane, but it's much easier to just force it all the * way to the top of the stacking order. */ Tk_RestackWindow(pwPtr->proxywin, Above, NULL); @@ -3112,16 +3099,16 @@ } GetFirstLastVisiblePane(pwPtr, &first, &last); isHandle = 0; found = -1; - for (i = 0; i < pwPtr->numSlaves - 1; i++) { - if (pwPtr->slaves[i]->hide || i == last) { + for (i = 0; i < pwPtr->numPanes - 1; i++) { + if (pwPtr->panes[i]->hide || i == last) { continue; } - thisx = pwPtr->slaves[i]->sashx; - thisy = pwPtr->slaves[i]->sashy; + thisx = pwPtr->panes[i]->sashx; + thisy = pwPtr->panes[i]->sashy; if (((thisx - lpad) <= x && x <= (thisx + rpad + sashWidth)) && ((thisy - tpad) <= y && y <= (thisy + bpad + sashHeight))) { found = i; @@ -3128,12 +3115,12 @@ /* * Determine if the point is over the handle or the sash. */ if (pwPtr->showHandle) { - thisx = pwPtr->slaves[i]->handlex; - thisy = pwPtr->slaves[i]->handley; + thisx = pwPtr->panes[i]->handlex; + thisy = pwPtr->panes[i]->handley; if (pwPtr->orient == ORIENT_HORIZONTAL) { if (thisy <= y && y <= (thisy + pwPtr->handleSize)) { isHandle = 1; } } else { Index: generic/tkPkgConfig.c ================================================================== --- generic/tkPkgConfig.c +++ generic/tkPkgConfig.c @@ -2,12 +2,12 @@ * tkPkgConfig.c -- * * This file contains the configuration information to embed into the tcl * binary library. * - * Copyright (c) 2002 Andreas Kupries - * Copyright (c) 2017 Stuart Cassoff + * Copyright © 2002 Andreas Kupries + * Copyright © 2017 Stuart Cassoff * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -38,11 +38,11 @@ #include "tkInt.h" #ifndef TCL_CFGVAL_ENCODING -#define TCL_CFGVAL_ENCODING "ascii" +#define TCL_CFGVAL_ENCODING "utf-8" #endif /* * Use C preprocessor statements to define the various values for the embedded * configuration information. @@ -82,11 +82,11 @@ # define CFG_PROFILED "1" #else # define CFG_PROFILED "0" #endif -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) # define CFG_FONTSYSTEM "gdi" #elif defined(MAC_OSX_TK) # define CFG_FONTSYSTEM "cocoa" #elif defined(HAVE_XFT) # define CFG_FONTSYSTEM "xft" @@ -98,10 +98,13 @@ {"debug", CFG_DEBUG}, {"threaded", CFG_THREADED}, {"profiled", CFG_PROFILED}, {"64bit", CFG_64}, {"optimized", CFG_OPTIMIZED}, +#ifdef TK_NO_DEPRECATED + {"nodeprecated", "1"}, +#endif {"mem_debug", CFG_MEMDEBUG}, {"fontsystem", CFG_FONTSYSTEM}, /* Runtime paths to various stuff */ Index: generic/tkPlace.c ================================================================== --- generic/tkPlace.c +++ generic/tkPlace.c @@ -2,12 +2,12 @@ * tkPlace.c -- * * This file contains code to implement a simple geometry manager for Tk * based on absolute placement or "rubber-sheet" placement. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -15,14 +15,14 @@ /* * Border modes for relative placement: * * BM_INSIDE: relative distances computed using area inside all - * borders of master window. + * borders of container window. * BM_OUTSIDE: relative distances computed using outside area that - * includes all borders of master. - * BM_IGNORE: border issues are ignored: place relative to master's + * includes all borders of container. + * BM_IGNORE: border issues are ignored: place relative to container's * actual window size. */ static const char *const borderModeStrings[] = { "inside", "outside", "ignore", NULL @@ -33,20 +33,20 @@ /* * For each window whose geometry is managed by the placer there is a * structure of the following type: */ -typedef struct Slave { +typedef struct Content { Tk_Window tkwin; /* Tk's token for window. */ Tk_Window inTkwin; /* Token for the -in window. */ - struct Master *masterPtr; /* Pointer to information for window relative + struct Container *containerPtr; /* Pointer to information for window relative * to which tkwin is placed. This isn't * necessarily the logical parent of tkwin. - * NULL means the master was deleted or never + * NULL means the container was deleted or never * assigned. */ - struct Slave *nextPtr; /* Next in list of windows placed relative to - * same master (NULL for end of list). */ + struct Content *nextPtr; /* Next in list of windows placed relative to + * same container (NULL for end of list). */ Tk_OptionTable optionTable; /* Table that defines configuration options * available for this command. */ /* * Geometry information for window; where there are both relative and * absolute values for the same attribute (e.g. x and relX) only one of @@ -55,63 +55,63 @@ int x, y; /* X and Y pixel coordinates for tkwin. */ Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel * spec. information. */ double relX, relY; /* X and Y coordinates relative to size of - * master. */ + * container. */ int width, height; /* Absolute dimensions for tkwin. */ Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel * spec. */ Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel * spec. */ double relWidth, relHeight; /* Dimensions for tkwin relative to size of - * master. */ + * container. */ Tcl_Obj *relWidthPtr; Tcl_Obj *relHeightPtr; Tk_Anchor anchor; /* Which point on tkwin is placed at the given * position. */ - BorderMode borderMode; /* How to treat borders of master window. */ + BorderMode borderMode; /* How to treat borders of container window. */ int flags; /* Various flags; see below for bit * definitions. */ -} Slave; +} Content; /* * Type masks for options: */ #define IN_MASK 1 static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE, - offsetof(Slave, anchor), 0, 0, 0}, + offsetof(Content, anchor), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE, - offsetof(Slave, borderMode), 0, borderModeStrings, 0}, - {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Slave, heightPtr), - offsetof(Slave, height), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Slave, inTkwin), + offsetof(Content, borderMode), 0, borderModeStrings, 0}, + {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Content, heightPtr), + offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Content, inTkwin), 0, 0, IN_MASK}, {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "", - offsetof(Slave, relHeightPtr), offsetof(Slave, relHeight), + offsetof(Content, relHeightPtr), offsetof(Content, relHeight), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "", - offsetof(Slave, relWidthPtr), offsetof(Slave, relWidth), + offsetof(Content, relWidthPtr), offsetof(Content, relWidth), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0", TCL_INDEX_NONE, - offsetof(Slave, relX), 0, 0, 0}, + offsetof(Content, relX), 0, 0, 0}, {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", TCL_INDEX_NONE, - offsetof(Slave, relY), 0, 0, 0}, - {TK_OPTION_PIXELS, "-width", NULL, NULL, "", offsetof(Slave, widthPtr), - offsetof(Slave, width), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Slave, xPtr), - offsetof(Slave, x), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Slave, yPtr), - offsetof(Slave, y), TK_OPTION_NULL_OK, 0, 0}, + offsetof(Content, relY), 0, 0, 0}, + {TK_OPTION_PIXELS, "-width", NULL, NULL, "", offsetof(Content, widthPtr), + offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xPtr), + offsetof(Content, x), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yPtr), + offsetof(Content, y), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; /* - * Flag definitions for Slave structures: + * Flag definitions for Content structures: * * CHILD_WIDTH - 1 means -width was specified; * CHILD_REL_WIDTH - 1 means -relwidth was specified. * CHILD_HEIGHT - 1 means -height was specified; * CHILD_REL_HEIGHT - 1 means -relheight was specified. @@ -121,29 +121,29 @@ #define CHILD_REL_WIDTH 2 #define CHILD_HEIGHT 4 #define CHILD_REL_HEIGHT 8 /* - * For each master window that has a slave managed by the placer there is a + * For each container window that has a content managed by the placer there is a * structure of the following form: */ -typedef struct Master { - Tk_Window tkwin; /* Tk's token for master window. */ - struct Slave *slavePtr; /* First in linked list of slaves placed - * relative to this master. */ +typedef struct Container { + Tk_Window tkwin; /* Tk's token for container window. */ + struct Content *contentPtr; /* First in linked list of content windowslaced + * relative to this container. */ int *abortPtr; /* If non-NULL, it means that there is a nested * call to RecomputePlacement already working on * this window. *abortPtr may be set to 1 to * abort that nested call. This happens, for - * example, if tkwin or any of its slaves + * example, if tkwin or any of its content * is deleted. */ int flags; /* See below for bit definitions. */ -} Master; +} Container; /* - * Flag definitions for masters: + * Flag definitions for containers: * * PARENT_RECONFIG_PENDING - 1 means that a call to RecomputePlacement is * already pending via a Do_When_Idle handler. */ @@ -153,38 +153,38 @@ * The following structure is the official type record for the placer: */ static void PlaceRequestProc(ClientData clientData, Tk_Window tkwin); -static void PlaceLostSlaveProc(ClientData clientData, +static void PlaceLostContentProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr placerType = { "place", /* name */ PlaceRequestProc, /* requestProc */ - PlaceLostSlaveProc, /* lostSlaveProc */ + PlaceLostContentProc, /* lostContentProc */ }; /* * Forward declarations for functions defined later in this file: */ -static void SlaveStructureProc(ClientData clientData, +static void ContentStructureProc(ClientData clientData, XEvent *eventPtr); -static int ConfigureSlave(Tcl_Interp *interp, Tk_Window tkwin, +static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin, Tk_OptionTable table, int objc, Tcl_Obj *const objv[]); static int PlaceInfoCommand(Tcl_Interp *interp, Tk_Window tkwin); -static Slave * CreateSlave(Tk_Window tkwin, Tk_OptionTable table); -static void FreeSlave(Slave *slavePtr); -static Slave * FindSlave(Tk_Window tkwin); -static Master * CreateMaster(Tk_Window tkwin); -static Master * FindMaster(Tk_Window tkwin); -static void MasterStructureProc(ClientData clientData, +static Content * CreateContent(Tk_Window tkwin, Tk_OptionTable table); +static void FreeContent(Content *contentPtr); +static Content * FindContent(Tk_Window tkwin); +static Container * CreateContainer(Tk_Window tkwin); +static Container * FindContainer(Tk_Window tkwin); +static void PlaceStructureProc(ClientData clientData, XEvent *eventPtr); static void RecomputePlacement(ClientData clientData); -static void UnlinkSlave(Slave *slavePtr); +static void UnlinkContent(Content *contentPtr); /* *-------------------------------------------------------------- * * Tk_PlaceObjCmd -- @@ -208,17 +208,20 @@ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window main_win = (Tk_Window)clientData; Tk_Window tkwin; - Slave *slavePtr; + Content *contentPtr; TkDisplay *dispPtr; Tk_OptionTable optionTable; static const char *const optionStrings[] = { - "configure", "forget", "info", "slaves", NULL + "configure", "content", "forget", "info", "slaves", NULL + }; + static const char *const optionStringsNoDep[] = { + "configure", "content", "forget", "info", NULL }; - enum options { PLACE_CONFIGURE, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES }; + enum options { PLACE_CONFIGURE, PLACE_CONTENT, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES }; int index; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option|pathName args"); return TCL_ERROR; @@ -245,16 +248,16 @@ * Initialize, if that hasn't been done yet. */ dispPtr = ((TkWindow *) tkwin)->dispPtr; if (!dispPtr->placeInit) { - Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS); - Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS); dispPtr->placeInit = 1; } - return ConfigureSlave(interp, tkwin, optionTable, objc-2, objv+2); + return ConfigureContent(interp, tkwin, optionTable, objc-2, objv+2); } /* * Handle more general case of option followed by window name followed by * possible additional arguments. @@ -269,84 +272,93 @@ * Initialize, if that hasn't been done yet. */ dispPtr = ((TkWindow *) tkwin)->dispPtr; if (!dispPtr->placeInit) { - Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS); - Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS); dispPtr->placeInit = 1; } if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { + /* + * Call it again without the deprecated ones to get a proper error + * message. This works well since there can't be any ambiguity between + * deprecated and new options. + */ + + Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep, + sizeof(char *), "option", 0, &index); return TCL_ERROR; } switch ((enum options) index) { case PLACE_CONFIGURE: if (objc == 3 || objc == 4) { Tcl_Obj *objPtr; - slavePtr = FindSlave(tkwin); - if (slavePtr == NULL) { + contentPtr = FindContent(tkwin); + if (contentPtr == NULL) { return TCL_OK; } - objPtr = Tk_GetOptionInfo(interp, slavePtr, optionTable, + objPtr = Tk_GetOptionInfo(interp, contentPtr, optionTable, (objc == 4) ? objv[3] : NULL, tkwin); if (objPtr == NULL) { return TCL_ERROR; } Tcl_SetObjResult(interp, objPtr); return TCL_OK; } - return ConfigureSlave(interp, tkwin, optionTable, objc-3, objv+3); + return ConfigureContent(interp, tkwin, optionTable, objc-3, objv+3); case PLACE_FORGET: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "pathName"); return TCL_ERROR; } - slavePtr = FindSlave(tkwin); - if (slavePtr == NULL) { + contentPtr = FindContent(tkwin); + if (contentPtr == NULL) { return TCL_OK; } - if ((slavePtr->masterPtr != NULL) && - (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); + if ((contentPtr->containerPtr != NULL) && + (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin))) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); } - UnlinkSlave(slavePtr); - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, + UnlinkContent(contentPtr); + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable, tkwin)); - Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - slavePtr); + Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc, + contentPtr); Tk_ManageGeometry(tkwin, NULL, NULL); Tk_UnmapWindow(tkwin); - FreeSlave(slavePtr); + FreeContent(contentPtr); break; case PLACE_INFO: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "pathName"); return TCL_ERROR; } return PlaceInfoCommand(interp, tkwin); - case PLACE_SLAVES: { - Master *masterPtr; + case PLACE_SLAVES: + case PLACE_CONTENT: { + Container *containerPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "pathName"); return TCL_ERROR; } - masterPtr = FindMaster(tkwin); - if (masterPtr != NULL) { + containerPtr = FindContainer(tkwin); + if (containerPtr != NULL) { Tcl_Obj *listPtr = Tcl_NewObj(); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, listPtr, - TkNewWindowObj(slavePtr->tkwin)); + Tk_NewWindowObj(contentPtr->tkwin)); } Tcl_SetObjResult(interp, listPtr); } break; } @@ -356,63 +368,63 @@ } /* *---------------------------------------------------------------------- * - * CreateSlave -- + * CreateContent -- * - * Given a Tk_Window token, find the Slave structure corresponding to + * Given a Tk_Window token, find the Content structure corresponding to * that token, creating a new one if necessary. * * Results: - * Pointer to the Slave structure. + * Pointer to the Content structure. * * Side effects: - * A new Slave structure may be created. + * A new Content structure may be created. * *---------------------------------------------------------------------- */ -static Slave * -CreateSlave( - Tk_Window tkwin, /* Token for desired slave. */ +static Content * +CreateContent( + Tk_Window tkwin, /* Token for desired content. */ Tk_OptionTable table) { Tcl_HashEntry *hPtr; - Slave *slavePtr; + Content *contentPtr; int isNew; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew); + hPtr = Tcl_CreateHashEntry(&dispPtr->contentTable, (char *) tkwin, &isNew); if (!isNew) { - return (Slave *)Tcl_GetHashValue(hPtr); + return (Content *)Tcl_GetHashValue(hPtr); } /* - * No preexisting slave structure for that window, so make a new one and + * No preexisting content structure for that window, so make a new one and * populate it with some default values. */ - slavePtr = (Slave *)ckalloc(sizeof(Slave)); - memset(slavePtr, 0, sizeof(Slave)); - slavePtr->tkwin = tkwin; - slavePtr->inTkwin = NULL; - slavePtr->anchor = TK_ANCHOR_NW; - slavePtr->borderMode = BM_INSIDE; - slavePtr->optionTable = table; - Tcl_SetHashValue(hPtr, slavePtr); - Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - slavePtr); - return slavePtr; + contentPtr = (Content *)ckalloc(sizeof(Content)); + memset(contentPtr, 0, sizeof(Content)); + contentPtr->tkwin = tkwin; + contentPtr->inTkwin = NULL; + contentPtr->anchor = TK_ANCHOR_NW; + contentPtr->borderMode = BM_INSIDE; + contentPtr->optionTable = table; + Tcl_SetHashValue(hPtr, contentPtr); + Tk_CreateEventHandler(tkwin, StructureNotifyMask, ContentStructureProc, + contentPtr); + return contentPtr; } /* *---------------------------------------------------------------------- * - * FreeSlave -- + * FreeContent -- * - * Frees the resources held by a Slave structure. + * Frees the resources held by a Content structure. * * Results: * None * * Side effects: @@ -420,348 +432,348 @@ * *---------------------------------------------------------------------- */ static void -FreeSlave( - Slave *slavePtr) +FreeContent( + Content *contentPtr) { - Tk_FreeConfigOptions((char *) slavePtr, slavePtr->optionTable, - slavePtr->tkwin); - ckfree(slavePtr); + Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable, + contentPtr->tkwin); + ckfree(contentPtr); } /* *---------------------------------------------------------------------- * - * FindSlave -- + * FindContent -- * - * Given a Tk_Window token, find the Slave structure corresponding to + * Given a Tk_Window token, find the Content structure corresponding to * that token. This is purely a lookup function; it will not create a * record if one does not yet exist. * * Results: - * Pointer to Slave structure; NULL if none exists. + * Pointer to Content structure; NULL if none exists. * * Side effects: * None. * *---------------------------------------------------------------------- */ -static Slave * -FindSlave( - Tk_Window tkwin) /* Token for desired slave. */ +static Content * +FindContent( + Tk_Window tkwin) /* Token for desired content. */ { Tcl_HashEntry *hPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, tkwin); + hPtr = Tcl_FindHashEntry(&dispPtr->contentTable, tkwin); if (hPtr == NULL) { return NULL; } - return (Slave *)Tcl_GetHashValue(hPtr); + return (Content *)Tcl_GetHashValue(hPtr); } /* *---------------------------------------------------------------------- * - * UnlinkSlave -- + * UnlinkContent -- * - * This function removes a slave window from the chain of slaves in its - * master. + * This function removes a content window from the chain of content windows in its + * container. * * Results: * None. * * Side effects: - * The slave list of slavePtr's master changes. + * The content list of contentPtr's container changes. * *---------------------------------------------------------------------- */ static void -UnlinkSlave( - Slave *slavePtr) /* Slave structure to be unlinked. */ -{ - Master *masterPtr; - Slave *prevPtr; - - masterPtr = slavePtr->masterPtr; - if (masterPtr == NULL) { +UnlinkContent( + Content *contentPtr) /* Content structure to be unlinked. */ +{ + Container *containerPtr; + Content *prevPtr; + + containerPtr = contentPtr->containerPtr; + if (containerPtr == NULL) { return; } - if (masterPtr->slavePtr == slavePtr) { - masterPtr->slavePtr = slavePtr->nextPtr; + if (containerPtr->contentPtr == contentPtr) { + containerPtr->contentPtr = contentPtr->nextPtr; } else { - for (prevPtr = masterPtr->slavePtr; ; prevPtr = prevPtr->nextPtr) { + for (prevPtr = containerPtr->contentPtr; ; prevPtr = prevPtr->nextPtr) { if (prevPtr == NULL) { - Tcl_Panic("UnlinkSlave couldn't find slave to unlink"); + Tcl_Panic("UnlinkContent couldn't find content to unlink"); } - if (prevPtr->nextPtr == slavePtr) { - prevPtr->nextPtr = slavePtr->nextPtr; + if (prevPtr->nextPtr == contentPtr) { + prevPtr->nextPtr = contentPtr->nextPtr; break; } } } - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - slavePtr->masterPtr = NULL; + contentPtr->containerPtr = NULL; } /* *---------------------------------------------------------------------- * - * CreateMaster -- + * CreateContainer -- * - * Given a Tk_Window token, find the Master structure corresponding to + * Given a Tk_Window token, find the Container structure corresponding to * that token, creating a new one if necessary. * * Results: - * Pointer to the Master structure. + * Pointer to the Container structure. * * Side effects: - * A new Master structure may be created. + * A new Container structure may be created. * *---------------------------------------------------------------------- */ -static Master * -CreateMaster( - Tk_Window tkwin) /* Token for desired master. */ +static Container * +CreateContainer( + Tk_Window tkwin) /* Token for desired container. */ { Tcl_HashEntry *hPtr; - Master *masterPtr; + Container *containerPtr; int isNew; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew); + hPtr = Tcl_CreateHashEntry(&dispPtr->containerTable, (char *)tkwin, &isNew); if (isNew) { - masterPtr = (Master *)ckalloc(sizeof(Master)); - masterPtr->tkwin = tkwin; - masterPtr->slavePtr = NULL; - masterPtr->abortPtr = NULL; - masterPtr->flags = 0; - Tcl_SetHashValue(hPtr, masterPtr); - Tk_CreateEventHandler(masterPtr->tkwin, StructureNotifyMask, - MasterStructureProc, masterPtr); + containerPtr = (Container *)ckalloc(sizeof(Container)); + containerPtr->tkwin = tkwin; + containerPtr->contentPtr = NULL; + containerPtr->abortPtr = NULL; + containerPtr->flags = 0; + Tcl_SetHashValue(hPtr, containerPtr); + Tk_CreateEventHandler(containerPtr->tkwin, StructureNotifyMask, + PlaceStructureProc, containerPtr); } else { - masterPtr = (Master *)Tcl_GetHashValue(hPtr); + containerPtr = (Container *)Tcl_GetHashValue(hPtr); } - return masterPtr; + return containerPtr; } /* *---------------------------------------------------------------------- * - * FindMaster -- + * FindContainer -- * - * Given a Tk_Window token, find the Master structure corresponding to + * Given a Tk_Window token, find the Container structure corresponding to * that token. This is simply a lookup function; a new record will not be * created if one does not already exist. * * Results: - * Pointer to the Master structure; NULL if one does not exist for the + * Pointer to the Container structure; NULL if one does not exist for the * given Tk_Window token. * * Side effects: * None. * *---------------------------------------------------------------------- */ -static Master * -FindMaster( - Tk_Window tkwin) /* Token for desired master. */ +static Container * +FindContainer( + Tk_Window tkwin) /* Token for desired container. */ { Tcl_HashEntry *hPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, tkwin); + hPtr = Tcl_FindHashEntry(&dispPtr->containerTable, tkwin); if (hPtr == NULL) { return NULL; } - return (Master *)Tcl_GetHashValue(hPtr); + return (Container *)Tcl_GetHashValue(hPtr); } /* *---------------------------------------------------------------------- * - * ConfigureSlave -- + * ConfigureContent -- * * This function is called to process an argv/argc list to reconfigure * the placement of a window. * * Results: * A standard Tcl result. If an error occurs then a message is left in * the interp's result. * * Side effects: - * Information in slavePtr may change, and slavePtr's master is scheduled + * Information in contentPtr may change, and contentPtr's container is scheduled * for reconfiguration. * *---------------------------------------------------------------------- */ static int -ConfigureSlave( +ConfigureContent( Tcl_Interp *interp, /* Used for error reporting. */ Tk_Window tkwin, /* Token for the window to manipulate. */ Tk_OptionTable table, /* Token for option table. */ int objc, /* Number of config arguments. */ Tcl_Obj *const objv[]) /* Object values for arguments. */ { - Master *masterPtr; + Container *containerPtr; Tk_SavedOptions savedOptions; int mask; - Slave *slavePtr; - Tk_Window masterWin = NULL; - TkWindow *master; + Content *contentPtr; + Tk_Window containerWin = NULL; + TkWindow *container; if (Tk_TopWinHierarchy(tkwin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use placer on top-level window \"%s\"; use " "wm command instead", Tk_PathName(tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } - slavePtr = CreateSlave(tkwin, table); + contentPtr = CreateContent(tkwin, table); - if (Tk_SetOptions(interp, slavePtr, table, objc, objv, - slavePtr->tkwin, &savedOptions, &mask) != TCL_OK) { + if (Tk_SetOptions(interp, contentPtr, table, objc, objv, + contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) { goto error; } /* - * Set slave flags. First clear the field, then add bits as needed. - */ - - slavePtr->flags = 0; - if (slavePtr->heightPtr) { - slavePtr->flags |= CHILD_HEIGHT; - } - - if (slavePtr->relHeightPtr) { - slavePtr->flags |= CHILD_REL_HEIGHT; - } - - if (slavePtr->relWidthPtr) { - slavePtr->flags |= CHILD_REL_WIDTH; - } - - if (slavePtr->widthPtr) { - slavePtr->flags |= CHILD_WIDTH; - } - - if (!(mask & IN_MASK) && (slavePtr->masterPtr != NULL)) { - /* - * If no -in option was passed and the slave is already placed then + * Set content flags. First clear the field, then add bits as needed. + */ + + contentPtr->flags = 0; + if (contentPtr->heightPtr) { + contentPtr->flags |= CHILD_HEIGHT; + } + + if (contentPtr->relHeightPtr) { + contentPtr->flags |= CHILD_REL_HEIGHT; + } + + if (contentPtr->relWidthPtr) { + contentPtr->flags |= CHILD_REL_WIDTH; + } + + if (contentPtr->widthPtr) { + contentPtr->flags |= CHILD_WIDTH; + } + + if (!(mask & IN_MASK) && (contentPtr->containerPtr != NULL)) { + /* + * If no -in option was passed and the content is already placed then * just recompute the placement. */ - masterPtr = slavePtr->masterPtr; + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } else if (mask & IN_MASK) { /* -in changed */ - Tk_Window tkwin; + Tk_Window win; Tk_Window ancestor; - tkwin = slavePtr->inTkwin; + win = contentPtr->inTkwin; /* - * Make sure that the new master is either the logical parent of the - * slave or a descendant of that window, and that the master and slave + * Make sure that the new container is either the logical parent of the + * content window or a descendant of that window, and that the container and content * aren't the same. */ - for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) { - if (ancestor == Tk_Parent(slavePtr->tkwin)) { + for (ancestor = win; ; ancestor = Tk_Parent(ancestor)) { + if (ancestor == Tk_Parent(contentPtr->tkwin)) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't place %s relative to %s", - Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin))); + "can't place \"%s\" relative to \"%s\"", + Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); goto error; } } - if (slavePtr->tkwin == tkwin) { + if (contentPtr->tkwin == win) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't place %s relative to itself", - Tk_PathName(slavePtr->tkwin))); + "can't place \"%s\" relative to itself", + Tk_PathName(contentPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); goto error; } /* * Check for management loops. */ - for (master = (TkWindow *)tkwin; master != NULL; - master = (TkWindow *)TkGetGeomMaster(master)) { - if (master == (TkWindow *)slavePtr->tkwin) { + for (container = (TkWindow *)win; container != NULL; + container = (TkWindow *)TkGetContainer(container)) { + if (container == (TkWindow *)contentPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put %s inside %s, would cause management loop", - Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin))); + "can't put \"%s\" inside \"%s\": would cause management loop", + Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); goto error; } } - if (tkwin != Tk_Parent(slavePtr->tkwin)) { - ((TkWindow *)slavePtr->tkwin)->maintainerPtr = (TkWindow *)tkwin; + if (win != Tk_Parent(contentPtr->tkwin)) { + ((TkWindow *)contentPtr->tkwin)->maintainerPtr = (TkWindow *)win; } - if ((slavePtr->masterPtr != NULL) - && (slavePtr->masterPtr->tkwin == tkwin)) { + if ((contentPtr->containerPtr != NULL) + && (contentPtr->containerPtr->tkwin == win)) { /* - * Re-using same old master. Nothing to do. + * Re-using same old container. Nothing to do. */ - masterPtr = slavePtr->masterPtr; + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } - if ((slavePtr->masterPtr != NULL) && - (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); - } - UnlinkSlave(slavePtr); - masterWin = tkwin; - } - - /* - * If there's no master specified for this slave, use its Tk_Parent. - */ - - if (masterWin == NULL) { - masterWin = Tk_Parent(slavePtr->tkwin); - slavePtr->inTkwin = masterWin; - } - - /* - * Manage the slave window in this master. - */ - - masterPtr = CreateMaster(masterWin); - slavePtr->masterPtr = masterPtr; - slavePtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = slavePtr; - Tk_ManageGeometry(slavePtr->tkwin, &placerType, slavePtr); - - /* - * Arrange for the master to be re-arranged at the first idle moment. + if ((contentPtr->containerPtr != NULL) && + (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin))) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); + } + UnlinkContent(contentPtr); + containerWin = win; + } + + /* + * If there's no container specified for this content, use its Tk_Parent. + */ + + if (containerWin == NULL) { + containerWin = Tk_Parent(contentPtr->tkwin); + contentPtr->inTkwin = containerWin; + } + + /* + * Manage the content window in this container. + */ + + containerPtr = CreateContainer(containerWin); + contentPtr->containerPtr = containerPtr; + contentPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = contentPtr; + Tk_ManageGeometry(contentPtr->tkwin, &placerType, contentPtr); + + /* + * Arrange for the container to be re-arranged at the first idle moment. */ scheduleLayout: Tk_FreeSavedOptions(&savedOptions); - if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) { - masterPtr->flags |= PARENT_RECONFIG_PENDING; - Tcl_DoWhenIdle(RecomputePlacement, masterPtr); + if (!(containerPtr->flags & PARENT_RECONFIG_PENDING)) { + containerPtr->flags |= PARENT_RECONFIG_PENDING; + Tcl_DoWhenIdle(RecomputePlacement, containerPtr); } return TCL_OK; /* * Error while processing some option, cleanup and return. @@ -793,53 +805,53 @@ static int PlaceInfoCommand( Tcl_Interp *interp, /* Interp into which to place result. */ Tk_Window tkwin) /* Token for the window to get info on. */ { - Slave *slavePtr; + Content *contentPtr; Tcl_Obj *infoObj; - slavePtr = FindSlave(tkwin); - if (slavePtr == NULL) { + contentPtr = FindContent(tkwin); + if (contentPtr == NULL) { return TCL_OK; } infoObj = Tcl_NewObj(); - if (slavePtr->masterPtr != NULL) { + if (contentPtr->containerPtr != NULL) { Tcl_AppendToObj(infoObj, "-in", -1); Tcl_ListObjAppendElement(NULL, infoObj, - TkNewWindowObj(slavePtr->masterPtr->tkwin)); + Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_AppendToObj(infoObj, " ", -1); } Tcl_AppendPrintfToObj(infoObj, "-x %d -relx %.4g -y %d -rely %.4g", - slavePtr->x, slavePtr->relX, slavePtr->y, slavePtr->relY); - if (slavePtr->flags & CHILD_WIDTH) { - Tcl_AppendPrintfToObj(infoObj, " -width %d", slavePtr->width); + contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY); + if (contentPtr->flags & CHILD_WIDTH) { + Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width); } else { Tcl_AppendToObj(infoObj, " -width {}", -1); } - if (slavePtr->flags & CHILD_REL_WIDTH) { + if (contentPtr->flags & CHILD_REL_WIDTH) { Tcl_AppendPrintfToObj(infoObj, - " -relwidth %.4g", slavePtr->relWidth); + " -relwidth %.4g", contentPtr->relWidth); } else { Tcl_AppendToObj(infoObj, " -relwidth {}", -1); } - if (slavePtr->flags & CHILD_HEIGHT) { - Tcl_AppendPrintfToObj(infoObj, " -height %d", slavePtr->height); + if (contentPtr->flags & CHILD_HEIGHT) { + Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height); } else { Tcl_AppendToObj(infoObj, " -height {}", -1); } - if (slavePtr->flags & CHILD_REL_HEIGHT) { + if (contentPtr->flags & CHILD_REL_HEIGHT) { Tcl_AppendPrintfToObj(infoObj, - " -relheight %.4g", slavePtr->relHeight); + " -relheight %.4g", contentPtr->relHeight); } else { Tcl_AppendToObj(infoObj, " -relheight {}", -1); } Tcl_AppendPrintfToObj(infoObj, " -anchor %s -bordermode %s", - Tk_NameOfAnchor(slavePtr->anchor), - borderModeStrings[slavePtr->borderMode]); + Tk_NameOfAnchor(contentPtr->anchor), + borderModeStrings[contentPtr->borderMode]); Tcl_SetObjResult(interp, infoObj); return TCL_OK; } /* @@ -846,11 +858,11 @@ *---------------------------------------------------------------------- * * RecomputePlacement -- * * This function is called as a when-idle handler. It recomputes the - * geometries of all the slaves of a given master. + * geometries of all the content of a given container. * * Results: * None. * * Side effects: @@ -859,121 +871,121 @@ *---------------------------------------------------------------------- */ static void RecomputePlacement( - ClientData clientData) /* Pointer to Master record. */ + ClientData clientData) /* Pointer to Container record. */ { - Master *masterPtr = (Master *)clientData; - Slave *slavePtr; + Container *containerPtr = (Container *)clientData; + Content *contentPtr; int x, y, width, height, tmp; - int masterWidth, masterHeight, masterX, masterY; + int containerWidth, containerHeight, containerX, containerY; double x1, y1, x2, y2; int abort; /* May get set to non-zero to abort this * placement operation. */ - masterPtr->flags &= ~PARENT_RECONFIG_PENDING; + containerPtr->flags &= ~PARENT_RECONFIG_PENDING; /* * Abort any nested call to RecomputePlacement for this window, since * we'll do everything necessary here, and set up so this call can be * aborted if necessary. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - masterPtr->abortPtr = &abort; + containerPtr->abortPtr = &abort; abort = 0; - Tcl_Preserve(masterPtr); + Tcl_Preserve(containerPtr); /* - * Iterate over all the slaves for the master. Each slave's geometry can - * be computed independently of the other slaves. Changes to the window's + * Iterate over all the content windows for the container. Each content's geometry can + * be computed independently of the other content. Changes to the window's * structure could cause almost anything to happen, including deleting the * parent or child. If this happens, we'll be told to abort. */ - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL && !abort; - slavePtr = slavePtr->nextPtr) { - /* - * Step 1: compute size and borderwidth of master, taking into account - * desired border mode. - */ - - masterX = masterY = 0; - masterWidth = Tk_Width(masterPtr->tkwin); - masterHeight = Tk_Height(masterPtr->tkwin); - if (slavePtr->borderMode == BM_INSIDE) { - masterX = Tk_InternalBorderLeft(masterPtr->tkwin); - masterY = Tk_InternalBorderTop(masterPtr->tkwin); - masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); - masterHeight -= masterY + - Tk_InternalBorderBottom(masterPtr->tkwin); - } else if (slavePtr->borderMode == BM_OUTSIDE) { - masterX = masterY = -Tk_Changes(masterPtr->tkwin)->border_width; - masterWidth -= 2 * masterX; - masterHeight -= 2 * masterY; - } - - /* - * Step 2: compute size of slave (outside dimensions including border) - * and location of anchor point within master. - */ - - x1 = slavePtr->x + masterX + (slavePtr->relX*masterWidth); - x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5)); - y1 = slavePtr->y + masterY + (slavePtr->relY*masterHeight); - y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5)); - if (slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) { - width = 0; - if (slavePtr->flags & CHILD_WIDTH) { - width += slavePtr->width; - } - if (slavePtr->flags & CHILD_REL_WIDTH) { + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL && !abort; + contentPtr = contentPtr->nextPtr) { + /* + * Step 1: compute size and borderwidth of container, taking into account + * desired border mode. + */ + + containerX = containerY = 0; + containerWidth = Tk_Width(containerPtr->tkwin); + containerHeight = Tk_Height(containerPtr->tkwin); + if (contentPtr->borderMode == BM_INSIDE) { + containerX = Tk_InternalBorderLeft(containerPtr->tkwin); + containerY = Tk_InternalBorderTop(containerPtr->tkwin); + containerWidth -= containerX + Tk_InternalBorderRight(containerPtr->tkwin); + containerHeight -= containerY + + Tk_InternalBorderBottom(containerPtr->tkwin); + } else if (contentPtr->borderMode == BM_OUTSIDE) { + containerX = containerY = -Tk_Changes(containerPtr->tkwin)->border_width; + containerWidth -= 2 * containerX; + containerHeight -= 2 * containerY; + } + + /* + * Step 2: compute size of content (outside dimensions including border) + * and location of anchor point within container. + */ + + x1 = contentPtr->x + containerX + (contentPtr->relX*containerWidth); + x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5)); + y1 = contentPtr->y + containerY + (contentPtr->relY*containerHeight); + y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5)); + if (contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) { + width = 0; + if (contentPtr->flags & CHILD_WIDTH) { + width += contentPtr->width; + } + if (contentPtr->flags & CHILD_REL_WIDTH) { /* * The code below is a bit tricky. In order to round correctly * when both relX and relWidth are specified, compute the * location of the right edge and round that, then compute * width. If we compute the width and round it, rounding * errors in relX and relWidth accumulate. */ - x2 = x1 + (slavePtr->relWidth*masterWidth); + x2 = x1 + (contentPtr->relWidth*containerWidth); tmp = (int) (x2 + ((x2 > 0) ? 0.5 : -0.5)); width += tmp - x; } } else { - width = Tk_ReqWidth(slavePtr->tkwin) - + 2*Tk_Changes(slavePtr->tkwin)->border_width; + width = Tk_ReqWidth(contentPtr->tkwin) + + 2*Tk_Changes(contentPtr->tkwin)->border_width; } - if (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) { + if (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) { height = 0; - if (slavePtr->flags & CHILD_HEIGHT) { - height += slavePtr->height; + if (contentPtr->flags & CHILD_HEIGHT) { + height += contentPtr->height; } - if (slavePtr->flags & CHILD_REL_HEIGHT) { + if (contentPtr->flags & CHILD_REL_HEIGHT) { /* * See note above for rounding errors in width computation. */ - y2 = y1 + (slavePtr->relHeight*masterHeight); + y2 = y1 + (contentPtr->relHeight*containerHeight); tmp = (int) (y2 + ((y2 > 0) ? 0.5 : -0.5)); height += tmp - y; } } else { - height = Tk_ReqHeight(slavePtr->tkwin) - + 2*Tk_Changes(slavePtr->tkwin)->border_width; + height = Tk_ReqHeight(contentPtr->tkwin) + + 2*Tk_Changes(contentPtr->tkwin)->border_width; } /* * Step 3: adjust the x and y positions so that the desired anchor - * point on the slave appears at that position. Also adjust for the - * border mode and master's border. + * point on the content appears at that position. Also adjust for the + * border mode and container's border. */ - switch (slavePtr->anchor) { + switch (contentPtr->anchor) { case TK_ANCHOR_N: x -= width/2; break; case TK_ANCHOR_NE: x -= width; @@ -1008,147 +1020,147 @@ * Step 4: adjust width and height again to reflect inside dimensions * of window rather than outside. Also make sure that the width and * height aren't zero. */ - width -= 2*Tk_Changes(slavePtr->tkwin)->border_width; - height -= 2*Tk_Changes(slavePtr->tkwin)->border_width; + width -= 2*Tk_Changes(contentPtr->tkwin)->border_width; + height -= 2*Tk_Changes(contentPtr->tkwin)->border_width; if (width <= 0) { width = 1; } if (height <= 0) { height = 1; } /* - * Step 5: reconfigure the window and map it if needed. If the slave - * is a child of the master, we do this ourselves. If the slave isn't - * a child of the master, let Tk_MaintainGeometry do the work (it will + * Step 5: reconfigure the window and map it if needed. If the content + * is a child of the container, we do this ourselves. If the content isn't + * a child of the container, let Tk_MaintainGeometry do the work (it will * re-adjust things as relevant windows map, unmap, and move). */ - if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) { - if ((x != Tk_X(slavePtr->tkwin)) - || (y != Tk_Y(slavePtr->tkwin)) - || (width != Tk_Width(slavePtr->tkwin)) - || (height != Tk_Height(slavePtr->tkwin))) { - Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height); + if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) { + if ((x != Tk_X(contentPtr->tkwin)) + || (y != Tk_Y(contentPtr->tkwin)) + || (width != Tk_Width(contentPtr->tkwin)) + || (height != Tk_Height(contentPtr->tkwin))) { + Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height); } if (abort) { break; } /* - * Don't map the slave unless the master is mapped: the slave will - * get mapped later, when the master is mapped. + * Don't map the content unless the container is mapped: the content will + * get mapped later, when the container is mapped. */ - if (Tk_IsMapped(masterPtr->tkwin)) { - Tk_MapWindow(slavePtr->tkwin); + if (Tk_IsMapped(containerPtr->tkwin)) { + Tk_MapWindow(contentPtr->tkwin); } } else { if ((width <= 0) || (height <= 0)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin, + Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin, x, y, width, height); } } } - masterPtr->abortPtr = NULL; - Tcl_Release(masterPtr); + containerPtr->abortPtr = NULL; + Tcl_Release(containerPtr); } /* *---------------------------------------------------------------------- * - * MasterStructureProc -- + * PlaceStructureProc -- * * This function is invoked by the Tk event handler when StructureNotify - * events occur for a master window. + * events occur for a container window. * * Results: * None. * * Side effects: * Structures get cleaned up if the window was deleted. If the window was - * resized then slave geometries get recomputed. + * resized then content geometries get recomputed. * *---------------------------------------------------------------------- */ static void -MasterStructureProc( - ClientData clientData, /* Pointer to Master structure for window +PlaceStructureProc( + ClientData clientData, /* Pointer to Container structure for window * referred to by eventPtr. */ XEvent *eventPtr) /* Describes what just happened. */ { - Master *masterPtr = (Master *)clientData; - Slave *slavePtr, *nextPtr; - TkDisplay *dispPtr = ((TkWindow *) masterPtr->tkwin)->dispPtr; + Container *containerPtr = (Container *)clientData; + Content *contentPtr, *nextPtr; + TkDisplay *dispPtr = ((TkWindow *) containerPtr->tkwin)->dispPtr; switch (eventPtr->type) { case ConfigureNotify: - if ((masterPtr->slavePtr != NULL) - && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) { - masterPtr->flags |= PARENT_RECONFIG_PENDING; - Tcl_DoWhenIdle(RecomputePlacement, masterPtr); + if ((containerPtr->contentPtr != NULL) + && !(containerPtr->flags & PARENT_RECONFIG_PENDING)) { + containerPtr->flags |= PARENT_RECONFIG_PENDING; + Tcl_DoWhenIdle(RecomputePlacement, containerPtr); } return; case DestroyNotify: - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = nextPtr) { - slavePtr->masterPtr = NULL; - nextPtr = slavePtr->nextPtr; - slavePtr->nextPtr = NULL; - } - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->masterTable, - masterPtr->tkwin)); - if (masterPtr->flags & PARENT_RECONFIG_PENDING) { - Tcl_CancelIdleCall(RecomputePlacement, masterPtr); - } - masterPtr->tkwin = NULL; - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; - } - Tcl_EventuallyFree(masterPtr, TCL_DYNAMIC); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = nextPtr) { + contentPtr->containerPtr = NULL; + nextPtr = contentPtr->nextPtr; + contentPtr->nextPtr = NULL; + } + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->containerTable, + containerPtr->tkwin)); + if (containerPtr->flags & PARENT_RECONFIG_PENDING) { + Tcl_CancelIdleCall(RecomputePlacement, containerPtr); + } + containerPtr->tkwin = NULL; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; + } + Tcl_EventuallyFree(containerPtr, TCL_DYNAMIC); return; case MapNotify: /* - * When a master gets mapped, must redo the geometry computation so - * that all of its slaves get remapped. + * When a container gets mapped, must redo the geometry computation so + * that all of its content get remapped. */ - if ((masterPtr->slavePtr != NULL) - && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) { - masterPtr->flags |= PARENT_RECONFIG_PENDING; - Tcl_DoWhenIdle(RecomputePlacement, masterPtr); + if ((containerPtr->contentPtr != NULL) + && !(containerPtr->flags & PARENT_RECONFIG_PENDING)) { + containerPtr->flags |= PARENT_RECONFIG_PENDING; + Tcl_DoWhenIdle(RecomputePlacement, containerPtr); } return; case UnmapNotify: /* - * Unmap all of the slaves when the master gets unmapped, so that they + * Unmap all of the content when the container gets unmapped, so that they * don't keep redisplaying themselves. */ - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - Tk_UnmapWindow(slavePtr->tkwin); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + Tk_UnmapWindow(contentPtr->tkwin); } return; } } /* *---------------------------------------------------------------------- * - * SlaveStructureProc -- + * ContentStructureProc -- * * This function is invoked by the Tk event handler when StructureNotify - * events occur for a slave window. + * events occur for a content window. * * Results: * None. * * Side effects: @@ -1156,34 +1168,34 @@ * *---------------------------------------------------------------------- */ static void -SlaveStructureProc( - ClientData clientData, /* Pointer to Slave structure for window +ContentStructureProc( + ClientData clientData, /* Pointer to Content structure for window * referred to by eventPtr. */ XEvent *eventPtr) /* Describes what just happened. */ { - Slave *slavePtr = (Slave *)clientData; - TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; + Content *contentPtr = (Content *)clientData; + TkDisplay *dispPtr = ((TkWindow *) contentPtr->tkwin)->dispPtr; if (eventPtr->type == DestroyNotify) { - if (slavePtr->masterPtr != NULL) { - UnlinkSlave(slavePtr); + if (contentPtr->containerPtr != NULL) { + UnlinkContent(contentPtr); } - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, - slavePtr->tkwin)); - FreeSlave(slavePtr); + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable, + contentPtr->tkwin)); + FreeContent(contentPtr); } } /* *---------------------------------------------------------------------- * * PlaceRequestProc -- * - * This function is invoked by Tk whenever a slave managed by us changes + * This function is invoked by Tk whenever a content managed by us changes * its requested geometry. * * Results: * None. * @@ -1194,77 +1206,76 @@ *---------------------------------------------------------------------- */ static void PlaceRequestProc( - ClientData clientData, /* Pointer to our record for slave. */ - Tk_Window tkwin) /* Window that changed its desired size. */ -{ - Slave *slavePtr = (Slave *)clientData; - Master *masterPtr; - (void)tkwin; - - if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) - && (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) { + ClientData clientData, /* Pointer to our record for content. */ + TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */ +{ + Content *contentPtr = (Content *)clientData; + Container *containerPtr; + + if ((contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) + && (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) { /* * Send a ConfigureNotify to indicate that the size change * request was rejected. */ - TkDoConfigureNotify((TkWindow *)(slavePtr->tkwin)); + TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin)); return; } - masterPtr = slavePtr->masterPtr; - if (masterPtr == NULL) { + containerPtr = contentPtr->containerPtr; + if (containerPtr == NULL) { return; } - if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) { - masterPtr->flags |= PARENT_RECONFIG_PENDING; - Tcl_DoWhenIdle(RecomputePlacement, masterPtr); + if (!(containerPtr->flags & PARENT_RECONFIG_PENDING)) { + containerPtr->flags |= PARENT_RECONFIG_PENDING; + Tcl_DoWhenIdle(RecomputePlacement, containerPtr); } } /* *-------------------------------------------------------------- * - * PlaceLostSlaveProc -- + * PlaceLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all placer-related information about the slave. + * Forgets all placer-related information about the content window. * *-------------------------------------------------------------- */ static void -PlaceLostSlaveProc( - ClientData clientData, /* Slave structure for slave window that was - * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ -{ - Slave *slavePtr = (Slave *)clientData; - TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; - - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); +PlaceLostContentProc( + ClientData clientData, /* Content structure for content window that was + * stolen away. */ + Tk_Window tkwin) /* Tk's handle for the content window. */ +{ + Content *contentPtr = (Content *)clientData; + TkDisplay *dispPtr = ((TkWindow *) contentPtr->tkwin)->dispPtr; + + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); } Tk_UnmapWindow(tkwin); - UnlinkSlave(slavePtr); - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, + UnlinkContent(contentPtr); + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable, tkwin)); - Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - slavePtr); - FreeSlave(slavePtr); + Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc, + contentPtr); + FreeContent(contentPtr); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ Index: generic/tkPlatDecls.h ================================================================== --- generic/tkPlatDecls.h +++ generic/tkPlatDecls.h @@ -1,11 +1,11 @@ /* * tkPlatDecls.h -- * * Declarations of functions in the platform-specific public Tcl API. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -52,55 +52,38 @@ EXTERN int Tk_TranslateWinEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ -/* 0 */ -EXTERN void Tk_MacOSXSetEmbedHandler( - Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, - Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, - Tk_MacOSXEmbedGetClipProc *getClipProc, - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); -/* 1 */ -EXTERN void Tk_MacOSXTurnOffMenus(void); -/* 2 */ -EXTERN void Tk_MacOSXTkOwnsCursor(int tkOwnsIt); -/* 3 */ -EXTERN void TkMacOSXInitMenus(Tcl_Interp *interp); +/* Slot 0 is reserved */ +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ +/* Slot 3 is reserved */ /* 4 */ EXTERN void TkMacOSXInitAppleEvents(Tcl_Interp *interp); /* 5 */ -EXTERN void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, +EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 6 */ EXTERN void TkMacOSXInvalClipRgns(Tk_Window tkwin); -/* 7 */ -EXTERN void * TkMacOSXGetDrawablePort(Drawable drawable); +/* Slot 7 is reserved */ /* 8 */ EXTERN void * TkMacOSXGetRootControl(Drawable drawable); /* 9 */ EXTERN void Tk_MacOSXSetupTkNotifier(void); /* 10 */ EXTERN int Tk_MacOSXIsAppInFront(void); /* 11 */ -EXTERN void Tk_MacOSXSetEmbedHandler_( - Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, - Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, - Tk_MacOSXEmbedGetClipProc *getClipProc, - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); +EXTERN Tk_Window Tk_MacOSXGetTkWindow(void *w); /* 12 */ -EXTERN void Tk_MacOSXTurnOffMenus_(void); +EXTERN void * Tk_MacOSXGetCGContextForDrawable(Drawable drawable); /* 13 */ -EXTERN void Tk_MacOSXTkOwnsCursor_(int tkOwnsIt); -/* 14 */ -EXTERN void TkMacOSXInitMenus_(Tcl_Interp *interp); -/* 15 */ -EXTERN void TkMacOSXInitAppleEvents_(Tcl_Interp *interp); +EXTERN void * Tk_MacOSXGetNSWindowForDrawable(Drawable drawable); +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ /* 16 */ -EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, +EXTERN void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width, int height, int flags); #endif /* AQUA */ typedef struct TkPlatStubs { int magic; @@ -113,27 +96,27 @@ Tk_Window (*tk_HWNDToWindow) (HWND hwnd); /* 3 */ void (*tk_PointerEvent) (HWND hwnd, int x, int y); /* 4 */ int (*tk_TranslateWinEvent) (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result); /* 5 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ - void (*tk_MacOSXSetEmbedHandler) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 0 */ - void (*tk_MacOSXTurnOffMenus) (void); /* 1 */ - void (*tk_MacOSXTkOwnsCursor) (int tkOwnsIt); /* 2 */ - void (*tkMacOSXInitMenus) (Tcl_Interp *interp); /* 3 */ + void (*reserved0)(void); + void (*reserved1)(void); + void (*reserved2)(void); + void (*reserved3)(void); void (*tkMacOSXInitAppleEvents) (Tcl_Interp *interp); /* 4 */ - void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */ + void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */ void (*tkMacOSXInvalClipRgns) (Tk_Window tkwin); /* 6 */ - void * (*tkMacOSXGetDrawablePort) (Drawable drawable); /* 7 */ + void (*reserved7)(void); void * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */ void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */ int (*tk_MacOSXIsAppInFront) (void); /* 10 */ - void (*tk_MacOSXSetEmbedHandler_) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 11 */ - void (*tk_MacOSXTurnOffMenus_) (void); /* 12 */ - void (*tk_MacOSXTkOwnsCursor_) (int tkOwnsIt); /* 13 */ - void (*tkMacOSXInitMenus_) (Tcl_Interp *interp); /* 14 */ - void (*tkMacOSXInitAppleEvents_) (Tcl_Interp *interp); /* 15 */ - void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */ + Tk_Window (*tk_MacOSXGetTkWindow) (void *w); /* 11 */ + void * (*tk_MacOSXGetCGContextForDrawable) (Drawable drawable); /* 12 */ + void * (*tk_MacOSXGetNSWindowForDrawable) (Drawable drawable); /* 13 */ + void (*reserved14)(void); + void (*reserved15)(void); + void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */ #endif /* AQUA */ } TkPlatStubs; extern const TkPlatStubs *tkPlatStubsPtr; @@ -160,60 +143,49 @@ (tkPlatStubsPtr->tk_PointerEvent) /* 4 */ #define Tk_TranslateWinEvent \ (tkPlatStubsPtr->tk_TranslateWinEvent) /* 5 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ -#define Tk_MacOSXSetEmbedHandler \ - (tkPlatStubsPtr->tk_MacOSXSetEmbedHandler) /* 0 */ -#define Tk_MacOSXTurnOffMenus \ - (tkPlatStubsPtr->tk_MacOSXTurnOffMenus) /* 1 */ -#define Tk_MacOSXTkOwnsCursor \ - (tkPlatStubsPtr->tk_MacOSXTkOwnsCursor) /* 2 */ -#define TkMacOSXInitMenus \ - (tkPlatStubsPtr->tkMacOSXInitMenus) /* 3 */ +/* Slot 0 is reserved */ +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ +/* Slot 3 is reserved */ #define TkMacOSXInitAppleEvents \ (tkPlatStubsPtr->tkMacOSXInitAppleEvents) /* 4 */ -#define TkGenWMConfigureEvent \ - (tkPlatStubsPtr->tkGenWMConfigureEvent) /* 5 */ +#define TkGenWMConfigureEvent_ \ + (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 5 */ #define TkMacOSXInvalClipRgns \ (tkPlatStubsPtr->tkMacOSXInvalClipRgns) /* 6 */ -#define TkMacOSXGetDrawablePort \ - (tkPlatStubsPtr->tkMacOSXGetDrawablePort) /* 7 */ +/* Slot 7 is reserved */ #define TkMacOSXGetRootControl \ (tkPlatStubsPtr->tkMacOSXGetRootControl) /* 8 */ #define Tk_MacOSXSetupTkNotifier \ (tkPlatStubsPtr->tk_MacOSXSetupTkNotifier) /* 9 */ #define Tk_MacOSXIsAppInFront \ (tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */ -#define Tk_MacOSXSetEmbedHandler_ \ - (tkPlatStubsPtr->tk_MacOSXSetEmbedHandler_) /* 11 */ -#define Tk_MacOSXTurnOffMenus_ \ - (tkPlatStubsPtr->tk_MacOSXTurnOffMenus_) /* 12 */ -#define Tk_MacOSXTkOwnsCursor_ \ - (tkPlatStubsPtr->tk_MacOSXTkOwnsCursor_) /* 13 */ -#define TkMacOSXInitMenus_ \ - (tkPlatStubsPtr->tkMacOSXInitMenus_) /* 14 */ -#define TkMacOSXInitAppleEvents_ \ - (tkPlatStubsPtr->tkMacOSXInitAppleEvents_) /* 15 */ -#define TkGenWMConfigureEvent_ \ - (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */ +#define Tk_MacOSXGetTkWindow \ + (tkPlatStubsPtr->tk_MacOSXGetTkWindow) /* 11 */ +#define Tk_MacOSXGetCGContextForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetCGContextForDrawable) /* 12 */ +#define Tk_MacOSXGetNSWindowForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetNSWindowForDrawable) /* 13 */ +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ +#define TkGenWMConfigureEvent \ + (tkPlatStubsPtr->tkGenWMConfigureEvent) /* 16 */ #endif /* AQUA */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ -#undef Tk_MacOSXSetEmbedHandler_ -#undef Tk_MacOSXTurnOffMenus_ -#undef Tk_MacOSXTkOwnsCursor_ -#undef TkMacOSXInitMenus_ -#undef TkMacOSXInitAppleEvents_ -#undef TkGenWMConfigureEvent_ - #ifdef __cplusplus } #endif #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT +#undef TkGenWMConfigureEvent_ +#define Tk_MacOSXGetNSViewForDrawable TkMacOSXGetRootControl + #endif /* _TKPLATDECLS */ Index: generic/tkPointer.c ================================================================== --- generic/tkPointer.c +++ generic/tkPointer.c @@ -4,11 +4,11 @@ * This file contains functions for emulating the X server pointer and * grab state machine. This file is used by the Mac and Windows platforms * to generate appropriate enter/leave events, and to update the global * grab window information. * - * Copyright (c) 1996 by Sun Microsystems, Inc. + * Copyright © 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -23,11 +23,11 @@ #endif typedef struct { TkWindow *grabWinPtr; /* Window that defines the top of the grab * tree in a global grab. */ - int lastState; /* Last known state flags. */ + unsigned lastState; /* Last known state flags. */ XPoint lastPos; /* Last reported mouse position. */ TkWindow *lastWinPtr; /* Last reported mouse window. */ TkWindow *restrictWinPtr; /* Window to which all mouse events will be * reported. */ TkWindow *cursorWinPtr; /* Window that is currently controlling the @@ -222,12 +222,13 @@ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); TkWindow *winPtr = (TkWindow *)tkwin; TkWindow *targetWinPtr; XPoint pos; XEvent event; - int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; - int type, b, mask; + unsigned changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; + int type, b; + unsigned mask; pos.x = x; pos.y = y; /* @@ -252,11 +253,11 @@ * Generate ButtonPress/ButtonRelease events based on the differences * between the current button state and the last known button state. */ for (b = Button1; b <= Button9; b++) { - mask = TkGetButtonMask(b); + mask = Tk_GetButtonMask(b); if (changes & mask) { if (state & mask) { type = ButtonPress; /* Index: generic/tkRectOval.c ================================================================== --- generic/tkRectOval.c +++ generic/tkRectOval.c @@ -1,12 +1,12 @@ /* * tkRectOval.c -- * * This file implements rectangle and oval items for canvas widgets. * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1991-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkScale.c ================================================================== --- generic/tkScale.c +++ generic/tkScale.c @@ -7,13 +7,13 @@ * * The modifications to use floating-point values are based on an * implementation by Paul Mackerras. The -variable option is due to * Henning Schulzrinne. All of these are used with permission. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-2000 by Scriptics Corporation. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-2000 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -355,11 +355,11 @@ * The widget was just created, no command callback must be invoked. */ scalePtr->flags &= ~INVOKE_COMMAND; - Tcl_SetObjResult(interp, TkNewWindowObj(scalePtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(scalePtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -657,17 +657,15 @@ (Tcl_GetDoubleFromObj(NULL, valuePtr, &value) == TCL_OK)) { scalePtr->value = TkRoundValueToResolution(scalePtr, value); } } - /* - * Several options need special processing, such as parsing the - * orientation and creating GCs. - */ + /* + * The fromValue shall not be rounded to the resolution, but the + * toValue and tickInterval do. + */ - scalePtr->fromValue = TkRoundValueToResolution(scalePtr, - scalePtr->fromValue); scalePtr->toValue = TkRoundValueToResolution(scalePtr, scalePtr->toValue); scalePtr->tickInterval = TkRoundIntervalToResolution(scalePtr, scalePtr->tickInterval); /* Index: generic/tkScale.h ================================================================== --- generic/tkScale.h +++ generic/tkScale.h @@ -2,12 +2,12 @@ * tkScale.h -- * * Declarations of types and functions used to implement the scale * widget. * - * Copyright (c) 1996 by Sun Microsystems, Inc. - * Copyright (c) 1999-2000 by Scriptics Corporation. + * Copyright © 1996 Sun Microsystems, Inc. + * Copyright © 1999-2000 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkScrollbar.c ================================================================== --- generic/tkScrollbar.c +++ generic/tkScrollbar.c @@ -3,12 +3,12 @@ * * This module implements a scrollbar widgets for the Tk toolkit. A * scrollbar displays a slider and two arrows; mouse clicks on features * within the scrollbar cause scrolling commands to be invoked. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -194,11 +194,11 @@ if (ConfigureScrollbar(interp, scrollPtr, objc-2, objv+2, 0) != TCL_OK) { Tk_DestroyWindow(scrollPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(scrollPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(scrollPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -224,12 +224,12 @@ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { TkScrollbar *scrollPtr = (TkScrollbar *)clientData; - int result = TCL_OK, cmdIndex; - TkSizeT length; + int result = TCL_OK, cmdIndex, length; + TkSizeT len; static const char *const commandNames[] = { "activate", "cget", "configure", "delta", "fraction", "get", "identify", "set", NULL }; enum command { @@ -269,17 +269,17 @@ } if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "activate element"); goto error; } - c = TkGetStringFromObj(objv[2], &length)[0]; + c = Tcl_GetStringFromObj(objv[2], &len)[0]; oldActiveField = scrollPtr->activeField; if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) { scrollPtr->activeField = TOP_ARROW; } else if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow2") == 0)) { scrollPtr->activeField = BOTTOM_ARROW; - } else if ((c == 's') && (strncmp(Tcl_GetString(objv[2]), "slider", length) == 0)) { + } else if ((c == 's') && (strncmp(Tcl_GetString(objv[2]), "slider", len) == 0)) { scrollPtr->activeField = SLIDER; } else { scrollPtr->activeField = OUTSIDE; } if (oldActiveField != scrollPtr->activeField) { @@ -308,11 +308,11 @@ objv+2, TK_CONFIG_ARGV_ONLY); } break; } case COMMAND_DELTA: { - int xDelta, yDelta, pixels, length; + int xDelta, yDelta, pixels; double fraction; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "delta xDelta yDelta"); goto error; @@ -337,11 +337,11 @@ } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); break; } case COMMAND_FRACTION: { - int x, y, pos, length; + int x, y, pos; double fraction; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "fraction x y"); goto error; Index: generic/tkScrollbar.h ================================================================== --- generic/tkScrollbar.h +++ generic/tkScrollbar.h @@ -2,11 +2,11 @@ * tkScrollbar.h -- * * Declarations of types and functions used to implement the scrollbar * widget. * - * Copyright (c) 1996 by Sun Microsystems, Inc. + * Copyright © 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkSelect.c ================================================================== --- generic/tkSelect.c +++ generic/tkSelect.c @@ -2,12 +2,12 @@ * tkSelect.c -- * * This file manages the selection for the Tk toolkit, translating * between the standard X ICCCM conventions and Tcl commands. * - * Copyright (c) 1990-1993 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1993 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -26,11 +26,11 @@ int charOffset; /* The offset of the next char to retrieve. */ int byteOffset; /* The expected byte offset of the next * chunk. */ char buffer[4]; /* A buffer to hold part of a UTF character * that is split across chunks. */ - char command[1]; /* Command to invoke. Actual space is + char command[TKFLEXARRAY]; /* Command to invoke. Actual space is * allocated as large as necessary. This must * be the last entry in the structure. */ } CommandInfo; /* @@ -898,11 +898,11 @@ } else if (formatName != NULL) { format = Tk_InternAtom(tkwin, formatName); } else { format = XA_STRING; } - string = TkGetStringFromObj(objs[1], &cmdLength); + string = Tcl_GetStringFromObj(objs[1], &cmdLength); if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { cmdInfoPtr = (CommandInfo *)ckalloc(offsetof(CommandInfo, command) + 1 + cmdLength); @@ -990,11 +990,11 @@ * Ignore the internal clipboard window. */ if ((infoPtr != NULL) && (infoPtr->owner != winPtr->dispPtr->clipWindow)) { - Tcl_SetObjResult(interp, TkNewWindowObj(infoPtr->owner)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(infoPtr->owner)); } return TCL_OK; } tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin); @@ -1287,16 +1287,14 @@ static int SelGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ - Tcl_Interp *dummy, /* Interpreter used for error reporting (not + TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { - (void)dummy; - Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1); return TCL_OK; } /* Index: generic/tkSelect.h ================================================================== --- generic/tkSelect.h +++ generic/tkSelect.h @@ -2,11 +2,11 @@ * tkSelect.h -- * * Declarations of types shared among the files that implement selection * support. * - * Copyright (c) 1995 Sun Microsystems, Inc. + * Copyright © 1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkSquare.c ================================================================== --- generic/tkSquare.c +++ generic/tkSquare.c @@ -5,11 +5,11 @@ * "square" is a widget that displays a single square that can be moved * around and resized. This file is intended as an example of how to * build a widget; it isn't included in the normal wish, but it is * included in "tktest". * - * Copyright (c) 1997 Sun Microsystems, Inc. + * Copyright © 1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -232,11 +232,11 @@ }; Tcl_Obj *resultObjPtr; int index; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[1], squareOptions, sizeof(char *), "command", 0, &index) != TCL_OK) { Index: generic/tkStubInit.c ================================================================== --- generic/tkStubInit.c +++ generic/tkStubInit.c @@ -1,11 +1,11 @@ /* * tkStubInit.c -- * * This file contains the initializers for the Tk stub vectors. * - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright © 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -22,10 +22,11 @@ #endif #if defined(MAC_OSX_TK) /* we could have used _TKMACINT */ #include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #endif /* TODO: These ought to come in some other way */ #include "tkPlatDecls.h" #include "tkIntXlibDecls.h" @@ -41,10 +42,11 @@ #undef Tk_FreeStyleFromObj #undef Tk_GetStyleFromObj #undef TkWinGetPlatformId #undef TkPutImage #undef XPutImage +#define TkMacOSXSetUpClippingRgn (void (*)(Drawable))(void *)doNothing #if defined(_WIN32) && !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 # define Tk_TranslateWinEvent TkTranslateWinEvent # define Tk_PointerEvent TkWinPointerEvent #define TkWinGetPlatformId winGetPlatformId @@ -55,10 +57,16 @@ # define Tk_TranslateWinEvent 0 # define Tk_PointerEvent 0 # define TkWinGetPlatformId 0 #endif +static int +doNothing(void) +{ + /* dummy implementation, no need to do anything */ + return 0; +} #if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 #define Tk_MainEx 0 #define Tk_FreeXId 0 #define Tk_FreeStyleFromObj 0 @@ -70,15 +78,10 @@ #define Tk_PhotoPutBlock_Panic 0 #define Tk_PhotoPutZoomedBlock_Panic 0 #define Tk_PhotoSetSize_Panic 0 #define Tk_CreateOldPhotoImageFormat 0 #else -static void -doNothing(void) -{ - /* dummy implementation, no need to do anything */ -} #define Tk_FreeXId ((void (*)(Display *, XID))(void *)doNothing) #define Tk_FreeStyleFromObj ((void (*)(Tcl_Obj *))(void *)doNothing) #define Tk_GetStyleFromObj getStyleFromObj static Tk_Style Tk_GetStyleFromObj(Tcl_Obj *obj) { @@ -92,23 +95,26 @@ #define TkUnixDoOneXEvent_ TkUnixDoOneXEvent #define TkUnixSetMenubar_ TkUnixSetMenubar #define TkWmCleanup_ TkWmCleanup #define TkSendCleanup_ TkSendCleanup #define TkpTestsendCmd_ TkpTestsendCmd -#define Tk_MacOSXSetEmbedHandler_ Tk_MacOSXSetEmbedHandler -#define Tk_MacOSXTurnOffMenus_ Tk_MacOSXTurnOffMenus -#define Tk_MacOSXTkOwnsCursor_ Tk_MacOSXTkOwnsCursor -#define TkMacOSXInitMenus_ TkMacOSXInitMenus -#define TkMacOSXInitAppleEvents_ TkMacOSXInitAppleEvents #define TkGenWMConfigureEvent_ TkGenWMConfigureEvent #define TkGenerateActivateEvents_ TkGenerateActivateEvents +#define TkMacOSXDrawable Tk_MacOSXGetNSWindowForDrawable #define Tk_CanvasTagsParseProc \ (int (*) (void *, Tcl_Interp *,Tk_Window, const char *, char *, \ int offset))(void *)TkCanvasTagsParseProc #define Tk_CanvasTagsPrintProc \ (const char *(*) (void *,Tk_Window, char *, int, \ Tcl_FreeProc **))(void *)TkCanvasTagsPrintProc + +#if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL) +# undef TkpWillDrawWidget +# undef TkpRedrawWidget +# define TkpWillDrawWidget ((int (*)(Tk_Window))(void *)doNothing) +# define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing) +#endif #ifdef _WIN32 int TkpCmapStressed(Tk_Window tkwin, Colormap colormap) @@ -493,31 +499,29 @@ TkSmoothPrintProc, /* 180 */ TkDrawAngledTextLayout, /* 181 */ TkUnderlineAngledTextLayout, /* 182 */ TkIntersectAngledTextLayout, /* 183 */ TkDrawAngledChars, /* 184 */ - TkDebugPhotoStringMatchDef, /* 185 */ -#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ +#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */ + 0, /* 185 */ +#endif /* UNIX */ +#if defined(_WIN32) /* WIN */ + 0, /* 185 */ +#endif /* WIN */ +#ifdef MAC_OSX_TCL /* MACOSX */ + TkpRedrawWidget, /* 185 */ +#endif /* MACOSX */ +#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */ 0, /* 186 */ -#endif /* X11 */ +#endif /* UNIX */ #if defined(_WIN32) /* WIN */ 0, /* 186 */ #endif /* WIN */ -#ifdef MAC_OSX_TK /* AQUA */ - 0, /* 186 */ /* Dummy entry for stubs table backwards compatibility */ - TkpRedrawWidget, /* 186 */ -#endif /* AQUA */ -#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ - 0, /* 187 */ -#endif /* X11 */ -#if defined(_WIN32) /* WIN */ - 0, /* 187 */ -#endif /* WIN */ -#ifdef MAC_OSX_TK /* AQUA */ - 0, /* 187 */ /* Dummy entry for stubs table backwards compatibility */ - TkpWillDrawWidget, /* 187 */ -#endif /* AQUA */ +#ifdef MAC_OSX_TCL /* MACOSX */ + TkpWillDrawWidget, /* 186 */ +#endif /* MACOSX */ + TkDebugPhotoStringMatchDef, /* 187 */ }; static const TkIntPlatStubs tkIntPlatStubs = { TCL_STUB_MAGIC, 0, @@ -581,11 +585,11 @@ TkpWmSetState, /* 6 */ TkAboutDlg, /* 7 */ TkMacOSXButtonKeyState, /* 8 */ TkMacOSXClearMenubarActive, /* 9 */ TkMacOSXDispatchMenuEvent, /* 10 */ - TkMacOSXInstallCursor, /* 11 */ + 0, /* 11 */ TkMacOSXHandleTearoffMenu, /* 12 */ 0, /* 13 */ TkMacOSXDoHLEvent, /* 14 */ 0, /* 15 */ TkMacOSXGetXWindow, /* 16 */ @@ -596,18 +600,18 @@ TkMacOSXInvalidateWindow, /* 21 */ TkMacOSXIsCharacterMissing, /* 22 */ TkMacOSXMakeRealWindowExist, /* 23 */ TkMacOSXMakeStippleMap, /* 24 */ TkMacOSXMenuClick, /* 25 */ - TkMacOSXRegisterOffScreenWindow, /* 26 */ + 0, /* 26 */ TkMacOSXResizable, /* 27 */ TkMacOSXSetHelpMenuItemCount, /* 28 */ TkMacOSXSetScrollbarGrow, /* 29 */ TkMacOSXSetUpClippingRgn, /* 30 */ TkMacOSXSetUpGraphicsPort, /* 31 */ TkMacOSXUpdateClipRgn, /* 32 */ - TkMacOSXUnregisterMacWindow, /* 33 */ + 0, /* 33 */ TkMacOSXUseMenuID, /* 34 */ TkMacOSXVisableClipRgn, /* 35 */ TkMacOSXWinBounds, /* 36 */ TkMacOSXWindowOffset, /* 37 */ TkSetMacColor, /* 38 */ @@ -619,11 +623,11 @@ TkMacOSXGetHostToplevel, /* 44 */ TkMacOSXPreprocessMenu, /* 45 */ TkpIsWindowFloating, /* 46 */ TkpGetCapture, /* 47 */ 0, /* 48 */ - TkGetTransientMaster, /* 49 */ + TkMacOSXGetContainer, /* 49 */ TkGenerateButtonEvent, /* 50 */ TkGenWMDestroyEvent, /* 51 */ TkMacOSXSetDrawingEnabled, /* 52 */ TkpGetMS, /* 53 */ TkMacOSXDrawable, /* 54 */ @@ -948,11 +952,11 @@ XGetWindowAttributes, /* 101 */ XGetWMColormapWindows, /* 102 */ XIconifyWindow, /* 103 */ XWithdrawWindow, /* 104 */ XListHosts, /* 105 */ - 0, /* 106 */ + XSetClipRectangles, /* 106 */ XFlush, /* 107 */ XGrabServer, /* 108 */ XUngrabServer, /* 109 */ XFree, /* 110 */ XNoOp, /* 111 */ @@ -1016,27 +1020,27 @@ Tk_HWNDToWindow, /* 3 */ Tk_PointerEvent, /* 4 */ Tk_TranslateWinEvent, /* 5 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ - Tk_MacOSXSetEmbedHandler, /* 0 */ - Tk_MacOSXTurnOffMenus, /* 1 */ - Tk_MacOSXTkOwnsCursor, /* 2 */ - TkMacOSXInitMenus, /* 3 */ + 0, /* 0 */ + 0, /* 1 */ + 0, /* 2 */ + 0, /* 3 */ TkMacOSXInitAppleEvents, /* 4 */ - TkGenWMConfigureEvent, /* 5 */ + TkGenWMConfigureEvent_, /* 5 */ TkMacOSXInvalClipRgns, /* 6 */ - TkMacOSXGetDrawablePort, /* 7 */ + 0, /* 7 */ TkMacOSXGetRootControl, /* 8 */ Tk_MacOSXSetupTkNotifier, /* 9 */ Tk_MacOSXIsAppInFront, /* 10 */ - Tk_MacOSXSetEmbedHandler_, /* 11 */ - Tk_MacOSXTurnOffMenus_, /* 12 */ - Tk_MacOSXTkOwnsCursor_, /* 13 */ - TkMacOSXInitMenus_, /* 14 */ - TkMacOSXInitAppleEvents_, /* 15 */ - TkGenWMConfigureEvent_, /* 16 */ + Tk_MacOSXGetTkWindow, /* 11 */ + Tk_MacOSXGetCGContextForDrawable, /* 12 */ + Tk_MacOSXGetNSWindowForDrawable, /* 13 */ + 0, /* 14 */ + 0, /* 15 */ + TkGenWMConfigureEvent, /* 16 */ #endif /* AQUA */ }; static const TkStubHooks tkStubHooks = { &tkPlatStubs, @@ -1144,11 +1148,11 @@ Tk_GetFont, /* 93 */ Tk_GetFontFromObj, /* 94 */ Tk_GetFontMetrics, /* 95 */ Tk_GetGC, /* 96 */ Tk_GetImage, /* 97 */ - Tk_GetImageMasterData, /* 98 */ + Tk_GetImageModelData, /* 98 */ Tk_GetItemTypes, /* 99 */ Tk_GetJoinStyle, /* 100 */ Tk_GetJustify, /* 101 */ Tk_GetNumMainWindows, /* 102 */ Tk_GetOption, /* 103 */ @@ -1320,11 +1324,17 @@ Tk_GetUserInactiveTime, /* 269 */ Tk_ResetUserInactiveTime, /* 270 */ Tk_Interp, /* 271 */ Tk_CreateOldImageType, /* 272 */ Tk_CreateOldPhotoImageFormat, /* 273 */ - Tk_CreatePhotoImageFormatVersion3 /* 274 */ + Tk_AlwaysShowSelection, /* 274 */ + Tk_GetButtonMask, /* 275 */ + Tk_GetDoublePixelsFromObj, /* 276 */ + Tk_NewWindowObj, /* 277 */ + Tk_SendVirtualEvent, /* 278 */ + Tk_FontGetDescription, /* 279 */ + Tk_CreatePhotoImageFormatVersion3 /* 280 */ }; /* !END!: Do not edit above this line. */ Index: generic/tkStubLib.c ================================================================== --- generic/tkStubLib.c +++ generic/tkStubLib.c @@ -2,12 +2,12 @@ * tkStubLib.c -- * * Stub object that will be statically linked into extensions that want * to access Tk. * - * Copyright (c) 1998-1999 by Scriptics Corporation. - * Copyright (c) 1998 Paul Duffin. + * Copyright © 1998-1999 Scriptics Corporation. + * Copyright © 1998 Paul Duffin. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -73,19 +73,23 @@ Tk_InitStubs( Tcl_Interp *interp, const char *version, int exact) { - const char *packageName = "Tk"; + const char *packageName = "tk"; const char *errMsg = NULL; void *clientData = NULL; const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, 0, &clientData); - const TkStubs *stubsPtr = (const TkStubs *)clientData; if (actualVersion == NULL) { - return NULL; + packageName = "Tk"; + actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, + packageName, version, 0, &clientData); + if (actualVersion == NULL) { + return NULL; + } } if (exact) { const char *p = version; int count = 0; @@ -111,19 +115,19 @@ if (actualVersion == NULL) { return NULL; } } } - if (stubsPtr == NULL) { + if (clientData == NULL) { errMsg = "missing stub table pointer"; } else { - tkStubsPtr = stubsPtr; - if (stubsPtr->hooks) { - tkPlatStubsPtr = stubsPtr->hooks->tkPlatStubs; - tkIntStubsPtr = stubsPtr->hooks->tkIntStubs; - tkIntPlatStubsPtr = stubsPtr->hooks->tkIntPlatStubs; - tkIntXlibStubsPtr = stubsPtr->hooks->tkIntXlibStubs; + tkStubsPtr = (const TkStubs *)clientData; + if (tkStubsPtr->hooks) { + tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs; + tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs; + tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs; + tkIntXlibStubsPtr = tkStubsPtr->hooks->tkIntXlibStubs; } else { tkPlatStubsPtr = NULL; tkIntStubsPtr = NULL; tkIntPlatStubsPtr = NULL; tkIntXlibStubsPtr = NULL; Index: generic/tkStyle.c ================================================================== --- generic/tkStyle.c +++ generic/tkStyle.c @@ -1,12 +1,12 @@ /* * tkStyle.c -- * * This file implements the widget styles and themes support. * - * Copyright (c) 1990-1993 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1990-1993 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -176,15 +176,14 @@ *--------------------------------------------------------------------------- */ void TkStylePkgInit( - TkMainInfo *mainPtr) /* The application being created. */ + TCL_UNUSED(TkMainInfo *)) /* The application being created. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - (void)mainPtr; if (tsdPtr->nbInit != 0) { return; } @@ -232,19 +231,18 @@ *--------------------------------------------------------------------------- */ void TkStylePkgFree( - TkMainInfo *mainPtr) /* The application being deleted. */ + TCL_UNUSED(TkMainInfo *)) /* The application being deleted. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_HashSearch search; Tcl_HashEntry *entryPtr; StyleEngine *enginePtr; int i; - (void)mainPtr; tsdPtr->nbInit--; if (tsdPtr->nbInit != 0) { return; } @@ -521,14 +519,12 @@ *--------------------------------------------------------------------------- */ static void FreeElement( - Element *elementPtr) /* The element to free. */ + TCL_UNUSED(Element *)) /* The element to free. */ { - (void)elementPtr; - /* Nothing to do. */ } /* *--------------------------------------------------------------------------- @@ -1378,13 +1374,12 @@ *--------------------------------------------------------------------------- */ void Tk_FreeStyle( - Tk_Style style) + TCL_UNUSED(Tk_Style)) { - (void)style; } /* *--------------------------------------------------------------------------- * Index: generic/tkTest.c ================================================================== --- generic/tkTest.c +++ generic/tkTest.c @@ -4,13 +4,13 @@ * This file contains C command functions for a bunch of additional Tcl * commands that are used for testing out Tcl's C interfaces. These * commands are not normally included in Tcl applications; they're only * used for testing. * - * Copyright (c) 1993-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright © 1993-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -29,13 +29,13 @@ #endif #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" -#define LOG_DISPLAY TkTestLogDisplay() +#define LOG_DISPLAY(drawable) TkTestLogDisplay(drawable) #else -#define LOG_DISPLAY 1 +#define LOG_DISPLAY(drawable) 1 #endif #ifdef __UNIX__ #include "tkUnixInt.h" #endif @@ -55,40 +55,42 @@ #ifdef __cplusplus } #endif /* - * The following data structure represents the master for a test image: + * The following data structure represents the model for a test image: */ -typedef struct TImageMaster { - Tk_ImageMaster master; /* Tk's token for image master. */ +typedef struct TImageModel { + Tk_ImageModel model; /* Tk's token for image model. */ Tcl_Interp *interp; /* Interpreter for application. */ int width, height; /* Dimensions of image. */ char *imageName; /* Name of image (malloc-ed). */ char *varName; /* Name of variable in which to log events for * image (malloc-ed). */ -} TImageMaster; +} TImageModel; /* * The following data structure represents a particular use of a particular * test image. */ typedef struct TImageInstance { - TImageMaster *masterPtr; /* Pointer to master for image. */ + TImageModel *modelPtr; /* Pointer to model for image. */ XColor *fg; /* Foreground color for drawing in image. */ GC gc; /* Graphics context for drawing in image. */ + Bool displayFailed; /* macOS display attempted out of drawRect. */ + char buffer[200 + TCL_INTEGER_SPACE * 6]; /* message to log on display. */ } TImageInstance; /* * The type record for test images: */ static int ImageCreate(Tcl_Interp *interp, const char *name, int argc, Tcl_Obj *const objv[], - const Tk_ImageType *typePtr, Tk_ImageMaster master, + const Tk_ImageType *typePtr, Tk_ImageModel model, ClientData *clientDataPtr); static ClientData ImageGet(Tk_Window tkwin, ClientData clientData); static void ImageDisplay(ClientData clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, @@ -243,11 +245,11 @@ /* * Create additional commands for testing Tk. */ - if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) { + if (Tcl_PkgProvideEx(interp, "tk::test", TK_PATCH_LEVEL, NULL) == TCL_ERROR) { return TCL_ERROR; } Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testbitmap", TestbitmapObjCmd, @@ -330,17 +332,15 @@ *---------------------------------------------------------------------- */ static int TestbitmapObjCmd( - ClientData clientData, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - (void)clientData; - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "bitmap"); return TCL_ERROR; } Tcl_SetObjResult(interp, TkDebugBitmap(Tk_MainWindow(interp), @@ -365,17 +365,15 @@ *---------------------------------------------------------------------- */ static int TestborderObjCmd( - ClientData clientData, /* Main window for application. */ + TCL_UNUSED(ClientData), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - (void)clientData; - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "border"); return TCL_ERROR; } Tcl_SetObjResult(interp, TkDebugBorder(Tk_MainWindow(interp), @@ -400,17 +398,15 @@ *---------------------------------------------------------------------- */ static int TestcolorObjCmd( - ClientData clientData, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - (void)clientData; - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "color"); return TCL_ERROR; } Tcl_SetObjResult(interp, TkDebugColor(Tk_MainWindow(interp), @@ -435,17 +431,15 @@ *---------------------------------------------------------------------- */ static int TestcursorObjCmd( - ClientData clientData, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - (void)clientData; - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "cursor"); return TCL_ERROR; } Tcl_SetObjResult(interp, TkDebugCursor(Tk_MainWindow(interp), @@ -471,20 +465,16 @@ *---------------------------------------------------------------------- */ static int TestdeleteappsObjCmd( - ClientData clientData, /* Main window for application. */ - Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *const objv[]) /* Argument strings. */ + TCL_UNUSED(void *), /* Main window for application. */ + TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */ + TCL_UNUSED(int), /* Number of arguments. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Argument strings. */ { NewApp *nextPtr; - (void)clientData; - (void)interp; - (void)objc; - (void)objv; while (newAppPtr != NULL) { nextPtr = newAppPtr->nextPtr; Tcl_DeleteInterp(newAppPtr->interp); ckfree(newAppPtr); @@ -546,11 +536,11 @@ /* * Structures used by the "chain1" subcommand and also shared by the * "chain2" subcommand: */ - typedef struct ExtensionWidgetRecord { + typedef struct { TrivialCommandHeader header; Tcl_Obj *base1ObjPtr; Tcl_Obj *base2ObjPtr; Tcl_Obj *extension3ObjPtr; Tcl_Obj *extension4ObjPtr; @@ -574,11 +564,11 @@ return TCL_ERROR; } switch (index) { case ALL_TYPES: { - typedef struct TypesRecord { + typedef struct { TrivialCommandHeader header; Tcl_Obj *booleanPtr; Tcl_Obj *integerPtr; Tcl_Obj *doublePtr; Tcl_Obj *stringPtr; @@ -647,11 +637,10 @@ {TK_OPTION_SYNONYM, "-synonym", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-color", 0x8000}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; Tk_OptionTable optionTable; - Tk_Window tkwin; optionTable = Tk_CreateOptionTable(interp, typesSpecs); tables[index] = optionTable; tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); @@ -703,11 +692,10 @@ break; } case CHAIN1: { ExtensionWidgetRecord *recordPtr; - Tk_Window tkwin; Tk_OptionTable optionTable; tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); if (tkwin == NULL) { @@ -756,11 +744,10 @@ "-oneAgain", "oneAgain", "OneAgain", "one again", offsetof(ExtensionWidgetRecord, extension5ObjPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, (ClientData) baseSpecs, 0} }; - Tk_Window tkwin; Tk_OptionTable optionTable; tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); if (tkwin == NULL) { @@ -795,11 +782,11 @@ } break; } case CONFIG_ERROR: { - typedef struct ErrorWidgetRecord { + typedef struct { Tcl_Obj *intPtr; } ErrorWidgetRecord; ErrorWidgetRecord widgetRecord; static const Tk_OptionSpec errorSpecs[] = { {TK_OPTION_INT, "-int", "integer", "Integer", "bogus", @@ -849,11 +836,11 @@ * This command is similar to the "alltypes" command except that it * stores all the configuration options as internal forms instead of * objects. */ - typedef struct InternalRecord { + typedef struct { TrivialCommandHeader header; int boolean; int integer; double doubleValue; char *string; @@ -925,11 +912,10 @@ {TK_OPTION_SYNONYM, "-synonym", NULL, NULL, NULL, TCL_INDEX_NONE, TCL_INDEX_NONE, 0, "-color", 0x8000}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; Tk_OptionTable optionTable; - Tk_Window tkwin; optionTable = Tk_CreateOptionTable(interp, internalSpecs); tables[index] = optionTable; tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); @@ -981,11 +967,11 @@ } break; } case NEW: { - typedef struct FiveRecord { + typedef struct { TrivialCommandHeader header; Tcl_Obj *one; Tcl_Obj *two; Tcl_Obj *three; Tcl_Obj *four; @@ -1040,11 +1026,11 @@ } break; } case NOT_ENOUGH_PARAMS: { - typedef struct NotEnoughRecord { + typedef struct { Tcl_Obj *fooObjPtr; } NotEnoughRecord; NotEnoughRecord record; static const Tk_OptionSpec errorSpecs[] = { {TK_OPTION_INT, "-foo", "foo", "Foo", "0", @@ -1070,32 +1056,32 @@ Tk_DestroyWindow(tkwin); return result; } case TWO_WINDOWS: { - typedef struct SlaveRecord { + typedef struct { TrivialCommandHeader header; Tcl_Obj *windowPtr; - } SlaveRecord; - SlaveRecord *recordPtr; - static const Tk_OptionSpec slaveSpecs[] = { + } ContentRecord; + ContentRecord *recordPtr; + static const Tk_OptionSpec contentSpecs[] = { {TK_OPTION_WINDOW, "-window", "window", "Window", ".bar", - offsetof(SlaveRecord, windowPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL, 0}, + offsetof(ContentRecord, windowPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; - Tk_Window tkwin = Tk_CreateWindowFromPath(interp, + tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); if (tkwin == NULL) { return TCL_ERROR; } Tk_SetClass(tkwin, "Test"); - recordPtr = (SlaveRecord *)ckalloc(sizeof(SlaveRecord)); + recordPtr = (ContentRecord *)ckalloc(sizeof(ContentRecord)); recordPtr->header.interp = interp; recordPtr->header.optionTable = Tk_CreateOptionTable(interp, - slaveSpecs); + contentSpecs); tables[index] = recordPtr->header.optionTable; recordPtr->header.tkwin = tkwin; recordPtr->windowPtr = NULL; result = Tk_InitOptions(interp, recordPtr, @@ -1162,11 +1148,11 @@ TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData; Tk_Window tkwin = headerPtr->tkwin; Tk_SavedOptions saved; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[1], options, sizeof(char *), "command", 0, &index) != TCL_OK) { @@ -1390,20 +1376,19 @@ * image. */ const char *name, /* Name to use for image. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[], /* Argument strings for options (doesn't * include image name or type). */ - const Tk_ImageType *typePtr, /* Pointer to our type record (not used). */ - Tk_ImageMaster master, /* Token for image, to be used by us in later + TCL_UNUSED(const Tk_ImageType *), /* Pointer to our type record (not used). */ + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ ClientData *clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { - TImageMaster *timPtr; + TImageModel *timPtr; const char *varName; int i; - (void)typePtr; varName = "log"; for (i = 0; i < objc; i += 2) { if (strcmp(Tcl_GetString(objv[i]), "-variable") != 0) { Tcl_AppendResult(interp, "bad option name \"", @@ -1416,22 +1401,22 @@ return TCL_ERROR; } varName = Tcl_GetString(objv[i+1]); } - timPtr = (TImageMaster *)ckalloc(sizeof(TImageMaster)); - timPtr->master = master; + timPtr = (TImageModel *)ckalloc(sizeof(TImageModel)); + timPtr->model = model; timPtr->interp = interp; timPtr->width = 30; timPtr->height = 15; timPtr->imageName = (char *)ckalloc(strlen(name) + 1); strcpy(timPtr->imageName, name); timPtr->varName = (char *)ckalloc(strlen(varName) + 1); strcpy(timPtr->varName, varName); Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL); *clientDataPtr = timPtr; - Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15); + Tk_ImageChanged(model, 0, 0, 30, 15, 30, 15); return TCL_OK; } /* *---------------------------------------------------------------------- @@ -1455,11 +1440,11 @@ ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; int x, y, width, height; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; @@ -1476,11 +1461,11 @@ || (Tcl_GetIntFromObj(interp, objv[5], &height) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &timPtr->width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) { return TCL_ERROR; } - Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width, + Tk_ImageChanged(timPtr->model, x, y, width, height, timPtr->width, timPtr->height); } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be changed", NULL); return TCL_ERROR; @@ -1508,26 +1493,27 @@ static ClientData ImageGet( Tk_Window tkwin, /* Token for window in which image will be * used. */ - ClientData clientData) /* Pointer to TImageMaster for image. */ + ClientData clientData) /* Pointer to TImageModel for image. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; TImageInstance *instPtr; char buffer[100]; XGCValues gcValues; sprintf(buffer, "%s get", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance)); - instPtr->masterPtr = timPtr; + instPtr->modelPtr = timPtr; instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues); + instPtr->displayFailed = False; return instPtr; } /* *---------------------------------------------------------------------- @@ -1558,51 +1544,60 @@ int drawableX, int drawableY) /* Coordinates in drawable corresponding to * imageX and imageY. */ { TImageInstance *instPtr = (TImageInstance *)clientData; - char buffer[200 + TCL_INTEGER_SPACE * 6]; /* * The purpose of the test image type is to track the calls to an image - * display proc and record the parameters passed in each call. On macOS - * a display proc must be run inside of the drawRect method of an NSView - * in order for the graphics operations to have any effect. To deal with - * this, whenever a display proc is called outside of any drawRect method - * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES]. - * This will trigger a later call to the view's drawRect method which will - * run the display proc a second time. - * - * This complicates testing, since it can result in more calls to the display - * proc than are expected by the test. It can also result in an inconsistent - * number of calls unless the test waits until the call to drawRect actually - * occurs before validating its results. - * - * In an attempt to work around this, this display proc only logs those - * calls which occur within a drawRect method. This means that tests must - * be written so as to ensure that the drawRect method is run before - * results are validated. In practice it usually suffices to run update - * idletasks (to run the display proc the first time) followed by update - * (to run the display proc in drawRect). - * - * This also has the consequence that the image changed command will log - * different results on Aqua than on other systems, because when the image - * is redisplayed in the drawRect method the entire image will be drawn, - * not just the changed portion. Tests must account for this. + * display proc and record the parameters passed in each call. On macOS a + * display proc must be run inside of the drawRect method of an NSView in + * order for the graphics operations to have any effect. To deal with + * this, whenever a display proc is called outside of any drawRect method + * it schedules a redraw of the NSView. + * + * In an attempt to work around this, each image instance maintains it own + * copy of the log message which gets written on the first call to the + * display proc. This usually means that the message created on macOS is + * the same as that created on other platforms. However it is possible + * for the messages to differ for other reasons, namely differences in + * how damage regions are computed. */ - if (LOG_DISPLAY) { - sprintf(buffer, "%s display %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, - NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - } - if (width > (instPtr->masterPtr->width - imageX)) { - width = instPtr->masterPtr->width - imageX; - } - if (height > (instPtr->masterPtr->height - imageY)) { - height = instPtr->masterPtr->height - imageY; + if (LOG_DISPLAY(drawable)) { + if (instPtr->displayFailed == False) { + + /* + * Drawing is possible on the first call to DisplayImage. + * Log the message. + */ + + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->modelPtr->imageName, imageX, imageY, width, height); + } + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, + NULL, instPtr->buffer, + TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + instPtr->displayFailed = False; + } else { + + /* + * Drawing is not possible on the first call to DisplayImage. + * Save the message, but do not log it until the actual display. + */ + + if (instPtr->displayFailed == False) { + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->modelPtr->imageName, imageX, imageY, width, height); + } + instPtr->displayFailed = True; + } + if (width > (instPtr->modelPtr->width - imageX)) { + width = instPtr->modelPtr->width - imageX; + } + if (height > (instPtr->modelPtr->height - imageY)) { + height = instPtr->modelPtr->height - imageY; } XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY, (unsigned) (width-1), (unsigned) (height-1)); XDrawLine(display, drawable, instPtr->gc, drawableX, drawableY, @@ -1635,12 +1630,12 @@ Display *display) /* Display where image was to be drawn. */ { TImageInstance *instPtr = (TImageInstance *)clientData; char buffer[200]; - sprintf(buffer, "%s free", instPtr->masterPtr->imageName); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + sprintf(buffer, "%s free", instPtr->modelPtr->imageName); + Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); Tk_FreeGC(display, instPtr->gc); ckfree(instPtr); } @@ -1662,15 +1657,15 @@ *---------------------------------------------------------------------- */ static void ImageDelete( - ClientData clientData) /* Pointer to TImageMaster for image. When + ClientData clientData) /* Pointer to TImageModel for image. When * this function is called, no more instances * exist. */ { - TImageMaster *timPtr = (TImageMaster *)clientData; + TImageModel *timPtr = (TImageModel *)clientData; char buffer[100]; sprintf(buffer, "%s delete", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); @@ -1806,18 +1801,17 @@ */ #if defined(_WIN32) static int TestmetricsObjCmd( - ClientData dummy, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { char buf[TCL_INTEGER_SPACE]; int val; - (void)dummy; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } @@ -1937,15 +1931,11 @@ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { char buffer[256]; Tcl_WideInt wideInt; -#ifdef _WIN32 - __int64 longLongInt; -#else long long longLongInt; -#endif (void)dummy; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "wideint"); return TCL_ERROR; @@ -1960,11 +1950,11 @@ * which still woudn't tell if the assumed size is correct: We want this * test-case to fail if the 64-bit value is printed as truncated to 32-bit. */ sprintf(buffer, "%s%s%s%s%s%s%s%s%" TCL_LL_MODIFIER "d %" TCL_LL_MODIFIER "u", "", "", "", "", "", "", "", "", - (Tcl_WideInt)longLongInt, (Tcl_WideUInt)longLongInt); + longLongInt, (unsigned long long)longLongInt); Tcl_AppendResult(interp, buffer, NULL); return TCL_OK; } #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) @@ -2043,23 +2033,21 @@ *---------------------------------------------------------------------- */ static int CustomOptionSet( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, - Tk_Window tkwin, + TCL_UNUSED(Tk_Window), Tcl_Obj **value, char *recordPtr, TkSizeT internalOffset, char *saveInternalPtr, int flags) { int objEmpty; char *newStr, *string, *internalPtr; - (void)dummy; - (void)tkwin; objEmpty = 0; if (internalOffset != TCL_INDEX_NONE) { internalPtr = recordPtr + internalOffset; @@ -2106,18 +2094,15 @@ return TCL_OK; } static Tcl_Obj * CustomOptionGet( - ClientData dummy, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *recordPtr, TkSizeT internalOffset) { - (void)dummy; - (void)tkwin; - return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), -1)); } static void CustomOptionRestore( Index: generic/tkText.c ================================================================== --- generic/tkText.c +++ generic/tkText.c @@ -4,13 +4,13 @@ * This module provides a big chunk of the implementation of multi-line * editable text widgets for Tk. Among other things, it provides the Tcl * command interfaces to text widgets. The B-tree representation of text * and its actual display are implemented elsewhere. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * Copyright (c) 1999 by Scriptics Corporation. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1996 Sun Microsystems, Inc. + * Copyright © 1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -296,14 +296,14 @@ * the from,to range. Otherwise the limits * only apply to the start of each match. */ int all; /* Whether all or the first match should be * reported. */ int startLine; /* First line to examine. */ - TkSizeT startOffset1; /* Index in first line to start at. */ + TkSizeT startOffset; /* Index in first line to start at. */ int stopLine; /* Last line to examine, or -1 when we search * all available text. */ - TkSizeT stopOffset1; /* Index to stop at, provided stopLine is not + TkSizeT stopOffset; /* Index to stop at, provided stopLine is not * -1. */ int numLines; /* Total lines which are available. */ int backwards; /* Searching forwards or backwards. */ Tcl_Obj *varPtr; /* If non-NULL, store length(s) of match(es) * in this variable. */ @@ -668,11 +668,11 @@ if (ConfigureText(interp, textPtr, objc-2, objv+2) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(textPtr->tkwin)); + Tcl_SetObjResult(interp, Tk_NewWindowObj(textPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- @@ -699,11 +699,11 @@ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkText *textPtr = (TkText *)clientData; int result = TCL_OK; - int index; + int idx; static const char *const optionStrings[] = { "bbox", "cget", "compare", "configure", "count", "debug", "delete", "dlineinfo", "dump", "edit", "get", "image", "index", "insert", "mark", "peer", "pendingsync", "replace", "scan", "search", @@ -722,16 +722,16 @@ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, - sizeof(char *), "option", 0, &index) != TCL_OK) { + sizeof(char *), "option", 0, &idx) != TCL_OK) { return TCL_ERROR; } textPtr->refCount++; - switch ((enum options) index) { + switch ((enum options) idx) { case TEXT_BBOX: { int x, y, width, height; const TkTextIndex *indexPtr; if (objc != 3) { @@ -863,11 +863,11 @@ } for (i = 2; i < objc-2; i++) { int value; TkSizeT length; - const char *option = TkGetStringFromObj(objv[i], &length); + const char *option = Tcl_GetStringFromObj(objv[i], &length); char c; if (length < 2 || option[0] != '-') { goto badOption; } @@ -1049,11 +1049,11 @@ } break; badOption: Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad option \"%s\" must be -chars, -displaychars, " + "bad option \"%s\": must be -chars, -displaychars, " "-displayindices, -displaylines, -indices, -lines, -update, " "-xpixels, or -ypixels", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_OPTION", NULL); result = TCL_ERROR; goto done; @@ -1159,11 +1159,11 @@ /* * Do a decreasing order sort so that we delete the end ranges * first to maintain index consistency. */ - qsort(indices, objc / 2, + qsort(indices, (size_t) objc / 2, 2 * sizeof(TkTextIndex), TextIndexSortProc); lastStart = NULL; /* * Second pass will handle bogus ranges (end < start) and @@ -1273,16 +1273,16 @@ * -displaychars (or any unique prefix). */ i = 2; if (objc > 3) { - name = TkGetStringFromObj(objv[i], &length); + name = Tcl_GetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { if (strncmp("-displaychars", name, length) == 0) { i++; visible = 1; - name = TkGetStringFromObj(objv[i], &length); + name = Tcl_GetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; } } @@ -1751,11 +1751,11 @@ } peersObj = Tcl_NewObj(); while (tPtr != NULL) { if (tPtr != textPtr) { Tcl_ListObjAppendElement(NULL, peersObj, - TkNewWindowObj(tPtr->tkwin)); + Tk_NewWindowObj(tPtr->tkwin)); } tPtr = tPtr->next; } Tcl_SetObjResult(interp, peersObj); } @@ -2634,11 +2634,11 @@ TkSizeT length; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; - const char *string = TkGetStringFromObj(stringPtr, &length); + const char *string = Tcl_GetStringFromObj(stringPtr, &length); if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } @@ -3171,11 +3171,11 @@ line1 = TkBTreeLinesTo(textPtr, index1.linePtr); line2 = TkBTreeLinesTo(textPtr, index2.linePtr); if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) { TkTextTag **arrayPtr; - int arraySize, i; + int arraySize; TkTextIndex oldIndex2; oldIndex2 = index2; TkTextIndexBackChars(NULL, &oldIndex2, 1, &index2, COUNT_INDICES); line2--; @@ -3555,11 +3555,11 @@ TkTextLostSelection( ClientData clientData) /* Information about text widget. */ { TkText *textPtr = (TkText *)clientData; - if (TkpAlwaysShowSelection(textPtr->tkwin)) { + if (Tk_AlwaysShowSelection(textPtr->tkwin)) { TkTextIndex start, end; if ((!textPtr->exportSelection) || Tcl_IsSafe(textPtr->interp)) { return; } @@ -3613,11 +3613,11 @@ /* * Send an event that the selection changed. This is equivalent to: * event generate $textWidget <> */ - TkSendVirtualEvent(textPtr->tkwin, "Selection", NULL); + Tk_SendVirtualEvent(textPtr->tkwin, "Selection", NULL); } /* *---------------------------------------------------------------------- * @@ -4286,11 +4286,11 @@ * the item we just found is actually outside the acceptable range, * and the search is over. */ if (searchSpecPtr->backwards ^ - (matchOffset + 1 >= searchSpecPtr->stopOffset1 + 1)) { + (matchOffset + 1 >= searchSpecPtr->stopOffset + 1)) { return 0; } } /* @@ -4311,11 +4311,11 @@ * full length fits inside the given range. */ if (searchSpecPtr->strictLimits && lineNum == searchSpecPtr->stopLine) { if (searchSpecPtr->backwards ^ - ((matchOffset + numChars + 1) > searchSpecPtr->stopOffset1 + 1)) { + ((matchOffset + numChars + 1) > searchSpecPtr->stopOffset + 1)) { return 0; } } /* @@ -4537,12 +4537,12 @@ /* * Parse the elements of the list one at a time to fill in the array. */ - tabArrayPtr = (TkTextTabArray *)ckalloc(sizeof(TkTextTabArray) - + (count - 1) * sizeof(TkTextTab)); + tabArrayPtr = (TkTextTabArray *)ckalloc(offsetof(TkTextTabArray, tabs) + + count * sizeof(TkTextTab)); tabArrayPtr->numTabs = 0; prevStop = 0.0; lastStop = 0.0; for (i = 0, tabPtr = &tabArrayPtr->tabs[0]; i < objc; i++, tabPtr++) { int index; @@ -4757,11 +4757,11 @@ const char *str; if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } - str = TkGetStringFromObj(objv[arg], &length); + str = Tcl_GetStringFromObj(objv[arg], &length); if (strncmp(str, "end", length) == 0) { atEnd = 1; } } if (TkTextIndexCmp(&index1, &index2) >= 0) { @@ -5058,15 +5058,14 @@ Tcl_Interp *interp, const char *key, /* Segment type key. */ const char *value, /* Segment value. */ Tcl_Obj *command, /* Script callback. */ const TkTextIndex *index, /* index with line/byte position info. */ - int what) /* Look for TK_DUMP_INDEX bit. */ + TCL_UNUSED(int)) /* Look for TK_DUMP_INDEX bit. */ { char buffer[TK_POS_CHARS]; Tcl_Obj *values[3], *tuple; - (void)what; TkTextPrintIndex(textPtr, index, buffer); values[0] = Tcl_NewStringObj(key, -1); values[1] = Tcl_NewStringObj(value, -1); values[2] = Tcl_NewStringObj(buffer, -1); @@ -5488,11 +5487,11 @@ TkText *textPtr) /* Information about text widget. */ { for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; textPtr = textPtr->next) { Tk_MakeWindowExist(textPtr->tkwin); - TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); + Tk_SendVirtualEvent(textPtr->tkwin, "Modified", NULL); } } /* *---------------------------------------------------------------------- @@ -5518,11 +5517,11 @@ TkText *textPtr) /* Information about text widget. */ { for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; textPtr = textPtr->next) { Tk_MakeWindowExist(textPtr->tkwin); - TkSendVirtualEvent(textPtr->tkwin, "UndoStack", NULL); + Tk_SendVirtualEvent(textPtr->tkwin, "UndoStack", NULL); } } /* *---------------------------------------------------------------------- @@ -5662,11 +5661,11 @@ * for regexp search, utf-8 bytes for exact search). */ if (searchSpecPtr->lineIndexProc(interp, fromPtr, searchSpecPtr, &searchSpecPtr->startLine, - &searchSpecPtr->startOffset1) != TCL_OK) { + &searchSpecPtr->startOffset) != TCL_OK) { return TCL_ERROR; } /* * Find the optional end location, similarly. @@ -5693,11 +5692,11 @@ return TCL_OK; } if (searchSpecPtr->lineIndexProc(interp, toPtr, searchSpecPtr, &searchSpecPtr->stopLine, - &searchSpecPtr->stopOffset1) != TCL_OK) { + &searchSpecPtr->stopOffset) != TCL_OK) { return TCL_ERROR; } } else { searchSpecPtr->stopLine = -1; } @@ -5827,11 +5826,11 @@ * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so * it has dual purpose. */ - pattern = TkGetStringFromObj(patObj, &matchLength); + pattern = Tcl_GetStringFromObj(patObj, &matchLength); nl = strchr(pattern, '\n'); /* * If there is no newline, or it is the very end of the string, then * we don't need any special treatment, since single-line matching @@ -5892,11 +5891,11 @@ goto nextLine; } if (lineNum == searchSpecPtr->stopLine && searchSpecPtr->backwards) { - firstOffset = searchSpecPtr->stopOffset1; + firstOffset = searchSpecPtr->stopOffset; } else { firstOffset = 0; } if (alreadySearchOffset >= 0) { @@ -5926,12 +5925,12 @@ * second pass. * * Only use the last part of the line. */ - if (searchSpecPtr->startOffset1 + 1 > (TkSizeT)firstOffset + 1) { - firstOffset = searchSpecPtr->startOffset1; + if (searchSpecPtr->startOffset + 1 > (TkSizeT)firstOffset + 1) { + firstOffset = searchSpecPtr->startOffset; } if ((firstOffset >= lastOffset) && ((lastOffset != 0) || searchSpecPtr->exact)) { goto nextLine; } @@ -5938,12 +5937,12 @@ } else { /* * Use only the first part of the line. */ - if (searchSpecPtr->startOffset1 + 1 < (TkSizeT)lastOffset + 1) { - lastOffset = searchSpecPtr->startOffset1; + if (searchSpecPtr->startOffset + 1 < (TkSizeT)lastOffset + 1) { + lastOffset = searchSpecPtr->startOffset; } } } /* @@ -6775,19 +6774,17 @@ *---------------------------------------------------------------------- */ static Tcl_Obj * GetLineStartEnd( - ClientData dummy, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *recordPtr, /* Pointer to widget record. */ TkSizeT internalOffset) /* Offset within *recordPtr containing the * line value. */ { TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset); - (void)dummy; - (void)tkwin; if (linePtr == NULL) { return Tcl_NewObj(); } return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr)); @@ -6812,13 +6809,13 @@ *---------------------------------------------------------------------- */ static int SetLineStartEnd( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interp; may be used for errors. */ - Tk_Window tkwin, /* Window for which option is being set. */ + TCL_UNUSED(Tk_Window), /* Window for which option is being set. */ Tcl_Obj **value, /* Pointer to the pointer to the value object. * We use a pointer to the pointer because we * may need to return a value (NULL). */ char *recordPtr, /* Pointer to storage for the widget record. */ TkSizeT internalOffset, /* Offset within *recordPtr at which the @@ -6827,12 +6824,10 @@ int flags) /* Flags for the option, set Tk_SetOptions. */ { TkTextLine *linePtr = NULL; char *internalPtr; TkText *textPtr = (TkText *) recordPtr; - (void)dummy; - (void)tkwin; if (internalOffset != TCL_INDEX_NONE) { internalPtr = (char *)recordPtr + internalOffset; } else { internalPtr = NULL; @@ -6873,18 +6868,15 @@ *---------------------------------------------------------------------- */ static void RestoreLineStartEnd( - ClientData dummy, - Tk_Window tkwin, + TCL_UNUSED(void *), + TCL_UNUSED(Tk_Window), char *internalPtr, /* Pointer to storage for value. */ char *oldInternalPtr) /* Pointer to old value. */ { - (void)dummy; - (void)tkwin; - *(TkTextLine **)internalPtr = *(TkTextLine **)oldInternalPtr; } /* *---------------------------------------------------------------------- @@ -6935,11 +6927,11 @@ *---------------------------------------------------------------------- */ int TkpTesttextCmd( - ClientData dummy, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { TkText *textPtr; @@ -6946,11 +6938,10 @@ size_t len; int lineIndex, byteIndex, byteOffset; TkTextIndex index; char buf[64]; Tcl_CmdInfo info; - (void)dummy; if (objc < 3) { return TCL_ERROR; } Index: generic/tkText.h ================================================================== --- generic/tkText.h +++ generic/tkText.h @@ -166,11 +166,11 @@ /* Next in list of segments for this line, or * NULL for end of list. */ TkSizeT size; /* Size of this segment (# of bytes of index * space it occupies). */ union { - char chars[2]; /* Characters that make up character info. + char chars[TKFLEXARRAY]; /* Characters that make up character info. * Actual length varies to hold as many * characters as needed.*/ TkTextToggle toggle; /* Information about tag toggle. */ TkTextMark mark; /* Information about mark. */ TkTextEmbWindow ew; /* Information about embedded window. */ @@ -487,11 +487,11 @@ double lastTab; /* The accurate fractional pixel position of * the last tab. */ double tabIncrement; /* The accurate fractional pixel increment * between interpolated tabs we have to create * when we exceed numTabs. */ - TkTextTab tabs[1]; /* Array of tabs. The actual size will be + TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be * numTabs. THIS FIELD MUST BE THE LAST IN THE * STRUCTURE. */ } TkTextTabArray; /* Index: generic/tkTextBTree.c ================================================================== --- generic/tkTextBTree.c +++ generic/tkTextBTree.c @@ -3,12 +3,12 @@ * * This file contains code that manages the B-tree representation of text * for Tk's text widget and implements character and toggle segment * types. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -4167,11 +4167,11 @@ while (nodePtr->numChildren < MIN_CHILDREN) { Node *otherPtr; Node *halfwayNodePtr = NULL; /* Initialization needed only */ TkTextLine *halfwayLinePtr = NULL; /* to prevent cc warnings. */ - int totalChildren, firstChildren, i; + int totalChildren, firstChildren; /* * Too few children for this node. If this is the root then, it's * OK for it to have less than MIN_CHILDREN children as long as * it's got at least two. If it has only one (and isn't at level @@ -4228,12 +4228,10 @@ nodePtr->children = otherPtr->children; otherPtr->children.nodePtr = NULL; otherPtr->children.linePtr = NULL; } if (nodePtr->level == 0) { - TkTextLine *linePtr; - for (linePtr = nodePtr->children.linePtr, i = 1; linePtr->nextPtr != NULL; linePtr = linePtr->nextPtr, i++) { if (i == firstChildren) { halfwayLinePtr = linePtr; @@ -4244,12 +4242,10 @@ halfwayLinePtr = linePtr; linePtr = linePtr->nextPtr; i++; } } else { - Node *childPtr; - for (childPtr = nodePtr->children.nodePtr, i = 1; childPtr->nextPtr != NULL; childPtr = childPtr->nextPtr, i++) { if (i <= firstChildren) { if (i == firstChildren) { @@ -4590,14 +4586,13 @@ static TkTextSegment * CharCleanupProc( TkTextSegment *segPtr, /* Pointer to first of two adjacent segments * to join. */ - TkTextLine *linePtr) /* Line containing segments (not used). */ + TCL_UNUSED(TkTextLine *)) /* Line containing segments (not used). */ { TkTextSegment *segPtr2, *newPtr; - (void)linePtr; segPtr2 = segPtr->nextPtr; if ((segPtr2 == NULL) || (segPtr2->typePtr != &tkTextCharType)) { return segPtr; } @@ -4630,18 +4625,15 @@ */ static int CharDeleteProc( TkTextSegment *segPtr, /* Segment to delete. */ - TkTextLine *linePtr, /* Line containing segment. */ - int treeGone) /* Non-zero means the entire tree is being + TCL_UNUSED(TkTextLine *), /* Line containing segment. */ + TCL_UNUSED(int)) /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ { - (void)linePtr; - (void)treeGone; - ckfree(segPtr); return 0; } /* @@ -4662,14 +4654,12 @@ */ static void CharCheckProc( TkTextSegment *segPtr, /* Segment to check. */ - TkTextLine *linePtr) /* Line containing segment. */ + TCL_UNUSED(TkTextLine *)) /* Line containing segment. */ { - (void)linePtr; - /* * Make sure that the segment contains the number of characters indicated * by its header, and that the last segment in a line ends in a newline. * Also make sure that there aren't ever two character segments adjacent * to each other: they should be merged together. Index: generic/tkTextDisp.c ================================================================== --- generic/tkTextDisp.c +++ generic/tkTextDisp.c @@ -4,12 +4,12 @@ * This module provides facilities to display text widgets. It is the * only place where information is kept about the screen layout of text * widgets. (Well, strictly, each TkTextLine and B-tree node caches its * last observed pixel height, but that information originates here). * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -438,16 +438,16 @@ /* * In TkTextDispChunk structures for character segments, the clientData field * points to one of the following structures: */ -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS) typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ - char chars[1]; /* UTF characters to display. Actual size will - * be numBytes, not 1. THIS MUST BE THE LAST + char chars[TKFLEXARRAY]; /* UTF characters to display. + * Allocated as large as necessary. THIS MUST BE THE LAST * FIELD IN THE STRUCTURE. */ } CharInfo; #else /* TK_LAYOUT_WITH_BASE_CHUNKS */ @@ -550,11 +550,11 @@ int height, int baseline, Display *display, Drawable dst, int screenY); static int CharMeasureProc(TkTextDispChunk *chunkPtr, int x); static void CharUndisplayProc(TkText *textPtr, TkTextDispChunk *chunkPtr); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS static void FinalizeBaseChunk(TkTextDispChunk *additionalChunkPtr); static void FreeBaseChunk(TkTextDispChunk *baseChunkPtr); static int IsSameFGStyle(TextStyle *style1, TextStyle *style2); static void RemoveFromBaseChunk(TkTextDispChunk *chunkPtr); #endif @@ -1365,11 +1365,11 @@ /* * Every logical line still gets at least one chunk due to * expectations in the rest of the code, but we are able to skip * elided portions of the line quickly. * - * If current chunk is elided and last chunk was too, coalese. + * If current chunk is elided and last chunk was too, coalesce. * * This also means that each logical line which is entirely elided * still gets laid out into a DLine, but with zero height. This isn't * particularly a problem, but it does seem somewhat unnecessary. We * may wish to redesign the code to remove these zero height DLines in @@ -1506,11 +1506,11 @@ break; } } } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr != NULL) { int expectedX = ((BaseCharInfo *) baseCharChunkPtr->clientData)->width + baseCharChunkPtr->x; @@ -1648,11 +1648,11 @@ } } chunkPtr = NULL; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS FinalizeBaseChunk(NULL); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ if (noCharsYet) { dlPtr->spaceAbove = 0; dlPtr->spaceBelow = 0; @@ -1707,11 +1707,11 @@ } segPtr = TkTextIndexToSeg(&breakIndex, &byteOffset); segPtr->typePtr->layoutProc(textPtr, &breakIndex, segPtr, byteOffset, maxX, breakByteOffset, 0, wrapMode, breakChunkPtr); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS FinalizeBaseChunk(NULL); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ } lastChunkPtr = breakChunkPtr; wholeLine = 0; @@ -3162,12 +3162,12 @@ if (NewSyncState) { textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; } else { textPtr->dInfoPtr->flags |= OUT_OF_SYNC; } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(NewSyncState)); + Tk_SendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(NewSyncState)); } } /* *---------------------------------------------------------------------- @@ -5274,11 +5274,11 @@ TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); } /* * Invalidate cached scrollbar positions, so that scrollbars sliders will - * be udpated. + * be updated. */ dInfoPtr->xScrollFirst = dInfoPtr->xScrollLast = -1; dInfoPtr->yScrollFirst = dInfoPtr->yScrollLast = -1; @@ -6180,11 +6180,11 @@ */ pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { const char *switchStr = - TkGetStringFromObj(objv[2], &switchLength); + Tcl_GetStringFromObj(objv[2], &switchLength); if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace", (unsigned) switchLength) == 0)) { pickPlace = 1; if (objc != 4) { @@ -7540,31 +7540,27 @@ * Get bounding-box information about an elided chunk. */ static void ElideBboxProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ - int index, /* Index of desired character within the + TCL_UNUSED(int), /* Index of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ - int lineHeight, /* Height of line, in pixels. */ - int baseline, /* Location of line's baseline, in pixels + TCL_UNUSED(int), /* Height of line, in pixels. */ + TCL_UNUSED(int), /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's * upper-left pixel. X-coord is in same * coordinate system as chunkPtr->x. */ int *widthPtr, /* Gets filled in with width of character, in * pixels. */ int *heightPtr) /* Gets filled in with height of character, in * pixels. */ { - (void)textPtr; - (void)index; - (void)lineHeight; - (void)baseline; *xPtr = chunkPtr->x; *yPtr = y; *widthPtr = *heightPtr = 0; } @@ -7573,17 +7569,14 @@ * Measure an elided chunk. */ static int ElideMeasureProc( - TkTextDispChunk *chunkPtr, /* Chunk containing desired coord. */ - int x) /* X-coordinate, in same coordinate system as + TCL_UNUSED(TkTextDispChunk *), /* Chunk containing desired coord. */ + TCL_UNUSED(int)) /* X-coordinate, in same coordinate system as * chunkPtr->x. */ { - (void)chunkPtr; - (void)x; - return 0 /*chunkPtr->numBytes - 1*/; } /* *-------------------------------------------------------------- @@ -7606,12 +7599,12 @@ *-------------------------------------------------------------- */ int TkTextCharLayoutProc( - TkText *textPtr, /* Text widget being layed out. */ - TkTextIndex *indexPtr, /* Index of first character to lay out + TCL_UNUSED(TkText *), /* Text widget being layed out. */ + TCL_UNUSED(TkTextIndex *), /* Index of first character to lay out * (corresponds to segPtr and offset). */ TkTextSegment *segPtr, /* Segment being layed out. */ TkSizeT byteOffset, /* Byte offset within segment of first * character to consider. */ int maxX, /* Chunk must not occupy pixels at this @@ -7633,18 +7626,16 @@ TkSizeT bytesThatFit; CharInfo *ciPtr; char *p; TkTextSegment *nextPtr; Tk_FontMetrics fm; -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS const char *line; int lineOffset; BaseCharInfo *bciPtr; Tcl_DString *baseString; #endif - (void)textPtr; - (void)indexPtr; /* * Figure out how many characters will fit in the space we've got. Include * the next character, even though it won't fit completely, if any of the * following is true: @@ -7660,11 +7651,11 @@ */ p = segPtr->body.chars + byteOffset; tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr == NULL) { baseCharChunkPtr = chunkPtr; bciPtr = ckalloc(sizeof(BaseCharInfo)); baseString = &bciPtr->baseChars; Tcl_DStringInit(baseString); @@ -7697,11 +7688,11 @@ if (bytesThatFit + 1 <= maxBytes) { if ((bytesThatFit == 0) && noCharsYet) { int ch; int chLen = TkUtfToUniChar(p, &ch); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS bytesThatFit = CharChunkMeasureChars(chunkPtr, line, lineOffset+chLen, lineOffset, -1, chunkPtr->x, -1, 0, &nextX); #else /* !TK_LAYOUT_WITH_BASE_CHUNKS */ bytesThatFit = CharChunkMeasureChars(chunkPtr, p, chLen, 0, -1, @@ -7741,11 +7732,11 @@ */ bytesThatFit++; } if (bytesThatFit == 0) { -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS chunkPtr->clientData = NULL; if (chunkPtr == baseCharChunkPtr) { baseCharChunkPtr = NULL; Tcl_DStringFree(baseString); } else { @@ -7774,11 +7765,11 @@ chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minHeight = 0; chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS) ciPtr = (CharInfo *)ckalloc(offsetof(CharInfo, chars) + 1 + bytesThatFit); chunkPtr->clientData = ciPtr; memcpy(ciPtr->chars, p, bytesThatFit); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ @@ -7785,11 +7776,11 @@ ciPtr->numBytes = bytesThatFit; if (p[bytesThatFit - 1] == '\n') { ciPtr->numBytes--; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS /* * Final update for the current base chunk data. */ Tcl_DStringSetLength(baseString,lineOffset+ciPtr->numBytes); @@ -7890,11 +7881,11 @@ * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS) if (chars == NULL) { chars = ciPtr->chars; charsLen = ciPtr->numBytes; } if (end == -1) { @@ -7963,50 +7954,47 @@ *-------------------------------------------------------------- */ static void CharDisplayProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (may differ from the x-position in * the chunk because of scrolling). */ int y, /* Y-position at which to draw this chunk in * dst. */ - int height, /* Total height of line. */ + TCL_UNUSED(int), /* Total height of line. */ int baseline, /* Offset of baseline from y. */ Display *display, /* Display to use for drawing. */ Drawable dst, /* Pixmap or window in which to draw chunk. */ - int screenY) /* Y-coordinate in text window that + TCL_UNUSED(int)) /* Y-coordinate in text window that * corresponds to y. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; const char *string; TextStyle *stylePtr; StyleValues *sValuePtr; int numBytes, offsetBytes, offsetX; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT BaseCharInfo *bciPtr; #endif /* TK_DRAW_IN_CONTEXT */ - (void)textPtr; - (void)height; - (void)screenY; if ((x + chunkPtr->width) <= 0) { /* * The chunk is off-screen. */ return; } -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT bciPtr = ciPtr->baseChunkPtr->clientData; numBytes = Tcl_DStringLength(&bciPtr->baseChars); string = Tcl_DStringValue(&bciPtr->baseChars); -#elif TK_LAYOUT_WITH_BASE_CHUNKS +#elif defined(TK_LAYOUT_WITH_BASE_CHUNKS) if (ciPtr->baseChunkPtr != chunkPtr) { /* * Without context drawing only base chunks display their foreground. */ @@ -8043,11 +8031,11 @@ * Draw the text, underline, and overstrike for this chunk. */ if (!sValuePtr->elide && (numBytes > offsetBytes) && (stylePtr->fgGC != NULL)) { -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; int xDisplacement = x - chunkPtr->x; if ((len > 0) && (string[start + len - 1] == '\t')) { @@ -8128,18 +8116,17 @@ *-------------------------------------------------------------- */ static void CharUndisplayProc( - TkText *textPtr, /* Overall information about text widget. */ + TCL_UNUSED(TkText *), /* Overall information about text widget. */ TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; - (void)textPtr; if (ciPtr) { -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (chunkPtr == ciPtr->baseChunkPtr) { /* * Basechunks are undisplayed first, when DLines are freed or * partially freed, so this makes sure we don't access their data * any more. @@ -8218,17 +8205,17 @@ *-------------------------------------------------------------- */ static void CharBboxProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ int byteIndex, /* Byte offset of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ - int lineHeight, /* Height of line, in pixels. */ + TCL_UNUSED(int), /* Height of line, in pixels. */ int baseline, /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's * upper-left pixel. X-coord is in same * coordinate system as chunkPtr->x. */ @@ -8237,12 +8224,10 @@ int *heightPtr) /* Gets filled in with height of character, in * pixels. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; int maxX; - (void)textPtr; - (void)lineHeight; maxX = chunkPtr->width + chunkPtr->x; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, byteIndex, chunkPtr->x, -1, 0, xPtr); @@ -8719,11 +8704,11 @@ */ if ((maxX >= 0) && (curX >= maxX)) { break; } -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT start += TkpMeasureCharsInContext(tkfont, source, maxBytes, start - source, special - start, maxX >= 0 ? maxX - curX : -1, flags, &width); #else (void) maxBytes; @@ -8800,10 +8785,11 @@ }; enum viewUnits { VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS, VIEW_SCROLL_UNITS }; int index; + double d; if (Tcl_GetIndexFromObjStruct(interp, objv[2], subcommands, sizeof(char *), "option", 0, &index) != TCL_OK) { return TKTEXT_SCROLL_ERROR; } @@ -8827,32 +8813,43 @@ sizeof(char *), "argument", 0, &index) != TCL_OK) { return TKTEXT_SCROLL_ERROR; } switch ((enum viewUnits) index) { case VIEW_SCROLL_PAGES: - if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) { return TKTEXT_SCROLL_ERROR; + } + *intPtr = (d > 0) ? ceil(d) : floor(d); + if (dblPtr) { + *dblPtr = d; } return TKTEXT_SCROLL_PAGES; case VIEW_SCROLL_PIXELS: if (Tk_GetPixelsFromObj(interp, textPtr->tkwin, objv[3], intPtr) != TCL_OK) { return TKTEXT_SCROLL_ERROR; } + if (dblPtr) { + *dblPtr = (double)*intPtr; + } return TKTEXT_SCROLL_PIXELS; case VIEW_SCROLL_UNITS: - if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) { return TKTEXT_SCROLL_ERROR; + } + *intPtr = (d > 0) ? ceil(d) : floor(d); + if (dblPtr) { + *dblPtr = d; } return TKTEXT_SCROLL_UNITS; } } Tcl_Panic("unexpected switch fallthrough"); return TKTEXT_SCROLL_ERROR; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS /* *---------------------------------------------------------------------- * * FinalizeBaseChunk -- * @@ -8879,11 +8876,11 @@ * NULL. */ { const char *baseChars; TkTextDispChunk *chunkPtr; CharInfo *ciPtr; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT int widthAdjust = 0; int newwidth; #endif /* TK_DRAW_IN_CONTEXT */ if (baseCharChunkPtr == NULL) { @@ -8893,11 +8890,11 @@ baseChars = Tcl_DStringValue( &((BaseCharInfo *) baseCharChunkPtr->clientData)->baseChars); for (chunkPtr = baseCharChunkPtr; chunkPtr != NULL; chunkPtr = chunkPtr->nextPtr) { -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT chunkPtr->x += widthAdjust; #endif /* TK_DRAW_IN_CONTEXT */ if (chunkPtr->displayProc != CharDisplayProc) { continue; @@ -8906,11 +8903,11 @@ if (ciPtr->baseChunkPtr != baseCharChunkPtr) { break; } ciPtr->chars = baseChars + ciPtr->baseOffset; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); if (newwidth < chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; @@ -8920,11 +8917,11 @@ if (addChunkPtr != NULL) { ciPtr = addChunkPtr->clientData; ciPtr->chars = baseChars + ciPtr->baseOffset; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT addChunkPtr->x += widthAdjust; CharChunkMeasureChars(addChunkPtr, NULL, 0, 0, -1, 0, -1, 0, &addChunkPtr->width); #endif /* TK_DRAW_IN_CONTEXT */ } @@ -9018,11 +9015,11 @@ if (style1 == style2) { return 1; } -#if !TK_DRAW_IN_CONTEXT +#if !defined(TK_DRAW_IN_CONTEXT) if ( #ifdef MAC_OSX_TK !TkMacOSXCompareColors(style1->fgGC->foreground, style2->fgGC->foreground) #else @@ -9034,11 +9031,11 @@ #endif /* !TK_DRAW_IN_CONTEXT */ sv1 = style1->sValuePtr; sv2 = style2->sValuePtr; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT return sv1->tkfont == sv2->tkfont && sv1->offset == sv2->offset; #else return sv1->tkfont == sv2->tkfont && sv1->underline == sv2->underline && sv1->overstrike == sv2->overstrike Index: generic/tkTextImage.c ================================================================== --- generic/tkTextImage.c +++ generic/tkTextImage.c @@ -2,11 +2,11 @@ * tkImage.c -- * * This file contains code that allows images to be nested inside text * widgets. It also implements the "image" widget command for texts. * - * Copyright (c) 1997 Sun Microsystems, Inc. + * Copyright © 1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -288,12 +288,16 @@ &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); } - Tcl_SetObjResult(interp, resultObj); - return TCL_OK; + if (resultObj == NULL) { + return TCL_ERROR; + } else { + Tcl_SetObjResult(interp, resultObj); + return TCL_OK; + } } default: Tcl_Panic("unexpected switch fallthrough"); } return TCL_ERROR; @@ -445,18 +449,16 @@ */ static int EmbImageDeleteProc( TkTextSegment *eiPtr, /* Segment being deleted. */ - TkTextLine *linePtr, /* Line containing segment. */ - int treeGone) /* Non-zero means the entire tree is being + TCL_UNUSED(TkTextLine *), /* Line containing segment. */ + TCL_UNUSED(int)) /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ { Tcl_HashEntry *hPtr; - (void)linePtr; - (void)treeGone; if (eiPtr->body.ei.image != NULL) { hPtr = Tcl_FindHashEntry(&eiPtr->body.ei.sharedTextPtr->imageTable, eiPtr->body.ei.name); if (hPtr != NULL) { @@ -529,32 +531,29 @@ */ static int EmbImageLayoutProc( TkText *textPtr, /* Text widget being layed out. */ - TkTextIndex *indexPtr, /* Identifies first character in chunk. */ + TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */ TkTextSegment *eiPtr, /* Segment corresponding to indexPtr. */ TkSizeT offset, /* Offset within segPtr corresponding to * indexPtr (always 0). */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TCL_UNUSED(TkSizeT), /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this line yet. */ - TkWrapMode wrapMode, /* Wrap mode to use for line: + TCL_UNUSED(TkWrapMode), /* Wrap mode to use for line: * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD. */ TkTextDispChunk *chunkPtr) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ { int width, height; - (void)indexPtr; - (void)maxChars; - (void)wrapMode; if (offset != 0) { Tcl_Panic("Non-zero offset in EmbImageLayoutProc"); } @@ -620,14 +619,12 @@ */ static void EmbImageCheckProc( TkTextSegment *eiPtr, /* Segment to check. */ - TkTextLine *linePtr) /* Line containing segment. */ + TCL_UNUSED(TkTextLine *)) /* Line containing segment. */ { - (void)linePtr; - if (eiPtr->nextPtr == NULL) { Tcl_Panic("EmbImageCheckProc: embedded image is last segment in line"); } if (eiPtr->size != 1) { Tcl_Panic("EmbImageCheckProc: embedded image has size %d", @@ -663,20 +660,18 @@ int y, /* Top of rectangular bounding box for line: * tells where to draw this chunk in dst * (x-position is in the chunk itself). */ int lineHeight, /* Total height of line. */ int baseline, /* Offset of baseline from y. */ - Display *display, /* Display to use for drawing. */ + TCL_UNUSED(Display *), /* Display to use for drawing. */ Drawable dst, /* Pixmap or window in which to draw */ - int screenY) /* Y-coordinate in text window that + TCL_UNUSED(int)) /* Y-coordinate in text window that * corresponds to y. */ { TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData; int lineX, imageX, imageY, width, height; Tk_Image image; - (void)display; - (void)screenY; image = eiPtr->body.ei.image; if (image == NULL) { return; } @@ -718,13 +713,13 @@ *-------------------------------------------------------------- */ static void EmbImageBboxProc( - TkText *textPtr, + TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ - int index, /* Index of desired character within the + TCL_UNUSED(int), /* Index of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ int lineHeight, /* Total height of line. */ int baseline, /* Location of line's baseline, in pixels @@ -736,12 +731,10 @@ int *heightPtr) /* Gets filled in with height of image, in * pixels. */ { TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData; Tk_Image image; - (void)textPtr; - (void)index; image = eiPtr->body.ei.image; if (image != NULL) { Tk_SizeOfImage(image, widthPtr, heightPtr); } else { @@ -828,25 +821,22 @@ */ static void EmbImageProc( ClientData clientData, /* Pointer to widget record. */ - int x, int y, /* Upper left pixel (within image) that must + TCL_UNUSED(int), /* Upper left pixel (within image) that must * be redisplayed. */ - int width, int height, /* Dimensions of area to redisplay (may be + TCL_UNUSED(int), + TCL_UNUSED(int), /* Dimensions of area to redisplay (may be * <= 0). */ - int imgWidth, int imgHeight)/* New dimensions of image. */ + TCL_UNUSED(int), + TCL_UNUSED(int),/* New dimensions of image. */ + TCL_UNUSED(int)) { TkTextSegment *eiPtr = (TkTextSegment *)clientData; TkTextIndex index; - (void)x; - (void)y; - (void)width; - (void)height; - (void)imgWidth; - (void)imgHeight; index.tree = eiPtr->body.ei.sharedTextPtr->tree; index.linePtr = eiPtr->body.ei.linePtr; index.byteIndex = TkTextSegToOffset(eiPtr, eiPtr->body.ei.linePtr); TkTextChanged(eiPtr->body.ei.sharedTextPtr, NULL, &index, &index); Index: generic/tkTextIndex.c ================================================================== --- generic/tkTextIndex.c +++ generic/tkTextIndex.c @@ -2,12 +2,12 @@ * tkTextIndex.c -- * * This module provides functions that manipulate indices for text * widgets. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -60,11 +60,11 @@ #define GET_TEXTINDEX(objPtr) \ ((TkTextIndex *) (objPtr)->internalRep.twoPtrValue.ptr1) #define GET_INDEXEPOCH(objPtr) \ (PTR2INT((objPtr)->internalRep.twoPtrValue.ptr2)) #define SET_TEXTINDEX(objPtr, indexPtr) \ - ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (indexPtr)) + ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(indexPtr)) #define SET_INDEXEPOCH(objPtr, epoch) \ ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (size_t) (epoch)) /* * Define the 'textindex' object type, which Tk uses to represent indices in Index: generic/tkTextMark.c ================================================================== --- generic/tkTextMark.c +++ generic/tkTextMark.c @@ -2,12 +2,12 @@ * tkTextMark.c -- * * This file contains the functions that implement marks for text * widgets. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -131,11 +131,11 @@ if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } - str = TkGetStringFromObj(objv[3], &length); + str = Tcl_GetStringFromObj(objv[3], &length); if (length == 6 && !strcmp(str, "insert")) { markPtr = textPtr->insertMarkPtr; } else if (length == 7 && !strcmp(str, "current")) { markPtr = textPtr->currentMarkPtr; } else { @@ -158,11 +158,11 @@ typeStr = "left"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); return TCL_OK; } - str = TkGetStringFromObj(objv[4],&length); + str = Tcl_GetStringFromObj(objv[4],&length); c = str[0]; if ((c == 'l') && (strncmp(str, "left", length) == 0)) { newTypePtr = &tkTextLeftMarkType; } else if ((c == 'r') && (strncmp(str, "right", length) == 0)) { @@ -499,20 +499,16 @@ *-------------------------------------------------------------- */ static int MarkDeleteProc( - TkTextSegment *segPtr, /* Segment being deleted. */ - TkTextLine *linePtr, /* Line containing segment. */ - int treeGone) /* Non-zero means the entire tree is being + TCL_UNUSED(TkTextSegment *), /* Segment being deleted. */ + TCL_UNUSED(TkTextLine *), /* Line containing segment. */ + TCL_UNUSED(int)) /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ { - (void)segPtr; - (void)linePtr; - (void)treeGone; - return 1; } /* *-------------------------------------------------------------- @@ -560,33 +556,26 @@ */ static int MarkLayoutProc( TkText *textPtr, /* Text widget being layed out. */ - TkTextIndex *indexPtr, /* Identifies first character in chunk. */ + TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */ TkTextSegment *segPtr, /* Segment corresponding to indexPtr. */ - TkSizeT offset, /* Offset within segPtr corresponding to + TCL_UNUSED(TkSizeT), /* Offset within segPtr corresponding to * indexPtr (always 0). */ - int maxX, /* Chunk must not occupy pixels at this + TCL_UNUSED(int), /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TCL_UNUSED(TkSizeT), /* Chunk must not include more than this many * characters. */ - int noCharsYet, /* Non-zero means no characters have been + TCL_UNUSED(int), /* Non-zero means no characters have been * assigned to this line yet. */ - TkWrapMode wrapMode, /* Not used. */ + TCL_UNUSED(TkWrapMode), /* Not used. */ TkTextDispChunk *chunkPtr) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ { - (void)indexPtr; - (void)offset; - (void)maxX; - (void)maxChars; - (void)noCharsYet; - (void)wrapMode; - if (segPtr != textPtr->insertMarkPtr) { return -1; } chunkPtr->displayProc = TkTextInsertDisplayProc; @@ -626,19 +615,19 @@ */ void TkTextInsertDisplayProc( TkText *textPtr, /* The current text widget. */ - TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ + TCL_UNUSED(TkTextDispChunk *), /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (may differ from the x-position in * the chunk because of scrolling). */ int y, /* Y-position at which to draw this chunk in * dst (x-position is in the chunk itself). */ int height, /* Total height of line. */ - int baseline, /* Offset of baseline from y. */ - Display *display, /* Display to use for drawing. */ + TCL_UNUSED(int), /* Offset of baseline from y. */ + TCL_UNUSED(Display *), /* Display to use for drawing. */ Drawable dst, /* Pixmap or window in which to draw chunk. */ int screenY) /* Y-coordinate in text window that * corresponds to y. */ { /* @@ -648,13 +637,10 @@ /* TkText *textPtr = chunkPtr->clientData; */ TkTextIndex index; int halfWidth = textPtr->insertWidth/2; int rightSideWidth; int ix = 0, iy = 0, iw = 0, ih = 0, charWidth = 0; - (void)chunkPtr; - (void)baseline; - (void)display; if (textPtr->insertCursorType) { TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index); TkTextIndexBbox(textPtr, &index, &ix, &iy, &iw, &ih, &charWidth); rightSideWidth = charWidth + halfWidth; @@ -733,16 +719,13 @@ *-------------------------------------------------------------- */ static void InsertUndisplayProc( - TkText *textPtr, /* Overall information about text widget. */ - TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */ + TCL_UNUSED(TkText *), /* Overall information about text widget. */ + TCL_UNUSED(TkTextDispChunk *)) /* Chunk that is about to be freed. */ { - (void)textPtr; - (void)chunkPtr; - return; } /* *-------------------------------------------------------------- Index: generic/tkTextTag.c ================================================================== --- generic/tkTextTag.c +++ generic/tkTextTag.c @@ -3,12 +3,12 @@ * * This module implements the "tag" subcommand of the widget command for * text widgets, plus most of the other high-level functions related to * tags. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -355,11 +355,11 @@ case TAG_CONFIGURE: { int newTag; if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, - "tagName ?-option? ?value? ?-option value ...?"); + "tagName ?-option value ...?"); return TCL_ERROR; } tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag); if (objc <= 5) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, tagPtr, @@ -1109,11 +1109,11 @@ { Tcl_HashEntry *hPtr; TkSizeT len; const char *str; - str = TkGetStringFromObj(tagName, &len); + str = Tcl_GetStringFromObj(tagName, &len); if (len == 3 && !strcmp(str, "sel")) { return textPtr->selTagPtr; } hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable, Tcl_GetString(tagName)); @@ -1438,11 +1438,11 @@ *-------------------------------------------------------------- */ void TkTextBindProc( - ClientData clientData, /* Pointer to canvas structure. */ + ClientData clientData, /* Pointer to text widget structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkText *textPtr = (TkText *)clientData; int repick = 0; @@ -1457,11 +1457,11 @@ if (eventPtr->type == ButtonPress) { textPtr->flags |= BUTTON_DOWN; } else if (eventPtr->type == ButtonRelease) { unsigned long mask; - mask = TkGetButtonMask(eventPtr->xbutton.button); + mask = Tk_GetButtonMask(eventPtr->xbutton.button); if ((eventPtr->xbutton.state & ALL_BUTTONS) == mask) { textPtr->flags &= ~BUTTON_DOWN; repick = 1; } } else if ((eventPtr->type == EnterNotify) Index: generic/tkTextWind.c ================================================================== --- generic/tkTextWind.c +++ generic/tkTextWind.c @@ -3,12 +3,12 @@ * * This file contains code that allows arbitrary windows to be nested * inside text widgets. It also implements the "window" widget command * for texts. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -20,17 +20,17 @@ * geometry manager: */ static void EmbWinRequestProc(ClientData clientData, Tk_Window tkwin); -static void EmbWinLostSlaveProc(ClientData clientData, +static void EmbWinLostContentProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr textGeomType = { "text", /* name */ EmbWinRequestProc, /* requestProc */ - EmbWinLostSlaveProc, /* lostSlaveProc */ + EmbWinLostContentProc, /* lostContentProc */ }; /* * Macro that determines the size of an embedded window segment: */ @@ -158,11 +158,10 @@ return TCL_ERROR; } switch ((enum windOptions) optionIndex) { case WIND_CGET: { TkTextIndex index; - TkTextSegment *ewPtr; Tcl_Obj *objPtr; TkTextEmbWindowClient *client; if (objc != 5) { Tcl_WrongNumArgs(interp, 3, objv, "index option"); @@ -199,11 +198,10 @@ Tcl_SetObjResult(interp, objPtr); return TCL_OK; } case WIND_CONFIGURE: { TkTextIndex index; - TkTextSegment *ewPtr; if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, "index ?-option value ...?"); return TCL_ERROR; } @@ -441,11 +439,11 @@ for (ancestor = textPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { - badMaster: + badContainer: Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf( "can't embed %s in %s", Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", @@ -457,11 +455,11 @@ return TCL_ERROR; } } if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (ewPtr->body.ew.tkwin == textPtr->tkwin)) { - goto badMaster; + goto badContainer; } if (client == NULL) { /* * Have to make the new client. @@ -574,16 +572,15 @@ */ static void EmbWinRequestProc( ClientData clientData, /* Pointer to record for window item. */ - Tk_Window tkwin) /* Window that changed its desired size. */ + TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */ { TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData; TkTextSegment *ewPtr = client->parent; TkTextIndex index; - (void)tkwin; index.tree = ewPtr->body.ew.sharedTextPtr->tree; index.linePtr = ewPtr->body.ew.linePtr; index.byteIndex = TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr); TkTextChanged(ewPtr->body.ew.sharedTextPtr, NULL, &index, &index); @@ -592,13 +589,13 @@ } /* *-------------------------------------------------------------- * - * EmbWinLostSlaveProc -- + * EmbWinLostContentProc -- * - * This function is invoked by the Tk geometry manager when a slave + * This function is invoked by the Tk geometry manager when a content * window managed by a text widget is claimed away by another geometry * manager. * * Results: * None. @@ -609,11 +606,11 @@ * *-------------------------------------------------------------- */ static void -EmbWinLostSlaveProc( +EmbWinLostContentProc( ClientData clientData, /* Pointer to record describing window item. */ Tk_Window tkwin) /* Window that was claimed away by another * geometry manager. */ { TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData; @@ -737,19 +734,17 @@ */ static int EmbWinDeleteProc( TkTextSegment *ewPtr, /* Segment being deleted. */ - TkTextLine *linePtr, /* Line containing segment. */ - int treeGone) /* Non-zero means the entire tree is being + TCL_UNUSED(TkTextLine *), /* Line containing segment. */ + TCL_UNUSED(int)) /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ { TkTextEmbWindowClient *client; client = ewPtr->body.ew.clients; - (void)linePtr; - (void)treeGone; while (client != NULL) { TkTextEmbWindowClient *next = client->next; Tcl_HashEntry *hPtr = NULL; @@ -818,33 +813,30 @@ */ static int EmbWinLayoutProc( TkText *textPtr, /* Text widget being layed out. */ - TkTextIndex *indexPtr, /* Identifies first character in chunk. */ + TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */ TkTextSegment *ewPtr, /* Segment corresponding to indexPtr. */ TkSizeT offset, /* Offset within segPtr corresponding to * indexPtr (always 0). */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ - TkSizeT maxChars, /* Chunk must not include more than this many + TCL_UNUSED(TkSizeT), /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this line yet. */ - TkWrapMode wrapMode, /* Wrap mode to use for line: + TCL_UNUSED(TkWrapMode), /* Wrap mode to use for line: * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD. */ TkTextDispChunk *chunkPtr) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ { int width, height; TkTextEmbWindowClient *client; - (void)indexPtr; - (void)maxChars; - (void)wrapMode; if (offset != 0) { Tcl_Panic("Non-zero offset in EmbWinLayoutProc"); } @@ -937,16 +929,16 @@ for (ancestor = textPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == Tk_Parent(ewPtr->body.ew.tkwin)) { break; } if (Tk_TopWinHierarchy(ancestor)) { - goto badMaster; + goto badContainer; } } if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (textPtr->tkwin == ewPtr->body.ew.tkwin)) { - badMaster: + badContainer: Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf( "can't embed %s relative to %s", Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", "HIERARCHY", @@ -1053,14 +1045,12 @@ */ static void EmbWinCheckProc( TkTextSegment *ewPtr, /* Segment to check. */ - TkTextLine *linePtr) /* Line containing segment. */ + TCL_UNUSED(TkTextLine *)) /* Line containing segment. */ { - (void)linePtr; - if (ewPtr->nextPtr == NULL) { Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line"); } if (ewPtr->size != 1) { Tcl_Panic("EmbWinCheckProc: embedded window has size %d", (int)ewPtr->size); @@ -1090,28 +1080,25 @@ TkText *textPtr, /* Information about text widget. */ TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (differs from the x-position in the * chunk because of scrolling). */ - int y, /* Top of rectangular bounding box for line: + TCL_UNUSED(int), /* Top of rectangular bounding box for line: * tells where to draw this chunk in dst * (x-position is in the chunk itself). */ int lineHeight, /* Total height of line. */ int baseline, /* Offset of baseline from y. */ - Display *display, /* Display to use for drawing (unused). */ - Drawable dst, /* Pixmap or window in which to draw + TCL_UNUSED(Display *), /* Display to use for drawing (unused). */ + TCL_UNUSED(Drawable), /* Pixmap or window in which to draw * (unused). */ int screenY) /* Y-coordinate in text window that * corresponds to y. */ { int lineX, windowX, windowY, width, height; Tk_Window tkwin; TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData; TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr); - (void)y; - (void)display; - (void)dst; if (client == NULL) { return; } @@ -1234,11 +1221,11 @@ static void EmbWinBboxProc( TkText *textPtr, /* Information about text widget. */ TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ - int index, /* Index of desired character within the + TCL_UNUSED(int), /* Index of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ int lineHeight, /* Total height of line. */ int baseline, /* Location of line's baseline, in pixels @@ -1251,11 +1238,10 @@ * pixels. */ { Tk_Window tkwin; TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData; TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr); - (void)index; if (client == NULL) { tkwin = NULL; } else { tkwin = client->tkwin; Index: generic/tkTrig.c ================================================================== --- generic/tkTrig.c +++ generic/tkTrig.c @@ -3,12 +3,12 @@ * * This file contains a collection of trigonometry utility routines that * are used by Tk and in particular by the canvas code. It also has * miscellaneous geometry functions used by canvases. * - * Copyright (c) 1992-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1992-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkUndo.c ================================================================== --- generic/tkUndo.c +++ generic/tkUndo.c @@ -1,12 +1,12 @@ /* * tkUndo.c -- * * This module provides the implementation of an undo stack. * - * Copyright (c) 2002 by Ludwig Callewaert. - * Copyright (c) 2003-2004 by Vincent Darley. + * Copyright © 2002 Ludwig Callewaert. + * Copyright © 2003-2004 Vincent Darley. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkUndo.h ================================================================== --- generic/tkUndo.h +++ generic/tkUndo.h @@ -1,11 +1,11 @@ /* * tkUndo.h -- * * Declarations shared among the files that implement an undo stack. * - * Copyright (c) 2002 Ludwig Callewaert. + * Copyright © 2002 Ludwig Callewaert. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkUtil.c ================================================================== --- generic/tkUtil.c +++ generic/tkUtil.c @@ -2,12 +2,12 @@ * tkUtil.c -- * * This file contains miscellaneous utility functions that are used by * the rest of Tk, such as a function for drawing a focus highlight. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -662,20 +662,22 @@ return TK_SCROLL_ERROR; } return TK_SCROLL_MOVETO; } else if ((c == 's') && (strncmp(argv[2], "scroll", length) == 0)) { + double d; if (argc != 5) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s %s %s\"", argv[0], argv[1], "scroll number pages|units")); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TK_SCROLL_ERROR; } - if (Tcl_GetInt(interp, argv[3], intPtr) != TCL_OK) { + if (Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) { return TK_SCROLL_ERROR; } + *intPtr = (d > 0) ? ceil(d) : floor(d); length = strlen(argv[4]); c = argv[4][0]; if ((c == 'p') && (strncmp(argv[4], "pages", length) == 0)) { return TK_SCROLL_PAGES; } else if ((c == 'u') && (strncmp(argv[4], "units", length) == 0)) { @@ -727,11 +729,11 @@ * any. */ int *intPtr) /* Filled in with number of pages or lines to * scroll, if any. */ { TkSizeT length; - const char *arg = TkGetStringFromObj(objv[2], &length); + const char *arg = Tcl_GetStringFromObj(objv[2], &length); #define ArgPfxEq(str) \ ((arg[0] == str[0]) && !strncmp(arg, str, length)) if (ArgPfxEq("moveto")) { @@ -742,19 +744,24 @@ if (Tcl_GetDoubleFromObj(interp, objv[3], dblPtr) != TCL_OK) { return TK_SCROLL_ERROR; } return TK_SCROLL_MOVETO; } else if (ArgPfxEq("scroll")) { + double d; if (objc != 5) { Tcl_WrongNumArgs(interp, 2, objv, "scroll number pages|units"); return TK_SCROLL_ERROR; } - if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) { return TK_SCROLL_ERROR; } + *intPtr = (d >= 0) ? ceil(d) : floor(d); + if (dblPtr) { + *dblPtr = d; + } - arg = TkGetStringFromObj(objv[4], &length); + arg = Tcl_GetStringFromObj(objv[4], &length); if (ArgPfxEq("pages")) { return TK_SCROLL_PAGES; } else if (ArgPfxEq("units")) { return TK_SCROLL_UNITS; } @@ -1128,11 +1135,11 @@ } Tcl_DStringAppend(&ds, name, -1); dictObj = Tcl_NewObj(); for (i = 0; map[i].name != NULL ; ++i) { - Tcl_Obj *nameObj, *fqdnObj; + Tcl_Obj *fqdnObj; nameObj = Tcl_NewStringObj(map[i].name, -1); fqdnObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_AppendStringsToObj(fqdnObj, "::", map[i].name, NULL); @@ -1155,11 +1162,11 @@ } /* *---------------------------------------------------------------------- * - * TkSendVirtualEvent -- + * Tk_SendVirtualEvent -- * * Send a virtual event notification to the specified target window. * Equivalent to: * "event generate $target <<$eventName>> -data $detail" * @@ -1168,11 +1175,11 @@ * *---------------------------------------------------------------------- */ void -TkSendVirtualEvent( +Tk_SendVirtualEvent( Tk_Window target, const char *eventName, Tcl_Obj *detail) { union {XEvent general; XVirtualEvent virt;} event; @@ -1303,25 +1310,12 @@ return (first + TkUtfToUniChar(first, &ch) >= src) ? first : p ; } #endif - -#if TCL_MAJOR_VERSION > 8 -unsigned char * -TkGetByteArrayFromObj( - Tcl_Obj *objPtr, - size_t *lengthPtr -) { - unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, NULL); - *lengthPtr = *(size_t *) objPtr->internalRep.twoPtrValue.ptr1; - return result; -} -#endif /* TCL_MAJOR_VERSION > 8 */ - /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ Index: generic/tkVisual.c ================================================================== --- generic/tkVisual.c +++ generic/tkVisual.c @@ -3,12 +3,12 @@ * * This file contains library procedures for allocating and freeing * visuals and colormaps. This code is based on a prototype * implementation by Paul Mackerras. * - * Copyright (c) 1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: generic/tkWindow.c ================================================================== --- generic/tkWindow.c +++ generic/tkWindow.c @@ -3,19 +3,19 @@ * * This file provides basic window-manipulation functions, which are * equivalent to functions in Xlib (and even invoke them) but also * maintain the local Tk_Window structure. * - * Copyright (c) 1989-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright © 1989-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" - +#include "tkPort.h" #ifdef _WIN32 #include "tkWinInt.h" #elif !defined(MAC_OSX_TK) #include "tkUnixInt.h" #endif @@ -237,12 +237,10 @@ TkCloseDisplay( TkDisplay *dispPtr) { TkClipCleanup(dispPtr); - TkpCancelWarp(dispPtr); - if (dispPtr->name != NULL) { ckfree(dispPtr->name); } if (dispPtr->atomInit) { @@ -920,11 +918,11 @@ if (cmdPtr->objProc == NULL) { Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } #if defined(_WIN32) && !defined(STATIC_BUILD) - if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) { + if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->tcl_CreateFileHandler) { /* * We are running on Cygwin, so don't use the win32 dialogs. */ continue; @@ -1642,11 +1640,11 @@ event.xmap.send_event = False; event.xmap.display = winPtr->display; event.xmap.event = winPtr->window; event.xmap.window = winPtr->window; event.xmap.override_redirect = winPtr->atts.override_redirect; - Tk_HandleEvent(&event); + TkpHandleMapOrUnmap((Tk_Window)winPtr, &event); } /* *-------------------------------------------------------------- * @@ -1804,11 +1802,11 @@ event.xunmap.send_event = False; event.xunmap.display = winPtr->display; event.xunmap.event = winPtr->window; event.xunmap.window = winPtr->window; event.xunmap.from_configure = False; - Tk_HandleEvent(&event); + TkpHandleMapOrUnmap((Tk_Window)winPtr, &event); } } void Tk_ConfigureWindow( @@ -2692,11 +2690,11 @@ } /* *---------------------------------------------------------------------- * - * TkpAlwaysShowSelection -- + * Tk_AlwaysShowSelection -- * * Indicates whether text/entry widgets should always display * their selection, regardless of window focus. * * Results: @@ -2710,11 +2708,11 @@ * *---------------------------------------------------------------------- */ int -TkpAlwaysShowSelection( +Tk_AlwaysShowSelection( Tk_Window tkwin) /* Window whose application is to be * checked. */ { return ((TkWindow *) tkwin)->mainPtr->alwaysShowSelection; } @@ -2959,11 +2957,11 @@ * screen etc etc. * * Current risks: * * - No CPU time limit, no memory allocation limits, no color limits. - * CPU time limits can be imposed by an unsafe master interpreter. + * CPU time limits can be imposed by an unsafe parent interpreter. * * The actual code called is the same as Tk_Init but Tcl_IsSafe() is * checked at several places to differentiate the two initialisations. */ @@ -3079,65 +3077,65 @@ Tcl_ResetResult(interp); if (Tcl_IsSafe(interp)) { /* * Get the clearance to start Tk and the "argv" parameters from the - * master. + * parent. */ /* - * Step 1 : find the master and construct the interp name (could be a + * Step 1 : find the parent and construct the interp name (could be a * function if new APIs were ok). We could also construct the path * while walking, but there is no API to get the name of an interp * either. */ - Tcl_Interp *master = interp; + Tcl_Interp *parent = interp; - while (Tcl_IsSafe(master)) { - master = Tcl_GetMaster(master); - if (master == NULL) { + while (Tcl_IsSafe(parent)) { + parent = Tcl_GetParent(parent); + if (parent == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "no controlling master interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL); + "no controlling parent interpreter", -1)); + Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_PARENT", NULL); return TCL_ERROR; } } /* * Construct the name (rewalk...) */ - code = Tcl_GetInterpPath(master, interp); + code = Tcl_GetInterpPath(parent, interp); if (code != TCL_OK) { Tcl_Panic("Tcl_GetInterpPath broken!"); } /* - * Build the command to eval in trusted master. + * Build the command to eval in trusted parent. */ cmd = Tcl_NewListObj(2, NULL); Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("::safe::TkInit", -1)); - Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(master)); + Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(parent)); /* - * Step 2 : Eval in the master. The argument is the *reversed* interp - * path of the slave. + * Step 2 : Eval in the parent. The argument is the *reversed* interp + * path of the child. */ Tcl_IncrRefCount(cmd); - code = Tcl_EvalObjEx(master, cmd, 0); + code = Tcl_EvalObjEx(parent, cmd, 0); Tcl_DecrRefCount(cmd); - Tcl_TransferResult(master, code, interp); + Tcl_TransferResult(parent, code, interp); if (code != TCL_OK) { return code; } /* - * Use the master's result as argv. Note: We don't use the Obj + * Use the parent's result as argv. Note: We don't use the Obj * interfaces to avoid dealing with cross interp refcounting and * changing the code below. */ value = Tcl_GetObjResult(interp); @@ -3201,11 +3199,11 @@ * The -class argument is always the ToTitle of the -name */ { TkSizeT numBytes; - const char *bytes = TkGetStringFromObj(nameObj, &numBytes); + const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes); classObj = Tcl_NewStringObj(bytes, numBytes); numBytes = Tcl_UtfToTitle(Tcl_GetString(classObj)); Tcl_SetObjLength(classObj, numBytes); @@ -3283,14 +3281,18 @@ goto done; } } /* - * Provide Tk and its stub table. + * Provide "tk" and its stub table. */ - code = Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL, +#ifndef TK_NO_DEPRECATED + Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL, + (ClientData) &tkStubs); +#endif + code = Tcl_PkgProvideEx(interp, "tk", TK_PATCH_LEVEL, (ClientData) &tkStubs); if (code != TCL_OK) { goto done; } @@ -3381,11 +3383,11 @@ Tk_PkgInitStubsCheck( Tcl_Interp *interp, const char * version, int exact) { - const char *actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, 0, NULL); + const char *actualVersion = Tcl_PkgRequireEx(interp, "tk", version, 0, NULL); if (exact && actualVersion) { const char *p = version; int count = 0; @@ -3393,15 +3395,15 @@ count += !isdigit(UCHAR(*p++)); } if (count == 1) { if (0 != strncmp(version, actualVersion, strlen(version))) { /* Construct error message */ - Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL); + Tcl_PkgPresentEx(interp, "tk", version, 1, NULL); return NULL; } } else { - return Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL); + return Tcl_PkgPresentEx(interp, "tk", version, 1, NULL); } } return actualVersion; } Index: generic/ttk/ttkBlink.c ================================================================== --- generic/ttk/ttkBlink.c +++ generic/ttk/ttkBlink.c @@ -57,11 +57,11 @@ cm = (CursorManager *)ckalloc(sizeof(*cm)); cm->timer = 0; cm->owner = 0; cm->onTime = DEF_CURSOR_ON_TIME; cm->offTime = DEF_CURSOR_OFF_TIME; - Tcl_SetAssocData(interp,cm_key,CursorManagerDeleteProc,(ClientData)cm); + Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm); } return cm; } /* CursorBlinkProc -- Index: generic/ttk/ttkButton.c ================================================================== --- generic/ttk/ttkButton.c +++ generic/ttk/ttkButton.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003, Joe English * * label, button, checkbutton, radiobutton, and menubutton widgets. */ #include "tkInt.h" @@ -83,11 +83,11 @@ /* * Compound base/image options */ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE, - TK_OPTION_NULL_OK,(void *)ttkCompoundStrings, + TK_OPTION_NULL_OK, (void *)ttkCompoundStrings, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, @@ -271,15 +271,16 @@ WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; static const Ttk_Ensemble LabelCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, - { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec LabelWidgetSpec = { @@ -376,16 +377,17 @@ } return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble ButtonCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, - { "invoke", ButtonInvokeCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, + { "invoke", ButtonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, - { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec ButtonWidgetSpec = { @@ -583,16 +585,17 @@ return Tcl_EvalObjEx(interp, checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble CheckbuttonCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, - { "invoke", CheckbuttonInvokeCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, + { "invoke", CheckbuttonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, - { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, /* MISSING: select, deselect, toggle */ { 0,0,0 } }; static const WidgetSpec CheckbuttonWidgetSpec = @@ -759,16 +762,17 @@ return Tcl_EvalObjEx(interp, radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble RadiobuttonCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, - { "invoke", RadiobuttonInvokeCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, + { "invoke", RadiobuttonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, - { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, /* MISSING: select, deselect */ { 0,0,0 } }; static const WidgetSpec RadiobuttonWidgetSpec = @@ -821,11 +825,11 @@ { {TK_OPTION_STRING, "-menu", "menu", "Menu", "", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0}, {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction", "below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE, - 0,(ClientData)directionStrings,GEOMETRY_CHANGED}, + 0, (void *)directionStrings, GEOMETRY_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; @@ -833,10 +837,11 @@ { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec MenubuttonWidgetSpec = { @@ -856,11 +861,11 @@ TTK_BEGIN_LAYOUT(MenubuttonLayout) TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_GROUP("Menubutton.focus", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) - TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, + TTK_GROUP("Menubutton.padding", TTK_FILL_X, TTK_NODE("Menubutton.label", TTK_PACK_LEFT)))) TTK_END_LAYOUT /*------------------------------------------------------------------------ * +++ Initialization. Index: generic/ttk/ttkCache.c ================================================================== --- generic/ttk/ttkCache.c +++ generic/ttk/ttkCache.c @@ -1,9 +1,9 @@ /* * Theme engine resource cache. * - * Copyright (c) 2004, Joe English + * Copyright © 2004, Joe English * * The problem: * * Tk maintains reference counts for fonts, colors, and images, * and deallocates them when the reference count goes to zero. Index: generic/ttk/ttkClamTheme.c ================================================================== --- generic/ttk/ttkClamTheme.c +++ generic/ttk/ttkClamTheme.c @@ -1,7 +1,7 @@ /* - * Copyright (C) 2004 Joe English + * Copyright © 2004 Joe English * * "clam" theme; inspired by the XFCE family of Gnome themes. */ #include "tkInt.h" @@ -953,11 +953,11 @@ TTK_BEGIN_LAYOUT_TABLE(LayoutTable) TTK_LAYOUT("TCombobox", TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Combobox.field", TTK_PACK_LEFT|TTK_FILL_BOTH|TTK_EXPAND, + TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))) TTK_LAYOUT("Horizontal.Sash", TTK_GROUP("Sash.hsash", TTK_FILL_BOTH, Index: generic/ttk/ttkClassicTheme.c ================================================================== --- generic/ttk/ttkClassicTheme.c +++ generic/ttk/ttkClassicTheme.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004, Joe English * * "classic" theme; implements the classic Motif-like Tk look. * */ @@ -451,11 +451,11 @@ TTK_LAYOUT("TMenubutton", TTK_GROUP("Menubutton.highlight", TTK_FILL_BOTH, TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) - TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, + TTK_GROUP("Menubutton.padding", TTK_FILL_X, TTK_NODE("Menubutton.label", 0))))) /* "classic" entry, includes highlight border */ TTK_LAYOUT("TEntry", TTK_GROUP("Entry.highlight", TTK_FILL_BOTH, Index: generic/ttk/ttkDecls.h ================================================================== --- generic/ttk/ttkDecls.h +++ generic/ttk/ttkDecls.h @@ -11,11 +11,15 @@ Tcl_Interp *, const char *version, int epoch, int revision); #define Ttk_InitStubs(interp) TtkInitializeStubs( \ interp, TTK_VERSION, TTK_STUBS_EPOCH, TTK_STUBS_REVISION) #else -#define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL) +#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 +# define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL) +#else +# define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "ttk", TTK_VERSION, 0, NULL) +#endif #endif #if !defined(BUILD_tk) # define TTK_DEPRECATED(msg) TTKAPI TCL_DEPRECATED_API(msg) Index: generic/ttk/ttkDefaultTheme.c ================================================================== --- generic/ttk/ttkDefaultTheme.c +++ generic/ttk/ttkDefaultTheme.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003 Joe English * * Tk alternate theme, intended to match the MSUE and Gtk's (old) default theme */ #include "tkInt.h" Index: generic/ttk/ttkElements.c ================================================================== --- generic/ttk/ttkElements.c +++ generic/ttk/ttkElements.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003 Joe English * * Default implementation for themed elements. * */ Index: generic/ttk/ttkEntry.c ================================================================== --- generic/ttk/ttkEntry.c +++ generic/ttk/ttkEntry.c @@ -1,13 +1,13 @@ /* * DERIVED FROM: tk/generic/tkEntry.c r1.35. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright (c) 2000 Ajuba Solutions. - * Copyright (c) 2002 ActiveState Corporation. - * Copyright (c) 2004 Joe English + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2000 Ajuba Solutions. + * Copyright © 2002 ActiveState Corporation. + * Copyright © 2004 Joe English */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" @@ -179,11 +179,11 @@ {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", NULL, offsetof(Entry, entry.textVariableObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,TEXTVAR_CHANGED}, {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate", "none", TCL_INDEX_NONE, offsetof(Entry, entry.validate), - 0, (ClientData) validateStrings, 0}, + 0, (void *) validateStrings, 0}, {TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand", NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_ENTRY_WIDTH, offsetof(Entry, entry.widthObj), TCL_INDEX_NONE, @@ -323,11 +323,11 @@ Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj), entryPtr->entry.displayString, entryPtr->entry.numChars, 0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES, &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight); } else { - text = TkGetStringFromObj(entryPtr->entry.placeholderObj, &length); + text = Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &length); entryPtr->entry.textLayout = Tk_ComputeTextLayout( Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj), text, length, 0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES, &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight); @@ -401,11 +401,11 @@ { if (entryPtr->entry.exportSelection && (!Tcl_IsSafe(entryPtr->core.interp)) && !(entryPtr->core.flags & GOT_SELECTION)) { Tk_OwnSelection(entryPtr->core.tkwin, XA_PRIMARY, EntryLostSelection, - (ClientData) entryPtr); + entryPtr); entryPtr->core.flags |= GOT_SELECTION; } } /*------------------------------------------------------------------------ @@ -598,13 +598,13 @@ { Tcl_Interp *interp = entryPtr->core.interp; VMODE vmode = entryPtr->entry.validate; int code, change_ok; - if ( (entryPtr->entry.validateCmd == NULL) + if ((entryPtr->entry.validateCmd == NULL) || (entryPtr->core.flags & VALIDATING) - || !EntryNeedsValidation(vmode, reason) ) + || !EntryNeedsValidation(vmode, reason)) { return TCL_OK; } entryPtr->core.flags |= VALIDATING; @@ -956,11 +956,11 @@ (void)dummy; Tk_CreateEventHandler( entryPtr->core.tkwin, EntryEventMask, EntryEventProc, entryPtr); Tk_CreateSelHandler(entryPtr->core.tkwin, XA_PRIMARY, XA_STRING, - EntryFetchSelection, (ClientData) entryPtr, XA_STRING); + EntryFetchSelection, entryPtr, XA_STRING); TtkBlinkCursor(&entryPtr->core); entryPtr->entry.string = (char *)ckalloc(1); *entryPtr->entry.string = '\0'; entryPtr->entry.displayString = entryPtr->entry.string; @@ -1310,30 +1310,51 @@ } else { foregroundObj = es.foregroundObj; } /* Use placeholder text width */ leftIndex = 0; - (void)TkGetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex); + (void)Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex); } else { foregroundObj = es.foregroundObj; } gc = EntryGetGC(entryPtr, foregroundObj, clipRegion); - Tk_DrawTextLayout( - Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, - entryPtr->entry.layoutX, entryPtr->entry.layoutY, - leftIndex, rightIndex); - XSetClipMask(Tk_Display(tkwin), gc, None); - Tk_FreeGC(Tk_Display(tkwin), gc); - - /* Overwrite the selected portion (if any) in the -selectforeground color: - */ if (showSelection) { + + /* Draw the selected and unselected portions separately. + */ + if (leftIndex < selFirst) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, selFirst); + } + if (selLast < rightIndex) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + selLast, rightIndex); + } + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); + + /* Draw the selected portion in the -selectforeground color: + */ gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion); Tk_DrawTextLayout( Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, entryPtr->entry.layoutX, entryPtr->entry.layoutY, selFirst, selLast); + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); + } else { + + /* Draw the entire visible text + */ + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, rightIndex); XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); } /* Drop the region. Note that we have to manually remove the reference to @@ -1370,18 +1391,18 @@ # define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */ TkSizeT length, idx; const char *string; if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) { - if (idx + 1 > entryPtr->entry.numChars + 1) { + if ((idx != TCL_INDEX_NONE) && (idx > entryPtr->entry.numChars)) { idx = entryPtr->entry.numChars; } *indexPtr = idx; return TCL_OK; } - string = TkGetStringFromObj(indexObj, &length); + string = Tcl_GetStringFromObj(indexObj, &length); if (strncmp(string, "insert", length) == 0) { *indexPtr = entryPtr->entry.insertPos; } else if (strncmp(string, "left", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.first; @@ -1554,11 +1575,11 @@ return TCL_ERROR; } if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); return TCL_OK; } /* $entry insert $index $text -- * Insert $text after position $index. @@ -1627,11 +1648,11 @@ TkSizeT start, end; if (objc != 5) { Tcl_WrongNumArgs(interp, 3, objv, "start end"); return TCL_ERROR; } - if ( EntryIndex(interp, entryPtr, objv[3], &start) != TCL_OK + if (EntryIndex(interp, entryPtr, objv[3], &start) != TCL_OK || EntryIndex(interp, entryPtr, objv[4], &end) != TCL_OK) { return TCL_ERROR; } if (entryPtr->core.state & TTK_STATE_DISABLED) { return TCL_OK; @@ -1688,11 +1709,11 @@ code = EntryRevalidate(interp, entryPtr, VALIDATE_FORCED); if (code == TCL_ERROR) return code; - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(code == TCL_OK)); + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(code == TCL_OK)); return TCL_OK; } /* $entry xview -- horizontal scrolling interface */ @@ -1722,10 +1743,11 @@ { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; @@ -1826,11 +1848,11 @@ Tcl_ListObjGetElements(interp, cbPtr->combobox.valuesObj, &nValues, &values); if (objc == 2) { /* Check if currentIndex still valid: */ - if ( currentIndex == TCL_INDEX_NONE + if (currentIndex == TCL_INDEX_NONE || currentIndex >= (TkSizeT)nValues || strcmp(currentValue,Tcl_GetString(values[currentIndex])) ) { /* Not valid. Check current value against each element in -values: @@ -1844,11 +1866,11 @@ /* Not found */ currentIndex = TCL_INDEX_NONE; } } cbPtr->combobox.currentIndex = currentIndex; - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)currentIndex)); + Tcl_SetObjResult(interp, TkNewIndexObj(currentIndex)); return TCL_OK; } else if (objc == 3) { TkSizeT idx; if (TCL_OK == TkGetIntForIndex(objv[2], nValues - 1, 0, &idx)) { @@ -1890,12 +1912,13 @@ { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, - { "state", TtkWidgetStateCommand,0 }, { "set", EntrySetCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; @@ -2002,12 +2025,13 @@ { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, - { "state", TtkWidgetStateCommand,0 }, { "set", EntrySetCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; @@ -2086,11 +2110,11 @@ TTK_END_LAYOUT TTK_BEGIN_LAYOUT(ComboboxLayout) TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Combobox.padding", TTK_FILL_BOTH|TTK_PACK_LEFT|TTK_EXPAND, + TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))) TTK_END_LAYOUT TTK_BEGIN_LAYOUT(SpinboxLayout) TTK_GROUP("Spinbox.field", TTK_PACK_TOP|TTK_FILL_X, Index: generic/ttk/ttkFrame.c ================================================================== --- generic/ttk/ttkFrame.c +++ generic/ttk/ttkFrame.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004 Joe English * * ttk::frame and ttk::labelframe widgets. */ #include "tkInt.h" @@ -46,15 +46,16 @@ WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble FrameCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, - { "identify", TtkWidgetIdentifyCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * FrameMargins -- @@ -86,16 +87,16 @@ /* FrameSize procedure -- * The frame doesn't request a size of its own by default, * but it does have an internal border. See also <> */ -static int FrameSize(void *recordPtr, int *widthPtr, int *heightPtr) +static int FrameSize( + void *recordPtr, + TCL_UNUSED(int *), + TCL_UNUSED(int *)) { Frame *framePtr = (Frame *)recordPtr; - (void)widthPtr; - (void)heightPtr; - Ttk_SetMargins(framePtr->core.tkwin, FrameMargins(framePtr)); return 0; } /* @@ -338,19 +339,20 @@ /* * LabelframeSize -- * Like the frame, this doesn't request a size of its own * but it does have internal padding and a minimum size. */ -static int LabelframeSize(void *recordPtr, int *widthPtr, int *heightPtr) +static int LabelframeSize( + void *recordPtr, + TCL_UNUSED(int *), + TCL_UNUSED(int *)) { Labelframe *lframePtr = (Labelframe *)recordPtr; WidgetCore *corePtr = &lframePtr->core; Ttk_Padding margins; LabelframeStyle style; int labelWidth, labelHeight; - (void)widthPtr; - (void)heightPtr; LabelframeStyleOptions(lframePtr, &style); /* Compute base margins (See also: FrameMargins) */ @@ -458,11 +460,11 @@ Ttk_PlaceLayout(corePtr->layout, corePtr->state, borderParcel); if (lframePtr->label.labelLayout) { Ttk_PlaceLayout( lframePtr->label.labelLayout, corePtr->state, labelParcel); } - /* labelWidget placed in LabelframePlaceSlaves GM hook */ + /* labelWidget placed in LabelframePlaceContent GM hook */ lframePtr->label.labelParcel = labelParcel; } static void LabelframeDisplay(void *recordPtr, Drawable d) { @@ -474,66 +476,67 @@ } /* +++ Labelframe geometry manager hooks. */ -/* LabelframePlaceSlaves -- +/* LabelframePlaceContent -- * Sets the position and size of the labelwidget. */ -static void LabelframePlaceSlaves(void *recordPtr) +static void LabelframePlaceContent(void *recordPtr) { Labelframe *lframe = (Labelframe *)recordPtr; - if (Ttk_NumberSlaves(lframe->label.mgr) == 1) { + if (Ttk_NumberContent(lframe->label.mgr) == 1) { Ttk_Box b; LabelframeDoLayout(recordPtr); b = lframe->label.labelParcel; - /* ASSERT: slave #0 is lframe->label.labelWidget */ - Ttk_PlaceSlave(lframe->label.mgr, 0, b.x,b.y,b.width,b.height); + /* ASSERT: content #0 is lframe->label.labelWidget */ + Ttk_PlaceContent(lframe->label.mgr, 0, b.x,b.y,b.width,b.height); } } -static int LabelRequest(void *managerData, TkSizeT index, int width, int height) +static int LabelRequest( + TCL_UNUSED(void *), + TCL_UNUSED(TkSizeT), + TCL_UNUSED(int), + TCL_UNUSED(int)) { - (void)managerData; - (void)index; - (void)width; - (void)height; - return 1; } /* LabelRemoved -- * Unset the -labelwidget option. * * <>: * This routine is also called when the widget voluntarily forgets - * the slave in LabelframeConfigure. + * the window in LabelframeConfigure. */ -static void LabelRemoved(void *managerData, TkSizeT slaveIndex) +static void LabelRemoved( + void *managerData, + TCL_UNUSED(TkSizeT)) { Labelframe *lframe = (Labelframe *)managerData; - (void)slaveIndex; lframe->label.labelWidget = 0; } static Ttk_ManagerSpec LabelframeManagerSpec = { - { "labelframe", Ttk_GeometryRequestProc, Ttk_LostSlaveProc }, + { "labelframe", Ttk_GeometryRequestProc, Ttk_LostContentProc }, LabelframeSize, - LabelframePlaceSlaves, + LabelframePlaceContent, LabelRequest, LabelRemoved }; /* LabelframeInitialize -- * Initialization hook. */ -static void LabelframeInitialize(Tcl_Interp *dummy, void *recordPtr) +static void LabelframeInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Labelframe *lframe = (Labelframe *)recordPtr; - (void)dummy; lframe->label.mgr = Ttk_CreateManager( &LabelframeManagerSpec, lframe, lframe->core.tkwin); lframe->label.labelWidget = 0; lframe->label.labelLayout = 0; @@ -601,19 +604,19 @@ } /* Update -labelwidget changes, if any: */ if (mask & LABELWIDGET_CHANGED) { - if (Ttk_NumberSlaves(lframePtr->label.mgr) == 1) { - Ttk_ForgetSlave(lframePtr->label.mgr, 0); + if (Ttk_NumberContent(lframePtr->label.mgr) == 1) { + Ttk_ForgetContent(lframePtr->label.mgr, 0); /* Restore labelWidget field (see <>) */ lframePtr->label.labelWidget = labelWidget; } if (labelWidget) { - Ttk_InsertSlave(lframePtr->label.mgr, 0, labelWidget, NULL); + Ttk_InsertContent(lframePtr->label.mgr, 0, labelWidget, NULL); RaiseLabelWidget(lframePtr); } } if (mask & GEOMETRY_CHANGED) { Index: generic/ttk/ttkImage.c ================================================================== --- generic/ttk/ttkImage.c +++ generic/ttk/ttkImage.c @@ -1,10 +1,10 @@ /* * Image specifications and image element factory. * - * Copyright (C) 2004 Pat Thoyts - * Copyright (C) 2004 Joe English + * Copyright © 2004 Pat Thoyts + * Copyright © 2004 Joe English * * An imageSpec is a multi-element list; the first element * is the name of the default image to use, the remainder of the * list is a sequence of statespec/imagename options as per * [style map]. @@ -261,21 +261,21 @@ int minHeight; /* Minimum width; overrides image width */ Ttk_Sticky sticky; /* -stickiness specification */ Ttk_Padding border; /* Fixed border region */ Ttk_Padding padding; /* Internal padding */ -#if TILE_07_COMPAT +#ifdef TILE_07_COMPAT Ttk_ResourceCache cache; /* Resource cache for images */ Ttk_StateMap imageMap; /* State-based lookup table for images */ #endif } ImageData; static void FreeImageData(void *clientData) { ImageData *imageData = (ImageData *)clientData; if (imageData->imageSpec) { TtkFreeImageSpec(imageData->imageSpec); } -#if TILE_07_COMPAT +#ifdef TILE_07_COMPAT if (imageData->imageMap) { Tcl_DecrRefCount(imageData->imageMap); } #endif ckfree(clientData); } @@ -309,11 +309,11 @@ Tk_Image image = 0; int imgWidth, imgHeight; Ttk_Box src, dst; (void)elementRecord; -#if TILE_07_COMPAT +#ifdef TILE_07_COMPAT if (imageData->imageMap) { Tcl_Obj *imageObj = Ttk_StateMapLookup(NULL,imageData->imageMap,state); if (imageObj) { image = Ttk_UseImage(imageData->cache, tkwin, imageObj); } @@ -381,11 +381,11 @@ imageData = (ImageData *)ckalloc(sizeof(*imageData)); imageData->imageSpec = imageSpec; imageData->minWidth = imageData->minHeight = -1; imageData->sticky = TTK_FILL_BOTH; imageData->border = imageData->padding = Ttk_UniformPadding(0); -#if TILE_07_COMPAT +#ifdef TILE_07_COMPAT imageData->cache = Ttk_GetResourceCache(interp); imageData->imageMap = 0; #endif for (i = 1; i < objc; i += 2) { @@ -396,11 +396,11 @@ "Value for %s missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TTK", "IMAGE", "VALUE", NULL); goto error; } -#if TILE_07_COMPAT +#ifdef TILE_07_COMPAT if (!strcmp("-map", Tcl_GetString(objv[i]))) { imageData->imageMap = objv[i+1]; Tcl_IncrRefCount(imageData->imageMap); continue; } Index: generic/ttk/ttkInit.c ================================================================== --- generic/ttk/ttkInit.c +++ generic/ttk/ttkInit.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003 Joe English * * Ttk package: initialization routine and miscellaneous utilities. */ #include "tkInt.h" @@ -122,32 +122,10 @@ break; } # undef SETFLAGS } -/* TtkSendVirtualEvent -- - * Send a virtual event notification to the specified target window. - * Equivalent to "event generate $tgtWindow <<$eventName>>" - * - * Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent, - * so this routine does not reenter the interpreter. - */ -void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName) -{ - union {XEvent general; XVirtualEvent virt;} event; - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(tgtWin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(tgtWin); - event.general.xany.display = Tk_Display(tgtWin); - event.virt.name = Tk_GetUid(eventName); - - Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); -} - /* TtkEnumerateOptions, TtkGetOptionValue -- * Common factors for data accessor commands. */ int TtkEnumerateOptions( Tcl_Interp *interp, void *recordPtr, const Tk_OptionSpec *specPtr, @@ -291,11 +269,14 @@ RegisterWidgets(interp); RegisterThemes(interp); Ttk_PlatformInit(interp); +#ifndef TK_NO_DEPRECATED Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs); +#endif + Tcl_PkgProvideEx(interp, "ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs); return TCL_OK; } /*EOF*/ Index: generic/ttk/ttkLabel.c ================================================================== --- generic/ttk/ttkLabel.c +++ generic/ttk/ttkLabel.c @@ -567,17 +567,19 @@ if (c->compound != TTK_COMPOUND_IMAGE) TextCleanup(&c->text); } static void LabelElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { LabelElement *label = (LabelElement *)elementRecord; int textReqWidth = 0; - (void)dummy; - (void)paddingPtr; LabelSetup(label, tkwin, 0); *heightPtr = label->totalHeight; @@ -626,16 +628,19 @@ ImageDraw(&l->image,tkwin,d,imageBox,state); TextDraw(&l->text,tkwin,d,textBox); } static void LabelElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, Ttk_State state) + TCL_UNUSED(void *), + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { LabelElement *l = (LabelElement *)elementRecord; Tk_Anchor anchor = TK_ANCHOR_CENTER; - (void)dummy; LabelSetup(l, tkwin, state); /* * Adjust overall parcel based on -anchor: Index: generic/ttk/ttkLayout.c ================================================================== --- generic/ttk/ttkLayout.c +++ generic/ttk/ttkLayout.c @@ -1,11 +1,11 @@ /* * ttkLayout.c -- * * Generic layout processing. * - * Copyright (c) 2003 Joe English. Freely redistributable. + * Copyright © 2003 Joe English. Freely redistributable. */ #include "tkInt.h" #include "ttkThemeInt.h" @@ -34,14 +34,14 @@ Tcl_Obj * Ttk_NewBoxObj(Ttk_Box box) { Tcl_Obj *result[4]; - result[0] = Tcl_NewIntObj(box.x); - result[1] = Tcl_NewIntObj(box.y); - result[2] = Tcl_NewIntObj(box.width); - result[3] = Tcl_NewIntObj(box.height); + result[0] = Tcl_NewWideIntObj(box.x); + result[1] = Tcl_NewWideIntObj(box.y); + result[2] = Tcl_NewWideIntObj(box.width); + result[3] = Tcl_NewWideIntObj(box.height); return Tcl_NewListObj(4, result); } /* @@ -807,11 +807,11 @@ */ APPENDSTR("-sticky"); APPENDOBJ(Ttk_NewStickyObj(flags & _TTK_MASK_STICK)); - /* @@@ Check again: are these necessary? */ + /* @@@ Check again: are these necessary? Can't see any effect! */ if (flags & TTK_BORDER) { APPENDSTR("-border"); APPENDSTR("1"); } if (flags & TTK_UNIT) { APPENDSTR("-unit"); APPENDSTR("1"); } if (node->child) { APPENDSTR("-children"); Index: generic/ttk/ttkManager.c ================================================================== --- generic/ttk/ttkManager.c +++ generic/ttk/ttkManager.c @@ -8,63 +8,63 @@ #include "ttkManager.h" /*------------------------------------------------------------------------ * +++ The Geometry Propagation Dance. * - * When a slave window requests a new size or some other parameter changes, - * the manager recomputes the required size for the master window and calls + * When a content window requests a new size or some other parameter changes, + * the manager recomputes the required size for the container window and calls * Tk_GeometryRequest(). This is scheduled as an idle handler so multiple * updates can be processed as a single batch. * - * If all goes well, the master's manager will process the request - * (and so on up the chain to the toplevel window), and the master + * If all goes well, the container's manager will process the request + * (and so on up the chain to the toplevel window), and the container * window will eventually receive a event. At this point - * it recomputes the size and position of all slaves and places them. + * it recomputes the size and position of all content windows and places them. * - * If all does not go well, however, the master's request may be ignored + * If all does not go well, however, the container's request may be ignored * (typically because the top-level window has a fixed, user-specified size). * Tk doesn't provide any notification when this happens; to account for this, * we also schedule an idle handler to call the layout procedure * after making a geometry request. * - * +++ Slave removal <>. + * +++ Content window removal <>. * - * There are three conditions under which a slave is removed: + * There are three conditions under which a content window is removed: * * (1) Another GM claims control * (2) Manager voluntarily relinquishes control - * (3) Slave is destroyed + * (3) Content window is destroyed * - * In case (1), Tk calls the manager's lostSlaveProc. - * Case (2) is performed by calling Tk_ManageGeometry(slave,NULL,0); - * in this case Tk does _not_ call the LostSlaveProc (documented behavior). + * In case (1), Tk calls the manager's lostContentProc. + * Case (2) is performed by calling Tk_ManageGeometry(window,NULL,0); + * in this case Tk does _not_ call the lostContentProc (documented behavior). * Tk doesn't handle case (3) either; to account for that we - * register an event handler on the slave widget to track events. + * register an event handler on the content window to track events. */ /* ++ Data structures. */ typedef struct { - Tk_Window slaveWindow; + Tk_Window window; Ttk_Manager *manager; - void *slaveData; + void *data; unsigned flags; -} Ttk_Slave; +} Ttk_Content; -/* slave->flags bits: +/* content->flags bits: */ -#define SLAVE_MAPPED 0x1 /* slave to be mapped when master is */ +#define CONTENT_MAPPED 0x1 /* content windows to be mapped when container is */ struct TtkManager_ { Ttk_ManagerSpec *managerSpec; void *managerData; - Tk_Window masterWindow; + Tk_Window window; unsigned flags; - TkSizeT nSlaves; - Ttk_Slave **slaves; + TkSizeT nContent; + Ttk_Content **content; }; /* manager->flags bits: */ #define MGR_UPDATE_PENDING 0x1 @@ -85,30 +85,30 @@ } mgr->flags |= flags; } /* ++ RecomputeSize -- - * Recomputes the required size of the master window, + * Recomputes the required size of the container window, * makes geometry request. */ static void RecomputeSize(Ttk_Manager *mgr) { int width = 1, height = 1; if (mgr->managerSpec->RequestedSize(mgr->managerData, &width, &height)) { - Tk_GeometryRequest(mgr->masterWindow, width, height); + Tk_GeometryRequest(mgr->window, width, height); ScheduleUpdate(mgr, MGR_RELAYOUT_REQUIRED); } mgr->flags &= ~MGR_RESIZE_REQUIRED; } /* ++ RecomputeLayout -- - * Recompute geometry of all slaves. + * Recompute geometry of all content windows. */ static void RecomputeLayout(Ttk_Manager *mgr) { - mgr->managerSpec->PlaceSlaves(mgr->managerData); + mgr->managerSpec->PlaceContent(mgr->managerData); mgr->flags &= ~MGR_RELAYOUT_REQUIRED; } /* ++ ManagerIdleProc -- * DoWhenIdle procedure for deferred updates. @@ -133,12 +133,12 @@ /*------------------------------------------------------------------------ * +++ Event handlers. */ /* ++ ManagerEventHandler -- - * Recompute slave layout when master widget is resized. - * Keep the slave's map state in sync with the master's. + * Recompute content layout when container widget is resized. + * Keep the content's map state in sync with the container's. */ static const int ManagerEventMask = StructureNotifyMask; static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; @@ -148,248 +148,247 @@ { case ConfigureNotify: RecomputeLayout(mgr); break; case MapNotify: - for (i = 0; i < mgr->nSlaves; ++i) { - Ttk_Slave *slave = mgr->slaves[i]; - if (slave->flags & SLAVE_MAPPED) { - Tk_MapWindow(slave->slaveWindow); - } - } - break; - case UnmapNotify: - for (i = 0; i < mgr->nSlaves; ++i) { - Ttk_Slave *slave = mgr->slaves[i]; - Tk_UnmapWindow(slave->slaveWindow); - } - break; - } -} - -/* ++ SlaveEventHandler -- - * Notifies manager when a slave is destroyed - * (see <>). - */ -static const unsigned SlaveEventMask = StructureNotifyMask; -static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr) -{ - Ttk_Slave *slave = (Ttk_Slave *)clientData; - if (eventPtr->type == DestroyNotify) { - slave->manager->managerSpec->tkGeomMgr.lostSlaveProc( - slave->manager, slave->slaveWindow); - } -} - -/*------------------------------------------------------------------------ - * +++ Slave initialization and cleanup. - */ - -static Ttk_Slave *NewSlave( - Ttk_Manager *mgr, Tk_Window slaveWindow, void *slaveData) -{ - Ttk_Slave *slave = (Ttk_Slave *)ckalloc(sizeof(*slave)); - - slave->slaveWindow = slaveWindow; - slave->manager = mgr; - slave->flags = 0; - slave->slaveData = slaveData; - - return slave; -} - -static void DeleteSlave(Ttk_Slave *slave) -{ - ckfree(slave); + for (i = 0; i < mgr->nContent; ++i) { + Ttk_Content *content = mgr->content[i]; + if (content->flags & CONTENT_MAPPED) { + Tk_MapWindow(content->window); + } + } + break; + case UnmapNotify: + for (i = 0; i < mgr->nContent; ++i) { + Ttk_Content *content = mgr->content[i]; + Tk_UnmapWindow(content->window); + } + break; + } +} + +/* ++ ContentLostEventHandler -- + * Notifies manager when a content window is destroyed + * (see <>). + */ +static void ContentLostEventHandler(void *clientData, XEvent *eventPtr) +{ + Ttk_Content *content = (Ttk_Content *)clientData; + if (eventPtr->type == DestroyNotify) { + content->manager->managerSpec->tkGeomMgr.lostContentProc( + content->manager, content->window); + } +} + +/*------------------------------------------------------------------------ + * +++ Content initialization and cleanup. + */ + +static Ttk_Content *NewContent( + Ttk_Manager *mgr, Tk_Window window, void *data) +{ + Ttk_Content *content = (Ttk_Content *)ckalloc(sizeof(Ttk_Content)); + + content->window = window; + content->manager = mgr; + content->flags = 0; + content->data = data; + + return content; +} + +static void DeleteContent(Ttk_Content *content) +{ + ckfree(content); } /*------------------------------------------------------------------------ * +++ Manager initialization and cleanup. */ Ttk_Manager *Ttk_CreateManager( - Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window masterWindow) + Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)ckalloc(sizeof(*mgr)); mgr->managerSpec = managerSpec; mgr->managerData = managerData; - mgr->masterWindow = masterWindow; - mgr->nSlaves = 0; - mgr->slaves = NULL; + mgr->window = window; + mgr->nContent = 0; + mgr->content = NULL; mgr->flags = 0; Tk_CreateEventHandler( - mgr->masterWindow, ManagerEventMask, ManagerEventHandler, mgr); + mgr->window, ManagerEventMask, ManagerEventHandler, mgr); return mgr; } void Ttk_DeleteManager(Ttk_Manager *mgr) { Tk_DeleteEventHandler( - mgr->masterWindow, ManagerEventMask, ManagerEventHandler, mgr); + mgr->window, ManagerEventMask, ManagerEventHandler, mgr); - while (mgr->nSlaves > 0) { - Ttk_ForgetSlave(mgr, mgr->nSlaves - 1); + while (mgr->nContent > 0) { + Ttk_ForgetContent(mgr, mgr->nContent - 1); } - if (mgr->slaves) { - ckfree(mgr->slaves); + if (mgr->content) { + ckfree(mgr->content); } Tcl_CancelIdleCall(ManagerIdleProc, mgr); ckfree(mgr); } /*------------------------------------------------------------------------ - * +++ Slave management. - */ - -/* ++ InsertSlave -- - * Adds slave to the list of managed windows. - */ -static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, TkSizeT index) -{ - TkSizeT endIndex = mgr->nSlaves++; - mgr->slaves = (Ttk_Slave **)ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *)); + * +++ Content window management. + */ + +/* ++ InsertContent -- + * Adds content to the list of managed windows. + */ +static void InsertContent(Ttk_Manager *mgr, Ttk_Content *content, TkSizeT index) +{ + TkSizeT endIndex = mgr->nContent++; + mgr->content = (Ttk_Content **)ckrealloc(mgr->content, mgr->nContent * sizeof(Ttk_Content *)); while (endIndex > index) { - mgr->slaves[endIndex] = mgr->slaves[endIndex - 1]; + mgr->content[endIndex] = mgr->content[endIndex - 1]; --endIndex; } - mgr->slaves[index] = slave; + mgr->content[index] = content; - Tk_ManageGeometry(slave->slaveWindow, - &mgr->managerSpec->tkGeomMgr, (ClientData)mgr); + Tk_ManageGeometry(content->window, + &mgr->managerSpec->tkGeomMgr, mgr); - Tk_CreateEventHandler(slave->slaveWindow, - SlaveEventMask, SlaveEventHandler, (ClientData)slave); + Tk_CreateEventHandler(content->window, + StructureNotifyMask, ContentLostEventHandler, content); ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } -/* RemoveSlave -- - * Unmanage and delete the slave. +/* RemoveContent -- + * Unmanage and delete the content window. * * NOTES/ASSUMPTIONS: * * [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this - * routine is called from the slave's DestroyNotify event handler. + * routine is called from the content window's DestroyNotify event handler. */ -static void RemoveSlave(Ttk_Manager *mgr, TkSizeT index) +static void RemoveContent(Ttk_Manager *mgr, TkSizeT index) { - Ttk_Slave *slave = mgr->slaves[index]; + Ttk_Content *content = mgr->content[index]; TkSizeT i; /* Notify manager: */ - mgr->managerSpec->SlaveRemoved(mgr->managerData, index); + mgr->managerSpec->ContentRemoved(mgr->managerData, index); /* Remove from array: */ - --mgr->nSlaves; - for (i = index ; i < mgr->nSlaves; ++i) { - mgr->slaves[i] = mgr->slaves[i+1]; + --mgr->nContent; + for (i = index ; i < mgr->nContent; ++i) { + mgr->content[i] = mgr->content[i+1]; } /* Clean up: */ Tk_DeleteEventHandler( - slave->slaveWindow, SlaveEventMask, SlaveEventHandler, slave); + content->window, StructureNotifyMask, ContentLostEventHandler, content); /* Note [1] */ - Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow); - Tk_UnmapWindow(slave->slaveWindow); + Tk_UnmaintainGeometry(content->window, mgr->window); + Tk_UnmapWindow(content->window); - DeleteSlave(slave); + DeleteContent(content); ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } /*------------------------------------------------------------------------ * +++ Tk_GeomMgr hooks. */ -void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow) +void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; - int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow); - int reqWidth = Tk_ReqWidth(slaveWindow); - int reqHeight= Tk_ReqHeight(slaveWindow); + TkSizeT index = Ttk_ContentIndex(mgr, window); + int reqWidth = Tk_ReqWidth(window); + int reqHeight= Tk_ReqHeight(window); - if (mgr->managerSpec->SlaveRequest( - mgr->managerData, slaveIndex, reqWidth, reqHeight)) + if (mgr->managerSpec->ContentRequest( + mgr->managerData, index, reqWidth, reqHeight)) { ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } } -void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow) +void Ttk_LostContentProc(ClientData clientData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; - int index = Ttk_SlaveIndex(mgr, slaveWindow); + TkSizeT index = Ttk_ContentIndex(mgr, window); /* ASSERT: index >= 0 */ - RemoveSlave(mgr, index); + RemoveContent(mgr, index); } /*------------------------------------------------------------------------ * +++ Public API. */ -/* ++ Ttk_InsertSlave -- - * Add a new slave window at the specified index. - */ -void Ttk_InsertSlave( - Ttk_Manager *mgr, TkSizeT index, Tk_Window tkwin, void *slaveData) -{ - Ttk_Slave *slave = NewSlave(mgr, tkwin, slaveData); - InsertSlave(mgr, slave, index); -} - -/* ++ Ttk_ForgetSlave -- - * Unmanage the specified slave. - */ -void Ttk_ForgetSlave(Ttk_Manager *mgr, TkSizeT slaveIndex) -{ - Tk_Window slaveWindow = mgr->slaves[slaveIndex]->slaveWindow; - RemoveSlave(mgr, slaveIndex); - Tk_ManageGeometry(slaveWindow, NULL, 0); -} - -/* ++ Ttk_PlaceSlave -- - * Set the position and size of the specified slave window. +/* ++ Ttk_InsertContent -- + * Add a new content window at the specified index. + */ +void Ttk_InsertContent( + Ttk_Manager *mgr, TkSizeT index, Tk_Window tkwin, void *data) +{ + Ttk_Content *content = NewContent(mgr, tkwin, data); + InsertContent(mgr, content, index); +} + +/* ++ Ttk_ForgetContent -- + * Unmanage the specified content window. + */ +void Ttk_ForgetContent(Ttk_Manager *mgr, TkSizeT index) +{ + Tk_Window window = mgr->content[index]->window; + RemoveContent(mgr, index); + Tk_ManageGeometry(window, NULL, 0); +} + +/* ++ Ttk_PlaceContent -- + * Set the position and size of the specified content window. * * NOTES: * Contrary to documentation, Tk_MaintainGeometry doesn't always - * map the slave. - */ -void Ttk_PlaceSlave( - Ttk_Manager *mgr, TkSizeT slaveIndex, int x, int y, int width, int height) -{ - Ttk_Slave *slave = mgr->slaves[slaveIndex]; - Tk_MaintainGeometry(slave->slaveWindow,mgr->masterWindow,x,y,width,height); - slave->flags |= SLAVE_MAPPED; - if (Tk_IsMapped(mgr->masterWindow)) { - Tk_MapWindow(slave->slaveWindow); + * map the content window. + */ +void Ttk_PlaceContent( + Ttk_Manager *mgr, TkSizeT index, int x, int y, int width, int height) +{ + Ttk_Content *content = mgr->content[index]; + Tk_MaintainGeometry(content->window,mgr->window,x,y,width,height); + content->flags |= CONTENT_MAPPED; + if (Tk_IsMapped(mgr->window)) { + Tk_MapWindow(content->window); } } -/* ++ Ttk_UnmapSlave -- - * Unmap the specified slave, but leave it managed. - */ -void Ttk_UnmapSlave(Ttk_Manager *mgr, TkSizeT slaveIndex) -{ - Ttk_Slave *slave = mgr->slaves[slaveIndex]; - Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow); - slave->flags &= ~SLAVE_MAPPED; +/* ++ Ttk_UnmapContent -- + * Unmap the specified content window, but leave it managed. + */ +void Ttk_UnmapContent(Ttk_Manager *mgr, TkSizeT index) +{ + Ttk_Content *content = mgr->content[index]; + Tk_UnmaintainGeometry(content->window, mgr->window); + content->flags &= ~CONTENT_MAPPED; /* Contrary to documentation, Tk_UnmaintainGeometry doesn't always - * unmap the slave: + * unmap the content window: */ - Tk_UnmapWindow(slave->slaveWindow); + Tk_UnmapWindow(content->window); } /* LayoutChanged, SizeChanged -- * Schedule a relayout, resp. resize request. */ @@ -403,134 +402,132 @@ ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } /* +++ Accessors. */ -TkSizeT Ttk_NumberSlaves(Ttk_Manager *mgr) -{ - return mgr->nSlaves; -} -void *Ttk_SlaveData(Ttk_Manager *mgr, TkSizeT slaveIndex) -{ - return mgr->slaves[slaveIndex]->slaveData; -} -Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, TkSizeT slaveIndex) -{ - return mgr->slaves[slaveIndex]->slaveWindow; +TkSizeT Ttk_NumberContent(Ttk_Manager *mgr) +{ + return mgr->nContent; +} +void *Ttk_ContentData(Ttk_Manager *mgr, TkSizeT index) +{ + return mgr->content[index]->data; +} +Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, TkSizeT index) +{ + return mgr->content[index]->window; } /*------------------------------------------------------------------------ * +++ Utility routines. */ -/* ++ Ttk_SlaveIndex -- - * Returns the index of specified slave window, -1 if not found. +/* ++ Ttk_ContentIndex -- + * Returns the index of specified content window, -1 if not found. */ -TkSizeT Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow) +TkSizeT Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window) { TkSizeT index; - for (index = 0; index < mgr->nSlaves; ++index) - if (mgr->slaves[index]->slaveWindow == slaveWindow) + for (index = 0; index < mgr->nContent; ++index) + if (mgr->content[index]->window == window) return index; return TCL_INDEX_NONE; } -/* ++ Ttk_GetSlaveIndexFromObj(interp, mgr, objPtr, indexPtr) -- - * Return the index of the slave specified by objPtr. - * Slaves may be specified as an integer index or +/* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, indexPtr) -- + * Return the index of the content window specified by objPtr. + * Content windows may be specified as an integer index or * as the name of the managed window. * * Returns: * Standard Tcl completion code. Leaves an error message in case of error. */ -int Ttk_GetSlaveIndexFromObj( - Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, TkSizeT *indexPtr) -{ - const char *string = Tcl_GetString(objPtr); - TkSizeT slaveIndex = 0; - TkSizeT idx; - Tk_Window tkwin; - - /* Try interpreting as an integer first: - */ - if (TkGetIntForIndex(objPtr, mgr->nSlaves - 1, 1, &idx) == TCL_OK) { - slaveIndex = idx; - if ((size_t)slaveIndex > (size_t)mgr->nSlaves) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Slave index %d out of bounds", (int)slaveIndex)); - Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); - return TCL_ERROR; - } - *indexPtr = slaveIndex; - return TCL_OK; - } - - /* Try interpreting as a slave window name; - */ - if ((*string == '.') && - (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow))) { - slaveIndex = Ttk_SlaveIndex(mgr, tkwin); - if (slaveIndex == TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "%s is not managed by %s", string, - Tk_PathName(mgr->masterWindow))); - Tcl_SetErrorCode(interp, "TTK", "SLAVE", "MANAGER", NULL); - return TCL_ERROR; - } - *indexPtr = slaveIndex; - return TCL_OK; - } - - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Invalid slave specification %s", string)); - Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL); - return TCL_ERROR; -} - -/* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) -- - * Change slave order. - */ -void Ttk_ReorderSlave(Ttk_Manager *mgr, TkSizeT fromIndex, TkSizeT toIndex) -{ - Ttk_Slave *moved = mgr->slaves[fromIndex]; - - /* Shuffle down: */ - while (fromIndex > toIndex) { - mgr->slaves[fromIndex] = mgr->slaves[fromIndex - 1]; - --fromIndex; - } - /* Or, shuffle up: */ - while (fromIndex < toIndex) { - mgr->slaves[fromIndex] = mgr->slaves[fromIndex + 1]; - ++fromIndex; - } - /* ASSERT: fromIndex == toIndex */ - mgr->slaves[fromIndex] = moved; - - /* Schedule a relayout. In general, rearranging slaves +int Ttk_GetContentIndexFromObj( + Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, TkSizeT *indexPtr) +{ + const char *string = Tcl_GetString(objPtr); + TkSizeT index = 0; + Tk_Window tkwin; + + /* Try interpreting as an integer first: + */ + if (TkGetIntForIndex(objPtr, mgr->nContent - 1, 1, &index) == TCL_OK) { + if (index + 1 > mgr->nContent + 1) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Managed window index %d out of bounds", (int)index)); + Tcl_SetErrorCode(interp, "TTK", "MANAGED", "INDEX", NULL); + return TCL_ERROR; + } + *indexPtr = index; + return TCL_OK; + } + + /* Try interpreting as a window name; + */ + if ((*string == '.') && + (tkwin = Tk_NameToWindow(interp, string, mgr->window))) { + index = Ttk_ContentIndex(mgr, tkwin); + if (index == TCL_INDEX_NONE) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "%s is not managed by %s", string, + Tk_PathName(mgr->window))); + Tcl_SetErrorCode(interp, "TTK", "MANAGED", "MANAGER", NULL); + return TCL_ERROR; + } + *indexPtr = index; + return TCL_OK; + } + + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Invalid managed window specification %s", string)); + Tcl_SetErrorCode(interp, "TTK", "MANAGED", "SPEC", NULL); + return TCL_ERROR; +} + +/* ++ Ttk_ReorderContent(mgr, fromIndex, toIndex) -- + * Change content window order. + */ +void Ttk_ReorderContent(Ttk_Manager *mgr, TkSizeT fromIndex, TkSizeT toIndex) +{ + Ttk_Content *moved = mgr->content[fromIndex]; + + /* Shuffle down: */ + while (fromIndex > toIndex) { + mgr->content[fromIndex] = mgr->content[fromIndex - 1]; + --fromIndex; + } + /* Or, shuffle up: */ + while (fromIndex < toIndex) { + mgr->content[fromIndex] = mgr->content[fromIndex + 1]; + ++fromIndex; + } + /* ASSERT: fromIndex == toIndex */ + mgr->content[fromIndex] = moved; + + /* Schedule a relayout. In general, rearranging content * may also change the size: */ ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } -/* ++ Ttk_Maintainable(interp, slave, master) -- - * Utility routine. Verifies that 'master' may be used to maintain - * the geometry of 'slave' via Tk_MaintainGeometry: - * - * + 'master' is either 'slave's parent -OR- - * + 'master is a descendant of 'slave's parent. - * + 'slave' is not a toplevel window - * + 'slave' belongs to the same toplevel as 'master' +/* ++ Ttk_Maintainable(interp, window, container) -- + * Utility routine. Verifies that 'container' may be used to maintain + * the geometry of 'window' via Tk_MaintainGeometry: + * + * + 'container' is either 'window's parent -OR- + * + 'container is a descendant of 'window's parent. + * + 'window' is not a toplevel window + * + 'window' belongs to the same toplevel as 'container' * * Returns: 1 if OK; otherwise 0, leaving an error message in 'interp'. */ -int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window slave, Tk_Window master) +int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window window, Tk_Window container) { - Tk_Window ancestor = master, parent = Tk_Parent(slave); + Tk_Window ancestor = container, parent = Tk_Parent(window); - if (Tk_IsTopLevel(slave) || slave == master) { + if (Tk_IsTopLevel(window) || window == container) { goto badWindow; } while (ancestor != parent) { if (Tk_IsTopLevel(ancestor)) { @@ -540,11 +537,11 @@ } return 1; badWindow: - Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s", - Tk_PathName(slave), Tk_PathName(master))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as content of %s", + Tk_PathName(window), Tk_PathName(container))); Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL); return 0; } Index: generic/ttk/ttkManager.h ================================================================== --- generic/ttk/ttkManager.h +++ generic/ttk/ttkManager.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2005, Joe English. Freely redistributable. + * Copyright © 2005 Joe English. Freely redistributable. * * Geometry manager utilities. */ #ifndef _TTKMANAGER @@ -12,81 +12,92 @@ typedef struct TtkManager_ Ttk_Manager; /* * Geometry manager specification record: * - * RequestedSize computes the requested size of the master window. + * RequestedSize computes the requested size of the container window. * - * PlaceSlaves sets the position and size of all managed slaves - * by calling Ttk_PlaceSlave(). + * PlaceContent sets the position and size of all managed content windows + * by calling Ttk_PlaceContent(). * - * SlaveRemoved() is called immediately before a slave is removed. - * NB: the associated slave window may have been destroyed when this + * ContentRemoved() is called immediately before a content window is removed. + * NB: the associated content window may have been destroyed when this * routine is called. * - * SlaveRequest() is called when a slave requests a size change. + * ContentRequest() is called when a content window requests a size change. * It should return 1 if the request should propagate, 0 otherwise. */ typedef struct { /* Manager hooks */ Tk_GeomMgr tkGeomMgr; /* "real" Tk Geometry Manager */ int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr); - void (*PlaceSlaves)(void *managerData); - int (*SlaveRequest)(void *managerData, TkSizeT slaveIndex, int w, int h); - void (*SlaveRemoved)(void *managerData, TkSizeT slaveIndex); + void (*PlaceContent)(void *managerData); + int (*ContentRequest)(void *managerData, TkSizeT index, int w, int h); + void (*ContentRemoved)(void *managerData, TkSizeT index); } Ttk_ManagerSpec; /* * Default implementations for Tk_GeomMgr hooks: */ -MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window slave); -MODULE_SCOPE void Ttk_LostSlaveProc(ClientData, Tk_Window slave); +#define Ttk_LostSlaveProc Ttk_LostContentProc +MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window window); +MODULE_SCOPE void Ttk_LostContentProc(ClientData, Tk_Window window); /* * Public API: */ MODULE_SCOPE Ttk_Manager *Ttk_CreateManager( - Ttk_ManagerSpec *, void *managerData, Tk_Window masterWindow); + Ttk_ManagerSpec *, void *managerData, Tk_Window window); MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *); -MODULE_SCOPE void Ttk_InsertSlave( - Ttk_Manager *, TkSizeT position, Tk_Window, void *slaveData); - -MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, TkSizeT slaveIndex); - -MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, TkSizeT fromIndex, TkSizeT toIndex); - /* Rearrange slave positions */ - -MODULE_SCOPE void Ttk_PlaceSlave( - Ttk_Manager *, TkSizeT slaveIndex, int x, int y, int width, int height); - /* Position and map the slave */ - -MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, TkSizeT slaveIndex); - /* Unmap the slave */ +#define Ttk_InsertSlave Ttk_InsertContent +MODULE_SCOPE void Ttk_InsertContent( + Ttk_Manager *, TkSizeT position, Tk_Window, void *clientData); + +#define Ttk_ForgetSlave Ttk_ForgetContent +MODULE_SCOPE void Ttk_ForgetContent(Ttk_Manager *, TkSizeT index); + +#define Ttk_ReorderSlave Ttk_ReorderContent +MODULE_SCOPE void Ttk_ReorderContent(Ttk_Manager *, TkSizeT fromIndex, TkSizeT toIndex); + /* Rearrange content window positions */ + +#define Ttk_PlaceSlave Ttk_PlaceContent +MODULE_SCOPE void Ttk_PlaceContent( + Ttk_Manager *, TkSizeT index, int x, int y, int width, int height); + /* Position and map the content window */ + +#define Ttk_UnmapSlave Ttk_UnmapContent +MODULE_SCOPE void Ttk_UnmapContent(Ttk_Manager *, TkSizeT index); + /* Unmap the content window */ MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *); MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *); /* Notify manager that size (resp. layout) needs to be recomputed */ /* Utilities: */ -MODULE_SCOPE TkSizeT Ttk_SlaveIndex(Ttk_Manager *, Tk_Window); - /* Returns: index in slave array of specified window, -1 if not found */ +#define Ttk_SlaveIndex Ttk_ContentIndex +MODULE_SCOPE TkSizeT Ttk_ContentIndex(Ttk_Manager *, Tk_Window); + /* Returns: index in content array of specified window, TCL_INDEX_NONE if not found */ -MODULE_SCOPE int Ttk_GetSlaveIndexFromObj( +#define Ttk_GetSlaveIndexFromObj Ttk_GetContentIndexFromObj +MODULE_SCOPE int Ttk_GetContentIndexFromObj( Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, TkSizeT *indexPtr); /* Accessor functions: */ -MODULE_SCOPE TkSizeT Ttk_NumberSlaves(Ttk_Manager *); - /* Returns: number of managed slaves */ - -MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, TkSizeT slaveIndex); - /* Returns: client data associated with slave */ - -MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, TkSizeT slaveIndex); - /* Returns: slave window */ - -MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window slave, Tk_Window master); - /* Returns: 1 if master can manage slave; 0 otherwise leaving error msg */ +#define Ttk_NumberSlaves Ttk_NumberContent +MODULE_SCOPE TkSizeT Ttk_NumberContent(Ttk_Manager *); + /* Returns: number of managed content windows */ + +#define Ttk_SlaveData Ttk_ContentData +MODULE_SCOPE void *Ttk_ContentData(Ttk_Manager *, TkSizeT index); + /* Returns: client data associated with content window */ + +#define Ttk_SlaveWindow Ttk_ContentWindow +MODULE_SCOPE Tk_Window Ttk_ContentWindow(Ttk_Manager *, TkSizeT index); + /* Returns: content window */ + +MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window content, Tk_Window container); + /* Returns: 1 if container can manage content; 0 otherwise leaving error msg */ #endif /* _TTKMANAGER */ Index: generic/ttk/ttkNotebook.c ================================================================== --- generic/ttk/ttkNotebook.c +++ generic/ttk/ttkNotebook.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004 Joe English */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" @@ -51,35 +51,35 @@ /* Two different option tables are used for tabs: * TabOptionSpecs is used to draw the tab, and only includes resources * relevant to the tab. * * PaneOptionSpecs includes additional options for child window placement - * and is used to configure the slave. + * and is used to configure the pane. */ static const Tk_OptionSpec TabOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-state", "", "", "normal", TCL_INDEX_NONE, offsetof(Tab,state), - 0,(ClientData)TabStateStrings,0 }, + 0, (void *)TabStateStrings, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", - offsetof(Tab,textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,textObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/, - offsetof(Tab,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + offsetof(Tab,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-underline", "underline", "Underline", "-1", - offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } }; static const Tk_OptionSpec PaneOptionSpecs[] = { {TK_OPTION_STRING, "-padding", "padding", "Padding", "0", - offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-sticky", "sticky", "Sticky", "nsew", - offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, WIDGET_INHERIT_OPTIONS(TabOptionSpecs) }; /*------------------------------------------------------------------------ @@ -96,11 +96,11 @@ Tk_OptionTable paneOptionTable; /* Tab+pane options */ TkSizeT currentIndex; /* index of currently selected tab */ TkSizeT activeIndex; /* index of currently active tab */ Ttk_Layout tabLayout; /* Sublayout for tabs */ - Ttk_Box clientArea; /* Where to pack slave widgets */ + Ttk_Box clientArea; /* Where to pack content windows */ } NotebookPart; typedef struct { WidgetCore core; @@ -185,17 +185,17 @@ /*------------------------------------------------------------------------ * +++ Tab management. */ -static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow) +static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window window) { Tk_OptionTable optionTable = nb->notebook.paneOptionTable; Tab *record = (Tab *)ckalloc(sizeof(Tab)); memset(record, 0, sizeof(Tab)); - if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) { + if (Tk_InitOptions(interp, record, optionTable, window) != TCL_OK) { ckfree(record); return NULL; } return record; @@ -207,20 +207,20 @@ Tk_FreeConfigOptions(record, nb->notebook.paneOptionTable, nb->core.tkwin); ckfree(record); } static int ConfigureTab( - Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window slaveWindow, + Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Ttk_Sticky sticky = tab->sticky; Ttk_Padding padding = tab->padding; Tk_SavedOptions savedOptions; int mask = 0; if (Tk_SetOptions(interp, tab, nb->notebook.paneOptionTable, - objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) + objc, objv, window, &savedOptions, &mask) != TCL_OK) { return TCL_ERROR; } /* Check options: @@ -228,11 +228,11 @@ */ if (Ttk_GetStickyFromObj(interp, tab->stickyObj, &sticky) != TCL_OK) { goto error; } - if (Ttk_GetPaddingFromObj(interp, slaveWindow, tab->paddingObj, &padding) + if (Ttk_GetPaddingFromObj(interp, window, tab->paddingObj, &padding) != TCL_OK) { goto error; } @@ -255,12 +255,12 @@ * or -1 if no tab at that point. */ static TkSizeT IdentifyTab(Notebook *nb, int x, int y) { TkSizeT index; - for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,index); + for (index = 0; index < Ttk_NumberContent(nb->notebook.mgr); ++index) { + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,index); if ( tab->state != TAB_STATE_HIDDEN && Ttk_BoxContains(tab->parcel, x,y)) { return index; } @@ -288,11 +288,11 @@ * is set for the rightmost visible tab. */ static Ttk_State TabState(Notebook *nb, TkSizeT index) { Ttk_State state = nb->core.state; - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + Tab *itab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); TkSizeT i = 0; if (index == nb->notebook.currentIndex) { state |= TTK_STATE_SELECTED; } else { @@ -300,31 +300,31 @@ } if (index == nb->notebook.activeIndex) { state |= TTK_STATE_ACTIVE; } - for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); + for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) { + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i); if (tab->state == TAB_STATE_HIDDEN) { continue; } if (index == i) { state |= TTK_STATE_USER1; } break; } - for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i != TCL_INDEX_NONE; --i) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); + for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != TCL_INDEX_NONE; --i) { + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i); if (tab->state == TAB_STATE_HIDDEN) { continue; } if (index == i) { state |= TTK_STATE_USER2; } break; } - if (tab->state == TAB_STATE_DISABLED) { + if (itab->state == TAB_STATE_DISABLED) { state |= TTK_STATE_DISABLED; } return state; } @@ -351,12 +351,12 @@ { Ttk_Layout tabLayout = nb->notebook.tabLayout; int tabrowWidth = 0, tabrowHeight = 0; TkSizeT i; - for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); + for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) { + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i); Ttk_State tabState = TabState(nb,i); Ttk_RebindSublayout(tabLayout, tab); Ttk_LayoutSize(tabLayout,tabState,&tab->width,&tab->height); tab->width = MAX(tab->width, minTabWidth); @@ -376,11 +376,11 @@ /* NotebookSize -- GM and widget size hook. * * Total height is tab height + client area height + pane internal padding * Total width is max(client width, tab width) + pane internal padding - * Client area size determined by max size of slaves, + * Client area size determined by max size of content windows, * overridden by -width and/or -height if nonzero. */ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) { @@ -393,22 +393,22 @@ tabrowWidth = 0, tabrowHeight = 0; TkSizeT i; NotebookStyleOptions(nb, &nbstyle); - /* Compute max requested size of all slaves: + /* Compute max requested size of all content windows: */ - for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { - Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, i); - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); - int slaveWidth - = Tk_ReqWidth(slaveWindow) + Ttk_PaddingWidth(tab->padding); - int slaveHeight - = Tk_ReqHeight(slaveWindow) + Ttk_PaddingHeight(tab->padding); - - clientWidth = MAX(clientWidth, slaveWidth); - clientHeight = MAX(clientHeight, slaveHeight); + for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) { + Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, i); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i); + int width + = Tk_ReqWidth(window) + Ttk_PaddingWidth(tab->padding); + int height + = Tk_ReqHeight(window) + Ttk_PaddingHeight(tab->padding); + + clientWidth = MAX(clientWidth, width); + clientHeight = MAX(clientHeight, height); } /* Client width/height overridable by widget options: */ Tcl_GetIntFromObj(NULL, nb->notebook.widthObj,&reqWidth); @@ -459,20 +459,20 @@ */ static void SqueezeTabs( Notebook *nb, int needed, int available) { - int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); + int nTabs = Ttk_NumberContent(nb->notebook.mgr); if (nTabs > 0) { int difference = available - needed; double delta = (double)difference / needed; double slack = 0; int i; for (i = 0; i < nTabs; ++i) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,i); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,i); double ad = slack + tab->width * delta; tab->width += (int)ad; slack = ad - (int)ad; } } @@ -483,15 +483,15 @@ */ static void PlaceTabs( Notebook *nb, Ttk_Box tabrowBox, Ttk_PositionSpec tabPlacement) { Ttk_Layout tabLayout = nb->notebook.tabLayout; - int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); + int nTabs = Ttk_NumberContent(nb->notebook.mgr); int i; for (i = 0; i < nTabs; ++i) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i); Ttk_State tabState = TabState(nb, i); if (tab->state != TAB_STATE_HIDDEN) { Ttk_Padding expand = Ttk_UniformPadding(0); Tcl_Obj *expandObj = Ttk_QueryOption(tabLayout,"-expand",tabState); @@ -511,11 +511,11 @@ /* NotebookDoLayout -- * Computes notebook layout and places tabs. * * Side effects: - * Sets clientArea, used to place slave panes. + * Sets clientArea, used to place panes. */ static void NotebookDoLayout(void *recordPtr) { Notebook *nb = (Notebook *)recordPtr; Tk_Window nbwin = nb->core.tkwin; @@ -565,46 +565,46 @@ nb->notebook.clientArea = cavity; } /* - * NotebookPlaceSlave -- + * NotebookPlaceContent -- * Set the position and size of a child widget - * based on the current client area and slave options: + * based on the current client area and content window options: */ -static void NotebookPlaceSlave(Notebook *nb, TkSizeT slaveIndex) +static void NotebookPlaceContent(Notebook *nb, TkSizeT index) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, slaveIndex); - Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, slaveIndex); - Ttk_Box slaveBox = + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); + Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index); + Ttk_Box box = Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding), - Tk_ReqWidth(slaveWindow), Tk_ReqHeight(slaveWindow),tab->sticky); + Tk_ReqWidth(window), Tk_ReqHeight(window),tab->sticky); - Ttk_PlaceSlave(nb->notebook.mgr, slaveIndex, - slaveBox.x, slaveBox.y, slaveBox.width, slaveBox.height); + Ttk_PlaceContent(nb->notebook.mgr, index, + box.x, box.y, box.width, box.height); } -/* NotebookPlaceSlaves -- +/* NotebookPlaceContents -- * Geometry manager hook. */ -static void NotebookPlaceSlaves(void *recordPtr) +static void NotebookPlaceContents(void *recordPtr) { Notebook *nb = (Notebook *)recordPtr; TkSizeT currentIndex = nb->notebook.currentIndex; if (currentIndex != TCL_INDEX_NONE) { NotebookDoLayout(nb); - NotebookPlaceSlave(nb, currentIndex); + NotebookPlaceContent(nb, currentIndex); } } /* * SelectTab(nb, index) -- * Change the currently-selected tab. */ static void SelectTab(Notebook *nb, TkSizeT index) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); TkSizeT currentIndex = nb->notebook.currentIndex; if (index == currentIndex) { return; } @@ -618,47 +618,47 @@ if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } if (currentIndex != TCL_INDEX_NONE) { - Ttk_UnmapSlave(nb->notebook.mgr, currentIndex); + Ttk_UnmapContent(nb->notebook.mgr, currentIndex); } - /* Must be set before calling NotebookPlaceSlave(), otherwise it may - * happen that NotebookPlaceSlaves(), triggered by an interveaning + /* Must be set before calling NotebookPlaceContent(), otherwise it may + * happen that NotebookPlaceContents(), triggered by an interveaning * geometry request, will swap to old index. */ nb->notebook.currentIndex = index; - NotebookPlaceSlave(nb, index); + NotebookPlaceContent(nb, index); TtkRedisplayWidget(&nb->core); - TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged"); + Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL); } /* NextTab -- * Returns the index of the next tab after the specified tab * in the normal state (e.g., not hidden or disabled), * or -1 if all tabs are disabled or hidden. */ static int NextTab(Notebook *nb, int index) { - TkSizeT nTabs = Ttk_NumberSlaves(nb->notebook.mgr); + TkSizeT nTabs = Ttk_NumberContent(nb->notebook.mgr); TkSizeT nextIndex; /* Scan forward for following usable tab: */ for (nextIndex = index + 1; nextIndex + 1 < nTabs + 1; ++nextIndex) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex); if (tab->state == TAB_STATE_NORMAL) { return nextIndex; } } /* Not found -- scan backwards. */ for (nextIndex = index - 1; nextIndex != TCL_INDEX_NONE; --nextIndex) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex); if (tab->state == TAB_STATE_NORMAL) { return nextIndex; } } @@ -678,29 +678,29 @@ { TkSizeT currentIndex = nb->notebook.currentIndex; TkSizeT nextIndex = NextTab(nb, currentIndex); if (currentIndex != TCL_INDEX_NONE) { - Ttk_UnmapSlave(nb->notebook.mgr, currentIndex); + Ttk_UnmapContent(nb->notebook.mgr, currentIndex); } if (currentIndex != nextIndex) { - TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged"); + Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL); } nb->notebook.currentIndex = nextIndex; Ttk_ManagerLayoutChanged(nb->notebook.mgr); TtkRedisplayWidget(&nb->core); } -/* TabRemoved -- GM SlaveRemoved hook. +/* TabRemoved -- GM TabRemoved hook. * Select the next tab if the current one is being removed. - * Adjust currentIndex to account for removed slave. + * Adjust currentIndex to account for removed content window. */ static void TabRemoved(void *managerData, TkSizeT index) { Notebook *nb = (Notebook *)managerData; - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); } @@ -711,53 +711,52 @@ DestroyTab(nb, tab); TtkRedisplayWidget(&nb->core); } -static int TabRequest(void *managerData, TkSizeT index, int width, int height) +static int TabRequest( + TCL_UNUSED(void *), + TCL_UNUSED(TkSizeT), + TCL_UNUSED(int), + TCL_UNUSED(int)) { - (void)managerData; - (void)index; - (void)width; - (void)height; - return 1; } /* AddTab -- * Add new tab at specified index. */ static int AddTab( Tcl_Interp *interp, Notebook *nb, - TkSizeT destIndex, Tk_Window slaveWindow, + TkSizeT destIndex, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Tab *tab; - if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) { + if (!Ttk_Maintainable(interp, window, nb->core.tkwin)) { return TCL_ERROR; } #if 0 /* can't happen */ - if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) != TCL_INDEX_NONE) { + if (Ttk_ContentIndex(nb->notebook.mgr, window) != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added", - Tk_PathName(slaveWindow))); + Tk_PathName(window))); Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL); return TCL_ERROR; } #endif /* Create and insert tab. */ - tab = CreateTab(interp, nb, slaveWindow); + tab = CreateTab(interp, nb, window); if (!tab) { return TCL_ERROR; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc, objv) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc, objv) != TCL_OK) { DestroyTab(nb, tab); return TCL_ERROR; } - Ttk_InsertSlave(nb->notebook.mgr, destIndex, slaveWindow, tab); + Ttk_InsertContent(nb->notebook.mgr, destIndex, window, tab); /* Adjust indices and/or autoselect first tab: */ if (nb->notebook.currentIndex == TCL_INDEX_NONE) { SelectTab(nb, destIndex); @@ -767,13 +766,13 @@ return TCL_OK; } static Ttk_ManagerSpec NotebookManagerSpec = { - { "notebook", Ttk_GeometryRequestProc, Ttk_LostSlaveProc }, + { "notebook", Ttk_GeometryRequestProc, Ttk_LostContentProc }, NotebookSize, - NotebookPlaceSlaves, + NotebookPlaceContents, TabRequest, TabRemoved }; /*------------------------------------------------------------------------ @@ -812,11 +811,11 @@ * Tab identifiers are one of: * * + positional specifications @x,y, * + "current", * + numeric indices [0..nTabs], - * + slave window names + * + content window names * * Stores index of specified tab in *index_rtn, -1 if not found. * * Returns TCL_ERROR and leaves an error message in interp->result * if the tab identifier was incorrect. @@ -843,25 +842,25 @@ if (!strcmp(string, "current")) { *index_rtn = nb->notebook.currentIndex; return TCL_OK; } - /* ... or integer index or slave window name: + /* ... or integer index or content window name: */ - if (Ttk_GetSlaveIndexFromObj( + if (Ttk_GetContentIndexFromObj( interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK) { return TCL_OK; } - if (*index_rtn == Ttk_NumberSlaves(nb->notebook.mgr)) { + if (*index_rtn == Ttk_NumberContent(nb->notebook.mgr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Invalid slave specification %s", string)); - Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL); + "Invalid tab specification %s", string)); + Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "SPEC", NULL); return TCL_ERROR; } - /* Nothing matched; Ttk_GetSlaveIndexFromObj will have left error message. + /* Nothing matched; Ttk_GetContentIndexFromObj will have left error message. */ return TCL_ERROR; } /* GetTabIndex -- @@ -871,14 +870,14 @@ */ static int GetTabIndex( Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, TkSizeT *index_rtn) { int status = FindTabIndex(interp, nb, objPtr, index_rtn); - if (status == TCL_OK && *index_rtn + 1 >= Ttk_NumberSlaves(nb->notebook.mgr) + 1) { + if (status == TCL_OK && *index_rtn + 1 >= Ttk_NumberContent(nb->notebook.mgr) + 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Slave index %s out of bounds", Tcl_GetString(objPtr))); - Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); + "tab index %s out of bounds", Tcl_GetString(objPtr))); + Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "INDEX", NULL); return TCL_ERROR; } if (status == TCL_OK && *index_rtn == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -897,35 +896,34 @@ */ static int NotebookAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = (Notebook *)recordPtr; - int index = Ttk_NumberSlaves(nb->notebook.mgr); - Tk_Window slaveWindow; - int slaveIndex; + Tk_Window window; + int index; Tab *tab; if (objc <= 2 || objc % 2 != 1) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?"); return TCL_ERROR; } - slaveWindow = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin); - if (!slaveWindow) { + window = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin); + if (!window) { return TCL_ERROR; } - slaveIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow); + index = Ttk_ContentIndex(nb->notebook.mgr, window); - if (slaveIndex < 0) { /* New tab */ - return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3); + if (index < 0) { /* New tab */ + return AddTab(interp, nb, Ttk_NumberContent(nb->notebook.mgr), window, objc-3,objv+3); } - tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, slaveIndex); + tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } TtkRedisplayWidget(&nb->core); @@ -938,59 +936,59 @@ static int NotebookInsertCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = (Notebook *)recordPtr; TkSizeT current = nb->notebook.currentIndex; - TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + TkSizeT nContent = Ttk_NumberContent(nb->notebook.mgr); TkSizeT srcIndex, destIndex; if (objc < 4) { - Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?"); + Tcl_WrongNumArgs(interp, 2,objv, "index window ?-option value ...?"); return TCL_ERROR; } - if (TCL_OK != Ttk_GetSlaveIndexFromObj( + if (TCL_OK != Ttk_GetContentIndexFromObj( interp, nb->notebook.mgr, objv[2], &destIndex)) { return TCL_ERROR; } if (Tcl_GetString(objv[3])[0] == '.') { - /* Window name -- could be new or existing slave. + /* Window name -- could be new or existing content window. */ - Tk_Window slaveWindow = + Tk_Window window = Tk_NameToWindow(interp,Tcl_GetString(objv[3]),nb->core.tkwin); - if (!slaveWindow) { + if (!window) { return TCL_ERROR; } - srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow); - if (srcIndex == TCL_INDEX_NONE) { /* New slave */ - return AddTab(interp, nb, destIndex, slaveWindow, objc-4,objv+4); + srcIndex = Ttk_ContentIndex(nb->notebook.mgr, window); + if (srcIndex == TCL_INDEX_NONE) { /* New content window */ + return AddTab(interp, nb, destIndex, window, objc-4,objv+4); } - } else if (Ttk_GetSlaveIndexFromObj( + } else if (Ttk_GetContentIndexFromObj( interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK) { return TCL_ERROR; - } else if (srcIndex + 1 >= Ttk_NumberSlaves(nb->notebook.mgr) + 1) { - srcIndex = Ttk_NumberSlaves(nb->notebook.mgr) - 1; + } else if (srcIndex + 1 >= Ttk_NumberContent(nb->notebook.mgr) + 1) { + srcIndex = Ttk_NumberContent(nb->notebook.mgr) - 1; } - /* Move existing slave: + /* Move existing content window: */ if (ConfigureTab(interp, nb, - (Tab *)Ttk_SlaveData(nb->notebook.mgr, srcIndex), - Ttk_SlaveWindow(nb->notebook.mgr, srcIndex), + (Tab *)Ttk_ContentData(nb->notebook.mgr, srcIndex), + Ttk_ContentWindow(nb->notebook.mgr, srcIndex), objc-4,objv+4) != TCL_OK) { return TCL_ERROR; } - if (destIndex + 1 >= nSlaves + 1) { - destIndex = nSlaves - 1; + if (destIndex + 1 >= nContent + 1) { + destIndex = nContent - 1; } - Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex); + Ttk_ReorderContent(nb->notebook.mgr, srcIndex, destIndex); /* Adjust internal indexes: */ nb->notebook.activeIndex = TCL_INDEX_NONE; if (current == srcIndex) { @@ -1022,11 +1020,11 @@ if (GetTabIndex(interp, nb, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - Ttk_ForgetSlave(nb->notebook.mgr, index); + Ttk_ForgetContent(nb->notebook.mgr, index); TtkRedisplayWidget(&nb->core); return TCL_OK; } @@ -1047,11 +1045,11 @@ if (GetTabIndex(interp, nb, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); tab->state = TAB_STATE_HIDDEN; if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); } @@ -1077,21 +1075,21 @@ if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2,objv, "?what? x y"); return TCL_ERROR; } - if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK + if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK || (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable, sizeof(char *), "option", 0, &what) != TCL_OK) ) { return TCL_ERROR; } tabIndex = IdentifyTab(nb, x, y); if (tabIndex != TCL_INDEX_NONE) { - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, tabIndex); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, tabIndex); Ttk_State state = TabState(nb, tabIndex); Ttk_Layout tabLayout = nb->notebook.tabLayout; Ttk_RebindSublayout(tabLayout, tab); Ttk_PlaceLayout(tabLayout, state, tab->parcel); @@ -1106,13 +1104,12 @@ Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; case IDENTIFY_TAB: - if (tabIndex != TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(tabIndex)); - } + if (tabIndex != TCL_INDEX_NONE) + Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex)); break; } return TCL_OK; } @@ -1132,12 +1129,13 @@ Tcl_WrongNumArgs(interp, 2, objv, "tab"); return TCL_ERROR; } status = FindTabIndex(interp, nb, objv[2], &index); - if (status == TCL_OK && index != TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + if (status == TCL_OK) { + if (index != TCL_INDEX_NONE) + Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return status; } @@ -1150,11 +1148,11 @@ { Notebook *nb = (Notebook *)recordPtr; if (objc == 2) { if (nb->notebook.currentIndex != TCL_INDEX_NONE) { - Tk_Window pane = Ttk_SlaveWindow( + Tk_Window pane = Ttk_ContentWindow( nb->notebook.mgr, nb->notebook.currentIndex); Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1)); } return TCL_OK; } else if (objc == 3) { @@ -1184,12 +1182,12 @@ Tcl_WrongNumArgs(interp, 2, objv, ""); return TCL_ERROR; } result = Tcl_NewListObj(0, NULL); - for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { - const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); + for (i = 0; i < Ttk_NumberContent(mgr); ++i) { + const char *pathName = Tk_PathName(Ttk_ContentWindow(mgr,i)); Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(pathName,-1)); } Tcl_SetObjResult(interp, result); return TCL_OK; @@ -1201,11 +1199,11 @@ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = (Notebook *)recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; TkSizeT index; - Tk_Window slaveWindow; + Tk_Window window; Tab *tab; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "tab ?-option ?value??..."); return TCL_ERROR; @@ -1213,22 +1211,22 @@ if (GetTabIndex(interp, nb, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - tab = (Tab *)Ttk_SlaveData(mgr, index); - slaveWindow = Ttk_SlaveWindow(mgr, index); + tab = (Tab *)Ttk_ContentData(mgr, index); + window = Ttk_ContentWindow(mgr, index); if (objc == 3) { return TtkEnumerateOptions(interp, tab, - PaneOptionSpecs, nb->notebook.paneOptionTable, slaveWindow); + PaneOptionSpecs, nb->notebook.paneOptionTable, window); } else if (objc == 4) { return TtkGetOptionValue(interp, tab, objv[3], - nb->notebook.paneOptionTable, slaveWindow); + nb->notebook.paneOptionTable, window); } /* else */ - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } /* If the current tab has become disabled or hidden, * select the next nondisabled, unhidden one: @@ -1242,20 +1240,21 @@ /* Subcommand table: */ static const Ttk_Ensemble NotebookCommands[] = { { "add", NotebookAddCommand,0 }, - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "forget", NotebookForgetCommand,0 }, { "hide", NotebookHideCommand,0 }, { "identify", NotebookIdentifyCommand,0 }, { "index", NotebookIndexCommand,0 }, { "insert", NotebookInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "select", NotebookSelectCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { "tab", NotebookTabCommand,0 }, { "tabs", NotebookTabsCommand,0 }, { 0,0,0 } }; @@ -1344,11 +1343,11 @@ */ static void DisplayTab(Notebook *nb, int index, Drawable d) { Ttk_Layout tabLayout = nb->notebook.tabLayout; - Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); Ttk_State state = TabState(nb, index); if (tab->state != TAB_STATE_HIDDEN) { Ttk_RebindSublayout(tabLayout, tab); Ttk_PlaceLayout(tabLayout, state, tab->parcel); @@ -1357,21 +1356,21 @@ } static void NotebookDisplay(void *clientData, Drawable d) { Notebook *nb = (Notebook *)clientData; - TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + TkSizeT nContent = Ttk_NumberContent(nb->notebook.mgr); TkSizeT index; /* Draw notebook background (base layout): */ Ttk_DrawLayout(nb->core.layout, nb->core.state, d); /* Draw tabs from left to right, but draw the current tab last * so it will overwrite its neighbors. */ - for (index = 0; index < nSlaves; ++index) { + for (index = 0; index < nContent; ++index) { if (index != nb->notebook.currentIndex) { DisplayTab(nb, index, d); } } if (nb->notebook.currentIndex != TCL_INDEX_NONE) { Index: generic/ttk/ttkPanedwindow.c ================================================================== --- generic/ttk/ttkPanedwindow.c +++ generic/ttk/ttkPanedwindow.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2005, Joe English. Freely redistributable. + * Copyright © 2005 Joe English. Freely redistributable. * * ttk::panedwindow widget implementation. * * TODO: track active/pressed sash. */ @@ -26,11 +26,11 @@ * This ensures continuous resize behavior (that is: changing * the size by X pixels then changing the size by Y pixels * gives the same result as changing the size by X+Y pixels * in one step). * - * The request size is initially set to the slave window's requested size. + * The request size is initially set to the content window's requested size. * When the user drags a sash, each pane's request size is set to its * actual size. This ensures that panes "stay put" on the next resize. * * If reqSize == 0, use 0 for the weight as well. This ensures that * "collapsed" panes stay collapsed during a resize, regardless of @@ -75,24 +75,24 @@ /* @@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI */ static const Tk_OptionSpec PanedOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient), - 0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED }, + 0, (void *)ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED }, {TK_OPTION_INT, "-width", "width", "Width", "0", - TCL_INDEX_NONE, offsetof(Paned,paned.width), - 0,0,GEOMETRY_CHANGED }, + TCL_INDEX_NONE, offsetof(Paned, paned.width), + 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_INT, "-height", "height", "Height", "0", - TCL_INDEX_NONE, offsetof(Paned,paned.height), - 0,0,GEOMETRY_CHANGED }, + TCL_INDEX_NONE, offsetof(Paned, paned.height), + 0, 0, GEOMETRY_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; /*------------------------------------------------------------------------ - * +++ Slave pane record. + * +++ Pane record. */ typedef struct { int reqSize; /* Pane request size */ int sashPos; /* Folowing sash position */ int weight; /* Pane -weight, for resizing */ @@ -105,25 +105,25 @@ }; /* CreatePane -- * Create a new pane record. */ -static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow) +static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window window) { Tk_OptionTable optionTable = pw->paned.paneOptionTable; void *record = ckalloc(sizeof(Pane)); Pane *pane = (Pane *)record; memset(record, 0, sizeof(Pane)); - if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) { + if (Tk_InitOptions(interp, record, optionTable, window) != TCL_OK) { ckfree(record); return NULL; } pane->reqSize = pw->paned.orient == TTK_ORIENT_HORIZONTAL - ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow); + ? Tk_ReqWidth(window) : Tk_ReqHeight(window); return pane; } /* DestroyPane -- @@ -138,19 +138,19 @@ /* ConfigurePane -- * Set pane options. */ static int ConfigurePane( - Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window slaveWindow, + Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Ttk_Manager *mgr = pw->paned.mgr; Tk_SavedOptions savedOptions; int mask = 0; if (Tk_SetOptions(interp, pane, pw->paned.paneOptionTable, - objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) + objc, objv, window, &savedOptions, &mask) != TCL_OK) { return TCL_ERROR; } /* Sanity-check: @@ -186,18 +186,18 @@ * Returns: final position of sash i. */ static int ShoveUp(Paned *pw, int i, int pos) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, i); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, i); int sashThickness = pw->paned.sashThickness; if (i == 0) { if (pos < 0) pos = 0; } else { - Pane *prevPane = (Pane *)Ttk_SlaveData(pw->paned.mgr, i-1); + Pane *prevPane = (Pane *)Ttk_ContentData(pw->paned.mgr, i-1); if (pos < prevPane->sashPos + sashThickness) pos = ShoveUp(pw, i-1, pos - sashThickness) + sashThickness; } return pane->sashPos = pos; } @@ -206,17 +206,17 @@ * Same as ShoveUp, but going in the opposite direction * and stopping at the sentinel sash. */ static int ShoveDown(Paned *pw, TkSizeT i, int pos) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr,i); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr,i); int sashThickness = pw->paned.sashThickness; - if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) { - pos = pane->sashPos; /* Sentinel value == master window size */ + if (i == Ttk_NumberContent(pw->paned.mgr) - 1) { + pos = pane->sashPos; /* Sentinel value == container window size */ } else { - Pane *nextPane = (Pane *)Ttk_SlaveData(pw->paned.mgr,i+1); + Pane *nextPane = (Pane *)Ttk_ContentData(pw->paned.mgr,i+1); if (pos + sashThickness > nextPane->sashPos) pos = ShoveDown(pw, i+1, pos + sashThickness) - sashThickness; } return pane->sashPos = pos; } @@ -228,33 +228,33 @@ * Used as the WidgetSpec sizeProc and the ManagerSpec sizeProc. */ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr) { Paned *pw = (Paned *)recordPtr; - int nPanes = Ttk_NumberSlaves(pw->paned.mgr); + int nPanes = Ttk_NumberContent(pw->paned.mgr); int nSashes = nPanes - 1; int sashThickness = pw->paned.sashThickness; int width = 0, height = 0; int index; if (pw->paned.orient == TTK_ORIENT_HORIZONTAL) { for (index = 0; index < nPanes; ++index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); - Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); + Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index); - if (height < Tk_ReqHeight(slaveWindow)) - height = Tk_ReqHeight(slaveWindow); + if (height < Tk_ReqHeight(window)) + height = Tk_ReqHeight(window); width += pane->reqSize; } width += nSashes * sashThickness; } else { for (index = 0; index < nPanes; ++index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); - Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); + Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index); - if (width < Tk_ReqWidth(slaveWindow)) - width = Tk_ReqWidth(slaveWindow); + if (width < Tk_ReqWidth(window)) + width = Tk_ReqWidth(window); height += pane->reqSize; } height += nSashes * sashThickness; } @@ -275,12 +275,12 @@ { int sashThickness = pw->paned.sashThickness; int pos = 0; TkSizeT index; - for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); + for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) { + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); int size = pane->sashPos - pos; pane->reqSize = size >= 0 ? size : 0; pos = pane->sashPos + sashThickness; } } @@ -302,11 +302,11 @@ * when more than one pane has weight > 1. */ static void PlaceSashes(Paned *pw, int width, int height) { Ttk_Manager *mgr = pw->paned.mgr; - int nPanes = Ttk_NumberSlaves(mgr); + int nPanes = Ttk_NumberContent(mgr); int sashThickness = pw->paned.sashThickness; int available = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? width : height; int reqSize = 0, totalWeight = 0; int difference, delta, remainder, pos, i; @@ -314,11 +314,11 @@ return; /* Compute total required size and total available weight: */ for (i = 0; i < nPanes; ++i) { - Pane *pane = (Pane *)Ttk_SlaveData(mgr, i); + Pane *pane = (Pane *)Ttk_ContentData(mgr, i); reqSize += pane->reqSize; totalWeight += pane->weight * (pane->reqSize != 0); } /* Compute difference to be redistributed: @@ -338,11 +338,11 @@ /* Place sashes: */ pos = 0; for (i = 0; i < nPanes; ++i) { - Pane *pane = (Pane *)Ttk_SlaveData(mgr, i); + Pane *pane = (Pane *)Ttk_ContentData(mgr, i); int weight = pane->weight * (pane->reqSize != 0); int size = pane->reqSize + delta * weight; if (weight > remainder) weight = remainder; @@ -362,32 +362,32 @@ */ ShoveUp(pw, nPanes - 1, available); } /* PlacePanes -- - * Places slave panes based on sash positions. + * Places panes based on sash positions. */ static void PlacePanes(Paned *pw) { int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL; int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin); int sashThickness = pw->paned.sashThickness; int pos = 0; TkSizeT index; - for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); + for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) { + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); int size = pane->sashPos - pos; if (size > 0) { if (horizontal) { - Ttk_PlaceSlave(pw->paned.mgr, index, pos, 0, size, height); + Ttk_PlaceContent(pw->paned.mgr, index, pos, 0, size, height); } else { - Ttk_PlaceSlave(pw->paned.mgr, index, 0, pos, width, size); + Ttk_PlaceContent(pw->paned.mgr, index, 0, pos, width, size); } } else { - Ttk_UnmapSlave(pw->paned.mgr, index); + Ttk_UnmapContent(pw->paned.mgr, index); } pos = pane->sashPos + sashThickness; } } @@ -394,76 +394,76 @@ /*------------------------------------------------------------------------ * +++ Manager specification. */ -static void PanedPlaceSlaves(void *managerData) +static void PanedPlaceContent(void *managerData) { Paned *pw = (Paned *)managerData; PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin)); PlacePanes(pw); } static void PaneRemoved(void *managerData, TkSizeT index) { Paned *pw = (Paned *)managerData; - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); DestroyPane(pw, pane); } static int AddPane( Tcl_Interp *interp, Paned *pw, - int destIndex, Tk_Window slaveWindow, + int destIndex, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Pane *pane; - if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) { + if (!Ttk_Maintainable(interp, window, pw->core.tkwin)) { return TCL_ERROR; } - if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) != TCL_INDEX_NONE) { + if (Ttk_ContentIndex(pw->paned.mgr, window) != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "%s already added", Tk_PathName(slaveWindow))); + "%s already added", Tk_PathName(window))); Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL); return TCL_ERROR; } - pane = CreatePane(interp, pw, slaveWindow); + pane = CreatePane(interp, pw, window); if (!pane) { return TCL_ERROR; } - if (ConfigurePane(interp, pw, pane, slaveWindow, objc, objv) != TCL_OK) { + if (ConfigurePane(interp, pw, pane, window, objc, objv) != TCL_OK) { DestroyPane(pw, pane); return TCL_ERROR; } - Ttk_InsertSlave(pw->paned.mgr, destIndex, slaveWindow, pane); + Ttk_InsertContent(pw->paned.mgr, destIndex, window, pane); return TCL_OK; } /* PaneRequest -- - * Only update pane request size if slave is currently unmapped. - * Geometry requests from mapped slaves are not directly honored + * Only update pane request size if pane is currently unmapped. + * Geometry requests from mapped panes are not directly honored * in order to avoid unexpected pane resizes (esp. while the * user is dragging a sash [#1325286]). */ static int PaneRequest(void *managerData, TkSizeT index, int width, int height) { Paned *pw = (Paned *)managerData; - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); - Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); + Tk_Window window = Ttk_ContentWindow(pw->paned.mgr, index); int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL; - if (!Tk_IsMapped(slaveWindow)) { + if (!Tk_IsMapped(window)) { pane->reqSize = horizontal ? width : height; } return 1; } static Ttk_ManagerSpec PanedManagerSpec = { - { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostSlaveProc }, + { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostContentProc }, PanedSize, - PanedPlaceSlaves, + PanedPlaceContent, PaneRequest, PaneRemoved }; /*------------------------------------------------------------------------ @@ -484,11 +484,11 @@ { WidgetCore *corePtr = (WidgetCore *)clientData; if ( eventPtr->type == LeaveNotify && eventPtr->xcrossing.detail == NotifyInferior) { - TtkSendVirtualEvent(corePtr->tkwin, "EnteredChild"); + Tk_SendVirtualEvent(corePtr->tkwin, "EnteredChild", NULL); } } /*------------------------------------------------------------------------ * +++ Initialization and cleanup hooks. @@ -517,14 +517,16 @@ Ttk_DeleteManager(pw->paned.mgr); } /* Post-configuration hook. */ -static int PanedPostConfigure(Tcl_Interp *dummy, void *clientData, int mask) +static int PanedPostConfigure( + TCL_UNUSED(Tcl_Interp *), + void *clientData, + int mask) { Paned *pw = (Paned *)clientData; - (void)dummy; if (mask & GEOMETRY_CHANGED) { /* User has changed -width or -height. * Recalculate sash positions based on requested size. */ @@ -579,11 +581,11 @@ * Place the sash sublayout after the specified pane, * in preparation for drawing. */ static Ttk_Layout SashLayout(Paned *pw, int index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); int thickness = pw->paned.sashThickness, height = Tk_Height(pw->core.tkwin), width = Tk_Width(pw->core.tkwin), sashPos = pane->sashPos; @@ -602,14 +604,14 @@ } static void PanedDisplay(void *recordPtr, Drawable d) { Paned *pw = (Paned *)recordPtr; - TkSizeT i, nSlaves = Ttk_NumberSlaves(pw->paned.mgr); + TkSizeT i, nContent = Ttk_NumberContent(pw->paned.mgr); TtkWidgetDisplay(recordPtr, d); - for (i = 1; i < nSlaves; ++i) { + for (i = 1; i < nContent; ++i) { DrawSash(pw, i - 1, d); } } /*------------------------------------------------------------------------ @@ -620,69 +622,69 @@ */ static int PanedAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = (Paned *)recordPtr; - Tk_Window slaveWindow; + Tk_Window window; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - slaveWindow = Tk_NameToWindow( + window = Tk_NameToWindow( interp, Tcl_GetString(objv[2]), pw->core.tkwin); - if (!slaveWindow) { + if (!window) { return TCL_ERROR; } - return AddPane(interp, pw, Ttk_NumberSlaves(pw->paned.mgr), slaveWindow, + return AddPane(interp, pw, Ttk_NumberContent(pw->paned.mgr), window, objc - 3, objv + 3); } -/* $pw insert $index $slave ?-option value ...? - * Insert new slave, or move existing one. +/* $pw insert $index $window ?-option value ...? + * Insert new content window, or move existing one. */ static int PanedInsertCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = (Paned *)recordPtr; - TkSizeT nSlaves = Ttk_NumberSlaves(pw->paned.mgr); + TkSizeT nContent = Ttk_NumberContent(pw->paned.mgr); TkSizeT srcIndex, destIndex; - Tk_Window slaveWindow; + Tk_Window window; if (objc < 4) { - Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?"); + Tcl_WrongNumArgs(interp, 2,objv, "index window ?-option value ...?"); return TCL_ERROR; } - slaveWindow = Tk_NameToWindow( + window = Tk_NameToWindow( interp, Tcl_GetString(objv[3]), pw->core.tkwin); - if (!slaveWindow) { + if (!window) { return TCL_ERROR; } - if (TCL_OK != Ttk_GetSlaveIndexFromObj( + if (TCL_OK != Ttk_GetContentIndexFromObj( interp,pw->paned.mgr, objv[2], &destIndex)) { return TCL_ERROR; } - srcIndex = Ttk_SlaveIndex(pw->paned.mgr, slaveWindow); - if (srcIndex == TCL_INDEX_NONE) { /* New slave: */ - return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4); - } /* else -- move existing slave: */ - - if (destIndex + 1 >= nSlaves + 1) - destIndex = nSlaves - 1; - Ttk_ReorderSlave(pw->paned.mgr, srcIndex, destIndex); + srcIndex = Ttk_ContentIndex(pw->paned.mgr, window); + if (srcIndex == TCL_INDEX_NONE) { /* New content: */ + return AddPane(interp, pw, destIndex, window, objc-4, objv+4); + } /* else -- move existing content: */ + + if (destIndex + 1 >= nContent + 1) + destIndex = nContent - 1; + Ttk_ReorderContent(pw->paned.mgr, srcIndex, destIndex); return objc == 4 ? TCL_OK : ConfigurePane(interp, pw, - (Pane *)Ttk_SlaveData(pw->paned.mgr, destIndex), - Ttk_SlaveWindow(pw->paned.mgr, destIndex), + (Pane *)Ttk_ContentData(pw->paned.mgr, destIndex), + Ttk_ContentWindow(pw->paned.mgr, destIndex), objc-4, objv+4); } /* $pw forget $pane */ @@ -695,18 +697,18 @@ if (objc != 3) { Tcl_WrongNumArgs(interp, 2,objv, "pane"); return TCL_ERROR; } - if (TCL_OK != Ttk_GetSlaveIndexFromObj( + if (TCL_OK != Ttk_GetContentIndexFromObj( interp, pw->paned.mgr, objv[2], &paneIndex)) { return TCL_ERROR; - } else if (paneIndex + 1 >= Ttk_NumberSlaves(pw->paned.mgr) + 1) { - paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1; + } else if (paneIndex + 1 >= Ttk_NumberContent(pw->paned.mgr) + 1) { + paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1; } - Ttk_ForgetSlave(pw->paned.mgr, paneIndex); + Ttk_ForgetContent(pw->paned.mgr, paneIndex); return TCL_OK; } /* $pw identify ?what? $x $y -- @@ -718,11 +720,11 @@ static const char *const whatTable[] = { "element", "sash", NULL }; enum { IDENTIFY_ELEMENT, IDENTIFY_SASH }; int what = IDENTIFY_SASH; Paned *pw = (Paned *)recordPtr; int sashThickness = pw->paned.sashThickness; - int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1; + int nSashes = Ttk_NumberContent(pw->paned.mgr) - 1; int x, y, pos; int index; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2,objv, "?what? x y"); @@ -737,11 +739,11 @@ return TCL_ERROR; } pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y; for (index = 0; index < nSashes; ++index) { - Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index); + Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index); if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) { /* Found it. */ switch (what) { case IDENTIFY_SASH: Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); @@ -769,38 +771,38 @@ static int PanedPaneCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = (Paned *)recordPtr; TkSizeT paneIndex; - Tk_Window slaveWindow; + Tk_Window window; Pane *pane; if (objc < 3) { Tcl_WrongNumArgs(interp, 2,objv, "pane ?-option value ...?"); return TCL_ERROR; } - if (TCL_OK != Ttk_GetSlaveIndexFromObj( + if (TCL_OK != Ttk_GetContentIndexFromObj( interp,pw->paned.mgr, objv[2], &paneIndex)) { return TCL_ERROR; - } else if (paneIndex + 1 >= Ttk_NumberSlaves(pw->paned.mgr) + 1) { - paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1; + } else if (paneIndex + 1 >= Ttk_NumberContent(pw->paned.mgr) + 1) { + paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1; } - pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, paneIndex); - slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex); + pane = (Pane *)Ttk_ContentData(pw->paned.mgr, paneIndex); + window = Ttk_ContentWindow(pw->paned.mgr, paneIndex); switch (objc) { case 3: return TtkEnumerateOptions(interp, pane, PaneOptionSpecs, - pw->paned.paneOptionTable, slaveWindow); + pw->paned.paneOptionTable, window); case 4: return TtkGetOptionValue(interp, pane, objv[3], - pw->paned.paneOptionTable, slaveWindow); + pw->paned.paneOptionTable, window); default: - return ConfigurePane(interp, pw, pane, slaveWindow, objc-3,objv+3); + return ConfigurePane(interp, pw, pane, window, objc-3,objv+3); } } /* $pw panes -- * Return list of managed panes. @@ -817,12 +819,12 @@ Tcl_WrongNumArgs(interp, 2, objv, ""); return TCL_ERROR; } panes = Tcl_NewListObj(0, NULL); - for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { - const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); + for (i = 0; i < Ttk_NumberContent(mgr); ++i) { + const char *pathName = Tk_PathName(Ttk_ContentWindow(mgr,i)); Tcl_ListObjAppendElement(interp, panes, Tcl_NewStringObj(pathName,-1)); } Tcl_SetObjResult(interp, panes); return TCL_OK; @@ -844,18 +846,18 @@ return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) { return TCL_ERROR; } - if (sashIndex < 0 || (TkSizeT)sashIndex + 1 >= Ttk_NumberSlaves(pw->paned.mgr)) { + if (sashIndex < 0 || (TkSizeT)sashIndex + 1 >= Ttk_NumberContent(pw->paned.mgr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "sash index %d out of range", sashIndex)); Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL); return TCL_ERROR; } - pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, sashIndex); + pane = (Pane *)Ttk_ContentData(pw->paned.mgr, sashIndex); if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos)); return TCL_OK; } @@ -878,20 +880,21 @@ return TCL_OK; } static const Ttk_Ensemble PanedCommands[] = { { "add", PanedAddCommand,0 }, - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "forget", PanedForgetCommand,0 }, { "identify", PanedIdentifyCommand,0 }, { "insert", PanedInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "pane", PanedPaneCommand,0 }, { "panes", PanedPanesCommand,0 }, { "sashpos", PanedSashposCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /*------------------------------------------------------------------------ * +++ Widget specification. @@ -928,18 +931,19 @@ offsetof(SashElement,thicknessObj), "5" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void SashElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), + void *elementRecord, + TCL_UNUSED(Tk_Window), + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { SashElement *sash = (SashElement *)elementRecord; int thickness = DEFAULT_SASH_THICKNESS; - (void)dummy; - (void)tkwin; - (void)paddingPtr; Tcl_GetIntFromObj(NULL, sash->thicknessObj, &thickness); *widthPtr = *heightPtr = thickness; } Index: generic/ttk/ttkProgress.c ================================================================== --- generic/ttk/ttkProgress.c +++ generic/ttk/ttkProgress.c @@ -1,7 +1,7 @@ /* - * Copyright (c) Joe English, Pat Thoyts, Michael Kirkham + * Copyright © Joe English, Pat Thoyts, Michael Kirkham * * ttk::progressbar widget. */ #include "tkInt.h" @@ -69,14 +69,14 @@ "100", offsetof(Progressbar,progress.maximumObj), TCL_INDEX_NONE, 0, 0, 0 }, {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate", offsetof(Progressbar,progress.modeObj), offsetof(Progressbar,progress.mode), - 0, (ClientData)ProgressbarModeStrings, 0 }, + 0, (void *)ProgressbarModeStrings, 0 }, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE, - 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, + 0, (void *)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_INT, "-phase", "phase", "Phase", "0", offsetof(Progressbar,progress.phaseObj), TCL_INDEX_NONE, 0, 0, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Progressbar,progress.textObj), TCL_INDEX_NONE, @@ -123,31 +123,32 @@ static void AnimateProgressProc(ClientData clientData) { Progressbar *pb = (Progressbar *)clientData; pb->progress.timer = 0; - if (AnimationEnabled(pb)) { int phase = 0; Tcl_GetIntFromObj(NULL, pb->progress.phaseObj, &phase); /* * Update -phase: */ + ++phase; - if (pb->progress.maxPhase) - phase %= pb->progress.maxPhase; + if (phase > pb->progress.maxPhase) { + phase = 0; + } Tcl_DecrRefCount(pb->progress.phaseObj); - pb->progress.phaseObj = Tcl_NewIntObj(phase); + pb->progress.phaseObj = Tcl_NewWideIntObj(phase); Tcl_IncrRefCount(pb->progress.phaseObj); /* * Reschedule: */ + pb->progress.timer = Tcl_CreateTimerHandler( pb->progress.period, AnimateProgressProc, clientData); - TtkRedisplayWidget(&pb->core); } } /* CheckAnimation -- @@ -206,14 +207,15 @@ /*------------------------------------------------------------------------ * +++ Widget class methods: */ -static void ProgressbarInitialize(Tcl_Interp *dummy, void *recordPtr) +static void ProgressbarInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Progressbar *pb = (Progressbar *)recordPtr; - (void)dummy; pb->progress.variableTrace = 0; pb->progress.timer = 0; } @@ -257,16 +259,16 @@ /* * Post-configuration hook: */ static int ProgressbarPostConfigure( - Tcl_Interp *dummy, void *recordPtr, int mask) + TCL_UNUSED(Tcl_Interp *), + void *recordPtr, + TCL_UNUSED(int)) { Progressbar *pb = (Progressbar *)recordPtr; int status = TCL_OK; - (void)dummy; - (void)mask; if (pb->progress.variableTrace) { status = Ttk_FireTrace(pb->progress.variableTrace); if (WidgetDestroyed(&pb->core)) { return TCL_ERROR; @@ -495,36 +497,39 @@ return status; } static int ProgressbarStartCommand( - void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) + TCL_UNUSED(void *), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) { - (void)recordPtr; - return ProgressbarStartStopCommand( - interp, "::ttk::progressbar::start", objc, objv); + interp, "::ttk::progressbar::start", objc, objv); } static int ProgressbarStopCommand( - void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) + TCL_UNUSED(void *), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) { - (void)recordPtr; - return ProgressbarStartStopCommand( - interp, "::ttk::progressbar::stop", objc, objv); + interp, "::ttk::progressbar::stop", objc, objv); } static const Ttk_Ensemble ProgressbarCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "start", ProgressbarStartCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "step", ProgressbarStepCommand,0 }, { "stop", ProgressbarStopCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * Widget specification: Index: generic/ttk/ttkScale.c ================================================================== --- generic/ttk/ttkScale.c +++ generic/ttk/ttkScale.c @@ -1,7 +1,7 @@ /* - * Copyright (C) 2004 Pat Thoyts + * Copyright © 2004 Pat Thoyts * * ttk::scale widget. */ #include "tkInt.h" @@ -55,15 +55,15 @@ {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Scale,scale.commandObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", "", offsetof(Scale,scale.variableObj), TCL_INDEX_NONE, - 0,0,0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Scale,scale.orientObj), offsetof(Scale,scale.orient), 0, - (ClientData)ttkOrientStrings, STYLE_CHANGED }, + (void *)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_DOUBLE, "-from", "from", "From", "0", offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", "1.0", offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0}, @@ -73,11 +73,11 @@ DEF_SCALE_LENGTH, offsetof(Scale,scale.lengthObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-state", "state", "State", "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE, - 0,0,STATE_CHANGED}, + 0, 0, STATE_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; @@ -108,14 +108,15 @@ } /* ScaleInitialize -- * Scale widget initialization hook. */ -static void ScaleInitialize(Tcl_Interp *dummy, void *recordPtr) +static void ScaleInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Scale *scalePtr = (Scale *)recordPtr; - (void)dummy; TtkTrackElementState(&scalePtr->core); } static void ScaleCleanup(void *recordPtr) @@ -161,16 +162,16 @@ /* ScalePostConfigure -- * Post-configuration hook. */ static int ScalePostConfigure( - Tcl_Interp *dummy, void *recordPtr, int mask) + TCL_UNUSED(Tcl_Interp *), + void *recordPtr, + TCL_UNUSED(int)) { Scale *scale = (Scale *)recordPtr; int status = TCL_OK; - (void)dummy; - (void)mask; if (scale->scale.variableTrace) { status = Ttk_FireTrace(scale->scale.variableTrace); if (WidgetDestroyed(&scale->core)) { return TCL_ERROR; @@ -374,12 +375,12 @@ } if (r == TCL_OK) { Tcl_Obj *point[2]; XPoint pt = ValueToPoint(scalePtr, value); - point[0] = Tcl_NewIntObj(pt.x); - point[1] = Tcl_NewIntObj(pt.y); + point[0] = Tcl_NewWideIntObj(pt.x); + point[1] = Tcl_NewWideIntObj(pt.y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, point)); } return r; } @@ -479,18 +480,19 @@ } return pt; } static const Ttk_Ensemble ScaleCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, - { "state", TtkWidgetStateCommand,0 }, - { "instate", TtkWidgetInstateCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "coords", ScaleCoordsCommand,0 }, + { "get", ScaleGetCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, { "set", ScaleSetCommand,0 }, - { "get", ScaleGetCommand,0 }, - { "coords", ScaleCoordsCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec ScaleWidgetSpec = { Index: generic/ttk/ttkScroll.c ================================================================== --- generic/ttk/ttkScroll.c +++ generic/ttk/ttkScroll.c @@ -128,16 +128,16 @@ ScrollHandle h = (ScrollHandle)clientData; Tcl_Interp *interp = h->corePtr->interp; int code; h->flags &= ~SCROLL_UPDATE_PENDING; - Tcl_Preserve((ClientData) interp); + Tcl_Preserve(interp); code = UpdateScrollbar(interp, h); if (code == TCL_ERROR && !Tcl_InterpDeleted(interp)) { Tcl_BackgroundException(interp, code); } - Tcl_Release((ClientData) interp); + Tcl_Release(interp); } /* TtkScrolled -- * Update scroll info, schedule scrollbar update. */ @@ -165,11 +165,11 @@ s->first = first; s->last = last; s->total = total; if (!(h->flags & SCROLL_UPDATE_PENDING)) { - Tcl_DoWhenIdle(UpdateScrollbarBG, (ClientData)h); + Tcl_DoWhenIdle(UpdateScrollbarBG, h); h->flags |= SCROLL_UPDATE_PENDING; } } } @@ -272,10 +272,10 @@ } void TtkFreeScrollHandle(ScrollHandle h) { if (h->flags & SCROLL_UPDATE_PENDING) { - Tcl_CancelIdleCall(UpdateScrollbarBG, (ClientData)h); + Tcl_CancelIdleCall(UpdateScrollbarBG, h); } ckfree(h); } Index: generic/ttk/ttkScrollbar.c ================================================================== --- generic/ttk/ttkScrollbar.c +++ generic/ttk/ttkScrollbar.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003 Joe English * * ttk::scrollbar widget. */ #include "tkInt.h" @@ -32,16 +32,16 @@ } Scrollbar; static const Tk_OptionSpec ScrollbarOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", - offsetof(Scrollbar,scrollbar.commandObj), TCL_INDEX_NONE, 0,0,0}, + offsetof(Scrollbar, scrollbar.commandObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", - offsetof(Scrollbar,scrollbar.orientObj), - offsetof(Scrollbar,scrollbar.orient), - 0,(ClientData)ttkOrientStrings,STYLE_CHANGED }, + offsetof(Scrollbar, scrollbar.orientObj), + offsetof(Scrollbar, scrollbar.orient), + 0, (void *)ttkOrientStrings, STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; @@ -48,14 +48,15 @@ /*------------------------------------------------------------------------ * +++ Widget hooks. */ static void -ScrollbarInitialize(Tcl_Interp *dummy, void *recordPtr) +ScrollbarInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Scrollbar *sb = (Scrollbar *)recordPtr; - (void)dummy; sb->scrollbar.first = 0.0; sb->scrollbar.last = 1.0; TtkTrackElementState(&sb->core); @@ -279,19 +280,20 @@ Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); return TCL_OK; } static const Ttk_Ensemble ScrollbarCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "delta", ScrollbarDeltaCommand,0 }, { "fraction", ScrollbarFractionCommand,0 }, { "get", ScrollbarGetCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "set", ScrollbarSetCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /*------------------------------------------------------------------------ * +++ Widget specification. @@ -314,20 +316,18 @@ TTK_BEGIN_LAYOUT(VerticalScrollbarLayout) TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y, TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_TOP) TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM) - TTK_NODE( - "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH)) + TTK_NODE("Vertical.Scrollbar.thumb", TTK_FILL_BOTH)) TTK_END_LAYOUT TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout) TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X, TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_LEFT) TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT) - TTK_NODE( - "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH)) + TTK_NODE("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH)) TTK_END_LAYOUT /*------------------------------------------------------------------------ * +++ Initialization. */ Index: generic/ttk/ttkSeparator.c ================================================================== --- generic/ttk/ttkSeparator.c +++ generic/ttk/ttkSeparator.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004 Joe English * * ttk::separator and ttk::sizegrip widgets. */ #include "tkInt.h" @@ -24,11 +24,11 @@ static const Tk_OptionSpec SeparatorOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Separator,separator.orientObj), offsetof(Separator,separator.orient), - 0,(ClientData)ttkOrientStrings,STYLE_CHANGED }, + 0, (void *)ttkOrientStrings, STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; @@ -46,15 +46,16 @@ /* * Widget commands: */ static const Ttk_Ensemble SeparatorCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * Widget specification: @@ -87,15 +88,16 @@ WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble SizegripCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec SizegripWidgetSpec = { Index: generic/ttk/ttkSquare.c ================================================================== --- generic/ttk/ttkSquare.c +++ generic/ttk/ttkSquare.c @@ -1,6 +1,6 @@ -/* square.c - Copyright (C) 2004 Pat Thoyts +/* square.c - Copyright © 2004 Pat Thoyts * * Minimal sample ttk widget. */ #include "tkInt.h" @@ -127,15 +127,16 @@ * subcommands are listed here. Ttk provides default implementations * that are sufficient for our needs. */ static const Ttk_Ensemble SquareCommands[] = { - { "configure", TtkWidgetConfigureCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * The Widget specification structure holds all the implementation @@ -196,16 +197,19 @@ * find out how big this element wants to be. We must return our preferred * size and padding information */ static void SquareElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { SquareElement *square = (SquareElement *)elementRecord; int borderWidth = 0; - (void)dummy; Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, square->widthObj, widthPtr); Tk_GetPixelsFromObj(NULL, tkwin, square->heightObj, heightPtr); @@ -214,18 +218,20 @@ /* * Draw the element in the box provided. */ static void SquareElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(unsigned int)) { SquareElement *square = (SquareElement *)elementRecord; Tk_3DBorder foreground = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; - (void)dummy; - (void)state; foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj); Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, square->reliefObj, &relief); Index: generic/ttk/ttkState.c ================================================================== --- generic/ttk/ttkState.c +++ generic/ttk/ttkState.c @@ -1,9 +1,9 @@ /* * Tk widget state utilities. * - * Copyright (c) 2003 Joe English. Freely redistributable. + * Copyright © 2003 Joe English. Freely redistributable. * */ #include "tkInt.h" #include "ttkTheme.h" Index: generic/ttk/ttkStubInit.c ================================================================== --- generic/ttk/ttkStubInit.c +++ generic/ttk/ttkStubInit.c @@ -1,11 +1,11 @@ /* * This file is (mostly) automatically generated from ttk.decls. * It is compiled and linked in with the ttk package proper. */ -#include "tk.h" +#include "tkInt.h" #include "ttkTheme.h" MODULE_SCOPE const TtkStubs ttkStubs; #if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 Index: generic/ttk/ttkStubLib.c ================================================================== --- generic/ttk/ttkStubLib.c +++ generic/ttk/ttkStubLib.c @@ -4,11 +4,11 @@ */ #undef USE_TCL_STUBS #define USE_TCL_STUBS -#include "tk.h" +#include "tkInt.h" #define USE_TTK_STUBS 1 #include "ttkTheme.h" MODULE_SCOPE const TtkStubs *ttkStubsPtr; @@ -32,21 +32,27 @@ MODULE_SCOPE const char * TtkInitializeStubs( Tcl_Interp *interp, const char *version, int epoch, int revision) { int exact = 0; - const char *packageName = "Ttk"; + const char *packageName = "ttk"; const char *errMsg = NULL; void *pkgClientData = NULL; const char *actualVersion = Tcl_PkgRequireEx( interp, packageName, version, exact, &pkgClientData); - const TtkStubs *stubsPtr = (const TtkStubs *)pkgClientData; + const TtkStubs *stubsPtr; if (!actualVersion) { - return NULL; + packageName = "Ttk"; + actualVersion = Tcl_PkgRequireEx( + interp, packageName, version, exact, &pkgClientData); + if (!actualVersion) { + return NULL; + } } + stubsPtr = (const TtkStubs *)pkgClientData; if (!stubsPtr) { errMsg = "missing stub table pointer"; goto error; } if (stubsPtr->epoch != epoch) { Index: generic/ttk/ttkTagSet.c ================================================================== --- generic/ttk/ttkTagSet.c +++ generic/ttk/ttkTagSet.c @@ -1,9 +1,9 @@ /* * Tag tables. 3/4-baked, work in progress. * - * Copyright (C) 2005, Joe English. Freely redistributable. + * Copyright © 2005, Joe English. Freely redistributable. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" Index: generic/ttk/ttkTheme.c ================================================================== --- generic/ttk/ttkTheme.c +++ generic/ttk/ttkTheme.c @@ -1,12 +1,12 @@ /* * ttkTheme.c -- * * This file implements the widget styles and themes support. * - * Copyright (c) 2002 Frederic Bonnet - * Copyright (c) 2003 Joe English + * Copyright © 2002 Frederic Bonnet + * Copyright © 2003 Joe English * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -93,11 +93,11 @@ return 0; } /* * Ttk_StyleDefault -- - * Look up default resource setting the in the specified style. + * Look up default resource setting in the specified style. */ Tcl_Obj *Ttk_StyleDefault(Ttk_Style style, const char *optionName) { while (style) { Tcl_HashEntry *entryPtr = @@ -289,17 +289,16 @@ /*------------------------------------------------------------------------ * +++ Themes. */ -static int ThemeEnabled(Ttk_Theme theme, void *dummy) +static int ThemeEnabled( + TCL_UNUSED(Ttk_Theme), + TCL_UNUSED(void *)) { - (void)theme; - (void)dummy; - /* Default ThemeEnabledProc -- always return true */ - return 1; + return 1; } typedef struct Ttk_Theme_ { Ttk_Theme parentPtr; /* Parent theme. */ @@ -388,11 +387,11 @@ Ttk_CleanupProc *cleanupProc; struct CleanupStruct *next; } Cleanup; /*------------------------------------------------------------------------ - * +++ Master style package data structure. + * +++ Style package data structure. */ typedef struct { Tcl_Interp *interp; /* Owner interp */ Tcl_HashTable themeTable; /* KEY: name; VALUE: Theme pointer */ @@ -402,22 +401,23 @@ Cleanup *cleanupList; /* Cleanup records */ Ttk_ResourceCache cache; /* Resource cache */ int themeChangePending; /* scheduled ThemeChangedProc call? */ } StylePackageData; -static void ThemeChangedProc(ClientData); /* Forward */ +static void ThemeChangedProc(void *); /* Forward */ /* Ttk_StylePkgFree -- * Cleanup procedure for StylePackageData. */ -static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *dummy) +static void Ttk_StylePkgFree( + ClientData clientData, + TCL_UNUSED(Tcl_Interp *)) { StylePackageData *pkgPtr = (StylePackageData *)clientData; Tcl_HashSearch search; Tcl_HashEntry *entryPtr; Cleanup *cleanup; - (void)dummy; /* * Cancel any pending ThemeChanged calls: */ if (pkgPtr->themeChangePending) { @@ -515,13 +515,10 @@ int code = Tcl_EvalEx(pkgPtr->interp, ThemeChangedScript, -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(pkgPtr->interp, code); } pkgPtr->themeChangePending = 0; -#ifdef MAC_OSX_TK - XSync(NULL, False); -#endif } /* * ThemeChanged -- * Schedule a call to ThemeChanged if one is not already pending. @@ -591,11 +588,11 @@ * returns NULL and leaves an error message in interp's result. */ static Ttk_Theme LookupTheme( Tcl_Interp *interp, /* where to leave error messages */ - StylePackageData *pkgPtr, /* style package master record */ + StylePackageData *pkgPtr, /* style package record */ const char *name) /* theme name */ { Tcl_HashEntry *entryPtr; entryPtr = Tcl_FindHashEntry(&pkgPtr->themeTable, name); @@ -828,17 +825,16 @@ /* Ttk_CloneElement -- element factory procedure. * (style element create $name) "from" $theme ?$element? */ static int Ttk_CloneElement( - Tcl_Interp *interp, void *dummy, + Tcl_Interp *interp, TCL_UNUSED(void *), Ttk_Theme theme, const char *elementName, int objc, Tcl_Obj *const objv[]) { Ttk_Theme fromTheme; Ttk_ElementClass *fromElement; - (void)dummy; if (objc <= 0 || objc > 2) { Tcl_WrongNumArgs(interp, 0, objv, "theme ?element?"); return TCL_ERROR; } @@ -1180,11 +1176,11 @@ * Note that resource names are unconstrained; the Style * doesn't know what resources individual elements may use. */ static int StyleMapCmd( - ClientData clientData, /* Master StylePackageData pointer */ + ClientData clientData, /* StylePackageData pointer */ Tcl_Interp *interp, /* Current interpreter */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { StylePackageData *pkgPtr = (StylePackageData *)clientData; @@ -1264,14 +1260,14 @@ } styleName = Tcl_GetString(objv[2]); stylePtr = Ttk_GetStyle(theme, styleName); - if (objc == 3) { /* style default $styleName */ + if (objc == 3) { /* style configure $styleName */ Tcl_SetObjResult(interp, HashTableToDict(&stylePtr->defaultsTable)); return TCL_OK; - } else if (objc == 4) { /* style default $styleName -option */ + } else if (objc == 4) { /* style configure $styleName -option */ const char *optionName = Tcl_GetString(objv[3]); Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&stylePtr->defaultsTable, optionName); if (entryPtr) { Tcl_SetObjResult(interp, (Tcl_Obj*)Tcl_GetHashValue(entryPtr)); @@ -1317,13 +1313,11 @@ Tcl_WrongNumArgs(interp, 2, objv, "style -option ?state? ?default?"); return TCL_ERROR; } style = Ttk_GetStyle(theme, Tcl_GetString(objv[2])); - if (!style) { - return TCL_ERROR; - } + optionName = Tcl_GetString(objv[3]); if (objc >= 5) { Ttk_StateSpec stateSpec; /* @@@ SB: Ttk_GetStateFromObj(); 'offbits' spec is ignored */ @@ -1444,15 +1438,16 @@ /* + style theme names -- * Return list of registered themes. */ static int StyleThemeNamesCmd( - ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) + ClientData clientData, + Tcl_Interp *interp, + TCL_UNUSED(int), + TCL_UNUSED(Tcl_Obj *const *)) { StylePackageData *pkgPtr = (StylePackageData *)clientData; - (void)objc; - (void)objv; return TtkEnumerateHashTable(interp, &pkgPtr->themeTable); } /* + style theme settings $theme $script @@ -1460,11 +1455,11 @@ * Temporarily sets the current theme to $themeName, * evaluates $script, then restores the old theme. */ static int StyleThemeSettingsCmd( - ClientData clientData, /* Master StylePackageData pointer */ + ClientData clientData, /* StylePackageData pointer */ Tcl_Interp *interp, /* Current interpreter */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { StylePackageData *pkgPtr = (StylePackageData *)clientData; @@ -1612,17 +1607,42 @@ Ttk_RegisterLayoutTemplate(theme, layoutName, layoutTemplate); ThemeChanged(pkgPtr); } return TCL_OK; } + +/* + style theme styles ?$theme? -- + * Return list of styles available in $theme. + * Use the current theme if $theme is omitted. + */ +static int StyleThemeStylesCmd( + TCL_UNUSED(ClientData), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) +{ + Ttk_Theme themePtr; + + if (objc < 3 || objc > 4) { + Tcl_WrongNumArgs(interp, 3, objv, "?theme?"); + return TCL_ERROR; + } + + if (objc == 3) { + themePtr = Ttk_GetCurrentTheme(interp); + } else { + themePtr = Ttk_GetTheme(interp, Tcl_GetString(objv[3])); + } + if (!themePtr) + return TCL_ERROR; + + return TtkEnumerateHashTable(interp, &themePtr->styleTable); +} /* + style theme use $theme -- * Sets the current theme to $theme */ static int StyleThemeUseCmd( - ClientData clientData, /* Master StylePackageData pointer */ + ClientData clientData, /* StylePackageData pointer */ Tcl_Interp *interp, /* Current interpreter */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { StylePackageData *pkgPtr = (StylePackageData *)clientData; @@ -1652,10 +1672,11 @@ static const Ttk_Ensemble StyleThemeEnsemble[] = { { "create", StyleThemeCreateCmd, 0 }, { "names", StyleThemeNamesCmd, 0 }, { "settings", StyleThemeSettingsCmd, 0 }, + { "styles", StyleThemeStylesCmd, 0 }, { "use", StyleThemeUseCmd, 0 }, { NULL, 0, 0 } }; static const Ttk_Ensemble StyleElementEnsemble[] = { @@ -1675,11 +1696,11 @@ { NULL, 0, 0 } }; static int StyleObjCmd( - ClientData clientData, /* Master StylePackageData pointer */ + ClientData clientData, /* StylePackageData pointer */ Tcl_Interp *interp, /* Current interpreter */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { return Ttk_InvokeEnsemble(StyleEnsemble, 1, clientData,interp,objc,objv); Index: generic/ttk/ttkTrace.c ================================================================== --- generic/ttk/ttkTrace.c +++ generic/ttk/ttkTrace.c @@ -24,19 +24,17 @@ */ static char * VarTraceProc( ClientData clientData, /* Widget record pointer */ Tcl_Interp *interp, /* Interpreter containing variable. */ - const char *name1, /* (unused) */ - const char *name2, /* (unused) */ + TCL_UNUSED(const char *), /* name1 */ + TCL_UNUSED(const char *), /* name2 */ int flags) /* Information about what happened. */ { Ttk_TraceHandle *tracePtr = (Ttk_TraceHandle *)clientData; const char *name, *value; Tcl_Obj *valuePtr; - (void)name1; - (void)name2; if (Tcl_InterpDeleted(interp)) { return NULL; } @@ -51,11 +49,11 @@ * indicator that we wanted this handler to be deleted (see below), * cleanup the ClientData bits and exit. */ if (tracePtr->interp == NULL) { Tcl_DecrRefCount(tracePtr->varnameObj); - ckfree((ClientData)tracePtr); + ckfree(tracePtr); return NULL; } Tcl_TraceVar2(interp, name, NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, VarTraceProc, clientData); @@ -96,11 +94,11 @@ h->clientData = clientData; h->callback = callback; status = Tcl_TraceVar2(interp, Tcl_GetString(varnameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VarTraceProc, (ClientData)h); + VarTraceProc, h); if (status != TCL_OK) { Tcl_DecrRefCount(h->varnameObj); ckfree(h); return NULL; @@ -137,11 +135,11 @@ * Search the traces on the variable to see if the one we are tasked * with removing is present. */ while ((cd = Tcl_VarTraceInfo(h->interp, Tcl_GetString(h->varnameObj), TCL_GLOBAL_ONLY, VarTraceProc, cd)) != NULL) { - if (cd == (ClientData) h) { + if (cd == h) { break; } } /* * If the trace we wish to delete is not visible, Tcl_UntraceVar @@ -152,11 +150,11 @@ h->interp = NULL; return; } Tcl_UntraceVar2(h->interp, Tcl_GetString(h->varnameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VarTraceProc, (ClientData)h); + VarTraceProc, h); Tcl_DecrRefCount(h->varnameObj); ckfree(h); } } Index: generic/ttk/ttkTrack.c ================================================================== --- generic/ttk/ttkTrack.c +++ generic/ttk/ttkTrack.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004, Joe English * * TtkTrackElementState() -- helper routine for widgets * like scrollbars in which individual elements may * be active or pressed instead of the widget as a whole. * Index: generic/ttk/ttkTreeview.c ================================================================== --- generic/ttk/ttkTreeview.c +++ generic/ttk/ttkTreeview.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2004, Joe English + * Copyright © 2004, Joe English * * ttk::treeview widget implementation. */ #include "tkInt.h" @@ -439,25 +439,25 @@ static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL }; static const Tk_OptionSpec TreeviewOptionSpecs[] = { {TK_OPTION_STRING, "-columns", "columns", "Columns", "", offsetof(Treeview,tree.columnsObj), TCL_INDEX_NONE, - 0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ }, + 0, 0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ }, {TK_OPTION_STRING, "-displaycolumns","displayColumns","DisplayColumns", "#all", offsetof(Treeview,tree.displayColumnsObj), TCL_INDEX_NONE, - 0,0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED }, + 0, 0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-show", "show", "Show", DEFAULT_SHOW, offsetof(Treeview,tree.showObj), TCL_INDEX_NONE, - 0,0,SHOW_CHANGED | GEOMETRY_CHANGED }, + 0, 0,SHOW_CHANGED | GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode", "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE, - 0,(ClientData)SelectModeStrings,0 }, + 0, (void *)SelectModeStrings, 0 }, {TK_OPTION_PIXELS, "-height", "height", "Height", DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE, - 0,0,GEOMETRY_CHANGED}, + 0, 0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", @@ -790,13 +790,12 @@ */ static int PickupSlack(Treeview *tv, int extra) { int newSlack = tv->tree.slack + extra; - if ( (newSlack < 0 && 0 <= tv->tree.slack) - || (newSlack > 0 && 0 >= tv->tree.slack)) - { + if ((newSlack < 0 && 0 <= tv->tree.slack) + || (newSlack > 0 && 0 >= tv->tree.slack)) { tv->tree.slack = 0; return newSlack; } else { tv->tree.slack = newSlack; return 0; @@ -1099,14 +1098,13 @@ } if (mask & SCROLLCMD_CHANGED) { TtkScrollbarUpdateRequired(tv->tree.xscrollHandle); TtkScrollbarUpdateRequired(tv->tree.yscrollHandle); } - if ( (mask & SHOW_CHANGED) - && GetEnumSetFromObj( - interp,tv->tree.showObj,showStrings,&showFlags) != TCL_OK) - { + if ((mask & SHOW_CHANGED) + && GetEnumSetFromObj( + interp,tv->tree.showObj,showStrings,&showFlags) != TCL_OK) { return TCL_ERROR; } if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) { return TCL_ERROR; @@ -1778,11 +1776,11 @@ int colwidth = tv->tree.column0.width; Ttk_Box parcel = Ttk_MakeBox( x+indent, y, colwidth-indent, rowHeight); if (item->textObj) { displayItem.textObj = item->textObj; } if (item->imageObj) { displayItem.imageObj = item->imageObj; } - /* ??? displayItem.anchorObj = 0; <> */ + displayItem.anchorObj = tv->tree.column0.anchorObj; DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d); x += colwidth; } /* Draw data cells: @@ -2107,11 +2105,11 @@ static int TreeviewIndexCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; - int index = 0; + TkSizeT index = 0; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "item"); return TCL_ERROR; } @@ -2123,11 +2121,11 @@ while (item->prev) { ++index; item = item->prev; } - Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); return TCL_OK; } /* + $tv exists $itemid -- * Test if the specified item id is present in the tree. @@ -2199,13 +2197,12 @@ int x, y, x1; (void)objc; /* ASSERT: objc == 4 */ - if ( Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK - || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK - ) { + if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK + || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) { return TCL_ERROR; } dColumnNumber = IdentifyDisplayColumn(tv, x, &x1); if (dColumnNumber < 0) { @@ -2375,11 +2372,11 @@ { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; if (objc < 3) { - Tcl_WrongNumArgs(interp, 2, objv, "item ?option ?value??..."); + Tcl_WrongNumArgs(interp, 2, objv, "item ?-option ?value??..."); return TCL_ERROR; } if (!(item = FindItem(interp, tv, objv[2]))) { return TCL_ERROR; } @@ -2728,11 +2725,11 @@ delq = next; } ckfree(items); if (selItemDeleted) { - TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect"); + Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } TtkRedisplayWidget(&tv->core); return TCL_OK; } @@ -2748,13 +2745,12 @@ if (objc != 5) { Tcl_WrongNumArgs(interp, 2, objv, "item parent index"); return TCL_ERROR; } - if ( (item = FindItem(interp, tv, objv[2])) == 0 - || (parent = FindItem(interp, tv, objv[3])) == 0) - { + if ((item = FindItem(interp, tv, objv[2])) == 0 + || (parent = FindItem(interp, tv, objv[3])) == 0) { return TCL_ERROR; } /* Locate previous sibling based on $index: */ @@ -2877,13 +2873,12 @@ if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "column xposition"); return TCL_ERROR; } - if ( (column = FindColumn(interp, tv, objv[2])) == 0 - || Tcl_GetIntFromObj(interp, objv[3], &newx) != TCL_OK) - { + if ((column = FindColumn(interp, tv, objv[2])) == 0 + || Tcl_GetIntFromObj(interp, objv[3], &newx) != TCL_OK) { return TCL_ERROR; } for (;i < tv->tree.nDisplayColumns; ++i) { TreeColumn *c = tv->tree.displayColumns[i]; @@ -3009,11 +3004,11 @@ } break; } ckfree(items); - TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect"); + Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); TtkRedisplayWidget(&tv->core); return TCL_OK; } @@ -3298,21 +3293,22 @@ { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,0 }, - { "instate", TtkWidgetInstateCommand,0 }, { "insert", TreeviewInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, { "item", TreeviewItemCommand,0 }, { "move", TreeviewMoveCommand,0 }, { "next", TreeviewNextCommand,0 }, { "parent", TreeviewParentCommand,0 }, { "prev", TreeviewPrevCommand,0 }, { "see", TreeviewSeeCommand,0 }, { "selection" , TreeviewSelectionCommand,0 }, { "set", TreeviewSetCommand,0 }, { "state", TtkWidgetStateCommand,0 }, + { "style", TtkWidgetStyleCommand,0 }, { "tag", 0,TreeviewTagCommands }, { "xview", TreeviewXViewCommand,0 }, { "yview", TreeviewYViewCommand,0 }, { 0,0,0 } }; @@ -3349,12 +3345,11 @@ TTK_LAYOUT("Item", TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", TTK_PACK_LEFT) - TTK_GROUP("Treeitem.focus", TTK_PACK_LEFT, - TTK_NODE("Treeitem.text", TTK_PACK_LEFT)))) + TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) TTK_LAYOUT("Cell", TTK_GROUP("Treedata.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) Index: generic/ttk/ttkWidget.c ================================================================== --- generic/ttk/ttkWidget.c +++ generic/ttk/ttkWidget.c @@ -1,13 +1,13 @@ /* - * Copyright (c) 2003, Joe English + * Copyright © 2003, Joe English * * Core widget utilities. */ #include "tkInt.h" -#include "ttkTheme.h" +#include "ttkThemeInt.h" #include "ttkWidget.h" #ifdef MAC_OSX_TK #define TK_NO_DOUBLE_BUFFERING 1 #endif @@ -211,11 +211,11 @@ corePtr->flags |= WIDGET_DESTROYED; corePtr->widgetSpec->cleanupProc(corePtr); Tk_FreeConfigOptions( - (ClientData)corePtr, corePtr->optionTable, corePtr->tkwin); + corePtr, corePtr->optionTable, corePtr->tkwin); if (corePtr->layout) { Ttk_FreeLayout(corePtr->layout); } @@ -792,9 +792,29 @@ if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp,Tcl_NewStringObj(elementName,-1)); } + return TCL_OK; +} + +/* $w style + * Return the style currently applied to the widget. + */ + +int TtkWidgetStyleCommand( + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) +{ + WidgetCore *corePtr = (WidgetCore *)recordPtr; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + + Tcl_SetObjResult(interp, Tcl_NewStringObj( + Ttk_StyleName(Ttk_LayoutStyle(corePtr->layout)), -1)); + return TCL_OK; } /*EOF*/ Index: generic/ttk/ttkWidget.h ================================================================== --- generic/ttk/ttkWidget.h +++ generic/ttk/ttkWidget.h @@ -87,19 +87,21 @@ MODULE_SCOPE int TtkCoreConfigure(Tcl_Interp*, void *, int mask); /* Common widget commands: */ +MODULE_SCOPE int TtkWidgetCgetCommand( + void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetConfigureCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); -MODULE_SCOPE int TtkWidgetCgetCommand( +MODULE_SCOPE int TtkWidgetIdentifyCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetInstateCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetStateCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); -MODULE_SCOPE int TtkWidgetIdentifyCommand( +MODULE_SCOPE int TtkWidgetStyleCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); /* Widget constructor: */ MODULE_SCOPE int TtkWidgetConstructorObjCmd( @@ -162,15 +164,10 @@ MODULE_SCOPE Ttk_TraceHandle *Ttk_TraceVariable( Tcl_Interp*, Tcl_Obj *varnameObj, Ttk_TraceProc callback, void *clientData); MODULE_SCOPE void Ttk_UntraceVariable(Ttk_TraceHandle *); MODULE_SCOPE int Ttk_FireTrace(Ttk_TraceHandle *); -/* - * Virtual events: - */ -MODULE_SCOPE void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName); - /* * Helper routines for data accessor commands: */ MODULE_SCOPE int TtkEnumerateOptions( Tcl_Interp *, void *, const Tk_OptionSpec *, Tk_OptionTable, Tk_Window); Index: library/bgerror.tcl ================================================================== --- library/bgerror.tcl +++ library/bgerror.tcl @@ -4,14 +4,14 @@ # the error message and gives the user a chance to see a more detailed # stack trace, and possible do something more interesting with that # trace (like save it to a log). This is adapted from work done by # Donal K. Fellows. # -# Copyright (c) 1998-2000 by Ajuba Solutions. -# Copyright (c) 2007 by ActiveState Software Inc. -# Copyright (c) 2007 Daniel A. Steffen -# Copyright (c) 2009 Pat Thoyts +# Copyright © 1998-2000 Ajuba Solutions. +# Copyright © 2007 ActiveState Software Inc. +# Copyright © 2007 Daniel A. Steffen +# Copyright © 2009 Pat Thoyts namespace eval ::tk::dialog::error { namespace import -force ::tk::msgcat::* namespace export bgerror option add *ErrorDialog.function.text [mc "Save To Log"] \ @@ -39,20 +39,20 @@ proc ::tk::dialog::error::Details {} { set w .bgerrorDialog set caption [option get $w.function text {}] set command [option get $w.function command {}] - if { ($caption eq "") || ($command eq "") } { + if {($caption eq "") || ($command eq "")} { grid forget $w.function } lappend command [$w.top.info.text get 1.0 end-1c] $w.function configure -text $caption -command $command grid $w.top.info - -sticky nsew -padx 3m -pady 3m } proc ::tk::dialog::error::SaveToLog {text} { - if { $::tcl_platform(platform) eq "windows" } { + if {$::tcl_platform(platform) eq "windows"} { set allFiles *.* } else { set allFiles * } set types [list \ @@ -127,15 +127,15 @@ # which one of those conditions is met. set displayedErr "" set lines 0 set maxLine 45 foreach line [split $err \n] { - if { [string length $line] > $maxLine } { - append displayedErr "[string range $line 0 [expr {$maxLine-3}]]..." + if {[string length $line] > $maxLine} { + append displayedErr "[string range $line 0 $maxLine-3]..." break } - if { $lines > 4 } { + if {$lines > 4} { append displayedErr "..." break } else { append displayedErr "${line}\n" } @@ -180,11 +180,11 @@ ttk::scrollbar $W.scroll -command [list $W.text yview] pack $W.scroll -side right -fill y pack $W.text -side left -expand yes -fill both $W.text insert 0.0 "$err\n$info" $W.text mark set insert 0.0 - bind $W.text { focus %W } + bind $W.text {focus %W} $W.text configure -state disabled # 2. Fill the top part with bitmap and message # Max-width of message is the width of the screen... Index: library/button.tcl ================================================================== --- library/button.tcl +++ library/button.tcl @@ -2,13 +2,13 @@ # # This file defines the default bindings for Tk label, button, # checkbutton, and radiobutton widgets and provides procedures # that help in implementing those bindings. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1996 Sun Microsystems, Inc. -# Copyright (c) 2002 ActiveState Corporation. +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1996 Sun Microsystems, Inc. +# Copyright © 2002 ActiveState Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -39,14 +39,14 @@ bind Checkbutton { tk::ButtonLeave %W } } if {"win32" eq [tk windowingsystem]} { - bind Checkbutton { + bind Checkbutton <=> { tk::CheckRadioInvoke %W select } - bind Checkbutton { + bind Checkbutton <+> { tk::CheckRadioInvoke %W select } bind Checkbutton { tk::CheckRadioInvoke %W deselect } Index: library/choosedir.tcl ================================================================== --- library/choosedir.tcl +++ library/choosedir.tcl @@ -1,10 +1,10 @@ # choosedir.tcl -- # # Choose directory dialog implementation for Unix/Mac. # -# Copyright (c) 1998-2000 by Scriptics Corporation. +# Copyright © 1998-2000 Scriptics Corporation. # All rights reserved. # Make sure the tk::dialog namespace, in which all dialogs should live, exists namespace eval ::tk::dialog {} namespace eval ::tk::dialog::file {} Index: library/clrpick.tcl ================================================================== --- library/clrpick.tcl +++ library/clrpick.tcl @@ -1,11 +1,11 @@ # clrpick.tcl -- # # Color selection dialog for platforms that do not support a # standard color selection dialog. # -# Copyright (c) 1996 Sun Microsystems, Inc. +# Copyright © 1996 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # ToDo: Index: library/comdlg.tcl ================================================================== --- library/comdlg.tcl +++ library/comdlg.tcl @@ -1,11 +1,11 @@ # comdlg.tcl -- # # Some functions needed for the common dialog boxes. Probably need to go # in a different file. # -# Copyright (c) 1996 Sun Microsystems, Inc. +# Copyright © 1996 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -27,11 +27,12 @@ # specs = { # {-commandlineswitch resourceName ResourceClass defaultValue verifier} # {....} # } # -# flags = currently unused. +# flags = a list of flags. Currently supported flags are: +# DONTSETDEFAULTS = skip default values setting # # argList = The list of "-option value" pairs. # proc tclParseConfigSpec {w specs flags argList} { upvar #0 $w data @@ -61,12 +62,14 @@ "value for \"$cmdsw\" missing" } # 2: set the default values # - foreach cmdsw [array names cmd] { - set data($cmdsw) $def($cmdsw) + if {"DONTSETDEFAULTS" ni $flags} { + foreach cmdsw [array names cmd] { + set data($cmdsw) $def($cmdsw) + } } # 3: parse the argument list # foreach {cmdsw value} $argList { Index: library/console.tcl ================================================================== --- library/console.tcl +++ library/console.tcl @@ -2,13 +2,13 @@ # # This code constructs the console window for an application. It # can be used by non-unix systems that do not have built-in support # for shells. # -# Copyright (c) 1995-1997 Sun Microsystems, Inc. -# Copyright (c) 1998-2000 Ajuba Solutions. -# Copyright (c) 2007-2008 Daniel A. Steffen +# Copyright © 1995-1997 Sun Microsystems, Inc. +# Copyright © 1998-2000 Ajuba Solutions. +# Copyright © 2007-2008 Daniel A. Steffen # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -129,11 +129,11 @@ aqua { set preferred {Monaco 10} } win32 { set preferred {ProFontWindows 8 Consolas 8} } default { set preferred {} } } foreach {family size} $preferred { - if {[lsearch -exact $families $family] != -1} { + if {$family in $families} { font configure TkConsoleFont -family $family -size $size break } } @@ -213,11 +213,11 @@ -title [mc "Select a file to source"] \ -filetypes [list \ [list [mc "Tcl Scripts"] .tcl] \ [list [mc "All Files"] *]]] if {$filename ne ""} { - set cmd [list source $filename] + set cmd [list source -encoding utf-8 $filename] if {[catch {consoleinterp eval $cmd} result]} { ConsoleOutput stderr "$result\n" } } } @@ -452,27 +452,20 @@ <> <> <> <> <> - <> + <> <> + <> + <> } { event add $ev $key bind Console $key {} } - if {[tk windowingsystem] eq "aqua"} { - foreach {ev key} { - <> - <> - } { - event add $ev $key - bind Console $key {} - } - if {$::tk::console::useFontchooser} { - bind Console [list ::tk::console::FontchooserToggle] - } + if {$::tk::console::useFontchooser} { + bind Console [list ::tk::console::FontchooserToggle] } bind Console <> { if {[%W compare insert > promptEnd]} { ::tk::console::Expand %W } @@ -590,16 +583,14 @@ bind Console { tk::ConsoleInsert %W %A } bind Console { eval destroy [winfo child .] - source [file join $tk_library console.tcl] + source -encoding utf-8 [file join $tk_library console.tcl] } - if {[tk windowingsystem] eq "aqua"} { - bind Console { - exit - } + bind Console { + exit } bind Console <> { ::tk::console::Cut %W } bind Console <> { ::tk::console::Copy %W } bind Console <> { ::tk::console::Paste %W } @@ -738,13 +729,13 @@ tk fontchooser show } } proc ::tk::console::FontchooserVisibility {index} { if {[tk fontchooser configure -visible]} { - .menubar.edit entryconfigure $index -label [msgcat::mc "Hide Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"] } else { - .menubar.edit entryconfigure $index -label [msgcat::mc "Show Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"] } } proc ::tk::console::FontchooserFocus {w isFocusIn} { if {$isFocusIn} { tk fontchooser configure -parent $w -font TkConsoleFont \ Index: library/demos/bind.tcl ================================================================== --- library/demos/bind.tcl +++ library/demos/bind.tcl @@ -65,14 +65,14 @@ foreach tag {d1 d2 d3 d4 d5 d6} { $w.text tag bind $tag "$w.text tag configure $tag $bold" $w.text tag bind $tag "$w.text tag configure $tag $normal" } # Main widget program sets variable tk_demoDirectory -$w.text tag bind d1 {source [file join $tk_demoDirectory items.tcl]} -$w.text tag bind d2 {source [file join $tk_demoDirectory plot.tcl]} -$w.text tag bind d3 {source [file join $tk_demoDirectory ctext.tcl]} -$w.text tag bind d4 {source [file join $tk_demoDirectory arrow.tcl]} -$w.text tag bind d5 {source [file join $tk_demoDirectory ruler.tcl]} -$w.text tag bind d6 {source [file join $tk_demoDirectory cscroll.tcl]} +$w.text tag bind d1 {source -encoding utf-8 [file join $tk_demoDirectory items.tcl]} +$w.text tag bind d2 {source -encoding utf-8 [file join $tk_demoDirectory plot.tcl]} +$w.text tag bind d3 {source -encoding utf-8 [file join $tk_demoDirectory ctext.tcl]} +$w.text tag bind d4 {source -encoding utf-8 [file join $tk_demoDirectory arrow.tcl]} +$w.text tag bind d5 {source -encoding utf-8 [file join $tk_demoDirectory ruler.tcl]} +$w.text tag bind d6 {source -encoding utf-8 [file join $tk_demoDirectory cscroll.tcl]} $w.text mark set insert 0.0 $w.text configure -state disabled Index: library/demos/cscroll.tcl ================================================================== --- library/demos/cscroll.tcl +++ library/demos/cscroll.tcl @@ -54,49 +54,65 @@ } $c bind all "scrollEnter $c" $c bind all "scrollLeave $c" $c bind all "scrollButton $c" -bind $c "$c scan mark %x %y" -bind $c "$c scan dragto %x %y" -if {[tk windowingsystem] eq "aqua"} { - bind $c { - %W yview scroll [expr {-(%D)}] units - } - bind $c { - %W yview scroll [expr {-10 * (%D)}] units - } - bind $c { - %W xview scroll [expr {-(%D)}] units - } - bind $c { - %W xview scroll [expr {-10 * (%D)}] units - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/30 = 0, - # but - # (int)-1/30 = -1 - # The following code ensure equal +/- behaviour. - bind $c { - if {%D >= 0} { - %W yview scroll [expr {-%D/30}] units - } else { - %W yview scroll [expr {(29-%D)/30}] units - } - } - bind $c { - if {%D >= 0} { - %W xview scroll [expr {-%D/30}] units - } else { - %W xview scroll [expr {(29-%D)/30}] units - } - } -} - -if {[tk windowingsystem] eq "x11"} { +if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" + bind $c { + %W yview scroll [expr {-%D}] units + } + bind $c { + %W yview scroll [expr {-10*%D}] units + } + bind $c { + %W xview scroll [expr {-%D}] units + } + bind $c { + %W xview scroll [expr {-10*%D}] units + } +} else { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" + # We must make sure that positive and negative movements are rounded + # equally to integers, avoiding the problem that + # (int)1/-30 = -1, + # but + # (int)-1/-30 = 0 + # The following code ensure equal +/- behaviour. + bind $c { + if {%D >= 0} { + %W yview scroll [expr {%D/-30}] units + } else { + %W yview scroll [expr {(%D-29)/-30}] units + } + } + bind $c { + if {%D >= 0} { + %W yview scroll [expr {%D/-3}] units + } else { + %W yview scroll [expr {(%D-2)/-3}] units + } + } + bind $c { + if {%D >= 0} { + %W xview scroll [expr {%D/-30}] units + } else { + %W xview scroll [expr {(%D-29)/-30}] units + } + } + bind $c { + if {%D >= 0} { + %W xview scroll [expr {%D/-3}] units + } else { + %W xview scroll [expr {(%D-2)/-3}] units + } + } +} + +if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} { # Support for mousewheels on Linux/Unix commonly comes through mapping # the wheel to the extended buttons. If you have a mousewheel, find # Linux configuration info at: # http://linuxreviews.org/howtos/xfree/mouse/ bind $c { @@ -116,22 +132,10 @@ } bind $c { if {!$tk_strictMotif} { %W xview scroll 5 units } - } - if {[package vsatisfies [package provide Tk] 8.7]} { - bind $c { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind $c { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } } } proc scrollEnter canvas { Index: library/demos/ctext.tcl ================================================================== --- library/demos/ctext.tcl +++ library/demos/ctext.tcl @@ -48,11 +48,15 @@ $c bind text "textInsert $c %A" $c bind text "textInsert $c \\n" $c bind text "textBs $c" $c bind text "textBs $c" $c bind text "textDel $c" -$c bind text "textPaste $c @%x,%y" +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { + $c bind text "textPaste $c @%x,%y" +} else { + $c bind text "textPaste $c @%x,%y" +} # Next, create some items that allow the text's anchor position # to be edited. proc mkTextConfigBox {w x y option value color} { Index: library/demos/dialog1.tcl ================================================================== --- library/demos/dialog1.tcl +++ library/demos/dialog1.tcl @@ -1,25 +1,25 @@ # dialog1.tcl -- # # This demonstration script creates a dialog box with a local grab. -interp create slave -load {} Tk slave -slave eval { - wm title . slave +interp create child +load {} Tk child +child eval { + wm title . child wm geometry . +700+30 pack [text .t -width 30 -height 10] } after idle {.dialog1.msg configure -wraplength 4i} -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.} \ +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.} \ info 0 OK Cancel {Show Code}] switch $i { 0 {puts "You pressed OK"} 1 {puts "You pressed Cancel"} 2 {showCode .dialog1} } -if {[interp exists slave]} { - interp delete slave +if {[interp exists child]} { + interp delete child } Index: library/demos/entry3.tcl ================================================================== --- library/demos/entry3.tcl +++ library/demos/entry3.tcl @@ -62,17 +62,17 @@ } labelframe $w.l1 -text "Integer Entry" # Alternatively try using {string is digit} for arbitrary length numbers, # and not just 32-bit ones. -entry $w.l1.e -validate focus -vcmd {string is integer %P} +entry $w.l1.e -validate focus -validatecommand {string is integer %P} $w.l1.e configure -invalidcommand \ "focusAndFlash %W [$w.l1.e cget -fg] [$w.l1.e cget -bg]" pack $w.l1.e -fill x -expand 1 -padx 1m -pady 1m labelframe $w.l2 -text "Length-Constrained Entry" -entry $w.l2.e -validate key -invcmd bell -vcmd {expr {[string length %P]<10}} +entry $w.l2.e -validate key -invcmd bell -validatecommand {expr {[string length %P]<10}} pack $w.l2.e -fill x -expand 1 -padx 1m -pady 1m ### PHONE NUMBER ENTRY ### # Note that the source to this is quite a bit longer as the behaviour # demonstrated is a lot more ambitious than with the others. @@ -100,11 +100,11 @@ # char - The character (or string, though that will always be # refused) to be overwritten at that point. proc validatePhoneChange {W vmode idx char} { global phoneNumberMap entry3content - if {$idx == -1} {return 1} + if {$idx < 0} {return 1} after idle [list $W configure -validate $vmode -invcmd bell] if { !($idx<3 || $idx==6 || $idx==7 || $idx==11 || $idx>15) && [string match {[0-9A-Za-z]} $char] } then { @@ -159,11 +159,11 @@ } } labelframe $w.l3 -text "US Phone-Number Entry" entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \ - -vcmd {validatePhoneChange %W %v %i %S} + -validatecommand {validatePhoneChange %W %v %i %S} # Click to focus goes to the first editable character... bind $w.l3.e { if {"%d" ne "NotifyAncestor"} { %W icursor 3 after idle {%W selection clear} @@ -172,14 +172,14 @@ bind $w.l3.e <> {phoneSkipLeft %W} bind $w.l3.e <> {phoneSkipRight %W} pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m labelframe $w.l4 -text "Password Entry" -entry $w.l4.e -validate key -show "*" -vcmd {expr {[string length %P]<=8}} +entry $w.l4.e -validate key -show "*" -validatecommand {expr {[string length %P]<=8}} pack $w.l4.e -fill x -expand 1 -padx 1m -pady 1m lower [frame $w.mid] grid $w.l1 $w.l2 -in $w.mid -padx 3m -pady 1m -sticky ew grid $w.l3 $w.l4 -in $w.mid -padx 3m -pady 1m -sticky ew grid columnconfigure $w.mid {0 1} -uniform 1 pack $w.msg -side top pack $w.mid -fill both -expand 1 Index: library/demos/floor.tcl ================================================================== --- library/demos/floor.tcl +++ library/demos/floor.tcl @@ -1357,10 +1357,15 @@ $c bind floor1 "floorDisplay $c 1" $c bind floor2 "floorDisplay $c 2" $c bind floor3 "floorDisplay $c 3" $c bind room "newRoom $c" $c bind room {set currentRoom ""} -bind $c "$c scan mark %x %y" -bind $c "$c scan dragto %x %y" +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" +} else { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" +} bind $c "unset currentRoom" set currentRoom "" trace variable currentRoom w "roomChanged $c" Index: library/demos/fontchoose.tcl ================================================================== --- library/demos/fontchoose.tcl +++ library/demos/fontchoose.tcl @@ -53,17 +53,15 @@ grid $f.msg $f.vs -sticky news grid $f.font - -sticky e grid columnconfigure $f 0 -weight 1 grid rowconfigure $f 0 -weight 1 -bind $w { - bind %W {} - grid propagate %W.f 0 -} ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] grid $f -sticky news grid $btns -sticky ew grid columnconfigure $w 0 -weight 1 grid rowconfigure $w 0 -weight 1 +update idletasks +grid propagate $f 0 Index: library/demos/goldberg.tcl ================================================================== --- library/demos/goldberg.tcl +++ library/demos/goldberg.tcl @@ -111,13 +111,13 @@ unset animationCallbacks(goldberg) } DoCtrlFrame $w DoDetailFrame $w if {[tk windowingsystem] ne "aqua"} { - ttk::button $w.show -text "\u00bb" -command [list ShowCtrl $w] -width 2 + ttk::button $w.show -text "»" -command [list ShowCtrl $w] -width 2 } else { - button $w.show -text "\u00bb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg) + button $w.show -text "»" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg) } place $w.show -in $w.c -relx 1 -rely 0 -anchor ne update } @@ -202,14 +202,14 @@ # Map or unmap the ctrl window proc ShowCtrl {w} { if {[winfo ismapped $w.ctrl]} { pack forget $w.ctrl - $w.show config -text "\u00bb" + $w.show config -text "»" } else { pack $w.ctrl -side right -fill both -ipady 5 - $w.show config -text "\u00ab" + $w.show config -text "»" } } proc DrawAll {w} { ResetStep Index: library/demos/items.tcl ================================================================== --- library/demos/items.tcl +++ library/demos/items.tcl @@ -15,11 +15,11 @@ wm title $w "Canvas Item Demonstration" wm iconname $w "Items" positionWindow $w set c $w.frame.c -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." +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." pack $w.msg -side top ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x @@ -171,14 +171,21 @@ # Set up event bindings for canvas: $c bind item "itemEnter $c" $c bind item "itemLeave $c" -bind $c "$c scan mark %x %y" -bind $c "$c scan dragto %x %y" -bind $c "itemMark $c %x %y" -bind $c "itemStroke $c %x %y" +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { + bind $c "itemMark $c %x %y" + bind $c "itemStroke $c %x %y" + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" +} else { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" + bind $c "itemMark $c %x %y" + bind $c "itemStroke $c %x %y" +} bind $c <> "itemsUnderArea $c" bind $c "itemStartDrag $c %x %y" bind $c "itemDrag $c %x %y" # Utility procedures for highlighting the item under the pointer: @@ -248,18 +255,18 @@ proc itemsUnderArea {c} { global areaX1 areaY1 areaX2 areaY2 set area [$c find withtag area] set items "" foreach i [$c find enclosed $areaX1 $areaY1 $areaX2 $areaY2] { - if {[lsearch [$c gettags $i] item] != -1} { + if {[lsearch [$c gettags $i] item] >= 0} { lappend items $i } } puts stdout "Items enclosed by area: $items" set items "" foreach i [$c find overlapping $areaX1 $areaY1 $areaX2 $areaY2] { - if {[lsearch [$c gettags $i] item] != -1} { + if {[lsearch [$c gettags $i] item] >= 0} { lappend items $i } } puts stdout "Items overlapping area: $items" } Index: library/demos/ixset ================================================================== --- library/demos/ixset +++ library/demos/ixset @@ -52,11 +52,11 @@ global screenbla ; set screenbla "blank" global screentim ; set screentim 600 global screencyc ; set screencyc 600 set xfd [open "|xset q" r] - while {[gets $xfd line] > -1} { + while {[gets $xfd line] >= 0} { switch -- [lindex $line 0] { auto { set rpt [lindex $line 1] if {$rpt eq "repeat:"} { set kbdrep [lindex $line 2] Index: library/demos/knightstour.tcl ================================================================== --- library/demos/knightstour.tcl +++ library/demos/knightstour.tcl @@ -1,6 +1,6 @@ -# Copyright (C) 2008 Pat Thoyts +# Copyright © 2008 Pat Thoyts # # Calculate a Knight's tour of a chessboard. # # This uses Warnsdorff's rule to calculate the next square each # time. This specifies that the next square should be the one that @@ -19,19 +19,19 @@ # # You can drag the knight to a specific square to start if you wish. # If you let it repeat then it will choose random start positions # for each new tour. -package require Tk 8.5 +package require Tk # Return a list of accessible squares from a given square proc ValidMoves {square} { set moves {} foreach pair {{-1 -2} {-2 -1} {-2 1} {-1 2} {1 2} {2 1} {2 -1} {1 -2}} { set col [expr {($square % 8) + [lindex $pair 0]}] set row [expr {($square / 8) + [lindex $pair 1]}] - if {$row > -1 && $row < 8 && $col > -1 && $col < 8} { + if {$row >= 0 && $row < 8 && $col >= 0 && $col < 8} { lappend moves [expr {$row * 8 + $col}] } } return $moves } @@ -39,11 +39,11 @@ # Return the number of available moves for this square proc CheckSquare {square} { variable visited set moves 0 foreach test [ValidMoves $square] { - if {[lsearch -exact -integer $visited $test] == -1} { + if {[lsearch -exact -integer $visited $test] < 0} { incr moves } } return $moves } @@ -53,11 +53,11 @@ proc Next {square} { variable visited set minimum 9 set nextSquare -1 foreach testSquare [ValidMoves $square] { - if {[lsearch -exact -integer $visited $testSquare] == -1} { + if {[lsearch -exact -integer $visited $testSquare] < 0} { set count [CheckSquare $testSquare] if {$count < $minimum} { set minimum $count set nextSquare $testSquare } elseif {$count == $minimum} { @@ -188,11 +188,11 @@ ttk::checkbutton $dlg.tf.cc -text Repeat \ -variable [namespace which -variable continuous] ttk::button $dlg.tf.b1 -text Start -command [list Tour $dlg] ttk::button $dlg.tf.b2 -text Exit -command [list Exit $dlg] set square 0 - for {set row 7} {$row != -1} {incr row -1} { + for {set row 7} {$row >= 0} {incr row -1} { for {set col 0} {$col < 8} {incr col} { if {(($col & 1) ^ ($row & 1))} { set fill tan3 ; set dfill tan4 } else { set fill bisque ; set dfill bisque3 @@ -203,14 +203,14 @@ -width 2 -state disabled -outline black } } if {[tk windowingsystem] ne "x11"} { catch {eval font create KnightFont -size -24} - $c create text 0 0 -font KnightFont -text "\u265e" \ + $c create text 0 0 -font KnightFont -text "♞" \ -anchor nw -tags knight -fill black -activefill "#600000" } else { - # On X11 we cannot reliably tell if the \u265e glyph is available + # On X11 we cannot reliably tell if the ♞ glyph is available # so just use a polygon set pts { 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16 2 17 4 14 5 15 3 17 5 17 9 14 10 15 5 21 } Index: library/demos/menu.tcl ================================================================== --- library/demos/menu.tcl +++ library/demos/menu.tcl @@ -61,11 +61,11 @@ } else { set modifier Meta } foreach i {A B C D E F} { $m add command -label "Print letter \"$i\"" -underline 14 \ - -accelerator Meta+$i -command "puts $i" -accelerator $modifier+$i + -accelerator $modifier+$i -command "puts $i" bind $w <$modifier-[string tolower $i]> "puts $i" } set m $w.menu.cascade $w.menu add cascade -label "Cascades" -menu $m -underline 0 @@ -149,13 +149,28 @@ menu entry." {} 0 OK ] set m $w.menu.colors $w.menu add cascade -label "Colors" -menu $m -underline 1 menu $m -tearoff 1 -foreach i {red orange yellow green blue} { - $m add command -label $i -background $i -command [list \ - puts "You invoked \"$i\"" ] +if {[tk windowingsystem] eq "aqua"} { + # Aqua ignores the -background and -foreground options, but a compound + # button can be used for selecting colors. + foreach i {red orange yellow green blue} { + image create photo image_$i -height 16 -width 16 + image_$i put black -to 0 0 16 1 + image_$i put black -to 0 1 1 16 + image_$i put black -to 0 15 16 16 + image_$i put black -to 15 1 16 16 + image_$i put $i -to 1 1 15 15 + $m add command -label $i -image image_$i -compound left -command [list \ + puts "You invoked \"$i\"" ] + } +} else { + foreach i {red orange yellow green blue} { + $m add command -label $i -background $i -command [list \ + puts "You invoked \"$i\"" ] + } } $w configure -menu $w.menu bind Menu <> { Index: library/demos/pendulum.tcl ================================================================== --- library/demos/pendulum.tcl +++ library/demos/pendulum.tcl @@ -48,12 +48,12 @@ for {set i 90} {$i>=0} {incr i -10} { # Coordinates of these items don't matter; they will be set properly below $w.k create line 0 0 1 1 -smooth true -tags graph$i -fill grey$i } -$w.k create text 0 0 -anchor ne -text "\u03b8" -tags label_theta -$w.k create text 0 0 -anchor ne -text "\u03b4\u03b8" -tags label_dtheta +$w.k create text 0 0 -anchor ne -text "θ" -tags label_theta +$w.k create text 0 0 -anchor ne -text "δθ" -tags label_dtheta pack $w.k -in $w.p.l2 -fill both -expand true # Initialize some variables set points {} set Theta 45.0 Index: library/demos/spin.tcl ================================================================== --- library/demos/spin.tcl +++ library/demos/spin.tcl @@ -36,11 +36,11 @@ Canberra Sydney Melbourne Perth Adelaide Brisbane Hobart Darwin "Alice Springs" } spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ - -vcmd {string is integer %P} + -validatecommand {string is integer %P} spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 spinbox $w.s3 -values $australianCities -width 10 #entry $w.e1 #entry $w.e2 Index: library/demos/square ================================================================== --- library/demos/square +++ library/demos/square @@ -9,12 +9,12 @@ # bindings for the widget: # # Button-1 press/drag: moves square to mouse # "a": toggle size animation on/off -package require Tk ;# We use Tk generally, and... -package require Tktest ;# ... we use the square widget too. +package require tk ;# We use Tk generally, and... +package require tk::test ;# ... we use the square widget too. square .s pack .s -expand yes -fill both wm minsize . 1 1 ADDED library/demos/systray.tcl Index: library/demos/systray.tcl ================================================================== --- /dev/null +++ library/demos/systray.tcl @@ -0,0 +1,89 @@ +# systray.tcl -- +# +# This demonstration script showcases the tk systray and tk sysnotify commands. +# + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .systray +destroy $w +toplevel $w +wm title $w "System Tray Demonstration" +positionWindow $w + +catch {tk systray destroy} +set trayIconExists false + +set iconmenu .menubar +destroy $iconmenu +menu $iconmenu +$iconmenu add command -label "Status" -command { puts "status icon clicked" } +$iconmenu add command -label "Exit" -command exit + +pack [label $w.l -text "This demonstration showcases + the tk systray and tk sysnotify commands. + Running this demo creates the systray icon. + Clicking the buttons below modifies and destroys the icon + and displays the notification."] + +image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw== + +labelframe $w.f -text "Tray Icon" +button $w.f.b0 -text "Create" -command create +button $w.f.b1 -text "Modify" -command modify +button $w.f.b2 -text "Destroy" -command remove +pack $w.f.b0 $w.f.b1 $w.f.b2 -padx 5 -pady 3 -side left -expand true -fill x + +button $w.b3 -text "Display Notification" -command notify +pack $w.f $w.b3 -expand true -fill x -padx 5 -pady 5 + +proc create {} { + global trayIconExists + if {$trayIconExists} { + tk_messageBox -message "Systray icon already exists" + return + } + tk systray create -image book -text "Systray sample" \ + -button1 {puts "foo"} \ + -button3 {tk_popup $iconmenu [winfo pointerx .] [winfo pointery .]} + set trayIconExists true +} + +proc modify {} { + global trayIconExists + if {!$trayIconExists} { + tk_messageBox -message "Please create systray icon first" + return + } + image create photo page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7 + tk systray configure -image page + tk systray configure -text "Modified text" + tk systray configure -button1 {puts "this is a different output"} + tk systray configure -button3 {puts "hello yall"} +} + +proc notify {} { + global trayIconExists + if {!$trayIconExists} { + tk_messageBox -message "Please create systray icon first" + return + } + tk sysnotify "Alert" "This is an alert" +} + +proc remove {} { + global trayIconExists + if {!$trayIconExists} { + tk_messageBox -message "Systray icon was already destroyed" + return + } + tk systray destroy + set trayIconExists false +} + +create + +## See Code / Dismiss buttons +pack [addSeeDismiss $w.buttons $w] -side bottom -fill x Index: library/demos/tclIndex ================================================================== --- library/demos/tclIndex +++ library/demos/tclIndex @@ -4,64 +4,66 @@ # more commands. Typically each line is a command that # sets an element in the auto_index array, where the # element name is the name of a command and the value is # a script that loads the command. -set auto_index(arrowSetup) [list source [file join $dir arrow.tcl]] -set auto_index(arrowMove1) [list source [file join $dir arrow.tcl]] -set auto_index(arrowMove2) [list source [file join $dir arrow.tcl]] -set auto_index(arrowMove3) [list source [file join $dir arrow.tcl]] -set auto_index(textLoadFile) [list source [file join $dir search.tcl]] -set auto_index(textSearch) [list source [file join $dir search.tcl]] -set auto_index(textToggle) [list source [file join $dir search.tcl]] -set auto_index(itemEnter) [list source [file join $dir items.tcl]] -set auto_index(itemLeave) [list source [file join $dir items.tcl]] -set auto_index(itemMark) [list source [file join $dir items.tcl]] -set auto_index(itemStroke) [list source [file join $dir items.tcl]] -set auto_index(itemsUnderArea) [list source [file join $dir items.tcl]] -set auto_index(itemStartDrag) [list source [file join $dir items.tcl]] -set auto_index(itemDrag) [list source [file join $dir items.tcl]] -set auto_index(butPress) [list source [file join $dir items.tcl]] -set auto_index(loadDir) [list source [file join $dir image2.tcl]] -set auto_index(loadImage) [list source [file join $dir image2.tcl]] -set auto_index(rulerMkTab) [list source [file join $dir ruler.tcl]] -set auto_index(rulerNewTab) [list source [file join $dir ruler.tcl]] -set auto_index(rulerSelectTab) [list source [file join $dir ruler.tcl]] -set auto_index(rulerMoveTab) [list source [file join $dir ruler.tcl]] -set auto_index(rulerReleaseTab) [list source [file join $dir ruler.tcl]] -set auto_index(mkTextConfig) [list source [file join $dir ctext.tcl]] -set auto_index(textEnter) [list source [file join $dir ctext.tcl]] -set auto_index(textInsert) [list source [file join $dir ctext.tcl]] -set auto_index(textPaste) [list source [file join $dir ctext.tcl]] -set auto_index(textB1Press) [list source [file join $dir ctext.tcl]] -set auto_index(textB1Move) [list source [file join $dir ctext.tcl]] -set auto_index(textBs) [list source [file join $dir ctext.tcl]] -set auto_index(textDel) [list source [file join $dir ctext.tcl]] -set auto_index(bitmapRow) [list source [file join $dir bitmap.tcl]] -set auto_index(scrollEnter) [list source [file join $dir cscroll.tcl]] -set auto_index(scrollLeave) [list source [file join $dir cscroll.tcl]] -set auto_index(scrollButton) [list source [file join $dir cscroll.tcl]] -set auto_index(textWindOn) [list source [file join $dir twind.tcl]] -set auto_index(textWindOff) [list source [file join $dir twind.tcl]] -set auto_index(textWindPlot) [list source [file join $dir twind.tcl]] -set auto_index(embPlotDown) [list source [file join $dir twind.tcl]] -set auto_index(embPlotMove) [list source [file join $dir twind.tcl]] -set auto_index(textWindDel) [list source [file join $dir twind.tcl]] -set auto_index(embDefBg) [list source [file join $dir twind.tcl]] -set auto_index(floorDisplay) [list source [file join $dir floor.tcl]] -set auto_index(newRoom) [list source [file join $dir floor.tcl]] -set auto_index(roomChanged) [list source [file join $dir floor.tcl]] -set auto_index(bg1) [list source [file join $dir floor.tcl]] -set auto_index(bg2) [list source [file join $dir floor.tcl]] -set auto_index(bg3) [list source [file join $dir floor.tcl]] -set auto_index(fg1) [list source [file join $dir floor.tcl]] -set auto_index(fg2) [list source [file join $dir floor.tcl]] -set auto_index(fg3) [list source [file join $dir floor.tcl]] -set auto_index(setWidth) [list source [file join $dir hscale.tcl]] -set auto_index(plotDown) [list source [file join $dir plot.tcl]] -set auto_index(plotMove) [list source [file join $dir plot.tcl]] -set auto_index(puzzleSwitch) [list source [file join $dir puzzle.tcl]] -set auto_index(setHeight) [list source [file join $dir vscale.tcl]] -set auto_index(showMessageBox) [list source [file join $dir msgbox.tcl]] -set auto_index(setColor) [list source [file join $dir clrpick.tcl]] -set auto_index(setColor_helper) [list source [file join $dir clrpick.tcl]] -set auto_index(fileDialog) [list source [file join $dir filebox.tcl]] +set auto_index(arrowSetup) [list source -encoding utf-8 [file join $dir arrow.tcl]] +set auto_index(arrowMove1) [list source -encoding utf-8 [file join $dir arrow.tcl]] +set auto_index(arrowMove2) [list source -encoding utf-8 [file join $dir arrow.tcl]] +set auto_index(arrowMove3) [list source -encoding utf-8 [file join $dir arrow.tcl]] +set auto_index(textLoadFile) [list source -encoding utf-8 [file join $dir search.tcl]] +set auto_index(textSearch) [list source -encoding utf-8 [file join $dir search.tcl]] +set auto_index(textToggle) [list source -encoding utf-8 [file join $dir search.tcl]] +set auto_index(itemEnter) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemLeave) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemMark) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemStroke) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemsUnderArea) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemStartDrag) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(itemDrag) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(butPress) [list source -encoding utf-8 [file join $dir items.tcl]] +set auto_index(loadDir) [list source -encoding utf-8 [file join $dir image2.tcl]] +set auto_index(loadImage) [list source -encoding utf-8 [file join $dir image2.tcl]] +set auto_index(rulerMkTab) [list source -encoding utf-8 [file join $dir ruler.tcl]] +set auto_index(rulerNewTab) [list source -encoding utf-8 [file join $dir ruler.tcl]] +set auto_index(rulerSelectTab) [list source -encoding utf-8 [file join $dir ruler.tcl]] +set auto_index(rulerMoveTab) [list source -encoding utf-8 [file join $dir ruler.tcl]] +set auto_index(rulerReleaseTab) [list source -encoding utf-8 [file join $dir ruler.tcl]] +set auto_index(mkTextConfig) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textEnter) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textInsert) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textPaste) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textB1Press) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textB1Move) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textBs) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(textDel) [list source -encoding utf-8 [file join $dir ctext.tcl]] +set auto_index(bitmapRow) [list source -encoding utf-8 [file join $dir bitmap.tcl]] +set auto_index(scrollEnter) [list source -encoding utf-8 [file join $dir cscroll.tcl]] +set auto_index(scrollLeave) [list source -encoding utf-8 [file join $dir cscroll.tcl]] +set auto_index(scrollButton) [list source -encoding utf-8 [file join $dir cscroll.tcl]] +set auto_index(textWindOn) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(textWindOff) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(textWindPlot) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(embPlotDown) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(embPlotMove) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(textWindDel) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(embDefBg) [list source -encoding utf-8 [file join $dir twind.tcl]] +set auto_index(floorDisplay) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(newRoom) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(roomChanged) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(bg1) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(bg2) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(bg3) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(fg1) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(fg2) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(fg3) [list source -encoding utf-8 [file join $dir floor.tcl]] +set auto_index(setWidth) [list source -encoding utf-8 [file join $dir hscale.tcl]] +set auto_index(plotDown) [list source -encoding utf-8 [file join $dir plot.tcl]] +set auto_index(plotMove) [list source -encoding utf-8 [file join $dir plot.tcl]] +set auto_index(puzzleSwitch) [list source -encoding utf-8 [file join $dir puzzle.tcl]] +set auto_index(setHeight) [list source -encoding utf-8 [file join $dir vscale.tcl]] +set auto_index(showMessageBox) [list source -encoding utf-8 [file join $dir msgbox.tcl]] +set auto_index(setColor) [list source -encoding utf-8 [file join $dir clrpick.tcl]] +set auto_index(setColor_helper) [list source -encoding utf-8 [file join $dir clrpick.tcl]] +set auto_index(fileDialog) [list source -encoding utf-8 [file join $dir filebox.tcl]] +set auto_index(systray) [list source -encoding utf-8 [file join $dir systray.tcl]] + Index: library/demos/tcolor ================================================================== --- library/demos/tcolor +++ library/demos/tcolor @@ -5,11 +5,11 @@ # tcolor -- # This script implements a simple color editor, where you can # create colors using either the RGB, HSB, or CYM color spaces # and apply the color to existing applications. -package require Tk 8.4 +package require Tk wm title . "Color Editor" # Global variables that control the program: # # colorSpace - Color space currently being used for Index: library/demos/toolbar.tcl ================================================================== --- library/demos/toolbar.tcl +++ library/demos/toolbar.tcl @@ -15,11 +15,11 @@ wm iconname $w "toolbar" positionWindow $w ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\ a toolbar that is styled correctly and which can be torn off. The\ - buttons are configured to be \u201Ctoolbar style\u201D buttons by\ + buttons are configured to be “toolbar style” buttons by\ telling them that they are to use the Toolbutton style. At the left\ end of the toolbar is a simple marker that the cursor changes to a\ movement icon over; drag that away from the toolbar to tear off the\ whole toolbar into a separate toplevel widget. When the dragged-off\ toolbar is no longer needed, just close it like any normal toplevel\ Index: library/demos/ttkbut.tcl ================================================================== --- library/demos/ttkbut.tcl +++ library/demos/ttkbut.tcl @@ -15,11 +15,11 @@ toplevel $w wm title $w "Simple Ttk Widgets" wm iconname $w "ttkbut" positionWindow $w -ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Ttk is the new Tk themed widget set. This is a Ttk themed label, and below are three groups of Ttk widgets in Ttk labelframes. The first group are all buttons that set the current application theme when pressed. The second group contains three sets of checkbuttons, with a separator widget between the sets. Note that the \u201cEnabled\u201d button controls whether all the other themed widgets in this toplevel are in the disabled state. The third group has a collection of linked radiobuttons." +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Ttk is the new Tk themed widget set. This is a Ttk themed label, and below are three groups of Ttk widgets in Ttk labelframes. The first group are all buttons that set the current application theme when pressed. The second group contains three sets of checkbuttons, with a separator widget between the sets. Note that the “Enabled” button controls whether all the other themed widgets in this toplevel are in the disabled state. The third group has a collection of linked radiobuttons." pack $w.msg -side top -fill x ## See Code / Dismiss pack [addSeeDismiss $w.seeDismiss $w {enabled cheese tomato basil oregano happiness}]\ -side bottom -fill x Index: library/demos/ttkprogress.tcl ================================================================== --- library/demos/ttkprogress.tcl +++ library/demos/ttkprogress.tcl @@ -13,11 +13,11 @@ toplevel $w wm title $w "Progress Bar Demonstration" wm iconname $w "ttkprogress" positionWindow $w -ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Below are two progress bars. The top one is a \u201Cdeterminate\u201D progress bar, which is used for showing how far through a defined task the program has got. The bottom one is an \u201Cindeterminate\u201D progress bar, which is used to show that the program is busy but does not know how long for. Both are run here in self-animated mode, which can be turned on and off using the buttons underneath." +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Below are two progress bars. The top one is a “determinate” progress bar, which is used for showing how far through a defined task the program has got. The bottom one is an “indeterminate” progress bar, which is used to show that the program is busy but does not know how long for. Both are run here in self-animated mode, which can be turned on and off using the buttons underneath." pack $w.msg -side top -fill x ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x Index: library/demos/unicodeout.tcl ================================================================== --- library/demos/unicodeout.tcl +++ library/demos/unicodeout.tcl @@ -19,13 +19,11 @@ label $w.msg -font $font -wraplength 4i -anchor w -justify left \ -text "This is a sample of Tk's support for languages that use\ non-Western character sets. However, what you will actually see\ below depends largely on what character sets you have installed,\ and what you see for characters that are not present varies greatly\ - between platforms as well. The strings are written in Tcl using\ - UNICODE characters using the \\uXXXX (or \\UXXXXXX) escape so as to\ - do so in a portable fashion." + between platforms as well." pack $w.msg -side top ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x @@ -96,51 +94,33 @@ update ## Add the samples... if {[usePresentationFormsFor Arabic]} { # Using presentation forms (pre-layouted) - addSample $w Arabic \ - "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \ - "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D" + addSample $w Arabic "ﺔﻴﺑﺮﻌﻟﺍ ﺔﻤﻠﻜﻟﺍ" } else { # Using standard text characters - addSample $w Arabic \ - "\u0627\u0644\u0643\u0644\u0645\u0629 " \ - "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" -} -addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57" -addSample $w "Simpl. Chinese" "\u6C49\u8BED" -addSample $w French "Langue fran\xE7aise" -addSample $w Greek \ - "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \ - "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1" + addSample $w Arabic "الكلمة العربية" +} +addSample $w "Trad. Chinese" "中國的漢字" +addSample $w "Simpl. Chinese" "汉语" +addSample $w French "Langue française" +addSample $w Greek "Ελληνική γλώσσα" if {[usePresentationFormsFor Hebrew]} { # Visual order (pre-layouted) - addSample $w Hebrew \ - "\u05EA\u05D9\u05E8\u05D1\u05E2 \u05D1\u05EA\u05DB" + addSample $w Hebrew "תירבע בתכ" } else { # Standard logical order - addSample $w Hebrew \ - "\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA" -} -addSample $w Hindi \ - "\u0939\u093F\u0928\u094D\u0926\u0940 \u092D\u093E\u0937\u093E" -addSample $w Icelandic "\xCDslenska" -addSample $w Japanese \ - "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \ - "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA" -addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" -addSample $w Russian \ - "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" + addSample $w Hebrew "כתב עברית" +} +addSample $w Hindi "हिन्दी भाषा" +addSample $w Icelandic "Íslenska" +addSample $w Japanese "日本語のひらがな, 漢字とカタカナ" +addSample $w Korean "대한민국의 한글" +addSample $w Russian "Русский язык" if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} { - if {[package vsatisfies [package provide Tcl] 8.7-]} { - addSample $w Emoji \ - "\U1F600\U1F4A9\U1F44D\U1F1F3\U1F1F1" - } else { - addSample $w Emoji \ - "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" - } + addSample $w Emoji "😀💩👍🇳🇱" } ## We're done processing, so change things back to normal running... destroy $w.wait $w conf -cursor $oldCursor Index: library/demos/widget ================================================================== --- library/demos/widget +++ library/demos/widget @@ -364,11 +364,10 @@ @@demo knightstour A Knight's tour of the chess board @@subtitle Scales and Progress Bars @@demo hscale Horizontal scale @@demo vscale Vertical scale - @@new @@demo ttkscale Themed scale linked to a label with traces @@demo ttkprogress Progress bar @@subtitle Paned Windows and Notebooks @@demo paned1 Horizontal paned window @@ -385,10 +384,12 @@ @@subtitle Common Dialogs @@demo msgbox Message boxes @@demo filebox File selection dialog @@demo clrpick Color picker @@demo fontchoose Font selection dialog + @@new + @@demo systray System tray icon and notification @@subtitle Animation @@demo anilabel Animated labels @@demo aniwave Animated wave @@demo pendulum Pendulum simulation @@ -514,11 +515,11 @@ } set cursor [.t cget -cursor] .t configure -cursor [::ttk::cursor busy] update set demo [string range [lindex $tags $i] 5 end] - uplevel 1 [list source [file join $tk_demoDirectory $demo.tcl]] + uplevel 1 [list source -encoding utf-8 [file join $tk_demoDirectory $demo.tcl]] update .t configure -cursor $cursor .t tag add visited "$index linestart +1 chars" "$index lineend -1 chars" } @@ -622,10 +623,11 @@ raise $top } wm title $top [mc "Demo code: %s" [file join $tk_demoDirectory $file]] wm iconname $top $file set id [open [file join $tk_demoDirectory $file]] + fconfigure $id -encoding utf-8 -eofchar "\032 {}" $top.f.text delete 1.0 end $top.f.text insert 1.0 [read $id] $top.f.text mark set insert 1.0 close $id } @@ -720,14 +722,14 @@ # Pops up a message box with an "about" message # proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc "Copyright \u00a9 %s" {1996-1997 Sun Microsystems, Inc.}] -[mc "Copyright \u00a9 %s" {1997-2000 Ajuba Solutions, Inc.}] -[mc "Copyright \u00a9 %s" {2001-2009 Donal K. Fellows}] -[mc "Copyright \u00a9 %s" {2002-2007 Daniel A. Steffen}]" +"[mc "Copyright © %s" {1996-1997 Sun Microsystems, Inc.}] +[mc "Copyright © %s" {1997-2000 Ajuba Solutions, Inc.}] +[mc "Copyright © %s" {2001-2009 Donal K. Fellows}] +[mc "Copyright © %s" {2002-2007 Daniel A. Steffen}]" } # Local Variables: # mode: tcl # End: Index: library/dialog.tcl ================================================================== --- library/dialog.tcl +++ library/dialog.tcl @@ -1,12 +1,12 @@ # dialog.tcl -- # # This file defines the procedure tk_dialog, which creates a dialog # box containing a bitmap, a message, and one or more buttons. # -# Copyright (c) 1992-1993 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright © 1992-1993 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/entry.tcl ================================================================== --- library/entry.tcl +++ library/entry.tcl @@ -1,12 +1,12 @@ # entry.tcl -- # # This file defines the default bindings for Tk entry widgets and provides # procedures that help in implementing those bindings. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -56,11 +56,11 @@ tk::EntrySeeInsert %W } } bind Entry <> { # ignore if there is no selection - catch { %W delete sel.first sel.last } + catch {%W delete sel.first sel.last} } bind Entry <> { if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] || !$tk::Priv(mouseMoved)} { tk::EntryPaste %W %x @@ -117,21 +117,21 @@ bind Entry { %W icursor @%x } bind Entry <> { - tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert]-1}] } bind Entry <> { - tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert]+1}] } bind Entry <> { - tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + tk::EntryKeySelect %W [expr {[%W index insert]-1}] tk::EntrySeeInsert %W } bind Entry <> { - tk::EntryKeySelect %W [expr {[%W index insert] + 1}] + tk::EntryKeySelect %W [expr {[%W index insert]+1}] tk::EntrySeeInsert %W } bind Entry <> { tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert] } @@ -207,13 +207,11 @@ bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Entry {# nothing} -} +bind Entry {# nothing} # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <> {# nothing} bind Entry <> {# nothing} # On Windows, paste is done using Shift-Insert. Shift-Insert already @@ -276,11 +274,11 @@ bind Entry <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <> { - if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} { bell } else { %W selection range $mark insert } } @@ -291,32 +289,19 @@ tk::EntryBackspace %W } # A few additional bindings of my own. -if {[tk windowingsystem] ne "aqua"} { - bind Entry { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Entry { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } - } -} else { - bind Entry { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Entry { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } - } +bind Entry { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x + } +} +bind Entry { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x + } } # ::tk::EntryClosestGap -- # Given x and y coordinates, this procedure finds the closest boundary # between characters to the given coordinates and returns the index @@ -389,14 +374,14 @@ } } word { if {$cur < $anchor} { set before [tcl_wordBreakBefore [$w get] $cur] - set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + set after [tcl_wordBreakAfter [$w get] $anchor-1] } elseif {$cur > $anchor} { set before [tcl_wordBreakBefore [$w get] $anchor] - set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + set after [tcl_wordBreakAfter [$w get] $cur-1] } else { if {[$w index @$Priv(pressX)] < $anchor} { incr anchor -1 } set before [tcl_wordBreakBefore [$w get] $anchor] @@ -516,13 +501,13 @@ proc ::tk::EntryBackspace w { if {[$w selection present]} { $w delete sel.first sel.last } else { - set x [expr {[$w index insert] - 1}] - if {$x >= 0} { - $w delete $x + set x [$w index insert] + if {$x > 0} { + $w delete [expr {$x-1}] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] set left [lindex $range 0] set right [lindex $range 1] @@ -573,16 +558,16 @@ proc ::tk::EntryTranspose w { set i [$w index insert] if {$i < [$w index end]} { incr i } - set first [expr {$i-2}] - if {$first < 0} { + if {$i < 2} { return } + set first [expr {$i-2}] set data [$w get] - set new [string index $data [expr {$i-1}]][string index $data $first] + set new [string index $data $i-1][string index $data $first] $w delete $first $i $w insert insert $new EntrySeeInsert $w } @@ -658,11 +643,11 @@ # x - x location on screen proc ::tk::EntryScanDrag {w x} { # Make sure these exist, as some weird situations can trigger the # motion binding without the initial press. [Bug #220269] - if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x } + if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x} # allow for a delta if {abs($x-$::tk::Priv(x)) > 2} { set ::tk::Priv(mouseMoved) 1 } $w scan dragto $x @@ -675,21 +660,12 @@ # Arguments: # w - The entry window from which the text to get proc ::tk::EntryGetSelection {w} { set entryString [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] if {[$w cget -show] ne ""} { return [string repeat [string index [$w cget -show] 0] \ [string length $entryString]] } return $entryString } - - - - - - - - - Index: library/focus.tcl ================================================================== --- library/focus.tcl +++ library/focus.tcl @@ -1,11 +1,11 @@ # focus.tcl -- # # This file defines several procedures for managing the input # focus. # -# Copyright (c) 1994-1995 Sun Microsystems, Inc. +# Copyright © 1994-1995 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/fontchooser.tcl ================================================================== --- library/fontchooser.tcl +++ library/fontchooser.tcl @@ -1,11 +1,11 @@ # fontchooser.tcl - # # A themeable Tk font selection dialog. See TIP #324. # -# Copyright (C) 2008 Keith Vetter -# Copyright (C) 2008 Pat Thoyts +# Copyright © 2008 Keith Vetter +# Copyright © 2008 Pat Thoyts # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. namespace eval ::tk::fontchooser { @@ -12,15 +12,15 @@ variable S set S(W) .__tk__fontchooser set S(fonts) [lsort -dictionary [font families]] set S(styles) [list \ - [::msgcat::mc "Regular"] \ - [::msgcat::mc "Italic"] \ - [::msgcat::mc "Bold"] \ - [::msgcat::mc "Bold Italic"] \ - ] + [::msgcat::mc "Regular"] \ + [::msgcat::mc "Italic"] \ + [::msgcat::mc "Bold"] \ + [::msgcat::mc "Bold Italic"] \ + ] set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} set S(strike) 0 set S(under) 0 set S(first) 1 @@ -34,13 +34,13 @@ proc ::tk::fontchooser::Setup {} { variable S # Canonical versions of font families, styles, etc. for easier searching set S(fonts,lcase) {} - foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]} + foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]} set S(styles,lcase) {} - foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style]} + foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]} set S(sizes,lcase) $S(sizes) ::ttk::style layout FontchooserFrame { Entry.field -sticky news -border true -children { FontchooserFrame.padding -sticky news @@ -109,21 +109,21 @@ -command, -font, -parent, -title or -visible" } set cache [dict create -parent $S(-parent) -title $S(-title) \ -font $S(-font) -command $S(-command)] - set r [tclParseConfigSpec [namespace which -variable S] $specs "" $args] + set r [tclParseConfigSpec [namespace which -variable S] $specs DONTSETDEFAULTS $args] if {![winfo exists $S(-parent)]} { set code [list TK LOOKUP WINDOW $S(-parent)] set err "bad window path name \"$S(-parent)\"" array set S $cache return -code error -errorcode $code $err } if {[string trim $S(-title)] eq ""} { set S(-title) [::msgcat::mc "Font"] } - if {[winfo exists $S(W)] && [lsearch $args -font] != -1} { + if {[winfo exists $S(W)] && ("-font" in $args)} { Init $S(-font) event generate $S(-parent) <> } return $r } @@ -143,14 +143,17 @@ if {[package provide tcltest] ne {}} {set ::tk_dialog $S(W)} wm withdraw $S(W) wm title $S(W) $S(-title) wm transient $S(W) [winfo toplevel $S(-parent)] + set scaling [tk scaling] + set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}] + set outer [::ttk::frame $S(W).outer -padding {10 10}] ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"] ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"] - ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] + ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth ttk::entry $S(W).efont -width 18 \ -textvariable [namespace which -variable S](font) ttk::entry $S(W).estyle -width 10 \ -textvariable [namespace which -variable S](style) ttk::entry $S(W).esize -textvariable [namespace which -variable S](size) \ @@ -197,11 +200,11 @@ set minsize(styles) \ [expr {[font measure TkDefaultFont "Bold Italic"] + $scroll_width}] set minsize(sizes) \ [expr {[font measure TkDefaultFont "-99"] + $scroll_width}] set min [expr {$minsize(gap) * 4}] - foreach {what width} [array get minsize] { incr min $width } + foreach {what width} [array get minsize] {incr min $width} wm minsize $S(W) $min 260 bind $S(W) [namespace code [list Done 1]] bind $S(W) [namespace code [list Done 0]] bind $S(W) [namespace code [list Visibility %W 1]] @@ -275,11 +278,11 @@ # Handles teardown of the dialog, calling -command if needed # # Arguments: # ok true if user pressed OK # -proc ::tk::::fontchooser::Done {ok} { +proc ::tk::fontchooser::Done {ok} { variable S if {! $ok} { set S(result) "" } @@ -325,17 +328,17 @@ array set F [font actual $defaultFont] set S(font) $F(-family) set S(size) $F(-size) set S(strike) $F(-overstrike) set S(under) $F(-underline) - set S(style) "Regular" + set S(style) [::msgcat::mc "Regular"] if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} { - set S(style) "Bold Italic" + set S(style) [::msgcat::mc "Bold Italic"] } elseif {$F(-weight) eq "bold"} { - set S(style) "Bold" + set S(style) [::msgcat::mc "Bold"] } elseif {$F(-slant) eq "italic"} { - set S(style) "Italic" + set S(style) [::msgcat::mc "Italic"] } set S(first) 0 } @@ -379,11 +382,11 @@ foreach var {font style size} { set value [string tolower $S($var)] $S(W).l${var}s selection clear 0 end set n [lsearch -exact $S(${var}s,lcase) $value] $S(W).l${var}s selection set $n - if {$n != -1} { + if {$n >= 0} { set S($var) [lindex $S(${var}s) $n] $S(W).e$var icursor end $S(W).e$var selection clear } else { ;# No match, try prefix # Size is weird: valid numbers are legal but don't display @@ -394,11 +397,11 @@ set nstate disabled } } $S(W).l${var}s see $n } - if {!$bad} { Update } + if {!$bad} {Update} $S(W).ok configure -state $nstate } # ::tk::fontchooser::Update -- # @@ -406,15 +409,15 @@ # proc ::tk::fontchooser::Update {} { variable S set S(result) [list $S(font) $S(size)] - if {$S(style) eq "Bold"} { lappend S(result) bold } - if {$S(style) eq "Italic"} { lappend S(result) italic } - if {$S(style) eq "Bold Italic"} { lappend S(result) bold italic} - if {$S(strike)} { lappend S(result) overstrike} - if {$S(under)} { lappend S(result) underline} + if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold} + if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic} + if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic} + if {$S(strike)} {lappend S(result) overstrike} + if {$S(under)} {lappend S(result) underline} $S(sample) configure -font $S(result) } # ::tk::fontchooser::Visibility -- Index: library/iconlist.tcl ================================================================== --- library/iconlist.tcl +++ library/iconlist.tcl @@ -1,12 +1,12 @@ # iconlist.tcl # # Implements the icon-list megawidget used in the "Tk" standard file # selection dialog boxes. # -# Copyright (c) 1994-1998 Sun Microsystems, Inc. -# Copyright (c) 2009 Donal K. Fellows +# Copyright © 1994-1998 Sun Microsystems, Inc. +# Copyright © 2009 Donal K. Fellows # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # # API Summary: @@ -24,11 +24,11 @@ # selection clear ?? # selection get # selection includes # selection set ?? -package require Tk 8.6 +package require tk ::tk::Megawidget create ::tk::IconList ::tk::FocusableWidget { variable w canvas sbar accel accelCB fill font index \ itemList itemsPerColumn list maxIH maxIW maxTH maxTW noScroll \ numItems oldX oldY options rect selected selection textList @@ -444,22 +444,13 @@ [namespace code {my Double1 %x %y}] bind $canvas {;} bind $canvas [namespace code {my ShiftMotion1 %x %y}] - if {[tk windowingsystem] eq "aqua"} { - bind $canvas [namespace code {my MouseWheel [expr {40 * (%D)}]}] - bind $canvas [namespace code {my MouseWheel [expr {400 * (%D)}]}] - } else { - bind $canvas [namespace code {my MouseWheel %D}] - } - if {[tk windowingsystem] eq "x11"} { - bind $canvas [namespace code {my MouseWheel 120}] - bind $canvas [namespace code {my MouseWheel -120}] - bind $canvas [namespace code {my MouseWheel 120}] - bind $canvas [namespace code {my MouseWheel -120}] - } + bind $canvas [namespace code {my MouseWheel %D}] + bind $canvas [namespace code {my MouseWheel %D -12}] + bind $canvas <> [namespace code {my UpDown -1}] bind $canvas <> [namespace code {my UpDown 1}] bind $canvas <> [namespace code {my LeftRight -1}] bind $canvas <> [namespace code {my LeftRight 1}] @@ -503,25 +494,15 @@ } # ---------------------------------------------------------------------- # Event handlers - method MouseWheel {amount} { + method MouseWheel {amount {factor -120.0}} { if {$noScroll || $::tk_strictMotif} { return } - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - if {$amount > 0} { - $canvas xview scroll [expr {(-119-$amount) / 120}] units - } else { - $canvas xview scroll [expr {-($amount / 120)}] units - } + $canvas xview scroll [expr {$amount/$factor}] units } method Btn1 {x y} { focus $canvas set i [$w index @$x,$y] if {$i eq ""} { @@ -703,11 +684,11 @@ if {$i == $start} { break } } - if {$theIndex > -1} { + if {$theIndex >= 0} { $w selection clear 0 end $w selection set $theIndex $w selection anchor $theIndex $w see $theIndex } Index: library/icons.tcl ================================================================== --- library/icons.tcl +++ library/icons.tcl @@ -6,11 +6,11 @@ # Creative Commons Attribution Share-Alike license # (http://creativecommons.org/licenses/by-sa/3.0/) # # See http://tango.freedesktop.org/Tango_Desktop_Project # -# Copyright (c) 2009 Pat Thoyts +# Copyright © 2009 Pat Thoyts namespace eval ::tk::icons {} image create photo ::tk::icons::warning -data { iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABSZJREFU Index: library/listbox.tcl ================================================================== --- library/listbox.tcl +++ library/listbox.tcl @@ -1,13 +1,13 @@ # listbox.tcl -- # # This file defines the default bindings for Tk listbox widgets # and provides procedures that help in implementing those bindings. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994-1995 Sun Microsystems, Inc. -# Copyright (c) 1998 by Scriptics Corporation. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994-1995 Sun Microsystems, Inc. +# Copyright © 1998 Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. #-------------------------------------------------------------------------- @@ -174,85 +174,21 @@ } bind Listbox { %W scan dragto %x %y } -# The MouseWheel will typically only fire on Windows and Mac OS X. -# However, someone could use the "event generate" command to produce -# one on other platforms. - -if {[tk windowingsystem] eq "aqua"} { - bind Listbox { - %W yview scroll [expr {-(%D)}] units - } - bind Listbox { - %W yview scroll [expr {-10 * (%D)}] units - } - bind Listbox { - %W xview scroll [expr {-(%D)}] units - } - bind Listbox { - %W xview scroll [expr {-10 * (%D)}] units - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/30 = 0, - # but - # (int)-1/30 = -1 - # The following code ensure equal +/- behaviour. - bind Listbox { - if {%D >= 0} { - %W yview scroll [expr {-%D/30}] units - } else { - %W yview scroll [expr {(29-%D)/30}] units - } - } - bind Listbox { - if {%D >= 0} { - %W xview scroll [expr {-%D/30}] units - } else { - %W xview scroll [expr {(29-%D)/30}] units - } - } -} - -if {[tk windowingsystem] eq "x11"} { - # Support for mousewheels on Linux/Unix commonly comes through mapping - # the wheel to the extended buttons. If you have a mousewheel, find - # Linux configuration info at: - # http://linuxreviews.org/howtos/xfree/mouse/ - bind Listbox { - if {!$tk_strictMotif} { - %W yview scroll -5 units - } - } - bind Listbox { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind Listbox { - if {!$tk_strictMotif} { - %W yview scroll 5 units - } - } - bind Listbox { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } - bind Listbox { - if {!$tk_strictMotif} { - %W xview scroll -5 units - } - } - bind Listbox { - if {!$tk_strictMotif} { - %W xview scroll 5 units - } - } +bind Listbox { + tk::MouseWheel %W y %D -40.0 +} +bind Listbox { + tk::MouseWheel %W y %D -12.0 +} +bind Listbox { + tk::MouseWheel %W x %D -40.0 +} +bind Listbox { + tk::MouseWheel %W x %D -12.0 } # ::tk::ListboxBeginSelect -- # # This procedure is typically invoked on button-1 presses. It begins @@ -325,17 +261,17 @@ } if {![info exists Priv(listboxSelection)]} { set Priv(listboxSelection) [$w curselection] } while {($i < $el) && ($i < $anchor)} { - if {[lsearch $Priv(listboxSelection) $i] >= 0} { + if {$i in $Priv(listboxSelection)} { $w selection set $i } incr i } while {($i > $el) && ($i > $anchor)} { - if {[lsearch $Priv(listboxSelection) $i] >= 0} { + if {$i in $Priv(listboxSelection)} { $w selection set $i } incr i -1 } set Priv(listboxPrev) $el @@ -531,11 +467,11 @@ set first $last set last $tmp } $w selection clear $first $last while {$first <= $last} { - if {[lsearch $Priv(listboxSelection) $first] >= 0} { + if {$first in $Priv(listboxSelection)} { $w selection set $first } incr first } tk::FireListboxSelectEvent $w Index: library/megawidget.tcl ================================================================== --- library/megawidget.tcl +++ library/megawidget.tcl @@ -2,17 +2,17 @@ # # Basic megawidget support classes. Experimental for any use other than # the ::tk::IconList megawdget, which is itself only designed for use in # the Unix file dialogs. # -# Copyright (c) 2009-2010 Donal K. Fellows +# Copyright © 2009-2010 Donal K. Fellows # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # -package require Tk 8.6 +package require tk ::oo::class create ::tk::Megawidget { superclass ::oo::class method unknown {w args} { if {[string match .* $w]} { Index: library/menu.tcl ================================================================== --- library/menu.tcl +++ library/menu.tcl @@ -2,14 +2,14 @@ # # This file defines the default bindings for Tk menus and menubuttons. # It also implements keyboard traversal of menus and implements a few # other utility procedures related to menus. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. -# Copyright (c) 2007 Daniel A. Steffen +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. +# Copyright © 1998-1999 Scriptics Corporation. +# Copyright © 2007 Daniel A. Steffen # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/msgbox.tcl ================================================================== --- library/msgbox.tcl +++ library/msgbox.tcl @@ -1,11 +1,11 @@ # msgbox.tcl -- # # Implements messageboxes for platforms that do not have native # messagebox support. # -# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright © 1994-1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/msgs/da.msg ================================================================== --- library/msgs/da.msg +++ library/msgs/da.msg @@ -1,15 +1,15 @@ namespace eval ::tk { ::msgcat::mcset da "&Abort" "&Afbryd" ::msgcat::mcset da "&About..." "&Om..." ::msgcat::mcset da "All Files" "Alle filer" ::msgcat::mcset da "Application Error" "Programfejl" - ::msgcat::mcset da "&Blue" "&Bl\u00E5" + ::msgcat::mcset da "&Blue" "&Blå" ::msgcat::mcset da "Cancel" "Annuller" ::msgcat::mcset da "&Cancel" "&Annuller" ::msgcat::mcset da "Cannot change to the directory \"%1\$s\".\nPermission denied." "Kan ikke skifte til katalog \"%1\$s\".\nIngen rettigheder." - ::msgcat::mcset da "Choose Directory" "V\u00E6lg katalog" + ::msgcat::mcset da "Choose Directory" "Vælg katalog" ::msgcat::mcset da "Cl&ear" "&Ryd" ::msgcat::mcset da "&Clear Console" "&Ryd konsolen" ::msgcat::mcset da "Color" "Farve" ::msgcat::mcset da "Console" "Konsol" ::msgcat::mcset da "&Copy" "&Kopier" @@ -29,50 +29,50 @@ ::msgcat::mcset da "File &names:" "Fil&navne:" ::msgcat::mcset da "Files of &type:" "Fil&typer:" ::msgcat::mcset da "Fi&les:" "Fi&ler:" ::msgcat::mcset da "&Filter" ::msgcat::mcset da "Fil&ter:" - ::msgcat::mcset da "&Green" "&Gr\u00F8n" - ::msgcat::mcset da "&Help" "&Hj\u00E6lp" + ::msgcat::mcset da "&Green" "&Grøn" + ::msgcat::mcset da "&Help" "&Hjælp" ::msgcat::mcset da "Hi" "Hej" ::msgcat::mcset da "&Hide Console" "Skjul &konsol" ::msgcat::mcset da "&Ignore" "&Ignorer" ::msgcat::mcset da "Invalid file name \"%1\$s\"." "Ugyldig fil navn \"%1\$s\"." ::msgcat::mcset da "Log Files" "Logfiler" ::msgcat::mcset da "&No" "&Nej" ::msgcat::mcset da "&OK" "&O.K." ::msgcat::mcset da "OK" "O.K." ::msgcat::mcset da "Ok" - ::msgcat::mcset da "Open" "\u00C5bn" - ::msgcat::mcset da "&Open" "&\u00C5bn" - ::msgcat::mcset da "Open Multiple Files" "\u00C5bn flere filer" - ::msgcat::mcset da "P&aste" "&Inds\u00E6t" + ::msgcat::mcset da "Open" "Åbn" + ::msgcat::mcset da "&Open" "&Åbn" + ::msgcat::mcset da "Open Multiple Files" "Åbn flere filer" + ::msgcat::mcset da "P&aste" "&Indsæt" ::msgcat::mcset da "&Quit" "&Afslut" - ::msgcat::mcset da "&Red" "&R\u00F8d" + ::msgcat::mcset da "&Red" "&Rød" ::msgcat::mcset da "Replace existing file?" "Erstat eksisterende fil?" ::msgcat::mcset da "&Retry" "&Gentag" ::msgcat::mcset da "&Save" "&Gem" ::msgcat::mcset da "Save As" "Gem som" ::msgcat::mcset da "Save To Log" "Gem i log" - ::msgcat::mcset da "Select Log File" "V\u00E6lg logfil" - ::msgcat::mcset da "Select a file to source" "V\u00E6lg k\u00F8rbar fil" + ::msgcat::mcset da "Select Log File" "Vælg logfil" + ::msgcat::mcset da "Select a file to source" "Vælg kørbar fil" ::msgcat::mcset da "&Selection:" "&Udvalg:" ::msgcat::mcset da "Show &Hidden Directories" "Vis &skjulte kataloger" ::msgcat::mcset da "Show &Hidden Files and Directories" "Vis &skjulte filer og kataloger" ::msgcat::mcset da "Skip Messages" "Overspring beskeder" - ::msgcat::mcset da "&Source..." "&K\u00F8r..." + ::msgcat::mcset da "&Source..." "&Kør..." ::msgcat::mcset da "Tcl Scripts" "Tcl-Skripter" ::msgcat::mcset da "Tcl for Windows" "Tcl for Windows" ::msgcat::mcset da "Text Files" "Tekstfiler" ::msgcat::mcset da "&Yes" "&Ja" ::msgcat::mcset da "abort" "afbryd" - ::msgcat::mcset da "blue" "bl\u00E5" + ::msgcat::mcset da "blue" "blå" ::msgcat::mcset da "cancel" "afbryd" ::msgcat::mcset da "extension" ::msgcat::mcset da "extensions" - ::msgcat::mcset da "green" "gr\u00F8n" + ::msgcat::mcset da "green" "grøn" ::msgcat::mcset da "ignore" "ignorer" ::msgcat::mcset da "ok" - ::msgcat::mcset da "red" "r\u00F8d" + ::msgcat::mcset da "red" "rød" ::msgcat::mcset da "retry" "gentag" ::msgcat::mcset da "yes" "ja" } Index: library/msgs/de.msg ================================================================== --- library/msgs/de.msg +++ library/msgs/de.msg @@ -50,11 +50,11 @@ ::msgcat::mcset de "&OK" ::msgcat::mcset de "OK" ::msgcat::mcset de "Ok" ::msgcat::mcset de "Open" "Öffnen" ::msgcat::mcset de "&Open" "Ö&ffnen" - ::msgcat::mcset de "Open Multiple Files" "Mehrere Dateien \u00F6ffnen" + ::msgcat::mcset de "Open Multiple Files" "Mehrere Dateien Öffnen" ::msgcat::mcset de "P&aste" "E&infügen" ::msgcat::mcset de "&Quit" "&Beenden" ::msgcat::mcset de "&Red" "&Rot" ::msgcat::mcset de "Regular" "Standard" ::msgcat::mcset de "Replace existing file?" "Existierende Datei ersetzen?" Index: library/obsolete.tcl ================================================================== --- library/obsolete.tcl +++ library/obsolete.tcl @@ -1,12 +1,12 @@ # obsolete.tcl -- # # This file contains obsolete procedures that people really shouldn't # be using anymore, but which are kept around for backward compatibility. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994 Sun Microsystems, Inc. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/optMenu.tcl ================================================================== --- library/optMenu.tcl +++ library/optMenu.tcl @@ -1,12 +1,12 @@ # optMenu.tcl -- # # This file defines the procedure tk_optionMenu, which creates # an option button and its associated menu. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994 Sun Microsystems, Inc. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/palette.tcl ================================================================== --- library/palette.tcl +++ library/palette.tcl @@ -1,11 +1,11 @@ # palette.tcl -- # # This file contains procedures that change the color palette used # by Tk. # -# Copyright (c) 1995-1997 Sun Microsystems, Inc. +# Copyright © 1995-1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/safetk.tcl ================================================================== --- library/safetk.tcl +++ library/safetk.tcl @@ -1,10 +1,10 @@ # safetk.tcl -- # # Support procs to use Tk in safe interpreters. # -# Copyright (c) 1997 Sun Microsystems, Inc. +# Copyright © 1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # see safetk.n for documentation @@ -12,13 +12,13 @@ # # # Note: It is now ok to let untrusted code being executed # between the creation of the interp and the actual loading # of Tk in that interp because the C side Tk_Init will -# now look up the master interp and ask its safe::TkInit +# now look up the parent interp and ask its safe::TkInit # for the actual parameters to use for it's initialization (if allowed), -# not relying on the slave state. +# not relying on the child state. # # We use opt (optional arguments parsing) package require opt 0.4.1; @@ -27,74 +27,74 @@ # counter for safe toplevels variable tkSafeId 0 } # -# tkInterpInit : prepare the slave interpreter for tk loading +# tkInterpInit : prepare the child interpreter for tk loading # most of the real job is done by loadTk -# returns the slave name (tkInterpInit does) +# returns the child name (tkInterpInit does) # -proc ::safe::tkInterpInit {slave argv} { +proc ::safe::tkInterpInit {child argv} { global env tk_library # We have to make sure that the tk_library variable is normalized. set tk_library [file normalize $tk_library] # Clear Tk's access for that interp (path). - allowTk $slave $argv + allowTk $child $argv # Ensure tk_library and subdirs (eg, ttk) are on the access path - ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]] + ::interp eval $child [list set tk_library [::safe::interpAddToAccessPath $child $tk_library]] foreach subdir [::safe::AddSubDirs [list $tk_library]] { - ::safe::interpAddToAccessPath $slave $subdir + ::safe::interpAddToAccessPath $child $subdir } - return $slave + return $child } # tkInterpLoadTk: # Do additional configuration as needed (calling tkInterpInit) -# and actually load Tk into the slave. +# and actually load Tk into the child. # # Either contained in the specified windowId (-use) or # creating a decorated toplevel for it. # empty definition for auto_mkIndex proc ::safe::loadTk {} {} ::tcl::OptProc ::safe::loadTk { - {slave -interp "name of the slave interpreter"} + {child -interp "name of the child interpreter"} {-use -windowId {} "window Id to use (new toplevel otherwise)"} {-display -displayName {} "display name to use (current one otherwise)"} } { set displayGiven [::tcl::OptProcArgGiven "-display"] if {!$displayGiven} { # Try to get the current display from "." - # (which might not exist if the master is tk-less) + # (which might not exist if the parent is tk-less) if {[catch {set display [winfo screen .]}]} { if {[info exists ::env(DISPLAY)]} { set display $::env(DISPLAY) } else { - Log $slave "no winfo screen . nor env(DISPLAY)" WARNING + Log $child "no winfo screen . nor env(DISPLAY)" WARNING set display ":0.0" } } } # Get state for access to the cleanupHook. - namespace upvar ::safe S$slave state + namespace upvar ::safe S$child state if {![::tcl::OptProcArgGiven "-use"]} { # create a decorated toplevel - lassign [tkTopLevel $slave $display] w use + lassign [tkTopLevel $child $display] w use - # set our delete hook (slave arg is added by interpDelete) - # to clean up both window related code and tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up both window related code and tkInit(child) set state(cleanupHook) [list tkDelete {} $w] } else { - # set our delete hook (slave arg is added by interpDelete) - # to clean up tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up tkInit(child) set state(cleanupHook) [list disallowTk] # Let's be nice and also accept tk window names instead of ids if {[string match ".*" $use]} { set windowName $use @@ -120,16 +120,16 @@ set display $nDisplay } } } - # Prepares the slave for tk with those parameters - tkInterpInit $slave [list "-use" $use "-display" $display] + # Prepares the child for tk with those parameters + tkInterpInit $child [list "-use" $use "-display" $display] - load {} Tk $slave + load {} Tk $child - return $slave + return $child } proc ::safe::TkInit {interpPath} { variable tkInit if {[info exists tkInit($interpPath)]} { @@ -147,11 +147,11 @@ # # Set tkInit(interpPath) to allow Tk to be initialized in # safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # argv arguments passed to safe::TkInterpInit # # Results: # none. @@ -166,11 +166,11 @@ # # Unset tkInit(interpPath) to disallow Tk from getting initialized # in safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. proc ::safe::disallowTk {interpPath} { @@ -186,47 +186,47 @@ # safe::tkDelete -- # # Clean up the window associated with the interp being deleted. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. -proc ::safe::tkDelete {W window slave} { +proc ::safe::tkDelete {W window child} { # we are going to be called for each widget... skip untill it's # top level - Log $slave "Called tkDelete $W $window" NOTICE - if {[::interp exists $slave]} { - if {[catch {::safe::interpDelete $slave} msg]} { - Log $slave "Deletion error : $msg" + Log $child "Called tkDelete $W $window" NOTICE + if {[::interp exists $child]} { + if {[catch {::safe::interpDelete $child} msg]} { + Log $child "Deletion error : $msg" } } if {[winfo exists $window]} { - Log $slave "Destroy toplevel $window" NOTICE + Log $child "Destroy toplevel $window" NOTICE destroy $window } - # clean up tkInit(slave) - disallowTk $slave + # clean up tkInit(child) + disallowTk $child return } -proc ::safe::tkTopLevel {slave display} { +proc ::safe::tkTopLevel {child display} { variable tkSafeId incr tkSafeId set w ".safe$tkSafeId" if {[catch {toplevel $w -screen $display -class SafeTk} msg]} { return -code error -errorcode {TK TOPLEVEL SAFE} \ - "Unable to create toplevel for safe slave \"$slave\" ($msg)" + "Unable to create toplevel for \"$child\" ($msg)" } - Log $slave "New toplevel $w" NOTICE + Log $child "New toplevel $w" NOTICE - set msg "Untrusted Tcl applet ($slave)" + set msg "Untrusted Tcl applet ($child)" wm title $w $msg # Control frame (we must create a style for it) ttk::style layout TWarningFrame {WarningFrame.border -sticky nswe} ttk::style configure TWarningFrame -background red @@ -234,11 +234,11 @@ set wc $w.fc ttk::frame $wc -relief ridge -borderwidth 4 -style TWarningFrame # We will destroy the interp when the window is destroyed bindtags $wc [concat Safe$wc [bindtags $wc]] - bind Safe$wc [list ::safe::tkDelete %W $w $slave] + bind Safe$wc [list ::safe::tkDelete %W $w $child] ttk::label $wc.l -text $msg -anchor w # We want the button to be the last visible item # (so be packed first) and at the right and not resizing horizontally @@ -245,11 +245,11 @@ # frame the button so it does not expand horizontally # but still have the default background instead of red one from the parent ttk::frame $wc.fb -borderwidth 0 ttk::button $wc.fb.b -text "Delete" \ - -command [list ::safe::tkDelete $w $w $slave] + -command [list ::safe::tkDelete $w $w $child] pack $wc.fb.b -side right -fill both pack $wc.fb -side right -fill both -expand 1 pack $wc.l -side left -fill both -expand 1 -ipady 2 pack $wc -side bottom -fill x Index: library/scale.tcl ================================================================== --- library/scale.tcl +++ library/scale.tcl @@ -1,12 +1,12 @@ # scale.tcl -- # # This file defines the default bindings for Tk scale widgets and provides # procedures that help in implementing the bindings. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994-1995 Sun Microsystems, Inc. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994-1995 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -58,18 +58,10 @@ bind Scale { tk::CancelRepeat tk::ScaleEndDrag %W tk::ScaleActivate %W %x %y } -if {[tk windowingsystem] eq "win32"} { - # On Windows do the same with button 3, as that is the right mouse button - bind Scale [bind Scale ] - bind Scale [bind Scale ] - bind Scale [bind Scale ] - bind Scale [bind Scale ] - bind Scale [bind Scale ] -} bind Scale { tk::ScaleControlPress %W %x %y } bind Scale <> { tk::ScaleIncrement %W up little noRepeat Index: library/scrlbar.tcl ================================================================== --- library/scrlbar.tcl +++ library/scrlbar.tcl @@ -1,12 +1,12 @@ # scrlbar.tcl -- # # This file defines the default bindings for Tk scrollbar widgets. # It also provides procedures that help in implementing the bindings. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994-1996 Sun Microsystems, Inc. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994-1996 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -127,38 +127,15 @@ bind Scrollbar <> { tk::ScrollToPos %W 1 } } -if {[tk windowingsystem] eq "aqua"} { - bind Scrollbar { - tk::ScrollByUnits %W hv [expr {-(%D)}] - } - bind Scrollbar { - tk::ScrollByUnits %W hv [expr {-10 * (%D)}] - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/30 = 0, - # but - # (int)-1/30 = -1 - # The following code ensure equal +/- behaviour. - bind Scrollbar { - if {%D >= 0} { - tk::ScrollByUnits %W hv [expr {-%D/30}] - } else { - tk::ScrollByUnits %W hv [expr {(29-%D)/30}] - } - } -} - -if {[tk windowingsystem] eq "x11"} { - bind Scrollbar {tk::ScrollByUnits %W hv -5} - bind Scrollbar {tk::ScrollByUnits %W hv 5} - bind Scrollbar {tk::ScrollByUnits %W hv -5} - bind Scrollbar {tk::ScrollByUnits %W hv 5} +bind Scrollbar { + tk::ScrollByUnits %W hv %D -40.0 +} +bind Scrollbar { + tk::ScrollByUnits %W hv %D -12.0 } # tk::ScrollButtonDown -- # This procedure is invoked when a button is pressed in a scrollbar. # It changes the way the scrollbar is displayed and takes actions @@ -327,21 +304,21 @@ # w - The scrollbar widget. # orient - Which kinds of scrollbars this applies to: "h" for # horizontal, "v" for vertical, "hv" for both. # amount - How many units to scroll: typically 1 or -1. -proc ::tk::ScrollByUnits {w orient amount} { +proc ::tk::ScrollByUnits {w orient amount {factor 1.0}} { set cmd [$w cget -command] if {$cmd eq "" || ([string first \ [string index [$w cget -orient] 0] $orient] < 0)} { return } set info [$w get] if {[llength $info] == 2} { - uplevel #0 $cmd scroll $amount units + uplevel #0 $cmd scroll [expr {$amount/$factor}] units } else { - uplevel #0 $cmd [expr {[lindex $info 2] + $amount}] + uplevel #0 $cmd [expr {[lindex $info 2] + [expr {$amount/$factor}]}] } } # ::tk::ScrollByPages -- # This procedure tells the scrollbar's associated widget to scroll up Index: library/spinbox.tcl ================================================================== --- library/spinbox.tcl +++ library/spinbox.tcl @@ -2,14 +2,14 @@ # # This file defines the default bindings for Tk spinbox widgets and provides # procedures that help in implementing those bindings. The spinbox builds # off the entry widget, so it can reuse Entry bindings and procedures. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. -# Copyright (c) 1999-2000 Jeffrey Hobbs -# Copyright (c) 2000 Ajuba Solutions +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. +# Copyright © 1999-2000 Jeffrey Hobbs +# Copyright © 2000 Ajuba Solutions # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -216,13 +216,11 @@ bind Spinbox {# nothing} bind Spinbox {# nothing} bind Spinbox {# nothing} bind Spinbox {# nothing} bind Spinbox {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Spinbox {# nothing} -} +bind Spinbox {# nothing} # On Windows, paste is done using Shift-Insert. Shift-Insert already # generates the <> event, so we don't need to do anything here. if {[tk windowingsystem] ne "win32"} { bind Spinbox { @@ -278,31 +276,18 @@ } } # A few additional bindings of my own. -if {[tk windowingsystem] ne "aqua"} { - bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } - } -} else { - bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntryScanMark %W %x - } - } - bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntryScanDrag %W %x - } +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x } } # ::tk::spinbox::Invoke -- # Invoke an element of the spinbox @@ -481,14 +466,14 @@ } } word { if {$cur < [$w index anchor]} { set before [tcl_wordBreakBefore [$w get] $cur] - set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + set after [tcl_wordBreakAfter [$w get] $anchor-1] } else { set before [tcl_wordBreakBefore [$w get] $anchor] - set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + set after [tcl_wordBreakAfter [$w get] $cur-1] } if {$before < 0} { set before 0 } if {$after < 0} { @@ -587,7 +572,7 @@ # Arguments: # w - The spinbox window from which the text to get proc ::tk::spinbox::GetSelection {w} { return [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] } ADDED library/systray.tcl Index: library/systray.tcl ================================================================== --- /dev/null +++ library/systray.tcl @@ -0,0 +1,329 @@ +# systray.tcl -- + +# This file defines the 'tk systray' command for icon display and manipulation +# in the system tray on X11, Windows, and macOS, and the 'tk sysnotify' command +# for system alerts on each platform. It implements an abstraction layer that +# presents a consistent API across the three platforms. + +# Copyright © 2020 Kevin Walzer/WordTech Communications LLC. +# Copyright © 2020 Eric Boudaillier. +# Copyright © 2020 Francois Vogel. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. + +# Pure-Tcl system tooltip window for use with system tray icon if native +# implementation not available. + +namespace eval ::tk::systray { + variable _created 0 + variable _options {-image "" -text "" -button1 "" -button3 ""} + variable _current {} + variable _ico + + proc _balloon {w help} { + bind $w "after 1000 [list ::tk::systray::_balloon_show %W [list $help]]" + bind $w "destroy %W._balloon" + } + + proc _balloon_show {w arg} { + if {[winfo containing {*}[winfo pointerxy .]] ne $w} { + return + } + set top $w._balloon + catch {destroy $top} + toplevel $top -bg black + wm overrideredirect $top 1 + if {[tk windowingsystem] eq "aqua"} { + ::tk::unsupported::MacWindowStyle style $top help none + } + pack [message $top._txt -aspect 10000 -text $arg] + set wmx [winfo rootx $w] + set wmy [expr {[winfo rooty $w] + [winfo height $w]}] + wm geometry $top [winfo reqwidth $top._txt]x[winfo reqheight $top._txt]+$wmx+$wmy + raise $top + } + + proc _win_callback {msg} { + variable _current + # The API at the Tk level does not feature bindings to double clicks. Whatever + # the speed the user clicks with, he expects the single click binding to fire. + # Therefore we need to bind to both WM_*BUTTONDOWN and to WM_*BUTTONDBLCLK. + switch -exact -- $msg { + WM_LBUTTONDOWN - WM_LBUTTONDBLCLK { + uplevel #0 [dict get $_current -button1] + } + WM_RBUTTONDOWN - WM_RBUTTONDBLCLK { + uplevel #0 [dict get $_current -button3] + } + } + } + + namespace export create configure destroy + namespace ensemble create +} + + +# Pure-Tcl system notification window for use if native implementation not available. +namespace eval ::tk::sysnotify:: { + + proc _notifywindow {title msg} { + catch {destroy ._notify} + set w [toplevel ._notify] + if {[tk windowingsystem] eq "aqua"} { + ::tk::unsupported::MacWindowStyle style $w utility {hud closeBox resizable} + wm title $w "Alert" + } + if {[tk windowingsystem] eq "win32"} { + wm attributes $w -toolwindow true + wm title $w "Alert" + } + label $w.l -bg gray30 -fg white -image ::tk::icons::information + pack $w.l -fill both -expand yes -side left + message $w.message -aspect 150 -bg gray30 -fg white -aspect 150 -text $title\n\n$msg -width 280 + pack $w.message -side right -fill both -expand yes + if {[tk windowingsystem] eq "x11"} { + wm overrideredirect $w true + } + wm attributes $w -alpha 0.0 + set xpos [expr {[winfo screenwidth $w] - 325}] + wm geometry $w +$xpos+30 + ::tk::sysnotify::_fade_in $w + after 3000 ::tk::sysnotify::_fade_out $w + } + + #Fade and destroy window. + proc _fade_out {w} { + catch { + set prev_degree [wm attributes $w -alpha] + set new_degree [expr {$prev_degree - 0.05}] + set current_degree [wm attributes $w -alpha $new_degree] + if {$new_degree > 0.0 && $new_degree != $prev_degree} { + after 10 [list ::tk::sysnotify::_fade_out $w] + } else { + destroy $w + } + } + } + + #Fade the window into view. + proc _fade_in {w} { + catch { + raise $w + wm attributes $w -topmost 1 + set prev_degree [wm attributes $w -alpha] + set new_degree [expr {$prev_degree + 0.05}] + set current_degree [wm attributes $w -alpha $new_degree] + focus -force $w + if {$new_degree < 0.9 && $new_degree != $prev_degree} { + after 10 [list ::tk::sysnotify::_fade_in $w] + } + } + } + namespace export * +} + + +# tk systray -- +# This procedure creates an icon display in the platform-specific system tray. +# +# Subcommands: +# +# create - create systray icon. +# Arguments: +# -image - Tk image to display. +# -text - string to display in tooltip over image. +# -button1 - Tcl proc to invoke on event. +# -button3 - Tcl proc to invoke on event. +# +# configure - change one of the systray properties. +# Arguments (Any or all can be called): +# -image - Tk image to update. +# -text - string to update. +# -button1 - Tcl proc to change for event. +# -button3 - Tcl proc to change for event. +# +# destroy - destroy systray icon. +# Arguments: +# none. +proc ::tk::systray::create {args} { + variable _created + variable _options + variable _current + variable _ico + + if {$_created} { + return -code error -errorcode {TK SYSTRAY CREATE} "only one system tray icon supported per interpeter" + } + _check_options $args 0 + if {![dict exists $args -image]} { + return -code error -errorcode {TK SYSTRAY CREATE} "missing required option \"-image\"" + } + set values [dict merge $_options $args] + try { + switch -- [tk windowingsystem] { + "win32" { + set _ico [_systray add -image [dict get $values -image] \ + -text [dict get $values -text] \ + -callback [list ::tk::systray::_win_callback %m]] + } + "x11" { + _systray ._tray -image [dict get $values -image] -visible true + _balloon ._tray [dict get $values -text] + bind ._tray [dict get $values -button1] + bind ._tray [dict get $values -button3] + } + "aqua" { + _systray create [dict get $values -image] [dict get $values -text] \ + [dict get $values -button1] [dict get $values -button3] + } + } + } on ok {} { + set _current $values + set _created 1 + return + } on error {msg opts} { + return -code error -errorcode [dict get $opts -errorcode] $msg + } +} + +# Modify the systray icon. +proc ::tk::systray::configure {args} { + variable _created + variable _options + variable _current + variable _ico + + if {!$_created} { + return -code error -errorcode {TK SYSTRAY CREATE} "systray not created" + } + _check_options $args 1 + if {[llength $args] == 0} { + return $_current + } elseif {[llength $args] == 1} { + return [dict get $_current [lindex $args 0]] + } + set values [dict merge $_current $args] + try { + switch -- [tk windowingsystem] { + "win32" { + if {[dict exists $args -image]} { + _systray modify $_ico -image [dict get $args -image] + } + if {[dict exists $args -text]} { + _systray modify $_ico -text [dict get $args -text] + } + } + "x11" { + if {[dict exists $args -image]} { + ._tray configure -image [dict get $args -image] + } + if {[dict exists $args -text]} { + _balloon ._tray [dict get $args -text] + } + if {[dict exists $args -button1]} { + bind ._tray [dict get $args -button1] + } + if {[dict exists $args -button3]} { + bind ._tray [dict get $args -button3] + } + } + "aqua" { + foreach {key opt} {image -image text \ + -text b1_callback -button1 b3_callback -button3} { + if {[dict exists $args $opt]} { + _systray modify $key [dict get $args $opt] + } + } + } + } + } on ok {} { + set _current $values + return + } on error {msg opts} { + return -code error -errorcode [dict get $opts -errorcode] $msg + } +} + + +# Remove the systray icon. +proc ::tk::systray::destroy {} { + variable _created + variable _current + variable _ico + + if {!$_created} { + return -code error -errorcode {TK SYSTRAY DESTROY} "systray not created" + } + switch -- [tk windowingsystem] { + "win32" { + _systray delete $_ico + set _ico "" + } + "x11" { + ::destroy ._tray + } + "aqua" { + _systray destroy + } + } + set _created 0 + set _current {} + return +} + +# Check systray options +proc ::tk::systray::_check_options {argsList singleOk} { + variable _options + + set len [llength $argsList] + while {[llength $argsList] > 0} { + set opt [lindex $argsList 0] + if {![dict exists $_options $opt]} { + tailcall return -code error -errorcode {TK SYSTRAY OPTION} \ + "unknown option \"$opt\": must be -image, -text, -button1 or -button3" + } + if {[llength $argsList] == 1 && !($len == 1 && $singleOk)} { + tailcall return -code error -errorcode {TK SYSTRAY OPTION} \ + "missing value for option \"$opt\"" + } + set argsList [lrange $argsList 2 end] + } +} + +# tk sysnotify -- +# This procedure implements a platform-specific system notification alert. +# +# Arguments: +# title - main text of alert. +# message - body text of alert. + +proc ::tk::sysnotify::sysnotify {title message} { + + switch -- [tk windowingsystem] { + "win32" { + if {!$::tk::systray::_created} { + error "must create a system tray icon with the \"tk systray\" command first" + } + _sysnotify notify $::tk::systray::_ico $title $message + } + "x11" { + if {[info commands ::tk::sysnotify::_sysnotify] eq ""} { + _notifywindow $title $message + } else { + _sysnotify $title $message + } + } + "aqua" { + _sysnotify $title $message + } + } + return +} + +#Add these commands to the tk command ensemble: tk systray, tk sysnotify +#Thanks to Christian Gollwitzer for the guidance here +set map [namespace ensemble configure tk -map] +dict set map systray ::tk::systray +dict set map sysnotify ::tk::sysnotify::sysnotify +namespace ensemble configure tk -map $map Index: library/tclIndex ================================================================== --- library/tclIndex +++ library/tclIndex @@ -197,10 +197,11 @@ set auto_index(::tk::SetFocusGrab) [list source [file join $dir tk.tcl]] set auto_index(::tk::RestoreFocusGrab) [list source [file join $dir tk.tcl]] set auto_index(::tk::ScreenChanged) [list source [file join $dir tk.tcl]] set auto_index(::tk::EventMotifBindings) [list source [file join $dir tk.tcl]] set auto_index(::tk::CancelRepeat) [list source [file join $dir tk.tcl]] +set auto_index(::tk::MouseWheel) [list source [file join $dir tk.tcl]] set auto_index(::tk::TabToWindow) [list source [file join $dir tk.tcl]] set auto_index(::tk::dialog::file::) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Config) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Create) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::SetSelectMode) [list source [file join $dir tkfbox.tcl]] Index: library/tearoff.tcl ================================================================== --- library/tearoff.tcl +++ library/tearoff.tcl @@ -1,11 +1,11 @@ # tearoff.tcl -- # # This file contains procedures that implement tear-off menus. # -# Copyright (c) 1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright © 1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -37,11 +37,11 @@ set y [winfo rooty $w] if {[tk windowingsystem] eq "aqua"} { # Shift by height of tearoff entry minus height of window titlebar catch {incr y [expr {[$w yposition 1] - 16}]} # Avoid the native menu bar which sits on top of everything. - if {$y < 22} { set y 22 } + if {$y < 22} {set y 22} } } set parent [winfo parent $w] while {[winfo toplevel $parent] ne $parent \ @@ -151,15 +151,15 @@ set tags [bindtags $src] set srcLen [string length $src] # Copy tags to x, replacing each substring of src with dst. - while {[set index [string first $src $tags]] != -1} { + while {[set index [string first $src $tags]] >= 0} { if {$index > 0} { - append x [string range $tags 0 [expr {$index - 1}]]$dst + append x [string range $tags 0 $index-1]$dst } - set tags [string range $tags [expr {$index + $srcLen}] end] + set tags [string range $tags $index+$srcLen end] } append x $tags bindtags $dst $x @@ -168,17 +168,17 @@ set script [bind $src $event] set eventLen [string length $event] # Copy script to x, replacing each substring of event with dst. - while {[set index [string first $event $script]] != -1} { + while {[set index [string first $event $script]] >= 0} { if {$index > 0} { - append x [string range $script 0 [expr {$index - 1}]] + append x [string range $script 0 $index-1] } append x $dst - set script [string range $script [expr {$index + $eventLen}] end] + set script [string range $script $index+$eventLen end] } append x $script bind $dst $event $x } } Index: library/text.tcl ================================================================== --- library/text.tcl +++ library/text.tcl @@ -1,13 +1,13 @@ # text.tcl -- # # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. -# Copyright (c) 1998 by Scriptics Corporation. +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. +# Copyright © 1998 Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -304,13 +304,11 @@ bind Text {# nothing } bind Text {# nothing} bind Text {# nothing} bind Text {# nothing} bind Text {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Text {# nothing} -} +bind Text {# nothing} # Additional emacs-like bindings: bind Text { if {!$tk_strictMotif && [%W compare end != insert+1c]} { @@ -427,111 +425,33 @@ if {!$tk_strictMotif && [%W compare insert != 1.0]} { %W delete insert-1c %W see insert } } -if {[tk windowingsystem] ne "aqua"} { - bind Text { - if {!$tk_strictMotif} { - tk::TextScanMark %W %x %y - } - } - bind Text { - if {!$tk_strictMotif} { - tk::TextScanDrag %W %x %y - } - } -} else { - bind Text { - if {!$tk_strictMotif} { - tk::TextScanMark %W %x %y - } - } - bind Text { - if {!$tk_strictMotif} { - tk::TextScanDrag %W %x %y - } +bind Text { + if {!$tk_strictMotif} { + tk::TextScanMark %W %x %y + } +} +bind Text { + if {!$tk_strictMotif} { + tk::TextScanDrag %W %x %y } } set ::tk::Priv(prevPos) {} -# The MouseWheel will typically only fire on Windows and MacOS X. -# However, someone could use the "event generate" command to produce one -# on other platforms. We must be careful not to round -ve values of %D -# down to zero. - -if {[tk windowingsystem] eq "aqua"} { - bind Text { - %W yview scroll [expr {-15 * (%D)}] pixels - } - bind Text { - %W yview scroll [expr {-150 * (%D)}] pixels - } - bind Text { - %W xview scroll [expr {-15 * (%D)}] pixels - } - bind Text { - %W xview scroll [expr {-150 * (%D)}] pixels - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/3 = 0, - # but - # (int)-1/3 = -1 - # The following code ensure equal +/- behaviour. - bind Text { - if {%D >= 0} { - %W yview scroll [expr {-%D/3}] pixels - } else { - %W yview scroll [expr {(2-%D)/3}] pixels - } - } - bind Text { - if {%D >= 0} { - %W xview scroll [expr {-%D/3}] pixels - } else { - %W xview scroll [expr {(2-%D)/3}] pixels - } - } -} - -if {[tk windowingsystem] eq "x11"} { - # Support for mousewheels on Linux/Unix commonly comes through mapping - # the wheel to the extended buttons. If you have a mousewheel, find - # Linux configuration info at: - # http://linuxreviews.org/howtos/xfree/mouse/ - bind Text { - if {!$tk_strictMotif} { - %W yview scroll -50 pixels - } - } - bind Text { - if {!$tk_strictMotif} { - %W yview scroll 50 pixels - } - } - bind Text { - if {!$tk_strictMotif} { - %W xview scroll -50 pixels - } - } - bind Text { - if {!$tk_strictMotif} { - %W xview scroll 50 pixels - } - } - bind Text { - if {!$tk_strictMotif} { - %W xview scroll -50 pixels - } - } - bind Text { - if {!$tk_strictMotif} { - %W xview scroll 50 pixels - } - } +bind Text { + tk::MouseWheel %W y %D -4.0 pixels +} +bind Text { + tk::MouseWheel %W y %D -1.2 pixels +} +bind Text { + tk::MouseWheel %W x %D -4.0 pixels +} +bind Text { + tk::MouseWheel %W x %D -1.2 pixels } # ::tk::TextClosestGap -- # Given x and y coordinates, this procedure finds the closest boundary # between characters to the given coordinates and returns the index @@ -579,16 +499,11 @@ if {$x > [lindex $bbox 0]} { $w mark gravity $anchorname right } else { $w mark gravity $anchorname left } - # Allow focus in any case on Windows, because that will let the - # selection be displayed even for state disabled text widgets. - if {[tk windowingsystem] eq "win32" \ - || [$w cget -state] eq "normal"} { - focus $w - } + focus $w if {[$w cget -autoseparators]} { $w edit separator } } Index: library/tk.tcl ================================================================== --- library/tk.tcl +++ library/tk.tcl @@ -1,19 +1,19 @@ # tk.tcl -- # # Initialization script normally executed in the interpreter for each Tk-based # application. Arranges class bindings for widgets. # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1996 Sun Microsystems, Inc. -# Copyright (c) 1998-2000 Ajuba Solutions. +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1996 Sun Microsystems, Inc. +# Copyright © 1998-2000 Ajuba Solutions. # # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.7a4 +package require -exact tk 8.7a4 # Create a ::tk namespace namespace eval ::tk { # Set up the msgcat commands namespace eval msgcat { @@ -364,23 +364,24 @@ #---------------------------------------------------------------------- # Define the set of common virtual events. #---------------------------------------------------------------------- +event add <> +event add <> + switch -exact -- [tk windowingsystem] { "x11" { event add <> event add <> event add <> - event add <> event add <> event add <> - event add <> # On Darwin/Aqua, buttons from left to right are 1,3,2. On Darwin/X11 with recent # XQuartz as the X server, they are 1,2,3; other X servers may differ. - event add <> + event add <> event add <> event add <> event add <> event add <> event add <> @@ -420,16 +421,14 @@ } "win32" { event add <> event add <> event add <> - event add <> event add <> event add <> - event add <> - event add <> + event add <> event add <> event add <> event add <> event add <> event add <> @@ -453,13 +452,11 @@ } "aqua" { event add <> event add <> event add <> - event add <> event add <> - event add <> # Official bindings # See http://support.apple.com/kb/HT1343 event add <> event add <> @@ -494,11 +491,11 @@ # Read in files that define all of the class bindings. # ---------------------------------------------------------------------- if {$::tk_library ne ""} { proc ::tk::SourceLibFile {file} { - namespace eval :: [list source [file join $::tk_library $file.tcl]] + namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]] } namespace eval ::tk { SourceLibFile icons SourceLibFile button SourceLibFile entry @@ -506,10 +503,11 @@ SourceLibFile menu SourceLibFile panedwindow SourceLibFile scale SourceLibFile scrlbar SourceLibFile spinbox + SourceLibFile systray SourceLibFile text } } # ---------------------------------------------------------------------- @@ -534,10 +532,17 @@ variable ::tk::Priv after cancel $Priv(afterId) set Priv(afterId) {} } +## ::tk::MouseWheel $w $dir $amount $factor $units + +proc ::tk::MouseWheel {w dir amount {factor -120.0} {units units}} { + $w ${dir}view scroll [expr {$amount/$factor}] $units +} + + # ::tk::TabToWindow -- # This procedure moves the focus to the given widget. # It sends a <> virtual event to the previous focus window, # if any, before changing the focus, and a <> event # to the new focus window afterwards. @@ -625,12 +630,12 @@ TButton TCheckbutton TLabel TRadiobutton } && [string equal -nocase $char \ [string index [$path cget -text] [$path cget -underline]]]} { return $path } - set subwins [concat [grid slaves $path] [pack slaves $path] \ - [place slaves $path]] + set subwins [concat [grid content $path] [pack content $path] \ + [place content $path]] if {$class eq "Canvas"} { foreach item [$path find all] { if {[$path type $item] eq "window"} { set w [$path itemcget $item -window] if {$w ne ""} {lappend subwins $w} @@ -685,13 +690,15 @@ if {[tk windowingsystem] eq "aqua"} { #stub procedures to respond to "do script" Apple Events proc ::tk::mac::DoScriptFile {file} { - source $file + uplevel #0 $file + source -encoding utf-8 $file } proc ::tk::mac::DoScriptText {script} { + uplevel #0 $script eval $script } } # Create a dictionary to store the starting index of the IME marked @@ -699,12 +706,12 @@ set ::tk::Priv(IMETextMark) [dict create] # Run the Ttk themed widget set initialization if {$::ttk::library ne ""} { - uplevel \#0 [list source $::ttk::library/ttk.tcl] + uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl] } # Local Variables: # mode: tcl # fill-column: 78 # End: Index: library/tkfbox.tcl ================================================================== --- library/tkfbox.tcl +++ library/tkfbox.tcl @@ -8,11 +8,11 @@ # selection dialog box on Win95(TM). The user can navigate the # directories by clicking on the folder icons or by selecting the # "Directory" option menu. The user can select files by clicking on the # file icons or by entering a filename in the "Filename:" entry. # -# Copyright (c) 1994-1998 Sun Microsystems, Inc. +# Copyright © 1994-1998 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Index: library/ttk/aquaTheme.tcl ================================================================== --- library/ttk/aquaTheme.tcl +++ library/ttk/aquaTheme.tcl @@ -33,25 +33,42 @@ pressed white {alternate !pressed !background} white} ttk::style configure TMenubutton -anchor center -padding {2 0 0 2} ttk::style configure Toolbutton -anchor center + # For Entry, Combobox and Spinbox widgets the selected text background + # is the "Highlight color" selected in preferences when the widget + # has focus. It is a gray color when the widget does not have focus or + # the window does not have focus. (The background state implies !focus + # so we only need to specify !focus.) + # Entry - ttk::style configure TEntry \ - -foreground systemTextColor \ - -background systemTextBackgroundColor ttk::style map TEntry \ -foreground { disabled systemDisabledControlTextColor } \ - -selectforeground { - background systemTextColor + -selectbackground { + !focus systemUnemphasizedSelectedTextBackgroundColor + } + + # Combobox: + ttk::style map TCombobox \ + -foreground { + disabled systemDisabledControlTextColor } \ -selectbackground { - background systemTextBackgroundColor + !focus systemUnemphasizedSelectedTextBackgroundColor } + # Spinbox + ttk::style map TSpinbox \ + -foreground { + disabled systemDisabledControlTextColor + } \ + -selectbackground { + !focus systemUnemphasizedSelectedTextBackgroundColor + } # Workaround for #1100117: # Actually, on Aqua we probably shouldn't stipple images in # disabled buttons even if it did work... ttk::style configure . -stipple {} @@ -65,44 +82,10 @@ -foreground { background systemControlTextColor disabled systemDisabledControlTextColor selected systemSelectedTabTextColor} - # Combobox: - ttk::style configure TCombobox \ - -foreground systemTextColor \ - -background systemTransparent - ttk::style map TCombobox \ - -foreground { - disabled systemDisabledControlTextColor - } \ - -selectforeground { - background systemTextColor - } \ - -selectbackground { - background systemTransparent - } - - # Spinbox - ttk::style configure TSpinbox \ - -foreground systemTextColor \ - -background systemTextBackgroundColor \ - -selectforeground systemSelectedTextColor \ - -selectbackground systemSelectedTextBackgroundColor - ttk::style map TSpinbox \ - -foreground { - disabled systemDisabledControlTextColor - } \ - -selectforeground { - !active systemTextColor - } \ - -selectbackground { - !active systemTextBackgroundColor - !focus systemTextBackgroundColor - focus systemSelectedTextBackgroundColor - } - # Treeview: ttk::style configure Heading \ -font TkHeadingFont \ -foreground systemTextColor \ -background systemWindowBackgroundColor @@ -114,11 +97,11 @@ -background { selected systemSelectedTextBackgroundColor } # Enable animation for ttk::progressbar widget: - ttk::style configure TProgressbar -period 100 -maxphase 255 + ttk::style configure TProgressbar -period 100 -maxphase 120 # For Aqua, labelframe labels should appear outside the border, # with a 14 pixel inset and 4 pixels spacing between border and label # (ref: Apple Human Interface Guidelines / Controls / Grouping Controls) # Index: library/ttk/button.tcl ================================================================== --- library/ttk/button.tcl +++ library/ttk/button.tcl @@ -40,11 +40,11 @@ # ...plus a few more: bind TRadiobutton { ttk::button::RadioTraverse %W -1 } bind TRadiobutton { ttk::button::RadioTraverse %W +1 } -# bind TCheckbutton { %W select } +# bind TCheckbutton <+> { %W select } # bind TCheckbutton { %W deselect } # activate -- # Simulate a button press: temporarily set the state to 'pressed', # then invoke the button. Index: library/ttk/combobox.tcl ================================================================== --- library/ttk/combobox.tcl +++ library/ttk/combobox.tcl @@ -180,43 +180,50 @@ event generate $cb <> -when mark } ## Scroll -- Mousewheel binding # -proc ttk::combobox::Scroll {cb dir} { +proc ttk::combobox::Scroll {cb dir {factor 1.0}} { $cb instate disabled { return } set max [llength [$cb cget -values]] set current [$cb current] - incr current $dir - if {$max != 0 && $current == $current % $max} { - SelectEntry $cb $current + if {$current < 0} { + set index 0 + } else { + set d [expr {$dir/$factor}] + set index [expr {$current + int($d > 0 ? ceil($d) : floor($d))}] + if {$index >= $max} {set index [expr {$max - 1}]} + if {$index < 0} {set index 0} + } + if {$max != 0 && $index != $current} { + SelectEntry $cb $index } } ## LBSelected $lb -- Activation binding for listbox # Set the combobox value to the currently-selected listbox value # and unpost the listbox. # proc ttk::combobox::LBSelected {lb} { - set cb [LBMaster $lb] + set cb [LBMain $lb] LBSelect $lb Unpost $cb focus $cb } ## LBCancel -- # Unpost the listbox. # proc ttk::combobox::LBCancel {lb} { - Unpost [LBMaster $lb] + Unpost [LBMain $lb] } ## LBTab -- Tab key binding for combobox listbox. # Set the selection, and navigate to next/prev widget. # proc ttk::combobox::LBTab {lb dir} { - set cb [LBMaster $lb] + set cb [LBMain $lb] switch -- $dir { next { set newFocus [tk_focusNext $cb] } prev { set newFocus [tk_focusPrev $cb] } } @@ -355,10 +362,13 @@ set x [winfo rootx $cb] set y [winfo rooty $cb] set w [winfo width $cb] set h [winfo height $cb] set style [$cb cget -style] + if { $style eq {} } { + set style TCombobox + } set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}] foreach var {x y w h} delta $postoffset { incr $var $delta } @@ -409,22 +419,22 @@ wm withdraw $cb.popdown } grab release $cb.popdown ;# in case of stuck or unexpected grab [#1239190] } -## LBMaster $lb -- +## LBMain $lb -- # Return the combobox main widget that owns the listbox. # -proc ttk::combobox::LBMaster {lb} { +proc ttk::combobox::LBMain {lb} { winfo parent [winfo parent [winfo parent $lb]] } ## LBSelect $lb -- # Transfer listbox selection to combobox value. # proc ttk::combobox::LBSelect {lb} { - set cb [LBMaster $lb] + set cb [LBMain $lb] set selection [$lb curselection] if {[llength $selection] == 1} { SelectEntry $cb [lindex $selection 0] } } @@ -437,9 +447,9 @@ # because the widget command is already gone when this binding fires). # [winfo parent] still works, fortunately. # proc ttk::combobox::LBCleanup {lb} { variable Values - unset Values([LBMaster $lb]) + unset Values([LBMain $lb]) } #*EOF* Index: library/ttk/entry.tcl ================================================================== --- library/ttk/entry.tcl +++ library/ttk/entry.tcl @@ -1,11 +1,11 @@ # # DERIVED FROM: tk/library/entry.tcl r1.22 # -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-1997 Sun Microsystems, Inc. -# Copyright (c) 2004, Joe English +# Copyright © 1992-1994 The Regents of the University of California. +# Copyright © 1994-1997 Sun Microsystems, Inc. +# Copyright © 2004, Joe English # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -80,24 +80,18 @@ bind TEntry <> { %W instate {!readonly !disabled} { %W icursor @%x ; focus %W } } -## Button2 (Button3 on Aqua) bindings: +## Button2 bindings: # Used for scanning and primary transfer. -# Note: ButtonRelease-2 (ButtonRelease-3 on Aqua) +# Note: ButtonRelease-2 # is mapped to <> in tk.tcl. # -if {[tk windowingsystem] ne "aqua"} { - bind TEntry { ttk::entry::ScanMark %W %x } - bind TEntry { ttk::entry::ScanDrag %W %x } - bind TEntry { ttk::entry::ScanRelease %W %x } -} else { - bind TEntry { ttk::entry::ScanMark %W %x } - bind TEntry { ttk::entry::ScanDrag %W %x } - bind TEntry { ttk::entry::ScanRelease %W %x } -} +bind TEntry { ttk::entry::ScanMark %W %x } +bind TEntry { ttk::entry::ScanDrag %W %x } +bind TEntry { ttk::entry::ScanRelease %W %x } bind TEntry <> { ttk::entry::ScanRelease %W %x } ## Keyboard navigation bindings: # bind TEntry <> { ttk::entry::Move %W prevchar } @@ -134,16 +128,12 @@ bind TEntry {# nothing} bind TEntry {# nothing} bind TEntry {# nothing} bind TEntry {# nothing} bind TEntry {# nothing} +bind TEntry {# nothing} -# Argh. Apparently on Windows, the NumLock modifier is interpreted -# as a Command modifier. -if {[tk windowingsystem] eq "aqua"} { - bind TEntry {# nothing} -} # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind TEntry <> {# nothing} bind TEntry <> {# nothing} ## Additional emacs-like bindings: @@ -177,11 +167,11 @@ ## EntrySelection -- Return the selected text of the entry. # Raises an error if there is no selection. # proc ttk::entry::EntrySelection {w} { set entryString [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] if {[$w cget -show] ne ""} { return [string repeat [string index [$w cget -show] 0] \ [string length $entryString]] } return $entryString Index: library/ttk/fonts.tcl ================================================================== --- library/ttk/fonts.tcl +++ library/ttk/fonts.tcl @@ -76,11 +76,11 @@ set F(family) "Tahoma" } else { set F(family) "MS Sans Serif" } } else { - if {[lsearch -exact [font families] Tahoma] != -1} { + if {[lsearch -exact [font families] Tahoma] >= 0} { set F(family) "Tahoma" } else { set F(family) "MS Sans Serif" } } Index: library/ttk/menubutton.tcl ================================================================== --- library/ttk/menubutton.tcl +++ library/ttk/menubutton.tcl @@ -222,15 +222,15 @@ } # FindMenuEntry -- # Hack to support tk_optionMenus. # Returns the index of the menu entry with a matching -label, -# -1 if not found. +# "" if not found. # proc ttk::menubutton::FindMenuEntry {menu s} { set last [$menu index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return "" } for {set i 0} {$i <= $last} {incr i} { if {![catch {$menu entrycget $i -label} label] && ($label eq $s)} { Index: library/ttk/notebook.tcl ================================================================== --- library/ttk/notebook.tcl +++ library/ttk/notebook.tcl @@ -14,10 +14,12 @@ catch { bind TNotebook { ttk::notebook::CycleTab %W -1; break } } bind TNotebook { ttk::notebook::Cleanup %W } +ttk::bindMouseWheel TNotebook [list ttk::notebook::CycleTab %W] + # ActivateTab $nb $tab -- # Select the specified tab and set focus. # # Desired behavior: # + take focus when reselecting the currently-selected tab; @@ -54,16 +56,20 @@ } # CycleTab -- # Select the next/previous tab in the list. # -proc ttk::notebook::CycleTab {w dir} { +proc ttk::notebook::CycleTab {w dir {factor 1.0}} { if {[$w index end] != 0} { set current [$w index current] - set select [expr {($current + $dir) % [$w index end]}] - while {[$w tab $select -state] != "normal" && ($select != $current)} { - set select [expr {($select + $dir) % [$w index end]}] + set d [expr {$dir/$factor}] + set d [expr {int($d > 0 ? ceil($d) : floor($d))}] + set tabCount [$w index end] + set select [expr {($current + $d) % $tabCount}] + set step [expr {$dir > 0 ? 1 : -1}] + while {[$w tab $select -state] ne "normal" && ($select != $current)} { + set select [expr {($select + $step) % $tabCount}] } if {$select != $current} { ActivateTab $w $select } } @@ -110,17 +116,12 @@ bind $top {+ttk::notebook::TLCycleTab %W 1} bind $top {+ttk::notebook::TLCycleTab %W -1} catch { bind $top {+ttk::notebook::TLCycleTab %W -1} } - if {[tk windowingsystem] eq "aqua"} { - bind $top \ - +[list ttk::notebook::MnemonicActivation $top %K] - } else { - bind $top \ - +[list ttk::notebook::MnemonicActivation $top %K] - } + bind $top \ + +[list ttk::notebook::MnemonicActivation $top %K] bind $top {+ttk::notebook::TLCleanup %W} } lappend TLNotebooks($top) $nb } Index: library/ttk/scale.tcl ================================================================== --- library/ttk/scale.tcl +++ library/ttk/scale.tcl @@ -1,6 +1,6 @@ -# scale.tcl - Copyright (C) 2004 Pat Thoyts +# scale.tcl - Copyright © 2004 Pat Thoyts # # Bindings for the TScale widget namespace eval ttk::scale { variable State Index: library/ttk/scrollbar.tcl ================================================================== --- library/ttk/scrollbar.tcl +++ library/ttk/scrollbar.tcl @@ -17,25 +17,12 @@ bind TScrollbar { ttk::scrollbar::Drag %W %x %y } bind TScrollbar { ttk::scrollbar::Release %W %x %y } # Redirect scrollwheel bindings to the scrollbar widget # -# The shift-bindings scroll left/right (not up/down) -# if a widget has both possibilities -set eventList [list ] -switch [tk windowingsystem] { - aqua { - lappend eventList - } - x11 { - lappend eventList - } -} -foreach event $eventList { - bind TScrollbar $event [bind Scrollbar $event] -} -unset eventList event +bind TScrollbar [bind Scrollbar ] +bind TScrollbar [bind Scrollbar ] proc ttk::scrollbar::Scroll {w n units} { set cmd [$w cget -command] if {$cmd ne ""} { uplevel #0 $cmd scroll $n $units @@ -54,18 +41,19 @@ set State(xPress) $x set State(yPress) $y switch -glob -- [$w identify $x $y] { - *uparrow - + *uparrow - *leftarrow { ttk::Repeatedly Scroll $w -1 units } *downarrow - *rightarrow { ttk::Repeatedly Scroll $w 1 units } + *grip - *thumb { set State(first) [lindex [$w get] 0] } *trough { set f [$w fraction $x $y] @@ -107,10 +95,11 @@ # proc ttk::scrollbar::Jump {w x y} { variable State switch -glob -- [$w identify $x $y] { + *grip - *thumb - *trough { set State(first) [$w fraction $x $y] Moveto $w $State(first) set State(xPress) $x Index: library/ttk/spinbox.tcl ================================================================== --- library/ttk/spinbox.tcl +++ library/ttk/spinbox.tcl @@ -21,20 +21,20 @@ bind TSpinbox { event generate %W <> } bind TSpinbox <> { ttk::spinbox::Spin %W +1 } bind TSpinbox <> { ttk::spinbox::Spin %W -1 } -ttk::bindMouseWheel TSpinbox [list ttk::spinbox::MouseWheel %W] +ttk::bindMouseWheel TSpinbox [list ttk::spinbox::Spin %W] ## Motion -- # Sets cursor. # proc ttk::spinbox::Motion {w x y} { variable State ttk::saveCursor $w State(userConfCursor) [ttk::cursor text] if { [$w identify $x $y] eq "textarea" - && [$w instate {!readonly !disabled}] + && [$w instate {!readonly !disabled}] } { ttk::setCursor $w text } else { ttk::setCursor $w $State(userConfCursor) } @@ -44,20 +44,20 @@ # proc ttk::spinbox::Press {w x y} { if {[$w instate disabled]} { return } focus $w switch -glob -- [$w identify $x $y] { - *textarea { ttk::entry::Press $w $x } + *textarea { ttk::entry::Press $w $x } *rightarrow - - *uparrow { ttk::Repeatedly event generate $w <> } + *uparrow { ttk::Repeatedly event generate $w <> } *leftarrow - - *downarrow { ttk::Repeatedly event generate $w <> } + *downarrow { ttk::Repeatedly event generate $w <> } *spinbutton { if {$y * 2 >= [winfo height $w]} { - set event <> + set event <> } else { - set event <> + set event <> } ttk::Repeatedly event generate $w $event } } } @@ -67,11 +67,11 @@ # proc ttk::spinbox::DoubleClick {w x y} { if {[$w instate disabled]} { return } switch -glob -- [$w identify $x $y] { - *textarea { SelectAll $w } + *textarea { SelectAll $w } * { Press $w $x $y } } } proc ttk::spinbox::Release {w} { @@ -78,17 +78,17 @@ ttk::CancelRepeat } ## MouseWheel -- # Mousewheel callback. Turn these into <> (-1, up) -# or < (+1, down) events. +# or < (+1, down) events. Not used any more. # -proc ttk::spinbox::MouseWheel {w dir} { +proc ttk::spinbox::MouseWheel {w dir {factor 1.0}} { if {[$w instate disabled]} { return } - if {$dir < 0} { + if {($dir < 0) ^ ($factor < 0)} { event generate $w <> - } else { + } elseif {$dir != 0} { event generate $w <> } } ## SelectAll -- @@ -132,35 +132,38 @@ # Handle <> and <> events. # If -values is specified, cycle through the list. # Otherwise cycle through numeric range based on # -from, -to, and -increment. # -proc ttk::spinbox::Spin {w dir} { +proc ttk::spinbox::Spin {w dir {factor -1.0}} { variable State if {[$w instate disabled]} { return } if {![info exists State($w,values.length)]} { - set State($w,values.index) -1 - set State($w,values.last) {} + set State($w,values.index) -1 + set State($w,values.last) {} } set State($w,values) [$w cget -values] set State($w,values.length) [llength $State($w,values)] + set d [expr {-($dir/$factor)}] + set d [expr {int($d > 0 ? ceil($d) : floor($d))}] if {$State($w,values.length) > 0} { - set value [$w get] - set current $State($w,values.index) - if {$value ne $State($w,values.last)} { - set current [lsearch -exact $State($w,values) $value] - } - set State($w,values.index) [Adjust $w [expr {$current + $dir}] 0 \ - [expr {$State($w,values.length) - 1}]] - set State($w,values.last) [lindex $State($w,values) $State($w,values.index)] - $w set $State($w,values.last) + set value [$w get] + set current $State($w,values.index) + if {$value ne $State($w,values.last)} { + set current [lsearch -exact $State($w,values) $value] + if {$current < 0} {set current -1} + } + set State($w,values.index) [Adjust $w [expr {$current + $d}] 0 \ + [expr {$State($w,values.length) - 1}]] + set State($w,values.last) [lindex $State($w,values) $State($w,values.index)] + $w set $State($w,values.last) } else { - if {[catch { - set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}] + if {[catch { + set v [expr {[scan [$w get] %f] + $d * [$w cget -increment]}] }]} { set v [$w cget -from] } $w set [FormatValue $w [Adjust $w $v [$w cget -from] [$w cget -to]]] } @@ -174,11 +177,11 @@ proc ttk::spinbox::FormatValue {w val} { set fmt [$w cget -format] if {$fmt eq ""} { # Try to guess a suitable -format based on -increment. set delta [expr {abs([$w cget -increment])}] - if {0 < $delta && $delta < 1} { + if {0 < $delta && $delta < 1} { # NB: This guesses wrong if -increment has more than 1 # significant digit itself, e.g., -increment 0.25 set nsd [expr {int(ceil(-log10($delta)))}] set fmt "%.${nsd}f" } else { Index: library/ttk/ttk.tcl ================================================================== --- library/ttk/ttk.tcl +++ library/ttk/ttk.tcl @@ -10,13 +10,13 @@ if {![info exists library]} { set library [file dirname [info script]] } } -source [file join $::ttk::library fonts.tcl] -source [file join $::ttk::library cursors.tcl] -source [file join $::ttk::library utils.tcl] +source -encoding utf-8 [file join $::ttk::library fonts.tcl] +source -encoding utf-8 [file join $::ttk::library cursors.tcl] +source -encoding utf-8 [file join $::ttk::library utils.tcl] ## ttk::deprecated $old $new -- # Define $old command as a deprecated alias for $new command # $old and $new must be fully namespace-qualified. # @@ -95,22 +95,22 @@ set currentTheme $theme } ### Load widget bindings. # -source [file join $::ttk::library button.tcl] -source [file join $::ttk::library menubutton.tcl] -source [file join $::ttk::library scrollbar.tcl] -source [file join $::ttk::library scale.tcl] -source [file join $::ttk::library progress.tcl] -source [file join $::ttk::library notebook.tcl] -source [file join $::ttk::library panedwindow.tcl] -source [file join $::ttk::library entry.tcl] -source [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl -source [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl -source [file join $::ttk::library treeview.tcl] -source [file join $::ttk::library sizegrip.tcl] +source -encoding utf-8 [file join $::ttk::library button.tcl] +source -encoding utf-8 [file join $::ttk::library menubutton.tcl] +source -encoding utf-8 [file join $::ttk::library scrollbar.tcl] +source -encoding utf-8 [file join $::ttk::library scale.tcl] +source -encoding utf-8 [file join $::ttk::library progress.tcl] +source -encoding utf-8 [file join $::ttk::library notebook.tcl] +source -encoding utf-8 [file join $::ttk::library panedwindow.tcl] +source -encoding utf-8 [file join $::ttk::library entry.tcl] +source -encoding utf-8 [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl +source -encoding utf-8 [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl +source -encoding utf-8 [file join $::ttk::library treeview.tcl] +source -encoding utf-8 [file join $::ttk::library sizegrip.tcl] ## Label and Labelframe bindings: # (not enough to justify their own file...) # bind TLabelframe <> { tk::TabToWindow [tk_focusNext %W] } @@ -120,11 +120,11 @@ # proc ttk::LoadThemes {} { variable library # "default" always present: - uplevel #0 [list source [file join $library defaults.tcl]] + uplevel #0 [list source -encoding utf-8 [file join $library defaults.tcl]] set builtinThemes [style theme names] foreach {theme scripts} { classic classicTheme.tcl alt altTheme.tcl @@ -133,11 +133,11 @@ xpnative {xpTheme.tcl vistaTheme.tcl} aqua aquaTheme.tcl } { if {[lsearch -exact $builtinThemes $theme] >= 0} { foreach script $scripts { - uplevel #0 [list source [file join $library $script]] + uplevel #0 [list source -encoding utf-8 [file join $library $script]] } } } } Index: library/ttk/utils.tcl ================================================================== --- library/ttk/utils.tcl +++ library/ttk/utils.tcl @@ -271,103 +271,34 @@ ### Mousewheel bindings. # # Platform inconsistencies: # -# On X11, the server typically maps the mouse wheel to Button4 and Button5. -# -# On OSX, Tk generates sensible values for the %D field in events. -# -# On Windows, %D must be scaled by a factor of 120. -# In addition, Tk redirects mousewheel events to the window with -# keyboard focus instead of sending them to the window under the pointer. -# We do not attempt to fix that here, see also TIP#171. -# -# OSX conventionally uses Shift+MouseWheel for horizontal scrolling, -# and Option+MouseWheel for accelerated scrolling. -# -# The Shift+MouseWheel behavior is not conventional on Windows or most -# X11 toolkits, but it's useful. -# # MouseWheel scrolling is accelerated on X11, which is conventional # for Tk and appears to be conventional for other toolkits (although # Gtk+ and Qt do not appear to use as large a factor). # ## ttk::bindMouseWheel $bindtag $command... # Adds basic mousewheel support to $bindtag. -# $command will be passed one additional argument -# specifying the mousewheel direction (-1: up, +1: down). +# $command will be passed two additional arguments +# specifying the mousewheel change and a factor. # proc ttk::bindMouseWheel {bindtag callback} { - if {[tk windowingsystem] eq "x11"} { - bind $bindtag "$callback -1" - bind $bindtag "$callback +1" - } - if {[tk windowingsystem] eq "aqua"} { - bind $bindtag [append callback { [expr {-(%D)}]} ] - bind $bindtag [append callback { [expr {-10 *(%D)}]} ] - } else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - bind $bindtag [append callback { [ - expr {%D>=0 ? (-%D/120) : ((119-%D)/120)} - ]}] - } + bind $bindtag "$callback %D -120.0" + bind $bindtag "$callback %D -12.0" } ## Mousewheel bindings for standard scrollable widgets. # -# Usage: [ttk::copyBindings TtkScrollable $bindtag] -# -# $bindtag should be for a widget that supports the -# standard scrollbar protocol. -# - -if {[tk windowingsystem] eq "x11"} { - bind TtkScrollable { %W yview scroll -5 units } - bind TtkScrollable { %W yview scroll 5 units } - bind TtkScrollable { %W xview scroll -5 units } - bind TtkScrollable { %W xview scroll 5 units } -} -if {[tk windowingsystem] eq "aqua"} { - bind TtkScrollable { - %W yview scroll [expr {-(%D)}] units - } - bind TtkScrollable { - %W xview scroll [expr {-(%D)}] units - } - bind TtkScrollable { - %W yview scroll [expr {-10 * (%D)}] units - } - bind TtkScrollable { - %W xview scroll [expr {-10 * (%D)}] units - } -} else { - # We must make sure that positive and negative movements are rounded - # equally to integers, avoiding the problem that - # (int)1/120 = 0, - # but - # (int)-1/120 = -1 - # The following code ensure equal +/- behaviour. - bind TtkScrollable { - if {%D >= 0} { - %W yview scroll [expr {-%D/120}] units - } else { - %W yview scroll [expr {(119-%D)/120}] units - } - } - bind TtkScrollable { - if {%D >= 0} { - %W xview scroll [expr {-%D/120}] units - } else { - %W xview scroll [expr {(119-%D)/120}] units - } - } -} + +bind TtkScrollable \ + { tk::MouseWheel %W y %D -40.0 } +bind TtkScrollable \ + { tk::MouseWheel %W y %D -12.0 } +bind TtkScrollable \ + { tk::MouseWheel %W x %D -40.0 } +bind TtkScrollable \ + { tk::MouseWheel %W x %D -12.0 } #*EOF* Index: library/ttk/vistaTheme.tcl ================================================================== --- library/ttk/vistaTheme.tcl +++ library/ttk/vistaTheme.tcl @@ -67,13 +67,13 @@ COMBOBOX 6 {disabled 4 pressed 3 active 2 {} 1} \ -syssize {SM_CXVSCROLL SM_CYVSCROLL} ttk::style layout TCombobox { Combobox.border -sticky nswe -border 0 -children { Combobox.rightdownarrow -side right -sticky ns - Combobox.padding -expand 1 -sticky nswe -children { + Combobox.padding -sticky nswe -children { Combobox.background -sticky nswe -children { - Combobox.focus -expand 1 -sticky nswe -children { + Combobox.focus -sticky nswe -children { Combobox.textarea -sticky nswe } } } } @@ -136,11 +136,11 @@ ttk::style layout TSpinbox { Spinbox.field -sticky nswe -children { Spinbox.background -sticky news -children { Spinbox.padding -sticky news -children { Spinbox.innerbg -sticky news -children { - Spinbox.textarea -expand 1 + Spinbox.textarea } } Spinbox.uparrow -side top -sticky ens Spinbox.downarrow -side bottom -sticky ens } @@ -201,23 +201,23 @@ # Scale ttk::style element create Horizontal.Scale.slider vsapi \ TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \ -width 6 -height 12 ttk::style layout Horizontal.TScale { - Scale.focus -expand 1 -sticky nswe -children { - Horizontal.Scale.trough -expand 1 -sticky nswe -children { + Scale.focus -sticky nswe -children { + Horizontal.Scale.trough -sticky nswe -children { Horizontal.Scale.track -sticky we Horizontal.Scale.slider -side left -sticky {} } } } ttk::style element create Vertical.Scale.slider vsapi \ TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \ -width 12 -height 6 ttk::style layout Vertical.TScale { - Scale.focus -expand 1 -sticky nswe -children { - Vertical.Scale.trough -expand 1 -sticky nswe -children { + Scale.focus -sticky nswe -children { + Vertical.Scale.trough -sticky nswe -children { Vertical.Scale.track -sticky ns Vertical.Scale.slider -side top -sticky {} } } } Index: library/xmfbox.tcl ================================================================== --- library/xmfbox.tcl +++ library/xmfbox.tcl @@ -2,12 +2,12 @@ # # Implements the "Motif" style file selection dialog for the # Unix platform. This implementation is used only if the # "::tk_strictMotif" flag is set. # -# Copyright (c) 1996 Sun Microsystems, Inc. -# Copyright (c) 1998-2000 Scriptics Corporation +# Copyright © 1996 Sun Microsystems, Inc. +# Copyright © 1998-2000 Scriptics Corporation # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. namespace eval ::tk::dialog {} ADDED macosx/Credits.html.in Index: macosx/Credits.html.in ================================================================== --- /dev/null +++ macosx/Credits.html.in @@ -0,0 +1,24 @@ + + + + + +

+Tcl and Tk are distributed under a modified BSD license:
+ + https:www.tcl.tk/software/tcltk/license.html + +

+
    +
  • © 1987-@TK_YEAR@ Tcl Core Team and Contributers.
  • +
  • © 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.
  • +
  • © 2014-@TK_YEAR@ Marc Culler.
  • +
  • © 2002-2012 Daniel A. Steffen.
  • +
  • © 2001-2009 Apple Inc.
  • +
  • © 2001-2002 Jim Ingham & Ian Reid.
  • +
  • © 1998-2000 Jim Ingham & Ray Johnson.
  • +
  • © 1998-2000 Scriptics Inc.
  • +
  • © 1996-1997 Sun Microsystems Inc.
  • +
+ + Index: macosx/GNUmakefile ================================================================== --- macosx/GNUmakefile +++ macosx/GNUmakefile @@ -41,10 +41,22 @@ # set to non-empty value to install manpages in addition to html help: INSTALL_MANPAGES ?= # set to non-empty value to build TkX11 instead of TkAqua: TK_X11 ?= + +# Checks and overrides for subframework builds +ifeq (${SUBFRAMEWORK}_${TK_X11},1_) +ifeq (${DYLIB_INSTALL_DIR},) + @echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false +endif +ifeq (${DESTDIR},) + @echo "Cannot install subframework with empty DESTDIR !" && false +endif +override BUILD_DIR = ${DESTDIR}/build +override INSTALL_PATH = /Frameworks +endif #------------------------------------------------------------------------------------------------------- # meta targets meta := all install embedded install-embedded clean distclean test @@ -86,11 +98,11 @@ empty := space := ${empty} ${empty} objdir = $(subst ${space},\ ,${OBJ_DIR}) develop_make_args := BUILD_STYLE=Development CONFIGURE_ARGS=--enable-symbols -deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install-strip +deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install embedded_make_args := EMBEDDED_BUILD=1 install_make_args := INSTALL_BUILD=1 ${targets}: ${MAKE} ${action}${PROJECT} \ @@ -209,13 +221,19 @@ install-${PROJECT}: build-${PROJECT} ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_) @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false endif +ifeq (${SUBFRAMEWORK}_${DYLIB_INSTALL_DIR},1_) + @echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false +endif ifeq (${EMBEDDED_BUILD},1) @rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tk.framework" endif +ifeq (${SUBFRAMEWORK},1) + @rm -rf "${INSTALL_ROOT}/Frameworks/Tk.framework" +endif ${DO_MAKE} ifeq (${EMBEDDED_BUILD}_${TK_X11},1_) # workaround bug with 'cp -pRH' on Darwin 6 and earlier @if [ "`uname -r | awk -F. '{print $$1}'`" -lt 7 ]; then \ mkdir -p "${TOP_DIR}"/{"${TCL_FMWK_DIR}","${TK_FMWK_DIR}"}/PrivateHeaders; fi @@ -226,21 +244,22 @@ @rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && \ rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true else # install wish symbolic link @ln -fs ${WISH} "${INSTALL_ROOT}${BINDIR}/${wish}" -endif -endif +endif # embedded +endif # install ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_) # keep copy of debug library around, so that # Deployment build can be installed on top # of Development build without overwriting # the debug library @cd "${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}" && \ ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug" -endif +endif # Development, not embedded ifeq (${TK_X11},) +ifeq (${SUBFRAMEWORK},) ifeq (${EMBEDDED_BUILD},) # install Wish.app link in APPLICATION_INSTALL_PATH and setup 'Wish Shell' compatibility links @cd "${TOP_DIR}" && if [ -n "${APP_DIR}" ]; then mkdir -p "./${APP_DIR}" && rm -rf "./${APP_DIR}/Wish.app" && \ ln -fsh "./$$(echo "${APP_DIR}" | sed -e 's#/[^/][^/]*#/..#g')/${FMWK_DIR}/${PRODUCT_NAME}.framework/Resources/Wish.app" "./${APP_DIR}" && \ ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app"; fi && \ @@ -270,13 +289,14 @@ } && \ fix_install_id Frameworks/Tcl.framework/Tcl Tcl && fix_install_id Frameworks/Tk.framework/Tk Tk && \ fix_install_name MacOS/Wish Tcl && fix_install_name MacOS/Wish Tk ifeq (${INSTALL_BUILD},1) @cd "${TOP_DIR}" && rm -rf "./${FMWK_DIR}"/T{cl,k}.framework && rmdir -p "./${FMWK_DIR}" 2>&- || true -endif -endif -endif +endif # install not subframework +endif # embedded +endif # not subframework +endif # not X11 clean-${PROJECT}: %-${PROJECT}: ${DO_MAKE} rm -rf "${SYMROOT}"/{${PRODUCT_NAME}.framework,${WISH},tktest} rm -f "${OBJ_DIR}"{"${LIBDIR}","${BINDIR}"} && \ Index: macosx/README ================================================================== --- macosx/README +++ macosx/README @@ -270,24 +270,28 @@ With the release of OSX 10.14 (Mojave), Apple introduced the DarkAqua appearance. Part of the implementation of the Dark Mode was to make some of the named NSColors have dynamic values. Apple calls these "semantic colors" because the name does not specify a specific color, but rather refers to the context in which the color should be used. -Tk now provides the following semantic colors as system colors: -systemTextColor, systemTextBackgroundColor, systemSelectedTextColor, -systemSelectedTextBackgroundColor, systemControlTextColor, -systemDisabledControlTextColor, systemLabelColor, systemLinkColor, and -systemControlAccentColor. All of these except the last three were -present in OSX 10.0 (and those three are simulated in systems where they -do not exist). The change in 10.14 was that the RGB color value of -these colors became dynamic, meaning that the color value can change -when the application appearance changes. In particular, when a user -selects Dark Mode in the system preferences these colors change -appearance. For example systemTextColor is dark in Aqua and light in -DarkAqua. One additional color, systemSelectedTabTextColor, does not -exist in macOS but is used by Tk to match the different colors used -for Notebook tab text in different OS versions. +In particular, when a user selects Dark Mode in the system preferences +these colors change appearance. For example systemTextColor is dark in +Aqua and light in DarkAqua. + +Tk now provides colors corresponding to all of the NSColors in Apple's System +ColorList. The convention for naming these colors is that the Tk name is +generated by capitalizing the macOS name and adding the prefix "system". The +System ColorList differs between releases of macOS and some colors, such as +systemLinkColor and systemControlAccentColor, are simulated on older systems +which did not provide them. The following colors are available on all +supported macOS releases, although newer systems will support additional +colors: systemControlAccentColor, systemControlTextColor, +systemDisabledControlTextColor, systemLabelColor, systemLinkColor, +systemPlaceholderTextColor, systemSelectedTextBackgroundColor, +systemSelectedTextColor, systemSeparatorColor, systemTextBackgroundColor, and +systemTextColor. One additional color, systemSelectedTabTextColor, does not +exist in macOS but is used by Tk to match the different colors used for +Notebook tab titles in different OS versions. The default background and foreground colors of most of the Tk widgets have been set to semantic colors, which means that the widgets will change appearance, and remain usable, when Dark Mode is selected in the system preferences. However, to get a close match to the native Dark Mode style it @@ -452,10 +456,24 @@ make -C tk${ver}/macosx \ TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin sudo make -C tk${ver}/macosx install \ TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3. + +- To build a Tcl.framework and Tk.framework for use as subframeworks in another +framework, use the install-embedded target and set SUBFRAMEWORK=1. Set the +DYLIB_INSTALL_DIR variable to the path which should be the install_name path of +the shared library and set the DESTDIR variable to the pathname of a staging +directory where the frameworks will be written. The Tcl framework must be +built first. +For example, running the commands: + make -C ../tcl8.6/macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \ + DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tcl.framework + make -C macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \ + DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tk.framework +will produce a Tcl.framework and a Tk.framework usable as subframeworks of +Some.framework. The frameworks will be found in /tmp/tcltk/Frameworks/ 5. Details regarding the macOS port of Tk. ------------------------------------------- 5.1 About the event loop @@ -660,19 +678,39 @@ constructed by TkScrollWindow contains only the difference between the source and destination rectangles for the scrolling. The embedded windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. -6.0 Virtual events on 10.14 -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -10.14 supports system appearance changes, and has added a "Dark Mode" -that casts all window frames and menus as black. Tk 8.6.9 has added two -virtual events, <> and <>, to allow you to update -your Tk app's appearance when the system appearance changes. Just bind -your appearance-updating code to these virtual events and you will see -it triggered when the system appearance toggles between dark and light. +6.0 Virtual events on macOS 10.14 and later +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The 10.14 release added support for system appearance changes, +including a "Dark Mode" that renders all window frames and menus in +dark colors. Tk 8.6.11 provides three virtual events <>, +<> and <>, to allow you to update your Tk +app's appearance when the system appearance changes. These events are +generated in [NSView effectiveAppearanceChanged], which is called by +the Apple window manager when the General Preferences is changed +either by switching between Light Mode and Dark Mode or by changing +the Accent Color or Highlight Color. + +The <> virtual event has a data string which can be +accessed with the %d substitution. The format of the data string is +that it consists of 6 words: + "Appearance XXXX Accent YYYY Highlight ZZZZ" +For example, the following code will print the current appearance +name, accent color and highlight color when the <> +virtual event fires: + +bind . <> { + array set data [split %d] + puts " Appearance: $data(Appearance)" + puts " Accent: $data(Accent)" + puts " Highlight: $data(Highlight)\n" +} + + 7.0 Mac Services ~~~~~~~~~~~~~~~~~~~~~~~~~~~ With 8.6.10, Tk supports the Mac's NSServices API, documented at Index: macosx/Tk-Common.xcconfig ================================================================== --- macosx/Tk-Common.xcconfig +++ macosx/Tk-Common.xcconfig @@ -21,11 +21,11 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES GCC_NO_COMMON_BLOCKS = YES GCC_DYNAMIC_NO_PIC = YES GCC_VERSION = 4.2 GCC = gcc-$(GCC_VERSION) -WARNING_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-value -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS) +WARNING_CFLAGS = -Wall -Wextra -Wshadow -Wundef -Wwrite-strings -Wpointer-arith -Winit-self -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS) REZ_RESOURCE_MAP_READ_ONLY = YES APPLICATION_INSTALL_PATH = /Applications/Utilities BINDIR = $(PREFIX)/bin CFLAGS = $(CFLAGS) CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS) Index: macosx/Tk.xcode/project.pbxproj ================================================================== --- macosx/Tk.xcode/project.pbxproj +++ macosx/Tk.xcode/project.pbxproj @@ -1406,11 +1406,11 @@ F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtCommand.3; sourceTree = ""; }; F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtFileHdlr.3; sourceTree = ""; }; F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = ""; }; F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = ""; }; F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = ""; }; - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = ""; }; + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = ""; }; F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = ""; }; F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = ""; }; F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = ""; }; F96D3E2608F272A5004A47F5 /* DetachPids.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DetachPids.3; sourceTree = ""; }; F96D3E2708F272A5004A47F5 /* dict.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dict.n; sourceTree = ""; }; @@ -3071,11 +3071,11 @@ F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */, F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */, F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */, F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */, F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */, - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */, + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */, F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */, F96D3E2408F272A5004A47F5 /* CrtTrace.3 */, F96D3E2508F272A5004A47F5 /* dde.n */, F93599D30DF1F8F500E04F67 /* define.n */, F96D3E2608F272A5004A47F5 /* DetachPids.3 */, Index: macosx/Tk.xcodeproj/project.pbxproj ================================================================== --- macosx/Tk.xcodeproj/project.pbxproj +++ macosx/Tk.xcodeproj/project.pbxproj @@ -1406,11 +1406,11 @@ F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtCommand.3; sourceTree = ""; }; F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtFileHdlr.3; sourceTree = ""; }; F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = ""; }; F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = ""; }; F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = ""; }; - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = ""; }; + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = ""; }; F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = ""; }; F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = ""; }; F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = ""; }; F96D3E2608F272A5004A47F5 /* DetachPids.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DetachPids.3; sourceTree = ""; }; F96D3E2708F272A5004A47F5 /* dict.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dict.n; sourceTree = ""; }; @@ -3070,11 +3070,11 @@ F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */, F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */, F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */, F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */, F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */, - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */, + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */, F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */, F96D3E2408F272A5004A47F5 /* CrtTrace.3 */, F96D3E2508F272A5004A47F5 /* dde.n */, F93599D30DF1F8F500E04F67 /* define.n */, F96D3E2608F272A5004A47F5 /* DetachPids.3 */, Index: macosx/tkMacOSX.h ================================================================== --- macosx/tkMacOSX.h +++ macosx/tkMacOSX.h @@ -24,11 +24,11 @@ */ typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window); typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window); typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window); -typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, Region rgn); +typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, void *rgn); typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner); #include "tkPlatDecls.h" #endif /* _TKMAC */ Index: macosx/tkMacOSXBitmap.c ================================================================== --- macosx/tkMacOSXBitmap.c +++ macosx/tkMacOSXBitmap.c @@ -1,13 +1,13 @@ /* * tkMacOSXBitmap.c -- * * This file handles the implementation of native bitmaps. * - * Copyright (c) 1996-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1996-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -134,19 +134,17 @@ { TkMacOSXDrawingContext dc; Pixmap pixmap; pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0); - if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { + if (TkMacOSXSetupDrawingContext(pixmap, NULL, &dc)) { if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = size.height}; CGContextConcatCTM(dc.context, t); [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext - graphicsContextWithGraphicsPort:dc.context - flipped:NO]]; + [NSGraphicsContext setCurrentContext:GET_NSCONTEXT(dc.context, NO)]; [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; [NSGraphicsContext restoreGraphicsState]; } TkMacOSXRestoreDrawingContext(&dc); @@ -178,11 +176,11 @@ { NSString *iconUTI = OSTYPE_TO_UTI(PTR2UINT(source)); NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFileType: iconUTI]; CGSize size = CGSizeMake(builtInIconSize, builtInIconSize); - Pixmap pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size)); + Pixmap pixmap = PixmapFromImage(display, iconImage, size); return pixmap; } /* @@ -341,20 +339,19 @@ *---------------------------------------------------------------------- */ int TkMacOSXIconBitmapObjCmd( - ClientData dummy, /* Unused. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_HashEntry *hPtr; int i = 1, len, isNew, result = TCL_ERROR; const char *name, *value; IconBitmap ib, *iconBitmap; - (void)dummy; if (objc != 6) { Tcl_WrongNumArgs(interp, 1, objv, "name width height " "-file|-fileType|-osType|-systemType|-namedImage|-imageFile " "value"); Index: macosx/tkMacOSXButton.c ================================================================== --- macosx/tkMacOSXButton.c +++ macosx/tkMacOSXButton.c @@ -2,16 +2,16 @@ * tkMacOSXButton.c -- * * This file implements the Macintosh specific portion of the button * widgets. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. - * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2006-2007 Daniel A. Steffen - * Copyright 2007 Revar Desmera. - * Copyright 2015 Kevin Walzer/WordTech Communications LLC. - * Copyright 2015 Marc Culler. + * Copyright © 1996-1997 Sun Microsystems, Inc. + * Copyright © 2001 Apple Computer, Inc. + * Copyright © 2006-2007 Daniel A. Steffen + * Copyright © 2007 Revar Desmera. + * Copyright © 2015 Kevin Walzer/WordTech Communications LLC. + * Copyright © 2015 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ @@ -192,17 +192,10 @@ if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); - /* - * Set up clipping region. Make sure the we are using the port - * for this button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); - if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; } else { macButtonPtr->useTkText = 1; } @@ -724,11 +717,11 @@ */ static void TkMacOSXDrawButton( MacButton *mbPtr, /* Mac button. */ - GC gc, /* The GC we are drawing into - needed for + TCL_UNUSED(GC), /* The GC we are drawing into - needed for * the bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed * for the bevel button */ { TkButton *butPtr = (TkButton *) mbPtr; @@ -735,11 +728,10 @@ TkWindow *winPtr = (TkWindow *) butPtr->tkwin; HIRect cntrRect; TkMacOSXDrawingContext dc; DrawParams *dpPtr = &mbPtr->drawParams; int useNewerHITools = 1; - (void)gc; TkMacOSXComputeButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff, Tk_Width(butPtr->tkwin), Tk_Height(butPtr->tkwin)); @@ -750,11 +742,11 @@ HIRect contHIRec; static HIThemeButtonDrawInfo hiinfo; ButtonBackgroundDrawCB(&cntrRect, mbPtr, 32, true); - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } hiinfo.version = 0; hiinfo.state = mbPtr->drawinfo.state; @@ -783,11 +775,11 @@ TkMacOSXRestoreDrawingContext(&dc); ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo, (MacButton *) mbPtr, 32, true); } else { - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } TkMacOSXRestoreDrawingContext(&dc); } @@ -811,23 +803,20 @@ *-------------------------------------------------------------- */ static void ButtonBackgroundDrawCB( - const HIRect *btnbounds, + TCL_UNUSED(const HIRect *), MacButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { MacButton *mbPtr = (MacButton *) ptr; TkButton *butPtr = (TkButton *) mbPtr; Tk_Window tkwin = butPtr->tkwin; Pixmap pixmap; int usehlborder = 0; - (void)btnbounds; - (void)depth; - (void)isColorDev; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); @@ -866,24 +855,19 @@ * *-------------------------------------------------------------- */ static void ButtonContentDrawCB ( - const HIRect * btnbounds, - ThemeButtonKind kind, - const HIThemeButtonDrawInfo *drawinfo, + TCL_UNUSED(const HIRect *), + TCL_UNUSED(ThemeButtonKind), + TCL_UNUSED(const HIThemeButtonDrawInfo *), MacButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { TkButton *butPtr = (TkButton *) ptr; Tk_Window tkwin = butPtr->tkwin; - (void)btnbounds; - (void)kind; - (void)drawinfo; - (void)depth; - (void)isColorDev; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } Index: macosx/tkMacOSXClipboard.c ================================================================== --- macosx/tkMacOSXClipboard.c +++ macosx/tkMacOSXClipboard.c @@ -1,13 +1,13 @@ /* * tkMacOSXClipboard.c -- * * This file manages the clipboard for the Tk toolkit. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -175,11 +175,11 @@ int XSetSelectionOwner( Display *display, /* X Display. */ Atom selection, /* What selection to own. */ Window owner, /* Window to be the owner. */ - Time time) /* The current time? */ + TCL_UNUSED(Time)) /* The current time? */ { TkDisplay *dispPtr = TkGetDisplayList(); (void)time; if (dispPtr && selection == dispPtr->clipboardAtom) { @@ -236,17 +236,15 @@ *---------------------------------------------------------------------- */ void TkSelUpdateClipboard( - TkWindow *winPtr, /* Window associated with clipboard. */ - TkClipboardTarget *targetPtr) + TCL_UNUSED(TkWindow *), /* Window associated with clipboard. */ + TCL_UNUSED(TkClipboardTarget *)) /* Info about the content. */ { NSPasteboard *pb = [NSPasteboard generalPasteboard]; - (void)winPtr; - (void)targetPtr; changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; } @@ -295,13 +293,12 @@ *---------------------------------------------------------------------- */ void TkSelPropProc( - XEvent *eventPtr) /* X PropertyChange event. */ + TCL_UNUSED(XEvent *)) /* X PropertyChange event. */ { - (void)eventPtr; } /* * Local Variables: * mode: objc Index: macosx/tkMacOSXColor.c ================================================================== --- macosx/tkMacOSXColor.c +++ macosx/tkMacOSXColor.c @@ -1,303 +1,291 @@ /* - * tkMacOSXColor.c -- + * TkMacOSXColor.c -- * * This file maintains a database of color values for the Tk * toolkit, in order to avoid round-trips to the server to * map color names to pixel values. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1996 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkColor.h" - -/* - * The colorType specifies how the color value should be interpreted. For the - * unique rgbColor entry, the RGB values are generated from the pixel value of - * an XColor. The ttkBackground and semantic types are dynamic, meaning - * that they change when dark mode is enabled on OSX 10.13 and later. - */ - -enum colorType { - clearColor, /* There should be only one of these. */ - rgbColor, /* There should be only one of these. */ - appearance, /* There should be only one of these. */ - HIBrush, /* The value is a HITheme brush color table index. */ - HIText, /* The value is a HITheme text color table index. */ - HIBackground, /* The value is a HITheme background color table index. */ - ttkBackground, /* The value can be used as a parameter.*/ - semantic, /* The value can be used as a parameter.*/ -}; - -/* - - */ - -struct SystemColorMapEntry { - const char *name; - enum colorType type; - long value; -}; /* unsigned char pixelCode; */ - -/* - * Array of system color definitions: the array index is required to equal the - * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept - * in sync with the public pixel code values in tkMacOSXPort.h ! - */ - -#define MIN_PIXELCODE 30 -static const struct SystemColorMapEntry systemColorMap[] = { - { "Transparent", clearColor, 0 }, /* 30: TRANSPARENT_PIXEL */ - { "Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 31 */ - { "HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 32 */ - { "HighlightText", HIBrush, kThemeBrushBlack }, /* 33 */ - { "HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 34 */ - { "ButtonText", HIText, kThemeTextColorPushButtonActive }, /* 35 */ - { "PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 36 */ - { "ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, /* 37 */ - { "SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 38 */ - { "ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, /* 39 */ - { "AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 40 */ - { "WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, /* 41 */ - { "SheetBackground", HIBrush, kThemeBrushSheetBackground }, /* 42 */ - { "MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 43 */ - { "Black", HIBrush, kThemeBrushBlack }, /* 44 */ - { "MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, /* 45 */ - { "White", HIBrush, kThemeBrushWhite }, /* 46 */ - { "Menu", HIBrush, kThemeBrushMenuBackground }, /* 47 */ - { "DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, /* 48 */ - { "MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, /* 49 */ - { "DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, /* 50 */ - { "MenuText", HIText, kThemeTextColorMenuItemActive }, /* 51 */ - { "AppearanceColor", appearance, 0 }, /* 52: APPEARANCE_PIXEL */ - { "AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, /* 53 */ - { "AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, /* 54 */ - { "ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, /* 55 */ - { "ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, /* 56 */ - { "UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, /* 57 */ - { "UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, /* 58 */ - { "ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, /* 59 */ - { "ListViewBackground", HIBrush, kThemeBrushListViewBackground }, /* 60 */ - { "IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, /* 61 */ - { "ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, /* 62 */ - { "ChasingArrows", HIBrush, kThemeBrushChasingArrows }, /* 63 */ - { "DragHilite", HIBrush, kThemeBrushDragHilite }, /* 64 */ - { "DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, /* 65 */ - { "FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, /* 66 */ - { "ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, /* 67 */ - { "ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, /* 68 */ - { "FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, /* 69 */ - { "PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, /* 70 */ - { "PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, /* 71 */ - { "PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, /* 72 */ - { "AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, /* 73 */ - { "IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, /* 74 */ - { "StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, /* 75 */ - { "ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, /* 76 */ - { "ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, /* 77 */ - { "ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, /* 78 */ - { "ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, /* 79 */ - { "ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, /* 80 */ - { "ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, /* 81 */ - { "ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, /* 82 */ - { "ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, /* 83 */ - { "ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, /* 84 */ - { "ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, /* 85 */ - { "ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, /* 86 */ - { "ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, /* 87 */ - { "ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, /* 88 */ - { "ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, /* 89 */ - { "ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, /* 90 */ - { "ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, /* 91 */ - { "ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, /* 92 */ - { "ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, /* 93 */ - { "BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, /* 94 */ - { "BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, /* 95 */ - { "BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, /* 96 */ - { "BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, /* 97 */ - { "NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, /* 98 */ - { "MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, /* 99 */ - { "SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, /* 100 */ - { "DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, /* 101 */ - { "ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, /* 102 */ - { "SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, /* 103 */ - { "MenuBackground", HIBrush, kThemeBrushMenuBackground }, /* 104 */ - { "Pixel", rgbColor, 0 }, /* 105: PIXEL_MAGIC */ - { "MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 106 */ - { "ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, /* 107 */ - { "ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, /* 108 */ - { "ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, /* 109 */ - { "BlackText", HIText, kThemeTextColorBlack }, /* 110 */ - { "DialogActiveText", HIText, kThemeTextColorDialogActive }, /* 111 */ - { "DialogInactiveText", HIText, kThemeTextColorDialogInactive }, /* 112 */ - { "AlertActiveText", HIText, kThemeTextColorAlertActive }, /* 113 */ - { "AlertInactiveText", HIText, kThemeTextColorAlertInactive }, /* 114 */ - { "ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, /* 115 */ - { "ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, /* 116 */ - { "WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, /* 117 */ - { "WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, /* 118 */ - { "PlacardActiveText", HIText, kThemeTextColorPlacardActive }, /* 119 */ - { "PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, /* 120 */ - { "PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, /* 121 */ - { "PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, /* 122 */ - { "PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, /* 123 */ - { "PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, /* 124 */ - { "BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, /* 125 */ - { "BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, /* 126 */ - { "BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, /* 127 */ - { "PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, /* 128 */ - { "PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, /* 129 */ - { "PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, /* 130 */ - { "IconLabelText", HIText, kThemeTextColorIconLabel }, /* 131 */ - { "ListViewText", HIText, kThemeTextColorListView }, /* 132 */ - { "DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, /* 133 */ - { "DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, /* 134 */ - { "MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, /* 135 */ - { "MovableModalWindowTitleInactiveText",HIText, kThemeTextColorMovableModalWindowTitleInactive }, /* 136 */ - { "UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, /* 137 */ - { "UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, /* 138 */ - { "PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, /* 139 */ - { "PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, /* 140 */ - { "RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, /* 141 */ - { "RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, /* 142 */ - { "RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, /* 143 */ - { "MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, /* 144 */ - { "MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, /* 145 */ - { "MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, /* 146 */ - { "PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, /* 147 */ - { "PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, /* 148 */ - { "TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, /* 149 */ - { "TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, /* 150 */ - { "TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, /* 151 */ - { "TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, /* 152 */ - { "TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, /* 153 */ - { "IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, /* 154 */ - { "BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, /* 155 */ - { "BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, /* 156 */ - { "NotificationText", HIText, kThemeTextColorNotification }, /* 157 */ - { "SystemDetailText", HIText, kThemeTextColorSystemDetail }, /* 158 */ - { "WhiteText", HIText, kThemeTextColorWhite }, /* 159 */ - { "TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, /* 160 */ - { "PlacardBackground", HIBackground, kThemeBackgroundPlacard }, /* 161 */ - { "WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, /* 162 */ - { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */ - { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */ - { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */ - - /* - * Colors based on "semantic" NSColors. - */ - - { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */ - { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */ - { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */ - { "WindowBackgroundColor3", ttkBackground, 3 }, /* 169 */ - { "WindowBackgroundColor4", ttkBackground, 4 }, /* 170 */ - { "WindowBackgroundColor5", ttkBackground, 5 }, /* 171 */ - { "WindowBackgroundColor6", ttkBackground, 6 }, /* 172 */ - { "WindowBackgroundColor7", ttkBackground, 7 }, /* 173 */ - { "TextColor", semantic, 0 }, /* 174 */ - { "SelectedTextColor", semantic, 1 }, /* 175 */ - { "LabelColor", semantic, 2 }, /* 176 */ - { "ControlTextColor", semantic, 3 }, /* 177 */ - { "DisabledControlTextColor", semantic, 4 }, /* 178 */ - { "SelectedTabTextColor", semantic, 5 }, /* 179 */ - { "TextBackgroundColor", semantic, 6 }, /* 180 */ - { "SelectedTextBackgroundColor", semantic, 7 }, /* 181 */ - { "ControlAccentColor", semantic, 8 }, /* 182 */ - /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ - { "SecondaryLabelColor", ttkBackground, 14 }, /* 183 */ - { "LinkColor", semantic, 9 }, /* 184 */ - { NULL, 0, 0 } -}; -#define FIRST_SEMANTIC_COLOR 166 -#define MAX_PIXELCODE 184 - -/* - *---------------------------------------------------------------------- - * - * GetEntryFromPixelCode -- - * - * Extract a SystemColorMapEntry from the table. - * - * Results: - * Returns false if the code is out of bounds. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static bool -GetEntryFromPixelCode( - unsigned char code, - struct SystemColorMapEntry *entry) -{ - if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) { - *entry = systemColorMap[code - MIN_PIXELCODE]; - return true; - } else { - return false; - } -} - -/* - *---------------------------------------------------------------------- - * - * SetCGColorComponents -- - * - * Set the components of a CGColorRef from an XColor pixel value and a - * system color map entry. The pixel value is only used in the case where - * the color is of type rgbColor. In that case the normalized XColor RGB - * values are copied into the CGColorRef. - * - * Results: - * OSStatus - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static NSColorSpace* sRGB = NULL; -static CGFloat windowBackground[4] = - {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; - -static OSStatus -SetCGColorComponents( - struct SystemColorMapEntry entry, - unsigned long pixel, - CGColorRef *c) -{ - OSStatus err = noErr; - NSColor *bgColor, *color = nil; - CGFloat rgba[4] = {0, 0, 0, 1}; +#include "tkMacOSXColor.h" + +static Tcl_HashTable systemColors; +static int numSystemColors; +static int rgbColorIndex; +static int controlAccentIndex; +static int selectedTabTextIndex; +static Bool useFakeAccentColor = NO; +static SystemColorDatum **systemColorIndex; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 +static NSAppearance *lightAqua = nil; +static NSAppearance *darkAqua = nil; +#endif +static NSColorSpace* sRGB = NULL; +static const CGFloat WINDOWBACKGROUND[4] = + {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; + +void initColorTable() +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + Tcl_InitHashTable(&systemColors, TCL_STRING_KEYS); + SystemColorDatum *entry, *oldEntry; + Tcl_HashSearch search; + Tcl_HashEntry *hPtr; + int newPtr, index = 0; + NSColorList *systemColorList = [NSColorList colorListNamed:@"System"]; + NSString *key; + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + if (@available(macOS 10.14, *)) { + darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; + } +#endif + + /* + * Build a hash table for looking up a color by its name. + * First add all of the static entries from tkMacOSXColor.h + */ + + for (entry = systemColorData; entry->name != NULL; entry++) { + hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); + if (entry->type == semantic) { + NSString *colorName = [[NSString alloc] + initWithCString:entry->macName + encoding:NSUTF8StringEncoding]; + SEL colorSelector = NSSelectorFromString(colorName); + if (![NSColor respondsToSelector:colorSelector]) { + if ([colorName isEqualToString:@"controlAccentColor"]) { + useFakeAccentColor = YES; + } else if (![colorName isEqualToString:@"selectedTabTextColor"]) { + /* Uncomment to print all unsupported colors: */ + /* printf("Unsupported color %s\n", colorName.UTF8String); */ + continue; + } + } + entry->selector = [colorName retain]; + } + if (newPtr == 0) { + oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + entry->index = oldEntry->index; + [oldEntry->selector release]; + } else { + entry->index = index++; + } + Tcl_SetHashValue(hPtr, entry); + } + + /* + * Add all of the colors in the System ColorList. + */ + + for (key in [systemColorList allKeys]) { + int length = [key lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + char *name; + entry = (SystemColorDatum *)ckalloc(sizeof(SystemColorDatum)); + bzero(entry, sizeof(SystemColorDatum)); + name = (char *)ckalloc(length + 1); + strcpy(name, key.UTF8String); + name[0] = toupper(name[0]); + if (!strcmp(name, "WindowBackgroundColor")) { + + /* + * Avoid black windows on old systems. + */ + + continue; + } + entry->type=semantic; + entry->name = name; + entry->selector = [key retain]; + hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); + if (newPtr == 0) { + oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + entry->index = oldEntry->index; + [oldEntry->selector release]; + } else { + entry->index = index++; + } + Tcl_SetHashValue(hPtr, entry); + } + + /* + * Build an array for looking up a color by its index. + */ + + numSystemColors = index; + systemColorIndex = (SystemColorDatum **)ckalloc(numSystemColors * sizeof(SystemColorDatum *)); + for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL; + hPtr = Tcl_NextHashEntry(&search)) { + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + if (entry == NULL) { + Tcl_Panic("Unsupported semantic color with no supported backup!"); + } + systemColorIndex[entry->index] = entry; + } + + /* + * Remember the indexes of some special entries. + */ + + hPtr = Tcl_FindHashEntry(&systemColors, "Pixel"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + rgbColorIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + controlAccentIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + selectedTabTextIndex = entry->index; + [pool drain]; +} + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXRGBPixel -- + * + * Return an unsigned long value suitable for use in the pixel + * field of an XColor with the specified red, green and blue + * intensities. The inputs are cast as unsigned longs but are + * expected to have values representable by an unsigned char. + * + * This is called in the TkpGetPixel macro, used in xcolor.c, + * and in ImageGetPixel. + * + * Results: + * An unsigned long that can be used as the pixel field of an XColor. + * + * Side effects: + * None. + *---------------------------------------------------------------------- + */ +MODULE_SCOPE +unsigned long +TkMacOSXRGBPixel( + unsigned long red, + unsigned long green, + unsigned long blue) +{ + MacPixel p = {0}; + p.pixel.colortype = rgbColor; + p.pixel.value = ((red & 0xff) << 16) | + ((green & 0xff) << 8) | + (blue & 0xff); + return p.ulong; +} + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXClearPixel -- + * + * Return the unsigned long value that appears in the pixel + * field of the XColor for systemTransparentColor. + * + * This is used in tkMacOSXImage.c. + * + * Results: + * The unsigned long that appears in the pixel field of the XColor + * for systemTransparentPixel. + * + * Side effects: + * None. + *---------------------------------------------------------------------- + */ +MODULE_SCOPE +unsigned long TkMacOSXClearPixel( + void) +{ + MacPixel p = {0}; + p.pixel.value = 0; + p.pixel.colortype = clearColor; + return p.ulong; +} + + +/* + *---------------------------------------------------------------------- + * + * GetEntryFromPixel -- + * + * Look up a SystemColorDatum which describes the XColor with + * the specified value as its pixel field. + * + * Results: + * A pointer to a SystemColorDatum, or NULL if the pixel value is + * invalid. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +SystemColorDatum* +GetEntryFromPixel( + unsigned long pixel) +{ + MacPixel p = {0}; + int index = rgbColorIndex; + + p.ulong = pixel; + if (p.pixel.colortype != rgbColor) { + index = p.pixel.value; + } + if (index < numSystemColors) { + return systemColorIndex[index]; + } else { + return NULL; + } +} + + +/* + *---------------------------------------------------------------------- + * + * GetRGBA -- + * + * Given a SystemColorDatum and a pointer to an array of 4 CGFloats, store + * the associated RGBA color values in the array. In the case of the + * RGBColor datum, the unsigned long pixel value containing the RGB values + * must also be provided as the pixel parameter. Otherwise the pixel + * parameter is ignored. + * + * Results: + * None + * + * Side effects: + * The array rgba is filled in. + * + *---------------------------------------------------------------------- + */ + +static void +GetRGBA( + SystemColorDatum *entry, + unsigned long pixel, + CGFloat *rgba) +{ + NSColor *bgColor, *color = nil; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } - /* - * This function is called before our autorelease pool is set up, - * so it needs its own pool. - */ - - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - switch (entry.type) { - case HIBrush: - err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c); - return err; + switch (entry->type) { case rgbColor: rgba[0] = ((pixel >> 16) & 0xff) / 255.0; rgba[1] = ((pixel >> 8) & 0xff) / 255.0; rgba[2] = ((pixel ) & 0xff) / 255.0; break; @@ -307,117 +295,97 @@ * Prior to OSX 10.14, getComponents returns black when applied to * windowBackGroundColor. */ if ([NSApp macOSVersion] < 101400) { - for (int i=0; i<3; i++) { - rgba[i] = windowBackground[i]; + for (int i = 0; i < 3; i++) { + rgba[i] = WINDOWBACKGROUND[i]; } } else { bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB]; [bgColor getComponents: rgba]; } if (rgba[0] + rgba[1] + rgba[2] < 1.5) { for (int i=0; i<3; i++) { - rgba[i] += entry.value*8.0 / 255.0; - } - } else { - for (int i=0; i<3; i++) { - rgba[i] -= entry.value*8.0 / 255.0; - } - } - break; - case semantic: - switch (entry.value) { - case 0: - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - break; - case 1: - color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB]; - break; - case 2: - if ([NSApp macOSVersion] > 100900) { -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - } - break; - case 3: - color = [[NSColor controlTextColor] colorUsingColorSpace:sRGB]; - break; - case 4: - color = [[NSColor disabledControlTextColor] - colorUsingColorSpace:sRGB]; - break; - case 5: - if ([NSApp macOSVersion] > 100600) { - color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; - } else { - color = [[NSColor blackColor] colorUsingColorSpace:sRGB]; - } - break; - case 6: - color = [[NSColor textBackgroundColor] colorUsingColorSpace:sRGB]; - break; - case 7: - color = [[NSColor selectedTextBackgroundColor] - colorUsingColorSpace:sRGB]; - break; - case 8: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - if (@available(macOS 14, *)) { - color = [[NSColor controlAccentColor] colorUsingColorSpace:sRGB]; -#else - if(false) { -#endif - } else { - color = [[NSColor - colorForControlTint:[NSColor currentControlTint]] - colorUsingColorSpace: sRGB]; - } - break; - case 9: - if ([NSApp macOSVersion] >= 101000) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - color = [[NSColor linkColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor blueColor] colorUsingColorSpace:sRGB]; - } - break; - default: - if ([NSApp macOSVersion] >= 101000) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - } - break; - } - [color getComponents: rgba]; - break; - case clearColor: - rgba[3] = 0.0; - break; - - /* - * There are no HITheme functions which convert Text or background colors - * to CGColors. (GetThemeTextColor has been removed, and it was never - * possible with backgrounds.) If we get one of these we return black. - */ - - case HIText: - case HIBackground: - default: - break; - } - *c = CGColorCreate(sRGB.CGColorSpace, rgba); - [pool drain]; - return err; + rgba[i] += entry->value*8.0 / 255.0; + } + } else { + for (int i=0; i<3; i++) { + rgba[i] -= entry->value*8.0 / 255.0; + } + } + break; + case clearColor: + rgba[0] = rgba[1] = rgba[2] = 1.0; + rgba[3] = 0; + break; + case semantic: + if (entry->index == controlAccentIndex && useFakeAccentColor) { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + color = [[NSColor colorForControlTint: [NSColor currentControlTint]] + colorUsingColorSpace:sRGB]; +#endif + } else if (entry->index == selectedTabTextIndex) { + int OSVersion = [NSApp macOSVersion]; + if (OSVersion > 100600 && OSVersion < 110000) { + color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; + } else { + color = [[NSColor textColor] colorUsingColorSpace:sRGB]; + } + } else { + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + } + [color getComponents: rgba]; + break; + default: + break; + } +} + +/* + *---------------------------------------------------------------------- + * + * SetCGColorComponents -- + * + * Set the components of a CGColorRef from an XColor pixel value and a + * SystemColorDatum. The pixel value is only used in the case where + * the color is of type rgbColor. In that case the normalized XColor RGB + * values are copied into the CGColorRef. Otherwise the components are + * computed from the SystemColorDatum. + * + * Results: + * True if the function succeeds, false otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Bool +SetCGColorComponents( + SystemColorDatum *entry, + unsigned long pixel, + CGColorRef *c) +{ + CGFloat rgba[4] = {0, 0, 0, 1}; + + /* + * This function is called before our autorelease pool is set up, + * so it needs its own pool. + */ + + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + if (entry->type == HIBrush) { + OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); + return err == noErr; + } + GetRGBA(entry, pixel, rgba); + *c = CGColorCreate(sRGB.CGColorSpace, rgba); + [pool drain]; + return true; } /* *---------------------------------------------------------------------- * @@ -435,227 +403,106 @@ */ MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin) { - int result = false; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua"; - - if ([NSApp macOSVersion] >= 101400) { + if (@available(macOS 10.14, *)) { TkWindow *winPtr = (TkWindow*) tkwin; + NSAppearanceName name; NSView *view = nil; if (winPtr && winPtr->privatePtr) { - view = TkMacOSXDrawableView(winPtr->privatePtr); + view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr); } if (view) { - result = [view.effectiveAppearance.name isEqualToString:darkAqua]; - } else { - result = [[NSAppearance currentAppearance].name - isEqualToString:darkAqua]; - } - } -#endif - - return result; + name = [[view effectiveAppearance] name]; + } else { + name = [[NSAppearance currentAppearance] name]; + } + return (name == NSAppearanceNameDarkAqua); + } +#else + (void) tkwin; +#endif + return false; } /* *---------------------------------------------------------------------- * * TkSetMacColor -- * - * Sets the components of a CGColorRef from an XColor pixel value. - * The high order byte of the pixel value is used as an index into - * the system color table, and then SetCGColorComponents is called - * with the table entry and the pixel value. + * Sets the components of a CGColorRef from an XColor pixel value. The + * pixel value is used to look up the color in the system color table, and + * then SetCGColorComponents is called with the table entry and the pixel + * value. The parameter macColor should be a pointer to a CGColorRef. * * Results: - * Returns false if the high order byte is not a valid index, true - * otherwise. + * Returns false if the color is not found, true otherwise. * * Side effects: - * The variable macColor is set to a new CGColorRef, the caller is - * responsible for releasing it! + * The CGColorRef referenced by the variable macColor may be modified. * *---------------------------------------------------------------------- */ int TkSetMacColor( - unsigned long pixel, /* Pixel value to convert. */ - void *macColor) /* CGColorRef to modify. */ + unsigned long pixel, /* Pixel value to convert. */ + void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; - OSStatus err = -1; - struct SystemColorMapEntry entry; - - if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) { - err = ChkErr(SetCGColorComponents, entry, pixel, color); - } - return (err == noErr); -} - -/* - *---------------------------------------------------------------------- - * - * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor -- - * - * Maintain a per-GC cache of previously converted CGColorRefs - * - * Results: - * None resp. retained CGColorRef for CopyCachedColor() - * - * Side effects:M - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkpInitGCCache( - GC gc) -{ - bzero(TkpGetGCCache(gc), sizeof(TkpGCCache)); -} - -void -TkpFreeGCCache( - GC gc) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } -} - -static CGColorRef -CopyCachedColor( - GC gc, - unsigned long pixel) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - CGColorRef cgColor = NULL; - - if (gcCache) { - if (gcCache->cachedForeground == pixel) { - cgColor = gcCache->cachedForegroundColor; - } else if (gcCache->cachedBackground == pixel) { - cgColor = gcCache->cachedBackgroundColor; - } - if (cgColor) { - CFRetain(cgColor); - } - } - return cgColor; -} - -static void -SetCachedColor( - GC gc, - unsigned long pixel, - CGColorRef cgColor) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache && cgColor) { - if (gc->foreground == pixel) { - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedForeground = pixel; - } else if (gc->background == pixel) { - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } - gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedBackground = pixel; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXCreateCGColor -- - * - * Creates a CGColorRef from a X style pixel value. - * - * Results: - * Returns NULL if not a real pixel, CGColorRef otherwise. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -CGColorRef -TkMacOSXCreateCGColor( - GC gc, - unsigned long pixel) /* Pixel value to convert. */ -{ - CGColorRef cgColor = CopyCachedColor(gc, pixel); - - if (!cgColor && TkSetMacColor(pixel, &cgColor)) { - SetCachedColor(gc, pixel, cgColor); - } - return cgColor; + SystemColorDatum *entry = GetEntryFromPixel(pixel); + + if (entry) { + return SetCGColorComponents(entry, pixel, color); + } else { + return false; + } } /* *---------------------------------------------------------------------- * * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. + * The return value is nil if the pixel value is invalid. * * Results: - * Returns nil if not a real pixel, NSColor* otherwise. + * A possibly nil pointer to an NSColor. * * Side effects: * None * *---------------------------------------------------------------------- */ NSColor* TkMacOSXGetNSColor( - GC gc, + TCL_UNUSED(GC), unsigned long pixel) /* Pixel value to convert. */ { - CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel); + CGColorRef cgColor; NSColor *nsColor = nil; - if (cgColor) { - NSColorSpace *colorSpace = [[NSColorSpace alloc] - initWithCGColorSpace:CGColorGetColorSpace(cgColor)]; - - nsColor = [NSColor colorWithColorSpace:colorSpace - components:CGColorGetComponents(cgColor) - count:CGColorGetNumberOfComponents(cgColor)]; - [colorSpace release]; - CFRelease(cgColor); - } + TkSetMacColor(pixel, &cgColor); + nsColor = [NSColor colorWithColorSpace:sRGB + components:CGColorGetComponents(cgColor) + count:CGColorGetNumberOfComponents(cgColor)]; return nsColor; } /* *---------------------------------------------------------------------- * * TkMacOSXSetColorInContext -- * - * Sets fill and stroke color in the given CG context from an X - * pixel value, or if the pixel code indicates a system color, - * sets the corresponding brush, textColor or background via - * HITheme APIs if available or Appearance mgr APIs. + * Sets the fill and stroke colors in the given CGContext to the CGColor + * which corresponds to the XColor having the specified value for its pixel + * field. * * Results: * None. * * Side effects: @@ -664,49 +511,30 @@ *---------------------------------------------------------------------- */ void TkMacOSXSetColorInContext( - GC gc, + TCL_UNUSED(GC), unsigned long pixel, CGContextRef context) { OSStatus err = noErr; CGColorRef cgColor = nil; - struct SystemColorMapEntry entry; - CGRect rect; - int code = (pixel >> 24) & 0xff; - HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; - - if (code < FIRST_SEMANTIC_COLOR) { - cgColor = CopyCachedColor(gc, pixel); - } - if (!cgColor && GetEntryFromPixelCode(code, &entry)) { - switch (entry.type) { - case HIBrush: - err = ChkErr(HIThemeSetFill, entry.value, NULL, context, - kHIThemeOrientationNormal); - if (err == noErr) { - err = ChkErr(HIThemeSetStroke, entry.value, NULL, context, - kHIThemeOrientationNormal); - } - break; - case HIText: - err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context, - kHIThemeOrientationNormal); - break; - case HIBackground: - info.kind = entry.value; - rect = CGContextGetClipBoundingBox(context); - err = ChkErr(HIThemeApplyBackground, &rect, &info, - context, kHIThemeOrientationNormal); - break; - default: - err = ChkErr(SetCGColorComponents, entry, pixel, &cgColor); - if (err == noErr) { - SetCachedColor(gc, pixel, cgColor); - } + SystemColorDatum *entry = GetEntryFromPixel(pixel); + + if (entry) { + switch (entry->type) { + case HIBrush: + err = ChkErr(HIThemeSetFill, entry->value, NULL, context, + kHIThemeOrientationNormal); + if (err == noErr) { + err = ChkErr(HIThemeSetStroke, entry->value, NULL, context, + kHIThemeOrientationNormal); + } + break; + default: + SetCGColorComponents(entry, pixel, &cgColor); break; } } if (cgColor) { CGContextSetFillColorWithColor(context, cgColor); @@ -721,19 +549,24 @@ /* *---------------------------------------------------------------------- * * TkpGetColor -- * - * Allocate a new TkColor for the color with the given name. + * Create a new TkColor for the color with the given name, for use in the + * specified window. The colormap field is set to lightColormap if the + * window has a LightAqua appearance, or darkColormap if the window has a + * DarkAqua appearance. TkColors with different colormaps are managed + * separately in the per-display table of TkColors maintained by Tk. + * + * This function is called by Tk_GetColor. * * Results: * Returns a newly allocated TkColor, or NULL on failure. * * Side effects: - * May invalidate the colormap cache associated with tkwin upon - * allocating a new colormap entry. Allocates a new TkColor - * structure. + * + * Allocates memory for the TkColor structure. * *---------------------------------------------------------------------- */ TkColor * @@ -740,35 +573,72 @@ TkpGetColor( Tk_Window tkwin, /* Window in which color will be used. */ Tk_Uid name) /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ { - Display *display = tkwin != None ? Tk_Display(tkwin) : NULL; - Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None; + Display *display = NULL; TkColor *tkColPtr; XColor color; + Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; + NSView *view = nil; + static Bool initialized = NO; + static NSColorSpace* sRGB = nil; + + if (!initialized) { + initialized = YES; + sRGB = [NSColorSpace sRGBColorSpace]; + initColorTable(); + } + if (tkwin) { + display = Tk_Display(tkwin); + Drawable d = Tk_WindowId(tkwin); + view = TkMacOSXGetNSViewForDrawable(d); + } /* - * Check to see if this is a system color. Otherwise, XParseColor - * will do all the work. + * Check to see if this is a system color. If not, just call XParseColor. */ if (strncasecmp(name, "system", 6) == 0) { - Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1); - int idx, result; - - result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, - sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); - Tcl_DecrRefCount(strPtr); - if (result == TCL_OK) { - OSStatus err; + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6); + MacPixel p = {0}; + + if (hPtr != NULL) { + SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); CGColorRef c; - unsigned char pixelCode = idx + MIN_PIXELCODE; - struct SystemColorMapEntry entry = systemColorMap[idx]; - err = ChkErr(SetCGColorComponents, entry, 0, &c); - if (err == noErr) { + p.pixel.colortype = entry->type; + p.pixel.value = entry->index; + color.pixel = p.ulong; + if (entry->type == semantic) { + CGFloat rgba[4]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + if (@available(macOS 10.14, *)) { + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + NSAppearance *windowAppearance = savedAppearance; + if (view) { + windowAppearance = [view effectiveAppearance]; + } + if ([windowAppearance name] == NSAppearanceNameDarkAqua) { + colormap = darkColormap; + } else { + colormap = lightColormap; + } + [NSAppearance setCurrentAppearance:windowAppearance]; + GetRGBA(entry, p.ulong, rgba); + [NSAppearance setCurrentAppearance:savedAppearance]; + } else { + GetRGBA(entry, p.ulong, rgba); + } +#else + GetRGBA(entry, p.ulong, rgba); +#endif + color.red = rgba[0] * 65535.0; + color.green = rgba[1] * 65535.0; + color.blue = rgba[2] * 65535.0; + goto validXColor; + } else if (SetCGColorComponents(entry, 0, &c)) { const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); switch (n) { case 4: @@ -780,67 +650,60 @@ color.red = color.green = color.blue = rgba[0] * 65535.0; break; default: Tcl_Panic("CGColor with %d components", (int) n); } - color.pixel = ((((((pixelCode << 8) - | ((color.red >> 8) & 0xff)) << 8) - | ((color.green >> 8) & 0xff)) << 8) - | ((color.blue >> 8) & 0xff)); CGColorRelease(c); goto validXColor; } - CGColorRelease(c); } } - if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } validXColor: tkColPtr = (TkColor *)ckalloc(sizeof(TkColor)); + tkColPtr->colormap = colormap; tkColPtr->color = color; - return tkColPtr; } /* *---------------------------------------------------------------------- * * TkpGetColorByValue -- * - * Given a desired set of red-green-blue intensities for a color, - * locate a pixel value to use to draw that color in a given - * window. + * Given an pointer to an XColor, construct a TkColor whose red, green and + * blue intensities match those of the XColor as closely as possible. For + * the Macintosh, this means that the colortype bitfield of the pixel + * value will be RGBColor and that the color intensities stored in its + * 24-bit value bitfield are computed from the 16-bit red green and blue + * values in the XColor by dividing by 256. * * Results: - * The return value is a pointer to an TkColor structure that - * indicates the closest red, blue, and green intensities available - * to those specified in colorPtr, and also specifies a pixel - * value to use to draw in that color. + * A pointer to a newly allocated TkColor structure. * * Side effects: * May invalidate the colormap cache for the specified window. - * Allocates a new TkColor structure. + * Allocates memory for a TkColor structure. * *---------------------------------------------------------------------- */ TkColor * TkpGetColorByValue( - Tk_Window tkwin, /* Window in which color will be used. */ + TCL_UNUSED(Tk_Window), /* Window in which color will be used. */ XColor *colorPtr) /* Red, green, and blue fields indicate * desired color. */ { TkColor *tkColPtr = (TkColor *)ckalloc(sizeof(TkColor)); - (void)tkwin; tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; tkColPtr->color.blue = colorPtr->blue; - tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color); + tkColPtr->color.pixel = TkpGetPixel(colorPtr); return tkColPtr; } /* *---------------------------------------------------------------------- @@ -860,68 +723,53 @@ */ Status XAllocColor( Display *display, /* Display. */ - Colormap map, /* Not used. */ + TCL_UNUSED(Colormap), /* Not used. */ XColor *colorPtr) /* XColor struct to modify. */ { - (void)map; - display->request++; colorPtr->pixel = TkpGetPixel(colorPtr); return 1; } Colormap XCreateColormap( - Display *display, /* Display. */ - Window window, /* X window. */ - Visual *visual, /* Not used. */ - int alloc) /* Not used. */ -{ - static Colormap index = 1; - (void)display; - (void)window; - (void)visual; - (void)alloc; + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Window), /* X window. */ + TCL_UNUSED(Visual *), /* Not used. */ + TCL_UNUSED(int)) /* Not used. */ +{ + static Colormap index = 16; /* - * Just return a new value each time. + * Just return a new value each time, large enough that it will not + * conflict with any value of the macColormap enum. */ return index++; } int XFreeColormap( - Display* display, /* Display. */ - Colormap colormap) /* Colormap. */ + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Colormap)) /* Colormap. */ { - (void)display; - (void)colormap; - return Success; } int XFreeColors( - Display* display, /* Display. */ - Colormap colormap, /* Colormap. */ - unsigned long* pixels, /* Array of pixels. */ - int npixels, /* Number of pixels. */ - unsigned long planes) /* Number of pixel planes. */ -{ - (void)display; - (void)colormap; - (void)pixels; - (void)npixels; - (void)planes; - - /* - * The Macintosh version of Tk uses TrueColor. Nothing - * needs to be done to release colors as there really is - * no colormap in the Tk sense. + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Colormap), /* Colormap. */ + TCL_UNUSED(unsigned long *), /* Array of pixels. */ + TCL_UNUSED(int), /* Number of pixels. */ + TCL_UNUSED(unsigned long)) /* Number of pixel planes. */ +{ + /* + * Nothing needs to be done to release colors as there really is no + * colormap in the Tk sense. */ return Success; } /* ADDED macosx/tkMacOSXColor.h Index: macosx/tkMacOSXColor.h ================================================================== --- /dev/null +++ macosx/tkMacOSXColor.h @@ -0,0 +1,199 @@ +#ifndef MACOSXCOLOR_H +#define MACOSXCOLOR_H +/* + * The generic Tk code uses the X11 GC type to describe a graphics context. + * (A GC is a pointer to a struct XGCValues). The foreground and background + * colors in a GC are unsigned longs. These are meant to be used as indexes + * into a table of XColors, where an XColor is declared in Xlib.h as: + * typedef struct { + * unsigned long pixel; + * unsigned short red, green, blue; + * char flags; + * char pad; + * } XColor; + * + * The xlib function XParseColor creates XColors from strings. It recognizes + * literal hexadecimal color specifications such as "#RRGGBB" as well as the + * standard X11 color names. When XParseColor creates an XColor it fills in + * all of the fields except for the pixel field, and then passes the XColor + * to TkpGetPixel to get a value to use for the pixel field. Since TkpGetPixel + * is platform specific, each platform is free to choose a value which can + * be used to set the foreground or background color in the platform's graphics + * context. + * + * Tk represents a color by a struct TkColor, which extends the XColor struct. + * Tk provides a mapping from color names to TkColors which extends the mapping + * provided by XParseColor but also allows for platform specific color names. + * By convention, these platform specific color names begin with the string + * "system". The mapping from names to TkColors is implemented by the function + * TkpGetColor defined for the Macintosh in this file. The pixel field in the + * XColor contained in a TkColor will be stored in the X11 graphics context. + * In X11 the pixel field is used as an index into a colormap. On the Mac + * the high order byte of the pixel is used to indicate a color type and + * the low 24 bits are either used as an rgb value (if the type is rgbColor) + * or as an index into a table of color descriptions. + */ + +enum colorType { + rgbColor, /* The 24 bit value is an rgb color. */ + clearColor, /* The unique rgba color with all channels 0. */ + HIBrush, /* A HITheme brush color.*/ + ttkBackground, /* A background color which indicates nesting level.*/ + semantic, /* A semantic NSColor.*/ +}; + +typedef struct xpixel_t { + unsigned value: 24; /* Either RGB or an index into systemColorData. */ + unsigned colortype: 8; +} xpixel; + +typedef union MacPixel_t { + unsigned long ulong; + xpixel pixel; +} MacPixel; + +/* + * We maintain two colormaps, one for the LightAqua appearance and one for the + * DarkAqua appearance. + */ + +enum macColormap { + noColormap, + lightColormap, + darkColormap, +}; + +/* + * In TkMacOSXColor.c a Tk hash table is constructed from the static data + * below to map system color names to CGColors. + */ + +typedef struct { + const char *name; + enum colorType type; + int value; + const char *macName; + /* Fields below are filled in after or during construction of the hash table. */ + int index; + NSString *selector; +} SystemColorDatum; + +/* + * WARNING: Semantic colors which are not supported on all systems must be + * preceded by a backup color with the same name which *is* supported. Systems + * which do support the color will replace the backup value when the table is + * constructed. Failing to ensure this will result in a Tcl_Panic abort. + */ + +static SystemColorDatum systemColorData[] = { +{"Pixel", rgbColor, 0, NULL, 0, NULL }, +{"Transparent", clearColor, 0, NULL, 0, NULL }, + +{"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"HighlightText", HIBrush, kThemeBrushBlack, NULL, 0, NULL }, +{"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"SheetBackground", HIBrush, kThemeBrushSheetBackground, NULL, 0, NULL }, +{"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"Menu", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive, NULL, 0, NULL }, +{"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive, NULL, 0, NULL }, +{"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive, NULL, 0, NULL }, +{"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive, NULL, 0, NULL }, +{"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive, NULL, 0, NULL }, +{"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive, NULL, 0, NULL }, +{"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground, NULL, 0, NULL }, +{"ListViewBackground", HIBrush, kThemeBrushListViewBackground, NULL, 0, NULL }, +{"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground, NULL, 0, NULL }, +{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator, NULL, 0, NULL }, +{"ChasingArrows", HIBrush, kThemeBrushChasingArrows, NULL, 0, NULL }, +{"DragHilite", HIBrush, kThemeBrushDragHilite, NULL, 0, NULL }, +{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground, NULL, 0, NULL }, +{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive, NULL, 0, NULL }, +{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive, NULL, 0, NULL }, +{"FocusHighlight", HIBrush, kThemeBrushFocusHighlight, NULL, 0, NULL }, +{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive, NULL, 0, NULL }, +{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed, NULL, 0, NULL }, +{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive, NULL, 0, NULL }, +{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark, NULL, 0, NULL }, +{"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected, NULL, 0, NULL }, +{"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill, NULL, 0, NULL }, +{"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill, NULL, 0, NULL }, +{"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive, NULL, 0, NULL }, +{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive, NULL, 0, NULL }, +{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed, NULL, 0, NULL }, +{"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow, NULL, 0, NULL }, +{"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight, NULL, 0, NULL }, +{"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow, NULL, 0, NULL }, +{"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight, NULL, 0, NULL }, +{"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow, NULL, 0, NULL }, +{"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight, NULL, 0, NULL }, +{"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow, NULL, 0, NULL }, +{"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight, NULL, 0, NULL }, +{"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow, NULL, 0, NULL }, +{"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight, NULL, 0, NULL }, +{"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow, NULL, 0, NULL }, +{"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight, NULL, 0, NULL }, +{"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight, NULL, 0, NULL }, +{"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark, NULL, 0, NULL }, +{"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight, NULL, 0, NULL }, +{"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark, NULL, 0, NULL }, +{"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground, NULL, 0, NULL }, +{"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground, NULL, 0, NULL }, +{"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque, NULL, 0, NULL }, +{"DrawerBackground", HIBrush, kThemeBrushDrawerBackground, NULL, 0, NULL }, +{"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground, NULL, 0, NULL }, +{"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent, NULL, 0, NULL }, +{"MenuBackground", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground, NULL, 0, NULL }, +{"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground, NULL, 0, NULL }, +{"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider, NULL, 0, NULL }, + + /* + * Dynamic Colors + */ + +{"WindowBackgroundColor", ttkBackground, 0, NULL, 0, NULL }, +{"WindowBackgroundColor1", ttkBackground, 1, NULL, 0, NULL }, +{"WindowBackgroundColor2", ttkBackground, 2, NULL, 0, NULL }, +{"WindowBackgroundColor3", ttkBackground, 3, NULL, 0, NULL }, +{"WindowBackgroundColor4", ttkBackground, 4, NULL, 0, NULL }, +{"WindowBackgroundColor5", ttkBackground, 5, NULL, 0, NULL }, +{"WindowBackgroundColor6", ttkBackground, 6, NULL, 0, NULL }, +{"WindowBackgroundColor7", ttkBackground, 7, NULL, 0, NULL }, +/* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ +{"SecondaryLabelColor", ttkBackground, 14, NULL, 0, NULL }, +/* Color to use for notebook tab labels -- depends on OS version. */ +{"SelectedTabTextColor", semantic, 0, "textColor", 0, NULL }, +/* Semantic colors that we simulate on older systems which don't supoort them. */ +{"SelectedMenuItemTextColor", semantic, 0, "selectedMenuItemTextColor", 0, NULL }, +{"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL }, +{"LabelColor", semantic, 0, "blackColor", 0, NULL }, +{"LinkColor", semantic, 0, "blueColor", 0, NULL }, +{"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL }, +{"SeparatorColor", semantic, 0, "grayColor", 0, NULL }, +{"UnemphasizedSelectedTextBackgroundColor", semantic, 0, "grayColor", 0, NULL }, +{NULL, 0, 0, NULL, 0, NULL } +}; + +#endif +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ Index: macosx/tkMacOSXConfig.c ================================================================== --- macosx/tkMacOSXConfig.c +++ macosx/tkMacOSXConfig.c @@ -2,12 +2,12 @@ * tkMacOSXConfig.c -- * * This module implements the Macintosh system defaults for * the configuration package. * - * Copyright (c) 1997 by Sun Microsystems, Inc. - * Copyright 2001, Apple Inc. + * Copyright © 1997 Sun Microsystems, Inc. + * Copyright © 2001, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: macosx/tkMacOSXConstants.h ================================================================== --- macosx/tkMacOSXConstants.h +++ macosx/tkMacOSXConstants.h @@ -4,11 +4,11 @@ * Macros which map the names of NS constants used in the Tk code to * the new name that Apple came up with for subsequent versions of the * operating system. (Each new OS release seems to come with a new * naming convention for the same old constants.) * - * Copyright (c) 2017 Marc Culler + * Copyright © 2017 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -100,12 +100,20 @@ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 #define NSStringPboardType NSPasteboardTypeString #define NSOnState NSControlStateValueOn #define NSOffState NSControlStateValueOff -// Now we are also changing names of methods! -#define graphicsContextWithGraphicsPort graphicsContextWithCGContext +#endif + +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 +#define NSWindowStyleMaskTexturedBackground 0 +#endif + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 +#define GET_NSCONTEXT(context, flip) [NSGraphicsContext \ + graphicsContextWithGraphicsPort:context flipped:flip] +#else +#define GET_NSCONTEXT(context, flip) [NSGraphicsContext \ + graphicsContextWithCGContext:context flipped:NO] #endif - #endif - Index: macosx/tkMacOSXCursor.c ================================================================== --- macosx/tkMacOSXCursor.c +++ macosx/tkMacOSXCursor.c @@ -1,13 +1,13 @@ /* * tkMacOSXCursor.c -- * * This file contains Macintosh specific cursor related routines. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -185,19 +185,10 @@ * Declarations of static variables used in this file. */ static TkMacOSXCursor *gCurrentCursor = NULL; /* A pointer to the current cursor. */ -static int gResizeOverride = false; - /* A boolean indicating whether we should use - * the resize cursor during installations. */ -static int gTkOwnsCursor = true;/* A boolean indicating whether Tk owns the - * cursor. If not (for instance, in the case - * where a Tk window is embedded in another - * app's window, and the cursor is out of the - * Tk window, we will not attempt to adjust - * the cursor. */ /* * Declarations of procedures local to this file */ @@ -269,11 +260,11 @@ case IMAGEPATH: path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1]; break; case IMAGEBITMAP: { unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1); - NSBitmapImageRep *bitmapImageRep = NULL; + NSBitmapImageRep *bitmapImageRep = nil; CGImageRef img = NULL, mask = NULL, maskedImg = NULL; static const CGFloat decodeWB[] = {1, 0}; CGColorSpaceRef colorspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericGray); CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, @@ -373,18 +364,17 @@ */ TkCursor * TkGetCursorByName( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - Tk_Window tkwin, /* Window in which cursor will be used. */ + TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */ Tk_Uid string) /* Description of cursor. See manual entry * for details on legal syntax. */ { TkMacOSXCursor *macCursorPtr = NULL; const char **argv = NULL; int argc; - (void)tkwin; /* * All cursor names are valid lists of one element (for * TkX11-compatibility), even unadorned system cursor names. */ @@ -428,28 +418,20 @@ *---------------------------------------------------------------------- */ TkCursor * TkCreateCursorFromData( - Tk_Window tkwin, /* Window in which cursor will be used. */ - const char *source, /* Bitmap data for cursor shape. */ - const char *mask, /* Bitmap data for cursor mask. */ - int width, int height, /* Dimensions of cursor. */ - int xHot, int yHot, /* Location of hot-spot in cursor. */ - XColor fgColor, /* Foreground color for cursor. */ - XColor bgColor) /* Background color for cursor. */ -{ - (void)tkwin; - (void)source; - (void)mask; - (void)width; - (void)height; - (void)xHot; - (void)yHot; - (void)fgColor; - (void)bgColor; - + TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */ + TCL_UNUSED(const char *), /* Bitmap data for cursor shape. */ + TCL_UNUSED(const char *), /* Bitmap data for cursor mask. */ + TCL_UNUSED(int), /* Dimensions of cursor. */ + TCL_UNUSED(int), + TCL_UNUSED(int), /* Location of hot-spot in cursor. */ + TCL_UNUSED(int), + TCL_UNUSED(XColor), /* Foreground color for cursor. */ + TCL_UNUSED(XColor)) /* Background color for cursor. */ +{ return NULL; } /* *---------------------------------------------------------------------- @@ -473,11 +455,11 @@ TkCursor *cursorPtr) { TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr; [macCursorPtr->macCursor release]; - macCursorPtr->macCursor = NULL; + macCursorPtr->macCursor = nil; if (macCursorPtr == gCurrentCursor) { gCurrentCursor = NULL; } } @@ -496,21 +478,19 @@ * Changes the Macintosh mouse cursor. * *---------------------------------------------------------------------- */ -void +static void TkMacOSXInstallCursor( - int resizeOverride) + void) { TkMacOSXCursor *macCursorPtr = gCurrentCursor; static int cursorHidden = 0; int cursorNone = 0; - gResizeOverride = resizeOverride; - - if (resizeOverride || !macCursorPtr) { + if (!macCursorPtr) { [[NSCursor arrowCursor] set]; } else { switch (macCursorPtr->type) { case NONE: if (!cursorHidden) { @@ -554,14 +534,10 @@ TkpSetCursor( TkpCursor cursor) { int cursorChanged = 1; - if (!gTkOwnsCursor) { - return; - } - if (cursor == None) { /* * This is a little tricky. We can't really tell whether * gCurrentCursor is NULL because it was NULL last time around or * because we just freed the current cursor. So if the input cursor is @@ -576,35 +552,12 @@ } gCurrentCursor = (TkMacOSXCursor *) cursor; } if (Tk_MacOSXIsAppInFront() && cursorChanged) { - TkMacOSXInstallCursor(gResizeOverride); - } -} - -/* - *---------------------------------------------------------------------- - * - * Tk_MacOSXTkOwnsCursor -- - * - * Sets whether Tk has the right to adjust the cursor. - * - * Results: - * None. - * - * Side effects: - * May keep Tk from changing the cursor. - * - *---------------------------------------------------------------------- - */ - -void -Tk_MacOSXTkOwnsCursor( - int tkOwnsIt) -{ - gTkOwnsCursor = tkOwnsIt; + TkMacOSXInstallCursor(); + } } /* * Local Variables: * mode: objc Index: macosx/tkMacOSXCursors.h ================================================================== --- macosx/tkMacOSXCursors.h +++ macosx/tkMacOSXCursors.h @@ -2,13 +2,13 @@ * tkMacOSXCursors.h -- * * This file defines a set of Macintosh cursor resources that * are only available on the Macintosh platform. * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * Copyright 2008-2009, Apple Inc. - * Copyright (c) 2008-2009 Daniel A. Steffen + * Copyright © 1995-1996 Sun Microsystems, Inc. + * Copyright © 2008-2009 Apple Inc. + * Copyright © 2008-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: macosx/tkMacOSXDebug.c ================================================================== --- macosx/tkMacOSXDebug.c +++ macosx/tkMacOSXDebug.c @@ -2,12 +2,12 @@ * tkMacOSXDebug.c -- * * Implementation of Macintosh specific functions for debugging MacOS * events, regions, etc... * - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: macosx/tkMacOSXDebug.h ================================================================== --- macosx/tkMacOSXDebug.h +++ macosx/tkMacOSXDebug.h @@ -2,12 +2,12 @@ * tkMacOSXDebug.h -- * * Declarations of Macintosh specific functions for debugging MacOS events, * regions, etc... * - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: macosx/tkMacOSXDefault.h ================================================================== --- macosx/tkMacOSXDefault.h +++ macosx/tkMacOSXDefault.h @@ -40,14 +40,15 @@ #define NORMAL_FG "systemTextColor" #define ACTIVE_BG "systemWindowBackgroundColor" #define ACTIVE_FG "systemTextColor" #define SELECT_BG "systemSelectedTextBackgroundColor" #define SELECT_FG "systemSelectedTextColor" -#define INACTIVE_SELECT_BG "systemSelectedTextBackgroundColor" +#define INACTIVE_SELECT_BG "systemUnemphasizedSelectedTextBackgroundColor" #define TROUGH "#c3c3c3" #define INDICATOR "#b03060" -#define DISABLED "#a3a3a3" +#define DISABLED "systemDisabledControlTextColor" +#define IGNORED "#abcdef" /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ @@ -86,23 +87,13 @@ #define DEF_BUTTON_JUSTIFY "center" #define DEF_BUTTON_OFF_VALUE "0" #define DEF_BUTTON_ON_VALUE "1" #define DEF_BUTTON_TRISTATE_VALUE "" #define DEF_BUTTON_OVER_RELIEF "" -//#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS -//#define DEF_BUTTON_PADX "12" -//#define DEF_BUTTON_PADX_NOCM "1" -//#else #define DEF_BUTTON_PADX "1" -//#endif #define DEF_LABCHKRAD_PADX "1" -//#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS -//#define DEF_BUTTON_PADY "3" -//#define DEF_BUTTON_PADY_NOCM "1" -//#else #define DEF_BUTTON_PADY "1" -//#endif #define DEF_LABCHKRAD_PADY "1" #define DEF_BUTTON_RELIEF "flat" #define DEF_LABCHKRAD_RELIEF "flat" #define DEF_BUTTON_REPEAT_DELAY "0" #define DEF_BUTTON_REPEAT_INTERVAL "0" @@ -191,11 +182,11 @@ #define DEF_ENTRY_INSERT_OFF_TIME "300" #define DEF_ENTRY_INSERT_ON_TIME "600" #define DEF_ENTRY_INSERT_WIDTH "1" #define DEF_ENTRY_JUSTIFY "left" #define DEF_ENTRY_PLACEHOLDER "" -#define DEF_ENTRY_PLACEHOLDERFG "#b3b3b3" +#define DEF_ENTRY_PLACEHOLDERFG "systemPlaceholderTextColor" #define DEF_ENTRY_READONLY_BG_COLOR NORMAL_BG #define DEF_ENTRY_READONLY_BG_MONO WHITE #define DEF_ENTRY_RELIEF "sunken" #define DEF_ENTRY_SCROLL_COMMAND "" #define DEF_ENTRY_SELECT_COLOR SELECT_BG @@ -309,28 +300,28 @@ /* * Defaults for menus overall: */ -#define DEF_MENU_ACTIVE_BG_COLOR "systemMenuActive" -#define DEF_MENU_ACTIVE_BG_MONO BLACK +#define DEF_MENU_ACTIVE_BG_COLOR IGNORED +#define DEF_MENU_ACTIVE_BG_MONO IGNORED #define DEF_MENU_ACTIVE_BORDER_WIDTH "0" -#define DEF_MENU_ACTIVE_FG_COLOR "systemMenuActiveText" -#define DEF_MENU_ACTIVE_FG_MONO WHITE +#define DEF_MENU_ACTIVE_FG_COLOR IGNORED +#define DEF_MENU_ACTIVE_FG_MONO IGNORED #define DEF_MENU_ACTIVE_RELIEF "flat" -#define DEF_MENU_BG_COLOR "systemMenu" -#define DEF_MENU_BG_MONO WHITE +#define DEF_MENU_BG_COLOR "#000001" /* Detects custom bg. */ +#define DEF_MENU_BG_MONO IGNORED #define DEF_MENU_BORDER_WIDTH "0" #define DEF_MENU_CURSOR "arrow" -#define DEF_MENU_DISABLED_FG_COLOR "systemMenuDisabled" +#define DEF_MENU_DISABLED_FG_COLOR IGNORED #define DEF_MENU_DISABLED_FG_MONO "" #define DEF_MENU_FONT "menu" /* special: see tkMacOSXMenu.c */ -#define DEF_MENU_FG "systemMenuText" +#define DEF_MENU_FG "#010000" /* Detects custom fg. */ #define DEF_MENU_POST_COMMAND "" #define DEF_MENU_RELIEF "flat" -#define DEF_MENU_SELECT_COLOR "systemMenuActive" -#define DEF_MENU_SELECT_MONO BLACK +#define DEF_MENU_SELECT_COLOR IGNORED +#define DEF_MENU_SELECT_MONO IGNORED #define DEF_MENU_TAKE_FOCUS "0" #define DEF_MENU_TEAROFF "0" #define DEF_MENU_TEAROFF_CMD NULL #define DEF_MENU_TITLE "" #define DEF_MENU_TYPE "normal" @@ -338,16 +329,16 @@ /* * Defaults for menubuttons: */ #define DEF_MENUBUTTON_ANCHOR "w" -#define DEF_MENUBUTTON_ACTIVE_BG_COLOR ACTIVE_BG -#define DEF_MENUBUTTON_ACTIVE_BG_MONO WHITE -#define DEF_MENUBUTTON_ACTIVE_FG_COLOR ACTIVE_FG -#define DEF_MENUBUTTON_ACTIVE_FG_MONO BLACK -#define DEF_MENUBUTTON_BG_COLOR NORMAL_BG -#define DEF_MENUBUTTON_BG_MONO WHITE +#define DEF_MENUBUTTON_ACTIVE_BG_COLOR NORMAL_BG /*ignored*/ +#define DEF_MENUBUTTON_ACTIVE_BG_MONO NORMAL_BG /*ignored*/ +#define DEF_MENUBUTTON_ACTIVE_FG_COLOR "systemTextColor" +#define DEF_MENUBUTTON_ACTIVE_FG_MONO "systemTextColor" +#define DEF_MENUBUTTON_BG_COLOR NORMAL_BG /*ignored*/ +#define DEF_MENUBUTTON_BG_MONO NORMAL_BG /*ignored*/ #define DEF_MENUBUTTON_BITMAP "" #define DEF_MENUBUTTON_BORDER_WIDTH "0" #define DEF_MENUBUTTON_CURSOR "" #define DEF_MENUBUTTON_DIRECTION "below" #define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED @@ -355,11 +346,11 @@ #define DEF_MENUBUTTON_FONT "TkDefaultFont" #define DEF_MENUBUTTON_FG NORMAL_FG #define DEF_MENUBUTTON_HEIGHT "0" #define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR #define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO -#define DEF_MENUBUTTON_HIGHLIGHT BLACK +#define DEF_MENUBUTTON_HIGHLIGHT NORMAL_BG #define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0" #define DEF_MENUBUTTON_IMAGE NULL #define DEF_MENUBUTTON_INDICATOR "1" #define DEF_MENUBUTTON_JUSTIFY "left" #define DEF_MENUBUTTON_MENU "" Index: macosx/tkMacOSXDialog.c ================================================================== --- macosx/tkMacOSXDialog.c +++ macosx/tkMacOSXDialog.c @@ -1,14 +1,14 @@ /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * - * Copyright (c) 1996-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2017 Christian Gollwitzer. + * Copyright © 1996-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2017 Christian Gollwitzer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -21,11 +21,11 @@ #define modalCancel NSCancelButton #else #define modalOK NSModalResponseOK #define modalCancel NSModalResponseCancel #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090 -#define modalOther -1 +#define modalOther -1 // indicates that the -command option was used. #define modalError -2 /* * Vars for filtering in "open file" and "save file" dialogs. */ @@ -50,10 +50,14 @@ * includes *.* */ NSUInteger fileTypeIndex; /* Index of currently selected * filter. */ } filepanelFilterInfo; +/* + * Only one of these is needed for the application, so they can be static. + */ + static filepanelFilterInfo filterInfo; static NSOpenPanel *openpanel; static NSSavePanel *savepanel; static const char *const colorOptionStrings[] = { @@ -248,17 +252,17 @@ Tcl_SetObjResult(callbackInfo->interp, resultObj); } } else if (returnCode == modalCancel) { Tcl_ResetResult(callbackInfo->interp); } - if (panel == [NSApp modalWindow]) { - [NSApp stopModalWithCode:returnCode]; - } if (callbackInfo->cmdObj) { Tcl_DecrRefCount(callbackInfo->cmdObj); + } + if (callbackInfo) { ckfree(callbackInfo); } + [NSApp stopModalWithCode:returnCode]; } - (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo { @@ -296,11 +300,10 @@ } - (void)selectFormat:(id)sender { NSPopUpButton *button = (NSPopUpButton *)sender; filterInfo.fileTypeIndex = [button indexOfSelectedItem]; - if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) { [openpanel setAllowsOtherFileTypes:YES]; /* * setAllowsOtherFileTypes might have no effect; it's inherited from @@ -354,18 +357,46 @@ [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:callbackInfo ]; }]; - modalReturnCode = callbackInfo->cmdObj ? modalOther : - [panel runModal]; + /* + * The sheet has been prepared, so now we have to run it as a modal + * window. Using [NSApp runModalForWindow:] on macOS 10.15 or later + * generates warnings on stderr. But using [NSOpenPanel runModal] or + * [NSSavePanel runModal] on 10.14 or earler does not cause the + * completion handler to run when the panel is closed. + */ + + if ([NSApp macOSVersion] > 101400) { + modalReturnCode = [panel runModal]; + } else { + modalReturnCode = [NSApp runModalForWindow:panel]; + } } else { - modalReturnCode = [panel runModal]; - [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode - contextInfo:callbackInfo]; + + /* + * For the standalone file dialog, completion handlers do not work + * at all on macOS 10.14 and earlier. + */ + + if ([NSApp macOSVersion] > 101400) { + [panel beginWithCompletionHandler:^(NSModalResponse returnCode) { + [NSApp tkFilePanelDidEnd:panel + returnCode:returnCode + contextInfo:callbackInfo ]; + }]; + modalReturnCode = [panel runModal]; + } else { + modalReturnCode = [panel runModal]; + [NSApp tkFilePanelDidEnd:panel + returnCode:modalReturnCode + contextInfo:callbackInfo ]; + [panel close]; + } } - return modalReturnCode; + return callbackInfo->cmdObj ? modalOther : modalReturnCode; } /* *---------------------------------------------------------------------- * @@ -765,10 +796,11 @@ [label setStringValue:@"Filter:"]; [label setBordered:NO]; [label setBezeled:NO]; [label setDrawsBackground:NO]; [popupButton addItemsWithTitles:filterInfo.fileTypeLabels]; + [popupButton setTarget:NSApp]; [popupButton setAction:@selector(selectFormat:)]; [accessoryView addSubview:label]; [accessoryView addSubview:popupButton]; if (filterInfo.preselectFilter) { @@ -816,11 +848,11 @@ NSURL *fileURL = getFileURL(directory, filename); [openpanel setDirectoryURL:fileURL]; } if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } @@ -868,19 +900,19 @@ if (filterInfo.preselectFilter && filterCompatible(extension, filterInfo.fileTypeIndex)) { selectedFilterIndex = filterInfo.fileTypeIndex; // The preselection from the typevariable selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex]; } else { - NSUInteger i; + NSUInteger j; - for (i = 0; i < [filterInfo.fileTypeNames count]; i++) { - if (filterCompatible(extension, i)) { - selectedFilterIndex = i; + for (j = 0; j < [filterInfo.fileTypeNames count]; j++) { + if (filterCompatible(extension, j)) { + selectedFilterIndex = j; break; } } - if (i == selectedFilterIndex) { + if (j == selectedFilterIndex) { selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex]; } else { selectedFilter = @""; } } @@ -915,11 +947,11 @@ ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int confirmOverwrite = 1; int index, len; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; @@ -1050,12 +1082,12 @@ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 340, 22.0) pullsDown:NO]; [popupButton addItemsWithTitles:filterInfo.fileTypeLabels]; [popupButton selectItemAtIndex:filterInfo.fileTypeIndex]; + [popupButton setTarget:NSApp]; [popupButton setAction:@selector(saveFormat:)]; - [accessoryView addSubview:label]; [accessoryView addSubview:popupButton]; [savepanel setAccessoryView:accessoryView]; @@ -1102,11 +1134,11 @@ [savepanel setNameFieldStringValue:filename]; } else { [savepanel setNameFieldStringValue:@""]; } if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } @@ -1157,11 +1189,11 @@ ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; Tcl_Obj *cmdObj = NULL; FilePanelCallbackInfo callbackInfoStruct; @@ -1244,14 +1276,14 @@ */ if (!directory) { directory = @"/"; } - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } @@ -1281,68 +1313,13 @@ */ void TkAboutDlg(void) { - NSImage *image; - NSString *path = [NSApp tkFrameworkImagePath: @"Tk.tiff"]; - - if (path) { - image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease]; - } else { - image = [NSApp applicationIconImage]; - } - - NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; - - [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; - [dateFormatter setDateFormat:@"Y"]; - - NSString *year = [dateFormatter stringFromDate:[NSDate date]]; - - [dateFormatter release]; - - /* - * This replaces the old about dialog with a standard alert that displays - * correctly on 10.14. - */ - - NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL; - NSString *url = @"www.tcl-lang.org"; - NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)]; - NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; - NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font - forKey:NSFontAttributeName]; - - [credits insertText: [[NSAttributedString alloc] - initWithString:[NSString stringWithFormat: @"\n" - "Tcl and Tk are distributed under a modified BSD license: " - "www.tcl.tk/software/tcltk/license.html\n\n" - "%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n" - "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n" - "%1$C 2014-%2$@ Marc Culler.\n\n" - "%1$C 2002-2012 Daniel A. Steffen.\n\n" - "%1$C 2001-2009 Apple Inc.\n\n" - "%1$C 2001-2002 Jim Ingham & Ian Reid\n\n" - "%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n" - "%1$C 1998-2000 Scriptics Inc.\n\n" - "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year] - attributes:textAttributes] - replacementRange:NSMakeRange(0,0)]; - [credits setDrawsBackground:NO]; - [credits setEditable:NO]; - - NSAlert *about = [[NSAlert alloc] init]; - - [[about window] setTitle:@"About Tcl & Tk"]; - [about setMessageText: version]; - [about setInformativeText:url]; - about.accessoryView = credits; - [about runModal]; - [about release]; -} - + [NSApp orderFrontStandardAboutPanel:nil]; +} + /* *---------------------------------------------------------------------- * * TkMacOSXStandardAboutPanelObjCmd -- * @@ -1357,22 +1334,20 @@ *---------------------------------------------------------------------- */ int TkMacOSXStandardAboutPanelObjCmd( - ClientData dummy, /* Unused. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - (void)dummy; - if (objc > 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } - TkAboutDlg(); + [NSApp orderFrontStandardAboutPanel:nil]; return TCL_OK; } /* *---------------------------------------------------------------------- @@ -1395,11 +1370,11 @@ ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, typeIndex, iconIndex, indexDefaultOption = 0; int defaultNativeButtonIndex = 1; /* 1, 2, 3: right to left */ Tcl_Obj *cmdObj = NULL; @@ -1533,11 +1508,11 @@ } callbackInfo = (AlertCallbackInfo *)ckalloc(sizeof(AlertCallbackInfo)); callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->typeIndex = typeIndex; - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 [alert beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) { @@ -1654,20 +1629,20 @@ [fontPanelFontAttributes setDictionary:attributes]; FontchooserEvent(FontchooserSelection); } } -- (NSUInteger) validModesForFontPanel: (NSFontPanel *) fontPanel +- (NSUInteger) validModesForFontPanel: (NSFontPanel *)fontPanel { (void)fontPanel; return (NSFontPanelStandardModesMask & ~NSFontPanelAllEffectsModeMask) | NSFontPanelUnderlineEffectModeMask | NSFontPanelStrikethroughEffectModeMask; } -- (void) windowDidOrderOffScreen: (NSNotification *) notification +- (void) windowDidOrderOffScreen: (NSNotification *)notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif if ([[notification object] isEqual:[[NSFontManager sharedFontManager] @@ -1687,11 +1662,11 @@ * * Results: * None. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ static void @@ -1706,11 +1681,11 @@ } fcdPtr = Tcl_GetAssocData(fontchooserInterp, "::tk::fontchooser", NULL); switch (kind) { case FontchooserClosed: if (fcdPtr->parent != None) { - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); fontchooserInterp = NULL; } break; case FontchooserSelection: fontObj = TkMacOSXFontDescriptionForNSFontAndNSFontAttributes( @@ -1729,11 +1704,11 @@ TkBackgroundEvalObjv(fontchooserInterp, objc + 1, tmpv, TCL_EVAL_GLOBAL); ckfree(tmpv); } } - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; } } @@ -1763,11 +1738,11 @@ switch(optionIndex) { case FontchooserParent: if (fcdPtr->parent != None) { resObj = Tcl_NewStringObj( - ((TkWindow *) fcdPtr->parent)->pathName, -1); + ((TkWindow *)fcdPtr->parent)->pathName, -1); } else { resObj = Tcl_NewStringObj(".", 1); } break; case FontchooserTitle: @@ -1938,11 +1913,11 @@ [fp setPanelFont:fontPanelFont isMultiple:NO]; [fm setSelectedFont:fontPanelFont isMultiple:NO]; [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { - TkSendVirtualEvent(fcdPtr->parent, + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; case FontchooserCmd: if (fcdPtr->cmdObj) { @@ -1984,20 +1959,18 @@ static int FontchooserShowCmd( ClientData clientData, /* Main window */ Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) + TCL_UNUSED(int), + TCL_UNUSED(Tcl_Obj *const *)) { FontchooserData *fcdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); - (void)objc; - (void)objv; if (fcdPtr->parent == None) { - fcdPtr->parent = (Tk_Window) clientData; + fcdPtr->parent = (Tk_Window)clientData; Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); } NSFontManager *fm = [NSFontManager sharedFontManager]; @@ -2006,11 +1979,11 @@ if ([fp delegate] != NSApp) { [fp setDelegate:NSApp]; } if (![fp isVisible]) { [fm orderFrontFontPanel:NSApp]; - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); } fontchooserInterp = interp; return TCL_OK; } @@ -2032,20 +2005,16 @@ * ---------------------------------------------------------------------- */ static int FontchooserHideCmd( - ClientData dummy, /* Main window */ - Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) + TCL_UNUSED(void *), /* Main window */ + TCL_UNUSED(Tcl_Interp *), + TCL_UNUSED(int), + TCL_UNUSED(Tcl_Obj *const *)) { NSFontPanel *fp = [[NSFontManager sharedFontManager] fontPanel:NO]; - (void)dummy; - (void)interp; - (void)objc; - (void)objv; if ([fp isVisible]) { [fp orderOut:NSApp]; } return TCL_OK; @@ -2138,14 +2107,13 @@ */ MODULE_SCOPE int TkInitFontchooser( Tcl_Interp *interp, - ClientData dummy) + TCL_UNUSED(void *)) { FontchooserData *fcdPtr = (FontchooserData *)ckalloc(sizeof(FontchooserData)); - (void)dummy; bzero(fcdPtr, sizeof(FontchooserData)); Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteFontchooserData, fcdPtr); if (!fontPanelFontAttributes) { Index: macosx/tkMacOSXDraw.c ================================================================== --- macosx/tkMacOSXDraw.c +++ macosx/tkMacOSXDraw.c @@ -1,25 +1,25 @@ /* * tkMacOSXDraw.c -- * - * This file contains functions that perform drawing to Xlib windows. Most - * of the functions simply emulate Xlib functions. + * This file contains functions that draw to windows. Many of thees + * functions emulate Xlib functions. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright 2014 Marc Culler. + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2014-2020 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "tkButton.h" -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext] #else #define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort] #endif @@ -41,16 +41,19 @@ static int cgAntiAliasLimit = 0; #define notAA(w) ((w) < cgAntiAliasLimit) static int useThemedToplevel = 0; static int useThemedFrame = 0; +static unsigned long transparentColor; /* * Prototypes for functions used only in this file. */ static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr); +static NSImage *CreateNSImageFromPixmap(Pixmap pixmap, int width, int height); + /* *---------------------------------------------------------------------- * * TkMacOSXInitCGDrawing -- @@ -67,388 +70,124 @@ */ MODULE_SCOPE int TkMacOSXInitCGDrawing( Tcl_Interp *interp, - int enable, + TCL_UNUSED(int), int limit) { static Boolean initialized = FALSE; - (void)enable; if (!initialized) { initialized = TRUE; if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) { Tcl_ResetResult(interp); } if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit", - (char *) &cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) { + (char *)&cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) { Tcl_ResetResult(interp); } cgAntiAliasLimit = limit; /* * Piggy-back the themed drawing var init here. */ if (Tcl_LinkVar(interp, "::tk::mac::useThemedToplevel", - (char *) &useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) { + (char *)&useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } if (Tcl_LinkVar(interp, "::tk::mac::useThemedFrame", - (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) { + (char *)&useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } + transparentColor = TkMacOSXClearPixel(); } return TCL_OK; } /* *---------------------------------------------------------------------- * - * TkMacOSXBitmapRepFromDrawableRect - * - * Extract bitmap data from a MacOSX drawable as an NSBitmapImageRep. - * - * This is only used by XGetImage, which is never called. And this - * implementation does not work correctly. Originally it relied on - * [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was - * deprecated by Apple in OSX 10.14 and also required the use of other - * deprecated functions such as [NSView lockFocus]. Apple's suggested - * replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that - * is what is being used here. However, that method only works when the - * view has a valid CGContext, and a view is only guaranteed to have a - * valid context during a call to [NSView drawRect]. To further complicate - * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is - * asking the view to draw a subrectangle of itself into a special - * graphics context which is linked to the BitmapImageRep. But our - * implementation of [NSView drawRect] does not allow recursive calls. If - * called recursively it returns immediately without doing any drawing. - * So the bottom line is that this function either returns a NULL pointer - * or a black image. To make it useful would require a significant amount - * of rewriting of the drawRect method. Perhaps the next release of OSX - * will include some more helpful ways of doing this. - * - * Results: - * Returns an NSBitmapRep representing the image of the given rectangle of - * the given drawable. This object is retained. The caller is responsible - * for releasing it. - * - * NOTE: The x,y coordinates should be relative to a coordinate system - * with origin at the top left, as used by XImage and CGImage, not bottom - * left as used by NSView. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -NSBitmapImageRep * -TkMacOSXBitmapRepFromDrawableRect( - Drawable drawable, - int x, - int y, - unsigned int width, - unsigned int height) -{ - MacDrawable *mac_drawable = (MacDrawable *) drawable; - CGContextRef cg_context = NULL; - CGImageRef cg_image = NULL, sub_cg_image = NULL; - NSBitmapImageRep *bitmap_rep = NULL; - NSView *view = NULL; - if (mac_drawable->flags & TK_IS_PIXMAP) { - /* - * This MacDrawable is a bitmap, so its view is NULL. - */ - - CGRect image_rect = CGRectMake(x, y, width, height); - - cg_context = TkMacOSXGetCGContextForDrawable(drawable); - cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context); - sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect); - if (sub_cg_image) { - bitmap_rep = [NSBitmapImageRep alloc]; - [bitmap_rep initWithCGImage:sub_cg_image]; - } - if (cg_image) { - CGImageRelease(cg_image); - } - } else if ((view = TkMacOSXDrawableView(mac_drawable)) != NULL) { - /* - * Convert Tk top-left to NSView bottom-left coordinates. - */ - - int view_height = [view bounds].size.height; - NSRect view_rect = NSMakeRect(x + mac_drawable->xOff, - view_height - height - y - mac_drawable->yOff, - width, height); - - /* - * Attempt to copy from the view to a bitmapImageRep. If the view does - * not have a valid CGContext, doing this will silently corrupt memory - * and make a big mess. So, in that case, we mark the view as needing - * display and return NULL. - */ - - if (view == [NSView focusView]) { - bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; - [bitmap_rep retain]; - [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; - } else { - TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap."); - [view setNeedsDisplay:YES]; - return NULL; - } - } else { - TkMacOSXDbgMsg("Invalid source drawable"); - } - return bitmap_rep; -} - -/* - *---------------------------------------------------------------------- - * - * XCopyArea -- - * - * Copies data from one drawable to another. - * - * Results: - * None. - * - * Side effects: - * Data is moved from a window or bitmap to a second window or bitmap. - * - *---------------------------------------------------------------------- - */ - -int -XCopyArea( - Display *display, /* Display. */ - Drawable src, /* Source drawable. */ - Drawable dst, /* Destination drawable. */ - GC gc, /* GC to use. */ - int src_x, /* X & Y, width & height */ - int src_y, /* define the source rectangle */ - unsigned int width, /* that will be copied. */ - unsigned int height, - int dest_x, /* Dest X & Y on dest rect. */ - int dest_y) -{ - TkMacOSXDrawingContext dc; - MacDrawable *srcDraw = (MacDrawable *) src; - NSBitmapImageRep *bitmap_rep = NULL; - CGImageRef img = NULL; - CGRect bounds, srcRect, dstRect; - - display->request++; - if (!width || !height) { - return BadDrawable; - } - - if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { - TkMacOSXDbgMsg("Failed to setup drawing context."); - return BadDrawable; - } - - if (!dc.context) { - TkMacOSXDbgMsg("Invalid destination drawable - no context."); - return BadDrawable; - } - - if (srcDraw->flags & TK_IS_PIXMAP) { - img = TkMacOSXCreateCGImageWithDrawable(src); - } else if (TkMacOSXDrawableWindow(src)) { - bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src, - src_x, src_y, width, height); - if (bitmap_rep) { - img = [bitmap_rep CGImage]; - } - } else { - TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap."); - } - - if (img) { - bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height); - srcRect = CGRectMake(src_x, src_y, width, height); - dstRect = CGRectMake(dest_x, dest_y, width, height); - TkMacOSXDrawCGImage(dst, gc, dc.context, img, - gc->foreground, gc->background, bounds, srcRect, dstRect); - CFRelease(img); - } else { - TkMacOSXDbgMsg("Failed to construct CGImage."); - } - - TkMacOSXRestoreDrawingContext(&dc); - return Success; -} - -/* - *---------------------------------------------------------------------- - * - * XCopyPlane -- - * - * Copies a bitmap from a source drawable to a destination drawable. The - * plane argument specifies which bit plane of the source contains the - * bitmap. Note that this implementation ignores the gc->function. - * - * Results: - * None. - * - * Side effects: - * Changes the destination drawable. - * - *---------------------------------------------------------------------- - */ - -int -XCopyPlane( - Display *display, /* Display. */ - Drawable src, /* Source drawable. */ - Drawable dst, /* Destination drawable. */ - GC gc, /* GC to use. */ - int src_x, /* X & Y, width & height */ - int src_y, /* define the source rectangle */ - unsigned int width, /* that will be copied. */ - unsigned int height, - int dest_x, /* Dest X & Y on dest rect. */ - int dest_y, - unsigned long plane) /* Which plane to copy. */ -{ - TkMacOSXDrawingContext dc; - MacDrawable *srcDraw = (MacDrawable *) src; - MacDrawable *dstDraw = (MacDrawable *) dst; - CGRect bounds, srcRect, dstRect; - display->request++; - if (!width || !height) { - /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ - return BadDrawable; - } - if (plane != 1) { - Tcl_Panic("Unexpected plane specified for XCopyPlane"); - } - if (srcDraw->flags & TK_IS_PIXMAP) { - if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { - return BadDrawable; - } - - CGContextRef context = dc.context; - - if (context) { - CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src); - - if (img) { - TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; - unsigned long imageBackground = gc->background; - - if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP) { - srcRect = CGRectMake(src_x, src_y, width, height); - CGImageRef mask = TkMacOSXCreateCGImageWithDrawable( - clipPtr->value.pixmap); - CGImageRef submask = CGImageCreateWithImageInRect( - img, srcRect); - CGRect rect = CGRectMake(dest_x, dest_y, width, height); - - rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff); - CGContextSaveGState(context); - - /* - * Move the origin of the destination to top left. - */ - - CGContextTranslateCTM(context, - 0, rect.origin.y + CGRectGetMaxY(rect)); - CGContextScaleCTM(context, 1, -1); - - /* - * Fill with the background color, clipping to the mask. - */ - - CGContextClipToMask(context, rect, submask); - TkMacOSXSetColorInContext(gc, gc->background, dc.context); - CGContextFillRect(context, rect); - - /* - * Fill with the foreground color, clipping to the - * intersection of img and mask. - */ - - CGImageRef subimage = CGImageCreateWithImageInRect( - img, srcRect); - CGContextClipToMask(context, rect, subimage); - TkMacOSXSetColorInContext(gc, gc->foreground, context); - CGContextFillRect(context, rect); - CGContextRestoreGState(context); - CGImageRelease(img); - CGImageRelease(mask); - CGImageRelease(submask); - CGImageRelease(subimage); - } else { - bounds = CGRectMake(0, 0, - srcDraw->size.width, srcDraw->size.height); - srcRect = CGRectMake(src_x, src_y, width, height); - dstRect = CGRectMake(dest_x, dest_y, width, height); - TkMacOSXDrawCGImage(dst, gc, dc.context, img, - gc->foreground, imageBackground, bounds, - srcRect, dstRect); - CGImageRelease(img); - } - } else { - /* no image */ - TkMacOSXDbgMsg("Invalid source drawable"); - } - } else { - TkMacOSXDbgMsg("Invalid destination drawable - " - "could not get a bitmap context."); - } - TkMacOSXRestoreDrawingContext(&dc); - return Success; - } else { - /* - * Source drawable is a Window, not a Pixmap. - */ - - return XCopyArea(display, src, dst, gc, src_x, src_y, width, height, - dest_x, dest_y); - } -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXCreateCGImageWithDrawable -- - * - * Create a CGImage from the given Drawable. - * - * Results: - * CGImage, release after use. + * TkMacOSXGetNSImageFromTkImage -- + * + * Get autoreleased NSImage for Tk_Image. + * + * Results: + * NSImage. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +NSImage * +TkMacOSXGetNSImageFromTkImage( + Display *display, + Tk_Image image, + int width, + int height) +{ + Pixmap pixmap; + NSImage *nsImage; + if (width == 0 || height == 0) { + return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)]; + } + pixmap = Tk_GetPixmap(display, None, width, height, 0); + Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); + nsImage = CreateNSImageFromPixmap(pixmap, width, height); + Tk_FreePixmap(display, pixmap); + + return [nsImage autorelease]; +} + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXGetNSImageFromBitmap -- + * + * Get autoreleased NSImage for Bitmap. + * + * Results: + * NSImage. * * Side effects: * None. * *---------------------------------------------------------------------- */ -CGImageRef -TkMacOSXCreateCGImageWithDrawable( - Drawable drawable) -{ - CGImageRef img = NULL; - CGContextRef context = TkMacOSXGetCGContextForDrawable(drawable); - - if (context) { - img = CGBitmapContextCreateImage(context); - } - return img; +NSImage * +TkMacOSXGetNSImageFromBitmap( + Display *display, + Pixmap bitmap, + GC gc, + int width, + int height) +{ + Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); + NSImage *nsImage; + + unsigned long origBackground = gc->background; + + gc->background = transparentColor; + XSetClipOrigin(display, gc, 0, 0); + XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); + gc->background = origBackground; + nsImage = CreateNSImageFromPixmap(pixmap, width, height); + Tk_FreePixmap(display, pixmap); + + return [nsImage autorelease]; } /* *---------------------------------------------------------------------- * - * CreateNSImageWithPixmap -- + * CreateNSImageFromPixmap -- * * Create NSImage for Pixmap. * * Results: * NSImage. @@ -458,20 +197,25 @@ * *---------------------------------------------------------------------- */ static NSImage * -CreateNSImageWithPixmap( +CreateNSImageFromPixmap( Pixmap pixmap, int width, int height) { CGImageRef cgImage; NSImage *nsImage; NSBitmapImageRep *bitmapImageRep; + CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap); - cgImage = TkMacOSXCreateCGImageWithDrawable(pixmap); + if (context) { + cgImage = CGBitmapContextCreateImage(context); + } else { + return NULL; + } nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)]; bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; [nsImage addRepresentation:bitmapImageRep]; [bitmapImageRep release]; CFRelease(cgImage); @@ -480,86 +224,11 @@ } /* *---------------------------------------------------------------------- * - * TkMacOSXGetNSImageWithTkImage -- - * - * Get autoreleased NSImage for Tk_Image. - * - * Results: - * NSImage. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -NSImage * -TkMacOSXGetNSImageWithTkImage( - Display *display, - Tk_Image image, - int width, - int height) -{ - Pixmap pixmap; - NSImage *nsImage; - if (width == 0 || height == 0) { - return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)]; - } - pixmap = Tk_GetPixmap(display, None, width, height, 0); - Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); - nsImage = CreateNSImageWithPixmap(pixmap, width, height); - Tk_FreePixmap(display, pixmap); - - return [nsImage autorelease]; -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXGetNSImageWithBitmap -- - * - * Get autoreleased NSImage for Bitmap. - * - * Results: - * NSImage. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -NSImage * -TkMacOSXGetNSImageWithBitmap( - Display *display, - Pixmap bitmap, - GC gc, - int width, - int height) -{ - Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); - NSImage *nsImage; - - unsigned long origBackground = gc->background; - - gc->background = TRANSPARENT_PIXEL << 24; - XSetClipOrigin(display, gc, 0, 0); - XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); - gc->background = origBackground; - nsImage = CreateNSImageWithPixmap(pixmap, width, height); - Tk_FreePixmap(display, pixmap); - - return [nsImage autorelease]; -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXGetCGContextForDrawable -- + * Tk_MacOSXGetCGContextForDrawable -- * * Get CGContext for given Drawable, creating one if necessary. * * Results: * CGContext. @@ -568,15 +237,15 @@ * None. * *---------------------------------------------------------------------- */ -CGContextRef -TkMacOSXGetCGContextForDrawable( +void * +Tk_MacOSXGetCGContextForDrawable( Drawable drawable) { - MacDrawable *macDraw = (MacDrawable *) drawable; + MacDrawable *macDraw = (MacDrawable *)drawable; if (macDraw && (macDraw->flags & TK_IS_PIXMAP) && !macDraw->context) { const size_t bitsPerComponent = 8; size_t bitsPerPixel, bytesPerRow, len; CGColorSpaceRef colorspace = NULL; @@ -590,11 +259,11 @@ CGRect bounds = CGRectMake(0, 0, macDraw->size.width, macDraw->size.height); if (macDraw->flags & TK_IS_BW_PIXMAP) { bitsPerPixel = 8; - bitmapInfo = (CGBitmapInfo) kCGImageAlphaOnly; + bitmapInfo = (CGBitmapInfo)kCGImageAlphaOnly; } else { colorspace = CGColorSpaceCreateDeviceRGB(); bitsPerPixel = 32; bitmapInfo |= kCGImageAlphaPremultipliedFirst; } @@ -643,11 +312,11 @@ unsigned long imageBackground, CGRect imageBounds, CGRect srcBounds, CGRect dstBounds) { - MacDrawable *macDraw = (MacDrawable *) d; + MacDrawable *macDraw = (MacDrawable *)d; if (macDraw && context && image) { CGImageRef subImage = NULL; if (!CGRectEqualToRect(imageBounds, srcBounds)) { @@ -661,21 +330,22 @@ } } dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff); if (CGImageIsMask(image)) { if (macDraw->flags & TK_IS_BW_PIXMAP) { + /* * Set fill color to black; background comes from the context, * or is transparent. */ - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { CGContextClearRect(context, dstBounds); } CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0); } else { - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { TkMacOSXSetColorInContext(gc, imageBackground, context); CGContextFillRect(context, dstBounds); } TkMacOSXSetColorInContext(gc, imageForeground, context); } @@ -738,20 +408,20 @@ GC gc, /* Use this GC. */ XPoint *points, /* Array of points. */ int npoints, /* Number of points. */ int mode) /* Line drawing mode. */ { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int i, lw = gc->line_width; if (npoints < 2) { return BadValue; } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { double prevx, prevy; double o = (lw % 2) ? .5 : 0; @@ -810,16 +480,16 @@ Drawable d, GC gc, XSegment *segments, int nsegments) { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { double o = (lw % 2) ? .5 : 0; @@ -859,20 +529,19 @@ Display *display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint *points, /* Array of points. */ int npoints, /* Number of points. */ - int shape, /* Shape to draw. */ + TCL_UNUSED(int), /* Shape to draw. */ int mode) /* Drawing mode. */ { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int i; - (void)shape; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { double prevx, prevy; double o = (gc->line_width % 2) ? .5 : 0; @@ -921,20 +590,20 @@ GC gc, /* Use this GC. */ int x, int y, /* Upper left corner. */ unsigned int width, /* Width & height of rect. */ unsigned int height) { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int lw = gc->line_width; if (width == 0 || height == 0) { return BadDrawable; } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -973,22 +642,22 @@ */ int XDrawRectangles( Display *display, - Drawable drawable, + Drawable d, GC gc, XRectangle *rectArr, int nRects) { - MacDrawable *macWin = (MacDrawable *) drawable; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -1030,17 +699,17 @@ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XRectangle *rectangles, /* Rectangle array. */ int n_rectangles) /* Number of rectangles. */ { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; @@ -1089,11 +758,11 @@ { Drawable d = Tk_WindowId(tkwin); TkMacOSXDrawingContext dc; CGRect outerRect, innerRect; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return; } if (dc.context) { outerRect = CGRectMake(Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin)); @@ -1132,20 +801,20 @@ unsigned int width, /* Width & height. */ unsigned int height, int angle1, /* Staring angle of arc. */ int angle2) /* Extent of arc. */ { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return BadDrawable; } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -1205,17 +874,17 @@ Drawable d, GC gc, XArc *arcArr, int nArcs) { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; XArc *arcPtr; int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -1283,20 +952,20 @@ unsigned int width, /* Width & height. */ unsigned int height, int angle1, /* Staring angle of arc. */ int angle2) /* Extent of arc. */ { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return BadDrawable; } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; @@ -1359,17 +1028,17 @@ Drawable d, GC gc, XArc *arcArr, int nArcs) { - MacDrawable *macWin = (MacDrawable *) d; + MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; XArc * arcPtr; int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; @@ -1438,24 +1107,23 @@ */ int TkScrollWindow( Tk_Window tkwin, /* The window to be scrolled. */ - GC gc, /* GC for window to be scrolled. */ + TCL_UNUSED(GC), /* GC for window to be scrolled. */ int x, int y, /* Position rectangle to be scrolled. */ int width, int height, int dx, int dy, /* Distance rectangle should be moved. */ Region damageRgn) /* Region to accumulate damage in. */ { Drawable drawable = Tk_WindowId(tkwin); - MacDrawable *macDraw = (MacDrawable *) drawable; - TKContentView *view = (TKContentView *) TkMacOSXDrawableView(macDraw); + MacDrawable *macDraw = (MacDrawable *)drawable; + TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(macDraw); CGRect srcRect, dstRect; HIShapeRef dmgRgn = NULL, extraRgn = NULL; NSRect bounds, visRect, scrollSrc, scrollDst; int result = 0; - (void)gc; if (view) { /* * Get the scroll area in NSView coordinates (origin at bottom left). */ @@ -1535,63 +1203,63 @@ *---------------------------------------------------------------------- */ void TkMacOSXSetUpGraphicsPort( - GC gc, /* GC to apply to current port. */ - void *destPort) + TCL_UNUSED(GC), /* GC to apply to current port. */ + TCL_UNUSED(void *)) { - (void)gc; - (void)destPort; - Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!"); } /* *---------------------------------------------------------------------- * * TkMacOSXSetUpDrawingContext -- * - * Set up a drawing context for the given drawable and GC. + * Set up a drawing context for the given drawable from an X GC. * * Results: - * Boolean indicating whether it is ok to draw; if false, drawing context - * was not setup, so do not attempt to draw and do not call + * Boolean indicating whether it is ok to draw; if false, the drawing + * context was not setup, so do not attempt to draw and do not call * TkMacOSXRestoreDrawingContext(). * * Side effects: - * None. + * May modify or create the drawable's graphics context. May expand the + * drawable's dirty rectangle. When the result is true The dcPtr + * parameter is set to reference the new or updated drawing context. * *---------------------------------------------------------------------- */ Bool TkMacOSXSetupDrawingContext( Drawable d, GC gc, - int useCG, /* advisory only ! */ TkMacOSXDrawingContext *dcPtr) { - MacDrawable *macDraw = (MacDrawable *) d; + MacDrawable *macDraw = (MacDrawable *)d; Bool canDraw = true; - NSWindow *win = NULL; + TKContentView *view = nil; TkMacOSXDrawingContext dc = {}; - CGRect clipBounds; - (void)useCG; /* - * If the drawable is not a pixmap and it has an associated NSWindow then - * we know we are drawing to a window. + * If the drawable is not a pixmap, get the associated NSView. */ if (!(macDraw->flags & TK_IS_PIXMAP)) { - win = TkMacOSXDrawableWindow(d); + view = (TKContentView *)TkMacOSXGetNSViewForDrawable(d); + if (!view) { + Tcl_Panic("TkMacOSXSetupDrawingContext(): " + "no NSView to draw into !"); + } } /* - * Check that we have a non-empty clipping region. + * Intersect the drawable's clipping region with the region stored in the + * X GC. If the resulting region is empty, don't do any drawing. */ dc.clipRgn = TkMacOSXGetClipRgn(d); ClipToGC(d, gc, &dc.clipRgn); if (dc.clipRgn && HIShapeIsEmpty(dc.clipRgn)) { @@ -1598,169 +1266,162 @@ canDraw = false; goto end; } /* - * If we already have a CGContext, use it. Otherwise, if we are drawing to - * a window then we can get one from the window. + * If the drawable already has a CGContext, use it. Otherwise, we must be + * drawing to a window and we use the current context of its ContentView. */ dc.context = TkMacOSXGetCGContextForDrawable(d); if (dc.context) { - dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); - } else if (win) { - NSView *view = TkMacOSXDrawableView(macDraw); - - if (!view) { - Tcl_Panic("TkMacOSXSetupDrawingContext(): " - "no NSView to draw into !"); - } - - /* - * We can only draw into the view when the current CGContext is valid - * and belongs to the view. Validity can only be guaranteed inside of - * a view's drawRect or setFrame methods. The isDrawing attribute - * tells us whether we are being called from one of those methods. - * - * If the CGContext is not valid then we mark our view as needing - * display in the bounding rectangle of the clipping region and - * return failure. That rectangle should get drawn in a later call - * to drawRect. - * - * As an exception to the above, if mouse buttons are pressed at the - * moment when we fail to obtain a valid context we schedule the entire - * view for a redraw rather than just the clipping region. The purpose - * of this is to make sure that scrollbars get updated correctly. - */ - - if (![NSApp isDrawing] || view != [NSView focusView]) { - NSRect bounds = [view bounds]; - NSRect dirtyNS = bounds; - if ([NSEvent pressedMouseButtons]) { - [view setNeedsDisplay:YES]; - } else { - CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, - .ty = dirtyNS.size.height}; - if (dc.clipRgn) { - CGRect dirtyCG = NSRectToCGRect(dirtyNS); - HIShapeGetBounds(dc.clipRgn, &dirtyCG); - dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t)); - } - [view setNeedsDisplayInRect:dirtyNS]; - } - canDraw = false; - goto end; - } + dc.portBounds = CGContextGetClipBoundingBox(dc.context); + } else { + NSRect drawingBounds, currentBounds; dc.view = view; dc.context = GET_CGCONTEXT; dc.portBounds = NSRectToCGRect([view bounds]); if (dc.clipRgn) { - clipBounds = CGContextGetClipBoundingBox(dc.context); - } - } else { - Tcl_Panic("TkMacOSXSetupDrawingContext(): " - "no context to draw into !"); - } - - /* - * Configure the drawing context. - */ - - if (dc.context) { - CGAffineTransform t = { - .a = 1, .b = 0, - .c = 0, .d = -1, - .tx = 0, - .ty = dc.portBounds.size.height - }; - - dc.portBounds.origin.x += macDraw->xOff; - dc.portBounds.origin.y += macDraw->yOff; - CGContextSaveGState(dc.context); - CGContextSetTextDrawingMode(dc.context, kCGTextFill); - CGContextConcatCTM(dc.context, t); - if (dc.clipRgn) { -#ifdef TK_MAC_DEBUG_DRAWING - CGContextSaveGState(dc.context); - ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); - CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); - CGContextEOFillPath(dc.context); - CGContextRestoreGState(dc.context); -#endif /* TK_MAC_DEBUG_DRAWING */ - CGRect r; - - if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( - *HIShapeGetBounds(dc.clipRgn, &r), - CGRectApplyAffineTransform(clipBounds, t))) { - ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); - CGContextEOClip(dc.context); - } - } - if (gc) { - static const CGLineCap cgCap[] = { - [CapNotLast] = kCGLineCapButt, - [CapButt] = kCGLineCapButt, - [CapRound] = kCGLineCapRound, - [CapProjecting] = kCGLineCapSquare, - }; - static const CGLineJoin cgJoin[] = { - [JoinMiter] = kCGLineJoinMiter, - [JoinRound] = kCGLineJoinRound, - [JoinBevel] = kCGLineJoinBevel, - }; - bool shouldAntialias; - double w = gc->line_width; - - TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); - if (win) { - CGContextSetPatternPhase(dc.context, CGSizeMake( - dc.portBounds.size.width, dc.portBounds.size.height)); - } - if (gc->function != GXcopy) { - TkMacOSXDbgMsg("Logical functions other than GXcopy are " - "not supported for CG drawing!"); - } - - /* - * When should we antialias? - */ - - shouldAntialias = !notAA(gc->line_width); - if (!shouldAntialias) { - /* - * Make non-antialiased CG drawing look more like X11. - */ - - w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); - } - CGContextSetShouldAntialias(dc.context, shouldAntialias); - CGContextSetLineWidth(dc.context, w); - if (gc->line_style != LineSolid) { - int num = 0; - char *p = &gc->dashes; - CGFloat dashOffset = gc->dash_offset; - CGFloat lengths[10]; - - while (p[num] != '\0' && num < 10) { - lengths[num] = p[num]; - num++; - } - CGContextSetLineDash(dc.context, dashOffset, lengths, num); - } - if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) { - CGContextSetLineCap(dc.context, - cgCap[(unsigned) gc->cap_style]); - } - if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) { - CGContextSetLineJoin(dc.context, - cgJoin[(unsigned) gc->join_style]); - } + CGRect clipBounds; + CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, + .ty = [view bounds].size.height}; + HIShapeGetBounds(dc.clipRgn, &clipBounds); + clipBounds = CGRectApplyAffineTransform(clipBounds, t); + drawingBounds = NSRectFromCGRect(clipBounds); + } else { + drawingBounds = [view bounds]; + } + + /* + * We can only draw into the NSView which is the current focusView. + * When the current [NSView focusView] is nil, the CGContext for + * [NSGraphicsContext currentContext] is nil. Otherwise the current + * CGContext draws into the current focusView. An NSView is guaranteed + * to be the focusView when its drawRect or setFrame methods are + * running. Prior to OSX 10.14 it was also possible to call the + * lockFocus method to force an NSView to become the current focusView. + * But that method was deprecated in 10.14 and so is no longer used by + * Tk. Instead, if the view is not the current focusView then we add + * the drawing bounds to its dirty rectangle and return false. The + * part of the view inside the drawing bounds will get redrawn during + * the next call to its drawRect method. + */ + + if (view != [NSView focusView]) { + [view addTkDirtyRect:drawingBounds]; + canDraw = false; + goto end; + } + + /* + * Drawing will also fail when the view is the current focusView but + * the clipping rectangle set by drawRect does not contain the clipping + * region of our drawing context. (See bug [2a61eca3a8].) If part of + * the drawing bounds will be clipped then we draw whatever we can, but + * we also add the drawing bounds to the view's dirty rectangle so it + * will get redrawn in the next call to its drawRect method. + */ + + currentBounds = NSRectFromCGRect(CGContextGetClipBoundingBox(dc.context)); + if (!NSContainsRect(currentBounds, drawingBounds)) { + [view addTkDirtyRect:drawingBounds]; + } + } + + /* + * Finish configuring the drawing context. + */ + + CGAffineTransform t = { + .a = 1, .b = 0, + .c = 0, .d = -1, + .tx = 0, + .ty = dc.portBounds.size.height + }; + + dc.portBounds.origin.x += macDraw->xOff; + dc.portBounds.origin.y += macDraw->yOff; + CGContextSaveGState(dc.context); + CGContextSetTextDrawingMode(dc.context, kCGTextFill); + CGContextConcatCTM(dc.context, t); + if (dc.clipRgn) { + +#ifdef TK_MAC_DEBUG_DRAWING + CGContextSaveGState(dc.context); + ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); + CGContextEOFillPath(dc.context); + CGContextRestoreGState(dc.context); +#endif /* TK_MAC_DEBUG_DRAWING */ + + CGRect r; + CGRect b = CGRectApplyAffineTransform( + CGContextGetClipBoundingBox(dc.context), t); + if (!HIShapeIsRectangular(dc.clipRgn) || + !CGRectContainsRect(*HIShapeGetBounds(dc.clipRgn, &r), b)) { + ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + CGContextEOClip(dc.context); + } + } + if (gc) { + static const CGLineCap cgCap[] = { + [CapNotLast] = kCGLineCapButt, + [CapButt] = kCGLineCapButt, + [CapRound] = kCGLineCapRound, + [CapProjecting] = kCGLineCapSquare, + }; + static const CGLineJoin cgJoin[] = { + [JoinMiter] = kCGLineJoinMiter, + [JoinRound] = kCGLineJoinRound, + [JoinBevel] = kCGLineJoinBevel, + }; + bool shouldAntialias = !notAA(gc->line_width); + double w = gc->line_width; + + TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); + if (view) { + CGContextSetPatternPhase(dc.context, CGSizeMake( + dc.portBounds.size.width, dc.portBounds.size.height)); + } + if (gc->function != GXcopy) { + TkMacOSXDbgMsg("Logical functions other than GXcopy are " + "not supported for CG drawing!"); + } + if (!shouldAntialias) { + + /* + * Make non-antialiased CG drawing look more like X11. + */ + + w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); + } + CGContextSetShouldAntialias(dc.context, shouldAntialias); + CGContextSetLineWidth(dc.context, w); + if (gc->line_style != LineSolid) { + int num = 0; + char *p = &gc->dashes; + CGFloat dashOffset = gc->dash_offset; + dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0; + CGFloat lengths[10]; + + while (p[num] != '\0' && num < 10) { + lengths[num] = p[num]; + num++; + } + CGContextSetLineDash(dc.context, dashOffset, lengths, num); + } + if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) { + CGContextSetLineCap(dc.context, cgCap[(unsigned) gc->cap_style]); + } + if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) { + CGContextSetLineJoin(dc.context, cgJoin[(unsigned) gc->join_style]); } } end: + #ifdef TK_MAC_DEBUG_DRAWING if (!canDraw && win != NULL) { TkWindow *winPtr = TkMacOSXGetTkWindow(win); if (winPtr) { @@ -1767,10 +1428,11 @@ fprintf(stderr, "Cannot draw in %s - postponing.\n", Tk_PathName(winPtr)); } } #endif + if (!canDraw && dc.clipRgn) { CFRelease(dc.clipRgn); dc.clipRgn = NULL; } *dcPtr = dc; @@ -1828,19 +1490,19 @@ HIShapeRef TkMacOSXGetClipRgn( Drawable drawable) /* Drawable. */ { - MacDrawable *macDraw = (MacDrawable *) drawable; + MacDrawable *macDraw = (MacDrawable *)drawable; HIShapeRef clipRgn = NULL; if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); - NSView *view = TkMacOSXDrawableView(macDraw); + NSView *view = TkMacOSXGetNSViewForDrawable(macDraw); CGContextRef context = GET_CGCONTEXT; CGContextSaveGState(context); CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, [view bounds].size.height)); @@ -1860,34 +1522,10 @@ } /* *---------------------------------------------------------------------- * - * TkMacOSXSetUpClippingRgn -- - * - * Set up the clipping region so that drawing only occurs on the specified - * X subwindow. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkMacOSXSetUpClippingRgn( - Drawable drawable) /* Drawable to update. */ -{ - (void)drawable; -} - -/* - *---------------------------------------------------------------------- - * * TkpClipDrawableToRect -- * * Clip all drawing into the drawable d to the given rectangle. If width * or height are negative, reset to no clipping. * @@ -1900,17 +1538,16 @@ *---------------------------------------------------------------------- */ void TkpClipDrawableToRect( - Display *display, + TCL_UNUSED(Display *), Drawable d, int x, int y, int width, int height) { - MacDrawable *macDraw = (MacDrawable *) d; - (void)display; + MacDrawable *macDraw = (MacDrawable *)d; if (macDraw->drawRgn) { CFRelease(macDraw->drawRgn); macDraw->drawRgn = NULL; } @@ -1953,14 +1590,14 @@ Drawable d, GC gc, HIShapeRef *clipRgnPtr) /* must point to initialized variable */ { if (gc && gc->clip_mask && - ((TkpClipMask *) gc->clip_mask)->type == TKP_CLIP_REGION) { - Region gcClip = ((TkpClipMask *) gc->clip_mask)->value.region; - int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin; - int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; + ((TkpClipMask *)gc->clip_mask)->type == TKP_CLIP_REGION) { + Region gcClip = ((TkpClipMask *)gc->clip_mask)->value.region; + int xOffset = ((MacDrawable *)d)->xOff + gc->clip_x_origin; + int yOffset = ((MacDrawable *)d)->yOff + gc->clip_y_origin; HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn; XOffsetRegion(gcClip, xOffset, yOffset); gcClipRgn = TkMacOSXGetNativeRegion(gcClip); if (clipRgn) { @@ -1992,16 +1629,13 @@ *---------------------------------------------------------------------- */ void * TkMacOSXMakeStippleMap( - Drawable drawable, /* Window to apply stipple. */ - Drawable stipple) /* The stipple pattern. */ + TCL_UNUSED(Drawable), /* Window to apply stipple. */ + TCL_UNUSED(Drawable)) /* The stipple pattern. */ { - (void)drawable; - (void)stipple; - return NULL; } /* *---------------------------------------------------------------------- Index: macosx/tkMacOSXEmbed.c ================================================================== --- macosx/tkMacOSXEmbed.c +++ macosx/tkMacOSXEmbed.c @@ -5,13 +5,13 @@ * basic operations needed for application embedding (where one * application can use as its main window an internal window from some * other application). Currently only Toplevel embedding within the same * Tk application is allowed on the Macintosh. * - * Copyright (c) 1996-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1996-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -41,15 +41,10 @@ } Container; static Container *firstContainerPtr = NULL; /* First in list of all containers managed by * this process. */ -/* - * Globals defined in this file: - */ - -TkMacOSXEmbedHandler *tkMacOSXEmbedHandler = NULL; /* * Prototypes for static procedures defined in this file: */ @@ -60,46 +55,10 @@ static void EmbedGeometryRequest(Container *containerPtr, int width, int height); static void EmbedSendConfigure(Container *containerPtr); static void EmbedStructureProc(ClientData clientData, XEvent *eventPtr); static void EmbedWindowDeleted(TkWindow *winPtr); - -/* - *---------------------------------------------------------------------- - * - * Tk_MacOSXSetEmbedHandler -- - * - * Registers a handler for an in process form of embedding, like Netscape - * plugins, where Tk is loaded into the process, but does not control the - * main window - * - * Results: - * None - * - * Side effects: - * The embed handler is set. - * - *---------------------------------------------------------------------- - */ - -void -Tk_MacOSXSetEmbedHandler( - Tk_MacOSXEmbedRegisterWinProc *registerWinProc, - Tk_MacOSXEmbedGetGrafPortProc *getPortProc, - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc, - Tk_MacOSXEmbedGetClipProc *getClipProc, - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) -{ - if (tkMacOSXEmbedHandler == NULL) { - tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *)ckalloc(sizeof(TkMacOSXEmbedHandler)); - } - tkMacOSXEmbedHandler->registerWinProc = registerWinProc; - tkMacOSXEmbedHandler->getPortProc = getPortProc; - tkMacOSXEmbedHandler->containerExistProc = containerExistProc; - tkMacOSXEmbedHandler->getClipProc = getClipProc; - tkMacOSXEmbedHandler->getOffsetProc = getOffsetProc; -} /* *---------------------------------------------------------------------- * * TkpMakeWindow -- @@ -445,11 +404,11 @@ Container *containerPtr; for (containerPtr = firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { if (containerPtr->embeddedPtr == winPtr) { - return (MacDrawable *) containerPtr->parent; + return (MacDrawable *)containerPtr->parent; } } Tcl_Panic("TkMacOSXContainerId couldn't find window"); return NULL; } @@ -857,11 +816,11 @@ * It is not clear whether the container should be destroyed * when an embedded window is destroyed. See ticket [67384bce7d]. * Here we are following unix, by destroying the container. */ - Tk_DestroyWindow((Tk_Window) winPtr); + Tk_DestroyWindow((Tk_Window)winPtr); } Tk_DeleteErrorHandler(errHandler); } /* @@ -906,12 +865,12 @@ * deleted its window. */ errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1, -1, -1, NULL, NULL); - Tk_MoveResizeWindow((Tk_Window) containerPtr->embeddedPtr, 0, 0, - (unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr), + Tk_MoveResizeWindow((Tk_Window)containerPtr->embeddedPtr, 0, 0, + (unsigned) Tk_Width((Tk_Window)containerPtr->parentPtr), (unsigned) Tk_Height((Tk_Window)containerPtr->parentPtr)); Tk_DeleteErrorHandler(errHandler); } } else if (eventPtr->type == DestroyNotify) { EmbedWindowDeleted(containerPtr->parentPtr); @@ -1052,14 +1011,12 @@ * happen, process all idle event handlers synchronously here (so that the * geometry managers have had a chance to do whatever they want to do), and * if the window's size didn't change then generate a configure event. */ - Tk_GeometryRequest((Tk_Window) winPtr, width, height); - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) { - /* Empty loop body. */ - } + Tk_GeometryRequest((Tk_Window)winPtr, width, height); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {} if ((winPtr->changes.width != width) || (winPtr->changes.height != height)) { EmbedSendConfigure(containerPtr); } } Index: macosx/tkMacOSXEntry.c ================================================================== --- macosx/tkMacOSXEntry.c +++ macosx/tkMacOSXEntry.c @@ -1,13 +1,13 @@ /* * tkMacOSXEntry.c -- * * This file implements the native aqua entry widget. * - * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright 2008-2009, Apple Inc. + * Copyright © 2001 Apple Computer, Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2008-2009 Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -90,11 +90,11 @@ CGRect bounds; TkMacOSXDrawingContext dc; GC bgGC; Tk_Window tkwin = entryPtr->tkwin; int oldWidth = 0; - MacDrawable *macDraw = (MacDrawable *) d; + MacDrawable *macDraw = (MacDrawable *)d; const HIThemeFrameDrawInfo info = { .version = 0, .kind = kHIThemeFrameTextFieldSquare, .state = (entryPtr->state == STATE_DISABLED ? kThemeStateInactive : kThemeStateActive), @@ -153,11 +153,11 @@ bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH; bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; - if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) { /* * No graphics context is available. If the widget is a Spinbox, we * must restore its width before returning 0. (Ticket [273b6a4996].) */ @@ -206,11 +206,11 @@ int buttonHeight = height - 2 * MAC_OSX_FOCUS_WIDTH; int incDecWidth; TkMacOSXDrawingContext dc; XRectangle rects[1]; GC bgGC; - MacDrawable *macDraw = (MacDrawable *) d; + MacDrawable *macDraw = (MacDrawable *)d; HIThemeButtonDrawInfo info = { .version = 0, .adornment = kThemeAdornmentNone, }; @@ -263,11 +263,11 @@ rects[0].y = 0; rects[0].width = incDecWidth + 1; rects[0].height = Tk_Height(tkwin); XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1); - if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) { return 0; } ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); TkMacOSXRestoreDrawingContext(&dc); return 1; Index: macosx/tkMacOSXEvent.c ================================================================== --- macosx/tkMacOSXEvent.c +++ macosx/tkMacOSXEvent.c @@ -1,13 +1,13 @@ /* * tkMacOSXEvent.c -- * * This file contains the basic Mac OS X Event handling routines. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -102,51 +102,30 @@ break; /* return theEvent */ } return processedEvent; } @end - #pragma mark - - -/* - *---------------------------------------------------------------------- - * - * XSync -- - * - * This routine is a stub called XSync, which is called during the Tk - * update command. The language specification does not require that the - * update command be synchronous but many of the tests implicitly assume - * that it is. It is definitely asynchronous on macOS since many idle - * tasks are run inside of the drawRect method of a window's contentView, - * which will not be called until after this function returns. - * - * Results: - * None. - * - * Side effects: Processes all pending idle events then calls the display - * method of each visible window. - * - *---------------------------------------------------------------------- - */ - int XSync( Display *display, - Bool discard) -{ - (void)discard; - - if (display) { - display->request++; - } - if (Tk_GetNumMainWindows() != 0) { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} - for (NSWindow *w in [NSApp orderedWindows]) { - [w display]; - } - } - return Success; + TCL_UNUSED(Bool)) +{ + /* + * The main use of XSync is by the update command, which alternates + * between running an event loop to process all events without waiting and + * calling XSync on all displays until no events are left. There is + * nothing for the mac to do with respect to syncing its one display but + * it can (and, during regression testing, frequently does) happen that + * timer events fire during the event loop. Processing those here seems + * to make the update command work in a way that is more consistent with + * its behavior on other platforms. + */ + + while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_DONT_WAIT)){} + display->request++; + return 0; } /* * Local Variables: * mode: objc Index: macosx/tkMacOSXFont.c ================================================================== --- macosx/tkMacOSXFont.c +++ macosx/tkMacOSXFont.c @@ -2,13 +2,13 @@ * tkMacOSXFont.c -- * * Contains the Macintosh implementation of the platform-independent font * package interface. * - * Copyright 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright 2008-2009, Apple Inc. + * Copyright © 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2008-2009 Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -91,14 +91,10 @@ const TkFontAttributes *reqFaPtr, MacFont *fontPtr); static int CreateNamedSystemFont(Tcl_Interp *interp, Tk_Window tkwin, const char *name, TkFontAttributes *faPtr); -static void DrawCharsInContext(Display *display, Drawable drawable, - GC gc, Tk_Font tkfont, const char *source, - int numBytes, int rangeStart, int rangeLength, - int x, int y, double angle); #pragma mark - #pragma mark Font Helpers: /* @@ -129,11 +125,11 @@ - (instancetype)initWithString:(NSString *)aString { self = [self init]; if (self) { _string = [[NSString alloc] initWithString:aString]; - self.UTF8String = _string.UTF8String; + _UTF8String = _string.UTF8String; } return self; } - (void)dealloc @@ -151,14 +147,10 @@ - (unichar)characterAtIndex:(NSUInteger)index { return [_string characterAtIndex:index]; } -# ifndef __clang__ -@synthesize DString = _ds; -#endif - - (Tcl_DString)DString { if ( _ds.string == NULL) { /* @@ -179,10 +171,11 @@ return _ds; } #ifndef __clang__ @synthesize UTF8String = _UTF8String; +@synthesize DString = _ds; #endif @end #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \ @@ -453,11 +446,11 @@ void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { Tcl_Interp *interp = mainPtr->interp; - Tk_Window tkwin = (Tk_Window) mainPtr->winPtr; + Tk_Window tkwin = (Tk_Window)mainPtr->winPtr; const struct SystemFontMapEntry *systemFont = systemFontMap; NSFont *nsFont; TkFontAttributes fa; NSMutableCharacterSet *cs; /* @@ -552,17 +545,16 @@ *--------------------------------------------------------------------------- */ TkFont * TkpGetNativeFont( - Tk_Window tkwin, /* For display where font will be used. */ + TCL_UNUSED(Tk_Window), /* For display where font will be used. */ const char *name) /* Platform-specific font name. */ { MacFont *fontPtr = NULL; ThemeFontID themeFontId; CTFontRef ctFont; - (void)tkwin; if (strcmp(name, SYSTEMFONT_NAME) == 0) { themeFontId = kThemeSystemFont; } else if (strcmp(name, APPLFONT_NAME) == 0) { themeFontId = kThemeApplicationFont; @@ -702,15 +694,14 @@ */ void TkpGetFontFamilies( Tcl_Interp *interp, /* Interp to hold result. */ - Tk_Window tkwin) /* For display to query. */ + TCL_UNUSED(Tk_Window)) /* For display to query. */ { Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL); NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies]; - (void)tkwin; for (NSString *family in list) { Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj([family UTF8String], -1)); } @@ -776,21 +767,20 @@ *---------------------------------------------------------------------- */ void TkpGetFontAttrsForChar( - Tk_Window tkwin, /* Window on the font's display */ + TCL_UNUSED(Tk_Window), /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ int c, /* Character of interest */ TkFontAttributes* faPtr) /* Output: Font attributes */ { MacFont *fontPtr = (MacFont *) tkfont; NSFont *nsFont = fontPtr->nsFont; *faPtr = fontPtr->font.fa; if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) { UTF16Char ch = (UTF16Char) c; - (void)tkwin; nsFont = [nsFont bestMatchingFontForCharacters:&ch length:1 attributes:nil actualCoveredLength:NULL]; if (nsFont) { GetTkFontAttributesForNSFont(nsFont, faPtr); @@ -1064,11 +1054,11 @@ * Tk_DrawChars -- * * Draw a string of characters on the screen. * * With ATSUI we need the line context to do this right, so we have the - * actual implementation in TkpDrawCharsInContext(). + * actual implementation in TkpDrawAngledCharsInContext(). * * Results: * None. * * Side effects: @@ -1093,11 +1083,11 @@ * regular printing characters. */ int numBytes, /* Number of bytes in string. */ int x, int y) /* Coordinates at which to place origin of the * string when drawing. */ { - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, 0, numBytes, x, y, 0.0); } void TkDrawAngledChars( @@ -1116,11 +1106,11 @@ int numBytes, /* Number of bytes in string. */ double x, double y, /* Coordinates at which to place origin of * string when drawing. */ double angle) /* What angle to put text at, in degrees. */ { - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, 0, numBytes, x, y, angle); } /* *--------------------------------------------------------------------------- @@ -1162,17 +1152,17 @@ int x, int y) /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ { (void)display; - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, rangeStart, rangeLength, x, y, 0.0); } -static void -DrawCharsInContext( - Display *display, /* Display on which to draw. */ +void +TkpDrawAngledCharsInContext( + TCL_UNUSED(Display *), /* Display on which to draw. */ Drawable drawable, /* Window or pixmap in which to draw. */ GC gc, /* Graphics context for drawing characters. */ Tk_Font tkfont, /* Font in which characters will be drawn; must * be the same as font used in GC. */ const char * source, /* UTF-8 string to be displayed. Need not be @@ -1183,49 +1173,46 @@ * stripped out, they will be displayed as * regular printing characters. */ int numBytes, /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ - int x, int y, /* Coordinates at which to place origin of the + double x, double y, /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ - double angle) + double angle) /* What angle to put text at, in degrees. */ { const MacFont *fontPtr = (const MacFont *) tkfont; NSString *string; NSMutableDictionary *attributes; NSAttributedString *attributedString; CTTypesetterRef typesetter; CFIndex start, length; CTLineRef line, full=nil; - MacDrawable *macWin = (MacDrawable *) drawable; + MacDrawable *macWin = (MacDrawable *)drawable; TkMacOSXDrawingContext drawingContext; CGContextRef context; CGColorRef fg; NSFont *nsFont; CGAffineTransform t; CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y; - (void)display; if (rangeStart < 0 || rangeLength <= 0 || rangeStart + rangeLength > numBytes || - !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) { + !TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) { return; } string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes]; if (!string) { return; } context = drawingContext.context; - fg = TkMacOSXCreateCGColor(gc, gc->foreground); + TkSetMacColor(gc->foreground, &fg); attributes = [fontPtr->nsAttributes mutableCopy]; [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; - CFRelease(fg); nsFont = [attributes objectForKey:NSFontAttributeName]; - [nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort: - context flipped:NO]]; + [nsFont setInContext:GET_NSCONTEXT(context, NO)]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); attributedString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); @@ -1334,16 +1321,13 @@ *--------------------------------------------------------------------------- */ int TkMacOSXIsCharacterMissing( - Tk_Font tkfont, /* The font we are looking in. */ - unsigned int searchChar) /* The character we are looking for. */ + TCL_UNUSED(Tk_Font), /* The font we are looking in. */ + TCL_UNUSED(unsigned int)) /* The character we are looking for. */ { - (void)tkfont; - (void)searchChar; - return 0; } /* *---------------------------------------------------------------------- @@ -1378,11 +1362,11 @@ id strikethrough = [nsAttributes objectForKey: NSStrikethroughStyleAttributeName]; objv[i++] = Tcl_NewStringObj(familyName, -1); objv[i++] = Tcl_NewWideIntObj([nsFont pointSize]); -#define S(s) Tcl_NewStringObj(STRINGIFY(s), (int)(sizeof(STRINGIFY(s))-1)) +#define S(s) Tcl_NewStringObj(STRINGIFY(s), (sizeof(STRINGIFY(s))-1)) objv[i++] = (traits & NSBoldFontMask) ? S(bold) : S(normal); objv[i++] = (traits & NSItalicFontMask) ? S(italic) : S(roman); if ([underline respondsToSelector:@selector(intValue)] && ([underline intValue] & (NSUnderlineStyleSingle | NSUnderlineStyleThick | NSUnderlineStyleDouble))) { Index: macosx/tkMacOSXFont.h ================================================================== --- macosx/tkMacOSXFont.h +++ macosx/tkMacOSXFont.h @@ -2,14 +2,14 @@ * tkMacOSXFont.h -- * * Contains the Macintosh implementation of the platform-independent * font package interface. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ Index: macosx/tkMacOSXHLEvents.c ================================================================== --- macosx/tkMacOSXHLEvents.c +++ macosx/tkMacOSXHLEvents.c @@ -1,15 +1,15 @@ /* * tkMacOSXHLEvents.c -- * * Implements high level event support for the Macintosh. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright (c) 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2015-2019 Marc Culler - * Copyright (c) 2019 Kevin Walzer/WordTech Communications LLC. + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2015-2019 Marc Culler + * Copyright © 2019 Kevin Walzer/WordTech Communications LLC. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -37,10 +37,11 @@ typedef struct AppleEventInfo { Tcl_Interp *interp; const char *procedure; Tcl_DString command; NSAppleEventDescriptor *replyEvent; /* Only used for DoScriptText. */ + int retryCount; } AppleEventInfo; /* * Static functions used only in this file. */ @@ -51,24 +52,30 @@ /* * Names of the procedures which can be used to process AppleEvents. */ -static const char* openDocumentProc = "::tk::mac::OpenDocument"; -static const char* launchURLProc = "::tk::mac::LaunchURL"; -static const char* printDocProc = "::tk::mac::PrintDocument"; -static const char* scriptFileProc = "::tk::mac::DoScriptFile"; -static const char* scriptTextProc = "::tk::mac::DoScriptText"; +static const char openDocumentProc[] = "::tk::mac::OpenDocument"; +static const char launchURLProc[] = "::tk::mac::LaunchURL"; +static const char printDocProc[] = "::tk::mac::PrintDocument"; +static const char scriptFileProc[] = "::tk::mac::DoScriptFile"; +static const char scriptTextProc[] = "::tk::mac::DoScriptText"; #pragma mark TKApplication(TKHLEvents) @implementation TKApplication(TKHLEvents) - (void) terminate: (id) sender { (void)sender; [self handleQuitApplicationEvent:Nil withReplyEvent:Nil]; } + +- (void) superTerminate: (id) sender +{ + (void) sender; + [super terminate:nil]; +} - (void) preferences: (id) sender { (void)sender; [self handleShowPreferencesEvent:Nil withReplyEvent:Nil]; @@ -228,10 +235,17 @@ AEDisposeDesc(&contents); AEInfo->interp = _eventInterp; AEInfo->procedure = openDocumentProc; AEInfo->replyEvent = nil; Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + AEInfo->retryCount = 0; + + if (Tcl_FindCommand(_eventInterp, "::tk::mac::OpenDocuments", NULL, 0)){ + ProcessAppleEvent((ClientData)AEInfo); + } else { + Tcl_CreateTimerHandler(500, ProcessAppleEvent, (ClientData)AEInfo); + } } - (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { @@ -247,10 +261,12 @@ Tcl_DStringAppendElement(printCommand, printFile); AEInfo->interp = _eventInterp; AEInfo->procedure = printDocProc; AEInfo->replyEvent = nil; Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + AEInfo->retryCount = 0; + ProcessAppleEvent((ClientData)AEInfo); } - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { @@ -308,10 +324,12 @@ Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptFileProc; AEInfo->replyEvent = nil; Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + AEInfo->retryCount = 0; + ProcessAppleEvent((ClientData)AEInfo); } } } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, NULL, 0, &actual)) { /* @@ -323,23 +341,26 @@ if (actual > 0) { char *data = (char *)ckalloc(actual + 1); if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, data, actual, NULL)) { - AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); - Tcl_DString *scriptTextCommand = &AEInfo->command; - Tcl_DStringInit(scriptTextCommand); - Tcl_DStringAppend(scriptTextCommand, scriptTextProc, -1); + data[actual] = '\0'; + AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); + Tcl_DString *scriptTextCommand = &AEInfo->command; + Tcl_DStringInit(scriptTextCommand); + Tcl_DStringAppend(scriptTextCommand, scriptTextProc, -1); Tcl_DStringAppendElement(scriptTextCommand, data); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptTextProc; + AEInfo->retryCount = 0; if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { AEInfo->replyEvent = replyEvent; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent(AEInfo); } else { AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); + ProcessAppleEvent(AEInfo); } } } } } @@ -359,10 +380,12 @@ Tcl_DStringAppendElement(launchCommand, cURL); AEInfo->interp = _eventInterp; AEInfo->procedure = launchURLProc; AEInfo->replyEvent = nil; Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + AEInfo->retryCount = 0; + ProcessAppleEvent((ClientData)AEInfo); } @end #pragma mark - @@ -393,19 +416,34 @@ static void ProcessAppleEvent( ClientData clientData) { int code; AppleEventInfo *AEInfo = (AppleEventInfo*) clientData; - if (!AEInfo->interp || - !Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { + + if (!AEInfo->interp) { + return; + } + + /* + * Apple events that are delivered during the app startup can arrive + * before the Tcl procedure for handling the events has been defined. + * If the command is not found we create a timer handler to process + * the event later, hopefully after the command has been created. + * We retry up to 2 times before giving up. + */ + + if (!Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { + if (AEInfo->retryCount < 2) { + AEInfo->retryCount++; + Tcl_CreateTimerHandler(200, ProcessAppleEvent, clientData); + } else { + ckfree(clientData); + } return; } code = Tcl_EvalEx(AEInfo->interp, Tcl_DStringValue(&AEInfo->command), Tcl_DStringLength(&AEInfo->command), TCL_EVAL_GLOBAL); - if (code != TCL_OK) { - Tcl_BackgroundException(AEInfo->interp, code); - } if (AEInfo->replyEvent && code >= 0) { int reslen; const char *result = Tcl_GetStringFromObj(Tcl_GetObjResult(AEInfo->interp), &reslen); @@ -416,11 +454,14 @@ AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc], keyErrorString, typeChar, result, reslen); AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc], keyErrorNumber, typeSInt32, (Ptr) &code, sizeof(int)); } + } else if (code != TCL_OK) { + Tcl_BackgroundException(AEInfo->interp, code); } + Tcl_DStringFree(&AEInfo->command); ckfree(clientData); } /* @@ -440,15 +481,14 @@ *---------------------------------------------------------------------- */ void TkMacOSXInitAppleEvents( - Tcl_Interp *dummy) /* not used */ + TCL_UNUSED(Tcl_Interp *)) { NSAppleEventManager *aeManager = [NSAppleEventManager sharedAppleEventManager]; static Boolean initialized = FALSE; - (void)dummy; if (!initialized) { initialized = TRUE; [aeManager setEventHandler:NSApp @@ -551,18 +591,22 @@ */ static int ReallyKillMe( Tcl_Event *eventPtr, - int flags) + TCL_UNUSED(int)) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL; - int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL); - (void)flags; + + if (!quit) { + Tcl_Exit(0); + } + int code = Tcl_EvalEx(interp, "::tk::mac::Quit", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { + /* * Should be never reached... */ Tcl_BackgroundException(interp, code); Index: macosx/tkMacOSXImage.c ================================================================== --- macosx/tkMacOSXImage.c +++ macosx/tkMacOSXImage.c @@ -1,30 +1,32 @@ /* * tkMacOSXImage.c -- * * The code in this file provides an interface for XImages, * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright 2017-2018 Marc Culler. + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2017-2020 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "xbytes.h" +static CGImageRef CreateCGImageFromPixmap(Drawable pixmap); +static CGImageRef CreateCGImageFromDrawableRect( Drawable drawable, + int x, int y, unsigned int width, unsigned int height); + #pragma mark XImage handling int _XInitImageFuncPtrs( - XImage *image) + TCL_UNUSED(XImage *)) /* image */ { - (void)image; - return 0; } /* *---------------------------------------------------------------------- @@ -41,14 +43,15 @@ * None. * *---------------------------------------------------------------------- */ -static void ReleaseData(void *info, const void *data, size_t size) { - (void)data; - (void)size; - +static void ReleaseData( + void *info, + TCL_UNUSED(const void *), /* data */ + TCL_UNUSED(size_t)) /* size */ +{ ckfree(info); } CGImageRef TkMacOSXCreateCGImageWithXImage( @@ -134,146 +137,10 @@ } /* *---------------------------------------------------------------------- * - * XGetImage -- - * - * This function copies data from a pixmap or window into an XImage. It - * is essentially never used. At one time it was called by - * pTkImgPhotoDisplay, but that is no longer the case. Currently it is - * called two places, one of which is requesting an XY image which we do - * not support. It probably does not work correctly -- see the comments - * for TkMacOSXBitmapRepFromDrawableRect. - * - * Results: - * Returns a newly allocated XImage containing the data from the given - * rectangle of the given drawable, or NULL if the XImage could not be - * constructed. NOTE: If we are copying from a window on a Retina - * display, the dimensions of the XImage will be 2*width x 2*height. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -struct pixel_fmt {int r; int g; int b; int a;}; -static struct pixel_fmt bgra = {2, 1, 0, 3}; -static struct pixel_fmt abgr = {3, 2, 1, 0}; - -XImage * -XGetImage( - Display *display, - Drawable drawable, - int x, - int y, - unsigned int width, - unsigned int height, - unsigned long plane_mask, - int format) -{ - NSBitmapImageRep* bitmap_rep = NULL; - NSUInteger bitmap_fmt = 0; - XImage* imagePtr = NULL; - char* bitmap = NULL; - char R, G, B, A; - int depth = 32, offset = 0, bitmap_pad = 0; - unsigned int bytes_per_row, size, row, n, m; - unsigned int scalefactor=1, scaled_height=height, scaled_width=width; - NSWindow *win = TkMacOSXDrawableWindow(drawable); - static enum {unknown, no, yes} has_retina = unknown; - (void)plane_mask; - - if (win && has_retina == unknown) { -#ifdef __clang__ - has_retina = [win respondsToSelector:@selector(backingScaleFactor)] ? - yes : no; -#else - has_retina = no; -#endif - } - - if (has_retina == yes) { - /* - * We only allow scale factors 1 or 2, as Apple currently does. - */ - -#ifdef __clang__ - scalefactor = [win backingScaleFactor] == 2.0 ? 2 : 1; -#endif - scaled_height *= scalefactor; - scaled_width *= scalefactor; - } - - if (format == ZPixmap) { - if (width == 0 || height == 0) { - return NULL; - } - - bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(drawable, - x, y, width, height); - if (!bitmap_rep) { - TkMacOSXDbgMsg("XGetImage: Failed to construct NSBitmapRep"); - return NULL; - } - bitmap_fmt = [bitmap_rep bitmapFormat]; - size = [bitmap_rep bytesPerPlane]; - bytes_per_row = [bitmap_rep bytesPerRow]; - bitmap = (char *)ckalloc(size); - if (!bitmap - || (bitmap_fmt != 0 && bitmap_fmt != 1) - || [bitmap_rep samplesPerPixel] != 4 - || [bitmap_rep isPlanar] != 0 - || bytes_per_row < 4 * scaled_width - || size != bytes_per_row * scaled_height) { - TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format"); - CFRelease(bitmap_rep); - return NULL; - } - memcpy(bitmap, (char *)[bitmap_rep bitmapData], size); - CFRelease(bitmap_rep); - - /* - * When Apple extracts a bitmap from an NSView, it may be in either - * BGRA or ABGR format. For an XImage we need RGBA. - */ - - struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr; - - for (row = 0, n = 0; row < scaled_height; row++, n += bytes_per_row) { - for (m = n; m < n + 4*scaled_width; m += 4) { - R = *(bitmap + m + pixel.r); - G = *(bitmap + m + pixel.g); - B = *(bitmap + m + pixel.b); - A = *(bitmap + m + pixel.a); - - *(bitmap + m) = R; - *(bitmap + m + 1) = G; - *(bitmap + m + 2) = B; - *(bitmap + m + 3) = A; - } - } - imagePtr = XCreateImage(display, NULL, depth, format, offset, - (char*) bitmap, scaled_width, scaled_height, - bitmap_pad, bytes_per_row); - if (scalefactor == 2) { - imagePtr->pixelpower = 1; - } - } else { - /* - * There are some calls to XGetImage in the generic Tk code which pass - * an XYPixmap rather than a ZPixmap. XYPixmaps should be handled - * here. - */ - TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment."); - } - return imagePtr; -} - -/* - *---------------------------------------------------------------------- - * * DestroyImage -- * * Destroys storage associated with an image. * * Results: @@ -304,11 +171,15 @@ * ImageGetPixel -- * * Get a single pixel from an image. * * Results: - * Returns the 32 bit pixel value. + * The XColor structure contains an unsigned long field named pixel which + * identifies the color. This function returns the unsigned long that + * would be used as the pixel value of an XColor that has the same red + * green and blue components as the XImage pixel at the specified + * location. * * Side effects: * None. * *---------------------------------------------------------------------- @@ -320,53 +191,59 @@ int x, int y) { unsigned char r = 0, g = 0, b = 0; + /* + * Compute 8 bit red green and blue values, which are passed as inputs to + * TkMacOSXRGBPixel to produce the pixel value. + */ + if (image && image->data) { unsigned char *srcPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); switch (image->bits_per_pixel) { - case 32: + case 32: /* 8 bits per channel */ r = (*((unsigned int*) srcPtr) >> 16) & 0xff; g = (*((unsigned int*) srcPtr) >> 8) & 0xff; b = (*((unsigned int*) srcPtr) ) & 0xff; /*if (image->byte_order == LSBFirst) { r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0]; } else { r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3]; }*/ break; - case 16: + case 16: /* 5 bits per channel */ r = (*((unsigned short*) srcPtr) >> 7) & 0xf8; g = (*((unsigned short*) srcPtr) >> 2) & 0xf8; b = (*((unsigned short*) srcPtr) << 3) & 0xf8; break; - case 8: + case 8: /* 2 bits per channel */ r = (*srcPtr << 2) & 0xc0; g = (*srcPtr << 4) & 0xc0; b = (*srcPtr << 6) & 0xc0; r |= r >> 2 | r >> 4 | r >> 6; g |= g >> 2 | g >> 4 | g >> 6; b |= b >> 2 | b >> 4 | b >> 6; break; - case 4: { + case 4: { /* 1 bit per channel */ unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4); r = (c & 0x04) ? 0xff : 0; g = (c & 0x02) ? 0xff : 0; b = (c & 0x01) ? 0xff : 0; break; } - case 1: + case 1: /* Black-white bitmap. */ r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0; break; } } - return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b; + + return TkMacOSXRGBPixel(r, g, b); } /* *---------------------------------------------------------------------- * @@ -444,11 +321,11 @@ */ XImage * XCreateImage( Display* display, - Visual* visual, + TCL_UNUSED(Visual*), /* visual */ unsigned int depth, int format, int offset, char* data, unsigned int width, @@ -455,30 +332,22 @@ unsigned int height, int bitmap_pad, int bytes_per_line) { XImage *ximage; - (void)visual; display->request++; - ximage = (XImage *)ckalloc(sizeof(XImage)); + ximage = ckalloc(sizeof(XImage)); ximage->height = height; ximage->width = width; ximage->depth = depth; ximage->xoffset = offset; ximage->format = format; ximage->data = data; ximage->obdata = NULL; - /* - * The default pixelpower is 0. This must be explicitly set to 1 in the - * case of an XImage extracted from a Retina display. - */ - - ximage->pixelpower = 0; - if (format == ZPixmap) { ximage->bits_per_pixel = 32; ximage->bitmap_unit = 32; } else { ximage->bits_per_pixel = 1; @@ -547,17 +416,17 @@ int src_x, /* Source X & Y. */ int src_y, int dest_x, /* Destination X & Y. */ int dest_y, unsigned int width, /* Same width & height for both */ - unsigned int height) /* distination and source. */ + unsigned int height) /* destination and source. */ { TkMacOSXDrawingContext dc; - MacDrawable *macDraw = (MacDrawable *) drawable; + MacDrawable *macDraw = (MacDrawable *)drawable; display->request++; - if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(drawable, gc, &dc)) { return BadDrawable; } if (dc.context) { CGRect bounds, srcRect, dstRect; CGImageRef img = TkMacOSXCreateCGImageWithXImage(image); @@ -569,21 +438,12 @@ if (!(macDraw->flags & TK_IS_PIXMAP)) { CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); } if (img) { - /* - * If the XImage has big pixels, the source is rescaled to reflect - * the actual pixel dimensions. This is not currently used, but - * could arise if the image were copied from a retina monitor and - * redrawn on an ordinary monitor. - */ - - int pp = image->pixelpower; - bounds = CGRectMake(0, 0, image->width, image->height); - srcRect = CGRectMake(src_x<foreground, gc->background, bounds, srcRect, dstRect); CFRelease(img); @@ -594,14 +454,462 @@ TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); return Success; } + +/* + *---------------------------------------------------------------------- + * + * CreateCGImageFromDrawableRect + * + * Extract image data from a MacOSX drawable as a CGImage. + * + * This is only called by XGetImage and XCopyArea. The Tk core uses + * these functions on some platforms, but on macOS the core does not + * call them with a source drawable which is a window. Such calls are + * used only for double-buffered drawing. Since macOS defines the + * macro TK_NO_DOUBLE_BUFFERING, the generic code never calls XGetImage + * or XCopyArea on macOS. Nonetheless, these function are in the stubs + * table and therefore could be used by extensions. + * + * This implementation does not work correctly. Originally it relied on + * [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was + * deprecated by Apple in OSX 10.14 and also required the use of other + * deprecated functions such as [NSView lockFocus]. Apple's suggested + * replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that + * is what is being used here. However, that method only works when the + * view has a valid CGContext, and a view is only guaranteed to have a + * valid context during a call to [NSView drawRect]. To further complicate + * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is + * asking the view to draw a subrectangle of itself using a special + * graphics context which is linked to the BitmapImageRep. But our + * implementation of [NSView drawRect] does not allow recursive calls. If + * called recursively it returns immediately without doing any drawing. + * So the bottom line is that this function either returns a NULL pointer + * or a black image. To make it useful would require a significant amount + * of rewriting of the drawRect method. Perhaps the next release of OSX + * will include some more helpful ways of doing this. + * + * Results: + * Returns an NSBitmapRep representing the image of the given rectangle of + * the given drawable. This object is retained. The caller is responsible + * for releasing it. + * + * NOTE: The x,y coordinates should be relative to a coordinate system + * with origin at the top left, as used by XImage and CGImage, not bottom + * left as used by NSView. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +static CGImageRef +CreateCGImageFromDrawableRect( + Drawable drawable, + int x, + int y, + unsigned int width, + unsigned int height) +{ + MacDrawable *mac_drawable = (MacDrawable *)drawable; + CGContextRef cg_context = NULL; + CGImageRef cg_image = NULL, result = NULL; + NSBitmapImageRep *bitmapRep = nil; + NSView *view = nil; + if (mac_drawable->flags & TK_IS_PIXMAP) { + /* + * This MacDrawable is a bitmap, so its view is NULL. + */ + + CGRect image_rect = CGRectMake(x, y, width, height); + + cg_context = TkMacOSXGetCGContextForDrawable(drawable); + cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context); + if (cg_image) { + result = CGImageCreateWithImageInRect(cg_image, image_rect); + CGImageRelease(cg_image); + } + } else if (TkMacOSXGetNSViewForDrawable(mac_drawable) != nil) { + + /* + * Convert Tk top-left to NSView bottom-left coordinates. + */ + + int view_height = [view bounds].size.height; + NSRect view_rect = NSMakeRect(x + mac_drawable->xOff, + view_height - height - y - mac_drawable->yOff, + width, height); + + /* + * Attempt to copy from the view to a bitmapImageRep. If the view does + * not have a valid CGContext, doing this will silently corrupt memory + * and make a big mess. So, in that case, we just return NULL. + */ + + if (view == [NSView focusView]) { + bitmapRep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; + [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmapRep]; + result = [bitmapRep CGImage]; + CFRelease(bitmapRep); + } else { + TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap."); + result = NULL; + } + } else { + TkMacOSXDbgMsg("Invalid source drawable"); + } + return result; +} + +/* + *---------------------------------------------------------------------- + * + * CreateCGImageFromPixmap -- + * + * Create a CGImage from an X Pixmap. + * + * Results: + * CGImage, release after use. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static CGImageRef +CreateCGImageFromPixmap( + Drawable pixmap) +{ + CGImageRef img = NULL; + CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap); + + if (context) { + img = CGBitmapContextCreateImage(context); + } + return img; +} + +/* + *---------------------------------------------------------------------- + * + * XGetImage -- + * + * This function copies data from a pixmap or window into an XImage. It + * is essentially never used. At one time it was called by + * pTkImgPhotoDisplay, but that is no longer the case. Currently it is + * called two places, one of which is requesting an XY image which we do + * not support. It probably does not work correctly -- see the comments + * for CGImageFromDrawableRect. + * + * Results: + * Returns a newly allocated XImage containing the data from the given + * rectangle of the given drawable, or NULL if the XImage could not be + * constructed. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +struct pixel_fmt {int r; int g; int b; int a;}; +static struct pixel_fmt bgra = {2, 1, 0, 3}; +static struct pixel_fmt abgr = {3, 2, 1, 0}; + +XImage * +XGetImage( + Display *display, + Drawable drawable, + int x, + int y, + unsigned int width, + unsigned int height, + TCL_UNUSED(unsigned long), /* plane_mask */ + int format) +{ + NSBitmapImageRep* bitmapRep = nil; + NSUInteger bitmap_fmt = 0; + XImage* imagePtr = NULL; + char* bitmap = NULL; + char R, G, B, A; + int depth = 32, offset = 0, bitmap_pad = 0; + unsigned int bytes_per_row, size, row, n, m; + + if (format == ZPixmap) { + CGImageRef cgImage; + if (width == 0 || height == 0) { + return NULL; + } + + cgImage = CreateCGImageFromDrawableRect(drawable, x, y, width, height); + if (cgImage) { + bitmapRep = [NSBitmapImageRep alloc]; + [bitmapRep initWithCGImage:cgImage]; + CFRelease(cgImage); + } else { + TkMacOSXDbgMsg("XGetImage: Failed to construct CGImage"); + return NULL; + } + bitmap_fmt = [bitmapRep bitmapFormat]; + size = [bitmapRep bytesPerPlane]; + bytes_per_row = [bitmapRep bytesPerRow]; + bitmap = ckalloc(size); + if (!bitmap + || (bitmap_fmt != 0 && bitmap_fmt != 1) + || [bitmapRep samplesPerPixel] != 4 + || [bitmapRep isPlanar] != 0 + || bytes_per_row < 4 * width + || size != bytes_per_row * height) { + TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format"); + CFRelease(bitmapRep); + return NULL; + } + memcpy(bitmap, (char *)[bitmapRep bitmapData], size); + CFRelease(bitmapRep); + + /* + * When Apple extracts a bitmap from an NSView, it may be in either + * BGRA or ABGR format. For an XImage we need RGBA. + */ + + struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr; + + for (row = 0, n = 0; row < height; row++, n += bytes_per_row) { + for (m = n; m < n + 4*width; m += 4) { + R = *(bitmap + m + pixel.r); + G = *(bitmap + m + pixel.g); + B = *(bitmap + m + pixel.b); + A = *(bitmap + m + pixel.a); + + *(bitmap + m) = R; + *(bitmap + m + 1) = G; + *(bitmap + m + 2) = B; + *(bitmap + m + 3) = A; + } + } + imagePtr = XCreateImage(display, NULL, depth, format, offset, + (char*) bitmap, width, height, + bitmap_pad, bytes_per_row); + } else { + /* + * There are some calls to XGetImage in the generic Tk code which pass + * an XYPixmap rather than a ZPixmap. XYPixmaps should be handled + * here. + */ + TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment."); + } + return imagePtr; +} + +/* + *---------------------------------------------------------------------- + * + * XCopyArea -- + * + * Copies image data from one drawable to another. + * + * Results: + * None. + * + * Side effects: + * Image data is moved from a window or bitmap to a second window or bitmap. + * + *---------------------------------------------------------------------- + */ + +int +XCopyArea( + Display *display, /* Display. */ + Drawable src, /* Source drawable. */ + Drawable dst, /* Destination drawable. */ + GC gc, /* GC to use. */ + int src_x, /* X & Y, width & height */ + int src_y, /* define the source rectangle */ + unsigned int width, /* that will be copied. */ + unsigned int height, + int dest_x, /* Dest X & Y on dest rect. */ + int dest_y) +{ + TkMacOSXDrawingContext dc; + MacDrawable *srcDraw = (MacDrawable *)src; + CGImageRef img = NULL; + CGRect bounds, srcRect, dstRect; + + display->request++; + if (!width || !height) { + return BadDrawable; + } + + if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) { + TkMacOSXDbgMsg("Failed to setup drawing context."); + return BadDrawable; + } + + if (!dc.context) { + TkMacOSXDbgMsg("Invalid destination drawable - no context."); + return BadDrawable; + } + + if (srcDraw->flags & TK_IS_PIXMAP) { + img = CreateCGImageFromPixmap(src); + } else if (TkMacOSXGetNSWindowForDrawable(src)) { + img = CreateCGImageFromDrawableRect(src, src_x, src_y, width, height); + } else { + TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap."); + } + + if (img) { + bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height); + srcRect = CGRectMake(src_x, src_y, width, height); + dstRect = CGRectMake(dest_x, dest_y, width, height); + TkMacOSXDrawCGImage(dst, gc, dc.context, img, + gc->foreground, gc->background, bounds, srcRect, dstRect); + CFRelease(img); + } else { + TkMacOSXDbgMsg("Failed to construct CGImage."); + } + + TkMacOSXRestoreDrawingContext(&dc); + return Success; +} + +/* + *---------------------------------------------------------------------- + * + * XCopyPlane -- + * + * Copies a bitmap from a source drawable to a destination drawable. The + * plane argument specifies which bit plane of the source contains the + * bitmap. Note that this implementation ignores the gc->function. + * + * Results: + * None. + * + * Side effects: + * Changes the destination drawable. + * + *---------------------------------------------------------------------- + */ + +int +XCopyPlane( + Display *display, /* Display. */ + Drawable src, /* Source drawable. */ + Drawable dst, /* Destination drawable. */ + GC gc, /* GC to use. */ + int src_x, /* X & Y, width & height */ + int src_y, /* define the source rectangle */ + unsigned int width, /* that will be copied. */ + unsigned int height, + int dest_x, /* Dest X & Y on dest rect. */ + int dest_y, + unsigned long plane) /* Which plane to copy. */ +{ + TkMacOSXDrawingContext dc; + MacDrawable *srcDraw = (MacDrawable *)src; + MacDrawable *dstDraw = (MacDrawable *)dst; + CGRect bounds, srcRect, dstRect; + display->request++; + if (!width || !height) { + /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ + return BadDrawable; + } + if (plane != 1) { + Tcl_Panic("Unexpected plane specified for XCopyPlane"); + } + if (srcDraw->flags & TK_IS_PIXMAP) { + if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) { + return BadDrawable; + } + + CGContextRef context = dc.context; + + if (context) { + CGImageRef img = CreateCGImageFromPixmap(src); + + if (img) { + TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; + unsigned long imageBackground = gc->background; + + if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP) { + srcRect = CGRectMake(src_x, src_y, width, height); + CGImageRef mask = CreateCGImageFromPixmap( + clipPtr->value.pixmap); + CGImageRef submask = CGImageCreateWithImageInRect( + img, srcRect); + CGRect rect = CGRectMake(dest_x, dest_y, width, height); + + rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff); + CGContextSaveGState(context); + + /* + * Move the origin of the destination to top left. + */ + + CGContextTranslateCTM(context, + 0, rect.origin.y + CGRectGetMaxY(rect)); + CGContextScaleCTM(context, 1, -1); + + /* + * Fill with the background color, clipping to the mask. + */ + + CGContextClipToMask(context, rect, submask); + TkMacOSXSetColorInContext(gc, gc->background, dc.context); + CGContextFillRect(context, rect); + + /* + * Fill with the foreground color, clipping to the + * intersection of img and mask. + */ + + CGImageRef subimage = CGImageCreateWithImageInRect( + img, srcRect); + CGContextClipToMask(context, rect, subimage); + TkMacOSXSetColorInContext(gc, gc->foreground, context); + CGContextFillRect(context, rect); + CGContextRestoreGState(context); + CGImageRelease(img); + CGImageRelease(mask); + CGImageRelease(submask); + CGImageRelease(subimage); + } else { + bounds = CGRectMake(0, 0, + srcDraw->size.width, srcDraw->size.height); + srcRect = CGRectMake(src_x, src_y, width, height); + dstRect = CGRectMake(dest_x, dest_y, width, height); + TkMacOSXDrawCGImage(dst, gc, dc.context, img, + gc->foreground, imageBackground, bounds, + srcRect, dstRect); + CGImageRelease(img); + } + } else { + /* no image */ + TkMacOSXDbgMsg("Invalid source drawable"); + } + } else { + TkMacOSXDbgMsg("Invalid destination drawable - " + "could not get a bitmap context."); + } + TkMacOSXRestoreDrawingContext(&dc); + return Success; + } else { + /* + * Source drawable is a Window, not a Pixmap. + */ + + return XCopyArea(display, src, dst, gc, src_x, src_y, width, height, + dest_x, dest_y); + } +} /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ Index: macosx/tkMacOSXInit.c ================================================================== --- macosx/tkMacOSXInit.c +++ macosx/tkMacOSXInit.c @@ -2,24 +2,23 @@ * tkMacOSXInit.c -- * * This file contains Mac OS X -specific interpreter initialization * functions. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright (c) 2017 Marc Culler + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2017 Marc Culler * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" - -#include #include #include +#include static char tkLibPath[PATH_MAX + 1] = ""; /* * If the App is in an App package, then we want to add the Scripts directory @@ -39,10 +38,12 @@ @implementation TKApplication @synthesize poolLock = _poolLock; @synthesize macOSVersion = _macOSVersion; @synthesize isDrawing = _isDrawing; +@synthesize needsToDraw = _needsToDraw; +@synthesize isSigned = _isSigned; @end /* * #define this to see a message on stderr whenever _resetAutoreleasePool is * called while the pool is locked. @@ -101,32 +102,34 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_postedNotification:) name:nil object:nil]; #endif [self _setupWindowNotifications]; [self _setupApplicationNotifications]; - - /* - * Construct the menu bar. - */ - _defaultMainMenu = nil; - [self _setupMenus]; - - /* - * Initialize event processing. - */ +} + +-(void)applicationDidFinishLaunching:(NSNotification *)notification +{ + (void)notification; + + /* + * Initialize event processing. + */ + TkMacOSXInitAppleEvents(_eventInterp); /* * Initialize the graphics context. */ TkMacOSXUseAntialiasedText(_eventInterp, -1); TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0); -} --(void)applicationDidFinishLaunching:(NSNotification *)notification -{ - (void)notification; + /* + * Construct the menu bar. + */ + + _defaultMainMenu = nil; + [self _setupMenus]; /* * It is not safe to force activation of the NSApp until this method is * called. Activating too early can cause the menu bar to be unresponsive. * The call to activateIgnoringOtherApps was moved here to avoid this. @@ -142,11 +145,11 @@ * Process events to ensure that the root window is fully initialized. See * ticket 56a1823c73. */ [NSApp _lockAutoreleasePool]; - while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {} + while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} [NSApp _unlockAutoreleasePool]; } - (void) _setup: (Tcl_Interp *) interp { @@ -199,10 +202,11 @@ if (!iconFile) { NSString *path = [NSApp tkFrameworkImagePath:@"Tk.icns"]; if (path) { NSImage *image = [[NSImage alloc] initWithContentsOfFile:path]; if (image) { + [image setName:@"NSApplicationIcon"]; [NSApp setApplicationIconImage:image]; [image release]; } } } @@ -267,37 +271,114 @@ * Side effects: * Sets "tk_library" Tcl variable, runs "tk.tcl" script. * *---------------------------------------------------------------------- */ + +/* + * Helper function which closes the shared NSFontPanel and NSColorPanel. + */ + +static void closePanels( + void) +{ + if ([NSFontPanel sharedFontPanelExists]) { + [[NSFontPanel sharedFontPanel] orderOut:nil]; + } + if ([NSColorPanel sharedColorPanelExists]) { + [[NSColorPanel sharedColorPanel] orderOut:nil]; + } +} + +/* + * This custom exit procedure is called by Tcl_Exit in place of the exit + * function from the C runtime. It calls the terminate method of the + * NSApplication class (superTerminate for a TKApplication). The purpose of + * doing this is to ensure that the NSFontPanel and the NSColorPanel are closed + * before the process exits, and that the application state is recorded + * correctly for all termination scenarios. + * + * TkpWantsExitProc tells Tcl_AppInit whether to install our custom exit proc, + * which terminates the process by calling [NSApplication terminate]. This + * does not work correctly if the process is part of an exec pipeline, so it is + * only done if the process was launched by the launcher or if both stdin and + * stdout are ttys. To disable using the custom exit proc altogether, undefine + * USE_CUSTOM_EXIT_PROC. + */ + +#if defined(USE_CUSTOM_EXIT_PROC) +static Bool doCleanupFromExit = NO; + +int TkpWantsExitProc(void) { + return doCleanupFromExit == YES; +} + +TCL_NORETURN void TkpExitProc( + void *clientdata) +{ + Bool doCleanup = doCleanupFromExit; + if (doCleanupFromExit) { + doCleanupFromExit = NO; /* prevent possible recursive call. */ + closePanels(); + } + + /* + * Tcl_Exit does not call Tcl_Finalize if there is an exit proc installed. + */ + + Tcl_Finalize(); + if (doCleanup == YES) { + [(TKApplication *)NSApp superTerminate:nil]; /* Should not return. */ + } + exit((long)clientdata); /* Convince the compiler that we don't return. */ +} +#endif + +/* + * This signal handler is installed for the SIGINT, SIGHUP and SIGTERM signals + * so that normal finalization occurs when a Tk app is killed by one of these + * signals (e.g when ^C is pressed while running Wish in the shell). It calls + * Tcl_Exit instead of the C runtime exit function called by the default handler. + * This is consistent with the Tcl_Exit manual page, which says that Tcl_Exit + * should always be called instead of exit. When Tk is killed by a signal we + * return exit status 1. + */ + +static void TkMacOSXSignalHandler(TCL_UNUSED(int)) { + + Tcl_Exit(1); +} int TkpInit( Tcl_Interp *interp) { static int initialized = 0; /* - * Since it is possible for TkInit to be called multiple times and we - * don't want to do the following initialization multiple times we protect - * against doing it more than once. + * TkpInit can be called multiple times with different interpreters. But + * The application initialization should only be done onece. */ if (!initialized) { struct stat st; - - initialized = 1; + Bool shouldOpenConsole = NO; + Bool stdinIsNullish = (!isatty(0) && + (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0))); /* * Initialize/check OS version variable for runtime checks. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 # error Mac OS X 10.6 required #endif + + initialized = 1; #ifdef TK_FRAMEWORK + /* * When Tk is in a framework, force tcl_findLibrary to look in the * framework scripts directory. * FIXME: Should we come up with a more generic way of doing this? */ @@ -309,20 +390,10 @@ TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed"); # endif } #endif - /* - * FIXME: Close stdin & stdout for remote debugging otherwise we will - * fight with gdb for stdin & stdout - */ - - if (getenv("XCNOSTDIN") != NULL) { - close(0); - close(1); - } - /* * Instantiate our NSApplication object. This needs to be done before * we check whether to open a console window. */ @@ -334,24 +405,24 @@ [NSNumber numberWithInt:-1], @"NSStringDrawingTypesetterBehavior", nil]]; [TKApplication sharedApplication]; [pool drain]; - [NSApp _setup:interp]; /* - * WARNING: The finishLaunching method runs asynchronously, apparently - * in a separate thread. This creates a race between the - * initialization of the NSApplication and the initialization of Tk. - * If Tk wins the race bad things happen with the root window (see - * below). If the NSApplication wins then an AppleEvent created during - * launch, e.g. by dropping a file icon on the application icon, will - * be delivered before the procedure meant to to handle the AppleEvent - * has been defined. This is now handled by processing the AppleEvent - * as an idle task. See tkMacOSXHLEvents.c. + * WARNING: The finishLaunching method runs asynchronously. This + * creates a race between the initialization of the NSApplication and + * the initialization of Tk. If Tk wins the race bad things happen + * with the root window (see below). If the NSApplication wins then an + * AppleEvent created during launch, e.g. by dropping a file icon on + * the application icon, will be delivered before the procedure meant + * to to handle the AppleEvent has been defined. This is handled in + * tkMacOSXHLEvents.c by scheduling a timer event to handle the + * ApplEvent later, after the required procedure has been defined. */ + [NSApp _setup:interp]; [NSApp finishLaunching]; /* * Create a Tk event source based on the Appkit event queue. */ @@ -374,51 +445,113 @@ */ Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT); /* - * If we don't have a TTY and stdin is a special character file of - * length 0, (e.g. /dev/null, which is what Finder sets when double - * clicking Wish) then use the Tk based console interpreter. + * Decide whether to open a console window. If the TK_CONSOLE + * environment variable is not defined we only show the console if + * stdin is not a tty and there is no startup script. */ - if (getenv("TK_CONSOLE") || - (!isatty(0) && (fstat(0, &st) || - (S_ISCHR(st.st_mode) && st.st_blocks == 0)))) { + if (getenv("TK_CONSOLE")) { + shouldOpenConsole = YES; + } else if (stdinIsNullish && Tcl_GetStartupScript(NULL) == NULL) { + const char *intvar = Tcl_GetVar2(interp, "tcl_interactive", + NULL, TCL_GLOBAL_ONLY); + if (intvar == NULL) { + Tcl_SetVar2(interp, "tcl_interactive", NULL, "1", + TCL_GLOBAL_ONLY); + } + +#if defined(USE_CUSTOM_EXIT_PROC) + doCleanupFromExit = YES; +#endif + + shouldOpenConsole = YES; + } + if (shouldOpenConsole) { Tk_InitConsoleChannels(interp); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); - - /* - * Only show the console if we don't have a startup script and - * tcl_interactive hasn't been set already. - */ - - if (Tcl_GetStartupScript(NULL) == NULL) { - const char *intvar = Tcl_GetVar2(interp, - "tcl_interactive", NULL, TCL_GLOBAL_ONLY); - - if (intvar == NULL) { - Tcl_SetVar2(interp, "tcl_interactive", NULL, "1", - TCL_GLOBAL_ONLY); - } - } if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { return TCL_ERROR; } + } else if (stdinIsNullish) { + + /* + * When launched as a macOS application with no console, + * redirect stderr and stdout to /dev/null. This avoids waiting + * forever for those files to become writable if the underlying + * Tcl program tries to write to them with a puts command. + */ + + FILE *null = fopen("/dev/null", "w"); + dup2(fileno(null), STDOUT_FILENO); + dup2(fileno(null), STDERR_FILENO); +#if defined(USE_CUSTOM_EXIT_PROC) + doCleanupFromExit = YES; +#endif + } + + /* + * FIXME: Close stdin & stdout for remote debugging if XCNOSTDIN is + * set. Otherwise we will fight with gdb for stdin & stdout + */ + + if (getenv("XCNOSTDIN") != NULL) { + close(0); + close(1); } /* * Initialize the NSServices object here. Apple's docs say to do this * in applicationDidFinishLaunching, but the Tcl interpreter is not * initialized until this function call. */ TkMacOSXServices_Init(interp); + + /* + * The root window has been created and mapped, but XMapWindow deferred its + * call to makeKeyAndOrderFront because the first call to XMapWindow + * occurs too early in the initialization process for that. Process idle + * tasks now, so the root window is configured, then order it front. + */ + + while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; + for (NSWindow *window in [NSApp windows]) { + TkWindow *winPtr = TkMacOSXGetTkWindow(window); + if (winPtr && Tk_IsMapped(winPtr)) { + [window makeKeyAndOrderFront:NSApp]; + break; + } + } + +# if defined(USE_CUSTOM_EXIT_PROC) + + if ((isatty(0) && isatty(1))) { + doCleanupFromExit = YES; + } + +# endif + + /* + * Install a signal handler for SIGINT, SIGHUP and SIGTERM which uses + * Tcl_Exit instead of exit so that normal cleanup takes place if a TK + * application is killed with one of these signals. + */ + + signal(SIGINT, TkMacOSXSignalHandler); + signal(SIGHUP, TkMacOSXSignalHandler); + signal(SIGTERM, TkMacOSXSignalHandler); } + /* + * Initialization steps that are needed for all interpreters. + */ + if (tkLibPath[0] != '\0') { Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY); } if (scriptPath[0] != '\0') { @@ -430,10 +563,12 @@ TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPathCmd, NULL, NULL); + MacSystrayInit(interp); + return TCL_OK; } /* *---------------------------------------------------------------------- @@ -488,17 +623,15 @@ *---------------------------------------------------------------------- */ static int TkMacOSXGetAppPathCmd( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - (void)dummy; - if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } @@ -623,15 +756,14 @@ *---------------------------------------------------------------------- */ MODULE_SCOPE void* TkMacOSXGetNamedSymbol( - const char* module, - const char* symbol) + TCL_UNUSED(const char *), + const char *symbol) { void *addr = dlsym(RTLD_NEXT, symbol); - (void)module; if (!addr) { (void) dlerror(); /* Clear dlfcn error state */ } return addr; Index: macosx/tkMacOSXInt.h ================================================================== --- macosx/tkMacOSXInt.h +++ macosx/tkMacOSXInt.h @@ -22,11 +22,13 @@ * Include platform specific public interfaces. */ #ifndef _TKMAC #include "tkMacOSX.h" +#define Cursor QDCursor #import +#undef Cursor #endif /* * Define compatibility platform types used in the structures below so that * this header can be included without pulling in the platform headers. @@ -96,43 +98,10 @@ * still tell what the correct port is after the TKWindow structure has been * freed. This actually happens when you bind destroy of a toplevel to * Destroy of a child. */ -/* - * This structure is for handling Netscape-type in process - * embedding where Tk does not control the top-level. It contains - * various functions that are needed by Mac specific routines, like - * TkMacOSXGetDrawablePort. The definitions of the function types - * are in tkMacOSX.h. - */ - -typedef struct { - Tk_MacOSXEmbedRegisterWinProc *registerWinProc; - Tk_MacOSXEmbedGetGrafPortProc *getPortProc; - Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc; - Tk_MacOSXEmbedGetClipProc *getClipProc; - Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc; -} TkMacOSXEmbedHandler; - -MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler; - -/* - * GC CGColorRef cache for tkMacOSXColor.c - */ - -typedef struct { - unsigned long cachedForeground; - CGColorRef cachedForegroundColor; - unsigned long cachedBackground; - CGColorRef cachedBackgroundColor; -} TkpGCCache; - -MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc); -MODULE_SCOPE void TkpInitGCCache(GC gc); -MODULE_SCOPE void TkpFreeGCCache(GC gc); - /* * Undef compatibility platform types defined above. */ #ifndef _TKMACPRIV @@ -178,11 +147,11 @@ #define TK_SIZE_CHANGED 2 #define TK_BOTH_CHANGED 3 #define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024 /* - * Defines for tkTextDisp.c + * Defines for tkTextDisp.c and tkFont.c */ #define TK_LAYOUT_WITH_BASE_CHUNKS 1 #define TK_DRAW_IN_CONTEXT 1 @@ -194,12 +163,11 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); MODULE_SCOPE void TkpRetainRegion(Region r); MODULE_SCOPE void TkpReleaseRegion(Region r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); -MODULE_SCOPE Bool TkTestLogDisplay(void); -MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); +MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable); /* * Include the stubbed internal platform-specific API. */ Index: macosx/tkMacOSXKeyEvent.c ================================================================== --- macosx/tkMacOSXKeyEvent.c +++ macosx/tkMacOSXKeyEvent.c @@ -2,14 +2,14 @@ * tkMacOSXKeyEvent.c -- * * This file implements functions that decode & handle keyboard events on * MacOS X. * - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2012 Adrian Robert. - * Copyright 2015-2020 Marc Culler. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2012 Adrian Robert. + * Copyright © 2015-2020 Marc Culler. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -49,11 +49,11 @@ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif NSWindow *w = [theEvent window]; TkWindow *winPtr = TkMacOSXGetTkWindow(w), *grabWinPtr, *focusWinPtr; - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin = (Tk_Window)winPtr; NSEventType type = [theEvent type]; NSUInteger virtual = [theEvent keyCode]; NSUInteger modifiers = ([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask); XEvent xEvent; @@ -81,11 +81,11 @@ grabWinPtr = winPtr->dispPtr->grabWinPtr; if (grabWinPtr) { if (winPtr->dispPtr->grabFlags || /* global grab */ grabWinPtr->mainPtr == winPtr->mainPtr){ /* same application */ winPtr =winPtr->dispPtr->focusPtr; - tkwin = (Tk_Window) winPtr; + tkwin = (Tk_Window)winPtr; } } /* * Extract the unicode character from KeyUp and KeyDown events. @@ -253,31 +253,24 @@ * Finally we can queue the XEvent, inserting a KeyRelease before a * repeated KeyPress. */ if (type == NSKeyDown && [theEvent isARepeat]) { + xEvent.xany.type = KeyRelease; Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); xEvent.xany.type = KeyPress; } - if (xEvent.xany.type == KeyPress) { - } Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); return theEvent; } @end @implementation TKContentView - --(id)init { - self = [super init]; - if (self) { - _needsRedisplay = NO; - } - return self; -} +@synthesize tkDirtyRect = _tkDirtyRect; +@synthesize tkNeedsDisplay = _tkNeedsDisplay; /* * Implementation of the NSTextInputClient protocol. */ @@ -291,11 +284,11 @@ { int i, len, state; XEvent xEvent; NSString *str, *keystr, *lower; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin = (Tk_Window)winPtr; Bool sendingIMEText = NO; str = ([aString isKindOfClass: [NSAttributedString class]]) ? [aString string] : aString; len = [str length]; @@ -327,12 +320,12 @@ * been displayed and we need to erase it before displaying the accented * letter. */ if (repRange.location == 0) { - Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; - TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL); + Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr; + Tk_SendVirtualEvent(focusWin, "TkAccentBackspace", NULL); } /* * Next we generate an XEvent for each unicode character in our string. * This string could contain non-BMP characters, for example if the @@ -401,11 +394,11 @@ - (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange replacementRange: (NSRange)repRange { TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; + Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr; NSString *temp; NSString *str; (void)selRange; str = ([aString isKindOfClass: [NSAttributedString class]]) ? @@ -437,16 +430,16 @@ /* * Use our insertText method to display the marked text. */ - TkSendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL); + Tk_SendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL); processingCompose = YES; temp = [str copy]; [self insertText: temp replacementRange:repRange]; privateWorkingText = temp; - TkSendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL); + Tk_SendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL); } - (BOOL)hasMarkedText { return privateWorkingText != nil; @@ -510,12 +503,12 @@ TKLog(@"doCommandBySelector: %@", NSStringFromSelector(aSelector)); } processingCompose = NO; if (aSelector == @selector (deleteBackward:)) { TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; - TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL); + Tk_Window focusWin = (Tk_Window)winPtr->dispPtr->focusPtr; + Tk_SendVirtualEvent(focusWin, "TkAccentBackspace", NULL); } } - (NSArray *)validAttributesForMarkedText { @@ -560,11 +553,10 @@ } return str; } /* End of NSTextInputClient implementation. */ -@synthesize needsRedisplay = _needsRedisplay; @end @implementation TKContentView(TKKeyEvent) @@ -586,11 +578,11 @@ [privateWorkingText release]; privateWorkingText = nil; processingCompose = NO; if (composeWin) { - TkSendVirtualEvent(composeWin, "TkClearIMEMarkedText", NULL); + Tk_SendVirtualEvent(composeWin, "TkClearIMEMarkedText", NULL); } } } - (void)cancelComposingText @@ -707,12 +699,12 @@ (void)pointer_mode; (void)keyboard_mode; (void)time; if (keyboardGrabWinPtr && captureWinPtr) { - NSWindow *w = TkMacOSXDrawableWindow(grab_window); - MacDrawable *macWin = (MacDrawable *) grab_window; + NSWindow *w = TkMacOSXGetNSWindowForDrawable(grab_window); + MacDrawable *macWin = (MacDrawable *)grab_window; if (w && macWin->toplevel->winPtr == (TkWindow *) captureWinPtr) { if (modalSession) { Tcl_Panic("XGrabKeyboard: already grabbed"); } @@ -786,11 +778,11 @@ * Tk_SetCaretPos -- * * This enables correct placement of the popups used for character * selection by the NSTextInputClient. It gets called by text entry * widgets whenever the cursor is drawn. It does nothing if the widget's - * NSWindow is not the current KeyWindow. Otherwise it udpates the + * NSWindow is not the current KeyWindow. Otherwise it updates the * display's caret structure and records the caret geometry in static * variables for use by the NSTextInputClient implementation. Any * widget passed to this function will be marked as being able to input * text by setting the TK_CAN_INPUT_TEXT flag. * @@ -812,11 +804,11 @@ int y, int height) { TkWindow *winPtr = (TkWindow *) tkwin; TkCaret *caretPtr = &(winPtr->dispPtr->caret); - NSWindow *w = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); + NSWindow *w = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); /* * Register this widget as being capable of text input, so we know we * should process (appropriate) key events for this window with the * NSTextInputClient protocol. Index: macosx/tkMacOSXKeyboard.c ================================================================== --- macosx/tkMacOSXKeyboard.c +++ macosx/tkMacOSXKeyboard.c @@ -1,14 +1,14 @@ /* * tkMacOSXKeyboard.c -- * * Routines to support keyboard events on the Macintosh. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright (c) 2020 Marc Culler + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -487,17 +487,16 @@ *---------------------------------------------------------------------- */ const char * TkpGetString( - TkWindow *winPtr, /* Window where event occurred: Needed to get + TCL_UNUSED(TkWindow *), /* Window where event occurred: Needed to get * input context. */ XEvent *eventPtr, /* X keyboard event. */ Tcl_DString *dsPtr) /* Uninitialized or empty string to hold * result. */ { - (void) winPtr; /*unused*/ MacKeycode macKC; char utfChars[8]; int length = 0; macKC.uint = eventPtr->xkey.keycode; @@ -586,23 +585,19 @@ *---------------------------------------------------------------------- */ char * XKeysymToString( - KeySym keysym) + TCL_UNUSED(KeySym)) { - (void)keysym; - return NULL; } KeySym XStringToKeysym( - const char* string) + TCL_UNUSED(const char *)) { - (void)string; - return NoSymbol; } /* *---------------------------------------------------------------------- @@ -664,11 +659,11 @@ if (hPtr != NULL) { unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr); macKC.x.keychar = (unsigned int) data; hPtr = Tcl_FindHashEntry(&unichar2xvirtual, INT2PTR(macKC.x.keychar)); if (hPtr != NULL) { - unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr); + data = (unsigned long) Tcl_GetHashValue(hPtr); macKC.x.xvirtual = (unsigned int) data; } } return (KeyCode) macKC.uint; } Index: macosx/tkMacOSXKeysyms.h ================================================================== --- macosx/tkMacOSXKeysyms.h +++ macosx/tkMacOSXKeysyms.h @@ -2,15 +2,15 @@ * tkMacOSXKeysyms.h -- * * Contains data used for processing key events, some of which was * moved from tkMacOSXKeyboard.c. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2020 Marc Culler + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -89,11 +89,11 @@ {111, XK_F12, NSF12FunctionKey}, {113, XK_F15, NSF15FunctionKey}, {114, XK_Help, NSHelpFunctionKey}, {115, XK_Home, NSHomeFunctionKey}, /* Fn Left */ {116, XK_Page_Up, NSPageUpFunctionKey}, /* Fn Up */ - {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Deleete */ + {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Delete */ {118, XK_F4, NSF4FunctionKey}, {119, XK_End, NSEndFunctionKey}, /* Fn Right */ {120, XK_F2, NSF2FunctionKey}, {121, XK_Page_Down, NSPageDownFunctionKey}, /* Fn Down */ {122, XK_F1, NSF1FunctionKey}, Index: macosx/tkMacOSXMenu.c ================================================================== --- macosx/tkMacOSXMenu.c +++ macosx/tkMacOSXMenu.c @@ -1,14 +1,14 @@ /* * tkMacOSXMenu.c -- * * This module implements the Mac-platform specific features of menus. * - * Copyright (c) 1996-1997 by Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright (c) 2012 Adrian Robert. + * Copyright © 1996-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2012 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -34,11 +34,11 @@ #define sl(s) ((int) (sizeof(s "") - 1)) #define SPECIALMENU(n, f) {.name = "." #n, .len = sl(#n) + 1, \ .flag = ENTRY_##f##_MENU } static const struct { - const char *name; const size_t len; const int flag; + const char *name; size_t len; int flag; } specialMenus[] = { SPECIALMENU(help, HELP), SPECIALMENU(apple, APPLE), SPECIALMENU(window, WINDOWS), {NULL, 0, 0} @@ -45,12 +45,12 @@ }; #undef SPECIALMENU #define MODIFIER(n, f) {.name = #n, .len = sl(#n), .mask = f } static const struct { - const char *name; const size_t len; const NSUInteger mask; -} modifiers[] = { + const char *name; size_t len; NSUInteger mask; +} allModifiers[] = { MODIFIER(Control, NSControlKeyMask), MODIFIER(Ctrl, NSControlKeyMask), MODIFIER(Option, NSAlternateKeyMask), MODIFIER(Opt, NSAlternateKeyMask), MODIFIER(Alt, NSAlternateKeyMask), @@ -62,11 +62,11 @@ }; #undef MODIFIER #define ACCEL(n, c) {.name = #n, .len = sl(#n), .ch = c } static const struct { - const char *name; const size_t len; const UniChar ch; + const char *name; size_t len; UniChar ch; } specialAccelerators[] = { ACCEL(PageUp, NSPageUpFunctionKey), ACCEL(PageDown, NSPageDownFunctionKey), ACCEL(Left, NSLeftArrowFunctionKey), ACCEL(Right, NSRightArrowFunctionKey), @@ -89,15 +89,11 @@ {NULL, 0, 0} }; #undef ACCEL #undef sl -static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as - * the flag that Tk is not to draw any - * menus. */ static int inPostMenu = 0; -static unsigned long defaultBg = 0, defaultFg = 0; static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0; static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0; static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0; static SInt16 menuSeparatorHeight = 0; @@ -105,10 +101,71 @@ static NSString *ParseAccelerator(const char *accel, NSUInteger *maskPtr); static int GenerateMenuSelectEvent(TKMenu *menu, NSMenuItem *menuItem); static void MenuSelectEvent(TkMenu *menuPtr); static void RecursivelyClearActiveMenu(TkMenu *menuPtr); static int ModifierCharWidth(Tk_Font tkfont); + +#pragma mark TkBackgroundLoop + +/* + * The function TkMacOSXEventsCheckProc (in tkMacOSXNotify.c) is the "check + * proc" for the macOS event source. Its job is to remove NSEvents from the + * default event queue of the NSApplication. It does this by calling the + * method [NSApp nextEventMatchingMask: untilDate: inMode: dequeue:]. As a + * rule, when the untilDate is set to the distant past this method returns + * immediately. An exception to that rule is when the next event is the button + * press on a menu button. In that case, the method starts running a nested + * event loop in the mode NSEventTrackingRunLoopMode which does not return + * until the menu has been dismissed. In Tk 8.6.10 and earlier, this meant + * that the Tk event loop would block in its call to the check proc as long as + * the menu was posted. For example, opening a menu during the Rube Goldberg + * demo would cause the animation to stop. This was also the case for + * menubuttons. + * + * The TKBackground object below works around this problem, and allows a Tk + * event loop to run while a menu is open. It is a subclass of NSThread which + * inserts requests to call [NSApp _runBackgroundLoop] onto the queue + * associated with the NSEventTrackingRunLoopMode. One of these threads gets + * started in the callback [NSApp menuBeginTracking] and cancelled in [NSApp + * menuEndTracking]. + */ + +@interface TKBackgroundLoop: NSThread +@end + +@implementation TKBackgroundLoop +- (void) main +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSArray *modeArray = [NSArray arrayWithObjects: NSEventTrackingRunLoopMode, + nil]; + while(1) { + + /* + * Queue a request to process Tk events during event tracking. + */ + + [NSApp performSelectorOnMainThread:@selector(_runBackgroundLoop) + withObject:nil + waitUntilDone:true + modes:modeArray]; + if ([self isCancelled]) { + [NSThread exit]; + } + + /* + * Allow the tracked events to be processed too. + */ + + [NSThread sleepForTimeInterval:0.001]; + } + [pool drain]; +} +@end + +TKBackgroundLoop *backgroundLoop = nil; + #pragma mark TKMenu /* * This interface is not declared in tkMacOSXPrivate.h because it requires @@ -257,16 +314,10 @@ TkMenuEntry *mePtr = (TkMenuEntry *) [menuItem tag]; if (menuPtr && mePtr) { Tcl_Interp *interp = menuPtr->interp; - /* - * Add time for errors to fire if necessary. This is sub-optimal - * but avoids issues with Tcl/Cocoa event loop integration. - */ - - //Tcl_Sleep(100); Tcl_Preserve(interp); Tcl_Preserve(menuPtr); int result = TkInvokeMenu(interp, menuPtr, mePtr->index); @@ -403,10 +454,16 @@ { (void)notification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif + if (backgroundLoop) { + [backgroundLoop cancel]; + [backgroundLoop release]; + } + backgroundLoop = [[TKBackgroundLoop alloc] init]; + [backgroundLoop start]; //TkMacOSXClearMenubarActive(); //TkMacOSXPreprocessMenu(); } - (void) menuEndTracking: (NSNotification *) notification @@ -413,21 +470,22 @@ { (void)notification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif + if (backgroundLoop) { + [backgroundLoop cancel]; + [backgroundLoop release]; + backgroundLoop = nil; + } if (!inPostMenu) { TkMacOSXClearMenubarActive(); } } - (void) tkSetMainMenu: (TKMenu *) menu { - if (gNoTkMenus) { - return; - } - TKMenu *applicationMenu = nil; if (menu) { NSMenuItem *applicationMenuItem = [menu numberOfItems] ? [menu itemAtIndex:0] : nil; @@ -619,32 +677,39 @@ NSAttributedString *attributedTitle = nil; NSImage *image = nil; NSString *keyEquivalent = @""; NSUInteger modifierMask = NSCommandKeyMask; NSMenu *submenu = nil; - NSDictionary *attributes; int imageWidth, imageHeight; GC gc = (mePtr->textGC ? mePtr->textGC : mePtr->menuPtr->textGC); - Tcl_Obj *fontPtr = (mePtr->fontPtr ? mePtr->fontPtr : - mePtr->menuPtr->fontPtr); + Tcl_Obj *fontPtr = (mePtr->fontPtr ? + mePtr->fontPtr : mePtr->menuPtr->fontPtr); + static unsigned long defaultBg, defaultFg; + static int initialized = 0; + + if (!initialized) { + TkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR); + defaultBg = tkColPtr->color.pixel; + ckfree(tkColPtr); + tkColPtr = TkpGetColor(NULL, DEF_MENU_FG); + defaultFg = tkColPtr->color.pixel; + ckfree(tkColPtr); + } if (mePtr->image) { Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight); - image = TkMacOSXGetNSImageWithTkImage(mePtr->menuPtr->display, + image = TkMacOSXGetNSImageFromTkImage(mePtr->menuPtr->display, mePtr->image, imageWidth, imageHeight); } else if (mePtr->bitmapPtr != None) { Pixmap bitmap = Tk_GetBitmapFromObj(mePtr->menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(mePtr->menuPtr->display, bitmap, &imageWidth, &imageHeight); - image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap, + image = TkMacOSXGetNSImageFromBitmap(mePtr->menuPtr->display, bitmap, gc, imageWidth, imageHeight); - if (gc->foreground == defaultFg) { - // Use a semantic foreground color by default - [image setTemplate:YES]; - } + [image setTemplate:YES]; } [menuItem setImage:image]; if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr && mePtr->labelLength) { title = [[[NSString alloc] initWithBytes:Tcl_GetString(mePtr->labelPtr) @@ -654,29 +719,54 @@ title = [NSString stringWithFormat:@"%@%C", [title substringToIndex:[title length] - 3], 0x2026]; } } [menuItem setTitle:title]; - if (strcmp(Tcl_GetString(fontPtr), "menu") || gc->foreground != defaultFg - || gc->background != defaultBg) { - attributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj( - mePtr->menuPtr->tkwin, fontPtr)); - if (gc->foreground != defaultFg || gc->background != defaultBg) { - NSColor *color = TkMacOSXGetNSColor(gc, - gc->foreground!=defaultFg? gc->foreground:gc->background); - - attributes = [[attributes mutableCopy] autorelease]; - [(NSMutableDictionary *) attributes setObject:color - forKey:NSForegroundColorAttributeName]; - } - if (attributes) { - attributedTitle = [[[NSAttributedString alloc] - initWithString:title attributes:attributes] autorelease]; - } - } + +#if 0 + + /* + * The -background and -foreground options are now ignored in Aqua. + * See ticket [635167af14]. + */ + + NSDictionary fontAttributes = TkMacOSXNSFontAttributesForFont( + Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr)); + NSMutableDictionary *attributes = [fontAttributes mutableCopy]; + static unsigned long defaultBg = 0, defaultFg = 0; + if (defaultBg == 0) { + tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR); + defaultBg = tkColPtr->color.pixel; + ckfree(tkColPtr); + } + if (defaultFg == 0) { + tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_FG); + defaultFg = tkColPtr->color.pixel; + ckfree(tkColPtr); + } + if (gc->foreground != defaultFg) { + NSColor *fgcolor = TkMacOSXGetNSColor(gc, gc->foreground); + [attributes setObject:fgcolor + forKey:NSForegroundColorAttributeName]; + } + if (gc->background != defaultBg) { + NSColor *bgcolor = TkMacOSXGetNSColor(gc, gc->background); + [attributes setObject:bgcolor + forKey:NSBackgroundColorAttributeName]; + } + +#else + + NSDictionary *attributes = TkMacOSXNSFontAttributesForFont( + Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr)); + +#endif + + attributedTitle = [[NSAttributedString alloc] initWithString:title + attributes:attributes]; [menuItem setAttributedTitle:attributedTitle]; - [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)]; + [menuItem setEnabled:(mePtr->state != ENTRY_DISABLED)]; [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY || mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)]; if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) { keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr), @@ -705,31 +795,21 @@ [submenu setTitle:title]; if ([menuItem isEnabled]) { /* - * This menuItem might have been previously disabled (XXX: - * track this), which would have disabled entries; we must - * re-enable the entries here. - */ - - int i = 0; - NSArray *itemArray = [submenu itemArray]; - - for (NSMenuItem *item in itemArray) { - TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i]; - - /* - * Work around an apparent bug where itemArray can have - * more items than the menu's entries[] array. - */ - - if (i >= (int) menuRefPtr->menuPtr->numEntries) { - break; - } - [item setEnabled: !(submePtr->state == ENTRY_DISABLED)]; - i++; + * This menuItem might have been previously disabled which + * would have disabled all of its entries; we must re-enable the + * entries here. It is important to iterate though the Tk + * entries, not the NSMenuItems, since some NSMenuItems may + * have been added by the system. See [7185d26cf4]. + */ + + for (TkSizeT i = 0; i < menuRefPtr->menuPtr->numEntries; i++) { + TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i]; + NSMenuItem *item = (NSMenuItem *) submePtr->platformEntryData; + [item setEnabled:(submePtr->state != ENTRY_DISABLED)]; } } } } } @@ -818,11 +898,11 @@ * This allows menus to appear on a separate monitor than the root * window, and to use the appearance of their parent real window * rather than the appearance of the root window. */ realWinPtr = (TkWindow*) realWin; - realWinView = TkMacOSXDrawableView(realWinPtr->privatePtr); + realWinView = TkMacOSXGetNSViewForDrawable(realWinPtr->privatePtr); if (realWinView != nil) { break; } realWin = Tk_Parent(realWin); } @@ -1039,12 +1119,12 @@ if (menuName) { Tk_Window menubar = NULL; if (winPtr->wmInfoPtr && winPtr->wmInfoPtr->menuPtr && - winPtr->wmInfoPtr->menuPtr->masterMenuPtr) { - menubar = winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin; + winPtr->wmInfoPtr->menuPtr->mainMenuPtr) { + menubar = winPtr->wmInfoPtr->menuPtr->mainMenuPtr->tkwin; } /* * Attempt to find the NSMenu directly. If that fails, ask Tk to find * it. @@ -1094,29 +1174,29 @@ static void CheckForSpecialMenu( TkMenu *menuPtr) /* The menu we are checking */ { - if (!menuPtr->masterMenuPtr->tkwin) { + if (!menuPtr->mainMenuPtr->tkwin) { return; } for (TkMenuEntry *cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr; cascadeEntryPtr; cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr->menuPtr->menuType == MENUBAR - && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) { - TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr; + && cascadeEntryPtr->menuPtr->mainMenuPtr->tkwin) { + TkMenu *mainMenuPtr = cascadeEntryPtr->menuPtr->mainMenuPtr; int i = 0; Tcl_DString ds; Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, Tk_PathName(masterMenuPtr->tkwin), -1); + Tcl_DStringAppend(&ds, Tk_PathName(mainMenuPtr->tkwin), -1); while (specialMenus[i].name) { Tcl_DStringAppend(&ds, specialMenus[i].name, specialMenus[i].len); if (strcmp(Tcl_DStringValue(&ds), - Tk_PathName(menuPtr->masterMenuPtr->tkwin)) == 0) { + Tk_PathName(menuPtr->mainMenuPtr->tkwin)) == 0) { cascadeEntryPtr->entryFlags |= specialMenus[i].flag; } else { cascadeEntryPtr->entryFlags &= ~specialMenus[i].flag; } Tcl_DStringSetLength(&ds, Tcl_DStringLength(&ds) - @@ -1154,22 +1234,22 @@ int i; *maskPtr = 0; while (1) { i = 0; - while (modifiers[i].name) { - int l = modifiers[i].len; + while (allModifiers[i].name) { + int l = allModifiers[i].len; - if (!strncasecmp(accel, modifiers[i].name, l) && + if (!strncasecmp(accel, allModifiers[i].name, l) && (accel[l] == '-' || accel[l] == '+')) { - *maskPtr |= modifiers[i].mask; + *maskPtr |= allModifiers[i].mask; accel += l+1; break; } i++; } - if (!modifiers[i].name || !*accel) { + if (!allModifiers[i].name || !*accel) { break; } } len = strlen(accel); if (len > 1) { @@ -1271,11 +1351,11 @@ /* * Do nothing if this menu is a clone. */ - if (menuPtr->tkwin == NULL || menuPtr->masterMenuPtr != menuPtr) { + if (menuPtr->tkwin == NULL || menuPtr->mainMenuPtr != menuPtr) { return; } menuSize = [(NSMenu *) menuPtr->platformData size]; Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, @@ -1389,18 +1469,18 @@ if (haveAccel && !mePtr->hideMargin) { modifierWidth = modifierCharWidth; } } else { NSUInteger modifMask = [menuItem keyEquivalentModifierMask]; - int i = 0; + int j = 0; - while (modifiers[i].name) { - if (modifMask & modifiers[i].mask) { - modifMask &= ~modifiers[i].mask; + while (allModifiers[j].name) { + if (modifMask & allModifiers[j].mask) { + modifMask &= ~allModifiers[j].mask; modifierWidth += modifierCharWidth; } - i++; + j++; } accelWidth = [[menuItem keyEquivalent] sizeWithAttributes: TkMacOSXNSFontAttributesForFont(tkfont)].width; } if (!mePtr->hideMargin) { @@ -1582,34 +1662,10 @@ } /* *---------------------------------------------------------------------- * - * Tk_MacOSXTurnOffMenus -- - * - * Turns off all the menu drawing code. This is more than just disabling - * the "menu" command, this means that Tk will NEVER touch the menubar. - * It is needed in the Plugin, where Tk does not own the menubar. - * - * Results: - * None. - * - * Side effects: - * A flag is set which will disable all menu drawing. - * - *---------------------------------------------------------------------- - */ - -void -Tk_MacOSXTurnOffMenus(void) -{ - gNoTkMenus = 1; -} - -/* - *---------------------------------------------------------------------- - * * TkpMenuInit -- * * Initializes Mac-specific menu data. * * Results: @@ -1622,28 +1678,19 @@ */ void TkpMenuInit(void) { - TkColor *tkColPtr; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) \ [nc addObserver:NSApp selector:@selector(s) name:(n) object:nil] observe(NSMenuDidBeginTrackingNotification, menuBeginTracking:); observe(NSMenuDidEndTrackingNotification, menuEndTracking:); #undef observe [NSMenuItem setUsesUserKeyEquivalents:NO]; - tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR); - defaultBg = tkColPtr->color.pixel; - ckfree(tkColPtr); - tkColPtr = TkpGetColor(NULL, DEF_MENU_FG); - defaultFg = tkColPtr->color.pixel; - ckfree(tkColPtr); - ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth, &menuMarkColumnWidth); ChkErr(GetThemeMetric, kThemeMetricMenuTextLeadingEdgeMargin, &menuTextLeadingEdgeMargin); ChkErr(GetThemeMetric, kThemeMetricMenuTextTrailingEdgeMargin, @@ -1770,17 +1817,21 @@ *---------------------------------------------------------------------- * * TkpDrawMenuEntry -- * * Draws the given menu entry at the given coordinates with the given - * attributes. + * attributes. This is a no-op on macOS since the menus are drawn by + * the Apple window manager, which also handles all events related to + * selecting menu items. This function is only called for tearoff + * menus, which are not supported on macOS but do get drawn as nearly + * invisible 1 pixel wide windows on macOS * * Results: * None. * * Side effects: - * X Server commands are executed to display the menu entry. + * None * *---------------------------------------------------------------------- */ void Index: macosx/tkMacOSXMenubutton.c ================================================================== --- macosx/tkMacOSXMenubutton.c +++ macosx/tkMacOSXMenubutton.c @@ -2,15 +2,15 @@ * tkMacOSXMenubutton.c -- * * This file implements the Macintosh specific portion of the menubutton * widget. * - * Copyright (c) 1996 by Sun Microsystems, Inc. - * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2006-2007 Daniel A. Steffen - * Copyright 2007 Revar Desmera. - * Copyright 2015 Kevin Walzer/WordTech Communications LLC. + * Copyright © 1996 Sun Microsystems, Inc. + * Copyright © 2001 Apple Computer, Inc. + * Copyright © 2006-2007 Daniel A. Steffen + * Copyright © 2007 Revar Desmera. + * Copyright © 2015 Kevin Walzer/WordTech Communications LLC. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ @@ -178,17 +178,10 @@ pixmap = (Pixmap) Tk_WindowId(tkwin); TkMacOSXComputeMenuButtonDrawParams(butPtr, dpPtr); - /* - * Set up clipping region. Make sure the we are using the port for this - * button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(pixmap); - /* * Draw the native portion of the buttons. */ TkMacOSXDrawMenuButton(mbPtr, dpPtr->gc, pixmap); @@ -362,11 +355,11 @@ /* *---------------------------------------------------------------------- * * DrawMenuButtonImageAndText -- * - * Draws the image and text associated witha button or label. + * Draws the image and text associated with a button or label. * * Results: * None. * * Side effects: @@ -565,11 +558,11 @@ if (useNewerHITools == 1) { HIRect contHIRec; static HIThemeButtonDrawInfo hiinfo; MenuButtonBackgroundDrawCB(mbPtr, 32, true); - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } hiinfo.version = 0; hiinfo.state = mbPtr->drawinfo.state; @@ -596,11 +589,11 @@ kHIThemeOrientationNormal, &contHIRec); TkMacOSXRestoreDrawingContext(&dc); MenuButtonContentDrawCB(mbPtr->btnkind, &mbPtr->drawinfo, mbPtr, 32, true); } else { - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } TkMacOSXRestoreDrawingContext(&dc); } mbPtr->lastdrawinfo = mbPtr->drawinfo; @@ -708,11 +701,11 @@ mbPtr->flags |= ACTIVE; } else { mbPtr->flags &= ~ACTIVE; } if ((buttonPtr->flags & REDRAW_PENDING) == 0) { - Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) buttonPtr); + Tcl_DoWhenIdle(TkpDisplayMenuButton, buttonPtr); buttonPtr->flags |= REDRAW_PENDING; } } } Index: macosx/tkMacOSXMenus.c ================================================================== --- macosx/tkMacOSXMenus.c +++ macosx/tkMacOSXMenus.c @@ -1,13 +1,13 @@ /* * tkMacOSXMenus.c -- * * These calls set up the default menus for Tk. * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen + * Copyright © 1995-1996 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -201,11 +201,11 @@ { (void)sender; if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog", NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) { - TkAboutDlg(); + [super orderFrontStandardAboutPanel:nil]; } else { int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { @@ -371,33 +371,10 @@ } /* *---------------------------------------------------------------------- * - * TkMacOSXInitMenus -- - * - * This procedure initializes the Macintosh menu bar. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkMacOSXInitMenus( - TCL_UNUSED(Tcl_Interp *)) -{ - [NSApp _setupMenus]; -} - -/* - *---------------------------------------------------------------------- - * * GenerateEditEvent -- * * Takes an edit menu item and posts the corasponding a virtual event to * Tk's event queue. * @@ -420,11 +397,11 @@ Tk_Window tkwin; if (!winPtr) { return; } - tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + tkwin = (Tk_Window)winPtr->dispPtr->focusPtr; if (!tkwin) { return; } bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; Index: macosx/tkMacOSXMouseEvent.c ================================================================== --- macosx/tkMacOSXMouseEvent.c +++ macosx/tkMacOSXMouseEvent.c @@ -2,12 +2,12 @@ * tkMacOSXMouseEvent.c -- * * This file implements functions that decode & handle mouse events on * MacOS X. * - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -22,10 +22,11 @@ long delta; Window window; Point global; Point local; } MouseEventData; + static Tk_Window captureWinPtr = NULL; /* Current capture window; may be * NULL. */ static int GenerateButtonEvent(MouseEventData *medPtr); static unsigned int ButtonModifiers2State(UInt32 buttonState, @@ -40,165 +41,181 @@ /* * In OS X 10.6 an NSEvent of type NSMouseMoved would always have a non-Nil * window attribute pointing to the active window. As of 10.8 this behavior * had changed. The new behavior was that if the mouse were ever moved outside * of a window, all subsequent NSMouseMoved NSEvents would have a Nil window - * attribute. To work around this the TKApplication remembers the last non-Nil - * window that it received in a mouse event. If it receives an NSEvent with a - * Nil window attribute then the saved window is used. + * attribute until the mouse returned to the window. In 11.1 it changed again. + * The window attribute can be non-nil, but referencing a window which does not + * belong to the application. */ @implementation TKApplication(TKMouseEvent) - (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent { NSWindow *eventWindow = [theEvent window]; NSEventType eventType = [theEvent type]; + NSRect viewFrame = [[eventWindow contentView] frame]; + NSPoint location = [theEvent locationInWindow]; TkWindow *winPtr = NULL, *grabWinPtr; - Tk_Window tkwin; + Tk_Window tkwin = NULL, capture, target; NSPoint local, global; - NSInteger button = -1; -#if 0 - NSTrackingArea *trackingArea = nil; - NSInteger eventNumber, clickCount, buttonNumber; -#endif - [NSEvent stopPeriodicEvents]; + NSInteger button; + Bool inTitleBar = NO; + int win_x, win_y; + unsigned int buttonState = 0; + static int validPresses = 0, ignoredPresses = 0; #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif - switch (eventType) { - case NSLeftMouseDown: - case NSRightMouseDown: - case NSOtherMouseDown: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: - button = [theEvent buttonNumber] + Button1; - case NSMouseEntered: - case NSMouseExited: - case NSCursorUpdate: - case NSLeftMouseUp: - case NSRightMouseUp: - case NSOtherMouseUp: - case NSMouseMoved: - case NSTabletPoint: - case NSTabletProximity: - case NSScrollWheel: - break; - default: /* Unrecognized mouse event. */ - return theEvent; - } - - /* - * Compute the mouse position in Tk screen coordinates (global) and in the - * Tk coordinates of its containing Tk Window (local). If a grab is in effect, - * the local coordinates should be relative to the grab window. - */ - - if (eventWindow) { - local = [theEvent locationInWindow]; - - /* - * Do not send ButtonPress XEvents for MouseDown NSEvents that start a - * resize. (The MouseUp will be handled during LiveResize.) See - * ticket [d72abe6b54]. - */ - - if (eventType == NSLeftMouseDown && - ([eventWindow styleMask] & NSResizableWindowMask) && - [NSApp macOSVersion] > 100600) { - NSRect frame = [eventWindow frame]; - if (local.x < 3 || local.x > frame.size.width - 3 || local.y < 3) { - return theEvent; - } - } - global = [eventWindow tkConvertPointToScreen: local]; - tkwin = TkpGetCapture(); - if (tkwin) { - winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXDrawableWindow(winPtr->window); - if (eventWindow) { - local = [eventWindow tkConvertPointFromScreen: global]; - } else { - return theEvent; - } - } - local.y = [eventWindow frame].size.height - local.y; - global.y = TkMacOSXZeroScreenHeight() - global.y; - } else { - - /* - * If the event has no NSWindow, the location is in screen coordinates. - */ - - global = [theEvent locationInWindow]; - tkwin = TkpGetCapture(); - if (tkwin) { - winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXDrawableWindow(winPtr->window); - } else { - eventWindow = [NSApp mainWindow]; - } + + /* + * If this event is not for a Tk toplevel, it should just be passed up the + * responder chain. However, there is an exception for synthesized events, + * which are used in testing. Those events are recognized by having their + * both the windowNumber and the eventNumber set to -1. + */ + + if (eventWindow && ![eventWindow isMemberOfClass:[TKWindow class]]) { + if ([theEvent windowNumber] != -1 || [theEvent eventNumber] != -1) + return theEvent; + } + + /* + * Check if the event is located in the titlebar. + */ + + if (eventWindow) { + inTitleBar = viewFrame.size.height < location.y; + } + + button = [theEvent buttonNumber] + Button1; + if ((button & -2) == Button2) { + button ^= 1; /* Swap buttons 2/3 */ + } + switch (eventType) { + case NSRightMouseUp: + case NSOtherMouseUp: + buttonState &= ~Tk_GetButtonMask(button); + break; + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDragged: + case NSRightMouseDown: + case NSOtherMouseDown: + buttonState |= Tk_GetButtonMask(button); + break; + case NSMouseEntered: + if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] && + !inTitleBar) { + [(TKWindow *)eventWindow setMouseInResizeArea:YES]; + } + break; + case NSMouseExited: + if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)]) { + [(TKWindow *)eventWindow setMouseInResizeArea:NO]; + break; + } + case NSLeftMouseUp: + case NSLeftMouseDown: + case NSMouseMoved: + case NSScrollWheel: +#if 0 + case NSCursorUpdate: + case NSTabletPoint: + case NSTabletProximity: +#endif + break; + default: /* This type of event is ignored. */ + return theEvent; + } + + /* + * Update the button state. We ignore left button presses that start a + * resize or occur in the title bar. See tickets [d72abe6b54] and + * [39cbacb9e8]. + */ + + if (eventType == NSLeftMouseDown) { + if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] && + [(TKWindow *) eventWindow mouseInResizeArea]) { + + /* + * When the left button is pressed in the resize area, we receive + * NSMouseDown, but when it is released we do not receive + * NSMouseUp. So ignore the event and clear the button state but + * do not change the ignoredPresses count. + */ + + buttonState &= ~Tk_GetButtonMask(Button1); + return theEvent; + } + if (inTitleBar) { + ignoredPresses++; + return theEvent; + } + validPresses++; + buttonState |= Tk_GetButtonMask(Button1); + } + if (eventType == NSLeftMouseUp) { + if (ignoredPresses > 0) { + ignoredPresses--; + } else if (validPresses > 0) { + validPresses--; + } + if (validPresses == 0) { + buttonState &= ~Tk_GetButtonMask(Button1); + } + } + + /* + * Find an appropriate NSWindow to attach to this event, and its + * associated Tk window. + */ + + capture = TkpGetCapture(); + if (capture) { + winPtr = (TkWindow *) capture; + eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (!eventWindow) { return theEvent; } - local = [eventWindow tkConvertPointFromScreen: global]; - local.y = [eventWindow frame].size.height - local.y; - global.y = TkMacOSXZeroScreenHeight() - global.y; - } - - /* - * If we still don't have a window, try using the toplevel that - * manages the NSWindow. - */ - - if (!tkwin) { - winPtr = TkMacOSXGetTkWindow(eventWindow); - tkwin = (Tk_Window) winPtr; - } - if (!tkwin) { - - /* - * We can't find a window for this event. We have to ignore it. + } else { + if (eventWindow) { + winPtr = TkMacOSXGetTkWindow(eventWindow); + } + if (!winPtr) { + eventWindow = [NSApp mainWindow]; + winPtr = TkMacOSXGetTkWindow(eventWindow); + } + } + if (!winPtr) { + + /* + * We couldn't find a Tk window for this event. We have to ignore it. */ #ifdef TK_MAC_DEBUG_EVENTS - TkMacOSXDbgMsg("tkwin == NULL"); + TkMacOSXDbgMsg("Event received with no Tk window."); #endif return theEvent; } - - /* - * Ignore the event if a local grab is in effect and the Tk event window is - * not in the grabber's subtree. - */ - - grabWinPtr = winPtr->dispPtr->grabWinPtr; - if (grabWinPtr && /* There is a grab in effect ... */ - !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */ - grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */ - Tk_Window tkwin2, tkEventWindow = Tk_CoordsToWindow(global.x, global.y, tkwin); - if (!tkEventWindow) { - return theEvent; - } - for (tkwin2 = tkEventWindow; - !Tk_IsTopLevel(tkwin2); - tkwin2 = Tk_Parent(tkwin2)) { - if (tkwin2 == (Tk_Window) grabWinPtr) { - break; - } - } - if (tkwin2 != (Tk_Window) grabWinPtr) { - return theEvent; - } - } - - /* - * Convert local from NSWindow flipped coordinates to the toplevel's - * coordinates. - */ - + tkwin = (Tk_Window) winPtr; + + /* + * Compute the mouse position in local (window) and global (screen) + * coordinates. These are Tk coordinates, meaning that the local origin is + * at the top left corner of the containing toplevel and the global origin + * is at top left corner of the primary screen. + */ + + global = [NSEvent mouseLocation]; + local = [eventWindow tkConvertPointFromScreen: global]; + global.x = floor(global.x); + global.y = floor(TkMacOSXZeroScreenHeight() - global.y); + local.x = floor(local.x); + local.y = floor([eventWindow frame].size.height - local.y); if (Tk_IsEmbedded(winPtr)) { TkWindow *contPtr = TkpGetOtherWindow(winPtr); if (Tk_IsTopLevel(contPtr)) { local.x -= contPtr->wmInfoPtr->xInParent; local.y -= contPtr->wmInfoPtr->yInParent; @@ -211,29 +228,48 @@ local.x -= winPtr->wmInfoPtr->xInParent; local.y -= winPtr->wmInfoPtr->yInParent; } /* - * Use the toplevel coordinates to find the containing Tk window. Then - * convert local into the coordinates of that window. (The converted - * local coordinates are only needed for scrollwheel events.) + * Use the local coordinates to find the Tk window which should receive + * this event. Also convert local into the coordinates of that window. + * (The converted local coordinates are only needed for scrollwheel + * events.) + */ + + target = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); + + /* + * Ignore the event if a local grab is in effect and the Tk window is + * not in the grabber's subtree. */ - int win_x, win_y; - tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); - local.x = win_x; - local.y = win_y; + grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && /* There is a grab in effect ... */ + !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */ + grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */ + Tk_Window tkwin2; + if (!target) { + return theEvent; + } + for (tkwin2 = target; + !Tk_IsTopLevel(tkwin2); + tkwin2 = Tk_Parent(tkwin2)) { + if (tkwin2 == (Tk_Window)grabWinPtr) { + break; + } + } + if (tkwin2 != (Tk_Window)grabWinPtr) { + return theEvent; + } + } /* * Generate an XEvent for this mouse event. */ - unsigned int state = 0; - if (button > 0) { - state |= TkGetButtonMask(button); - } - + unsigned int state = buttonState; NSUInteger modifiers = [theEvent modifierFlags]; if (modifiers & NSAlphaShiftKeyMask) { state |= LockMask; } @@ -257,89 +293,58 @@ } if (eventType != NSScrollWheel) { /* - * For normal mouse events, Tk_UpdatePointer will send the XEvent. + * For normal mouse events, Tk_UpdatePointer will send the appropriate + * XEvents using its cached state information. Unfortunately, it will + * also recompute the local coordinates. */ #ifdef TK_MAC_DEBUG_EVENTS - TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d", - tkwin, global.x, global.y, state); + TKLog(@"UpdatePointer %p x %.1f y %.1f %d", + target, global.x, global.y, state); #endif - Tk_UpdatePointer(tkwin, global.x, global.y, state); + + Tk_UpdatePointer(target, global.x, global.y, state); } else { + CGFloat delta; + XEvent xEvent; /* * For scroll wheel events we need to send the XEvent here. */ - CGFloat delta; - int coarseDelta; - XEvent xEvent; - xEvent.type = MouseWheelEvent; - xEvent.xbutton.x = local.x; - xEvent.xbutton.y = local.y; + xEvent.xbutton.x = win_x; + xEvent.xbutton.y = win_y; xEvent.xbutton.x_root = global.x; xEvent.xbutton.y_root = global.y; xEvent.xany.send_event = false; - xEvent.xany.display = Tk_Display(tkwin); - xEvent.xany.window = Tk_WindowId(tkwin); + xEvent.xany.display = Tk_Display(target); + xEvent.xany.window = Tk_WindowId(target); - delta = [theEvent deltaY]; + delta = [theEvent deltaY] * 120; if (delta != 0.0) { - coarseDelta = (delta > -1.0 && delta < 1.0) ? - (signbit(delta) ? -1 : 1) : lround(delta); xEvent.xbutton.state = state; - xEvent.xkey.keycode = coarseDelta; + xEvent.xkey.keycode = (delta > 0) ? ceil(delta) : floor(delta); xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - delta = [theEvent deltaX]; + delta = [theEvent deltaX] * 120; if (delta != 0.0) { - coarseDelta = (delta > -1.0 && delta < 1.0) ? - (signbit(delta) ? -1 : 1) : lround(delta); xEvent.xbutton.state = state | ShiftMask; - xEvent.xkey.keycode = coarseDelta; + xEvent.xkey.keycode = (delta > 0) ? ceil(delta) : floor(delta); xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } } return theEvent; } @end #pragma mark - - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXKeyModifiers -- - * - * Returns the current state of the modifier keys. - * - * Results: - * An OS Modifier state. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -EventModifiers -TkMacOSXModifierState(void) -{ - UInt32 keyModifiers; - int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()); - - keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() : - GetCurrentKeyModifiers(); - - return (EventModifiers) (keyModifiers & USHRT_MAX); -} /* *---------------------------------------------------------------------- * * TkMacOSXButtonKeyState -- @@ -396,12 +401,19 @@ /* * Tk on OSX supports at most 9 buttons. */ - state = (buttonState & 0x7F) * Button1Mask; - /* Handle buttons 8/9 */ + state = (buttonState & 0x079) * Button1Mask; + /* Handle swapped buttons 2/3 */ + if (buttonState & 0x02) { + state |= Button3Mask; + } + if (buttonState & 0x04) { + state |= Button2Mask; + } + /* Handle buttons 8/9 */ state |= (buttonState & 0x180) * (Button8Mask >> 7); if (keyModifiers & alphaLock) { state |= LockMask; } @@ -466,12 +478,12 @@ if (getGlobal || getLocal) { NSPoint global = [NSEvent mouseLocation]; if (getLocal) { - MacDrawable *macWin = (MacDrawable *) w; - NSWindow *win = TkMacOSXDrawableWindow(w); + MacDrawable *macWin = (MacDrawable *)w; + NSWindow *win = TkMacOSXGetNSWindowForDrawable(w); if (win) { NSPoint local; local = [win tkConvertPointFromScreen:global]; @@ -505,11 +517,11 @@ * * Results: * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ @@ -543,11 +555,11 @@ * * Results: * True if event(s) are generated, false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ @@ -556,12 +568,12 @@ int x, /* X location of mouse, */ int y, /* Y location of mouse. */ Window window, /* X Window containing button event. */ unsigned int state) /* Button Key state suitable for X event. */ { - MacDrawable *macWin = (MacDrawable *) window; - NSWindow *win = TkMacOSXDrawableWindow(window); + MacDrawable *macWin = (MacDrawable *)window; + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); MouseEventData med; bzero(&med, sizeof(MouseEventData)); med.state = state; med.window = window; @@ -595,11 +607,11 @@ * * Results: * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ @@ -609,11 +621,11 @@ { Tk_Window tkwin; int dummy; TkDisplay *dispPtr; -#if UNUSED +#ifdef UNUSED /* * ButtonDown events will always occur in the front window. ButtonUp * events, however, may occur anywhere on the screen. ButtonUp events * should only be sent to Tk if in the front window or during an implicit @@ -638,55 +650,44 @@ Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); return true; } +/* + *---------------------------------------------------------------------- + * + * TkpWarpPointer -- + * + * Move the mouse cursor to the screen location specified by the warpX and + * warpY fields of a TkDisplay. + * + * Results: + * None + * + * Side effects: + * The mouse cursor is moved. + * + *---------------------------------------------------------------------- + */ + void TkpWarpPointer( TkDisplay *dispPtr) { CGPoint pt; - NSPoint loc; - int wNum; if (dispPtr->warpWindow) { int x, y; - TkWindow *winPtr = (TkWindow *) dispPtr->warpWindow; - TkWindow *topPtr = winPtr->privatePtr->toplevel->winPtr; - NSWindow *w = TkMacOSXDrawableWindow(winPtr->window); - wNum = [w windowNumber]; Tk_GetRootCoords(dispPtr->warpWindow, &x, &y); pt.x = x + dispPtr->warpX; pt.y = y + dispPtr->warpY; - loc.x = dispPtr->warpX; - loc.y = Tk_Height(topPtr) - dispPtr->warpY; - } else { - wNum = 0; - pt.x = loc.x = dispPtr->warpX; - pt.y = dispPtr->warpY; - loc.y = TkMacOSXZeroScreenHeight() - pt.y; - } - - /* - * Generate an NSEvent of type NSMouseMoved. - * - * It is not clear why this is necessary. For example, calling - * event generate $w -warp 1 -x $X -y $Y - * will cause two events to be added to the Tcl queue. - */ - - CGWarpMouseCursorPosition(pt); - NSEvent *warpEvent = [NSEvent mouseEventWithType:NSMouseMoved - location:loc - modifierFlags:0 - timestamp:GetCurrentEventTime() - windowNumber:wNum - context:nil - eventNumber:0 - clickCount:1 - pressure:0.0]; - [NSApp postEvent:warpEvent atStart:NO]; + } else { + pt.x = dispPtr->warpX; + pt.y = dispPtr->warpY; + } + + CGWarpMouseCursorPosition(pt); } /* *---------------------------------------------------------------------- * @@ -710,12 +711,11 @@ TkWindow *winPtr) /* Capture window, or NULL. */ { while (winPtr && !Tk_IsTopLevel(winPtr)) { winPtr = winPtr->parentPtr; } - [NSEvent stopPeriodicEvents]; - captureWinPtr = (Tk_Window) winPtr; + captureWinPtr = (Tk_Window)winPtr; } /* *---------------------------------------------------------------------- * Index: macosx/tkMacOSXNotify.c ================================================================== --- macosx/tkMacOSXNotify.c +++ macosx/tkMacOSXNotify.c @@ -2,23 +2,50 @@ * tkMacOSXNotify.c -- * * This file contains the implementation of a tcl event source * for the AppKit event loop. * - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright 2015 Marc Culler. + * Copyright © 1995-1997 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2015 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXInt.h" #include "tkMacOSXConstants.h" -#include +#if TCL_MAJOR_VERSION < 9 +#undef Tcl_MacOSXNotifierAddRunLoopMode +#ifdef USE_TCL_STUBS +#ifdef __cplusplus +extern "C" { +#endif +/* Little hack to eliminate the need for "tclInt.h" here: + Just copy a small portion of TclIntPlatStubs, just + enough to make it work. See [600b72bfbc] */ +typedef struct TclIntPlatStubs { + int magic; + void *hooks; + void (*dummy[19]) (void); /* dummy entries 0-18, not used */ + void (*tclMacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 19 */ +} TclIntPlatStubs; +extern const TclIntPlatStubs *tclIntPlatStubsPtr; +#ifdef __cplusplus +} +#endif +#define Tcl_MacOSXNotifierAddRunLoopMode \ + (tclIntPlatStubsPtr->tclMacOSXNotifierAddRunLoopMode) /* 19 */ +#elif TCL_MINOR_VERSION < 7 + extern void TclMacOSXNotifierAddRunLoopMode(const void *runLoopMode); +# define Tcl_MacOSXNotifierAddRunLoopMode TclMacOSXNotifierAddRunLoopMode +#else + extern void Tcl_MacOSXNotifierAddRunLoopMode(const void *runLoopMode); +#endif +#endif #import /* This is not used for anything at the moment. */ typedef struct ThreadSpecificData { int initialized; @@ -154,10 +181,11 @@ * course, no movement is occurring. The popup is not movable and is just * being closed. The bug has been reported to Apple. If they ever fix it, * this block should be removed. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500 if ([theEvent type] == NSAppKitDefined) { static Bool aWindowIsMoving = NO; switch([theEvent subtype]) { case 20: aWindowIsMoving = YES; @@ -172,19 +200,28 @@ } default: break; } } +#endif + [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; #ifdef TK_MAC_DEBUG_EVENTS fprintf(stderr, "Sending event of type %d\n", (int)[theEvent type]); DebugPrintQueue(); #endif } + +- (void) _runBackgroundLoop +{ + while(Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)){ + TkMacOSXDrawAllViews(NULL); + } +} @end #pragma mark - /* @@ -199,19 +236,17 @@ * None. * *---------------------------------------------------------------------- */ -NSString * +static NSString * GetRunLoopMode(NSModalSession modalSession) { NSString *runLoopMode = nil; if (modalSession) { runLoopMode = NSModalPanelRunLoopMode; - } else if (TkpGetCapture()) { - runLoopMode = NSEventTrackingRunLoopMode; } if (!runLoopMode) { runLoopMode = [[NSRunLoop currentRunLoop] currentMode]; } if (!runLoopMode) { @@ -259,13 +294,12 @@ "first [load] of TkAqua has to occur in the main thread!"); } Tcl_CreateEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, NULL); TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL); - Tcl_SetServiceMode(TCL_SERVICE_ALL); - TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode); - TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode); + Tcl_MacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode); + Tcl_MacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode); } } } /* @@ -298,72 +332,171 @@ } /* *---------------------------------------------------------------------- * + * TkMacOSXDrawAllViews -- + * + * This static function is meant to be run as an idle task. It attempts + * to redraw all views which have the tkNeedsDisplay property set to YES. + * This relies on a feature of [NSApp nextEventMatchingMask: ...] which + * is undocumented, namely that it sometimes blocks and calls drawRect + * for all views that need display before it returns. We call it with + * deQueue=NO so that it will not change anything on the AppKit event + * queue, because we only want the side effect that it runs drawRect. The + * only time when any NSViews have the needsDisplay property set to YES + * is during execution of this function. + * + * The reason for running this function as an idle task is to try to + * arrange that all widgets will be fully configured before they are + * drawn. Any idle tasks that might reconfigure them should be higher on + * the idle queue, so they should be run before the display procs are run + * by drawRect. + * + * If this function is called directly with non-NULL clientData parameter + * then the int which it references will be set to the number of windows + * that need display, but the needsDisplay property of those windows will + * not be changed. + * + * Results: + * None. + * + * Side effects: + * Parts of windows may get redrawn. + * + *---------------------------------------------------------------------- + */ + +void +TkMacOSXDrawAllViews( + ClientData clientData) +{ + int count = 0, *dirtyCount = (int *)clientData; + + for (NSWindow *window in [NSApp windows]) { + if ([[window contentView] isMemberOfClass:[TKContentView class]]) { + TKContentView *view = [window contentView]; + if ([view tkNeedsDisplay]) { + count++; + if (dirtyCount) { + continue; + } + [view setNeedsDisplayInRect:[view tkDirtyRect]]; + } + } else { + [window displayIfNeeded]; + } + } + if (dirtyCount) { + *dirtyCount = count; + } + [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantPast] + inMode:GetRunLoopMode(TkMacOSXGetModalSession()) + dequeue:NO]; + for (NSWindow *window in [NSApp windows]) { + if ([[window contentView] isMemberOfClass:[TKContentView class]]) { + TKContentView *view = [window contentView]; + + /* + * If we did not run drawRect, we set needsDisplay back to NO. + * Note that if drawRect did run it may have added to Tk's dirty + * rect, due to attempts to draw outside of drawRect's dirty rect. + */ + + if ([view needsDisplay]) { + [view setNeedsDisplay: NO]; + } + } + } + [NSApp setNeedsToDraw:NO]; +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXEventsSetupProc -- * * This procedure implements the setup part of the MacOSX event source. It - * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsProc to + * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsCheckProc to * process all queued NSEvents. In our case, all we need to do is to set * the Tcl MaxBlockTime to 0 before starting the loop to process all * queued NSEvents. * * Results: * None. * * Side effects: * - * If NSEvents are queued, then the maximum block time will be set to 0 to - * ensure that control returns immediately to Tcl. + * If NSEvents are queued, or if there is any drawing that needs to be + * done, then the maximum block time will be set to 0 to ensure that + * Tcl_WaitForEvent returns immediately. * *---------------------------------------------------------------------- */ +#define TICK 200 +static Tcl_TimerToken ticker = NULL; + +static void +Heartbeat( + TCL_UNUSED(ClientData)) +{ + + if (ticker) { + ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); + } +} + +static const Tcl_Time zeroBlockTime = { 0, 0 }; + static void TkMacOSXEventsSetupProc( ClientData dummy, int flags) { - static Bool havePeriodicEvents = NO; NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; (void)dummy; /* * runloopMode will be nil if we are in a Tcl event loop. */ if (flags & TCL_WINDOW_EVENTS && !runloopMode) { - static const Tcl_Time zeroBlockTime = { 0, 0 }; + [NSApp _resetAutoreleasePool]; - /* - * Call this with dequeue=NO -- just checking if the queue is empty. - */ + /* + * After calling this setup proc, Tcl_DoOneEvent will call + * Tcl_WaitForEvent. Then it will call check proc to collect the + * events and translate them into XEvents. + * + * If we have any events waiting or if there is any drawing to be done + * we want Tcl_WaitForEvent to return immediately. So we set the block + * time to 0 and stop the heartbeat. + */ NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:NO]; - if (currentEvent) { - if (currentEvent.type > 0) { - Tcl_SetMaxBlockTime(&zeroBlockTime); - [NSEvent stopPeriodicEvents]; - havePeriodicEvents = NO; - } - } else if (!havePeriodicEvents){ + if ((currentEvent) || [NSApp needsToDraw] ) { + Tcl_SetMaxBlockTime(&zeroBlockTime); + Tcl_DeleteTimerHandler(ticker); + ticker = NULL; + } else if (ticker == NULL) { /* - * When the user is not generating events we schedule a "hearbeat" - * event to fire every 0.1 seconds. This helps to make the vwait - * command more responsive when there is no user input, e.g. when - * running the test suite. + * When the user is not generating events we schedule a "heartbeat" + * TimerHandler to fire every 200 milliseconds. The handler does + * nothing, but when its timer fires it causes Tcl_WaitForEvent to + * return. This helps avoid hangs when calling vwait during the + * non-regression tests. */ - havePeriodicEvents = YES; - [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1]; + ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); } } } /* @@ -383,15 +516,15 @@ * *---------------------------------------------------------------------- */ static void TkMacOSXEventsCheckProc( - ClientData dummy, + TCL_UNUSED(ClientData), int flags) { NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; - (void)dummy; + int eventsFound = 0; /* * runloopMode will be nil if we are in a Tcl event loop. */ @@ -426,21 +559,23 @@ currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) dequeue:YES]; if (currentEvent) { + /* * Generate Xevents. */ - int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent]; - Tcl_SetServiceMode(oldServiceMode); if (processedEvent) { + eventsFound++; + #ifdef TK_MAC_DEBUG_EVENTS TKLog(@" event: %@", currentEvent); #endif + if (modalSession) { [NSApp _modalSession:modalSession sendEvent:currentEvent]; } else { [NSApp sendEvent:currentEvent]; } @@ -453,10 +588,29 @@ /* * Now we can unlock the pool. */ [NSApp _unlockAutoreleasePool]; + + /* + * Add an idle task to the end of the idle queue which will redisplay + * all of our dirty windows. We want this to happen after all other + * idle tasks have run so that all widgets will be configured before + * they are displayed. The drawRect method "borrows" the idle queue + * while drawing views. That is, it sends expose events which cause + * display procs to be posted as idle tasks and then runs an inner + * event loop to processes those idle tasks. We are trying to arrange + * for the idle queue to be empty when it starts that process and empty + * when it finishes. + */ + + int dirtyCount = 0; + TkMacOSXDrawAllViews(&dirtyCount); + if (dirtyCount > 0) { + Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + } } } /* * Local Variables: Index: macosx/tkMacOSXPort.h ================================================================== --- macosx/tkMacOSXPort.h +++ macosx/tkMacOSXPort.h @@ -33,20 +33,14 @@ #endif #include #ifndef _TCL # include #endif -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H +#if HAVE_SYS_TIME_H # include -# else -# include -# endif #endif +#include #if HAVE_INTTYPES_H # include #endif #include #if defined(__GNUC__) && !defined(__cplusplus) @@ -129,31 +123,40 @@ /* * Turn off Tk double-buffering as Aqua windows are already double-buffered. */ #define TK_NO_DOUBLE_BUFFERING 1 - -/* - * Magic pixel code values for system colors. - * - * NOTE: values must be kept in sync with indices into the - * systemColorMap array in tkMacOSXColor.c ! - */ - -#define TRANSPARENT_PIXEL 30 -#define APPEARANCE_PIXEL 52 -#define PIXEL_MAGIC ((unsigned char) 0x69) - -/* - * The following macro returns the pixel value that corresponds to the - * 16-bit RGB values in the given XColor structure. - * The format is: (PIXEL_MAGIC << 24) | (R << 16) | (G << 8) | B - * where each of R, G and B is the high order byte of a 16-bit component. - */ - -#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \ - | (((p)->red >> 8) & 0xff)) << 8) \ - | (((p)->green >> 8) & 0xff)) << 8) \ - | (((p)->blue >> 8) & 0xff)) - +#define TK_HAS_DYNAMIC_COLORS 1 +#define TK_DYNAMIC_COLORMAP 0x0fffffff + +/* + * Inform tkImgPhInstance.c that our tkPutImage can render an image with an + * alpha channel directly into a window. + */ + +#define TKPUTIMAGE_CAN_BLEND + +/* + * Used by xcolor.c + */ + +MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green, + unsigned long blue); +#define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8)) + +/* + * Used by tkWindow.c + */ + +MODULE_SCOPE void TkMacOSXHandleMapOrUnmap(Tk_Window tkwin, XEvent *event); + +#define TkpHandleMapOrUnmap(tkwin, event) TkMacOSXHandleMapOrUnmap(tkwin, event) + +/* + * Used by tkAppInit + */ + +#define USE_CUSTOM_EXIT_PROC +EXTERN int TkpWantsExitProc(void); +EXTERN TCL_NORETURN void TkpExitProc(void *); #endif /* _TKMACPORT */ Index: macosx/tkMacOSXPrivate.h ================================================================== --- macosx/tkMacOSXPrivate.h +++ macosx/tkMacOSXPrivate.h @@ -1,12 +1,13 @@ /* * tkMacOSXPrivate.h -- * * Macros and declarations that are purely internal & private to TkAqua. * - * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright 2008-2009, Apple Inc. + * Copyright © 2005-2009 Daniel A. Steffen + * Copyright © 2008-2009 Apple Inc. + * Copyright © 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id$ @@ -22,11 +23,13 @@ #ifndef __clang__ #define instancetype id #endif #define TextStyle MacTextStyle +#define Cursor QDCursor #import +#undef Cursor #import #ifndef NO_CARBON_H #import #endif #undef TextStyle @@ -100,15 +103,15 @@ /* * Macro to do very common check for noErr return from given API and output * debug message in case of failure. */ #define ChkErr(f, ...) ({ \ - OSStatus err = f(__VA_ARGS__); \ - if (err != noErr) { \ - TkMacOSXDbgOSErr(f, err); \ + OSStatus err_ = f(__VA_ARGS__); \ + if (err_ != noErr) { \ + TkMacOSXDbgOSErr(f, err_); \ } \ - err;}) + err_;}) #else /* TK_MAC_DEBUG */ #define TKLog(f, ...) #define TkMacOSXDbgMsg(m, ...) #define TkMacOSXDbgOSErr(f, err) @@ -223,14 +226,10 @@ MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect( const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape( HIMutableShapeRef inDestShape, HIShapeRef inSrcShape); -#if 0 -MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape, - const CGRect *inRect); -#endif MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect( HIMutableShapeRef inShape, const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape, const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1, @@ -247,49 +246,35 @@ MODULE_SCOPE CGFloat TkMacOSXZeroScreenTop(); MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); -MODULE_SCOPE int TkMacOSXGenerateFocusEvent(TkWindow *winPtr, - int activeFlag); -MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); -MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); -MODULE_SCOPE NSBitmapImageRep* TkMacOSXBitmapRepFromDrawableRect(Drawable drawable, - int x, int y, unsigned int width, unsigned int height); -MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithXImage(XImage *image); MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef context, CGImageRef image, unsigned long imageForeground, unsigned long imageBackground, CGRect imageBounds, CGRect srcBounds, CGRect dstBounds); MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, - int useCG, TkMacOSXDrawingContext *dcPtr); + TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel, CGContextRef context); -MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, - NSWindow *window, int fullscreen, - Tcl_Interp *interp); -MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, - int active); -MODULE_SCOPE NSWindow* TkMacOSXDrawableWindow(Drawable drawable); -MODULE_SCOPE NSView* TkMacOSXDrawableView(MacDrawable *macWin); +#define TkMacOSXGetTkWindow(window) (TkWindow *)Tk_MacOSXGetTkWindow(window) +#define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow *)Tk_MacOSXGetNSWindowForDrawable(drawable)) +#define TkMacOSXGetNSViewForDrawable(macWin) ((NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin))) +#define TkMacOSXGetCGContextForDrawable(drawable) ((CGContextRef)Tk_MacOSXGetCGContextForDrawable(drawable)) MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds); MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable); MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view, HIShapeRef rgn); -MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable); -MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithDrawable(Drawable drawable); -MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithTkImage(Display *display, +MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display, Tk_Image image, int width, int height); -MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display, +MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display, Pixmap bitmap, GC gc, int width, int height); -MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel); MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel); -MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w); MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont); MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont); MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void); MODULE_SCOPE void TkMacOSXSelDeadWindow(TkWindow *winPtr); MODULE_SCOPE void TkMacOSXApplyWindowAttributes(TkWindow *winPtr, @@ -302,13 +287,19 @@ Tcl_Obj *const objv[]); MODULE_SCOPE void TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc, int inset, int thickness); MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp); MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); + Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); +MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, + NSRect *bounds); +MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); +MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); +MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); +MODULE_SCOPE int MacSystrayInit(Tcl_Interp *); + #pragma mark Private Objective-C Classes #define VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) @@ -335,20 +326,27 @@ TKMenu *_defaultMainMenu, *_defaultApplicationMenu; NSMenuItem *_demoMenuItem; NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems; NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems; NSAutoreleasePool *_mainPool; + NSThread *_backgoundLoop; + #ifdef __i386__ /* The Objective C runtime used on i386 requires this. */ int _poolLock; int _macOSVersion; /* 10000 * major + 100*minor */ Bool _isDrawing; + Bool _needsToDraw; + Bool _isSigned; #endif + } @property int poolLock; @property int macOSVersion; @property Bool isDrawing; +@property Bool needsToDraw; +@property Bool isSigned; @end @interface TKApplication(TKInit) - (NSString *)tkFrameworkImagePath:(NSString*)image; - (void)_resetAutoreleasePool; @@ -370,10 +368,11 @@ - (void) _setupMenus; @end @interface NSApplication(TKNotify) /* We need to declare this hidden method. */ - (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event; +- (void) _runBackgroundLoop; @end @interface TKApplication(TKEvent) - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKMouseEvent) @@ -386,10 +385,11 @@ - (void)tkProvidePasteboard:(TkDisplay *)dispPtr; - (void)tkCheckPasteboard; @end @interface TKApplication(TKHLEvents) - (void) terminate: (id) sender; +- (void) superTerminate: (id) sender; - (void) preferences: (id) sender; - (void) handleQuitApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent; - (void) handleOpenApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent; @@ -415,22 +415,26 @@ @interface TKContentView : NSView { @private NSString *privateWorkingText; - Bool _needsRedisplay; + Bool _tkNeedsDisplay; + NSRect _tkDirtyRect; } -@property Bool needsRedisplay; +@property Bool tkNeedsDisplay; +@property NSRect tkDirtyRect; @end @interface TKContentView(TKKeyEvent) - (void) deleteWorkingText; - (void) cancelComposingText; @end @interface TKContentView(TKWindowEvent) -- (void) generateExposeEvents: (HIShapeRef) shape; +- (void) addTkDirtyRect: (NSRect) rect; +- (void) clearTkDirtyRect; +- (void) generateExposeEvents: (NSRect) rect; - (void) tkToolbarButton: (id) sender; @end @interface NSWindow(TKWm) - (NSPoint) tkConvertPointToScreen:(NSPoint)point; @@ -437,20 +441,44 @@ - (NSPoint) tkConvertPointFromScreen:(NSPoint)point; @end VISIBILITY_HIDDEN @interface TKWindow : NSWindow +{ +#ifdef __i386__ + /* The Objective C runtime used on i386 requires this. */ + Bool _mouseInResizeArea; + Window _tkWindow; +#endif +} +@property Bool mouseInResizeArea; +@property Window tkWindow; @end @interface TKWindow(TKWm) - (void) tkLayoutChanged; @end -@interface NSDrawerWindow : NSWindow +@interface TKDrawerWindow : NSWindow { id _i1, _i2; +#ifdef __i386__ + /* The Objective C runtime used on i386 requires this. */ + Window _tkWindow; +#endif +} +@property Window tkWindow; +@end + +@interface TKPanel : NSPanel +{ +#ifdef __i386__ + /* The Objective C runtime used on i386 requires this. */ + Window _tkWindow; +#endif } +@property Window tkWindow; @end #pragma mark NSMenu & NSMenuItem Utilities @interface NSMenu(TKUtils) @@ -534,10 +562,11 @@ @interface TKNSString:NSString { @private Tcl_DString _ds; NSString *_string; + const char *_UTF8String; } @property const char *UTF8String; @property (readonly) Tcl_DString DString; - (instancetype)initWithTclUtfBytes:(const void *)bytes length:(NSUInteger)len; Index: macosx/tkMacOSXRegion.c ================================================================== --- macosx/tkMacOSXRegion.c +++ macosx/tkMacOSXRegion.c @@ -1,19 +1,29 @@ /* * tkMacOSXRegion.c -- * * Implements X window calls for manipulating regions * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright © 1995-1996 Sun Microsystems, Inc. + * Copyright © 2001-2009, Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" +static void RetainRegion(TkRegion r); +static void ReleaseRegion(TkRegion r); + +#ifdef DEBUG +static int totalRegions = 0; +static int totalRegionRetainCount = 0; +#define DebugLog(msg, ...) fprintf(stderr, (msg), ##__VA_ARGS__) +#else +#define DebugLog(msg, ...) +#endif /* *---------------------------------------------------------------------- * @@ -32,11 +42,14 @@ */ Region XCreateRegion(void) { - return (Region) HIShapeCreateMutable(); + Region region = (Region) HIShapeCreateMutable(); + DebugLog("Created region: total regions = %d\n", ++totalRegions); + RetainRegion(region); + return region; } /* *---------------------------------------------------------------------- * @@ -57,11 +70,12 @@ int XDestroyRegion( Region r) { if (r) { - CFRelease(r); + DebugLog("Destroyed region: total regions = %d\n", --totalRegions); + ReleaseRegion(r); } return Success; } /* @@ -318,11 +332,11 @@ } /* *---------------------------------------------------------------------- * - * TkpRetainRegion -- + * RetainRegion -- * * Increases reference count of region. * * Results: * None. @@ -331,21 +345,22 @@ * None. * *---------------------------------------------------------------------- */ -void -TkpRetainRegion( +static void +RetainRegion( Region r) { CFRetain(r); + DebugLog("Retained region: total count is %d\n", ++totalRegionRetainCount); } /* *---------------------------------------------------------------------- * - * TkpReleaseRegion -- + * ReleaseRegion -- * * Decreases reference count of region. * * Results: * None. @@ -354,15 +369,16 @@ * May free memory. * *---------------------------------------------------------------------- */ -void -TkpReleaseRegion( +static void +ReleaseRegion( Region r) { CFRelease(r); + DebugLog("Released region: total count is %d\n", --totalRegionRetainCount); } /* *---------------------------------------------------------------------- * @@ -461,11 +477,11 @@ /* *---------------------------------------------------------------------- * * TkMacOSXHIShapeCreateEmpty, TkMacOSXHIShapeCreateMutableWithRect, - * TkMacOSXHIShapeSetWithShape, TkMacOSXHIShapeSetWithRect, + * TkMacOSXHIShapeSetWithShape, * TkMacOSHIShapeDifferenceWithRect, TkMacOSHIShapeUnionWithRect, * TkMacOSHIShapeUnion -- * * Wrapper functions for missing/buggy HIShape API * @@ -500,26 +516,10 @@ result = HIShapeSetWithShape(inDestShape, inSrcShape); return result; } -#if 0 -OSStatus -TkMacOSXHIShapeSetWithRect( - HIMutableShapeRef inShape, - const CGRect *inRect) -{ - OSStatus result; - HIShapeRef rgn = HIShapeCreateWithRect(inRect); - - result = TkMacOSXHIShapeSetWithShape(inShape, rgn); - CFRelease(rgn); - - return result; -} -#endif - OSStatus TkMacOSHIShapeDifferenceWithRect( HIMutableShapeRef inShape, const CGRect *inRect) { Index: macosx/tkMacOSXScale.c ================================================================== --- macosx/tkMacOSXScale.c +++ macosx/tkMacOSXScale.c @@ -2,14 +2,14 @@ * tkMacOSXScale.c -- * * This file implements the Macintosh specific portion of the * scale widget. * - * Copyright (c) 1996 by Sun Microsystems, Inc. - * Copyright (c) 1998-2000 by Scriptics Corporation. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright 2008-2009, Apple Inc. + * Copyright © 1996 Sun Microsystems, Inc. + * Copyright © 1998-2000 Scriptics Corporation. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2008-2009 Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -147,12 +147,10 @@ int result; char string[TCL_DOUBLE_SPACE]; MacScale *macScalePtr = clientData; Rect r; WindowRef windowRef; - CGrafPtr destPort, savePort; - Boolean portChanged; MacDrawable *macDraw; SInt32 initialValue, minValue, maxValue; UInt16 numTicks; Tcl_DString buf; @@ -213,15 +211,12 @@ /* * Set up port for drawing Macintosh control. */ - macDraw = (MacDrawable *) Tk_WindowId(tkwin); - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); - windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); + macDraw = (MacDrawable *)Tk_WindowId(tkwin); + windowRef = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); /* * Create Macintosh control. */ @@ -291,13 +286,10 @@ SetControlVisibility(macScalePtr->scaleHandle, true, true); HiliteControl(macScalePtr->scaleHandle, 0); Draw1Control(macScalePtr->scaleHandle); - if (portChanged) { - QDSwapPort(savePort, NULL); - } done: scalePtr->flags &= ~REDRAW_ALL; } /* @@ -325,18 +317,14 @@ { MacScale *macScalePtr = (MacScale *) scalePtr; ControlPartCode part; Point where; Rect bounds; - CGrafPtr destPort, savePort; - Boolean portChanged; #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("TkpScaleElement"); #endif - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin)); - portChanged = QDSwapPort(destPort, &savePort); /* * All of the calculations in this procedure mirror those in * DisplayScrollbar. Be sure to keep the two consistent. */ @@ -344,14 +332,10 @@ TkMacOSXWinBounds((TkWindow *) scalePtr->tkwin, &bounds); where.h = x + bounds.left; where.v = y + bounds.top; part = TestControl(macScalePtr->scaleHandle, where); - if (portChanged) { - QDSwapPort(savePort, NULL); - } - #ifdef TK_MAC_DEBUG_SCALE fprintf (stderr,"ScalePart %d, pos ( %d %d )\n", part, where.h, where.v ); #endif switch (part) { @@ -399,12 +383,10 @@ { MacScale *macScalePtr = (MacScale *) clientData; Point where; Rect bounds; int part; - CGrafPtr destPort, savePort; - Boolean portChanged; #ifdef TK_MAC_DEBUG_SCALE fprintf(stderr,"MacScaleEventProc\n" ); #endif @@ -412,18 +394,10 @@ * To call Macintosh control routines we must have the port set to the * window containing the control. We will then test which part of the * control was hit and act accordingly. */ - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); - - TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); - where.h = eventPtr->xbutton.x + bounds.left; - where.v = eventPtr->xbutton.y + bounds.top; -#ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("calling TestControl"); #endif part = TestControl(macScalePtr->scaleHandle, where); if (part == 0) { return; @@ -445,14 +419,10 @@ * The HandleControlClick call will "eat" the ButtonUp event. We now * generate a ButtonUp event so Tk will unset implicit grabs etc. */ TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin)); - - if (portChanged) { - QDSwapPort(savePort, NULL); - } } /* *-------------------------------------------------------------- * Index: macosx/tkMacOSXScrlbr.c ================================================================== --- macosx/tkMacOSXScrlbr.c +++ macosx/tkMacOSXScrlbr.c @@ -2,15 +2,15 @@ * tkMacOSXScrollbar.c -- * * This file implements the Macintosh specific portion of the scrollbar * widget. * - * Copyright (c) 1996 by Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. - * Copyright (c) 2006-2009 Daniel A. Steffen - * Copyright (c) 2015 Kevin Walzer/WordTech Commununications LLC. - * Copyright (c) 2018-2019 Marc Culler + * Copyright © 1996 Sun Microsystems, Inc. + * Copyright © 2001-2009 Apple Inc. + * Copyright © 2006-2009 Daniel A. Steffen + * Copyright © 2015 Kevin Walzer/WordTech Commununications LLC. + * Copyright © 2018-2019 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -172,12 +172,12 @@ static void drawMacScrollbar( TkScrollbar *scrollPtr, MacScrollbar *msPtr, CGContextRef context) { - MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); - NSView *view = TkMacOSXDrawableView(macWin); + Drawable d = Tk_WindowId(scrollPtr->tkwin); + NSView *view = TkMacOSXGetNSViewForDrawable(d); CGPathRef path; CGPoint inner[2], outer[2], thumbOrigin; CGSize thumbSize; CGRect troughBounds = msPtr->info.bounds; troughBounds.origin.y = [view bounds].size.height - @@ -256,16 +256,16 @@ if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } - MacDrawable *macWin = (MacDrawable *) winPtr->window; - NSView *view = TkMacOSXDrawableView(macWin); + MacDrawable *macWin = (MacDrawable *)winPtr->window; + NSView *view = TkMacOSXGetNSViewForDrawable(macWin); if ((view == NULL) || (macWin->flags & TK_DO_NOT_DRAW) - || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { + || !TkMacOSXSetupDrawingContext((Drawable)macWin, NULL, &dc)) { return; } /* * Transform NSView coordinates to CoreGraphics coordinates. @@ -588,16 +588,16 @@ UpdateControlValues( TkScrollbar *scrollPtr) /* Scrollbar data struct. */ { MacScrollbar *msPtr = (MacScrollbar *) scrollPtr; Tk_Window tkwin = scrollPtr->tkwin; - MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); + MacDrawable *macWin = (MacDrawable *)Tk_WindowId(scrollPtr->tkwin); double dViewSize; HIRect contrlRect; short width, height; - NSView *view = TkMacOSXDrawableView(macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(macWin); CGFloat viewHeight = [view bounds].size.height; NSRect frame; frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); @@ -660,11 +660,11 @@ /* *-------------------------------------------------------------- * * ScrollbarEvent -- * - * This procedure is invoked in response to , + * This procedure is invoked in response to